Tony Kang 3 tygodni temu
rodzic
commit
26e06636db

+ 2 - 2
app/const/source_type.js

@@ -11,8 +11,8 @@ const sourceTypeData = [
     { id: 100, name: '支付审批', key: 'payment' },
     { id: 101, name: '安全生产费', key: 'payment_safe' },
     { id: 200, name: '动态投资', key: 'budget' },
-    { id: 300, name: '项目合同', key: 'project_contract' },
-    { id: 301, name: '标段合同', key: 'tender_contract' },
+    { id: 300, name: '合同管理', key: 'contract_management' },
+    // { id: 301, name: '标段合同', key: 'tender_contract' },
 ];
 
 // sourceType = { tender: 1, advance: 10, ... };

+ 143 - 66
app/controller/report_controller.js

@@ -148,6 +148,22 @@ module.exports = app => {
             return { accountList, newAccountGroup, advance };
         }
 
+        async _getPrjAccList(ctx, pageShow) {
+            let prjAccList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject, ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile', 'company_id', 'account', 'telephone', 'permission', 'sign_path', 'stamp_path']);
+            // 根据需求,如果开启了‘开启个人「签字」’功能,则只能是本身用户签名,管理员例外
+            if (!ctx.session.sessionUser.is_admin && pageShow.individualSign === 1) {
+                // 削减其他account
+                const newAccList = [];
+                for (const acc of prjAccList) {
+                    if (acc.id === this.ctx.session.sessionUser.accountId) {
+                        newAccList.push(acc);
+                    }
+                }
+                prjAccList = newAccList;
+            }
+            return prjAccList;
+        }
+
         /**
          * 报表显示页面
          *
@@ -235,25 +251,9 @@ module.exports = app => {
                         archiveList = JSON.parse(archives[0].content);
                     }
                 }
-                // let prjAccList = await ctx.service.projectAccount.getAllAccountByProjectId(tender.data.project_id);
-                // prjAccList = prjAccList.filter(pa => pa.enable !== 0);
-                let prjAccList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject, ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile', 'company_id', 'account', 'telephone', 'permission', 'sign_path', 'stamp_path']);
                 const roleList = await ctx.service.signatureRole.getSignatureRolesByTenderId(tender.id);
                 const usedList = await ctx.service.signatureUsed.getSignatureUsedByTenderId(tender.id);
-
-                // ctx.session.sessionUser.is_admin
-                // const pageShow = ctx.session.sessionProject.page_show;
-                // 根据需求,如果开启了‘开启个人「签字」’功能,则只能是本身用户签名,管理员例外
-                if (!ctx.session.sessionUser.is_admin && pageShow.individualSign === 1) {
-                    // 削减其他account
-                    const newAccList = [];
-                    for (const acc of prjAccList) {
-                        if (acc.id === this.ctx.session.sessionUser.accountId) {
-                            newAccList.push(acc);
-                        }
-                    }
-                    prjAccList = newAccList;
-                }
+                const prjAccList = this._getPrjAccList(ctx, pageShow);
 
                 // 分类列表
                 const categoryData = await this.ctx.service.category.getAllCategory(ctx.subProject);
@@ -433,22 +433,9 @@ module.exports = app => {
                 const isAdmin = ctx.session.sessionUser.is_admin;
                 const lastAuditor = null;
                 const archiveList = [];
-                // let prjAccList = await ctx.service.projectAccount.getAllAccountByProjectId(tender.pid);
-                // prjAccList = prjAccList.filter(pa => pa.enable !== 0);
-                let prjAccList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject, ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile', 'company_id', 'account', 'telephone', 'permission', 'sign_path', 'stamp_path']);
                 const roleList = await ctx.service.signatureRole.getSignatureRolesByTenderId(tender.id);
                 const usedList = await ctx.service.signatureUsed.getSignatureUsedByTenderId(tender.id);
-                // 根据需求,如果开启了‘开启个人「签字」’功能,则只能是本身用户签名,管理员例外
-                if (!ctx.session.sessionUser.is_admin && pageShow.individualSign === 1) {
-                    // 削减其他account
-                    const newAccList = [];
-                    for (const acc of prjAccList) {
-                        if (acc.id === this.ctx.session.sessionUser.accountId) {
-                            newAccList.push(acc);
-                        }
-                    }
-                    prjAccList = newAccList;
-                }
+                const prjAccList = this._getPrjAccList(ctx, pageShow);
                 // 分类列表 todo 支付审批 目前没有所属子项目,自定义分类暂无法按所属子项目取值
                 const categoryData = await this.ctx.service.category.getAllCategory(this.ctx.subProject.id);
                 // 获取用户权限
@@ -588,22 +575,9 @@ module.exports = app => {
                 const isAdmin = ctx.session.sessionUser.is_admin;
                 const lastAuditor = null;
                 const archiveList = [];
-                // let prjAccList = await ctx.service.projectAccount.getAllAccountByProjectId(pid);
-                // prjAccList = prjAccList.filter(pa => pa.enable !== 0);
-                let prjAccList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject, ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile', 'company_id', 'account', 'telephone', 'permission', 'sign_path', 'stamp_path']);
                 const roleList = [];
                 const usedList = [];
-                // 根据需求,如果开启了‘开启个人「签字」’功能,则只能是本身用户签名,管理员例外
-                if (!ctx.session.sessionUser.is_admin && pageShow.individualSign === 1) {
-                    // 削减其他account
-                    const newAccList = [];
-                    for (const acc of prjAccList) {
-                        if (acc.id === this.ctx.session.sessionUser.accountId) {
-                            newAccList.push(acc);
-                        }
-                    }
-                    prjAccList = newAccList;
-                }
+                const prjAccList = this._getPrjAccList(ctx, pageShow);
                 // 分类列表
                 const categoryData = await this.ctx.service.category.getAllCategory(ctx.subProject);
                 // 获取用户权限
@@ -806,22 +780,9 @@ module.exports = app => {
                     archiveList = JSON.parse(archives[0].content);
                 }
 
-                // let prjAccList = await ctx.service.projectAccount.getAllAccountByProjectId(pid);
-                // prjAccList = prjAccList.filter(pa => pa.enable !== 0);
-                let prjAccList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject, ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile', 'company_id', 'account', 'telephone', 'permission', 'sign_path', 'stamp_path']);
                 const roleList = [];
                 const usedList = await ctx.service.signatureUsed.getSignatureUsedByTenderId(tenderId);
-                // 根据需求,如果开启了‘开启个人「签字」’功能,则只能是本身用户签名,管理员例外
-                if (!ctx.session.sessionUser.is_admin && pageShow.individualSign === 1) {
-                    // 削减其他account
-                    const newAccList = [];
-                    for (const acc of prjAccList) {
-                        if (acc.id === this.ctx.session.sessionUser.accountId) {
-                            newAccList.push(acc);
-                        }
-                    }
-                    prjAccList = newAccList;
-                }
+                const prjAccList = this._getPrjAccList(ctx, pageShow);
                 // 分类列表
                 const categoryData = await this.ctx.service.category.getAllCategory(ctx.subProject);
                 // 获取用户权限
@@ -952,7 +913,7 @@ module.exports = app => {
             await this._indexForBGL(ctx, sourceTypeConst.sourceType.change_apply, -303);
         }
 
-        async _indexForContract(ctx, source_type, stage_id) {
+        async _indexForContract(ctx, source_type, stage_id, preUrl) {
             // 合同管理报表入口(项目、标段级别)
             try {
                 await this._getStageAuditViewData(ctx);
@@ -960,24 +921,140 @@ module.exports = app => {
                 pageShow.closeWatermark = 1;
                 pageShow.showArchive = 1;
                 pageShow.closeShowAllCustomized = 0;
-                const tenderId = ctx.params.tid || -1; // 标段级别有
+                // const tenderId = ctx.params.tid || -1; // 标段级别有
+                const tenderId = ctx.contractOptions.tid || -1;
                 const bglObj = {};
+                // const tender = ctx.tender;
+                const stage = ctx.stage;
+                const stage_order = -1;
+                const sorder = -1;
+                const stage_times = -1;
+                const stage_status = -1;
+                const project_id = ctx.params.id;
+                const { treeNodes, custCfg, commonArrs } = await this._createNodes(ctx, sourceTypeConst.sourceType.contract_management, project_id);
                 if (stage_id === -400) {
-                    // 项目级别
-                } else {
-                    // 标段级别 -401
+                    // 统一为合同管理
+                }
+                const cust_select_keys = JSON.stringify(['common', 'customize']); // 因其他地方也有可能保存用户报表的显示选择项,因当初设计问题,不好改数据库结构了,但可以调节内部json来满足需求
+                const rpt_tpl_items = { customize: [], common: [] };
+                commonArrs.forEach(item => {
+                    rpt_tpl_items.common.push(item.name);
+                });
+                if (treeNodes && treeNodes.length > 0) {
+                    for (let tIdx = treeNodes.length - 1; tIdx >= 0; tIdx--) {
+                        if (treeNodes[tIdx].name !== '通用报表') {
+                            rpt_tpl_items.customize.push(treeNodes[tIdx].name);
+                        }
+                    }
                 }
+
+                // const custTreeFolders = await ctx.service.rptTreeNodeCust.getCustFoldersByUserId(this.ctx.session.sessionUser.accountId);
+                // if (custTreeFolders.length > 0) {
+                //     const cust_select_item = JSON.parse(custTreeFolders[0].rpt_tpl_items);
+                //     if (cust_select_item.common) rpt_tpl_items.common = cust_select_item.common;
+                //     if (cust_select_item.customize) rpt_tpl_items.customize = cust_select_item.customize;
+                // }
+                // 获取所有项目参与者
+                const { accountList, newAccountGroup, advance } = await this._getInvolveAcc(ctx, tenderId);
+                const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } }); // 找公司章用的
+                const roleList = await ctx.service.signatureRole.getSignatureRolesByTenderId(tenderId);
+                const usedList = await ctx.service.signatureUsed.getSignatureUsedByTenderId(tenderId);
+                const isAdmin = ctx.session.sessionUser.is_admin;
+                const prjAccList = await this._getPrjAccList(ctx, pageShow);
+                for (const prjAcc of prjAccList) {
+                    prjAcc.account_group = prjAcc.company;
+                }
+                // 分类列表
+                const categoryData = await this.ctx.service.category.getAllCategory(ctx.subProject);
+                // // 获取用户权限
+                const accountInfo = await this.ctx.service.projectAccount.getDataById(this.ctx.session.sessionUser.accountId);
+                const tenderList = [];
+                const cid = this.ctx.helper._.map(treeNodes, 'id');
+                const customSelects = null;
+                const dataSelects = {};
+                dataSelects.material_select = await ctx.service.rptCustomDefine.getDataSelectByRpt(cid,
+                    reportConst.rptDataType[JV.NODE_CUS_MATERIAL_SELECT]);
+
+                // const materialList = await ctx.service.material.getValidMaterials(ctx.tenderId);
+                // const materialAdjAuditList = await ctx.service.materialAudit.getAuditorsByTender(tenderId);
+
+                const renderData = {
+                    accountGroup: newAccountGroup,
+                    accountList,
+                    unitList: JSON.stringify(unitList),
+                    tender: null,
+                    tenderInfo: null,
+                    rpt_tpl_data: JSON.stringify(treeNodes),
+                    cust_tpl_data: JSON.stringify(rpt_tpl_items),
+                    all_common_tpl_data: JSON.stringify([]),
+                    all_indivi_tpl_data: JSON.stringify([]),
+                    cust_select_keys,
+                    cust_cfg: JSON.stringify(custCfg),
+                    project_id,
+                    tender_id: tenderId,
+                    budget_id: -1,
+                    sp_id: -1,
+                    tender_name: '',
+                    detail_id: -1,
+                    stg_id: stage_id,
+                    stg_order: stage_order,
+                    cur_order: sorder,
+                    stg_times: stage_times,
+                    stg_status: stage_status,
+                    stage_list: '[]',
+                    prj_account_list: JSON.stringify(prjAccList),
+                    role_list: JSON.stringify(roleList),
+                    used_list: JSON.stringify(usedList),
+                    tenderMenu,
+                    preUrl,
+                    thisUrl: `/sp/${ctx.params.id}/contract/detail`, // 合同专有
+                    measureType,
+                    categoryData,
+                    tenderList,
+                    auditConst: auditConst.stage,
+                    ledgerAuditConst: auditConst.ledger,
+                    jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.report.main),
+                    customSelects,
+                    rptCustomType: reportConst.rptCustomType,
+                    advanceList: JSON.stringify([]),
+                    advanceAuditList: JSON.stringify([]),
+                    materialAdjList: JSON.stringify([]),
+                    materialAdjAuditList: JSON.stringify([]),
+                    materialList: [],
+                    stages: [],
+                    dataSelects,
+                    pageShow,
+                    authMobile: accountInfo.auth_mobile,
+                    shenpiConst,
+                    archiveList: [],
+                    lastAuditor: null,
+                    rpt_id: ctx.query.rpt_id,
+                    isAdmin,
+                    prePay: JSON.stringify(advance),
+                    OSS_PATH: ctx.app.config.fujianOssPath,
+                    viewPmData: PermissionCheck.viewPmData(this.ctx.session.sessionUser.permission),
+                    source_type,
+                    bglObj: JSON.stringify(bglObj),
+                    changes: 'null',
+                    otherChangeList: 'null',
+                    otherHintName: '',
+                    bizId: bglObj.BUSINESS_ID,
+                };
+                await this.layout('report/index.ejs', renderData, 'report/rpt_all_popup.ejs');
             } catch (err) {
                 this.log(err);
             }
         }
 
         async indexForProjectContract(ctx) {
-            await this._indexForContract(ctx, sourceTypeConst.sourceType.project_contract, -400);
+            const preUrl = `/sp/${ctx.params.prjid}/contract/panel`;
+            await this._indexForContract(ctx, sourceTypeConst.sourceType.contract_management, -400, preUrl);
         }
 
         async indexForTenderContract(ctx) {
-            await this._indexForContract(ctx, sourceTypeConst.sourceType.tender_contract, -401);
+            // const preUrl = `/sp/${ctx.params.prjid}/contract/panel`;
+            const preUrl = '';
+            await this._indexForContract(ctx, sourceTypeConst.sourceType.contract_management, -400, preUrl);
         }
 
         /**

+ 3 - 1
app/router.js

@@ -810,7 +810,9 @@ module.exports = app => {
     app.get('/tender/:id/change/project/:cprjid/report', sessionAuth, tenderCheck, subProjectCheck, uncheckTenderCheck, 'reportController.indexForChangeProject');
     app.get('/tender/:id/change/apply/:caid/report', sessionAuth, tenderCheck, subProjectCheck, uncheckTenderCheck, 'reportController.indexForChangeApply');
     app.get('/tender/:id/measure/stage/:order/report', sessionAuth, tenderCheck, subProjectCheck, uncheckTenderCheck, stageCheck, 'reportController.index');
-    // app.get('/sp/:prjid/contract/:contracid/report', sessionAuth, tenderCheck, subProjectCheck, uncheckTenderCheck, 'reportController.indexForProjectContract');
+    // app.get('/sp/:prjid/contract/report', sessionAuth, subProjectCheck, 'reportController.indexForProjectContract');
+    // app.get('/sp/:id/contract/panel', sessionAuth, subProjectCheck, contractCheck, 'contractController.panel');
+    app.get('/sp/:id/contract/report', sessionAuth, subProjectCheck, contractCheck, 'reportController.indexForProjectContract');
     // app.get('/sp?/contract/report', sessionAuth, tenderCheck, subProjectCheck, uncheckTenderCheck, 'reportController.indexForTenderContract');
     app.get('/sp/:id/payment/:pid/safe/:did/report', sessionAuth, subProjectCheck, paymentTenderCheck, paymentDetailCheck, 'reportController.indexForPaymentSafe');
     app.get('/budget/:id/report', sessionAuth, budgetCheck, 'reportController.indexForDynamicGrandTotal');

+ 1 - 1
app/view/contract/sub_menu_list.ejs

@@ -23,7 +23,7 @@
 <div class="nav-box">
     <ul class="nav-list list-unstyled">
         <li class="">
-            <a href="/sp/<%- `${ctx.subProject.id}` %>/contract/<%- `${ctx.contract.id}` %>/report"><span class="ml-3">输出报表</span></a>
+            <a href="/sp/<%- `${ctx.subProject.id}` %>/contract/report"><span class="ml-3">输出报表</span></a>
         </li>
     </ul>
 </div>

+ 11 - 5
app/view/report/index.ejs

@@ -6,6 +6,8 @@
     <% include ../budget/sub_menu.ejs %>
 <% } else if ([-300, -301, -302, -303].includes(stg_id)) { %>
     <% include ../tender/tender_sub_menu.ejs %>
+<% } else if ([-400, -401].includes(stg_id)) { %>
+    <% include ../contract/sub_menu.ejs %>
 <% } else { %>
     <% include ../stage/stage_sub_menu.ejs %>
 <% } %>
@@ -14,7 +16,7 @@
         <div class="title-main d-flex">
             <% if(stg_id === -1) { %>
                 <% include ../tender/tender_sub_mini_menu.ejs %>
-            <% } else if ([-100, -200, -300, -301, -302, -303].includes(stg_id)) { %>
+            <% } else if ([-100, -200, -300, -301, -302, -303, -400, -401].includes(stg_id)) { %>
             <% } else { %>
                 <% include ../stage/stage_sub_mini_menu.ejs %>
             <% } %>
@@ -46,7 +48,7 @@
                     </div>
                 </div>
                 <% } %>
-                <% if (false || ![-100, -200, -300, -301, -302, -303].includes(stg_id)) { %>
+                <% if (false || ![-100, -200, -300, -301, -302, -303, -400].includes(stg_id)) { %>
                 <div class="d-inline-block" id="divSelectableBizs_up">
                     <div class="dropdown" id="divSelectableStages">
                         <button class="btn btn-sm btn-light dropdown-toggle text-primary" type="button" id="btnCurrentStage" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></button>
@@ -62,7 +64,7 @@
                     </div>
                 </div>
                 <% } %>
-                <% if (stg_id === -200 || ![-100, -300, -301, -302, -303].includes(stg_id)) { %>
+                <% if (stg_id === -200 || ![-100, -300, -301, -302, -303, -400, -401].includes(stg_id)) { %>
                 <div class="d-inline-block" id="report_selects_div">
                     <ul class="nav nav-pills m-0" id="report_selects_ul">
                         <% if (ctx.session.sessionUser.is_admin || ctx.session.sessionProject.page_show.isCommonSetup) { %>
@@ -616,7 +618,11 @@
         CUST_CFG.continuousOutput = false;
     }
     //
-    const PROJECT_ID = <%- project_id %>;
+    <% if (stg_id === -400) {%>
+        const PROJECT_ID = '<%- project_id %>';
+    <% } else { %>
+        const PROJECT_ID = <%- project_id %>;
+    <% } %>
     const TENDER_ID = <%- tender_id %>;
     const TENDER_NAME = '<%- tender_name %>';
     const STAGE_ID = <%- stg_id %>;
@@ -671,7 +677,7 @@
         current_stage_status = STAGE_LIST[STAGE_LIST.length - 1].status;
     }
 
-    <% if (false || ![-100, -200, -300, -301, -302, -303].includes(stg_id)) { %>
+    <% if (false || ![-100, -200, -300, -301, -302, -303, -400, -401].includes(stg_id)) { %>
     buildStageSelection();
     <% } %>
     setupSignature();

+ 2 - 2
app/view/report/rpt_all_popup.ejs

@@ -793,7 +793,7 @@
         </div>
     </div>
 </div>
-<% if (![-100, -200, -300, -301, -302, -303].includes(stg_id)) { %>
+<% if (![-100, -200, -300, -301, -302, -303, -400, -401].includes(stg_id)) { %>
 <% include ../stage/audit_modal.ejs %>
 <% } %>
 
@@ -801,7 +801,7 @@
     zTreeOprObj.getCustomerCfg();
     zTreeOprObj.iniFontCfgDom(CUST_CFG);
     
-    <% if (![-100, -300, -301, -302, -303].includes(stg_id)) { %>
+    <% if (![-100, -300, -301, -302, -303, -400, -401].includes(stg_id)) { %>
     buildCustRptCommon('report_cust_group_common', ORG_TOP_TREE_NODES[1], CUST_TREE_NODES.common, 'true');
     buildCustRptCommon('report_cust_group_individual', ORG_TOP_TREE_NODES[0], CUST_TREE_NODES.customize, 'false');
     <% } %>