Explorar el Código

fix: 材料调差附件序号问题

lanjianrong hace 4 años
padre
commit
640372e7e7

+ 1 - 1
app/controller/advance_controller.js

@@ -423,7 +423,7 @@ module.exports = app => {
             try {
                 const { id } = JSON.parse(ctx.request.body.data);
                 const fileInfo = await ctx.service.advanceFile.getDataById(id);
-                if (fileInfo) {
+                if (fileInfo || Object.keys(fileInfo).length) {
                     // 先删除文件
                     await fs.unlinkSync(path.resolve(this.app.baseDir, './app', fileInfo.filepath));
                     // 再删除数据库

+ 3 - 0
app/controller/change_controller.js

@@ -790,6 +790,9 @@ module.exports = app => {
                 const data = JSON.parse(ctx.request.body.data);
                 const change = await ctx.service.change.getDataByCondition({ cid: ctx.params.cid });
                 const fileInfo = await ctx.service.changeAtt.getDataById(data.id);
+                if (!fileInfo || !Object.keys(fileInfo).length) {
+                    throw '该文件不存在';
+                }
                 if (!fileInfo.extra_upload && change.status === audit.flow.status.checked) {
                     throw '无权限删除';
                 }

+ 3 - 0
app/controller/material_controller.js

@@ -987,6 +987,9 @@ module.exports = app => {
                 const { data } = ctx.request.body;
                 const { id } = JSON.parse(data);
                 const fileInfo = await ctx.service.materialFile.getMaterialFileById(id);
+                if (!fileInfo || !Object.keys(fileInfo).length) {
+                    throw '该文件不存在';
+                }
                 if (!fileInfo.extra_upload && ctx.material.status === auditConst.status.checked) {
                     throw '无权限删除';
                 }

+ 3 - 0
app/controller/stage_controller.js

@@ -1453,6 +1453,9 @@ module.exports = app => {
 
                 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) {
                     throw '无权限删除';
                 }

+ 4 - 2
app/public/js/material_file.js

@@ -61,7 +61,6 @@ $(document).ready(function () {
             if ($('#file-list tr').length === 1) {
                 getAllList(curPageNo - 1);
             } else {
-
                 getAllList(curPageNo);
             }
             // self.parents('tr').remove();
@@ -124,7 +123,10 @@ $(document).ready(function () {
         // 总页数
         const pageNum = Math.ceil(total/pageCount);
         // 当前页附件内容
-        const currPageAttData = fileData && isCheckAll ? fileData.slice((currPageNum-1)*pageCount, currPageNum*pageCount) : filterFileData.map((v, index) => {
+        const currPageAttData = fileData && isCheckAll ? fileData.map((v, index) => {
+            return {...v, index }
+        }).slice((currPageNum-1)*pageCount, currPageNum*pageCount)
+        : filterFileData.map((v, index) => {
             return {...v, index }
         }).slice((currPageNum-1)*pageCount, currPageNum*pageCount);
         renderHtml(currPageAttData)