Explorar el Código

feat: 材料调差附件删除权限优化

lanjianrong hace 4 años
padre
commit
6aa796175d
Se han modificado 3 ficheros con 18 adiciones y 7 borrados
  1. 2 0
      app/controller/material_controller.js
  2. 13 7
      app/public/js/material_file.js
  3. 3 0
      sql/update.sql

+ 2 - 0
app/controller/material_controller.js

@@ -876,6 +876,7 @@ module.exports = app => {
                 const files = [];
                 const create_time = Date.parse(new Date()) / 1000;
                 let idx = 0;
+                const extra_upload = ctx.material.status === auditConst.status.checked;
                 while ((stream = await parts()) !== undefined) {
                     if (!stream.filename) {
                         // 如果没有传入直接返回
@@ -906,6 +907,7 @@ module.exports = app => {
                         file_size: ctx.helper.bytesToSize(idx === 'isString' ? parts.field.size : parts.field.size[idx]),
                         file_name: file.name,
                         fileext: file.ext,
+                        extra_upload,
                     };
                     return newFile;
                 });

+ 13 - 7
app/public/js/material_file.js

@@ -117,16 +117,18 @@ $(document).ready(function () {
     })
     // 生成所有附件列表
     function getAllList(currPageNum = 1) {
+        const isCheckAll = $('#dropdownMenuButton').attr('btn-type') === 'all'
          // 未选中checkbox,需要过滤出来当前期的数据
-        const filterFileData = fileData && fileData.filter(file => file.mid === parseInt(mid) && file.tid === parseInt(tid))
-        const total = calcCount(filterFileData);
+        const filterFileData = fileData && isCheckAll ? fileData : fileData.filter(file => file.mid === parseInt(mid) && file.tid === parseInt(tid))
+        const total = calcCount();
         // 总页数
         const pageNum = Math.ceil(total/pageCount);
         // 当前页附件内容
-        const currPageAttData = fileData && $('#dropdownMenuButton').attr('type') === 'all' ? fileData.slice((currPageNum-1)*pageCount, currPageNum*pageCount) : filterFileData.map((v, index) => {
+        const currPageAttData = fileData && isCheckAll ? fileData.slice((currPageNum-1)*pageCount, currPageNum*pageCount) : filterFileData.map((v, index) => {
             return {...v, index }
         }).slice((currPageNum-1)*pageCount, currPageNum*pageCount);
 
+        console.log(currPageAttData)
         renderHtml(currPageAttData)
         // 渲染分页器
         renderPagination(currPageNum, pageNum)
@@ -212,7 +214,7 @@ $(document).ready(function () {
             <td>${fileInfo.file_size}</td>
             <td>第${fileInfo.s_order}期</td>
             <td>${fileInfo.upload_time}</td>`
-            if (fileInfo.canDel ) {
+            if (fileInfo.showDel ) {
                 html += `<td>
                 <a href="/${fileInfo.filepath}" class="btn btn-light btn-sm" title="下载"><span class="fa fa-download text-primary"></span></a>
                 <a href="javascript:void(0);" class="btn btn-light btn-sm delete-file" data-attid="${fileInfo.id}" title="删除附件">
@@ -263,22 +265,26 @@ $(document).ready(function () {
             let showDel = false
             // 只判断当前期,因为以往期都是只读的
             if (file.mid === parseInt(mid) && file.tid === parseInt(tid) && file.user_id === parseInt(cur_uid)) {
+                if (materialStatus === auditConst.status.checked) {
+                    showDel = Boolean(file.extra_upload )
+                } else {
+                    showDel = true
+                }
                 // if (!curAuditor) {
                 //     materialStatus === auditConst.status.uncheck && parseInt(cur_uid) === materialUid && (showDel = true)
                 //     materialStatus === auditConst.status.checkNo && parseInt(cur_uid) === materialUid && (showDel = true)
                 // } else {
                 //     curAuditor.aid === parseInt(cur_uid) && (showDel = true)
                 // }
-                showDel = true
             }
-            return showDel ? {...file, canDel: true, index} : {...file, index}
+            return {...file, index, showDel}
         })
     };
 
     function calcCount() {
         // 附件总数
         let total = fileData && fileData.length;
-        if(!$('#file-checkbox').is(':checked')) {
+        if(!$('#dropdownMenuButton').attr('btn-type') === 'all') {
             total = fileData && fileData.filter(file => file.mid === parseInt(mid) && file.tid === parseInt(tid)).length
         }
         return total

+ 3 - 0
sql/update.sql

@@ -2,3 +2,6 @@ ALTER TABLE `zh_s2b_proj`
 ADD COLUMN `common_option`  text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '通用配置' AFTER `dagl_option`;
 
 ALTER TABLE `zh_tender_info` ADD `shenpi` VARCHAR(1000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '审批流程设置' AFTER `pay_account`;
+
+ALTER TABLE `zh_material_file`
+ADD COLUMN `extra_upload` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否是审核完成后上传的,0:否、1:是' AFTER `fileext`;