Browse Source

code sync

Tony Kang 1 year ago
parent
commit
0d796dca48

+ 146 - 1
app/controller/report_controller.js

@@ -364,6 +364,152 @@ module.exports = app => {
             }
         }
 
+        async indexForPaymentSafe(ctx) {
+            // 安全生产费入口
+            try {
+                await this._getStageAuditViewData(ctx);
+                const pageShow = ctx.session.sessionProject.page_show;
+                pageShow.showArchive = 1;
+                const tenderId = ctx.params.id;
+                const paymentDetail_id = ctx.params.did;
+                // 支付审批: ctx.params.did 是 zh_payment_detail表的id, 通过这个did在 zh_payment_detail_audit表里找审核信息(td_id = ctx.params.did)
+                //          没有计量期的概念!!!
+                const paymentAuditorList = await ctx.service.paymentDetailAudit.getAuditors(paymentDetail_id);
+                const tender = ctx.paymentTender;
+                // const treeNodes = await ctx.service.rptTreeNode.getNodesByProjectId([-1, tender.pid]);
+                const treeNodes = await ctx.service.rptTreeNode.getNodesBySourceType([tender.pid], 101); //
+                // 加一个dummy的通用报表
+                const dummyCommonRptNode = { id: 1, name: '通用报表', pid: -1, rpt_type: 0, items: '[]', hidden: true };
+                treeNodes.push(dummyCommonRptNode);
+                // const custTreeNodes = await ctx.service.rptTreeNodeCust.getCustFoldersByUserId(this.ctx.session.sessionUser.accountId);
+                const custCfg = await ctx.service.rptCustomizeCfg.getCustomizeCfgByUserId('Administrator');
+                // const stageList = await ctx.service.stage.getValidStagesShort(tender.id);
+                const stageList = [];
+                const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: tender.pid } }); // 找公司章用的
+                const isAdmin = ctx.session.sessionUser.is_admin;
+                const lastAuditor = null;
+                const archiveList = [];
+                let prjAccList = await ctx.service.projectAccount.getAllAccountByProjectId(tender.pid);
+                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 categoryData = await this.ctx.service.category.getAllCategory(this.ctx.session.sessionProject.id);
+                // 获取用户权限
+                const accountInfo = await this.ctx.service.projectAccount.getDataById(this.ctx.session.sessionUser.accountId);
+                const userPermission = accountInfo !== undefined && accountInfo.permission !== '' ? JSON.parse(accountInfo.permission) : null;
+                // 获取用户可查看的标段
+                const tenderList = await this.ctx.service.tender.getList('', userPermission);
+                for (const t of tenderList) {
+                    if (t.ledger_status === auditConst.ledger.status.checked) {
+                        t.lastStage = await this.ctx.service.stage.getLastestStage(t.id, true);
+                    }
+                }
+                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();
+
+                const stage_id = -100;
+                const stage_order = -1;
+                const sorder = -1;
+                const stage_times = -1;
+                const stage_status = -1;
+
+                for (const prjAcc of prjAccList) {
+                    prjAcc.account_group = accountGroup[prjAcc.account_group];
+                }
+                const rpt_tpl_items = '{ customize: [], common: [] }';
+                // if (custTreeNodes.length > 0) {
+                //     rpt_tpl_items = custTreeNodes[0].rpt_tpl_items;
+                // }
+
+                // 获取所有项目参与者
+                const accountList = await ctx.service.projectAccount.getAllDataByCondition({
+                    where: { project_id: ctx.session.sessionProject.id, enable: 1 },
+                    columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
+                });
+                const newAccountGroup = accountGroup.map((item, idx) => {
+                    const groupList = accountList.filter(item => item.account_group === idx);
+                    return { groupName: item, groupList };
+                });
+                const where = { tid: tenderId };
+                const advance = await ctx.service.advance.getAllDataByCondition({
+                    columns: ['id', 'order', 'status', 'selected', 'type'],
+                    where,
+                    orders: [['type', 'asc'], ['create_time', 'desc']],
+                });
+                advance.forEach(x => {
+                    x.statusStr = auditConst.advance.statusString[x.status];
+                    x.typeStr = advanceConst.typeColMap[x.type].text;
+                });
+
+                const renderData = {
+                    accountGroup: newAccountGroup,
+                    accountList,
+                    unitList: JSON.stringify(unitList),
+                    tender: null,
+                    tenderInfo: null,
+                    rpt_tpl_data: JSON.stringify(treeNodes),
+                    cust_tpl_data: rpt_tpl_items,
+                    cust_cfg: JSON.stringify(custCfg),
+                    project_id: tender.pid,
+                    tender_id: tenderId,
+                    tender_name: tender.name,
+                    stg_id: stage_id,
+                    stg_order: stage_order,
+                    cur_order: sorder,
+                    stg_times: stage_times,
+                    stg_status: stage_status,
+                    stage_list: JSON.stringify(stageList),
+                    prj_account_list: JSON.stringify(prjAccList),
+                    role_list: JSON.stringify(roleList),
+                    used_list: JSON.stringify(usedList),
+                    tenderMenu,
+                    preUrl: '/tender/' + tenderId + '/measure/stage/' + ctx.params.order,
+                    measureType,
+                    categoryData,
+                    tenderList,
+                    auditConst: auditConst.stage,
+                    ledgerAuditConst: auditConst.ledger,
+                    jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.report.main),
+                    customSelects,
+                    rptCustomType: reportConst.rptCustomType,
+                    materialList,
+                    stages: stageList,
+                    dataSelects,
+                    pageShow,
+                    authMobile: accountInfo.auth_mobile,
+                    shenpiConst,
+                    archiveList,
+                    lastAuditor,
+                    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),
+                };
+                /*
+                //*/
+                await this.layout('report/index.ejs', renderData, 'report/rpt_all_popup.ejs');
+            } catch (err) {
+                this.log(err);
+                // ctx.redirect('/tender/' + ctx.tender.id + '/measure/stage');
+            }
+        }
         /**
          * 报表打印页面
          *
@@ -1508,7 +1654,6 @@ async function _chkRawPicSizeOSS(ctx, picPath) {
     return rst;
 }
 
-
 function _resetPageDataByBreaks(pageDataArr, breakAmt, rpt_names, newRptNames) {
     const rst = [];
     for (let pi = 0; pi < pageDataArr.length; pi++) {

+ 2 - 1
app/public/report/js/rpt_cfg_const.js

@@ -19,7 +19,8 @@ const rpt_tpl_setting = {
         },
         key: {
             children: "items",
-            title: "title"
+            title: "title",
+            isHidden: "hidden"
         },
         simpleData: {
             enable: true,

+ 65 - 61
app/public/report/js/rpt_main.js

@@ -96,7 +96,7 @@ let zTreeOprObj = {
     getReportTemplateTree: function() {
         let me = zTreeOprObj;
         const _chkIfShouldFilter = function(rptItem, currentRptType = 'normal') {
-            let rst = (!(rptItem.released) && rptItem.nodeType === 2); //未发布判断
+            let rst = (!(rptItem.released) && rptItem.nodeType === 2 || rptItem.hidden); //未发布判断 或 故意隐藏
             if (!rst) {
                 // 根据当前业务类型判断及检测其他非同类报表,如动态决算类型、支付审批类型
                 switch(currentRptType) {
@@ -310,36 +310,38 @@ let zTreeOprObj = {
             _getSplitAmendmentParam(params, treeNode);
         
             rptArchiveObj.toggleBtn(false);
-            const gather_select = customSelects.gather_select.find(function (x) {
-                return x.id === treeNode.refId;
-            });
-            if (gather_select) {
-                rptCustomObj.init(gather_select.custom_define, customSelects.stageFlow, gather_select);
-                return;
-            }
-
-            const stage_select = customSelects.stage_select.find(function (x) {
-                return x.id === treeNode.refId;
-            });
-            if (stage_select) {
-                rptCustomObj.init(stage_select.custom_define, customSelects.stageFlow, stage_select);
-                return;
-            }
-
-            const material_sum_select = customSelects.material_sum_select.find(function (x) {
-                return x.id === treeNode.refId;
-            });
-            if (material_sum_select) {
-                rptCustomObj.init(material_sum_select.custom_define, customSelects.stageFlow, material_sum_select);
-                return;
-            }
-
-            const change_select = customSelects.change_select.find(function (x) {
-                return x.id === treeNode.refId;
-            });
-            if (change_select) {
-                rptCustomObj.init(change_select.custom_define, customSelects.stageFlow, change_select);
-                return;
+            if (customSelects) {
+                const gather_select = customSelects.gather_select.find(function (x) {
+                    return x.id === treeNode.refId;
+                });
+                if (gather_select) {
+                    rptCustomObj.init(gather_select.custom_define, customSelects.stageFlow, gather_select);
+                    return;
+                }
+    
+                const stage_select = customSelects.stage_select.find(function (x) {
+                    return x.id === treeNode.refId;
+                });
+                if (stage_select) {
+                    rptCustomObj.init(stage_select.custom_define, customSelects.stageFlow, stage_select);
+                    return;
+                }
+    
+                const material_sum_select = customSelects.material_sum_select.find(function (x) {
+                    return x.id === treeNode.refId;
+                });
+                if (material_sum_select) {
+                    rptCustomObj.init(material_sum_select.custom_define, customSelects.stageFlow, material_sum_select);
+                    return;
+                }
+                
+                const change_select = customSelects.change_select.find(function (x) {
+                    return x.id === treeNode.refId;
+                });
+                if (change_select) {
+                    rptCustomObj.init(change_select.custom_define, customSelects.stageFlow, change_select);
+                    return;
+                }
             }
 
             rptArchiveObj.toggleBtn(true);
@@ -387,36 +389,38 @@ let zTreeOprObj = {
             // me.requestNormalReport(params);
             localStorage[CUST_NAME + '_custCfg'] = JSON.stringify(CUST_CFG);
 
-            const gather_select = customSelects.gather_select.find(function (x) {
-                return x.id === me.currentNode.refId;
-            });
-            if (gather_select) {
-                rptCustomObj.init(gather_select.custom_define, customSelects.stageFlow, gather_select);
-                return;
-            }
-
-            const stage_select = customSelects.stage_select.find(function (x) {
-                return x.id === me.currentNode.refId;
-            });
-            if (stage_select) {
-                rptCustomObj.init(stage_select.custom_define, customSelects.stageFlow, stage_select);
-                return;
-            }
-
-            const material_sum_select = customSelects.material_sum_select.find(function (x) {
-                return x.id === me.currentNode.refId;
-            });
-            if (material_sum_select) {
-                rptCustomObj.init(material_sum_select.custom_define, customSelects.stageFlow, material_sum_select);
-                return;
-            }
-
-            const change_select = customSelects.change_select.find(function (x) {
-                return x.id === me.currentNode.refId;
-            });
-            if (change_select) {
-                rptCustomObj.init(change_select.custom_define, customSelects.stageFlow, change_select);
-                return;
+            if (customSelects) {
+                const gather_select = customSelects.gather_select.find(function (x) {
+                    return x.id === me.currentNode.refId;
+                });
+                if (gather_select) {
+                    rptCustomObj.init(gather_select.custom_define, customSelects.stageFlow, gather_select);
+                    return;
+                }
+    
+                const stage_select = customSelects.stage_select.find(function (x) {
+                    return x.id === me.currentNode.refId;
+                });
+                if (stage_select) {
+                    rptCustomObj.init(stage_select.custom_define, customSelects.stageFlow, stage_select);
+                    return;
+                }
+    
+                const material_sum_select = customSelects.material_sum_select.find(function (x) {
+                    return x.id === me.currentNode.refId;
+                });
+                if (material_sum_select) {
+                    rptCustomObj.init(material_sum_select.custom_define, customSelects.stageFlow, material_sum_select);
+                    return;
+                }
+    
+                const change_select = customSelects.change_select.find(function (x) {
+                    return x.id === me.currentNode.refId;
+                });
+                if (change_select) {
+                    rptCustomObj.init(change_select.custom_define, customSelects.stageFlow, change_select);
+                    return;
+                }
             }
 
             await me.requestNormalReport(params);

+ 1 - 0
app/router.js

@@ -411,6 +411,7 @@ module.exports = app => {
     // 报表
     app.get('/tender/:id/report', sessionAuth, tenderCheck, uncheckTenderCheck, 'reportController.index');
     app.get('/tender/:id/measure/stage/:order/report', sessionAuth, tenderCheck, uncheckTenderCheck, stageCheck, 'reportController.index');
+    app.get('/payment/:id/safe/:did/report', sessionAuth, paymentTenderCheck, paymentDetailCheck, 'reportController.indexForPaymentSafe');
     app.get('/tender/:id/archiveReport', sessionAuth, tenderCheck, uncheckTenderCheck, 'reportArchiveController.index');
     app.post('/tender/report_api/getReportArchive', sessionAuth, 'reportArchiveController.getReportArchive');
     app.get('/getArchivedFileByUUID/:uuid/:rptName', sessionAuth, 'reportArchiveController.getArchivedFileByUUID');

+ 18 - 1
app/service/rpt_tree_node.js

@@ -64,6 +64,23 @@ module.exports = app => {
             return list;
         }
 
+        async getNodesBySourceType(prjIdArr, sourceType) {
+            this.initSqlBuilder();
+            this.sqlBuilder.setAndWhere('pid', {
+                value: prjIdArr,
+                operate: 'in',
+            });
+            this.sqlBuilder.setAndWhere('source_type', {
+                value: sourceType,
+                operate: '=',
+            });
+            this.sqlBuilder.columns = ['id', 'name', 'rpt_type', 'pid', 'items', 'last_update_time'];
+            const [sql, sqlParam] = this.sqlBuilder.build(this.tableName);
+
+            const list = await this.db.query(sql, sqlParam);
+            return list;
+        }
+
         async createNode(prjId, name) {
             let rst = null;
             this.transaction = await this.db.beginTransaction();
@@ -71,7 +88,7 @@ module.exports = app => {
                 const data = {
                     // id: 0,
                     rpt_type: 0,
-                    name: name,
+                    name,
                     pid: prjId,
                     items: '[]',
                     last_update_time: (new Date()).getTime().toString(),

+ 20 - 15
app/view/report/index.ejs

@@ -1,17 +1,21 @@
 <% if (stg_id === -1) {%>
-<% include ../tender/tender_sub_menu.ejs %>
+    <% include ../tender/tender_sub_menu.ejs %>
+<% } else if (stg_id === -100) { %>
+    <% include ../payment_safe/sub_menu.ejs %>
 <% } else { %>
-<% include ../stage/stage_sub_menu.ejs %>
+    <% include ../stage/stage_sub_menu.ejs %>
 <% } %>
 <div class="panel-content">
     <div class="panel-title">
         <div class="title-main d-flex">
             <% if(stg_id === -1) { %>
                 <% include ../tender/tender_sub_mini_menu.ejs %>
+            <% } else if (stg_id === -100) { %>
             <% } else { %>
                 <% include ../stage/stage_sub_mini_menu.ejs %>
             <% } %>
             <div>
+                <% if (false || (stg_id !== -100 && stg_id !== -200 && stg_id !== -300)) { %>
                 <div class="d-inline-block">
                     <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>
@@ -44,6 +48,7 @@
                     </div>
                 </div>
                 <% } %>
+                <% } %>
             </div>
             <div>
             </div>
@@ -441,7 +446,9 @@
         current_stage_status = STAGE_LIST[STAGE_LIST.length - 1].status;
     }
 
+    <% if (false || (stg_id !== -100 && stg_id !== -200 && stg_id !== -300)) { %>
     buildStageSelection();
+    <% } %>
     setupSignature();
 
     for (let item of TOP_TREE_NODES) {
@@ -521,19 +528,17 @@
                     TOP_TREE_NODES.splice(tnIdx, 1);
                 }
             }
-            // 1.1 移除未被选择的模板
-            filterUnchkTplTreeNode(TOP_TREE_NODES[0], CUST_TREE_NODES.common);
-            TOP_TREE_NODES.unshift(individualNode); //定制在前
-            // PAGE_SHOW['dftShowAllCustimed']
-//            if (!(CUST_TREE_NODES.customize && CUST_TREE_NODES.customize.length === 0 && PAGE_SHOW['dftShowAllCustomized'] === 1)) {
-//                filterUnchkTplTreeNode(TOP_TREE_NODES[0], CUST_TREE_NODES.customize);
-//            }
-            if (CUST_TREE_NODES.customize && CUST_TREE_NODES.customize.length > 0) {
-                // 优先过滤用户选择
-                filterUnchkTplTreeNode(TOP_TREE_NODES[0], CUST_TREE_NODES.customize);
-            } else if (PAGE_SHOW['closeShowAllCustomized'] === 1) {
-                // 如果没有用户选择 且 关闭显示所有定制表
-                filterUnchkTplTreeNode(TOP_TREE_NODES[0], []);
+            if (TOP_TREE_NODES.length > 0) {
+                // 1.1 移除未被选择的模板
+                filterUnchkTplTreeNode(TOP_TREE_NODES[0], CUST_TREE_NODES.common);
+                TOP_TREE_NODES.unshift(individualNode); //定制在前
+                if (CUST_TREE_NODES.customize && CUST_TREE_NODES.customize.length > 0) {
+                    // 优先过滤用户选择
+                    filterUnchkTplTreeNode(TOP_TREE_NODES[0], CUST_TREE_NODES.customize);
+                } else if (PAGE_SHOW['closeShowAllCustomized'] === 1) {
+                    // 如果没有用户选择 且 关闭显示所有定制表
+                    filterUnchkTplTreeNode(TOP_TREE_NODES[0], []);
+                }
             }
             //2. 原始的模板树(恢复用)
             const individualNodeOrg = {id: 99999, name: '定制报表', pid: -1, rpt_type: 0, items: [], isParent: true};

+ 4 - 0
app/view/report/rpt_all_popup.ejs

@@ -744,8 +744,12 @@
 <script>
     zTreeOprObj.getCustomerCfg();
     zTreeOprObj.iniFontCfgDom(CUST_CFG);
+    
+    <% if (false || (stg_id !== -100 && stg_id !== -200 && stg_id !== -300)) { %>
     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');
+    <% } %>
+
     let SELECTED_TENDERS = [];
 
     function buildTendersTree() {

+ 5 - 5
config/web.js

@@ -50,7 +50,7 @@ const JsFiles = {
         '/public/js/messages_zh.js',
         '/public/js/component/input.js',
         '/public/js/cookies.js',
-        '/public/js/global.js'
+        '/public/js/global.js',
     ],
     controller: {
         tender: {
@@ -804,7 +804,7 @@ const JsFiles = {
         },
         report: {
             main: {
-                files: ['/public/js/spreadjs/sheets/v11/gc.spread.sheets.all.11.2.2.min.js', '/public/js/decimal.min.js', '/public/js/moment/moment.min.js'],
+                files: ['/public/js/spreadjs/sheets/v11/gc.spread.sheets.all.11.2.2.min.js', '/public/js/decimal.min.js', '/public/js/moment/moment.min.js', '/public/js/component/menu.js'],
                 mergeFiles: [
                     '/public/js/zh_calc.js',
                     '/public/js/path_tree.js',
@@ -1029,7 +1029,7 @@ const JsFiles = {
                 mergeFile: 'datacollect_index',
             },
         },
-        subProject:{
+        subProject: {
             list: {
                 files: [
                     '/public/js/moment/moment.min.js',
@@ -1106,7 +1106,7 @@ const JsFiles = {
                     '/public/js/shares/tenders2tree.js',
                     '/public/js/budget_compare.js',
                 ],
-                mergeFile: 'budget_compare.js'
+                mergeFile: 'budget_compare.js',
             },
             detail: {
                 files: [
@@ -1220,7 +1220,7 @@ const JsFiles = {
                     '/public/js/payment_compare.js',
                 ],
                 mergeFile: 'payment_compare',
-            }
+            },
         },
     },
 };