浏览代码

修复资金测试bug

ellisran 9 月之前
父节点
当前提交
9a2b900494

+ 13 - 2
app/controller/financial_controller.js

@@ -598,9 +598,20 @@ module.exports = app => {
             }
             const fptAudits = await ctx.service.financialPayTenderAudit.getAllDataByCondition({ where: { spid: ctx.subProject.id, uid: ctx.session.sessionUser.accountId } });
             const fptAuditTids = ctx.helper._.map(fptAudits, 'tid');
-            const tenders = await ctx.service.tender.getAllDataByCondition({ where: { spid: ctx.subProject.id, id: fptAuditTids }, columns: ['id', 'name'] });
-            const filter = JSON.parse(JSON.stringify(auditConst.financial.filter));
             const filterTids = tid === null ? (ctx.session.sessionUser.is_admin ? null : fptAuditTids) : [tid];
+            const tenderCondition = { spid: ctx.subProject.id };
+            let hadTender = false;
+            if (ctx.session.sessionUser.is_admin) {
+                hadTender = true;
+            } else if (fptAuditTids.length !== 0) {
+                hadTender = true;
+                tenderCondition.id = fptAuditTids;
+            } else {
+                hadTender = false;
+                tenderCondition.id = -1;
+            }
+            const tenders = hadTender ? await ctx.service.tender.getAllDataByCondition({ where: tenderCondition, columns: ['id', 'name'] }) : [];
+            const filter = JSON.parse(JSON.stringify(auditConst.financial.filter));
             filter.count = [];
             filter.count[filter.status.pending] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, filter.status.pending, filterTids, used);// await ctx.service.change.pendingDatas(tender.id, ctx.session.sessionUser.accountId);
             filter.count[filter.status.uncheck] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, filter.status.uncheck, filterTids, used);// await ctx.service.change.checkingDatas(tender.id, ctx.session.sessionUser.accountId);

+ 1 - 1
app/public/js/financial_transfer_tender.js

@@ -45,7 +45,7 @@ $(function () {
         const ftid = $(this).data('ftid');
         const value = $(this).val() || 0;
         postData(window.location.pathname + '/update', {postType: 'update-hb_tp', postData: { node: ftid, hb_tp: parseFloat(value) }}, function (result) {
-            window.location.reload();
+            // window.location.reload();
         });
     });
 

+ 8 - 2
app/service/financial_pay.js

@@ -40,7 +40,10 @@ module.exports = app => {
          */
         async getListByStatus(spid, status = 0, tid = null, used = null) {
             let addSql = '';
-            if (tid) {
+            if (tid !== null) {
+                if (tid.length === 0) {
+                    return [];
+                }
                 addSql += ' AND a.tid in (' + this.ctx.helper.getInArrStrSqlFilter(tid) + ')';
             }
             if (used) {
@@ -95,7 +98,10 @@ module.exports = app => {
          */
         async getCountByStatus(spid, status = 0, tid = null, used = null) {
             let addSql = '';
-            if (tid) {
+            if (tid !== null) {
+                if (tid.length === 0) {
+                    return 0;
+                }
                 addSql += ' AND a.tid in (' + this.ctx.helper.getInArrStrSqlFilter(tid) + ')';
             }
             if (used) {

+ 4 - 0
app/service/financial_transfer_tender.js

@@ -96,6 +96,10 @@ module.exports = app => {
             if (!node) {
                 throw '资金划拨标段不存在';
             }
+            if (node.is_lock) {
+                throw '资金划拨标段已锁定,无法修改';
+            }
+
             const transaction = await this.db.beginTransaction();
             try {
                 await transaction.update(this.tableName, { id: node.id, hb_tp });