|
@@ -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;
|