|
@@ -843,16 +843,23 @@ module.exports = app => {
|
|
async _generateChangeApply(tid) {
|
|
async _generateChangeApply(tid) {
|
|
if (!!this.changeApplyData) return;
|
|
if (!!this.changeApplyData) return;
|
|
const helper = this.ctx.helper;
|
|
const helper = this.ctx.helper;
|
|
|
|
+ const decimal = this.ctx.tender.info.decimal;
|
|
const where = { tid };
|
|
const where = { tid };
|
|
if (this.ctx.session.sessionProject.page_show.isOnlyChecked) where.status = audit.changeApply.status.checked;
|
|
if (this.ctx.session.sessionProject.page_show.isOnlyChecked) where.status = audit.changeApply.status.checked;
|
|
const apply = await this.ctx.service.changeApply.getAllDataByCondition({ where });
|
|
const apply = await this.ctx.service.changeApply.getAllDataByCondition({ where });
|
|
const bills = await this.ctx.service.changeApplyList.getChangeBills(tid, this.ctx.session.sessionProject.page_show.isOnlyChecked);
|
|
const bills = await this.ctx.service.changeApplyList.getChangeBills(tid, this.ctx.session.sessionProject.page_show.isOnlyChecked);
|
|
|
|
+ bills.forEach(x => {
|
|
|
|
+ const a = apply.find(y => { return y.id === x.caid });
|
|
|
|
+ const a_decimal = a.decimal ? JSON.stringify(a.decimal) : { tp: decimal.tp, up: decimal.up };
|
|
|
|
+ x.o_tp = helper.mul(x.oamount, x.unit_price, a_decimal.tp);
|
|
|
|
+ x.c_tp = helper.mul(x.camount, x.unit_price, a_decimal.tp);
|
|
|
|
+ });
|
|
bills.sort(function(a, b ) {
|
|
bills.sort(function(a, b ) {
|
|
const aCIndex = apply.findIndex(function (c) {
|
|
const aCIndex = apply.findIndex(function (c) {
|
|
- return c.cid === a.cid;
|
|
|
|
|
|
+ return c.id === a.caid;
|
|
});
|
|
});
|
|
const bCIndex = apply.findIndex(function (c) {
|
|
const bCIndex = apply.findIndex(function (c) {
|
|
- return c.cid === b.cid;
|
|
|
|
|
|
+ return c.id === b.caid;
|
|
});
|
|
});
|
|
return aCIndex === bCIndex
|
|
return aCIndex === bCIndex
|
|
? helper.compareCode(a.code, b.code)
|
|
? helper.compareCode(a.code, b.code)
|
|
@@ -904,17 +911,36 @@ module.exports = app => {
|
|
async _generateChangePlan(tid) {
|
|
async _generateChangePlan(tid) {
|
|
if (!!this.changePlanData) return;
|
|
if (!!this.changePlanData) return;
|
|
const helper = this.ctx.helper;
|
|
const helper = this.ctx.helper;
|
|
|
|
+ const decimal = this.ctx.tender.info.decimal;
|
|
this.changePlanData = {};
|
|
this.changePlanData = {};
|
|
const where = { tid };
|
|
const where = { tid };
|
|
if (this.ctx.session.sessionProject.page_show.isOnlyChecked) where.status = audit.changeApply.status.checked;
|
|
if (this.ctx.session.sessionProject.page_show.isOnlyChecked) where.status = audit.changeApply.status.checked;
|
|
const data = await this.ctx.service.changePlan.getAllDataByCondition({ where });
|
|
const data = await this.ctx.service.changePlan.getAllDataByCondition({ where });
|
|
const bills = await this.ctx.service.changePlanList.getChangeBills(tid, this.ctx.session.sessionProject.page_show.isOnlyChecked);
|
|
const bills = await this.ctx.service.changePlanList.getChangeBills(tid, this.ctx.session.sessionProject.page_show.isOnlyChecked);
|
|
|
|
+ bills.forEach(x => {
|
|
|
|
+ const plan = data.find(y => { return y.id === x.cpid });
|
|
|
|
+ const p_decimal = plan.decimal ? JSON.stringify(plan.decimal) : { tp: decimal.tp, up: decimal.up };
|
|
|
|
+ x.o_tp = helper.mul(x.oamount, x.unit_price, p_decimal.tp);
|
|
|
|
+ x.c_tp = helper.mul(x.camount, x.unit_price, p_decimal.tp);
|
|
|
|
+ x.s_tp = helper.mul(x.samount, x.unit_price, p_decimal.tp);
|
|
|
|
+ x.sp_tp = helper.mul(x.spamount, x.unit_price, p_decimal.tp);
|
|
|
|
+
|
|
|
|
+ const auditAmount = x.audit_amount ? x.audit_amount.split(',') : [];
|
|
|
|
+ for (const [i, aa] of auditAmount.entries()) {
|
|
|
|
+ const amountField = 'qty_' + (i+1), tpField = 'tp_' + (i+1);
|
|
|
|
+ x[amountField] = aa ? parseFloat(aa) : 0;
|
|
|
|
+ x[tpField] = helper.mul(x[amountField], x.unit_price, p_decimal.tp);
|
|
|
|
+ if (plan) {
|
|
|
|
+ plan[tpField] = helper.add(plan[tpField], x[tpField]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
bills.sort(function(a, b ) {
|
|
bills.sort(function(a, b ) {
|
|
const aCIndex = data.findIndex(function (c) {
|
|
const aCIndex = data.findIndex(function (c) {
|
|
- return c.cid === a.cid;
|
|
|
|
|
|
+ return c.id === a.cpid;
|
|
});
|
|
});
|
|
const bCIndex = data.findIndex(function (c) {
|
|
const bCIndex = data.findIndex(function (c) {
|
|
- return c.cid === b.cid;
|
|
|
|
|
|
+ return c.id === b.cpid;
|
|
});
|
|
});
|
|
return aCIndex === bCIndex
|
|
return aCIndex === bCIndex
|
|
? helper.compareCode(a.code, b.code)
|
|
? helper.compareCode(a.code, b.code)
|