Browse Source

1. 调用变更令后,界面刷新问题
2. 过滤,可变更数量为0

MaiXinRong 6 years ago
parent
commit
ebc3777dfb

+ 3 - 3
app/controller/stage_controller.js

@@ -256,10 +256,10 @@ module.exports = app => {
                     throw '调用变更令数据错误'
                 }
                 let result;
-                if (data.target.bills) {
-                    result = await ctx.service.stageChange.billsChange(data.target.bills, data.change);
-                } else {
+                if (data.target.pos) {
                     result = await ctx.service.stageChange.posChange(data.target.pos, data.change);
+                } else {
+                    result = await ctx.service.stageChange.billsChange(data.target.bills, data.change);
                 }
                 await this.ctx.service.stage.updateCheckDetailFlag(ctx.stage.id, true);
                 ctx.body = {err: 0, msg: '', data: result};

+ 2 - 2
app/public/js/stage.js

@@ -269,7 +269,7 @@ $(document).ready(() => {
                 // 提交数据到后端
                 postData(window.location.pathname + '/use-change', data, function(result) {
                     if (result.pos) {
-                        stagePos.loadCurStageData(result.pos);
+                        stagePos.loadCurStageData(result.pos.curStageData);
                     }
                     const nodes = stageTree.loadPostStageData(result.bills);
                     stageTreeSpreadObj.refreshTreeNodes(slSpread.getActiveSheet(), nodes);
@@ -357,7 +357,7 @@ $(document).ready(() => {
         }
         _filterChange(filterEmpty, matchPosName) {
             for (const c of this.changes) {
-                const filterVisible = filterEmpty ? (c.vamount && !checkZero(c.vamount)) : true;
+                const filterVisible = filterEmpty ? (c.vamount ? !checkZero(c.vamount) : false) : true;
                 const matchVisible = matchPosName && this.callData.pos ? c.b_detail === this.callData.pos.name : true;
                 c.visible = filterVisible && matchVisible;
             }

+ 5 - 4
app/service/stage_change.js

@@ -141,7 +141,7 @@ module.exports = app => {
                 throw err;
             }
             const result = await this.ctx.service.stageBills.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, [bills.id]);
-            return { bills: result };
+            return { bills: {curStageData: result} };
         }
 
         /**
@@ -208,6 +208,7 @@ module.exports = app => {
                 for (const c of updateChanges) {
                     await transaction.update(this.tableName, c);
                 }
+                console.log(posQty);
                 await this.ctx.service.stagePos.updateChangeQuantity(transaction, pos, posQty);
                 await transaction.commit();
             } catch (err) {
@@ -217,9 +218,9 @@ module.exports = app => {
 
             // 获取返回数据
             try {
-                const data = {};
-                data.bills = await this.ctx.service.stageBills.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, [pos.lid]);
-                data.pos = await this.ctx.service.stagePos.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, [pos.id]);
+                const data = { bills: {}, pos: {} };
+                data.bills.curStageData = await this.ctx.service.stageBills.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, [pos.lid]);
+                data.pos.curStageData = await this.ctx.service.stagePos.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, [pos.id]);
                 return data;
             } catch(err) {
                 throw '获取数据错误,请刷新页面';

+ 3 - 3
app/service/stage_pos.js

@@ -319,15 +319,15 @@ module.exports = app => {
         }
 
         async updateChangeQuantity(transaction, pos, qty) {
-            const orgPos = await this.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, pos.id);
+            const orgPos = await this.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, pos.pid);
             if (orgPos && orgPos.times === this.ctx.stage.curTimes && orgPos.order === this.ctx.stage.curOrder) {
-                await transaction.update(this.tableName, {qc_qty: qty}, {where: {id: orgPos.id}});
+                await transaction.update(this.tableName, {id: orgPos.id, qc_qty: qty});
             } else {
                 await transaction.insert(this.tableName, {
                     tid: this.ctx.tender.id,
                     sid: this.ctx.stage.id,
                     lid: pos.lid,
-                    pid: pos.id,
+                    pid: pos.pid,
                     said: this.ctx.session.sessionUser.accountId,
                     times: this.ctx.stage.curTimes,
                     order: this.ctx.stage.curOrder,

+ 1 - 1
test/app/service/stage_pay.test.js

@@ -166,8 +166,8 @@ describe('test/app/service/stage_pay.test.js', () => {
         const bqyf = app._.find(dealPay, {name: '本期应付'});
         assert(bqyf.tp === 525);
     });
-    // calcAllStagePays, copyAuditStagePays 在 stageAudit.start/stageAudit.check 调用测试
     // 第一期/一审
+    // calcAllStagePays, copyAuditStagePays 在 stageAudit.start/stageAudit.check 调用测试
     it('test calcAllStagePays & copyAuditStagePays', function* () {
         const ctx = app.mockContext(mockData);
         const result1 = yield ctx.service.stageAudit.addAuditor(ctx.stage.id, 14, ctx.stage.curTimes);