|
|
@@ -292,7 +292,24 @@ module.exports = app => {
|
|
|
// 本期一些必要数据(如应耗数量和上期调差金额)插入到material_bills_history表里
|
|
|
const materialBillsData = await this.ctx.service.materialBills.getAllDataByCondition({ where: { tid: this.ctx.tender.id } });
|
|
|
if (materialBillsData.length === 0 && this.ctx.material.ex_expr === null) {
|
|
|
- throw '请至少使用一种调差方式';
|
|
|
+ if (!this.ctx.material.exponent_node && this.ctx.material.is_stage_self === 0) {
|
|
|
+ throw '请至少使用一种调差方式';
|
|
|
+ } else if (this.ctx.material.exponent_node) {
|
|
|
+ const nodes = await this.ctx.service.materialExponentNode.getAllDataByCondition({ where: { mid: materialId } });
|
|
|
+ const ex_exprs = this._.map(nodes, 'ex_expr');
|
|
|
+ // 如果都为空或者null,则抛出错误
|
|
|
+ if (ex_exprs.every(expr => expr === null || expr === '')) {
|
|
|
+ throw '请至少使用一种调差方式';
|
|
|
+ }
|
|
|
+ } else if (!this.ctx.material.exponent_node && this.ctx.material.is_stage_self === 1) {
|
|
|
+ const stages = await this.ctx.service.materialStage.getAllDataByCondition({where: {mid: materialId}});
|
|
|
+ const stage_exprs = this._.map(stages, 'ex_expr');
|
|
|
+ // 如果都为空或者null,则抛出错误
|
|
|
+ if (stage_exprs.every(expr => expr === null || expr === '')) {
|
|
|
+ throw '请至少使用一种调差方式';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ throw 'test';
|
|
|
}
|
|
|
|
|
|
// 微信模板通知
|