ellisran пре 21 часа
родитељ
комит
3a2e96e4cb

+ 20 - 1
app/controller/contract_controller.js

@@ -699,6 +699,7 @@ module.exports = app => {
                 const cid = ctx.params.cid;
                 const cid = ctx.params.cid;
                 if (!cid) throw '参数有误';
                 if (!cid) throw '参数有误';
                 const cpid = parseInt(ctx.params.cpid);
                 const cpid = parseInt(ctx.params.cpid);
+                const csid = parseInt(ctx.params.csid);
                 const parts = this.ctx.multipart({
                 const parts = this.ctx.multipart({
                     autoFields: true,
                     autoFields: true,
                 });
                 });
@@ -712,7 +713,7 @@ module.exports = app => {
                     }
                     }
                     const fileInfo = path.parse(stream.filename);
                     const fileInfo = path.parse(stream.filename);
                     const headpath = ctx.contractOptions.spid ? `sp/contract/${ctx.contractOptions.spid}` : `app/public/upload/${ctx.contractOptions.tid}`;
                     const headpath = ctx.contractOptions.spid ? `sp/contract/${ctx.contractOptions.spid}` : `app/public/upload/${ctx.contractOptions.tid}`;
-                    const filepath = `${headpath}/contract/${cid}${cpid ? '/pay/' + cpid : ''}/fujian_${create_time + idx.toString() + fileInfo.ext}`;
+                    const filepath = `${headpath}/contract/${cid}${cpid ? '/pay/' + cpid : (csid ? '/supplement/' + csid : '')}/fujian_${create_time + idx.toString() + fileInfo.ext}`;
                     // await ctx.helper.saveStreamFile(stream, path.resolve(this.app.baseDir, 'app', filepath));
                     // await ctx.helper.saveStreamFile(stream, path.resolve(this.app.baseDir, 'app', filepath));
                     await ctx.app.fujianOss.put(ctx.app.config.fujianOssFolder + filepath, stream);
                     await ctx.app.fujianOss.put(ctx.app.config.fujianOssFolder + filepath, stream);
                     files.push({ filepath, name: stream.filename, ext: fileInfo.ext });
                     files.push({ filepath, name: stream.filename, ext: fileInfo.ext });
@@ -742,6 +743,9 @@ module.exports = app => {
                     if (cpid) {
                     if (cpid) {
                         newFile.cpid = cpid;
                         newFile.cpid = cpid;
                     }
                     }
+                    if (csid) {
+                        newFile.csid = csid;
+                    }
                     return newFile;
                     return newFile;
                 });
                 });
                 if (cpid) {
                 if (cpid) {
@@ -749,6 +753,11 @@ module.exports = app => {
                     await ctx.service.contractPayAtt.saveFileMsgToDb(payload);
                     await ctx.service.contractPayAtt.saveFileMsgToDb(payload);
                     // 将最新的当前标段的所有文件信息返回
                     // 将最新的当前标段的所有文件信息返回
                     responseData.data = await ctx.service.contractPayAtt.getAtt(cpid);
                     responseData.data = await ctx.service.contractPayAtt.getAtt(cpid);
+                } else if (csid) {
+                    // 执行文件信息写入数据库
+                    await ctx.service.contractSupplementAtt.saveFileMsgToDb(payload);
+                    // 将最新的当前标段的所有文件信息返回
+                    responseData.data = await ctx.service.contractSupplementAtt.getAtt(csid);
                 } else {
                 } else {
                     // 执行文件信息写入数据库
                     // 执行文件信息写入数据库
                     await ctx.service.contractAtt.saveFileMsgToDb(payload);
                     await ctx.service.contractAtt.saveFileMsgToDb(payload);
@@ -770,12 +779,15 @@ module.exports = app => {
         async deleteFile(ctx) {
         async deleteFile(ctx) {
             try {
             try {
                 const cpid = ctx.params.cpid;
                 const cpid = ctx.params.cpid;
+                const csid = ctx.params.csid;
                 const cid = ctx.params.cid;
                 const cid = ctx.params.cid;
                 const responseData = { err: 0, msg: '', data: {} };
                 const responseData = { err: 0, msg: '', data: {} };
                 const data = JSON.parse(ctx.request.body.data);
                 const data = JSON.parse(ctx.request.body.data);
                 let fileInfo = null;
                 let fileInfo = null;
                 if (cpid) {
                 if (cpid) {
                     fileInfo = await ctx.service.contractPayAtt.getDataById(data.id);
                     fileInfo = await ctx.service.contractPayAtt.getDataById(data.id);
+                } else if (csid) {
+                    fileInfo = await ctx.service.contractSupplementAtt.getDataById(data.id);
                 } else if (cid) {
                 } else if (cid) {
                     fileInfo = await ctx.service.contractAtt.getDataById(data.id);
                     fileInfo = await ctx.service.contractAtt.getDataById(data.id);
                 } else {
                 } else {
@@ -788,6 +800,8 @@ module.exports = app => {
                     // 再删除数据库
                     // 再删除数据库
                     if (cpid) {
                     if (cpid) {
                         await ctx.service.contractPayAtt.delete(data.id);
                         await ctx.service.contractPayAtt.delete(data.id);
+                    } else if (csid) {
+                        await ctx.service.contractSupplementAtt.delete(data.id);
                     } else {
                     } else {
                         await ctx.service.contractAtt.delete(data.id);
                         await ctx.service.contractAtt.delete(data.id);
                     }
                     }
@@ -796,6 +810,8 @@ module.exports = app => {
                 }
                 }
                 if (cpid) {
                 if (cpid) {
                     responseData.data = await ctx.service.contractPayAtt.getAtt(cpid);
                     responseData.data = await ctx.service.contractPayAtt.getAtt(cpid);
+                } else if (csid) {
+                    responseData.data = await ctx.service.contractSupplementAtt.getAtt(csid);
                 } else {
                 } else {
                     responseData.data = await ctx.service.contractAtt.getAtt(cid);
                     responseData.data = await ctx.service.contractAtt.getAtt(cid);
                 }
                 }
@@ -816,10 +832,13 @@ module.exports = app => {
             if (id) {
             if (id) {
                 try {
                 try {
                     const cpid = ctx.params.cpid;
                     const cpid = ctx.params.cpid;
+                    const csid = ctx.params.csid;
                     const cid = ctx.params.cid;
                     const cid = ctx.params.cid;
                     let fileInfo = null;
                     let fileInfo = null;
                     if (cpid) {
                     if (cpid) {
                         fileInfo = await ctx.service.contractPayAtt.getDataById(id);
                         fileInfo = await ctx.service.contractPayAtt.getDataById(id);
+                    } else if (csid) {
+                        fileInfo = await ctx.service.contractSupplementAtt.getDataById(id);
                     } else if (cid) {
                     } else if (cid) {
                         fileInfo = await ctx.service.contractAtt.getDataById(id);
                         fileInfo = await ctx.service.contractAtt.getDataById(id);
                     } else {
                     } else {

+ 24 - 17
app/public/js/contract_detail.js

@@ -403,20 +403,20 @@ $(document).ready(function() {
                 if (node.settle_code) {
                 if (node.settle_code) {
                     $('#add_contract_supplement_btn').hide();
                     $('#add_contract_supplement_btn').hide();
                     if (need) {
                     if (need) {
-                        $('#htsupplement-table tbody').find('.pay-edit').hide();
-                        $('#htsupplement-table tbody').find('.pay-del').hide();
+                        $('#htsupplement-table tbody').find('.supplement-edit').hide();
+                        $('#htsupplement-table tbody').find('.supplement-del').hide();
                     }
                     }
                 } else {
                 } else {
                     if ((node.uid === user_id || permission_edit_contract) && (!shenpi_status || (shenpi_status && node.status === auditConst.status.checked))) $('#add_contract_supplement_btn').show();
                     if ((node.uid === user_id || permission_edit_contract) && (!shenpi_status || (shenpi_status && node.status === auditConst.status.checked))) $('#add_contract_supplement_btn').show();
                     if (need && contractSupplements && contractSupplements.length > 0) {
                     if (need && contractSupplements && contractSupplements.length > 0) {
                         for (const [i, cp] of contractSupplements.entries()) {
                         for (const [i, cp] of contractSupplements.entries()) {
                             if (cp.uid === user_id && (!shenpi_status || (shenpi_status && (cp.status === auditConst.status.uncheck || cp.status === auditConst.status.checkNo)))) {
                             if (cp.uid === user_id && (!shenpi_status || (shenpi_status && (cp.status === auditConst.status.uncheck || cp.status === auditConst.status.checkNo)))) {
-                                $('#htsupplement-table tbody tr').eq(i).find('.pay-edit').show();
-                                $('#htsupplement-table tbody tr').eq(i).find('.pay-del').show();
+                                $('#htsupplement-table tbody tr').eq(i).find('.supplement-edit').show();
+                                $('#htsupplement-table tbody tr').eq(i).find('.supplement-del').show();
                             } else if (shenpi_status && cp.status === auditConst.status.checked && is_admin) {
                             } else if (shenpi_status && cp.status === auditConst.status.checked && is_admin) {
-                                $('#htsupplement-table tbody tr').eq(i).find('.pay-del').show();
+                                $('#htsupplement-table tbody tr').eq(i).find('.supplement-del').show();
                             } else if (shenpi_status && (cp.status === auditConst.status.checking || cp.status === auditConst.status.checkNoPre) && cp.curAuditorIds && cp.curAuditorIds.length > 0 && cp.curAuditorIds.indexOf(user_id) !== -1) {
                             } else if (shenpi_status && (cp.status === auditConst.status.checking || cp.status === auditConst.status.checkNoPre) && cp.curAuditorIds && cp.curAuditorIds.length > 0 && cp.curAuditorIds.indexOf(user_id) !== -1) {
-                                $('#htsupplement-table tbody tr').eq(i).find('.pay-edit').show();
+                                $('#htsupplement-table tbody tr').eq(i).find('.supplement-edit').show();
                             }
                             }
                         }
                         }
                     }
                     }
@@ -431,19 +431,25 @@ $(document).ready(function() {
             this.setContractFiles(supplement.files, supplement.cid, supplement.id, '#cons-supplement-file table tbody');
             this.setContractFiles(supplement.files, supplement.cid, supplement.id, '#cons-supplement-file table tbody');
         },
         },
         checkCloseStatus: function (node) {
         checkCloseStatus: function (node) {
+            let have_uncheck = false;
             if (pay_shenpi_status) {
             if (pay_shenpi_status) {
-                let have_uncheck = false;
                 for (const pay of contractPays) {
                 for (const pay of contractPays) {
                     if (pay.status !== auditConst.status.checked) {
                     if (pay.status !== auditConst.status.checked) {
                         have_uncheck = true;
                         have_uncheck = true;
                         break;
                         break;
                     }
                     }
                 }
                 }
-                if (have_uncheck) {
-                    $('a[href*="#cons-close"]').hide();
-                } else if ((node.uid === user_id || permission_edit_contract) && !node.settle_code) {
-                    $('a[href*="#cons-close"]').show();
+            }
+            if (!have_uncheck && shenpi_status) {
+                for (const supplement of contractSupplements) {
+                    if (supplement.status !== auditConst.status.checked) {
+                        have_uncheck = true;
+                        break;
+                    }
                 }
                 }
+            }
+            if (have_uncheck) {
+                $('a[href*="#cons-close"]').hide();
             } else if ((node.uid === user_id || permission_edit_contract) && !node.settle_code) {
             } else if ((node.uid === user_id || permission_edit_contract) && !node.settle_code) {
                 $('a[href*="#cons-close"]').show();
                 $('a[href*="#cons-close"]').show();
             }
             }
@@ -489,7 +495,7 @@ $(document).ready(function() {
                 }
                 }
                 $('#shenpi_btn').html(shenpi_html);
                 $('#shenpi_btn').html(shenpi_html);
                 if (node.uid === user_id || permission_edit_contract) {
                 if (node.uid === user_id || permission_edit_contract) {
-                    contractTreeSpreadObj.changeContractTab(node);
+                    contractTreeSpreadObj.changeContractTab(node, true);
                 } else {
                 } else {
                     $('#edit_contract_btn').hide();
                     $('#edit_contract_btn').hide();
                     $('#save_contract_btn').hide();
                     $('#save_contract_btn').hide();
@@ -515,7 +521,7 @@ $(document).ready(function() {
                     $('a[href*="#cons-unlock"]').hide();
                     $('a[href*="#cons-unlock"]').hide();
                     contractTreeSpreadObj.checkCloseStatus(node);
                     contractTreeSpreadObj.checkCloseStatus(node);
                 }
                 }
-                contractTreeSpreadObj.changeContractTab(node);
+                contractTreeSpreadObj.changeContractTab(node, true);
             } else {
             } else {
                 $('#edit_contract_btn').hide();
                 $('#edit_contract_btn').hide();
                 $('#save_contract_btn').hide();
                 $('#save_contract_btn').hide();
@@ -621,7 +627,8 @@ $(document).ready(function() {
             newSupplements.forEach((supplement, idx) => {
             newSupplements.forEach((supplement, idx) => {
                 const shenpi_html = setSupplementShenpiHtml(supplement, false, node);
                 const shenpi_html = setSupplementShenpiHtml(supplement, false, node);
                 const operationHtml = `<a href="javascript:void(0);" class="text-primary supplement-edit" data-id="${supplement.id}" ${!supplement.showEdit ? `style="display:none"` : ''}>编辑</a> <a href="javascript:void(0);" class="text-danger supplement-del" data-id="${supplement.id}" ${!supplement.showDel ? `style="display:none"` : ''}>删除</a>`;
                 const operationHtml = `<a href="javascript:void(0);" class="text-primary supplement-edit" data-id="${supplement.id}" ${!supplement.showEdit ? `style="display:none"` : ''}>编辑</a> <a href="javascript:void(0);" class="text-danger supplement-del" data-id="${supplement.id}" ${!supplement.showDel ? `style="display:none"` : ''}>删除</a>`;
-                supplementsHtml += `<tr class="text-center" data-cpid="${supplement.id}">
+                supplementsHtml += `<tr class="text-center" data-csid="${supplement.id}">
+                                        <td>${idx + 1}</td>
                                         <td>${supplement.code}</td>
                                         <td>${supplement.code}</td>
                                         <td>${supplement.name}</td>
                                         <td>${supplement.name}</td>
                                         <td>${supplement.price}</td>
                                         <td>${supplement.price}</td>
@@ -2245,8 +2252,8 @@ $(document).ready(function() {
         $('#cons-addsupplement input[name="price"]').val(csInfo ? csInfo.price : '');
         $('#cons-addsupplement input[name="price"]').val(csInfo ? csInfo.price : '');
         $('#cons-addsupplement input[name="party_a"]').val(csInfo ? csInfo.party_a : '');
         $('#cons-addsupplement input[name="party_a"]').val(csInfo ? csInfo.party_a : '');
         $('#cons-addsupplement input[name="party_b"]').val(csInfo ? csInfo.party_b : '');
         $('#cons-addsupplement input[name="party_b"]').val(csInfo ? csInfo.party_b : '');
-        $('#cons-addsupplement input[name="sign_time"]').val(csInfo ? moment(csInfo.sign_time).format('YYYY-MM-DD') : '');
-        signTime.selectDate(csInfo ? new Date(csInfo.sign_time) : '');
+        $('#cons-addsupplement input[name="sign_time"]').val(csInfo && csInfo.sign_time ? moment(csInfo.sign_time).format('YYYY-MM-DD') : '');
+        signTime.selectDate(csInfo && csInfo.sign_time ? new Date(csInfo.sign_time) : '');
         $('#cons-addsupplement textarea[name="content"]').val(csInfo ? csInfo.content : '');
         $('#cons-addsupplement textarea[name="content"]').val(csInfo ? csInfo.content : '');
         if (only_sf_edit) {
         if (only_sf_edit) {
             // 用readOnly
             // 用readOnly
@@ -2286,7 +2293,7 @@ $(document).ready(function() {
             return;
             return;
         }
         }
         const csid = $('#cons-supplement-file input[name="csid"]').val();
         const csid = $('#cons-supplement-file input[name="csid"]').val();
-        const csInfo = _.find(contractsupplements, { id: parseInt(csid) });
+        const csInfo = _.find(contractSupplements, { id: parseInt(csid) });
         if (!csInfo) {
         if (!csInfo) {
             toastr.warning('请选择补充合同再上传文件');
             toastr.warning('请选择补充合同再上传文件');
             $('#cons-supplement-file input[type="file"]').val('');
             $('#cons-supplement-file input[type="file"]').val('');

+ 6 - 0
app/router.js

@@ -339,6 +339,9 @@ module.exports = app => {
     app.post('/sp/:id/contract/tender/:tid/col-set', sessionAuth, subProjectCheck, contractCheck, 'contractController.colSet');
     app.post('/sp/:id/contract/tender/:tid/col-set', sessionAuth, subProjectCheck, contractCheck, 'contractController.colSet');
     app.post('/sp/:id/contract/tender/:tid/detail/check', sessionAuth, subProjectCheck, contractCheck, 'contractController.checkAudit');
     app.post('/sp/:id/contract/tender/:tid/detail/check', sessionAuth, subProjectCheck, contractCheck, 'contractController.checkAudit');
     app.post('/sp/:id/contract/tender/:tid/detail/:type/check', sessionAuth, subProjectCheck, contractCheck, 'contractController.checkAudit');
     app.post('/sp/:id/contract/tender/:tid/detail/:type/check', sessionAuth, subProjectCheck, contractCheck, 'contractController.checkAudit');
+    app.post('/sp/:id/contract/tender/:tid/detail/:type/:cid/supplement/:csid/file/upload', sessionAuth, subProjectCheck, contractCheck, 'contractController.uploadFile');
+    app.post('/sp/:id/contract/tender/:tid/detail/:type/:cid/supplement/:csid/file/delete', sessionAuth, subProjectCheck, contractCheck, 'contractController.deleteFile');
+    app.get('/sp/:id/contract/tender/:tid/detail/:type/:cid/supplement/:csid/file/:fid/download', sessionAuth, subProjectCheck, contractCheck, 'contractController.downloadFile');
     // 项目合同管理
     // 项目合同管理
     app.get('/sp/:id/contract', sessionAuth, subProjectCheck, contractCheck, 'contractController.detail');
     app.get('/sp/:id/contract', sessionAuth, subProjectCheck, contractCheck, 'contractController.detail');
     app.post('/sp/:id/contract/audit/save', sessionAuth, subProjectCheck, contractCheck, 'contractController.auditSave');
     app.post('/sp/:id/contract/audit/save', sessionAuth, subProjectCheck, contractCheck, 'contractController.auditSave');
@@ -363,6 +366,9 @@ module.exports = app => {
     app.get('/sp/:id/contract/tender/setting', sessionAuth, subProjectCheck, 'contractController.setting');
     app.get('/sp/:id/contract/tender/setting', sessionAuth, subProjectCheck, 'contractController.setting');
     app.get('/sp/:id/contract/setting/shenpi', sessionAuth, subProjectCheck, 'contractController.shenpiSet');
     app.get('/sp/:id/contract/setting/shenpi', sessionAuth, subProjectCheck, 'contractController.shenpiSet');
     app.post('/sp/:id/contract/setting/update', sessionAuth, subProjectCheck, 'contractController.updateSetting');
     app.post('/sp/:id/contract/setting/update', sessionAuth, subProjectCheck, 'contractController.updateSetting');
+    app.post('/sp/:id/contract/detail/:type/:cid/supplement/:csid/file/upload', sessionAuth, subProjectCheck, contractCheck, 'contractController.uploadFile');
+    app.post('/sp/:id/contract/detail/:type/:cid/supplement/:csid/file/delete', sessionAuth, subProjectCheck, contractCheck, 'contractController.deleteFile');
+    app.get('/sp/:id/contract/detail/:type/:cid/supplement/:csid/file/:fid/download', sessionAuth, subProjectCheck, contractCheck, 'contractController.downloadFile');
 
 
 
 
     // 资料归集-列表
     // 资料归集-列表

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

@@ -267,7 +267,7 @@
                                 <table class="table table-sm table-bordered" id="htsupplement-table" style="display: none;">
                                 <table class="table table-sm table-bordered" id="htsupplement-table" style="display: none;">
                                     <thead>
                                     <thead>
                                     <tr class="text-center" id="supplement-header">
                                     <tr class="text-center" id="supplement-header">
-                                        <th width="5%" sort="code">编号</th><th width="10%">名称</th><th width="7%">金额</th><th width="10%">甲方</th><th width="10%">乙方</th><th width="5%">签订日期</th><th width="5%">签订地点</th><th width="5%">创建人</th><th width="9%" sort="create_time">创建时间</th><th width="15%">补充原因及内容</th><th width="4%">附件</th>
+                                        <th width="3%">序号</th><th width="5%" sort="code">编号</th><th width="10%">名称</th><th width="7%">金额</th><th width="10%">甲方</th><th width="10%">乙方</th><th width="5%">签订时间</th><th width="5%">签订地点</th><th width="5%">创建人</th><th width="9%" sort="create_time">创建时间</th><th width="15%">补充原因及内容</th><th width="4%">附件</th>
                                         <% if (shenpi_status) { %>
                                         <% if (shenpi_status) { %>
                                             <th width="15%">审批进度</th>
                                             <th width="15%">审批进度</th>
                                         <% } %>
                                         <% } %>

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

@@ -271,11 +271,11 @@
                 </div>
                 </div>
                 <div class="form-group">
                 <div class="form-group">
                     <label>甲方</label>
                     <label>甲方</label>
-                    <input class="form-control form-control-sm" name="name" placeholder="" type="text">
+                    <input class="form-control form-control-sm" name="party_a" placeholder="" type="text">
                 </div>
                 </div>
                 <div class="form-group">
                 <div class="form-group">
                     <label>乙方</label>
                     <label>乙方</label>
-                    <input class="form-control form-control-sm" name="name" placeholder="" type="text">
+                    <input class="form-control form-control-sm" name="party_b" placeholder="" type="text">
                 </div>
                 </div>
                 <div class="form-group form-group-sm">
                 <div class="form-group form-group-sm">
                     <label>签订时间</label>
                     <label>签订时间</label>