浏览代码

删除期时,删除中间计量附件数据

MaiXinRong 3 年之前
父节点
当前提交
3fac20345d
共有 3 个文件被更改,包括 15 次插入2 次删除
  1. 1 1
      app/public/js/stage_im.js
  2. 11 0
      app/service/stage.js
  3. 3 1
      app/service/stage_detail_att.js

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

@@ -339,7 +339,7 @@ const stageIm = (function () {
         });
     }
 
-    function checkTzCustomDetail(im, details) {
+    function checkTzCustomDetail(im) {
         const cd = findTzRela(details, im);
         if (cd) loadCustomDetail(im, cd);
         const att = findTzRela(detailsAtt, im);

+ 11 - 0
app/service/stage.js

@@ -584,6 +584,17 @@ module.exports = app => {
                 await transaction.delete(this.ctx.service.stageOther.tableName, { sid: id });
                 // 同步删除进度里所选的期
                 await transaction.delete(this.ctx.service.scheduleStage.tableName, { tid: stageInfo.tid, order: stageInfo.order });
+                const detailAtt = await this.ctx.service.stageDetailAtt.getStageData(id);
+                if (detailAtt && detailAtt.length > 0) {
+                    for (const da of detailAtt) {
+                        for (const daa of da.attachment) {
+                            if (fs.existsSync(path.join(this.app.baseDir, daa.filepath))) {
+                                await fs.unlinkSync(path.join(this.app.baseDir, daa.filepath));
+                            }
+                        }
+                    }
+                }
+                await transaction.delete(this.ctx.service.stageDetailAtt.tableName, { sid: id });
                 // 重算进度计量总金额
                 await this.ctx.service.scheduleStage.calcStageSjTp(transaction, stageInfo.tid);
                 // 删除收方单及附件

+ 3 - 1
app/service/stage_detail_att.js

@@ -80,7 +80,9 @@ module.exports = app => {
         }
 
         async getStageData(sid, im_type) {
-            const result = await this.getAllDataByCondition({ where: { sid: sid, im_type: im_type } });
+            const result = im_type !== undefined
+                ? await this.getAllDataByCondition({ where: { sid: sid, im_type: im_type } })
+                : await this.getAllDataByCondition({ where: { sid: sid } });
             this._analysisDetailAtt(result);
             await this._complete4Output(result);
             return result;