|
|
@@ -2230,18 +2230,24 @@ module.exports = app => {
|
|
|
return returnList;
|
|
|
}
|
|
|
|
|
|
- async getReCalcChangeData(tenderId, tenderInfo) {
|
|
|
- const change = await this.ctx.service.change.getAllDataByCondition({
|
|
|
- columns: [ 'cid', 'code', 'name', 'w_code', 'tp_decimal', 'up_decimal' ],
|
|
|
- where: { tid: tenderId, valid: 1, status: audit.flow.status.checked },
|
|
|
+ async getReCalcChangeData(tenderId, tenderInfo, checked = true) {
|
|
|
+ let change = await this.ctx.service.change.getAllDataByCondition({
|
|
|
+ columns: [ 'cid', 'code', 'name', 'w_code', 'tp_decimal', 'up_decimal', 'status' ],
|
|
|
+ where: { tid: tenderId, valid: 1 },
|
|
|
orders: [['code', 'asc']],
|
|
|
});
|
|
|
+ if (checked) {
|
|
|
+ change = change.filter(x => { return x.status === audit.flow.status.checked; });
|
|
|
+ } else {
|
|
|
+ change = change.filter(x => { return x.status !== audit.flow.status.checked; });
|
|
|
+ }
|
|
|
const changeBills = await this.ctx.service.changeAuditList.getAllDataByCondition({
|
|
|
- columns: [ 'id', 'cid', 'code', 'name', 'unit', 'unit_price', 'oamount2', 'checked_amount', 'checked_price', 'is_valuation', 'gcl_id', 'bwmx', 'mx_id'],
|
|
|
+ columns: [ 'id', 'cid', 'code', 'name', 'unit', 'unit_price', 'oamount2', 'checked_amount', 'checked_price', 'is_valuation', 'gcl_id', 'bwmx', 'mx_id', 'camount'],
|
|
|
where: { tid: tenderId }
|
|
|
});
|
|
|
const changeIndex = {};
|
|
|
change.forEach(x => { changeIndex[x.cid] = x; x.bills = [] });
|
|
|
+ const field = checked ? 'checked_amount' : 'camount';
|
|
|
changeBills.forEach(cb => {
|
|
|
const c = changeIndex[cb.cid];
|
|
|
if (!c) return;
|
|
|
@@ -2251,19 +2257,18 @@ module.exports = app => {
|
|
|
b = { code: cb.code, name: cb.name, unit: cb.unit, unit_price: cb.unit_price, pos: [], gcl_id: cb.gcl_id };
|
|
|
c.bills.push(b);
|
|
|
}
|
|
|
- b.checked_amount = this.ctx.helper.add(b.checked_amount, cb.checked_amount);
|
|
|
+ b.checked_amount = this.ctx.helper.add(b.checked_amount, cb[field]);
|
|
|
if (cb.is_valuation) {
|
|
|
- b.qty = this.ctx.helper.add(b.qty, cb.checked_amount);
|
|
|
+ b.qty = this.ctx.helper.add(b.qty, cb[field]);
|
|
|
} else {
|
|
|
- b.minus_qty = this.ctx.helper.add(b.minus_qty, cb.checked_amount);
|
|
|
+ b.minus_qty = this.ctx.helper.add(b.minus_qty, cb[field]);
|
|
|
}
|
|
|
b.pos.push(cb);
|
|
|
} else {
|
|
|
c.bills.push({
|
|
|
code: cb.code, name: cb.name, unit: cb.unit, unit_price: cb.unit_price,
|
|
|
gcl_id: '', checked_amount: cb.checked_amount, checked_price: cb.checked_price,
|
|
|
- qty: cb.is_valuation ? cb.checked_amount : 0, tp: cb.is_valuation ? cb.checked_price : 0,
|
|
|
- minus_qty: !cb.is_valuation ? cb.checked_amount : 0, minus_tp: !cb.is_valuation ? cb.checked_price : 0,
|
|
|
+ qty: cb.is_valuation ? cb[field] : 0, minus_qty: !cb.is_valuation ? cb[field] : 0,
|
|
|
pos: [cb],
|
|
|
});
|
|
|
}
|