Browse Source

修复支付审批部分bug

laiguoran 2 years ago
parent
commit
f596fba169

+ 4 - 3
app/controller/payment_controller.js

@@ -252,7 +252,7 @@ module.exports = app => {
                     preUrl: '/payment/' + ctx.tender.id + '/detail/' + ctx.detail.id,
                     OSS_PATH: ctx.app.config.fujianOssPath,
                 };
-
+                renderData.nextDetail = await ctx.service.paymentDetail.getDataByCondition({ tr_id: ctx.trInfo.id, order: ctx.detail.order + 1 });
                 let report_json = JSON.parse(ctx.detail.report_json);
                 const content = [];
                 // 获取当前报表人
@@ -277,7 +277,9 @@ module.exports = app => {
                             });
                         }
                     }
-                    if (ctx.detail.status !== auditConst.status.checked) {
+                    if (rptAudit && ((ctx.detail.status !== auditConst.status.checkNo && ctx.detail.status !== auditConst.status.checked) ||
+                        (ctx.detail.status === auditConst.status.checked && !renderData.nextDetail) ||
+                        (ctx.detail.status === auditConst.status.checkNo && ctx.detail.uid === ctx.session.sessionUser.accountId))) {
                         // 获取个人签字,单位章,个人章地址
                         const userInfo = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
                         const stampPathList = userInfo.stamp_path ? userInfo.stamp_path.split('!;!') : [];
@@ -299,7 +301,6 @@ module.exports = app => {
                 renderData.rptAudit = rptAudit;
                 renderData.content = content;
                 renderData.report_json = report_json;
-                renderData.nextDetail = await ctx.service.paymentDetail.getDataByCondition({ tr_id: ctx.trInfo.id, order: ctx.detail.order + 1 });
                 if ((ctx.detail.status === auditConst.status.uncheck || ctx.detail.status === auditConst.status.checkNo) && ctx.session.sessionUser.accountId === ctx.detail.uid) {
                     // data.accountGroup = accountGroup;
                     // 获取所有项目参与者

+ 7 - 1
app/middleware/payment_detail_check.js

@@ -37,9 +37,11 @@ module.exports = options => {
             // 读取原报、审核人数据
             detail.auditors = yield this.service.paymentDetailAudit.getAuditors(detail.id, detail.times);
             detail.curAuditor = yield this.service.paymentDetailAudit.getCurAuditor(detail.id, detail.times);
+            const rptAudits = yield this.service.paymentRptAudit.getAllDataByCondition({ where: { td_id: detail.id } });
 
             const accountId = this.session.sessionUser.accountId,
-                auditorIds = _.map(detail.auditors, 'aid');
+                auditorIds = _.map(detail.auditors, 'aid'),
+                rptAuditIds = _.map(rptAudits, 'uid');
             if (accountId === detail.uid) { // 原报
                 detail.curTimes = detail.times;
                 if (detail.status === status.uncheck || detail.status === status.checkNo) {
@@ -74,6 +76,10 @@ module.exports = options => {
                 } else {
                     detail.curOrder = accountId === detail.curAuditor.aid ? detail.curAuditor.order : detail.curAuditor.order - 1;
                 }
+            } else if (rptAuditIds.indexOf(accountId) !== -1) {
+                if (detail.status === status.uncheck || detail.status === status.checkNo) {
+                    throw '您无权查看该数据';
+                }
             } else { // 其他不可见
                 throw '您无权查看该数据';
             }

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

@@ -74,9 +74,9 @@ $(function () {
         $('#stamp_path').prop('checked', rptAudit.signature_msg.stamp_path !== null);
         $('#signature_date').val(rptAudit.signature_msg.date ? rptAudit.signature_msg.date : '');
         signatureDate = !signatureDate ? $('#signature_date').datepicker().data('datepicker') : signatureDate;
-        if (rptAudit.signature_msg.date) {
+        if (signatureDate && rptAudit.signature_msg.date) {
             signatureDate.selectDate(new Date(rptAudit.signature_msg.date));
-        } else {
+        } else if (signatureDate) {
             signatureDate.clear();
         }
         $('#signature_content').val(rptAudit.signature_msg.content ? rptAudit.signature_msg.content : '');

+ 12 - 8
app/service/payment_detail.js

@@ -195,22 +195,26 @@ module.exports = app => {
 
         async haveNotice2Tender(tid, uid) {
             const sql = 'SELECT count(pd.`id`) as count FROM ?? as pd LEFT JOIN ?? as pda' +
-                ' ON pd.`id` = pda.`td_id` WHERE pd.`tender_id` = ? AND (pd.`uid` = ? AND (pd.`status` = ? OR pd.`status` = ?))' +
-                ' OR ((pd.`status` = ? OR pd.`status` = ?) AND pda.aid = ? AND pda.`status` = ?)';
-            const params = [this.tableName, this.ctx.service.paymentDetailAudit.tableName, tid,
+                ' ON pd.`id` = pda.`td_id` LEFT JOIN ?? as pra ON pd.`id` = pra.`td_id` WHERE pd.`tender_id` = ? AND ((pd.`uid` = ? AND (pd.`status` = ? OR pd.`status` = ?))' +
+                ' OR ((pd.`status` = ? OR pd.`status` = ?) AND pda.aid = ? AND pda.`status` = ?)' +
+                ' OR (pra.`uid` = ? AND pra.`signature_msg` is null AND pd.`status` != ? AND pd.`status` != ?))';
+            const params = [this.tableName, this.ctx.service.paymentDetailAudit.tableName, this.ctx.service.paymentRptAudit.tableName, tid,
                 uid, auditConst.status.uncheck, auditConst.status.checkNo,
-                auditConst.status.checking, auditConst.status.checkNoPre, uid, auditConst.status.checking];
+                auditConst.status.checking, auditConst.status.checkNoPre, uid, auditConst.status.checking,
+                uid, auditConst.status.uncheck, auditConst.status.checkNo];
             const result = await this.db.queryOne(sql, params);
             return result ? result.count : 0;
         }
 
         async haveNotice2TenderRpt(tr_id, uid) {
             const sql = 'SELECT count(pd.`id`) as count FROM ?? as pd LEFT JOIN ?? as pda' +
-                ' ON pd.`id` = pda.`td_id` WHERE pd.`tr_id` = ? AND ((pd.`uid` = ? AND (pd.`status` = ? OR pd.`status` = ?))' +
-                ' OR ((pd.`status` = ? OR pd.`status` = ?) AND pda.aid = ? AND pda.`status` = ?))';
-            const params = [this.tableName, this.ctx.service.paymentDetailAudit.tableName, tr_id,
+                ' ON pd.`id` = pda.`tr_id` LEFT JOIN ?? as pra ON pd.`id` = pra.`td_id` WHERE pd.`tr_id` = ? AND ((pd.`uid` = ? AND (pd.`status` = ? OR pd.`status` = ?))' +
+                ' OR ((pd.`status` = ? OR pd.`status` = ?) AND pda.aid = ? AND pda.`status` = ?)' +
+                ' OR (pra.`uid` = ? AND pra.`signature_msg` is null AND pd.`status` != ? AND pd.`status` != ?))';
+            const params = [this.tableName, this.ctx.service.paymentDetailAudit.tableName, this.ctx.service.paymentRptAudit.tableName, tr_id,
                 uid, auditConst.status.uncheck, auditConst.status.checkNo,
-                auditConst.status.checking, auditConst.status.checkNoPre, uid, auditConst.status.checking];
+                auditConst.status.checking, auditConst.status.checkNoPre, uid, auditConst.status.checking,
+                uid, auditConst.status.uncheck, auditConst.status.checkNo];
             const result = await this.db.queryOne(sql, params);
             return result ? result.count : 0;
         }

+ 1 - 1
app/service/payment_detail_audit.js

@@ -394,7 +394,7 @@ module.exports = app => {
                 const updateDetailData = {
                     id: detailId,
                 };
-                const rptAudit = await this.getDataByCondition({ detailId, uid: audit.aid });
+                const rptAudit = await this.ctx.service.paymentRptAudit.getDataByCondition({ td_id: detailId, uid: audit.aid });
                 if (rptAudit && rptAudit.signature_msg) {
                     const report_json = JSON.parse(this.ctx.detail.report_json);
                     const sign_msg = JSON.parse(rptAudit.signature_msg);

+ 6 - 2
app/service/payment_tender.js

@@ -19,9 +19,13 @@ module.exports = app => {
 
         async getList(uid) {
             const sql = 'SELECT pt.*, pa.name as user_name FROM ?? as pt LEFT JOIN ?? as pa ON pt.`uid` = pa.`id` WHERE pt.`uid` = ? ' +
-                'OR pt.`id` in (SELECT pda.`tender_id` FROM ?? as pda LEFT JOIN ?? as pd ON pda.`tender_id` = pd.`tender_id` WHERE pd.`status` != ' + auditConst.status.uncheck + ' AND pda.`aid` = ?)';
+                'OR pt.`id` in (SELECT pda.`tender_id` FROM ?? as pda LEFT JOIN ?? as pd ON pda.`tender_id` = pd.`tender_id` ' +
+                'WHERE pd.`status` != ' + auditConst.status.uncheck + ' AND pda.`aid` = ?)' +
+                'OR pt.`id` in (SELECT pra.`tender_id` FROM ?? as pra LEFT JOIN ?? as pd ON pra.`tender_id` = pd.`tender_id` ' +
+                'WHERE (pd.`status` != ' + auditConst.status.uncheck + ' OR pd.`status` !=' + auditConst.status.checkNo + ') AND pra.`uid` = ?)';
             const params = [this.tableName, this.ctx.service.projectAccount.tableName, uid,
-                this.ctx.service.paymentDetailAudit.tableName, this.ctx.service.paymentDetail.tableName, uid];
+                this.ctx.service.paymentDetailAudit.tableName, this.ctx.service.paymentDetail.tableName, uid,
+                this.ctx.service.paymentRptAudit.tableName, this.ctx.service.paymentDetail.tableName, uid];
             return await this.db.query(sql, params);
         }
 

+ 4 - 2
app/service/payment_tender_rpt.js

@@ -19,8 +19,10 @@ module.exports = app => {
 
         async getList(tid, uid) {
             const sql = 'SELECT * FROM ?? WHERE `tender_id` = ?' +
-                ' AND `id` in (SELECT pda.`tr_id` FROM ?? as pda LEFT JOIN ?? as pd ON pda.`tr_id` = pd.`tr_id` WHERE pd.`status` != ' + auditConst.status.uncheck + ' AND pda.`aid` = ?)';
-            const params = [this.tableName, tid, this.ctx.service.paymentDetailAudit.tableName, this.ctx.service.paymentDetail.tableName, uid];
+                ' AND (`id` in (SELECT pda.`tr_id` FROM ?? as pda LEFT JOIN ?? as pd ON pda.`tr_id` = pd.`tr_id` WHERE pd.`status` != ' + auditConst.status.uncheck + ' AND pda.`aid` = ?)' +
+                ' OR `id` in (SELECT pra.`tr_id` FROM ?? as pra LEFT JOIN ?? as pd ON pra.`tr_id` = pd.`tr_id` WHERE (pd.`status` != ' + auditConst.status.uncheck + ' OR pd.`status` != ' + auditConst.status.checkNo + ') AND pra.`uid` = ?))';
+            const params = [this.tableName, tid, this.ctx.service.paymentDetailAudit.tableName, this.ctx.service.paymentDetail.tableName, uid,
+                this.ctx.service.paymentRptAudit.tableName, this.ctx.service.paymentDetail.tableName, uid];
             return await this.db.query(sql, params);
         }
 

+ 2 - 2
app/view/payment/list.ejs

@@ -4,10 +4,10 @@
             <div><%- ctx.tender.name %></div>
             <div>
                 <% if (ctx.session.sessionUser.accountId === trInfo.uid && trInfo.is_del === 0 && rptMsg) { %>
-                <% if (trDetailList.length === 0 || trDetailList[0].status === auditConst.status.checked) { %>
+                <% if (trDetailList.length === 0 || (trDetailList.length !== 0 && trDetailList[0].status === auditConst.status.checked)) { %>
                 <a href="javascript:void(0);" id="show-add-btn" class="btn btn-sm btn-primary pull-right ml-2">新建审批</a>
                 <% } %>
-                <% if (trDetailList.length === 0 || trDetailList[0].status === auditConst.status.uncheck || trDetailList[0].status === auditConst.status.checkNo) { %>
+                <% if (trDetailList.length === 0 || trDetailList[0].status === auditConst.status.checked || trDetailList[0].status === auditConst.status.uncheck || trDetailList[0].status === auditConst.status.checkNo) { %>
                 <a href="#set-bdjs" data-toggle="modal" data-target="#set-bdjs" class="btn btn-sm btn-primary pull-right">绑定表单角色</a>
                 <span class="text-danger pull-right" id="first_msg" <% if (trInfo.is_first === 0) { %>style="display:none;" <% } %>>第一次新建审批,请点击右侧的“绑定表单角色” &nbsp; &nbsp; </span>
                 <% } %>

+ 7 - 7
config/menu.js

@@ -57,13 +57,6 @@ const menu = {
         children: null,
         caption: '动态投资',
     },
-    management: {
-        name: '项目管理系统',
-        icon: 'fa-cubes',
-        display: false,
-        caption: '项目管理系统',
-        children: null,
-    },
     payment: {
         name: '支付审批',
         icon: 'fa-handshake-o',
@@ -72,6 +65,13 @@ const menu = {
         caption: '支付审批',
         children: null,
     },
+    management: {
+        name: '项目管理系统',
+        icon: 'fa-cubes',
+        display: false,
+        caption: '项目管理系统',
+        children: null,
+    },
     // sum: {
     //     name: '总分包',
     //     icon: 'fa-sitemap',