浏览代码

通知增加审批意见

laiguoran 3 年之前
父节点
当前提交
2f31c7c6e3

+ 7 - 4
app/service/advance_audit.js

@@ -269,7 +269,7 @@ module.exports = app => {
             try {
                 await transaction.update(this.tableName, { id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time });
                 // 获取推送必要信息
-                const noticeContent = await this.getNoticeContent(pid, audit.tid, advanceId, audit.audit_id);
+                const noticeContent = await this.getNoticeContent(pid, audit.tid, advanceId, audit.audit_id, checkData.opinion);
                 // 添加推送
                 const records = [{ pid, type: pushType.advance, uid: this.ctx.advance.uid, status: auditConst.status.checked, content: noticeContent }];
                 auditors.forEach(audit => {
@@ -350,7 +350,7 @@ module.exports = app => {
                 await transaction.update(this.tableName, { id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time });
 
                 // 添加到消息推送表
-                const noticeContent = await this.getNoticeContent(pid, audit.tid, advanceId, audit.audit_id);
+                const noticeContent = await this.getNoticeContent(pid, audit.tid, advanceId, audit.audit_id, checkData.opinion);
                 const records = [{ pid, type: pushType.advance, uid: this.ctx.advance.uid, status: auditConst.status.checkNo, content: noticeContent }];
                 auditors.forEach(audit => {
                     records.push({ pid, type: pushType.advance, uid: audit.audit_id, status: auditConst.status.checkNo, content: noticeContent });
@@ -400,7 +400,7 @@ module.exports = app => {
                 return item.audit_id === audit.audit_id;
             });
             const preAuditor = auditors2[auditorIndex - 1];
-            const noticeContent = await this.getNoticeContent(pid, audit.tid, advanceId, audit.audit_id);
+            const noticeContent = await this.getNoticeContent(pid, audit.tid, advanceId, audit.audit_id, checkData.opinion);
             const transaction = await this.db.beginTransaction();
             try {
                 // 添加到消息推送表
@@ -491,7 +491,7 @@ module.exports = app => {
          * @param {Number} vid 预付款id
          * @param {Number} uid 审批人id
          */
-        async getNoticeContent(pid, tid, vid, uid) {
+        async getNoticeContent(pid, tid, vid, uid, opinion = '') {
             const noticeSql =
                 'SELECT * FROM (SELECT ' +
                 '  t.`id` As `tid`, ad.`vid`, t.`name`, m.`order`, pa.`name` As `su_name`, pa.role As `su_role`' +
@@ -511,6 +511,9 @@ module.exports = app => {
                 pid,
             ];
             const content = await this.db.query(noticeSql, noticeSqlParam);
+            if (content.length) {
+                content[0].opinion = opinion;
+            }
             return content.length ? JSON.stringify(content[0]) : '';
         }
 

+ 8 - 5
app/service/change.js

@@ -712,7 +712,7 @@ module.exports = app => {
                 // console.log('auditors', auditors);
                 // console.log('postData', postData);
                 // 添加到消息推送表
-                const noticeContent = await this.getNoticeContent(pid, changeData.tid, changeData.cid, this.ctx.session.sessionUser.accountId);
+                const noticeContent = await this.getNoticeContent(pid, changeData.tid, changeData.cid, this.ctx.session.sessionUser.accountId, postData.sdesc);
                 const records = [];
                 auditors.forEach(auditor => {
                     records.push({
@@ -896,7 +896,7 @@ module.exports = app => {
                 // 获取所有审核人列表
                 const auditors = await this.ctx.service.changeAudit.getAllAuditors(changeData.tid);
                 // 添加到消息推送表
-                const noticeContent = await this.getNoticeContent(pid, changeData.tid, changeData.cid, this.ctx.session.sessionUser.accountId);
+                const noticeContent = await this.getNoticeContent(pid, changeData.tid, changeData.cid, this.ctx.session.sessionUser.accountId, postData.sdesc);
                 const records = [];
                 auditors.forEach(auditor => {
                     records.push({
@@ -1010,7 +1010,7 @@ module.exports = app => {
                 // 获取所有审核人列表
                 const auditors = await this.ctx.service.changeAudit.getAllAuditors(changeData.tid);
                 // 添加到消息推送表
-                const noticeContent = await this.getNoticeContent(pid, changeData.tid, changeData.cid, this.ctx.session.sessionUser.accountId);
+                const noticeContent = await this.getNoticeContent(pid, changeData.tid, changeData.cid, this.ctx.session.sessionUser.accountId, postData.sdesc);
                 const records = [];
                 auditors.forEach(auditor => {
                     records.push({
@@ -1358,7 +1358,7 @@ module.exports = app => {
                 // 获取所有审核人列表
                 const auditors = await this.ctx.service.changeAudit.getAllAuditors(changeData.tid);
                 // 添加到消息推送表
-                const noticeContent = await this.getNoticeContent(pid, changeData.tid, changeData.cid, this.ctx.session.sessionUser.accountId);
+                const noticeContent = await this.getNoticeContent(pid, changeData.tid, changeData.cid, this.ctx.session.sessionUser.accountId, '发起重新审批');
                 const records = [];
                 auditors.forEach(auditor => {
                     records.push({
@@ -1601,7 +1601,7 @@ module.exports = app => {
          * @param {Number} cid 变更id
          * @param {Number} uid 审核人id
          */
-        async getNoticeContent(pid, tid, cid, uid) {
+        async getNoticeContent(pid, tid, cid, uid, opinion = '') {
             const noticeSql =
                 'SELECT * FROM (SELECT ' +
                 '  t.`id` As `tid`, t.`name`, c.`cid`, c.`code` As `c_code`, pa.`name` As `su_name`, pa.role As `su_role`' +
@@ -1611,6 +1611,9 @@ module.exports = app => {
                 '  WHERE  t.`project_id` = ? ) as new_t GROUP BY new_t.`tid`';
             const noticeSqlParam = [this.ctx.service.tender.tableName, tid, this.ctx.service.change.tableName, cid, this.ctx.service.projectAccount.tableName, uid, pid];
             const content = await this.db.query(noticeSql, noticeSqlParam);
+            if (content.length) {
+                content[0].opinion = opinion;
+            }
             return content.length ? JSON.stringify(content[0]) : '';
         }
 

+ 6 - 3
app/service/change_apply_audit.js

@@ -313,7 +313,7 @@ module.exports = app => {
          * @param {Number} caId 立项书id
          * @param {Number} uid 审批人id
          */
-        async getNoticeContent(pid, tid, caId, uid) {
+        async getNoticeContent(pid, tid, caId, uid, opinion = '') {
             const noticeSql = 'SELECT * FROM (SELECT ' +
                 '  t.`id` As `tid`, ma.`caid`, m.`code` as `c_code`, t.`name`, pa.`name` As `su_name`, pa.role As `su_role`' +
                 '  FROM (SELECT * FROM ?? WHERE `id` = ? ) As t' +
@@ -323,6 +323,9 @@ module.exports = app => {
                 '  WHERE  t.`project_id` = ? ) as new_t GROUP BY new_t.`tid`';
             const noticeSqlParam = [this.ctx.service.tender.tableName, tid, this.ctx.service.changeApply.tableName, caId, this.tableName, this.ctx.service.projectAccount.tableName, uid, pid];
             const content = await this.db.query(noticeSql, noticeSqlParam);
+            if (content.length) {
+                content[0].opinion = opinion;
+            }
             return content.length ? JSON.stringify(content[0]) : '';
         }
 
@@ -372,7 +375,7 @@ module.exports = app => {
                 await transaction.update(this.tableName, { id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time });
 
                 // 获取推送必要信息
-                const noticeContent = await this.getNoticeContent(pid, audit.tid, caId, audit.aid);
+                const noticeContent = await this.getNoticeContent(pid, audit.tid, caId, audit.aid, checkData.opinion);
                 // 添加推送
                 const records = [{ pid, type: pushType.changeApply, uid: this.ctx.change.uid, status: auditConst.status.checked, content: noticeContent }];
                 auditors.forEach(audit => {
@@ -448,7 +451,7 @@ module.exports = app => {
             try {
                 await transaction.update(this.tableName, { id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time });
                 // 添加到消息推送表
-                const noticeContent = await this.getNoticeContent(pid, audit.tid, caId, audit.aid);
+                const noticeContent = await this.getNoticeContent(pid, audit.tid, caId, audit.aid, checkData.opinion);
                 const records = [{ pid, type: pushType.changeApply, uid: this.ctx.change.uid, status: auditConst.status.checkNo, content: noticeContent }];
                 auditors.forEach(audit => {
                     records.push({ pid, type: pushType.changeApply, uid: audit.aid, status: auditConst.status.checkNo, content: noticeContent });

+ 6 - 3
app/service/change_plan_audit.js

@@ -317,7 +317,7 @@ module.exports = app => {
          * @param {Number} cpId 方案id
          * @param {Number} uid 审批人id
          */
-        async getNoticeContent(pid, tid, cpId, uid) {
+        async getNoticeContent(pid, tid, cpId, uid, opinion = '') {
             const noticeSql = 'SELECT * FROM (SELECT ' +
                 '  t.`id` As `tid`, ma.`cpid`, m.`code` as `c_code`, t.`name`, pa.`name` As `su_name`, pa.role As `su_role`' +
                 '  FROM (SELECT * FROM ?? WHERE `id` = ? ) As t' +
@@ -327,6 +327,9 @@ module.exports = app => {
                 '  WHERE  t.`project_id` = ? ) as new_t GROUP BY new_t.`tid`';
             const noticeSqlParam = [this.ctx.service.tender.tableName, tid, this.ctx.service.changePlan.tableName, cpId, this.tableName, this.ctx.service.projectAccount.tableName, uid, pid];
             const content = await this.db.query(noticeSql, noticeSqlParam);
+            if (content.length) {
+                content[0].opinion = opinion;
+            }
             return content.length ? JSON.stringify(content[0]) : '';
         }
 
@@ -376,7 +379,7 @@ module.exports = app => {
                 await transaction.update(this.tableName, { id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time });
 
                 // 获取推送必要信息
-                const noticeContent = await this.getNoticeContent(pid, audit.tid, cpId, audit.aid);
+                const noticeContent = await this.getNoticeContent(pid, audit.tid, cpId, audit.aid, checkData.opinion);
                 // 添加推送
                 const records = [{ pid, type: pushType.changePlan, uid: this.ctx.change.uid, status: auditConst.status.checked, content: noticeContent }];
                 auditors.forEach(audit => {
@@ -462,7 +465,7 @@ module.exports = app => {
             try {
                 await transaction.update(this.tableName, { id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time });
                 // 添加到消息推送表
-                const noticeContent = await this.getNoticeContent(pid, audit.tid, cpId, audit.aid);
+                const noticeContent = await this.getNoticeContent(pid, audit.tid, cpId, audit.aid, checkData.opinion);
                 const records = [{ pid, type: pushType.changePlan, uid: this.ctx.change.uid, status: auditConst.status.checkNo, content: noticeContent }];
                 auditors.forEach(audit => {
                     records.push({ pid, type: pushType.changePlan, uid: audit.aid, status: auditConst.status.checkNo, content: noticeContent });

+ 7 - 4
app/service/change_project_audit.js

@@ -314,7 +314,7 @@ module.exports = app => {
          * @param {Number} cpId 立项书id
          * @param {Number} uid 审批人id
          */
-        async getNoticeContent(pid, tid, cpId, uid) {
+        async getNoticeContent(pid, tid, cpId, uid, opinion = '') {
             const noticeSql = 'SELECT * FROM (SELECT ' +
                 '  t.`id` As `tid`, ma.`cpid`, m.`code` as `c_code`, t.`name`, pa.`name` As `su_name`, pa.role As `su_role`' +
                 '  FROM (SELECT * FROM ?? WHERE `id` = ? ) As t' +
@@ -324,6 +324,9 @@ module.exports = app => {
                 '  WHERE  t.`project_id` = ? ) as new_t GROUP BY new_t.`tid`';
             const noticeSqlParam = [this.ctx.service.tender.tableName, tid, this.ctx.service.changeProject.tableName, cpId, this.tableName, this.ctx.service.projectAccount.tableName, uid, pid];
             const content = await this.db.query(noticeSql, noticeSqlParam);
+            if (content.length) {
+                content[0].opinion = opinion;
+            }
             return content.length ? JSON.stringify(content[0]) : '';
         }
 
@@ -376,7 +379,7 @@ module.exports = app => {
                 await transaction.update(this.tableName, { id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time });
 
                 // 获取推送必要信息
-                const noticeContent = await this.getNoticeContent(pid, audit.tid, cpId, audit.aid);
+                const noticeContent = await this.getNoticeContent(pid, audit.tid, cpId, audit.aid, checkData.opinion);
                 // 添加推送
                 const records = [{ pid, type: pushType.changeProject, uid: this.ctx.change.uid, status: auditConst.status.checked, content: noticeContent }];
                 auditors.forEach(audit => {
@@ -450,7 +453,7 @@ module.exports = app => {
             try {
                 await transaction.update(this.tableName, { id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time });
                 // 添加到消息推送表
-                const noticeContent = await this.getNoticeContent(pid, audit.tid, cpId, audit.aid);
+                const noticeContent = await this.getNoticeContent(pid, audit.tid, cpId, audit.aid, checkData.opinion);
                 const records = [{ pid, type: pushType.changeProject, uid: this.ctx.change.uid, status: auditConst.status.back, content: noticeContent }];
                 auditors.forEach(audit => {
                     records.push({ pid, type: pushType.changeProject, uid: audit.aid, status: auditConst.status.back, content: noticeContent });
@@ -498,7 +501,7 @@ module.exports = app => {
                 await transaction.update(this.tableName, { id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time });
 
                 // 获取推送必要信息
-                const noticeContent = await this.getNoticeContent(pid, audit.tid, cpId, audit.aid);
+                const noticeContent = await this.getNoticeContent(pid, audit.tid, cpId, audit.aid, checkData.opinion);
                 // 添加推送
                 const records = [{ pid, type: pushType.changeProject, uid: this.ctx.change.uid, status: auditConst.status.checkNo, content: noticeContent }];
                 auditors.forEach(audit => {

+ 5 - 2
app/service/ledger_audit.js

@@ -323,7 +323,7 @@ module.exports = app => {
                 // 获取审核人列表
                 const auditList = await this.getAuditors(tenderId, times);
                 // 添加推送
-                const noticeContent = await this.getNoticeContent(audit.tender_id, pid, audit.audit_id);
+                const noticeContent = await this.getNoticeContent(audit.tender_id, pid, audit.audit_id, opinion);
                 const records = [
                     {
                         pid,
@@ -481,7 +481,7 @@ module.exports = app => {
          * @param {Number} pid 项目id
          * @param {Number} uid 审核人id
          */
-        async getNoticeContent(id, pid, uid) {
+        async getNoticeContent(id, pid, uid, opinion = '') {
             const noticeSql =
                 'SELECT * FROM (SELECT ' +
                 '  t.`id` As `tid`, t.`name`,  pa.`name` As `su_name`, pa.role As `su_role`' +
@@ -490,6 +490,9 @@ module.exports = app => {
                 '  WHERE  t.`project_id` = ? ) as new_t GROUP BY new_t.`tid`';
             const noticeSqlParam = [this.ctx.service.tender.tableName, id, this.ctx.service.projectAccount.tableName, uid, pid];
             const content = await this.db.query(noticeSql, noticeSqlParam);
+            if (content.length) {
+                content[0].opinion = opinion;
+            }
             return content.length ? JSON.stringify(content[0]) : '';
         }
 

+ 7 - 4
app/service/material_audit.js

@@ -292,7 +292,7 @@ module.exports = app => {
                 await transaction.update(this.tableName, { id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time });
 
                 // 获取推送必要信息
-                const noticeContent = await this.getNoticeContent(pid, audit.tid, materialId, audit.aid);
+                const noticeContent = await this.getNoticeContent(pid, audit.tid, materialId, audit.aid, checkData.opinion);
                 // 添加推送
                 const records = [{ pid, type: pushType.material, uid: this.ctx.material.user_id, status: auditConst.status.checked, content: noticeContent }];
                 auditors.forEach(audit => {
@@ -477,7 +477,7 @@ module.exports = app => {
             try {
                 await transaction.update(this.tableName, { id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time });
                 // 添加到消息推送表
-                const noticeContent = await this.getNoticeContent(pid, audit.tid, materialId, audit.aid);
+                const noticeContent = await this.getNoticeContent(pid, audit.tid, materialId, audit.aid, checkData.opinion);
                 const records = [{ pid, type: pushType.material, uid: this.ctx.material.user_id, status: auditConst.status.checkNo, content: noticeContent }];
                 auditors.forEach(audit => {
                     records.push({ pid, type: pushType.material, uid: audit.aid, status: auditConst.status.checkNo, content: noticeContent });
@@ -572,7 +572,7 @@ module.exports = app => {
                 return item.aid === audit.aid;
             });
             const preAuditor = auditors2[auditorIndex - 1];
-            const noticeContent = await this.getNoticeContent(pid, audit.tid, materialId, audit.aid);
+            const noticeContent = await this.getNoticeContent(pid, audit.tid, materialId, audit.aid, checkData.opinion);
             const transaction = await this.db.beginTransaction();
             try {
                 // 添加到消息推送表
@@ -659,7 +659,7 @@ module.exports = app => {
          * @param {Number} mid 期id
          * @param {Number} uid 审批人id
          */
-        async getNoticeContent(pid, tid, mid, uid) {
+        async getNoticeContent(pid, tid, mid, uid, opinion = '') {
             const noticeSql = 'SELECT * FROM (SELECT ' +
                 '  t.`id` As `tid`, ma.`mid`, t.`name`, m.`order`, pa.`name` As `su_name`, pa.role As `su_role`' +
                 '  FROM (SELECT * FROM ?? WHERE `id` = ? ) As t' +
@@ -669,6 +669,9 @@ module.exports = app => {
                 '  WHERE  t.`project_id` = ? ) as new_t GROUP BY new_t.`tid`';
             const noticeSqlParam = [this.ctx.service.tender.tableName, tid, this.ctx.service.material.tableName, mid, this.tableName, this.ctx.service.projectAccount.tableName, uid, pid];
             const content = await this.db.query(noticeSql, noticeSqlParam);
+            if (content.length) {
+                content[0].opinion = opinion;
+            }
             return content.length ? JSON.stringify(content[0]) : '';
         }
 

+ 5 - 2
app/service/revise_audit.js

@@ -358,7 +358,7 @@ module.exports = app => {
             try {
                 const auditList = await this.getAuditors(revise.id, times);
                 // 审核通过添加到推送表
-                const noticeContent = await this.getNoticeContent(pid, audit.tender_id, audit.rid, audit.audit_id);
+                const noticeContent = await this.getNoticeContent(pid, audit.tender_id, audit.rid, audit.audit_id, opinion);
                 const records = [
                     {
                         pid,
@@ -650,7 +650,7 @@ module.exports = app => {
          * @param {Number} rid 修订id
          * @param {Number} uid 审核人id
          */
-        async getNoticeContent(pid, tid, rid, uid) {
+        async getNoticeContent(pid, tid, rid, uid, opinion = '') {
             const noticeSql =
                 'SELECT * FROM (SELECT ' +
                 '  t.`id` As `tid`, t.`name`, r.`corder`, r.`id` As rid, pa.`name` As `su_name`, pa.role As `su_role`' +
@@ -660,6 +660,9 @@ module.exports = app => {
                 '  WHERE  t.`project_id` = ? ) as new_t GROUP BY new_t.`tid`';
             const noticeSqlParam = [this.ctx.service.tender.tableName, tid, this.ctx.service.ledgerRevise.tableName, rid, this.ctx.service.projectAccount.tableName, uid, pid];
             const content = await this.db.query(noticeSql, noticeSqlParam);
+            if (content.length) {
+                content[0].opinion = opinion;
+            }
             return content.length ? JSON.stringify(content[0]) : '';
         }
 

+ 7 - 4
app/service/stage_audit.js

@@ -379,7 +379,7 @@ module.exports = app => {
             try {
                 await this._updateTender(transaction);
                 // 添加推送
-                const noticeContent = await this.getNoticeContent(pid, audit.tid, stageId, audit.aid);
+                const noticeContent = await this.getNoticeContent(pid, audit.tid, stageId, audit.aid, checkData.opinion);
                 const auditors = await this.getAuditGroupByListWithOwner(stageId, times);
                 const records = [];
                 auditors.forEach(audit => {
@@ -577,7 +577,7 @@ module.exports = app => {
             try {
                 await this._updateTender(transaction);
                 // 添加推送
-                const noticeContent = await this.getNoticeContent(pid, audit.tid, stageId, audit.aid);
+                const noticeContent = await this.getNoticeContent(pid, audit.tid, stageId, audit.aid, checkData.opinion);
                 const records = [
                     {
                         pid,
@@ -710,7 +710,7 @@ module.exports = app => {
             try {
                 await this._updateTender(transaction);
                 // 添加推送
-                const noticeContent = await this.getNoticeContent(pid, audit.tid, stageId, audit.aid);
+                const noticeContent = await this.getNoticeContent(pid, audit.tid, stageId, audit.aid, checkData.opinion);
                 const records = [
                     {
                         pid,
@@ -1077,7 +1077,7 @@ module.exports = app => {
          * @param {Number} sid 期id
          * @param {Number} uid 审核人id
          */
-        async getNoticeContent(pid, tid, sid, uid) {
+        async getNoticeContent(pid, tid, sid, uid, opinion = '') {
             const noticeSql =
                 'SELECT * FROM (SELECT ' +
                 '  t.`id` As `tid`, t.`name`, s.`order`, pa.`name` As `su_name`, pa.role As `su_role`' +
@@ -1087,6 +1087,9 @@ module.exports = app => {
                 '  WHERE  t.`project_id` = ? ) as new_t GROUP BY new_t.`tid`';
             const noticeSqlParam = [this.ctx.service.tender.tableName, tid, this.ctx.service.stage.tableName, sid, this.ctx.service.projectAccount.tableName, uid, pid];
             const content = await this.db.query(noticeSql, noticeSqlParam);
+            if (content.length) {
+                content[0].opinion = opinion;
+            }
             return content.length ? JSON.stringify(content[0]) : '';
         }