|
@@ -447,9 +447,7 @@ module.exports = app => {
|
|
|
if (!ctx.material.ex_calc) {
|
|
|
const calcBase = await ctx.service.stage.getMaterialCalcBase(stage_list, ctx.tender.info);
|
|
|
for (const bq of renderData.ex_calc) {
|
|
|
- const calc = _.find(calcBase, function(item) {
|
|
|
- return bq.code === item.code;
|
|
|
- });
|
|
|
+ const calc = _.find(calcBase, { code: bq.code }) || _.find(calcBase, { code: 'bqwc' });
|
|
|
bq.value = calc.value;
|
|
|
// if (calc.code === 'bqwc') {
|
|
|
// ctx.material.ex_expr = calc.value.toString() + '*[0-1]';
|
|
@@ -459,7 +457,18 @@ module.exports = app => {
|
|
|
// 并更新至调差表中
|
|
|
await ctx.service.material.update({ ex_calc: JSON.stringify(renderData.ex_calc) }, { id: ctx.material.id });
|
|
|
} else {
|
|
|
- renderData.ex_calc = JSON.parse(ctx.material.ex_calc);
|
|
|
+ const ex_calc = JSON.parse(ctx.material.ex_calc);
|
|
|
+ if (ctx.helper._.findIndex(ex_calc, { code: 'zdy' }) === -1) {
|
|
|
+ ex_calc.push({
|
|
|
+ code: 'zdy',
|
|
|
+ text: '自定义金额',
|
|
|
+ value: ctx.helper._.find(ex_calc, { code: 'bqwc' }).value,
|
|
|
+ select: false,
|
|
|
+ });
|
|
|
+ // 并更新至调差表中
|
|
|
+ await ctx.service.material.update({ ex_calc: JSON.stringify(ex_calc) }, { id: ctx.material.id });
|
|
|
+ }
|
|
|
+ renderData.ex_calc = ex_calc;
|
|
|
}
|
|
|
|
|
|
renderData.materialExponentData = await this._getMaterialExponentData(ctx);
|