浏览代码

修复资金监管和合同关联支付和增加审批流程

ellisran 2 天之前
父节点
当前提交
8214884ca9
共有 4 个文件被更改,包括 65 次插入22 次删除
  1. 2 2
      app/const/audit.js
  2. 2 2
      app/public/js/contract_detail.js
  3. 56 17
      app/service/contract_pay.js
  4. 5 1
      app/service/financial_pay_audit.js

+ 2 - 2
app/const/audit.js

@@ -1527,8 +1527,8 @@ const contract = (function() {
         checked: 3, // 审批通过
         checkNo: 4, // 审批退回原报
         checkNoPre: 5, // 审批退回上一人
-        checkAgain: 6, // 重新审批 // 该状态仅可用于,终审退回时,修改原终审的审批状态,并同时新增一条新的终审审批中记录
-        checkCancel: 7, // 撤回 // 该状态为上一审批人可发起,回到它到审批阶段,并同时新增一条新的审批中记录
+        checkAgain: 7, // 重新审批 // 该状态仅可用于,终审退回时,修改原终审的审批状态,并同时新增一条新的终审审批中记录
+        // checkCancel: 11, // 撤回 // 该状态为上一审批人可发起,回到它到审批阶段,并同时新增一条新的审批中记录
         checkSkip: 8, // 跳过
     };
 

+ 2 - 2
app/public/js/contract_detail.js

@@ -2877,7 +2877,7 @@ $(document).ready(function() {
                     }
                     if (group.status === auditConst.status.checked) {
                         historyHTML.push('<div class="timeline-item-icon bg-success text-light"><i class="fa fa-check"></i></div>');
-                    } else if (group.status === auditConst.status.checkNo || group.status === auditConst.status.checkNoPre) {
+                    } else if (group.status === auditConst.status.checkNo || group.status === auditConst.status.checkNoPre || group.status === auditConst.status.checkAgain) {
                         historyHTML.push('<div class="timeline-item-icon bg-warning text-light"><i class="fa fa-level-up"></i></div>');
                     } else if (group.status === auditConst.status.checking) {
                         historyHTML.push('<div class="timeline-item-icon bg-warning text-light"><i class="fa fa-ellipsis-h"></i></div>');
@@ -2912,7 +2912,7 @@ $(document).ready(function() {
                         historyHTML.push('<div class="col">');
                         if (auditor.status === auditConst.status.checked) {
                             historyHTML.push('<span class="pull-right text-success"><i class="fa fa-check-circle"></i></span>');
-                        } else if (auditor.status === auditConst.status.checkNo || auditor.status === auditConst.status.checkNoPre) {
+                        } else if (auditor.status === auditConst.status.checkNo || auditor.status === auditConst.status.checkNoPre || auditor.status === auditConst.status.checkAgain) {
                             historyHTML.push('<span class="pull-right text-warning"><i class="fa fa-share-square fa-rotate-270"></i></span>');
                         } else if (auditor.status === auditConst.status.checking) {
                             historyHTML.push('<span class="pull-right text-warning"><i class="fa fa-commenting"></i></span>');

+ 56 - 17
app/service/contract_pay.js

@@ -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);

+ 5 - 1
app/service/financial_pay_audit.js

@@ -397,7 +397,11 @@ module.exports = app => {
                         const pays = await this.ctx.service.financialPayContract.getAllDataByCondition({ where: { fpid: fp.id } });
                         const contractPays = this._.filter(pays, x => { return x.cid !== null; });
                         if (contractPays.length > 0) {
-                            await this.ctx.service.contractPay.createContractPays(transaction, fp.id, fp.uid, time, contractPays);
+                            const lastAudit = this._.find(fp.auditors, { id: selfAudit.id });
+                            lastAudit.status = checkData.checkType;
+                            lastAudit.opinion = checkData.opinion;
+                            lastAudit.end_time = time;
+                            await this.ctx.service.contractPay.createContractPays(transaction, fp, time, contractPays);
                         }
                     }
                 } else {