|
@@ -129,7 +129,7 @@ module.exports = app => {
|
|
|
change.finalAuditorIds = change.userGroups[change.userGroups.length - 1].map(x => { return x.uid; });
|
|
|
}
|
|
|
|
|
|
- async add(tenderId, userId, code, plan_code, name, delimit = 100) {
|
|
|
+ async add(tenderId, userId, code, plan_code, name, plan_list = false, delimit = 100) {
|
|
|
const sql = 'SELECT COUNT(*) as count FROM ?? WHERE `tid` = ? AND ((`code` = ? AND `status` != ?) OR (`p_code` = ? AND `status` = ?))';
|
|
|
const sqlParam = [this.tableName, tenderId, code, audit.change.status.checked, code, audit.change.status.checked];
|
|
|
const codeCount = await this.db.queryOne(sql, sqlParam);
|
|
@@ -180,6 +180,43 @@ module.exports = app => {
|
|
|
content = content + (planInfo.content ? (planInfo.reason ? '\r\n' : '') + planInfo.content.replace(/[\r\n]/g, '\r\n') : '');
|
|
|
change.content = content ? content : null;
|
|
|
change.expr = planInfo.expr;
|
|
|
+ if (plan_list) {
|
|
|
+ const planList = await this.ctx.service.changePlanList.getAllDataByCondition({ where: { cpid: planInfo.id } });
|
|
|
+ const insertList = [];
|
|
|
+ for (const p of planList) {
|
|
|
+ insertList.push({
|
|
|
+ tid: tenderId,
|
|
|
+ cid,
|
|
|
+ lid: '0',
|
|
|
+ code: p.code,
|
|
|
+ name: p.name,
|
|
|
+ unit: p.unit,
|
|
|
+ unit_price: p.unit_price,
|
|
|
+ oamount: p.oamount,
|
|
|
+ oamount2: p.oamount,
|
|
|
+ camount: p.camount,
|
|
|
+ camount_expr: p.camount,
|
|
|
+ samount: '',
|
|
|
+ gcl_id: '',
|
|
|
+ mx_id: '',
|
|
|
+ spamount: p.camount,
|
|
|
+ detail: '',
|
|
|
+ xmj_code: null,
|
|
|
+ xmj_jldy: null,
|
|
|
+ xmj_dwgc: null,
|
|
|
+ xmj_fbgc: null,
|
|
|
+ xmj_fxgc: null,
|
|
|
+ is_valuation: 1,
|
|
|
+ order: null,
|
|
|
+ delimit,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (insertList.length > 0) {
|
|
|
+ await this.transaction.insert(this.ctx.service.changeAuditList.tableName, insertList);
|
|
|
+ // // 重新算变更令总额
|
|
|
+ // await this.ctx.changeAuditList.calcCamountSum(this.transaction);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
const operate = await this.transaction.insert(this.tableName, change);
|