diff --git a/app/contract/controller/Index.php b/app/contract/controller/Index.php index 5b6808f..1100fcb 100644 --- a/app/contract/controller/Index.php +++ b/app/contract/controller/Index.php @@ -264,6 +264,15 @@ class Index extends BaseController $is_create_admin = 1; } + $file_array_other = Db::name('ContractFile') + ->field('cf.id,f.filepath,f.name,f.filesize,f.fileext') + ->alias('cf') + ->join('File f', 'f.id = cf.file_id', 'LEFT') + ->order('cf.create_time asc') + ->where(array('cf.contract_id' => $id, 'cf.delete_time' => 0)) + ->select()->toArray(); + $detail['file_array_other'] = $file_array_other; + $check_record = Db::name('FlowRecord')->field('f.*,a.name,a.thumb') ->alias('f') ->join('Admin a', 'a.id = f.check_user_id', 'left') @@ -283,6 +292,7 @@ class Index extends BaseController $vv['status_str'] = '撤销'; } } + View::assign('is_check_admin', $is_check_admin); View::assign('is_create_admin', $is_create_admin); View::assign('check_record', $check_record); diff --git a/app/contract/model/Contract.php b/app/contract/model/Contract.php index 87aa98e..6377831 100644 --- a/app/contract/model/Contract.php +++ b/app/contract/model/Contract.php @@ -77,15 +77,7 @@ class Contract extends Model public function detail($id) { $detail = self::where(['id' => $id])->find(); - if (!empty($detail)) { - $file_array = Db::name('ContractFile') - ->field('cf.id,f.filepath,f.name,f.filesize,f.fileext') - ->alias('cf') - ->join('File f', 'f.id = cf.file_id', 'LEFT') - ->order('cf.create_time asc') - ->where(array('cf.contract_id' => $id, 'cf.delete_time' => 0)) - ->select()->toArray(); - + if (!empty($detail)) { $detail['status_name'] = self::$Status[(int) $detail['check_status']]; $detail['archive_status_name'] = self::$ArchiveStatus[(int) $detail['archive_status']]; $detail['sign_time'] = date('Y-m-d', $detail['sign_time']); @@ -125,7 +117,11 @@ class Contract extends Model if($detail['pid']>0){ $detail['pname'] = self::where(['id' => $detail['pid']])->value('name'); } - $detail['file_array'] = $file_array; + + if($detail['file_ids'] !=''){ + $fileArray = Db::name('File')->where('id','in',$detail['file_ids'])->select(); + $detail['fileArray'] = $fileArray; + } } return $detail; } diff --git a/app/contract/model/ContractLog.php b/app/contract/model/ContractLog.php index 63812ec..1242388 100644 --- a/app/contract/model/ContractLog.php +++ b/app/contract/model/ContractLog.php @@ -45,6 +45,7 @@ class ContractLog extends Model 'check_status' => '状态', 'status' => '状态', 'archive_status' => '归档状态', + 'file_ids' => '合同附件', 'file' => '合同附件', 'remark' => '备注信息', 'new' => '新增', diff --git a/app/contract/view/index/add.html b/app/contract/view/index/add.html index 7b0014d..28d95e4 100644 --- a/app/contract/view/index/add.html +++ b/app/contract/view/index/add.html @@ -111,37 +111,49 @@ 合同签订人* - - - +
+ +
+
+ + 合同签订时间* - 合同签订部门 - - - - - 合同制定人* + + 合同保管人* 合同共享人员 - + + 相关附件 + + + + + + +
+ +
+ + + 备注信息 @@ -162,9 +174,9 @@ {block name="script"} {/block} diff --git a/app/contract/view/index/edit.html b/app/contract/view/index/edit.html index 41e7c6c..a57c1dc 100644 --- a/app/contract/view/index/edit.html +++ b/app/contract/view/index/edit.html @@ -102,35 +102,61 @@ 合同签订人* - - - +
+ +
+
部门:{$detail.sign_department}
+ + 合同签订时间* - 合同签订部门 - - - - - 合同制定人* + + 合同保管人* 合同共享人员 - + + + + 相关附件 + + + + + + +
+ + {notempty name="$detail.file_ids"} + {volist name="$detail.fileArray" id="vo"} +
+
+ +
{$vo.name}
+
+ + +
+
+
+ {/volist} + {/notempty} +
+ 备注信息 @@ -154,9 +180,9 @@ {block name="script"} diff --git a/app/install/data/gouguoa.sql b/app/install/data/gouguoa.sql index 1e33af5..5e18334 100644 --- a/app/install/data/gouguoa.sql +++ b/app/install/data/gouguoa.sql @@ -1581,6 +1581,7 @@ CREATE TABLE `oa_contract` ( `sign_uid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '合同签订人', `keeper_uid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '合同保管人', `share_ids` varchar(500) NOT NULL DEFAULT '' COMMENT '共享人员,如:1,2,3', + `file_ids` varchar(500) NOT NULL DEFAULT '' COMMENT '相关附件,如:1,2,3', `sign_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '合同签订时间', `sign_did` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '合同签订部门', `cost` decimal(15, 2) NOT NULL DEFAULT 0.00 COMMENT '合同金额', diff --git a/public/static/assets/gougu/module/oaTool.js b/public/static/assets/gougu/module/oaTool.js index 0f3a7e2..105230a 100644 --- a/public/static/assets/gougu/module/oaTool.js +++ b/public/static/assets/gougu/module/oaTool.js @@ -21,6 +21,7 @@ layui.define(['tool'], function (exports) { addFile: function (options) { let that = this; let settings = { + type:0, btn: 'uploadBtn', box: 'fileBox', url: "/api/index/upload", @@ -28,40 +29,58 @@ layui.define(['tool'], function (exports) { exts: 'png|jpg|gif|jpeg|doc|docx|ppt|pptx|xls|xlsx|pdf|zip|rar|7z', //只允许上传文件格式 colmd:4, isSave:false, - ajaxSave:function(val){} + ajaxSave:function(val){}, + ajaxDelete:function(val){} }; let opts = $.extend({}, settings, options); - //虚拟删除 - $('#'+opts.box).on('click', '.btn-delete', function () { - let file_id = $(this).data('id'); - let idsStr = $('#'+opts.box+'Input').val(),idsArray = []; - if (idsStr != '') { - idsArray = idsStr.split(","); - } - idsArray.remove(file_id); - $('#'+opts.box+'Input').val(idsArray.join(',')); - $('#fileItem' + file_id).remove(); - }) - - //ajax删除 - $('#'+opts.box).on('click', '.ajax-delete', function () { - let file_id = $(this).data('id'); - let idsStr = $('#'+opts.box+'Input').val(),idsArray = []; - if (idsStr != '') { - idsArray = idsStr.split(","); - } - idsArray.remove(file_id); - layer.confirm('确定删除该附件吗?', { - icon: 3, - title: '提示' - }, function(index) { - if (typeof (opts.ajaxSave) == "function") { - opts.ajaxSave(idsArray.join(',')); + if(opts.type==0){ + //虚拟删除 + $('#'+opts.box).on('click', '.btn-delete', function () { + let file_id = $(this).data('id'); + let idsStr = $('#'+opts.box+'Input').val(),idsArray = []; + if (idsStr != '') { + idsArray = idsStr.split(","); } - layer.close(index); - }); - }) + idsArray.remove(file_id); + $('#'+opts.box+'Input').val(idsArray.join(',')); + $('#fileItem' + file_id).remove(); + }) + + //ajax删除 + $('#'+opts.box).on('click', '.ajax-delete', function () { + let file_id = $(this).data('id'); + let idsStr = $('#'+opts.box+'Input').val(),idsArray = []; + if (idsStr != '') { + idsArray = idsStr.split(","); + } + idsArray.remove(file_id); + layer.confirm('确定删除该附件吗?', { + icon: 3, + title: '提示' + }, function(index) { + if (typeof (opts.ajaxSave) == "function") { + opts.ajaxSave(idsArray.join(',')); + } + layer.close(index); + }); + }) + } + if(opts.type==1){ + //ajax删除 + $('#'+opts.box).on('click', '.ajax-delete', function () { + let file_id = $(this).data('id'); + layer.confirm('确定删除该附件吗?', { + icon: 3, + title: '提示' + }, function(index) { + if (typeof (opts.ajaxSave) == "function") { + opts.ajaxDelete(file_id); + } + layer.close(index); + }); + }) + } //多附件上传 upload.render({ @@ -74,31 +93,86 @@ layui.define(['tool'], function (exports) { layer.msg(res.msg); if (res.code == 0) { //上传成功 - let idsStr = $('#'+opts.box+'Input').val(),idsArray = []; - if (idsStr != '') { - idsArray = idsStr.split(","); - } - idsArray.push(res.data.id); - $('#'+opts.box+'Input').val(idsArray.join(',')); - let temp = `
-
- -
${res.data.name}
-
- - + if(opts.type==0){ + let idsStr = $('#'+opts.box+'Input').val(),idsArray = []; + if (idsStr != '') { + idsArray = idsStr.split(","); + } + idsArray.push(res.data.id); + $('#'+opts.box+'Input').val(idsArray.join(',')); + let temp = `
+
+ +
${res.data.name}
+
+ + +
-
-
`; - $('#'+opts.box).append(temp); - - if (typeof (opts.ajaxSave) == "function" && opts.isSave ==true) { - opts.ajaxSave(idsArray.join(',')); +
`; + $('#'+opts.box).append(temp); + + if (typeof (opts.ajaxSave) == "function" && opts.isSave ==true) { + opts.ajaxSave(idsArray.join(',')); + } + } + if(opts.type==1){ + if (typeof (opts.ajaxSave) == "function" && opts.isSave ==true) { + opts.ajaxSave(res); + } } } } }); - }, + }, + customerPicker:function(callback){ + var customeTable; + layer.open({ + title: '选择客户', + area: ['600px', '580px'], + type: 1, + content: '
\ +
\ +
\ + \ +
\ + \ +
\ +
', + success: function () { + customeTable = table.render({ + elem: '#customerTable' + , url: '/contract/api/get_customer' + , page: true //开启分页 + , limit: 10 + , cols: [[ + { type: 'radio', title: '选择' } + , { field: 'id', width: 100, title: '编号', align: 'center' } + , { field: 'name', title: '客户名称' } + ]] + }); + //客户搜索提交 + form.on('submit(search_customer)', function (data) { + customeTable.reload({ where: { keywords: data.field.keywords }, page: { curr: 1 } }); + return false; + }); + }, + btn: ['确定'], + btnAlign: 'c', + yes: function () { + var checkStatus = table.checkStatus(customeTable.config.id); + var data = checkStatus.data; + if (data.length > 0) { + callback(data[0]); + layer.closeAll(); + } + else { + layer.msg('请先选择客户'); + return false; + } + } + }) + }, contractPicker:function(callback){ var contractTable; layer.open({ @@ -110,7 +184,7 @@ layui.define(['tool'], function (exports) {
\ \
\ - \ + \ \
', success: function () { @@ -126,7 +200,7 @@ layui.define(['tool'], function (exports) { ]] }); //项目搜索提交 - form.on('submit(search_form)', function (data) { + form.on('submit(search_contract)', function (data) { contractTable.reload({ where: { keywords: data.field.keywords }, page: { curr: 1 } }); return false; }); @@ -149,12 +223,24 @@ layui.define(['tool'], function (exports) { } }; + + //选择客户 + $('body').on('click','.picker-customer',function () { + let that = $(this); + let callback = function(data){ + that.val(data.name); + that.next.val(data.id); + } + obj.customerPicker(callback); + }); + + //选择合同 $('body').on('click','.picker-contract',function () { let that = $(this); let callback = function(data){ - that.val(data[0].name); - that.next.val(data[0].id); + that.val(data.name); + that.next.val(data.id); } obj.contractPicker(callback); });