Pārlūkot izejas kodu

计量台账、中间计量、合同支付,附件删除功能调整

MaiXinRong 10 mēneši atpakaļ
vecāks
revīzija
5781b2e76f

+ 5 - 1
app/controller/stage_controller.js

@@ -28,6 +28,7 @@ const stdConst = require('../const/standard');
 const LzString = require('lz-string');
 const spreadSetting = require('../lib/spread_setting');
 const funSetConst = require('../const/fun_set');
+const PermissionCheck = require('../const/account_permission').PermissionCheck;
 
 module.exports = app => {
     class StageController extends app.BaseController {
@@ -188,6 +189,7 @@ module.exports = app => {
                 renderData.hintMinusCb = projectFunInfo.banMinusChangeBills && ctx.tender.info.ledger_check.banMinusChangeBills;
                 renderData.categoryData = await ctx.service.category.getAllCategory(this.ctx.session.sessionProject.id);
                 renderData.settleStatus = ctx.service.settle.settleStatus;
+                renderData.deleteFilePermission = PermissionCheck.delFile(this.ctx.session.sessionUser.permission);
                 await this.layout('stage/index.ejs', renderData, 'stage/modal.ejs');
             } catch (err) {
                 this.log(err);
@@ -1033,6 +1035,7 @@ module.exports = app => {
 
                 const projectFunInfo = await this.ctx.service.project.getFunRela(ctx.session.sessionProject.id);
                 renderData.lockPayExpr = projectFunInfo.lockPayExpr;
+                renderData.deleteFilePermission = PermissionCheck.delFile(this.ctx.session.sessionUser.permission);
 
                 if (!ctx.stage.readOnly || ctx.tender.isTourist) {
                     // 计算 本期金额
@@ -1794,13 +1797,14 @@ module.exports = app => {
             };
             try {
                 this._checkStageCanModifyRe(ctx);
+                const deleteFilePermission = PermissionCheck.delFile(this.ctx.session.sessionUser.permission);
 
                 const data = JSON.parse(ctx.request.body.data);
                 const fileInfo = await ctx.service.stageAtt.getDataById(data.id);
                 if (!fileInfo || !Object.keys(fileInfo).length) {
                     throw '该文件不存在';
                 }
-                if (!fileInfo.extra_upload && ctx.stage.status === auditConst.status.checked) {
+                if (!fileInfo.extra_upload && ctx.stage.status === auditConst.status.checked && !deleteFilePermission) {
                     throw '无权限删除';
                 }
                 if (fileInfo !== undefined && fileInfo !== '') {

+ 1 - 1
app/public/js/ledger.js

@@ -4719,7 +4719,7 @@ $(document).ready(function() {
           $('#showAttachment').hide();
           $('#showAttachment').attr('file-id', '');
       });
-  })
+  });
 });
 // 生成当前节点列表
 function getNodeList(node) {

+ 37 - 6
app/public/js/stage.js

@@ -122,12 +122,15 @@ function getAllList(currPageNum = 1) {
     let html = '';
     // '/tender/' + tender.id + '/measure/stage/' + stage.order + '/download/file/' + att.id
     for(const att of currPageAttData) {
+        const delHtml = deleteFilePermission && parseInt(cur_uid) === att.uid
+            ? `<a class="ml-1 text-danger" href="javascript:void(0)" name="att-delete" file-id="${att.id}"><i class="fa fa-close" title="删除"></i></a>`
+            : '';
         html += `<tr>
         <td width="25"><input type="checkbox" class="check-file" file-id=${att.id}></td>
         <td>
         <div class="d-flex">
-            <a href="javascript:void(0)" class="pl-0 col-11 att-file-name" file-id=${att.id}>${att.filename}${att.fileext}</a>
-            <a href="/tender/${tender.id}/measure/stage/${stage.order}/download/file/${att.id}" class="col-1 pl-0 att-file-btn"><i class="fa fa-download"></i></a>
+            <a href="javascript:void(0)" class="pl-0 col-10 att-file-name" file-id=${att.id}>${att.filename}${att.fileext}</a>
+            <div class="att-file-btn col-2"><a href="/tender/${tender.id}/ledger/download/file/${att.id}" class="pl-0"><i class="fa fa-download"></i></a>${delHtml}</div>
         </div>
         </td><td>${att.username}</td></tr>`
     }
@@ -135,20 +138,23 @@ function getAllList(currPageNum = 1) {
     $('#alllist-table').on('click', 'tr', function() {
         $('#alllist-table tr').removeClass('bg-light')
         $(this).addClass('bg-light')
-    })
+    });
 }
 // 生成当前节点列表
 function getNodeList(node) {
     let html = '';
     for(const att of attData) {
         if (node === att.lid) {
+            const delHtml = deleteFilePermission && parseInt(cur_uid) === att.uid
+                ? `<a class="ml-1 text-danger" href="javascript:void(0)" name="att-delete" file-id="${att.id}"><i class="fa fa-close" title="删除"></i></a>`
+                : '';
             // html += '<tr><td><a href="javascript:void(0)" file-id="'+ att.id +'">'+ att.filename + att.fileext +'</a></td><td>'+ att.username +'</td></tr>';
             html += `<tr>
             <td width="25"><input type="checkbox" class="check-file" file-id=${att.id}></td>
             <td>
             <div class="d-flex">
-                <a href="javascript:void(0)" class="pl-0 col-11 att-file-name" file-id=${att.id}>${att.filename}${att.fileext}</a>
-                <a href="/tender/${tender.id}/measure/stage/${stage.order}/download/file/${att.id}" class="col-1 pl-0 att-file-btn"><i class="fa fa-download"></i></a>
+                <a href="javascript:void(0)" class="pl-0 col-10 att-file-name" file-id=${att.id}>${att.filename}${att.fileext}</a>
+                <div class="att-file-btn col-2"><a href="/tender/${tender.id}/ledger/download/file/${att.id}" class="pl-0"><i class="fa fa-download"></i></a>${delHtml}</div>
             </div>
             </td><td>${att.username}</td></tr>`
         }
@@ -3151,7 +3157,7 @@ $(document).ready(() => {
             let html = [];
             if (data.attachment) {
                 for (const att of data.attachment) {
-                    const delHtml = (parseInt(att.uid) === userID && (att.renew || stage.status !== auditConst.status.checked))
+                    const delHtml = (parseInt(att.uid) === userID && (att.renew || stage.status !== auditConst.status.checked || deleteFilePermission))
                         ? '<a class="delete-att text-danger ml-1" href="javascript:void(0);" data-imid="'+ data.att_uuid +'" data-attid="'+ att.file_id +'" title="删除"><i class="fa fa-remove "></i></a>'
                         : '';
                     const viewHtml = att.viewpath ? `<a class="ml-1" href="${att.viewpath}" target="_blank" title="预览"><i class="fa fa-eye"></i></a>` : '';
@@ -5320,6 +5326,31 @@ $(document).ready(() => {
             stageAssistRela.refreshAssistTable();
         });
     });
+    $('body').on('click', 'a[name=att-delete]', function() {
+        const fid = this.getAttribute('file-id');
+        if (!fid) return;
+
+        const node = SpreadJsObj.getSelectObject(slSpread.getActiveSheet());
+        const data = {id: fid};
+        postData('/tender/' + tender.id + '/measure/stage/' + stage.order + '/delete/file', data, function (result) {
+            // 删除到attData中
+            const att_index = attData.findIndex(function (item) {
+                return item.id === parseInt(fid);
+            });
+            attData.splice(att_index, 1);
+            // 重新生成List
+
+            if ($('#alllist-table tr').length === 1) {
+                getAllList(parseInt($('#currentPage').text()) - 1);
+
+            } else {
+                getAllList(parseInt($('#currentPage').text()));
+            }
+            getNodeList(node.id);
+            $('#showAttachment').hide();
+            $('#showAttachment').attr('file-id', '');
+        });
+    });
 });
 function makeOneShouFang(sf) {
     const lData = _.find(ledgerData, { id: sf.lid });

+ 1 - 1
app/public/js/stage_pay.js

@@ -34,7 +34,7 @@ function makeAttTable(payNode) {
     let html = '';
     if (attachment !== null) {
         for (const att of attachment) {
-            const delhtml = uploadPermission && parseInt(att.uid) === userID && (att.renew || stage.status !== auditConst.status.checked)
+            const delhtml = uploadPermission && parseInt(att.uid) === userID && (att.renew || stage.status !== auditConst.status.checked || deleteFilePermission)
                 ? '<a class="delete-att text-danger" href="javascript:void(0);" data-fileid="'+ att.id +'" title="删除"><i class="fa fa-remove "></i></a>'
                 : '';
             html += '<tr><td style="width: 200px">' + att.filename + att.fileext + '</td><td>' + att.username + '</td><td>' + att.in_time + '</td>' +

+ 1 - 0
app/view/stage/index.ejs

@@ -557,6 +557,7 @@
     let currPageFileData = [];
     const settleStatus = JSON.parse('<%- JSON.stringify(settleStatus) %>');
     const contractExpr = <%- !!ctx.session.sessionProject.page_show.openContractExpr %>;
+    const deleteFilePermission = <%- deleteFilePermission %>;
 </script>
 <style>
 

+ 1 - 0
app/view/stage/pay.ejs

@@ -70,4 +70,5 @@
     const preGatherTp = <%- (pre.gather_tp || 0) %>;
     const auditConst = JSON.parse('<%- JSON.stringify(auditConst) %>');
     const lockPayExpr = <%- lockPayExpr %>;
+    const deleteFilePermission = <%- deleteFilePermission %>;
 </script>