|
|
@@ -167,7 +167,7 @@ module.exports = app => {
|
|
|
await transaction.update(this.ctx.service.contract.tableName, node);
|
|
|
}
|
|
|
|
|
|
- async createContractPays(transaction, fpid, uid, times, pays) {
|
|
|
+ async createContractPays(transaction, fp, times, pays) {
|
|
|
const addPays = [];
|
|
|
const contracts = await transaction.select(this.ctx.service.contract.tableName, { where: { id: this._.uniq(this._.map(pays, 'cid')) } });
|
|
|
for (const p of pays) {
|
|
|
@@ -178,11 +178,11 @@ module.exports = app => {
|
|
|
tid: contract.tid || null,
|
|
|
contract_type: contract.contract_type,
|
|
|
cid: p.cid,
|
|
|
- uid,
|
|
|
- fpid,
|
|
|
+ uid: fp.uid,
|
|
|
+ fpid: fp.id,
|
|
|
fpcid: p.id,
|
|
|
pay_time: times,
|
|
|
- used: p.used || '合同',
|
|
|
+ used: fp.used || '合同',
|
|
|
pay_price: p.pay_price || 0,
|
|
|
debit_price: 0,
|
|
|
yf_price: p.pay_price || 0,
|
|
|
@@ -190,6 +190,9 @@ module.exports = app => {
|
|
|
pay_type: p.pay_type || '',
|
|
|
remark: '',
|
|
|
create_time: times,
|
|
|
+ status: auditConst.status.checked,
|
|
|
+ times: 1,
|
|
|
+ need_shenpi: contract.spid ? this.ctx.subProject.page_show.openContractPaySubProjectShenpi : this.ctx.subProject.page_show.openContractPayTenderShenpi,
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
@@ -202,30 +205,66 @@ module.exports = app => {
|
|
|
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);
|
|
|
+ if (fp.auditors && fp.auditors.length > 0) {
|
|
|
+ const addSpAudits = [];
|
|
|
+ for (const p of addPays) {
|
|
|
+ // 先push fp原报
|
|
|
+ const ybAudit = {
|
|
|
+ spid: p.spid,
|
|
|
+ tid: p.tid,
|
|
|
+ cid: p.cid,
|
|
|
+ cpid: p.id,
|
|
|
+ aid: fp.uid,
|
|
|
+ order: 0,
|
|
|
+ times: 1,
|
|
|
+ status: auditConst.status.checked,
|
|
|
+ audit_type: 1,
|
|
|
+ audit_order: 0,
|
|
|
+ opinion: '',
|
|
|
+ };
|
|
|
+ for (const a of fp.auditors) {
|
|
|
+ if (a.order === 1) {
|
|
|
+ ybAudit.begin_time = a.begin_time;
|
|
|
+ ybAudit.end_time = a.begin_time;
|
|
|
+ ybAudit.times = 1;
|
|
|
+ addSpAudits.push(ybAudit);
|
|
|
+ }
|
|
|
+ addSpAudits.push({
|
|
|
+ spid: p.spid,
|
|
|
+ tid: p.tid,
|
|
|
+ cid: p.cid,
|
|
|
+ cpid: p.id,
|
|
|
+ aid: a.aid,
|
|
|
+ order: a.order,
|
|
|
+ times: 1,
|
|
|
+ status: a.status,
|
|
|
+ audit_type: a.audit_type,
|
|
|
+ audit_order: a.audit_order,
|
|
|
+ begin_time: a.begin_time,
|
|
|
+ end_time: a.end_time,
|
|
|
+ opinion: a.opinion,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (addSpAudits.length > 0) {
|
|
|
+ await transaction.insert(this.ctx.service.contractSpAudit.tableName, addSpAudits);
|
|
|
+ }
|
|
|
}
|
|
|
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'));
|
|
|
- // 还要判断里面有叫"合同"的值,如果有则去除
|
|
|
- const index = addUsed.indexOf('合同');
|
|
|
- if (index > -1) {
|
|
|
- addUsed.splice(index, 1);
|
|
|
- }
|
|
|
- // 判断addUsed和used对比是否有新增的值,如果有则更新分项目的common_json
|
|
|
- if (this._.difference(addUsed, used).length > 0) {
|
|
|
- const newUsed = this._.uniq([...used, ...addUsed]);
|
|
|
- commonJson.tender_contract_used = newUsed;
|
|
|
+ if (fp.used !== '合同' && !this._.includes(used, fp.used)) {
|
|
|
+ used.push(fp.used);
|
|
|
+ commonJson.tender_contract_used = used;
|
|
|
await transaction.update(this.ctx.service.subProject.tableName, { id: this.ctx.subProject.id, common_json: JSON.stringify(commonJson) });
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
async removeContractPays(transaction, fpid, pays) {
|
|
|
+ const contractPays = await transaction.select(this.tableName, { where: { fpid } });
|
|
|
await transaction.delete(this.tableName, { fpid });
|
|
|
// 删除合同附件, 删除审批人列表
|
|
|
- for (const p of pays) {
|
|
|
+ for (const p of contractPays) {
|
|
|
// 删除合同附件
|
|
|
const attList = await this.ctx.service.contractPayAtt.getAllDataByCondition({ where: { cpid: p.id } });
|
|
|
await this.ctx.helper.delFiles(attList);
|