|
|
@@ -80,8 +80,9 @@ module.exports = app => {
|
|
|
create_time: new Date(),
|
|
|
need_shenpi: options.spid ? this.ctx.subProject.page_show.openContractPaySubProjectShenpi : this.ctx.subProject.page_show.openContractPayTenderShenpi,
|
|
|
};
|
|
|
- await transaction.insert(this.tableName, insertData);
|
|
|
+ const result = await transaction.insert(this.tableName, insertData);
|
|
|
await this.calcContract(transaction, node);
|
|
|
+ await this.ctx.service.contractSpAudit.makeAudits(transaction, options, cid, result.insertId, this.ctx.session.sessionUser.accountId);
|
|
|
await transaction.commit();
|
|
|
} catch (err) {
|
|
|
await transaction.rollback();
|
|
|
@@ -193,10 +194,17 @@ module.exports = app => {
|
|
|
}
|
|
|
}
|
|
|
if (addPays.length > 0) {
|
|
|
- await transaction.insert(this.tableName, addPays);
|
|
|
+ const result = await transaction.insert(this.tableName, addPays);
|
|
|
for (const c of contracts) {
|
|
|
await this.calcContract(transaction, c);
|
|
|
}
|
|
|
+ // 获取刚批量添加的所有list
|
|
|
+ for (let j = 0; j < addPays.length; j++) {
|
|
|
+ addPays[j].id = result.insertId + j;
|
|
|
+ }
|
|
|
+ for (const p of addPays) {
|
|
|
+ await this.ctx.service.contractSpAudit.makeAudits(transaction, p, p.cid, p.id, uid);
|
|
|
+ }
|
|
|
const commonJson = this.ctx.subProject.common_json ? JSON.parse(this.ctx.subProject.common_json) : {};
|
|
|
const used = commonJson && commonJson.tender_contract_used ? commonJson.tender_contract_used : [];
|
|
|
const addUsed = this._.uniq(this._.map(pays, 'used'));
|
|
|
@@ -216,6 +224,14 @@ module.exports = app => {
|
|
|
|
|
|
async removeContractPays(transaction, fpid, pays) {
|
|
|
await transaction.delete(this.tableName, { fpid });
|
|
|
+ // 删除合同附件, 删除审批人列表
|
|
|
+ for (const p of pays) {
|
|
|
+ // 删除合同附件
|
|
|
+ const attList = await this.ctx.service.contractPayAtt.getAllDataByCondition({ where: { cpid: p.id } });
|
|
|
+ await this.ctx.helper.delFiles(attList);
|
|
|
+ await transaction.delete(this.ctx.service.contractPayAtt.tableName, { cpid: p.id });
|
|
|
+ await transaction.delete(this.ctx.service.contractSpAudit.tableName, { cpid: p.id });
|
|
|
+ }
|
|
|
const contracts = await transaction.select(this.ctx.service.contract.tableName, { where: { id: this._.uniq(this._.map(pays, 'cid')) } });
|
|
|
if (contracts.length > 0) {
|
|
|
for (const c of contracts) {
|