Browse Source

修复资金测试bug

ellisran 9 months ago
parent
commit
e887fc2396

+ 16 - 10
app/controller/financial_controller.js

@@ -596,31 +596,37 @@ module.exports = app => {
             if (!financialPermission.pay_show) {
             if (!financialPermission.pay_show) {
                 throw '没有查看权限';
                 throw '没有查看权限';
             }
             }
-            const tenders = await ctx.service.tender.getAllDataByCondition({ where: { spid: ctx.subProject.id }, columns: ['id', 'name'] });
+            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 filter = JSON.parse(JSON.stringify(auditConst.financial.filter));
+            const filterTids = tid === null ? (ctx.session.sessionUser.is_admin ? null : fptAuditTids) : [tid];
             filter.count = [];
             filter.count = [];
-            filter.count[filter.status.pending] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, filter.status.pending, tid, 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, tid, used);// await ctx.service.change.checkingDatas(tender.id, ctx.session.sessionUser.accountId);
-            filter.count[filter.status.checking] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, filter.status.checking, tid, used);// await ctx.service.change.checkedDatas(tender.id, ctx.session.sessionUser.accountId);
-            filter.count[filter.status.checked] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, filter.status.checked, tid, used);// await ctx.service.change.pendingDatas(tender.id, ctx.session.sessionUser.accountId);
-            const payList = await ctx.service.financialPay.getListByStatus(ctx.subProject.id, status, tid, used);
+            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);
+            filter.count[filter.status.checking] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, filter.status.checking, filterTids, used);// await ctx.service.change.checkedDatas(tender.id, ctx.session.sessionUser.accountId);
+            filter.count[filter.status.checked] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, filter.status.checked, filterTids, used);// await ctx.service.change.pendingDatas(tender.id, ctx.session.sessionUser.accountId);
+            const payList = await ctx.service.financialPay.getListByStatus(ctx.subProject.id, status, filterTids, used);
             // 获取所有项目参与者
             // 获取所有项目参与者
             const accountList = await ctx.service.projectAccount.getAllDataByCondition({
             const accountList = await ctx.service.projectAccount.getAllDataByCondition({
                 where: { project_id: ctx.session.sessionProject.id, enable: 1 },
                 where: { project_id: ctx.session.sessionProject.id, enable: 1 },
                 columns: ['id', 'account', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
                 columns: ['id', 'account', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
             });
             });
-            const fptAudits = await ctx.service.financialPayTenderAudit.getAllDataByCondition({ where: { spid: ctx.subProject.id, uid: ctx.session.sessionUser.accountId, is_report: 1 } });
-            const fptAuditTids = ctx.helper._.map(fptAudits, 'tid');
             const payTenders = await ctx.service.financialPayTender.getAllDataByCondition({ where: { spid: ctx.subProject.id } });
             const payTenders = await ctx.service.financialPayTender.getAllDataByCondition({ where: { spid: ctx.subProject.id } });
             for (const t of tenders) {
             for (const t of tenders) {
+                const fptReportTids = ctx.helper._.map(ctx.helper._.filter(fptAudits, { is_report: 1 }), 'tid');
                 const info = await ctx.service.tenderInfo.getDataByCondition({ tid: t.id });
                 const info = await ctx.service.tenderInfo.getDataByCondition({ tid: t.id });
                 t.pay_account = info && info.pay_account ? JSON.parse(info.pay_account).project : '';
                 t.pay_account = info && info.pay_account ? JSON.parse(info.pay_account).project : '';
                 const pt = ctx.helper._.find(payTenders, { tid: t.id });
                 const pt = ctx.helper._.find(payTenders, { tid: t.id });
                 t.pt = pt ? pt : { id: 0, tid: t.id, name: '', bank: '', bank_account: '', contact: '', phone: '' };
                 t.pt = pt ? pt : { id: 0, tid: t.id, name: '', bank: '', bank_account: '', contact: '', phone: '' };
-                if (ctx.session.sessionUser.is_admin || ctx.helper._.includes(fptAuditTids, t.id)) {
+                if (ctx.session.sessionUser.is_admin || ctx.helper._.includes(fptReportTids, t.id)) {
                     t.dealCode = info && info.deal_info ? JSON.parse(info.deal_info).dealCode : '';
                     t.dealCode = info && info.deal_info ? JSON.parse(info.deal_info).dealCode : '';
                     const lastPay = await ctx.service.financialPay.getAllDataByCondition({ where: { spid: ctx.subProject.id, tid: t.id }, columns: ['code'], orders: [['id', 'desc']], limit: 1 });
                     const lastPay = await ctx.service.financialPay.getAllDataByCondition({ where: { spid: ctx.subProject.id, tid: t.id }, columns: ['code'], orders: [['id', 'desc']], limit: 1 });
-                    t.startNum = lastPay.length > 0 ? parseInt(lastPay[0].code.split('-')[2]) + 1 : 1;
+                    t.startNum = 1;
+                    if (lastPay.length > 0) {
+                        const startArray = lastPay[0].code.split('-');
+                        t.startNum = parseInt(startArray[startArray.length - 1]) + 1;
+                    }
                 }
                 }
             }
             }
             for (const pay of payList) {
             for (const pay of payList) {

+ 4 - 0
app/middleware/financial_pay_check.js

@@ -39,6 +39,10 @@ module.exports = options => {
             const accountId = this.session.sessionUser.accountId,
             const accountId = this.session.sessionUser.accountId,
                 auditorIds = _.map(financialPay.auditors, 'aid');
                 auditorIds = _.map(financialPay.auditors, 'aid');
             if (financialPay.permission.pay_show) {
             if (financialPay.permission.pay_show) {
+                const fptAudits = yield this.service.financialPayTenderAudit.getDataByCondition({ spid: financialPay.spid, tid: financialPay.tid, uid: accountId });
+                if (!this.session.sessionUser.is_admin && !fptAudits) {
+                    throw '您无权查看该数据';
+                }
                 financialPay.filePermission = financialPay.permission.pay_file ||
                 financialPay.filePermission = financialPay.permission.pay_file ||
                     (financialPay.status === status.checking && auditorIds.indexOf(accountId) !== -1) ||
                     (financialPay.status === status.checking && auditorIds.indexOf(accountId) !== -1) ||
                     ((financialPay.status === status.uncheck || financialPay.status === status.checkNo) && accountId === financialPay.uid);
                     ((financialPay.status === status.uncheck || financialPay.status === status.checkNo) && accountId === financialPay.uid);

+ 2 - 2
app/service/financial_pay.js

@@ -41,7 +41,7 @@ module.exports = app => {
         async getListByStatus(spid, status = 0, tid = null, used = null) {
         async getListByStatus(spid, status = 0, tid = null, used = null) {
             let addSql = '';
             let addSql = '';
             if (tid) {
             if (tid) {
-                addSql += ' AND a.tid = ' + tid;
+                addSql += ' AND a.tid in (' + this.ctx.helper.getInArrStrSqlFilter(tid) + ')';
             }
             }
             if (used) {
             if (used) {
                 addSql += ' AND a.used = "' + used + '"';
                 addSql += ' AND a.used = "' + used + '"';
@@ -96,7 +96,7 @@ module.exports = app => {
         async getCountByStatus(spid, status = 0, tid = null, used = null) {
         async getCountByStatus(spid, status = 0, tid = null, used = null) {
             let addSql = '';
             let addSql = '';
             if (tid) {
             if (tid) {
-                addSql += ' AND a.tid = ' + tid;
+                addSql += ' AND a.tid in (' + this.ctx.helper.getInArrStrSqlFilter(tid) + ')';
             }
             }
             if (used) {
             if (used) {
                 addSql += ' AND a.used = "' + used + '"';
                 addSql += ' AND a.used = "' + used + '"';

+ 5 - 5
app/view/financial/modal.ejs

@@ -62,14 +62,14 @@
 <!--                        </div>-->
 <!--                        </div>-->
                     </div>
                     </div>
                 </div>
                 </div>
-                <table id="contract-audit-table" class="table table-bordered text-center" data-height="300" data-toggle="table">
+                <table id="contract-audit-table" class="table table-bordered text-center" data-height="500" data-toggle="table">
                     <thead>
                     <thead>
                     <tr>
                     <tr>
-                        <th rowspan="2">用户名</th>
-                        <th rowspan="2">角色/职位</th>
+                        <th rowspan="2" class="align-middle">用户名</th>
+                        <th rowspan="2" class="align-middle">角色/职位</th>
                         <th colspan="3">资金划拨</th>
                         <th colspan="3">资金划拨</th>
                         <th colspan="2">资金支付</th>
                         <th colspan="2">资金支付</th>
-                        <th rowspan="2">操作</th>
+                        <th rowspan="2" class="align-middle">操作</th>
                     </tr>
                     </tr>
                     <tr>
                     <tr>
                         <th>查看划拨</th>
                         <th>查看划拨</th>
@@ -188,7 +188,7 @@
             if (first) {
             if (first) {
                 const option = {
                 const option = {
                     locale: 'zh-CN',
                     locale: 'zh-CN',
-                    height: 300,
+                    height: 500,
                 }
                 }
                 $("#contract-audit-table").bootstrapTable('destroy').bootstrapTable(option);
                 $("#contract-audit-table").bootstrapTable('destroy').bootstrapTable(option);
                 first = 0;
                 first = 0;

+ 1 - 1
app/view/financial/pay_detail.ejs

@@ -77,7 +77,7 @@
                             <td width=""><input type="text" data-name="bank_account" value="<%- financialPay.bank_account %>" <% if (financialPay.readOnly) { %>readonly<% } %> class="form-control form-control-sm"></td>
                             <td width=""><input type="text" data-name="bank_account" value="<%- financialPay.bank_account %>" <% if (financialPay.readOnly) { %>readonly<% } %> class="form-control form-control-sm"></td>
                         </tr>
                         </tr>
                         <tr>
                         <tr>
-                            <th width="120px" >备注</th>
+                            <th width="120px" class="text-center align-middle">备注</th>
                             <td width=""colspan="5"><textarea class="form-control form-control-sm" data-name="remark" rows="3" <% if (financialPay.readOnly) { %>readonly<% } %>><%- financialPay.remark %></textarea></td>
                             <td width=""colspan="5"><textarea class="form-control form-control-sm" data-name="remark" rows="3" <% if (financialPay.readOnly) { %>readonly<% } %>><%- financialPay.remark %></textarea></td>
                         </tr>
                         </tr>
                         </tbody>
                         </tbody>