Forráskód Böngészése

BUG #3677 + 部分TASK #4805(屏蔽)

Tony Kang 1 éve
szülő
commit
2a1f4bce9e

+ 8 - 2
app/controller/report_controller.js

@@ -62,6 +62,10 @@ module.exports = app => {
         async _createNodes(ctx, source_type, pid) {
             const treeNodes = await ctx.service.rptTreeNode.getNodesBySourceType([pid], source_type); // 这个查定制的
             const commonTreeNodes = await ctx.service.rptTreeNode.getNodesByProjectId([-1]); // 这个查通用的
+            const allTreeNodes = await ctx.service.rptTreeNode.getAllNodes([-1]); // 这个得到所有通用的(新业务需求)
+            const allTreeItems = JSON.parse(allTreeNodes[0].items);
+            const allIndivTreeNodes = await ctx.service.rptTreeNode.getAllNodes([pid]); // 这个得到所有定制的(新业务需求)
+            const allIndivTreeItems = JSON.parse(allIndivTreeNodes[0].items);
             const nodeItems = JSON.parse(commonTreeNodes[0].items);
             const commonArrs = [];
             nodeItems.forEach(nodeItem => {
@@ -74,7 +78,7 @@ module.exports = app => {
             const dummyCommonRptNode = { id: 1, name: '通用报表', pid: -1, rpt_type: 0, items: JSON.stringify(commonArrs) };
             treeNodes.push(dummyCommonRptNode);
             const custCfg = await ctx.service.rptCustomizeCfg.getCustomizeCfgByUserId('Administrator');
-            return { treeNodes, commonArrs, custCfg };
+            return { treeNodes, commonArrs, custCfg, allTreeItems, allIndivTreeItems };
         }
 
         async _getInvolveAcc(ctx, tId) {
@@ -120,7 +124,7 @@ module.exports = app => {
                 let stage_times = -1;
                 let stage_status = -1;
 
-                const { treeNodes, custCfg } = await this._createNodes(ctx, sourceTypeConst.sourceType.tender, tender.data.project_id);
+                const { treeNodes, custCfg, allTreeItems, allIndivTreeItems } = await this._createNodes(ctx, sourceTypeConst.sourceType.tender, tender.data.project_id);
                 const custTreeNodes = await ctx.service.rptTreeNodeCust.getCustFoldersByUserId(this.ctx.session.sessionUser.accountId);
                 const stageList = await ctx.service.stage.getValidStagesShort(tender.id);
                 const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: tender.data.project_id } }); // 找公司章用的
@@ -275,6 +279,8 @@ module.exports = app => {
                     tenderInfo: tender.info,
                     rpt_tpl_data: JSON.stringify(treeNodes),
                     cust_tpl_data: JSON.stringify(rpt_tpl_items),
+                    all_common_tpl_data: JSON.stringify(allTreeItems),
+                    all_indivi_tpl_data: JSON.stringify(allIndivTreeItems),
                     cust_select_keys,
                     cust_cfg: JSON.stringify(custCfg),
                     project_id: tender.data.project_id,

+ 1 - 1
app/public/report/js/jpc_output.js

@@ -276,7 +276,7 @@ let JpcCanvasOutput = {
             if (control[JV.CONTROL_PROPS[JV.CONTROL_PROP_IDX_WRAP]] === 'T' && control[JV.CONTROL_PROPS[JV.CONTROL_PROP_IDX_SHRINK_FIRST]] !== 'T') {
                 let vals = [];
                 let validAreaTxtWidth = cell[JV.PROP_AREA][JV.PROP_RIGHT] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_RIGHT] - cell[JV.PROP_AREA][JV.PROP_LEFT] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_LEFT] - 1;
-                validAreaTxtWidth = validAreaTxtWidth * this.scaleFactor; // 本身的高度、宽度都得根据缩放系数来调整
+                validAreaTxtWidth = validAreaTxtWidth * me.scaleFactor; // 本身的高度、宽度都得根据缩放系数来调整
                 for (let val of orgValues) {
                     let actW = ctx2D.measureText(val).width;
                     if (actW > (validAreaTxtWidth - 4)) {

+ 26 - 4
app/service/rpt_tree_node.js

@@ -69,15 +69,37 @@ module.exports = app => {
             return list;
         }
 
-        async getNodesBySourceType(prjIdArr, sourceType) {
+        async getNodesBySourceType(prjIdArr, sourceType = null) {
             this.initSqlBuilder();
             this.sqlBuilder.setAndWhere('pid', {
                 value: prjIdArr,
                 operate: 'in',
             });
-            this.sqlBuilder.setAndWhere('source_type', {
-                value: sourceType,
-                operate: '=',
+            if (sourceType) {
+                if (sourceType instanceof Array) {
+                    this.sqlBuilder.setAndWhere('source_type', {
+                        value: sourceType,
+                        operate: 'in',
+                    });
+                } else {
+                    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 getAllNodes(prjIdArr) {
+            this.initSqlBuilder();
+            this.sqlBuilder.setAndWhere('pid', {
+                value: prjIdArr,
+                operate: 'in',
             });
             this.sqlBuilder.columns = ['id', 'name', 'rpt_type', 'pid', 'items', 'last_update_time'];
             const [sql, sqlParam] = this.sqlBuilder.build(this.tableName);

+ 107 - 4
app/view/report/index.ejs

@@ -19,8 +19,34 @@
                 <% include ../stage/stage_sub_mini_menu.ejs %>
             <% } %>
             <div>
-                <% if (false || ![-100, -200, -300, -301, -302, -303].includes(stg_id)) { %>
+                <!-- <div class="d-inline-block">
+                    <div class="dropdown">
+                        <button class="btn btn-sm btn-light dropdown-toggle text-primary" type="button" id="allBizDropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+                            计量期
+                        </button>
+                        <div class="dropdown-menu" aria-labelledby="allBizDropdownMenuButton" id="biz-select-item">
+                            <a class="dropdown-item" href="javascript:void(0);" data-type="stage" style="display: none">计量期</a>
+                            <a class="dropdown-item" href="javascript:void(0);" data-type="change_prepay">预付款</a>
+                            <a class="dropdown-item" href="javascript:void(0);" data-type="change_material_adjustment">材料调差</a>
+                        </div>
+                    </div>
+                </div>
                 <div class="d-inline-block">
+                    <div class="dropdown" style="display: none" id="biz-prepay-item">
+                        <button class="btn btn-sm btn-light dropdown-toggle text-primary" type="button" id="allPrepayButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+                            所有预付款
+                        </button>
+                        <div class="dropdown-menu" aria-labelledby="allPrepayButton" id="prepay-select-item">
+                            <a class="dropdown-item" href="javascript:void(0);" data-type="prepay_all" >所有预付款</a>
+                            <a class="dropdown-item" href="javascript:void(0);" data-type="prepay_start">开工预付款</a>
+                            <a class="dropdown-item" href="javascript:void(0);" data-type="prepay_material">材料预付款</a>
+                            <a class="dropdown-item" href="javascript:void(0);" data-type="prepay_safe">安全生产费预付款</a>
+                            <a class="dropdown-item" href="javascript:void(0);" data-type="prepay_dust">扬尘污染预付款</a>
+                        </div>
+                    </div>
+                </div> -->
+                <% if (false || ![-100, -200, -300, -301, -302, -303].includes(stg_id)) { %>
+                <div class="d-inline-block" id="divSelectableStages_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>
                         <div class="dropdown-menu" aria-labelledby="dropdownMenuButton" id="optionSelectableStages"></div>
@@ -28,8 +54,8 @@
                 </div>
                 <% } %>
                 <% if (stg_id === -200 || ![-100, -300, -301, -302, -303].includes(stg_id)) { %>
-                <div class="d-inline-block">
-                    <ul class="nav nav-pills m-0">
+                <div class="d-inline-block" id="report_selects_div">
+                    <ul class="nav nav-pills m-0" id="report_selects_ul">
                         <li class="nav-item mr-1"><a href="#man-c" data-toggle="modal" data-target="#man-c" class=" btn btn-outline-primary btn-sm"><i class="fa fa-cog"></i> 推荐报表</a></li>
                         <li class="nav-item"><a href="#man-i" data-toggle="modal" data-target="#man-i" class=" btn btn-outline-primary btn-sm"><i class="fa fa-plus"></i> 定制报表</a></li>
                         <!--
@@ -65,7 +91,7 @@
                 <% if (false || ![-100, -200, -300, -301, -302, -303].includes(stg_id)) { %>
                 <% if (ctx.session.sessionProject.page_show.isPreset) { %>
                 <div class="d-inline-block">
-                    <div class="dropdown">
+                    <div class="dropdown" id="divPresets">
                         <button class="btn btn-sm btn-light dropdown-toggle text-primary" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">报表数据预设</button>
                         <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
                             <a class="dropdown-item" href="javascript: void(0)" onclick="rptShowLevel.show('show_level');">显示层级</a>
@@ -331,6 +357,53 @@
             autoFlashHeight();
         }
     });
+    let CURRENT_SELECTED_BIZ_TYPE = 'stage';
+    $('#prepay-select-item a').on('click', function () {
+        $('#prepay-select-item a').show();
+        $(this).hide();
+        $('#prepay-select-item').siblings('button').text($(this).text());
+        const type = $(this).data('type');
+        if (type === 'prepay_start') {
+            //
+        } else if (type === 'prepay_material') {
+            //
+        } if (type === 'prepay_safe') {
+            //
+        } if (type === 'prepay_dust') {
+            //
+        }
+    });
+
+    $('#biz-select-item a').on('click', function () {
+        $('#biz-select-item a').show();
+        $(this).hide();
+        $('#biz-select-item').siblings('button').text($(this).text());
+        const type = $(this).data('type');
+        CURRENT_SELECTED_BIZ_TYPE = type;
+        // CHANGE_ID = -1;
+        // BUSINESS_ID = -1;
+        if (type === 'stage') {
+            // 计量期
+            $('#divSelectableStages').show();
+            $('#biz-prepay-item').hide();
+            $('#report_selects_ul').show();
+            $('#divPresets').show();
+        } else if (type === 'change_prepay') {
+            // 预付款
+            $('#divSelectableStages').hide();
+            $('#biz-prepay-item').show();
+            $('#report_selects_ul').hide();
+            $('#divPresets').hide();
+        } else if (type === 'change_material_adjustment') {
+            // 材料调差
+            $('#divSelectableStages').show();
+            $('#biz-prepay-item').hide();
+            $('#report_selects_ul').hide();
+            $('#divPresets').hide();
+        }
+        filterReportsByType();
+    });
+
     $.divResizer({
         select: '#right-spr',
         callback: function () {
@@ -440,6 +513,8 @@
 //    PAGE_SHOW['closeWatermark'] = 0; //测试用,check in 前要屏蔽
 
     const CUST_TREE_NODES = <%- cust_tpl_data %>;
+    const ALL_COMMON_TREE_NODES = <%- all_common_tpl_data %>;
+    const ALL_INDIVI_TREE_NODES = <%- all_indivi_tpl_data %>;
     const CUST_SELECT_KEYS = <%- cust_select_keys %>;
     if (!(CUST_TREE_NODES.customize instanceof Array)) {
         CUST_TREE_NODES.customize = [];
@@ -545,6 +620,34 @@
 
     const SCREEN_DPI = [];
 
+    function filterReportsByType() {
+        function _filterBySourceType(nodes, srcType) {
+            for (let idx = nodes.length - 1; idx >= 0; idx--) {
+                if (!nodes[idx].hasOwnProperty('source_type')) {
+                    nodes[idx].source_type = 1;
+                }
+                if (nodes[idx].source_type !== srcType) {
+                    nodes.splice(idx, 1);
+                }
+            }
+        }
+        const newCommonTreeNodes = JSON.parse(JSON.stringify(ALL_COMMON_TREE_NODES));
+        const newCustomTreeNodes = JSON.parse(JSON.stringify(ALL_INDIVI_TREE_NODES));
+        let bizType = 1;
+        if (CURRENT_SELECTED_BIZ_TYPE === 'stage') bizType = 1; // 计量期
+        if (CURRENT_SELECTED_BIZ_TYPE === 'change_prepay') bizType = 10; // 预付款
+        if (CURRENT_SELECTED_BIZ_TYPE === 'change_material_adjustment') bizType = 30; // 材差
+        _filterBySourceType(newCommonTreeNodes, bizType);
+        _filterBySourceType(newCustomTreeNodes, bizType);
+        TOP_TREE_NODES[0].items = newCustomTreeNodes;
+        TOP_TREE_NODES[1].items = newCommonTreeNodes;
+        if (bizType === 1) {
+            filterUnchkTplTreeNode(TOP_TREE_NODES[0], CUST_TREE_NODES.customize);
+            filterUnchkTplTreeNode(TOP_TREE_NODES[1], CUST_TREE_NODES.common);
+        }
+        zTreeOprObj.getReportTemplateTree();
+    }
+
     function filterUnchkTplTreeNode(topNode, srcData) {
         const _chkAndSpliceItem = function(pNode, pStr) {
             let rst = false;