Browse Source

金额概况缓存相关

MaiXinRong 1 year ago
parent
commit
6f4dcdde88

+ 1 - 1
app/controller/tender_controller.js

@@ -1190,7 +1190,7 @@ module.exports = app => {
                     responseData.data.tenders = tenderList;
                 } else if (data.type === 'ledger') {
                     responseData.data.tenders = tenderList.filter(x => {
-                        return x.ledger_status === auditConst.ledger.status.checked;
+                        return x.ledger_status === auditConst.ledger.status.checked;    ``
                     });
                     const history = await this.ctx.service.sumLoadHistory.getLedgerHistory(data.tid, data.lid);
                     if (history) responseData.data.history = { tenders: history.tenders, load_time: history.load_time, type: 'ledger' };

+ 6 - 5
app/service/stage.js

@@ -140,7 +140,7 @@ module.exports = app => {
                 stage.isCheckFirst = stage.order > 1 ? (stage.preCheckedStage ? stage.preCheckedStage.order === stage.order - 1 : false) : true;
             } else {
                 stage.preCheckedStage = undefined;
-                stage.isCheckFirst = false;
+                stage.isCheckFirst = true;
             }
         }
 
@@ -393,7 +393,6 @@ module.exports = app => {
             }
         }
 
-
         async _checkStageValid(stage) {
             if (stage.status === auditConst.stage.status.uncheck && !this.ctx.tender.isTourist) {
                 const assist = await this.ctx.service.auditAss.getAllDataByCondition({ where: { tid: stage.tid, user_id: stage.user_id } });
@@ -511,6 +510,7 @@ module.exports = app => {
                 const result = await transaction.insert(this.tableName, newStage);
                 if (result.affectedRows === 1) {
                     newStage.id = result.insertId;
+                    newStage.preCheckedStage = preCheckedStage;
                 } else {
                     throw '新增期数据失败';
                 }
@@ -542,8 +542,8 @@ module.exports = app => {
                 if (preStage && preCheckedStage && preStage.order === preCheckedStage.order) {
                     const priceCalc = new RevisePrice(this.ctx);
                     pcTp = await priceCalc.newStagePriceChange(newStage, preStage, transaction);
+                    await this.ctx.service.tenderCache.updateStageCache4Add(transaction, newStage, pcTp);
                 }
-                await this.ctx.service.tenderCache.updateStageCache4Add(transaction, newStage, pcTp);
                 // 新增期拷贝报表相关配置/签名角色 等
                 if (preStage) {
                     const rptResult = await this.ctx.service.rptCustomDefine.addInitialStageData(newStage, preStage, transaction);
@@ -690,9 +690,10 @@ module.exports = app => {
          * @return {Promise<void>}
          */
         async deleteStage(id) {
+            const stageInfo = await this.getDataById(id);
+            await this.loadPreCheckedStage(stageInfo);
             const transaction = await this.db.beginTransaction();
             try {
-                const stageInfo = await this.getDataById(id);
                 // 通知发送 - 第三方更新
                 // if (this.ctx.session.sessionProject.custom && syncApiConst.notice_type.indexOf(this.ctx.session.sessionProject.customType) !== -1) {
                 //     const base_data = {
@@ -707,7 +708,7 @@ module.exports = app => {
                 //     await this.ctx.helper.syncNoticeSend(this.ctx.session.sessionProject.customType, JSON.stringify(base_data));
                 // }
                 await transaction.delete(this.tableName, { id });
-                await this.ctx.service.tenderCache.updateStageCache4Del(transaction, stageInfo);
+                if (stageInfo.isCheckFirst) await this.ctx.service.tenderCache.updateStageCache4Del(transaction, stageInfo);
                 await transaction.delete(this.ctx.service.pos.tableName, { add_stage: id });
                 await transaction.delete(this.ctx.service.stageAudit.tableName, { sid: id });
                 await transaction.delete(this.ctx.service.stageBills.tableName, { sid: id });

+ 1 - 1
app/service/stage_audit.js

@@ -1895,7 +1895,7 @@ module.exports = app => {
                 });
                 // 同步 期信息
                 const time = new Date();
-                await this.ctx.service.tenderCache.updateStageCache4DelTimes(transaction, this.ctx.stage, nowTimes);
+                if (this.ctx.stage.isCheckFirst) await this.ctx.service.tenderCache.updateStageCache4DelTimes(transaction, this.ctx.stage, nowTimes);
                 await transaction.update(this.ctx.service.stage.tableName, {
                     id: this.ctx.stage.id,
                     status: auditConst.status.checkNo,

+ 1 - 1
app/view/stage/audit_btn.ejs

@@ -2,7 +2,7 @@
     <% if (ctx.stage.status === auditConst.status.uncheck) { %>
     <% if (ctx.session.sessionUser.accountId === ctx.stage.user_id) { %>
 
-    <% if (ctx.stage.order > 1 && ctx.stage.preCheckedStage && ctx.stage.preCheckedStage.order === ctx.stage.order - 1) { %>
+    <% if (ctx.stage.isCheckFirst) { %>
     <% if (!ctx.session.sessionProject.page_show.openStageStart || (ctx.session.sessionProject.page_show.openStageStart && ctx.stage.startPermission)) { %>
     <a id="sub-sp-btn" href="javascript: void(0);" data-toggle="modal" data-target="#sub-sp" class="btn btn-primary btn-sm btn-block">上报审批</a>
     <% } else { %>