Browse Source

其他台账,所有历史数据调整

MaiXinRong 5 years ago
parent
commit
e7531a38ec

+ 4 - 2
app/service/stage_bonus.js

@@ -164,11 +164,13 @@ module.exports = app => {
             const datas = await this.getStageData(stage.id);
             if (datas.length === 0) return;
 
-            const filter = {stimes: this.ctx.stage.curTimes, sorder: this.ctx.stage.curOrder};
             const updateDatas = [];
             for (const d of datas) {
                 const history = d.shistory && d.shistory !== '' ? JSON.parse(d.shistory) : [];
-                const his = this.ctx.helper._.find(datas, filter);
+                const his = datas.find(function (x) {
+                    return x.stimes && x.stimes === this.ctx.stage.curTimes
+                        && x.sorder && x.sorder === this.ctx.stage.curOrder;
+                });
                 if (his) {
                     his.tp = d.tp;
                 } else {

+ 8 - 9
app/service/stage_jgcl.js

@@ -185,11 +185,13 @@ module.exports = app => {
             const datas = await this.getStageData(stage);
             if (datas.length === 0) return;
 
-            const filter = {stimes: this.ctx.stage.curTimes, sorder: this.ctx.stage.curOrder};
             const updateDatas = [];
             for (const d of datas) {
                 const history = d.shistory && d.shistory !== '' ? JSON.parse(d.shistory) : [];
-                const his = this.ctx.helper._.find(datas, filter);
+                const his = datas.find(function (x) {
+                    return x.stimes && x.stimes === this.ctx.stage.curTimes
+                        && x.sorder && x.sorder === this.ctx.stage.curOrder;
+                });
                 if (his) {
                     his.arrive_qty = d.arrive_qty;
                     his.arrive_tp = d.arrive_tp;
@@ -211,17 +213,14 @@ module.exports = app => {
             if (!stage || !preStage) {
                 throw '标段数据有误';
             }
-            const preDatas = await this.getStageData(preStage);
+            const preDatas = await this.getAllDataByCondition({
+                columns: ['uuid', 'name', 'unit', 'unit_price', 'source', 'bills_code', 'check_code', 'memo', 'add_uid', 'add_sid'],
+                where: { sid: preStage.id }
+            });;
             if (preDatas.length > 0) {
                 for (const pd of preDatas) {
-                    delete pd.id;
                     pd.pre_used = pd.pre_used || !this.ctx.helper.checkZero(pd.arrive_qty) || !this.ctx.helper.checkZero(pd.deduct_qty);
-                    delete pd.arrive_qty;
-                    delete pd.arrive_tp;
-                    delete pd.deduct_qty;
-                    delete pd.deduct_tp;
                     pd.sid = stage.id;
-                    delete pd.shistory;
                 }
                 const result = await transaction.insert(this.tableName, preDatas);
                 return result.affectedRows === preDatas.length;

+ 8 - 6
app/service/stage_other.js

@@ -158,11 +158,13 @@ module.exports = app => {
             const datas = await this.getStageData(stage);
             if (datas.length === 0) return;
 
-            const filter = {stimes: this.ctx.stage.curTimes, sorder: this.ctx.stage.curOrder};
             const updateDatas = [];
             for (const d of datas) {
                 const history = d.shistory && d.shistory !== '' ? JSON.parse(d.shistory) : [];
-                const his = this.ctx.helper._.find(datas, filter);
+                const his = datas.find(function (x) {
+                    return x.stimes && x.stimes === this.ctx.stage.curTimes
+                        && x.sorder && x.sorder === this.ctx.stage.curOrder;
+                });
                 if (his) {
                     his.tp = d.tp;
                     if (d.sid === d.add_sid) his.total_price = d.total_price;
@@ -180,15 +182,15 @@ module.exports = app => {
             if (!stage || !preStage) {
                 throw '标段数据有误';
             }
-            const preDatas = await this.getStageData(preStage);
+            const preDatas = await this.getAllDataByCondition({
+                columns: ['uuid', 'tid', 'add_uid', 'add_sid', 'add_time', 'name', 'o_type', 'total_price', 'order', 'memo', 'real_time'],
+                where: { sid: preStage.id }
+            });
             if (preDatas.length > 0) {
                 for (const pd of preDatas) {
-                    delete pd.id;
                     pd.pre_used = pd.pre_used || !this.ctx.helper.checkZero(pd.tp);
-                    delete pd.tp;
                     pd.sid = stage.id;
                     pd.sorder = stage.order;
-                    delete pd.shistory;
                 }
                 const result = await transaction.insert(this.tableName, preDatas);
                 return result.affectedRows === preDatas.length;

+ 1 - 1
app/view/stage_extra/sub_menu.ejs

@@ -1,7 +1,7 @@
 <div class="panel-sidebar" id="sub-menu">
     <div class="panel-title">
         <div class="title-bar">
-            <h2 class="text-truncate" style="white-space:nowrap; overflow:hidden; text-overflow:ellipsis;" data-toggle="tooltip" data-placement="right" title=""  data-original-title="其他台账">其他台账</h2>
+            <h2 class="text-truncate" style="white-space:nowrap; overflow:hidden; text-overflow:ellipsis;" data-toggle="tooltip" data-placement="right" title=""  data-original-title="第<%- ctx.stage.order%>期 - 其他台账">其他台账</h2>
         </div>
     </div>
     <div class="scrollbar-auto">