Merge remote-tracking branch 'origin/master'

This commit is contained in:
zhangzq
2026-03-18 11:31:10 +08:00
8 changed files with 984 additions and 568 deletions

View File

@@ -235,11 +235,13 @@ class Contract extends Common
$insert_info['contract_category']= $param['contract_category'];
}
if($param['contract_url'] == ''){
// 先检查键是否存在,再判断值是否为空
if (!isset($param['contract_url']) || $param['contract_url'] == '') {
$insert_info['contract_url'] = '';
}else{
$insert_info['contract_url'] = $param['contract_url'];
$insert_info['contract_file_name'] = $param['contract_file_name'];
} else {
$insert_info['contract_url'] = $param['contract_url'];
// 同理contract_file_name 也建议做存在性检查,避免同理报错
$insert_info['contract_file_name'] = isset($param['contract_file_name']) ? $param['contract_file_name'] : '';
}
db('contract_info')->insert($insert_info);
return $this->sendSuccess('添加成功');
@@ -320,4 +322,109 @@ class Contract extends Common
return $this->sendError('删除失败');
}
}
// 合同检索
public function searchContracts()
{
$param = request()->param();
$currPage = isset($param['currPage']) ? $param['currPage'] : 1;
$pageSize = isset($param['pageSize']) ? $param['pageSize'] : 20;
// 构建查询条件
$where = ['del_time' => null];
// 时间范围筛选
if (isset($param['start_date']) && !empty($param['start_date'])) {
$where['create_time'] = ['>=', $param['start_date']];
}
if (isset($param['end_date']) && !empty($param['end_date'])) {
if (isset($where['create_time'])) {
$where['create_time'] = [
['>=', $param['start_date']],
['<=', $param['end_date']]
];
} else {
$where['create_time'] = ['<=', $param['end_date']];
}
}
// 合同分类筛选
if (isset($param['contract_category']) && $param['contract_category'] !== '' && $param['contract_category'] !== '0') {
$where['contract_category'] = $param['contract_category'];
}
// 查询合同列表
$contractList = db('contract_info')
->where($where)
->order('contract_id', 'desc')
->page($currPage, $pageSize)
->select();
// 遍历合同列表,补充关联信息
foreach ($contractList as &$contract) {
// 获取合同类型名称
if ($contract['contract_type']) {
$contractType = db('contract_type')
->where('type_id', $contract['contract_type'])
->field('type_name')
->find();
$contract['contract_type_name'] = $contractType ? $contractType['type_name'] : '';
} else {
$contract['contract_type_name'] = '';
}
// 获取合同分类名称
switch ($contract['contract_category']) {
case 1:
$contract['contract_category_name'] = '销售合同';
break;
case 2:
$contract['contract_category_name'] = '销售技术协议';
break;
case 3:
$contract['contract_category_name'] = '采购合同';
break;
case 4:
$contract['contract_category_name'] = '采购及技术协议';
break;
case 5:
$contract['contract_category_name'] = '其他';
break;
default:
$contract['contract_category_name'] = '';
}
// 获取项目名称
if ($contract['project_id']) {
$project = db('project_info')
->where('project_id', $contract['project_id'])
->field('project_name')
->find();
$contract['project_name'] = $project ? $project['project_name'] : '';
} else {
$contract['project_name'] = '';
}
// 获取合作伙伴名称
if ($contract['partner_id']) {
$partner = db('partner_company')
->where('company_id', $contract['partner_id'])
->field('company_name')
->find();
$contract['partner_name'] = $partner ? $partner['company_name'] : '';
} else {
$contract['partner_name'] = '';
}
}
unset($contract);
// 查询总记录数
$total = db('contract_info')->where($where)->count();
$res['list'] = $contractList;
$res['total'] = $total;
return $this->sendSuccess($res);
}
}

View File

@@ -321,6 +321,7 @@ class User extends Common
$ret['company'] = "苏州维达奇智能科技有限公司";
}
$ret['id'] = $login_id;
$ret['name'] = $res['user_name'];
}
//客户
if (2 == $res['user_type'])
@@ -332,6 +333,7 @@ class User extends Common
->field('i.contacts_name as name, i.contacts_idcard as idcard, c.company_name as company')
->find();
$ret['id'] = $login_id;
$ret['name'] = $res['user_name'];
}
}

View File

@@ -19,7 +19,7 @@ return [
// 用户名
'username' => 'root',
// 密码
'password' => '123456',
'password' => '12356',
// 端口
'hostport' => '',
// 连接dsn

View File

@@ -1,7 +1,7 @@
module.exports = {
NODE_ENV: '"development"',
ENV_CONFIG: '"dev"',
BASE_WMS_API: '"http://47.111.78.178:8011/api"',
BASE_WMS_FILE: '"http://47.111.78.178:8011/"'
BASE_WMS_API: '"http://127.0.0.1:8080/api"',
BASE_WMS_FILE: '"http://127.0.0.1:8080/"'
// 47.101.147.253
}

View File

@@ -1,8 +1,8 @@
module.exports = {
NODE_ENV: '"production"',
ENV_CONFIG: '"prod"',
BASE_WMS_API: '"http://47.111.78.178:8011/api"',
BASE_WMS_FILE: '"http://47.111.78.178:8011/"'
BASE_WMS_API: '"http://127.0.0.1:8080/api"',
BASE_WMS_FILE: '"http://127.0.0.1:8080/"'
////BASE_AGV_API: '"http://192.168.3.223:55200/v1"',
//BASE_WMS_API: '"http://169.254.71.103/api"',
//BASE_AGV_API: '"http://127.0.0.1:55200/v1"',

View File

@@ -90,5 +90,14 @@ export default {
method: 'post',
data: param
})
},
// 合同检索
searchContracts(param) {
return request({
url: `/Contract/searchContracts`,
method: 'post',
data: param
})
}
}

View File

@@ -8,53 +8,321 @@
<div>
<el-form :inline="true" :model="queryParam" class="form-inline" style="margin-left: 10px;margin-top: 10px;">
<el-form-item label="时间范围">
<el-date-picker style="width:100%" v-model="busTime" type="daterange" :editable="false"
range-separator="" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd" clearable
:picker-options="executeTimeOptions">
</el-date-picker>
<el-date-picker
v-model="busTime"
:editable="false"
:picker-options="executeTimeOptions"
style="width:100%"
type="daterange"
range-separator=""
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="yyyy-MM-dd"
clearable/>
</el-form-item>
<el-form-item label="合同类">
<el-select v-model="map_idx" filterable placeholder="合同类">
<el-option label="全部合同" value="0"></el-option>
<el-option label="项目合同" value="1"></el-option>
<el-option label="运营合同" value="2"></el-option>
<el-form-item label="合同类">
<el-select v-model="queryParam.contract_category" filterable placeholder="合同类">
<el-option label="全部合同" value="0"/>
<el-option label="销售合同" value="1"/>
<el-option label="销售技术协议" value="2"/>
<el-option label="采购合同" value="3"/>
<el-option label="采购及技术协议" value="4"/>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSubmit">查询</el-button>
<el-button @click="onReset">重置</el-button>
</el-form-item>
</el-form>
</div>
</el-card>
</el-row>
<!-- 合同列表表格 -->
<el-row style="margin-top: 20px;">
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>合同列表</span>
<span style="float: right;"> {{ total }} 条记录</span>
</div>
<el-table
v-loading="loading"
:data="contractList"
style="width: 100%"
stripe
border>
<el-table-column
prop="contract_number"
label="合同编号"
width="150"/>
<el-table-column
prop="contract_name"
label="合同名称"
width="200"/>
<el-table-column
prop="contract_type_name"
label="合同类型"
width="120"/>
<el-table-column
prop="contract_category_name"
label="合同分类"
width="120"/>
<el-table-column
prop="project_name"
label="所属项目"
width="150">
<template slot-scope="scope">
{{ scope.row.project_name || '-' }}
</template>
</el-table-column>
<el-table-column
prop="partner_name"
label="合作伙伴"
width="150">
<template slot-scope="scope">
{{ scope.row.partner_name || '-' }}
</template>
</el-table-column>
<el-table-column
prop="contract_price"
label="合同金额"
width="120">
<template slot-scope="scope">
¥{{ scope.row.contract_price | currency }}
</template>
</el-table-column>
<el-table-column
prop="create_time"
label="签署时间"
width="120"/>
<el-table-column
prop="contract_des"
label="合同描述"
min-width="200">
<template slot-scope="scope">
{{ scope.row.contract_des || '-' }}
</template>
</el-table-column>
<el-table-column
label="操作"
width="100"
fixed="right">
<template slot-scope="scope">
<el-button
v-if="scope.row.contract_url"
type="text"
size="small"
@click="viewContract(scope.row)">
查看
</el-button>
<span v-else>-</span>
</template>
</el-table-column>
<template slot="empty">
<div style="padding: 20px;">
<i class="el-icon-document" style="font-size: 48px; color: #ddd;"/>
<p style="margin-top: 10px; color: #999;">暂无合同数据</p>
</div>
</template>
</el-table>
<!-- 分页组件 -->
<div style="margin-top: 20px; text-align: right;">
<el-pagination
:current-page="currentPage"
:page-sizes="[10, 20, 50, 100]"
:page-size="pageSize"
:total="total"
layout="total, sizes, prev, pager, next, jumper"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"/>
</div>
</el-card>
</el-row>
<!-- 显示文件对话框 -->
<el-dialog :visible.sync="dialogVisibleShowFile" title="文件信息" width="80%" append-to-body>
<img v-if="isImage" :src="previewUrl" alt="Preview" style="max-width: 40%; max-height: 30%;">
<iframe v-else-if="isPDF" :src="previewUrl" frameborder="0" style="width: 100%; height: 600px;"/>
<div v-else>
<p>该文件类型{{ fileExtension }}需要下载后查看</p>
<el-button type="primary" @click="downloadFile(previewUrl)">
立即下载 {{ fileExtension.toUpperCase() }} 文件
</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
export default {
data() {
import contractApi from '@/api/contract'
export default {
filters: {
currency(value) {
if (!value) return '0.00'
return Number(value).toLocaleString('zh-CN', {
minimumFractionDigits: 2,
maximumFractionDigits: 2
})
}
},
data() {
return {
queryParam:
{
busTime: [],
map_idx: "16",
lock: "2",
storage_type: "0",
work_type: "0"
}, //查询条件
};
queryParam: {
contract_category: '0'
},
busTime: [],
contractList: [],
loading: false,
// 分页相关
currentPage: 1,
pageSize: 10,
total: 0,
// 文件预览相关
dialogVisibleShowFile: false,
previewUrl: '',
currentFileName: '',
fileExtension: '',
isImage: false,
isPDF: false,
executeTimeOptions: {
shortcuts: [{
text: '最近一周',
onClick(picker) {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
picker.$emit('pick', [start, end])
}
}, {
text: '最近一个月',
onClick(picker) {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
picker.$emit('pick', [start, end])
}
}, {
text: '最近三个月',
onClick(picker) {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
picker.$emit('pick', [start, end])
}
}]
}
}
},
mounted() {
},
created() {
this.loadContracts()
},
methods: {
onSubmit() {
this.currentPage = 1
this.loadContracts()
},
onReset() {
this.queryParam.contract_category = '0'
this.busTime = []
this.currentPage = 1
this.loadContracts()
},
// 分页大小改变
handleSizeChange(val) {
this.pageSize = val
this.currentPage = 1 // 重置到第一页
this.loadContracts()
},
// 当前页改变
handleCurrentChange(val) {
this.currentPage = val
this.loadContracts()
},
async loadContracts() {
this.loading = true
try {
const params = {
contract_category: this.queryParam.contract_category,
page: this.currentPage,
pageSize: this.pageSize
}
// 添加时间范围参数
if (this.busTime && this.busTime.length === 2) {
params.start_date = this.busTime[0]
params.end_date = this.busTime[1]
}
const response = await contractApi.searchContracts(params)
// 处理响应数据 - 兼容两种可能的响应结构
const apiResponse = response.data || response
if (apiResponse.code === 20000) {
const data = apiResponse.data
this.contractList = Array.isArray(data.list) ? data.list : []
this.total = parseInt(data.total) || 0
if (this.contractList.length === 0) {
this.$message.info('未找到符合条件的合同数据')
}
} else {
this.$message.error(apiResponse.msg || '查询失败')
this.contractList = []
this.total = 0
}
} catch (error) {
console.error('查询合同失败:', error)
this.$message.error('查询失败,请稍后重试')
this.contractList = []
this.total = 0
} finally {
this.loading = false
}
},
viewContract(row) {
if (!row.contract_url) {
this.$message.warning('该合同暂无文件')
return
}
const url = row.contract_url
const ext = url.split('.').pop().toLowerCase()
this.currentFileName = row.contract_file_name || row.contract_name
this.isImage = false
this.isPDF = false
this.fileExtension = ext
// 构建完整的文件URL
const baseUrl = process.env.BASE_WMS_FILE || (
process.env.NODE_ENV === 'development'
? 'http://localhost/oms/back/public'
: window.location.origin + '/back/public'
)
if (['jpg', 'jpeg', 'png'].includes(ext)) {
this.previewUrl = baseUrl + url
this.isImage = true
} else if (ext === 'pdf') {
this.previewUrl = baseUrl + url
this.isPDF = true
} else {
this.previewUrl = baseUrl + url
}
this.dialogVisibleShowFile = true
},
downloadFile(url) {
const link = document.createElement('a')
link.href = url
link.setAttribute('download', this.currentFileName)
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
}
}
}

File diff suppressed because it is too large Load Diff