浏览代码

合同管理功能完善

ellisran 1 月之前
父节点
当前提交
015815930c

+ 10 - 6
app/public/js/contract_detail.js

@@ -6,7 +6,7 @@ $(document).ready(function() {
         cols: [
             {title: '编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 100, formatter: '@', readOnly: 'readOnly.code', cellType: 'tree'},
             {title: '合同编号', colSpan: '1', rowSpan: '2', field: 'c_code', hAlign: 0, width: 120, formatter: '@', readOnly: true},
-            {title: '项目名称/合同名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 240, formatter: '@', readOnly: 'readOnly.code', cellType: 'ellipsisAutoTip', scrollHeightClass: '.sjs-height-1'},
+            {title: '项目名称/合同名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 360, formatter: '@', readOnly: 'readOnly.code', wordWrap: true},
             {title: '创建人', colSpan: '1', rowSpan: '2', field: 'username', hAlign: 1, width: 80, formatter: '@', readOnly: true},
             {title: '合同金额', colSpan: '1', rowSpan: '2', field: 'total_price', hAlign: 2, width: 120, formatter: '@', readOnly: true},
         ],
@@ -425,6 +425,7 @@ $(document).ready(function() {
                     $('a[href*="#cons-unlock"]').hide();
                     $('a[href*="#cons-close"]').hide();
                     $('a[href*="#cons-upfile"]').hide();
+                    if (node && node.c_code && $('.bc-bar .nav li .active').attr('href') === '#htfile' && permission_att) $('a[href*="#cons-upfile"]').show();
                     $('#add_contract_pay_btn').hide();
                 }
             } else {
@@ -437,6 +438,7 @@ $(document).ready(function() {
                 $('a[href*="#cons-unlock"]').hide();
                 $('a[href*="#cons-close"]').hide();
                 $('a[href*="#cons-upfile"]').hide();
+                if (node && node.c_code && $('.bc-bar .nav li .active').attr('href') === '#htfile' && permission_att) $('a[href*="#cons-upfile"]').show();
                 $('#add_contract_pay_btn').hide();
             }
         },
@@ -1153,8 +1155,10 @@ $(document).ready(function() {
 
     $('.bc-bar ul li a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
         const node = SpreadJsObj.getSelectObject(contractSheet);
-        if (node && node.c_code && node.uid === user_id) {
-            contractTreeSpreadObj.changeContractTab(node, true);
+        $('a[href*="#cons-upfile"]').hide();
+        if (node && node.c_code) {
+            if ($('.bc-bar .nav li .active').attr('href') === '#htfile' && permission_att) $('a[href*="#cons-upfile"]').show();
+            if (node.uid === user_id) contractTreeSpreadObj.changeContractTab(node, true);
         }
     });
 
@@ -1652,7 +1656,7 @@ $(document).ready(function() {
                 uids.push(parseInt($(this).parents('tr').data('id')));
             });
             if (uids.length === 0) {
-                toastr.warning('请选择要除的成员');
+                toastr.warning('请选择要除的成员');
                 return;
             }
             deleteAfterHint(function () {
@@ -1667,7 +1671,7 @@ $(document).ready(function() {
                     contractTreeAudits = result;
                     sqTreeSpreadObj.setTreeAudits(sqSheet);
                 });
-            }, '确认除「当前节点已勾选授权用户」?');
+            }, '确认除「当前节点已勾选授权用户」?');
         });
 
         $('body').on('click', '#empower .del-tree-audit', function () {
@@ -1963,7 +1967,7 @@ $(document).ready(function() {
             toastr.error('请选择一个合同节点');
             return;
         }
-        if (node.uid !== user_id) {
+        if (node.uid !== user_id && !permission_att) {
             $('#cons-pay-file .upload-permission').hide();
         } else {
             $('#cons-pay-file .upload-permission').show();

+ 1 - 0
app/service/contract_audit.js

@@ -144,6 +144,7 @@ module.exports = app => {
                                 permission_edit: user.permission.edit,
                                 permission_show_unit: user.permission.showUnit,
                                 permission_show_node: user.permission.showNode,
+                                permission_att: user.permission_att,
                                 create_time: new Date(),
                             });
                         }

+ 10 - 7
app/service/contract_tree.js

@@ -656,11 +656,11 @@ module.exports = app => {
             if (!count) count = 1;
             const selects = await this.getDataByKidAndCount(options, kid, count);
             if (!selects) throw '降级节点数据错误';
-            if (this._.findIndex(selects, function (item) {
-                return item.c_code;
-            }) !== -1) {
-                throw '存在合同节点不可降级';
-            }
+            // if (this._.findIndex(selects, function (item) {
+            //     return item.c_code;
+            // }) !== -1) {
+            //     throw '存在合同节点不可降级';
+            // }
             const first = selects[0], last = selects[count - 1];
             const pre = await this.getDataByParentAndOrder(options, first[this.setting.pid], first[this.setting.order] - 1);
             if (!pre) throw '节点不可降级';
@@ -685,7 +685,7 @@ module.exports = app => {
                         updateData[this.setting.fullPath] = s[this.setting.fullPath].substring(0, index-1) + '-' + pre[this.setting.kid] + '-' + s[this.setting.kid];
                     }
                     newPath.push(updateData[this.setting.fullPath]);
-                    await transaction.update(this.tableName, updateData);
+                    s.c_code ? await transaction.update(this.ctx.service.contract.tableName, updateData) : await transaction.update(this.tableName, updateData);
                     // 选中节点--全部子节点(含孙) level++, fullPath
                     await this._syncDownlevelChildren(options, s, updateData[this.setting.fullPath], transaction);
                 }
@@ -705,7 +705,10 @@ module.exports = app => {
             for (const p of newPath) {
                 updateData = updateData.concat(await this.getDataByFullPath(options, p + '-%'));
             }
-            updateData = updateData.concat(await this.getDataById(selects.map(x => { return x.id; })));
+            const contractSelects = selects.filter(x => x.c_code);
+            const treeSelects = selects.filter(x => !x.c_code);
+            updateData = updateData.concat(await this.getDataById(treeSelects.map(x => { return x.id; })));
+            updateData = updateData.concat(await this.ctx.service.contract.getDataById(contractSelects.map(x => { return x.id; })));
             // 选中节点--原前兄弟节点&全部后兄弟节点
             return { update: updateData };
         }

+ 7 - 0
app/service/sub_proj_permission.js

@@ -52,6 +52,7 @@ module.exports = app => {
                     node: { title: '授权节点下查看本节点合同', value: 3 },
                     unit: { title: '授权节点下查看本单位合同', value: 4 },
                     view: { title: '查看所有合同', value: 5 },
+                    att: { title: '上传附件', value: 6 },
                 },
                 fund_trans: {
                     view: { title: '查看', value: 1 },
@@ -410,6 +411,7 @@ module.exports = app => {
                     permission_edit: permission.permission_edit,
                     permission_show_node: permission.permission_show_node,
                     permission_show_unit: permission.permission_show_unit,
+                    permission_att: permission.permission_att,
                 });
             }
             return list;
@@ -429,12 +431,16 @@ module.exports = app => {
             if (newContractPermission.permission_show_unit !== undefined) {
                 oldPermission.permission_show_unit = newContractPermission.permission_show_unit;
             }
+            if (newContractPermission.permission_att !== undefined) {
+                oldPermission.permission_att = newContractPermission.permission_att;
+            }
             const permissionArr = [];
             if (oldPermission.permission_edit) permissionArr.push(1);
             if (oldPermission.permission_add) permissionArr.push(2);
             if (oldPermission.permission_show_node) permissionArr.push(3);
             if (oldPermission.permission_show_unit) permissionArr.push(4);
             if (!oldPermission.permission_show_unit && !oldPermission.permission_show_node) permissionArr.push(5);
+            if (oldPermission.permission_att) permissionArr.push(6);
             return permissionArr.join(',');
         }
 
@@ -444,6 +450,7 @@ module.exports = app => {
                 permission_add: cp.indexOf(2) !== -1 ? 1: 0,
                 permission_show_node: cp.indexOf(3) !== -1 ? 1: 0,
                 permission_show_unit: cp.indexOf(4) !== -1 ? 1: 0,
+                permission_att: cp.indexOf(6) !== -1 ? 1: 0,
             };
             return permission;
         }

+ 1 - 0
app/view/contract/detail.ejs

@@ -194,6 +194,7 @@
     const is_admin = <%- ctx.session.sessionUser.is_admin %>;
     const permission_edit = <%- (ctx.session.sessionUser.is_admin || audit_permission.permission_edit) %>;
     const permission_add = <%- (ctx.session.sessionUser.is_admin || audit_permission.permission_add) %>;
+    const permission_att = <%- (ctx.session.sessionUser.is_admin || audit_permission.permission_att) %>;
     const contract_type = <%- contract_type %>;
     const whiteList = JSON.parse(unescape('<%- escape(JSON.stringify(whiteList)) %>'));
     const contractConst = JSON.parse(unescape('<%- escape(JSON.stringify(contractConst)) %>'));

+ 1 - 1
app/view/contract/detail_modal.ejs

@@ -71,7 +71,7 @@
                                         </dl>
                                     </div>
                                 </div>
-                                <div class="ml-2"><a href="javascript:void(0);" id="batch-del-audits" class="text-danger">批量除</a></div>
+                                <div class="ml-2"><a href="javascript:void(0);" id="batch-del-audits" class="text-danger">批量除</a></div>
                             </div>
                             <div class="modal-height-500" style="overflow-y:auto;">
                                 <table class="table table-bordered text-center">

+ 4 - 0
app/view/contract/modal.ejs

@@ -70,6 +70,7 @@
                         <th rowspan="2" class="align-middle">编辑节点</th>
                         <th rowspan="2" class="align-middle">添加合同</th>
                         <th colspan="2">授权节点合同查看范围</th>
+                        <th rowspan="2" class="align-middle">上传附件</th>
                         <th rowspan="2" class="align-middle">操作</th>
                     </tr>
                     <tr>
@@ -224,6 +225,9 @@
                                 <input type="checkbox" class="permission-checkbox" data-type="permission_show_node" value="${ca.uid}" ${ca.permission_show_node ? 'checked' : ''}>
                             </td>
                             <td>
+                                <input type="checkbox" class="permission-checkbox" data-type="permission_att" value="${ca.uid}" ${ca.permission_att ? 'checked' : ''}>
+                            </td>
+                            <td>
                                 <a href="#del-contract-audit" data-toggle="modal" data-target="#del-contract-audit" class="btn btn-outline-danger btn-sm ml-1 del-contract-audit-a" data-id="${ca.uid}">移除</a>
                             </td>
                         </tr>`;

+ 4 - 1
sql/update.sql

@@ -11,6 +11,9 @@ ALTER TABLE `zh_sub_project_permission`
 ADD COLUMN `tp_cache` json NULL COMMENT '金额概况缓存' AFTER `payment_permission`,
 ADD COLUMN `tp_cache_time` timestamp NULL COMMENT '缓存时间' AFTER `tp_cache`;
 
+ALTER TABLE `zh_contract_audit`
+ADD COLUMN `permission_att` tinyint(1) NULL DEFAULT 0 COMMENT '上传附件' AFTER `permission_show_node`;
+
 ------------------------------------
 -- 表数据
-------------------------------------
+------------------------------------