Bläddra i källkod

报表报错及变更附件删除权限

ellisran 10 månader sedan
förälder
incheckning
5dd043531a

+ 1 - 0
app/const/account_permission.js

@@ -41,6 +41,7 @@ const permission = {
         type: 'checkbox',
         children: [
             { title: '变更意向', value: 1, hint: '开启该选项,变更立项可新建变更意向书', hintIcon: 'fa-question-circle' },
+            { title: '删除附件', value: 2, hint: '开启该选项,可删除审批通过前自己上传的附件', hintIcon: 'fa-question-circle' },
         ],
     },
     material: {

+ 10 - 1
app/controller/change_controller.js

@@ -424,6 +424,10 @@ module.exports = app => {
                         }
                     }
                 }
+                const accountInfo = await this.ctx.service.projectAccount.getDataById(this.ctx.session.sessionUser.accountId);
+                const userPermission = accountInfo !== undefined && accountInfo.permission !== ''
+                    ? JSON.parse(accountInfo.permission) : null;
+                const deleteFilePermission = userPermission && userPermission.change !== undefined && userPermission.change.indexOf('2') !== -1;
 
                 // 工程变更类别读取
                 const projectData = await ctx.service.project.getDataById(ctx.session.sessionProject.id);
@@ -467,6 +471,7 @@ module.exports = app => {
                     settleBills,
                     settlePos,
                     removeSettleNum,
+                    deleteFilePermission,
                 };
                 // 获取是否已存在调用变更令
                 let changeUsedData = await ctx.service.stageChange.getAllFinalUsedData(ctx.tender.id, change.cid);
@@ -1224,7 +1229,11 @@ module.exports = app => {
                 if (!fileInfo || !Object.keys(fileInfo).length) {
                     throw '该文件不存在';
                 }
-                if (!fileInfo.extra_upload && change.status === audit.change.status.checked) {
+                const accountInfo = await this.ctx.service.projectAccount.getDataById(this.ctx.session.sessionUser.accountId);
+                const userPermission = accountInfo !== undefined && accountInfo.permission !== ''
+                    ? JSON.parse(accountInfo.permission) : null;
+                const deleteFilePermission = userPermission && userPermission.change !== undefined && userPermission.change.indexOf('2') !== -1;
+                if (!fileInfo.extra_upload && change.status === audit.change.status.checked && !deleteFilePermission) {
                     throw '无权限删除';
                 }
                 if (fileInfo !== undefined && fileInfo !== '') {

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

@@ -724,7 +724,7 @@ function getAllList(currPageNum = 1) {
         <td>${moment(att.in_time * 1000).format('YYYY-MM-DD')}<br>${bytesToSize(att.filesize)}</td>
         <td>
             <a href="/change/download/file/${att.id}" class="mr-2" title="下载"><span class="fa fa-download text-primary"></span></a>`
-        html += (att.uid === accountId && (changeStatus === auditConst.status.checked ? Boolean(att.extra_upload) : true)) ?
+        html += (att.uid === accountId && ((changeStatus === auditConst.status.checked ? Boolean(att.extra_upload) : true)) || deleteFilePermission) ?
             `<a href="javascript:void(0)" class="mr-2 delete-file" data-attid="${att.id}" title="删除附件"><span class="fa fa-trash text-danger"></span></a>` : '';
         html += `</td>`;
     }

+ 2 - 1
app/view/change/information.ejs

@@ -369,7 +369,7 @@
                                                 <td><%- moment(att.in_time * 1000).format('YYYY-MM-DD') %><br><%- ctx.helper.bytesToSize(att.filesize) %></td>
                                                 <td>
                                                     <a href="/change/download/file/<%- att.id %>" class="mr-2" title="下载"><span class="fa fa-download text-primary"></span></a>
-                                                    <% if (att.uid === ctx.session.sessionUser.accountId && (change.status === auditConst.status.checked ? Boolean(att.extra_upload) : true )) { %>
+                                                    <% if (att.uid === ctx.session.sessionUser.accountId && ((change.status === auditConst.status.checked ? Boolean(att.extra_upload) : true ) || deleteFilePermission)) { %>
                                                         <a href="javascript:void(0)" class="mr-2 delete-file" data-attid="<%- att.id %>" title="删除附件"><span class="fa fa-trash text-danger"></span></a>
                                                     <% } %>
                                                 </td>
@@ -477,6 +477,7 @@
 <script>
     const tenderName = JSON.parse(unescape('<%- escape(JSON.stringify(tender.data.name)) %>'));
     const tenderId = '<%- tender.id %>';
+    const deleteFilePermission = <%- deleteFilePermission %>;
     const totalPriceUnit = '<%- tpUnit %>';
     const unitPriceUnit = '<%- upUnit %>';
     const accountId = parseInt('<%- ctx.session.sessionUser.accountId %>');

+ 4 - 4
app/view/report/index_archive.ejs

@@ -475,17 +475,17 @@
             $("#optionSelectableAdvancePays").append(str);
         }
         if (needClick) {
-            changeCurrentAdvancePays($("#optionSelectableAdvancePays a")[0]);
+            changeCurrentAdvancePays($("#optionSelectableAdvancePays a")[0], !needClick);
         }
     }
 
-    function changeCurrentAdvancePays(ele) {
+    function changeCurrentAdvancePays(ele, refresh = true) {
         $('#optionSelectableAdvancePays a').show();
         $(ele).hide();
-        current_advance_id = +ele.attributes[3].value;
+        current_advance_id = ele ? +ele.attributes[3].value : -1;
         $('#optionSelectableAdvancePays').siblings('button').text($(ele).text());
         // BUSINESS_ID = material_id;
-        buildAdvancePaySelection(current_advance_type);
+        if (refresh) buildAdvancePaySelection(current_advance_type);
         //还有必要触发归档报表刷新!
         //rptArchiveObj.onClick(null, null, rptArchiveObj.currentNode);
         const params = {tenderId: TENDER_ID, business_type, bzId: current_advance_id};