ソースを参照

Merge branch 'dev' of http://192.168.1.41:3000/maixinrong/Calculation into dev

Tony Kang 3 週間 前
コミット
0986827e01

+ 32 - 15
app/controller/financial_controller.js

@@ -585,6 +585,7 @@ module.exports = app => {
                 await this._filterPayStage(ctx, company, qi);
             } catch (err) {
                 this.log(err);
+                ctx.session.postError = err.toString();
                 ctx.redirect(`/sp/${ctx.subProject.id}/dashboard`);
             }
         }
@@ -617,9 +618,9 @@ module.exports = app => {
             if (!userCompany) {
                 throw '请联系管理员添加用户所在单位信息';
             }
-            const userOrderList = await ctx.service.financialPayStage.getUserOrderList(ctx.subProject.id, userCompany ? userCompany.id : 0);
-            const userCompanyList = await ctx.service.financialPayStage.getUserCompanyList(ctx.subProject.id, userCompany ? userCompany.id : 0, unitList);
             const companyInfo = company ? ctx.helper._.find(unitList, { name: company }) : null;
+            const userOrderList = await ctx.service.financialPayStage.getUserOrderList(ctx.subProject.id, userCompany ? userCompany.id : 0, companyInfo ? companyInfo.id : null);
+            const userCompanyList = await ctx.service.financialPayStage.getUserCompanyList(ctx.subProject.id, userCompany ? userCompany.id : 0, unitList, qi);
             const payList = await ctx.service.financialPayStage.getListByStatus(ctx.subProject.id, companyInfo ? companyInfo.id : null, userCompany ? userCompany.id : 0, qi);
             const total = await ctx.service.financialPayStage.getCountByStatus(ctx.subProject.id, companyInfo ? companyInfo.id : null, userCompany ? userCompany.id : 0, qi);
             // 分页相关
@@ -782,7 +783,8 @@ module.exports = app => {
                 await this._filterPay(ctx, status, tid, used, from);
             } catch (err) {
                 this.log(err);
-                ctx.redirect(`/sp/${ctx.subProject.id}/dashboard`);
+                ctx.session.postError = err.toString();
+                ctx.redirect(`/sp/${ctx.subProject.id}/financial/pay/stage`);
             }
         }
 
@@ -820,6 +822,7 @@ module.exports = app => {
             filter.count[filter.status.checking] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, payStage.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, payStage.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, payStage.id, status, filterTids, used, 1);
+            const userTenderList = await ctx.service.financialPay.getUserTenderList(ctx.subProject.id, ctx.session.sessionUser.accountId, payStage.id);
             const total = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, payStage.id, status, filterTids, used);
             // 分页相关
             const page = ctx.page;
@@ -834,6 +837,15 @@ module.exports = app => {
             };
             // 获取所有项目参与者
             const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject, ['id', 'account', 'name', 'company', 'company_id', 'role', 'enable', 'is_admin', 'account_group', 'mobile']);
+            const user = accountList.find(item => item.id === ctx.session.sessionUser.accountId) || null;
+            const userCompany = user ? ctx.helper._.find(unitList, { name: user.company }) : null;
+            if (!userCompany) {
+                throw '请联系管理员添加用户所在单位信息';
+            }
+            const userCompanyList = await ctx.service.financialPayStage.getUserCompanyList(ctx.subProject.id, userCompany ? userCompany.id : 0, unitList);
+            if (userCompanyList.length === 0 || !ctx.helper._.includes(ctx.helper._.map(userCompanyList, 'id'), payStage.company_id)) {
+                throw '没有查看权限';
+            }
             const payTenders = await ctx.service.financialPayTender.getAllDataByCondition({ where: { spid: ctx.subProject.id } });
             if (tenders.length > 0) {
                 const allLastPay = await ctx.service.financialPay.getAllDataByCondition({ where: { spid: ctx.subProject.id, tid: ctx.helper._.map(tenders, 'id') }, columns: ['id', 'tid', 'code'], orders: [['id', 'desc']] });
@@ -892,6 +904,7 @@ module.exports = app => {
             const renderData = {
                 categoryData,
                 tenders,
+                userTenderList,
                 financialPermission,
                 usedList: financialConst.used,
                 auditConst: auditConst.financial,
@@ -979,6 +992,7 @@ module.exports = app => {
                 await this._filterPayList(ctx, company, qi, status, tid, used);
             } catch (err) {
                 this.log(err);
+                ctx.session.postError = err.toString();
                 ctx.redirect(`/sp/${ctx.subProject.id}/dashboard`);
             }
         }
@@ -1012,23 +1026,24 @@ module.exports = app => {
             if (!userCompany) {
                 throw '请联系管理员添加用户所在单位信息';
             }
-            const userOrderList = await ctx.service.financialPayStage.getUserOrderList(ctx.subProject.id, userCompany ? userCompany.id : 0);
-            const userCompanyList = await ctx.service.financialPayStage.getUserCompanyList(ctx.subProject.id, userCompany ? userCompany.id : 0, unitList);
-            let fpsidList = [];
+            const companyInfo = company ? ctx.helper._.find(unitList, { name: company }) : null;
+            const userCompanyList = await ctx.service.financialPayStage.getUserCompanyList(ctx.subProject.id, userCompany ? userCompany.id : 0, unitList, qi);
+            const userOrderList = await ctx.service.financialPayStage.getUserOrderList(ctx.subProject.id, userCompany ? userCompany.id : 0, companyInfo ? companyInfo.id : null);
+            const userTenderList = await ctx.service.financialPay.getUserTenderList(ctx.subProject.id, ctx.session.sessionUser.accountId);
+            let fpsidList = null;
             if (company || qi) {
-                const companyInfo = company ? ctx.helper._.find(unitList, { name: company }) : null;
                 const fpstageList = await ctx.service.financialPayStage.getListByStatus(ctx.subProject.id, companyInfo ? companyInfo.id : null, userCompany ? userCompany.id : 0, qi, 0);
-                fpsidList = ctx.helper._.map(fpstageList, 'id');
+                fpsidList = fpstageList.length > 0 ? ctx.helper._.map(fpstageList, 'id') : 0;
             }
             // const payList = await ctx.service.financialPayStage.getListByStatus(ctx.subProject.id, companyInfo ? companyInfo.id : null, userCompany ? userCompany.id : 0, qi);
             const filter = JSON.parse(JSON.stringify(auditConst.financial.filter));
             filter.count = [];
-            filter.count[filter.status.pending] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, fpsidList.length > 0 ? fpsidList : null, filter.status.pending, filterTids, used);
-            filter.count[filter.status.uncheck] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, fpsidList.length > 0 ? fpsidList : null, filter.status.uncheck, filterTids, used);
-            filter.count[filter.status.checking] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, fpsidList.length > 0 ? fpsidList : null, filter.status.checking, filterTids, used);
-            filter.count[filter.status.checked] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, fpsidList.length > 0 ? fpsidList : null, filter.status.checked, filterTids, used);
-            const payList = await ctx.service.financialPay.getListByStatus(ctx.subProject.id, fpsidList.length > 0 ? fpsidList : null, status, filterTids, used, 1);
-            const total = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, fpsidList.length > 0 ? fpsidList : null, status, filterTids, used);
+            filter.count[filter.status.pending] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, fpsidList !== null ? fpsidList : null, filter.status.pending, filterTids, used);
+            filter.count[filter.status.uncheck] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, fpsidList !== null ? fpsidList : null, filter.status.uncheck, filterTids, used);
+            filter.count[filter.status.checking] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, fpsidList !== null ? fpsidList : null, filter.status.checking, filterTids, used);
+            filter.count[filter.status.checked] = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, fpsidList !== null ? fpsidList : null, filter.status.checked, filterTids, used);
+            const payList = await ctx.service.financialPay.getListByStatus(ctx.subProject.id, fpsidList !== null ? fpsidList : null, status, filterTids, used, 1);
+            const total = await ctx.service.financialPay.getCountByStatus(ctx.subProject.id, fpsidList !== null ? fpsidList : null, status, filterTids, used);
             // 分页相关
             const page = ctx.page;
             const pageSize = ctx.pageSize;
@@ -1071,6 +1086,7 @@ module.exports = app => {
                 used,
                 company,
                 qi,
+                userTenderList,
                 userCompanyList,
                 userOrderList,
                 payList,
@@ -1129,6 +1145,7 @@ module.exports = app => {
                 await this._filterPayTender(ctx);
             } catch (err) {
                 this.log(err);
+                ctx.session.postError = err.toString();
                 ctx.redirect(`/sp/${ctx.subProject.id}/dashboard`);
             }
         }
@@ -1266,7 +1283,7 @@ module.exports = app => {
                 jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.financial.payTender),
                 // pageInfo,
             };
-            await this.layout('financial/pay_tender.ejs', renderData);
+            await this.layout('financial/pay_tender.ejs', renderData, 'financial/pay_list_modal.ejs');
         }
 
         async payTenderSave(ctx) {

+ 5 - 5
app/controller/report_controller.js

@@ -167,11 +167,11 @@ module.exports = app => {
         async _resetAccCompanySignPath(ctx, prjAccList) {
             // 新需求: 如没有授权公司章的,要取自己的章
             for (let idx = 0; idx < prjAccList.length; idx++) {
-                if (prjAccList[idx].unit_sign_path === undefined || prjAccList[idx].unit_sign_path === null || prjAccList[idx].unit_sign_path === '') {
-                    // getUserUnitSign
-                    const signPaths = await ctx.service.projectAccount.getUserUnitSign(prjAccList[idx].id);
-                    prjAccList[idx].unit_sign_path = signPaths.join('&%&');
-                }
+                // if (prjAccList[idx].unit_sign_path === undefined || prjAccList[idx].unit_sign_path === null || prjAccList[idx].unit_sign_path === '') {
+                // getUserUnitSign
+                const signPaths = await ctx.service.projectAccount.getUserUnitSign(prjAccList[idx].id);
+                prjAccList[idx].unit_sign_path = signPaths.join('&%&');
+                // }
             }
         }
 

+ 1 - 1
app/lib/bills_pos_convert.js

@@ -95,7 +95,7 @@ class BillsPosConvert {
                 let end_contract_qty = data.contract_qty;
                 activeQty = this.ctx.helper.add(activeQty, data.pre_qc_minus_qty);
                 end_contract_qty = this.ctx.helper.add(end_contract_qty, data.pre_contract_qty);
-                const end_contract_tp = this.ctx.helper.mul(end_contract_qty, data.total_price, info.decimal.tp);
+                const end_contract_tp = this.ctx.helper.mul(end_contract_qty, node.unit_price, info.decimal.tp);
                 return activeQty === end_contract_qty ? this.ctx.helper.sub(end_contract_tp, data.pre_contract_tp) : this.ctx.helper.mul(node.unit_price, data.contract_qty, info.decimal.tp);
             } else {
                 return this.ctx.helper.mul(node.unit_price, data.contract_qty, info.decimal.tp);

+ 170 - 0
app/public/js/financial_pay_tender.js

@@ -278,6 +278,163 @@ $(function () {
         $('.c-body .tender-info').eq(0).click();// 需要延时加载
     }, 500);
 
+    $('#audit-list').on('click', 'a', function() {
+        const type = $(this).data('target')
+        const auditCard = $(this).parent().parent()
+        if (type === 'show') {
+            $(this).data('target', 'hide')
+            auditCard.find('.fold-card').slideDown('swing', () => {
+                auditCard.find('#end-target').text($(this).data('idx') + '#')
+                auditCard.find('#fold-btn').text('收起历史审核记录')
+            })
+        } else {
+            $(this).data('target', 'show')
+            auditCard.find('.fold-card').slideUp('swing', () => {
+                auditCard.find('#end-target').text('1#')
+                auditCard.find('#fold-btn').text('展开历史审核记录')
+            })
+        }
+    });
+
+    // 获取审批流程
+    $('body').on('click', 'a[data-target="#sp-list" ]', function () {
+        const data = {
+            type: 'get-auditors',
+            id: $(this).attr('c-id'),
+        };
+        postData(`/sp/${spid}/financial/pay/save`, data, function (result) {
+            const { auditHistory, auditors2, user } = result;
+            let auditorsHTML = [];
+            auditors2.forEach((group, idx) => {
+                if (idx === 0) {
+                    auditorsHTML.push(`<li class="list-group-item d-flex justify-content-between align-items-center">
+                        <span class="mr-1"><i class="fa fa fa-play-circle fa-rotate-90"></i></span>
+                    <span class="text-muted">${getGroupAuditHtml(group)}</span>
+                    <span class="badge badge-light badge-pill ml-auto"><small>原报</small></span>
+                    </li>`);
+                } else if(idx === auditors2.length -1 && idx !== 0) {
+                    auditorsHTML.push(`<li class="list-group-item d-flex justify-content-between align-items-center">
+                        <span class="mr-1"><i class="fa fa fa-stop-circle fa-rotate-90"></i></span>
+                    <span class="text-muted">${getGroupAuditHtml(group)}</span>
+                    <div class="d-flex ml-auto">
+                    ${getAuditTypeHtml(group[0].audit_type)}
+                    <span class="badge badge-light badge-pill ml-auto"><small>终审</small></span>
+                    </div>
+                    </li>`);
+                } else {
+                    auditorsHTML.push(`<li class="list-group-item d-flex justify-content-between align-items-center">
+                        <span class="mr-1"><i class="fa fa fa-chevron-circle-down"></i></span>
+                    <span class="text-muted">${getGroupAuditHtml(group)}</span>
+                    <div class="d-flex ml-auto">
+                    ${getAuditTypeHtml(group[0].audit_type)}
+                    <span class="badge badge-light badge-pill"><small>${transFormToChinese(idx)}审</small></span>
+                    </div>
+                    </li>`);
+                }
+            });
+            $('#auditor-list').empty();
+            $('#auditor-list').append(auditorsHTML.join(''));
+
+            let historyHTML = [];
+            auditHistory.forEach((his, idx) => {
+                if (idx === auditHistory.length - 1 && auditHistory.length !== 1) {
+                    historyHTML.push(`<div class="text-right"><a href="javascript: void(0);" id="fold-btn" data-target="show">展开历史审批流程</a></div>`);
+                }
+                historyHTML.push(`<div class="${idx < auditHistory.length - 1 ? 'fold-card' : ''}">`);
+                historyHTML.push(`<div class="text-center text-muted">${idx+1}#</div>`);
+                historyHTML.push(`<ul class="timeline-list list-unstyled mt-2 ${ idx === auditHistory.length - 1 && auditHistory.length !== 1 ? 'last-auditor-list' : '' }">`);
+                his.forEach((group, index) => {
+                    if (index === 0) {
+                        historyHTML.push(`<li class="timeline-list-item pb-2">
+                                            <div class="timeline-item-date">
+                                                ${group.beginYear}
+                                                <span>${group.beginDate}</span>
+                                                <span>${group.beginTime}</span>
+                                            </div>
+                                            <div class="timeline-item-tail"></div>
+                                            <div class="timeline-item-icon bg-success text-light"><i class="fa fa-caret-down"></i></div>
+                                            <div class="timeline-item-content">
+                                                <div class="py-1">
+                                                    <span class="text-black-50">原报</span>
+                                                    <span class="pull-right text-success">${idx !== 0 ? '重新' : '' }上报审批</span>
+                                                </div>
+                                                <div class="card">
+                                                    <div class="card-body px-3 py-0">
+                                                        <div class="card-text p-2 py-3 row">
+                                                            <div class="col">
+                                                                <span class="h6">${user.name}</span>
+                                                                <span class="text-muted ml-1">${user.role}</span>
+                                                            </div>
+                                                            <div class="col">
+                                                                <span class="pull-right text-success"><i class="fa fa-check-circle"></i></span>
+                                                            </div>
+                                                        </div>
+                                                    </div>
+                                                </div>
+                                            </div>
+                                        </li>`);
+                    }
+                    historyHTML.push(`<li class="timeline-list-item pb-2 ${ group.status === auditConst.status.uncheck && idx === auditHistory.length - 1 && auditHistory.length !== 1 ? 'is_uncheck' : ''}">`);
+                    if (group.endYear) {
+                        historyHTML.push(`<div class="timeline-item-date">${group.endYear}<span>${group.endDate}</span><span>${group.endTime}</span></div>`);
+                    }
+                    if (index < his.length - 1) {
+                        historyHTML.push('<div class="timeline-item-tail"></div>');
+                    }
+                    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) {
+                        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>');
+                    } else if (group.status === auditConst.status.checkAgain) {
+                        historyHTML.push('<div class="timeline-item-icon bg-warning text-light"><i class="fa fa-check"></i></div>');
+                    } else {
+                        historyHTML.push('<div class="timeline-item-icon bg-secondary text-light"></div>');
+                    }
+
+                    historyHTML.push('<div class="timeline-item-content">');
+                    historyHTML.push('<div class="py-1">');
+                    const statuStr = group.status !== auditConst.status.uncheck ?
+                        `<span class="pull-right ${auditConst.statusClass[group.status]}">${auditConst.statusString[group.status]}</span>` : '';
+                    historyHTML.push(`
+                    <span class="text-black-50">
+                    ${ group.audit_order === 0 ? '原报' : !group.is_final ? group.audit_order + '审' : '终审' } ${getAuditTypeText(group.audit_type)}
+                    </span>
+                    ${statuStr}`);
+                    historyHTML.push('</div>');
+                    historyHTML.push('<div class="card"><div class="card-body px-3 py-0">');
+                    for (const [i, auditor] of group.auditors.entries()) {
+                        historyHTML.push(`<div class="card-text p-2 py-3 row ${ ( i > 0 ? 'border-top' : '') }">`);
+                        historyHTML.push(`<div class="col"><span class="h6">${auditor.name}</span><span class="text-muted ml-1">${auditor.role}</span></div>`);
+                        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) {
+                            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>');
+                        } else if (auditor.status === auditConst.status.checkAgain) {
+                            historyHTML.push('<span class="pull-right text-warning"><i class="fa fa-check"></i></span>');
+                        }
+                        historyHTML.push('</div>');
+                        if (auditor.opinion) {
+                            historyHTML.push(`<div class="col-12 py-1 bg-light"><i class="fa fa-commenting-o mr-1"></i>${auditor.opinion}</div>`);
+                        }
+                        historyHTML.push('</div>');
+                    }
+                    historyHTML.push('</div></div>');
+                    historyHTML.push('</div>');
+                    historyHTML.push('</li>');
+                });
+                historyHTML.push('</div>');
+                historyHTML.push('</ul>');
+            });
+            $('#audit-list').empty();
+            $('#audit-list').append(historyHTML.join(''));
+        });
+    });
+
     $.subMenu({
         menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
         toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',
@@ -295,3 +452,16 @@ $(function () {
         }
     });
 });
+const getGroupAuditHtml = function (group) {
+    return group.map(u => { return `<small class="d-inline-block text-dark mx-1" title="${u.role}" data-auditorId="${u.aid}">${u.name}</small>`; }).join('');
+};
+
+const getAuditTypeHtml = function (type) {
+    if (type === auditType.key.common) return '';
+    return `<div class="li-subscript"><span class="badge badge-pill badge-${auditType.info[type].class} p-1 badge-bg-small"><small>${auditType.info[type].short}</small></span></div>`;
+};
+
+const getAuditTypeText = function (type) {
+    if (type === auditType.key.common) return '';
+    return `<span class="text-${auditType.info[type].class}">${auditType.info[type].long}</span>`;
+};

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

@@ -4,7 +4,7 @@ $(document).ready(() => {
     const xmjSheet = xmjSpread.getActiveSheet();
     const xmjSpreadSetting = {
         cols: [
-            { title: '工程编号', colSpan: '1', rowSpan: '1', field: 'code', hAlign: 0, width: 135, formatter: '@', cellType: 'tree' },
+            { title: '工程编号', colSpan: '1', rowSpan: '1', field: 'code', hAlign: 0, width: 200, formatter: '@', cellType: 'tree' },
             { title: '工程名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 195, formatter: '@' },
         ],
         emptyRows: 0,

+ 8 - 2
app/public/js/quality_rule.js

@@ -68,8 +68,10 @@ $(() => {
         };
         const loadGroupRules = function(group) {
             const html = [];
-            for (const rule of group.rules) {
-                html.push(`<tr class="text-center" ruleId = "${rule.id}">`, getRuleHtml(rule), '</tr>');
+            if (group) {
+                for (const rule of group.rules) {
+                    html.push(`<tr class="text-center" ruleId = "${rule.id}">`, getRuleHtml(rule), '</tr>');
+                }
             }
             $('#ruleOptions').html(html.join(''));
         };
@@ -115,6 +117,10 @@ $(() => {
                 $(`dd[groupId=${result.del}]`).remove();
                 const groupIndex = groups.findIndex(x => { return x.group_id === group_id; });
                 groups.splice(groupIndex, 1);
+                if (curGroup.group_id === group_id) {
+                    curGroup = null;
+                    loadGroupRules();
+                }
             });
         };
 

+ 1 - 0
app/router.js

@@ -443,6 +443,7 @@ module.exports = app => {
     app.post('/sp/:id/financial/pay/stage/save', sessionAuth, subProjectCheck, financialCheck, 'financialController.payStageSave');
     app.get('/sp/:id/financial/pay/stage/:fpsid', sessionAuth, subProjectCheck, financialCheck, 'financialController.pay');
     app.post('/sp/:id/financial/pay/stage/:fpsid/save', sessionAuth, subProjectCheck, financialCheck, 'financialController.paySave');
+    app.post('/sp/:id/financial/pay/save', sessionAuth, subProjectCheck, financialCheck, 'financialController.paySave');
     app.get('/sp/:id/financial/pay/:fpid/detail', sessionAuth, subProjectCheck, financialCheck, financialPayCheck, financialPayAuditCheck, 'financialController.payDetail');
     app.post('/sp/:id/financial/pay/:fpid/save', sessionAuth, subProjectCheck, financialCheck, financialPayCheck, 'financialController.payDetailSave');
     app.post('/sp/:id/financial/pay/:fpid/file/upload', sessionAuth, subProjectCheck, financialCheck, financialPayCheck, 'financialController.payUploadFile');

+ 18 - 2
app/service/financial_pay.js

@@ -42,7 +42,7 @@ module.exports = app => {
          */
         async getListByStatus(spid, fpsid = null, status = 0, tid = null, used = null, hadlimit = 0, sortBy = '', orderBy = '') {
             let addSql = '';
-            if (fpsid) {
+            if (fpsid !== null) {
                 fpsid = fpsid instanceof Array ? fpsid : [fpsid];
                 addSql += ' AND a.fpsid in (' + this.ctx.helper.getInArrStrSqlFilter(fpsid) + ')';
             }
@@ -118,7 +118,7 @@ module.exports = app => {
          */
         async getCountByStatus(spid, fpsid = null, status = 0, tid = null, used = null, company_id = null, user_company_id, qi = null) {
             let addSql = '';
-            if (fpsid) {
+            if (fpsid !== null) {
                 fpsid = fpsid instanceof Array ? fpsid : [fpsid];
                 addSql += ' AND a.fpsid in (' + this.ctx.helper.getInArrStrSqlFilter(fpsid) + ')';
             }
@@ -172,6 +172,22 @@ module.exports = app => {
             }
         }
 
+        async getUserTenderList(spid, uid, fpsid = null) {
+            let addSql = '';
+            let notAdminSql = '';
+            if (fpsid) {
+                addSql += ' AND a.fpsid = ' + fpsid;
+            }
+            if (!this.ctx.session.sessionUser.is_admin) {
+                notAdminSql += 'a.tid in (SELECT tid FROM ' + this.ctx.service.financialPayAudit.tableName + ' WHERE aid = ' + this.ctx.session.sessionUser.accountId + (fpsid ? ' AND fpsid = ' + fpsid : '') + ' GROUP BY tid)';
+                addSql += ' AND (a.uid = ' + uid + ' OR ' + notAdminSql + ')';
+            }
+            const sql = 'SELECT a.tid, t.name FROM ?? As a LEFT JOIN ?? As t ON a.tid = t.id' +
+                ' WHERE a.spid = ?' + addSql + ' GROUP BY a.tid';
+            const sqlParam = [this.tableName, this.ctx.service.tender.tableName, spid];
+            return await this.db.query(sql, sqlParam);
+        }
+
         async addPay(spid, payStage, data) {
             if (!data.tid || !data.code || !data.used) {
                 throw '参数错误';

+ 4 - 4
app/service/financial_pay_stage.js

@@ -30,12 +30,12 @@ module.exports = app => {
             return await this.db.queryOne(sql, sqlParam);
         }
 
-        async getUserCompanyList(spid, user_company_id, unitList) {
+        async getUserCompanyList(spid, user_company_id, unitList, qi = null) {
             let userCompanyList = [];
             if (this.ctx.session.sessionUser.is_admin) {
                 userCompanyList = unitList;
             } else {
-                let addSql = '';
+                let addSql = qi ? ' AND a.order = ' + qi : '';
                 let notAdminSql = '';
                 if (!this.ctx.session.sessionUser.is_admin) {
                     notAdminSql += '(a.id in (SELECT fpsid FROM ' + this.ctx.service.financialPay.tableName + ' WHERE uid = ' + this.ctx.session.sessionUser.accountId + ' GROUP BY fpsid)' +
@@ -60,8 +60,8 @@ module.exports = app => {
             return userCompanyList;
         }
 
-        async getUserOrderList(spid, user_company_id) {
-            let addSql = '';
+        async getUserOrderList(spid, user_company_id, company_id = null) {
+            let addSql = company_id ? ' AND a.company_id = ' + company_id : '';
             let notAdminSql = '';
             if (!this.ctx.session.sessionUser.is_admin) {
                 notAdminSql += '(a.id in (SELECT fpsid FROM ' + this.ctx.service.financialPay.tableName + ' WHERE uid = ' + this.ctx.session.sessionUser.accountId + ' GROUP BY fpsid)' +

+ 3 - 2
app/service/project_account.js

@@ -1120,8 +1120,9 @@ module.exports = app => {
             if (!userInfo || !userInfo.company) {
                 return [];
             }
-            if (userInfo.unit_sign_path) {
-                return userInfo.unit_sign_path.split('&%&');
+            const userPermission = userInfo !== undefined && userInfo.permission !== '' ? JSON.parse(userInfo.permission) : null;
+            if (userPermission !== null && userPermission.other !== undefined && userPermission.other.indexOf('1') !== -1) {
+                return userInfo.unit_sign_path ? userInfo.unit_sign_path.split('&%&') : [];
             }
             const info = await this.ctx.service.constructionUnit.getDataByCondition({ pid: userInfo.project_id, name: userInfo.company });
             if (!info || info.sign_permission === 0) {

+ 2 - 2
app/service/stage_change.js

@@ -860,7 +860,7 @@ module.exports = app => {
             const stageBills = await this.ctx.service.stageBills.getAllDataByCondition({ where: { sid: stage.id } });
             const stagePos = await this.ctx.service.stagePos.getAllDataByCondition({ where: { sid: stage.id } });
             const stageChange = await this.ctx.service.stageChange.getAllDataByCondition({ where: { sid: stage.id, lid }});
-            const preStageBills = stage.preCheckedStage ? await this.ctx.service.stageBillsFinal.getFinalData(stage.tid, stage.preCheckedStage.order) : [];
+            const preStageBills = stage.preCheckedStage ? await this.ctx.service.stageBillsFinal.getFinalData(tender, stage.preCheckedStage.order) : [];
 
             const useModal = new autoUseChange(this.ctx, tender.info);
             const projectFunInfo = this.ctx.subProject.fun_rela;
@@ -911,7 +911,7 @@ module.exports = app => {
             ]);
             const stageBills = await this.ctx.service.stageBills.getAllDataByCondition({ where: { sid: stage.id } });
             const stagePos = await this.ctx.service.stagePos.getAllDataByCondition({ where: { sid: stage.id } });
-            const preStageBills = stage.preCheckedStage ? await this.ctx.service.stageBillsFinal.getFinalData(stage.tid, stage.preCheckedStage.order) : [];
+            const preStageBills = stage.preCheckedStage ? await this.ctx.service.stageBillsFinal.getFinalData(tender, stage.preCheckedStage.order) : [];
             const useModal = new autoUseChange(this.ctx, tender.info, this.ctx.service.settle.settleStatus);
             const projectFunInfo = this.ctx.subProject.fun_rela;
             const minusNoValue = projectFunInfo.minusNoValue && tender.info.fun_rela.stage_change.minusNoValue;

+ 2 - 2
app/service/stage_stash.js

@@ -481,7 +481,7 @@ module.exports = app => {
                 const stageBills = await this.ctx.service.stageBills.getAllDataByCondition({ where: { sid: stage.id } });
                 const stagePos = await this.ctx.service.stagePos.getAllDataByCondition({ where: { sid: stage.id } });
                 const stageBillsDgn = await this.ctx.service.stageBillsDgn.getAllDataByCondition({ where: { tid: stage.tid } });
-                const preStageBills = stage.preCheckedStage ? await this.ctx.service.stageBillsFinal.getFinalData(stage.tid, this.ctx.stage.preCheckedStage.order) : [];
+                const preStageBills = stage.preCheckedStage ? await this.ctx.service.stageBillsFinal.getFinalData(this.ctx.tender, this.ctx.stage.preCheckedStage.order) : [];
 
                 const loadModal = new loadStageExcelTree(this.ctx);
                 loadModal.load(cacheTree, { ledgerData, posData, stageBills, stagePos, stageBillsDgn, preStageBills, default: { tid: stage.tid, sid: stage.id, said: this.ctx.session.sessionUser.accountId } });
@@ -540,7 +540,7 @@ module.exports = app => {
                 const stageBills = await this.ctx.service.stageBills.getAllDataByCondition({ where: { sid: stage.id } });
                 const stagePos = await this.ctx.service.stagePos.getAllDataByCondition({ where: { sid: stage.id } });
                 const stageBillsDgn = await this.ctx.service.stageBillsDgn.getAllDataByCondition({ where: { tid: stage.tid } });
-                const preStageBills = stage.preCheckedStage ? await this.ctx.service.stageBillsFinal.getFinalData(stage.tid, this.ctx.stage.preCheckedStage.order) : [];
+                const preStageBills = stage.preCheckedStage ? await this.ctx.service.stageBillsFinal.getFinalData(this.ctx.tender, this.ctx.stage.preCheckedStage.order) : [];
 
                 const loadModal = new loadStageExcelTree(this.ctx);
                 loadModal.loadDeal(dealTree, dealPos, { ledgerData, posData, stageBills, stagePos, stageBillsDgn, preStageBills, default: { tid: stage.tid, sid: stage.id, said: this.ctx.session.sessionUser.accountId } });

+ 3 - 3
app/view/financial/pay.ejs

@@ -9,8 +9,8 @@
                     <div class="input-group input-group-sm pr-1">
                         <select class="form-control form-control-sm col-auto" id="tid_select">
                             <option value="0">全部</option>
-                            <% for (const t of tenders) { %>
-                            <option value="<%- t.id %>" <% if (t.id === tid) { %>selected<% } %> ><%- t.name %></option>
+                            <% for (const t of userTenderList) { %>
+                            <option value="<%- t.tid %>" <% if (t.tid === tid) { %>selected<% } %> ><%- t.name %></option>
                             <% } %>
                         </select>
                     </div>
@@ -44,7 +44,7 @@
                         </div>
                     </div>
                 </div>
-                <% if (notStagePays.length > 0 && (ctx.session.sessionUser.is_admin || fptReportTids.length > 0)) { %>
+                <% if (notStagePays.length > 0 && ctx.session.sessionUser.is_admin) { %>
                 <div class="d-inline-block">
                     <a href="#contract-old-pay" data-toggle="modal" data-target="#contract-old-pay" class="btn btn-sm btn-primary mr-2">关联旧数据</a>
                 </div>

+ 2 - 2
app/view/financial/pay_list.ejs

@@ -33,8 +33,8 @@
                     <div class="input-group input-group-sm pr-1">
                         <select class="form-control form-control-sm col-auto" id="tid_select">
                             <option value="0">筛选标段</option>
-                            <% for (const t of tenders) { %>
-                            <option value="<%- t.id %>" <% if (t.id === tid) { %>selected<% } %> ><%- t.name %></option>
+                            <% for (const t of userTenderList) { %>
+                            <option value="<%- t.tid %>" <% if (t.tid === tid) { %>selected<% } %> ><%- t.name %></option>
                             <% } %>
                         </select>
                     </div>

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

@@ -85,7 +85,7 @@
         });
     });
 </script>
-<% if (notStagePays.length > 0) { %>
+<% if (notStagePays.length > 0 && ctx.session.sessionUser.is_admin) { %>
     <div class="modal fade" id="contract-old-pay" data-backdrop="static">
         <div class="modal-dialog" role="document">
             <div class="modal-content">

+ 7 - 3
app/view/sp_setting/user_modal.ejs

@@ -147,21 +147,25 @@
                     <div class="col-4">
                         <div class="modal-height-500 scroll-y">
                             <table class="table table-bordered">
-                                <tr class="text-center"><th width="15%"><input type="checkbox" id="cub-sp-all"></th><th>项目名称</th></tr>
+                                <thead class="text-center" style="position: sticky; top:0; z-index:1;"><tr><th width="15%"><input type="checkbox" id="cub-sp-all"></th><th>项目名称</th></tr></thead>
+                                <tbody>
                                 <% for (const sp of subProjects) { %>
                                 <% if (sp.id === ctx.subProject.id) continue; %>
                                 <tr><td class="text-center"><input type="checkbox" name="cub-sp-check" spid="<%- sp.id %>"></td><td><%- sp.name %></td></tr>
                                 <% } %>
+                                </tbody>
                             </table>
                         </div>
                     </div>
                     <div class="col">
                         <div class="modal-height-500 scroll-y">
-                            <table class="table table-bordered scroll-y">
-                                <tr class="text-center"><th width="15%"><input type="checkbox" id="cub-user-all"></th><th width="20%">用户</th><th width="30%">职位</th><th>单位</th></tr>
+                            <table class="table table-bordered">
+                                <thead style="position: sticky; top:0; z-index:1;"><tr class="text-center"><th width="15%"><input type="checkbox" id="cub-user-all"></th><th width="20%">用户</th><th width="30%">职位</th><th>单位</th></tr></thead>
+                                <tbody>
                                 <% for (const u of subProjectAllAccountList) { %>
                                 <tr><td class="text-center"><input type="checkbox" name="cub-user-check" uid="<%- u.id %>"></td><td><%- u.name %></td><td><%- u.role %></td><td><%- u.company %></td></tr>
                                 <% } %>
+                                </tbody>
                             </table>
                         </div>
                     </div>