Pārlūkot izejas kodu

code sync + JS UI tuning

TonyKang 6 gadi atpakaļ
vecāks
revīzija
a5f58c5cee

+ 132 - 1
modules/reports/util/rpt_construct_data_util.js

@@ -13,7 +13,9 @@ let treeUtil = require('../../../public/treeUtil');
 let projectConst = consts.projectConst;
 let projectConstList = consts.projectConstList;
 const gljUtil = require('../../../public/gljUtil');
+const gljType = require('../../common/const/glj_type_const');
 // const pm_facade = require('../../pm/facade/pm_facade');
+const GLJID_PRE = `gljId_`, COMPONENT_GLJID_PRE = `componetGljId_`;
 
 
 const GLJ_TYPE = {
@@ -21,8 +23,14 @@ const GLJ_TYPE = {
     Material: 2,
     Machine: 3,
     Main_Material: 4,
-    Equipment: 5
+    Equipment: 5,
+
+    OTHER_MATERIAL: 207,
+    MACHINE_LABOUR: 303,
+    INSTRUMENT: 304,
+    FUEL_POWER_FEE: 305
 };
+const oprMachines = [306, 307, 308, 309, 310, 311, 312];
 
 class Rpt_Common{
     initialize(rpt_tpl, currentDataObj) {
@@ -233,6 +241,17 @@ class Rpt_Data_Extractor {
                 setupFunc($PROJECT.DETAIL, item.moduleName, item);
             }
             let projectGLJDatas = getModuleDataByKey(rawDataObj.prjData, "projectGLJ");
+            if (projectGLJDatas) {
+                //增加一个辅助对象,方便通过gljid key直接获取数据,省去循环时间
+                let gljAssitantObj = {"gljIds": {}, "componentGljIds": {}};
+                projectGLJDatas.data.gljAssistant = gljAssitantObj;
+                for (let gljItem of projectGLJDatas.data.gljList) {
+                    gljAssitantObj.gljIds[GLJID_PRE + gljItem.id] = gljItem;
+                    if (!(gljItem.ratio_data) || gljItem.ratio_data.length === 0) {
+                        gljAssitantObj.componentGljIds[COMPONENT_GLJID_PRE + gljItem.glj_id] = gljItem;
+                    }
+                }
+            }
             let rationGLJDatas = getModuleDataByKey(rawDataObj.prjData, "ration_glj");
             let rationDatas = getModuleDataByKey(rawDataObj.prjData, "ration");
             let billsDatas = getModuleDataByKey(rawDataObj.prjData, "bills");
@@ -280,8 +299,13 @@ class Rpt_Data_Extractor {
                         adjustData(srcData, preHandle);
                         break;
                     case JV.PROP_HANDLE_TYPE_BILLS_DATA_MOVE:
+                        //把显示在清单中的量材转移到工料机去
                         moveRationData(srcData, rawDataObj);
                         break;
+                    case JV.PROP_HANDLE_TYPE_COMPONENT_REPLACEMENT:
+                        //重庆2018 09-x表专用,机械数据用 组成物替换掉 ^_^!
+                        componentReplacement(rawDataObj);
+                        break;
                     default:
                         break;
                 }
@@ -668,6 +692,65 @@ function adjustData(sourceData, adjustCfg) {
     replaceActDataArr(sourceData, rstArr);
 }
 
+function componentReplacement(rawDataObj) {
+    let rationGljData = getModuleDataByKey(rawDataObj.prjData, projectConst.RATION_GLJ),
+        prjGljData = getModuleDataByKey(rawDataObj.prjData, projectConst.PROJECTGLJ),
+        gljAssistant = prjGljData.data.gljAssistant;
+    let connectStrArr = [], dataArr = getActDataArr(rationGljData), rvRGljIds = [], replaceGljItems = [];
+    for (let idx = 0; idx < dataArr.length; idx++) {
+        let rationGljItem = dataArr[idx];
+        if (rationGljItem.type === 301 || rationGljItem.type === 302) {
+            connectStrArr[0] = rationGljItem.code;
+            connectStrArr[1] = rationGljItem.name;
+            connectStrArr[2] = rationGljItem.specs;
+            connectStrArr[3] = rationGljItem.unit;
+            connectStrArr[4] = rationGljItem.type;
+            let mapData = prjGljData.data.mixRatioMap[connectStrArr.join('|-|')];
+            if (mapData) {
+                rvRGljIds.push(idx);
+                let rgItems = [];
+                replaceGljItems.push(rgItems);
+                for (let mapItem of mapData) {
+                    let copyItem = {};
+                    rgItems.push(copyItem);
+                    copyItem.ID = `Replace_` + rationGljItem.ID;
+                    copyItem.projectID = rationGljItem.projectID;
+                    copyItem.GLJID = rationGljItem.GLJID;
+                    copyItem.rationID = rationGljItem.rationID;
+                    if (gljAssistant.componentGljIds[COMPONENT_GLJID_PRE + mapItem.glj_id]) {
+                        copyItem.projectGLJID = gljAssistant.componentGljIds[COMPONENT_GLJID_PRE + mapItem.glj_id].id; //关键key
+                    } else {
+                        copyItem.projectGLJID = mapItem.glj_id; //不应该走到这一步,否则就是错误!!!
+                    }
+                    copyItem.rationItemQuantity = rationGljItem.rationItemQuantity;
+                    // copyItem.quantity = rationGljItem.quantity;
+                    copyItem.quantity = rationGljItem.quantity * mapItem.consumption;
+                    copyItem.name = mapItem.name;
+                    copyItem.code = mapItem.code;
+                    copyItem.original_code = mapItem.code;
+                    copyItem.unit = mapItem.unit;
+                    copyItem.specs = mapItem.specs;
+                    copyItem.model = gljAssistant.gljIds['gljId_'+rationGljItem.projectGLJID].model;
+                    copyItem.shortName = mapItem.shortName;
+                    copyItem.billsItemID = rationGljItem.billsItemID;
+                    copyItem.type = mapItem.type; //关键key
+                }
+            }
+        }
+    }
+    if (rvRGljIds.length > 0) {
+        for (let lIdx = rvRGljIds.length - 1; lIdx >= 0; lIdx--) {
+            dataArr.splice(rvRGljIds[lIdx],1);
+        }
+        for (let componentItems of replaceGljItems) {
+            for (let compItem of componentItems) {
+                dataArr.push(compItem);
+                //gljAssistant[COMPONENT_GLJID_PRE + mapItem.glj_id]
+            }
+        }
+    }
+}
+
 function moveRationData(rationData, rawDataObj) {
     if (rawDataObj) {
         // let rationData = getModuleDataByKey(rawDataObj.prjData, projectConst.RATION);
@@ -787,6 +870,54 @@ function addDummyData(sourceData, addCfg) {
     replaceActDataArr(sourceData, rstArr);
 }
 
+function getGLJBizType2018(orgType, orgCode, orgName) {
+    let rst = orgType;
+    if (orgType === GLJ_TYPE.Labour) {
+        rst = 11;
+        if (orgCode === "000000") rst = 10;
+    } else if (orgType === GLJ_TYPE.Material || (orgType >= 200 && orgType < 300)) {
+        //材料
+        if (orgCode === "000000") {
+            rst = 200; //2.材料
+        } else if (orgCode === "000000_1") {
+            rst = 230; //(1) 计价材料
+        } else if (orgCode === "000000_2") {
+            rst = 240; //(2) 其他材料费
+        } else {
+            if (orgType === GLJ_TYPE.OTHER_MATERIAL) {
+                //其他材料
+                rst = 245;
+            } else {
+                //计价材料
+                rst = 235;
+            }
+        }
+    } else if (orgType === GLJ_TYPE.Machine || (orgType >= 300 && orgType < 400)) {
+        //机械
+        if (orgCode === "000000") {
+            rst = 300; //3.机械
+        } else if (orgCode === "000000_1") {
+            rst = 330; //(1) 机上人工
+        } else if (orgCode === "000000_2") {
+            rst = 340; //(2) 燃油动力费
+        } else if (orgCode === "000000_3") {
+            rst = 350; //(2) 施工机具摊销费
+        } else {
+            if (orgType === GLJ_TYPE.MACHINE_LABOUR) {
+                //机上人工
+                rst = 335;
+            } else if (orgType === GLJ_TYPE.FUEL_POWER_FEE) {
+                //燃油动力费
+                rst = 345;
+            } else if (oprMachines.indexOf(orgType) >= 0) {
+                //施工机具摊销费
+                rst = 355 + oprMachines.indexOf(orgType);
+            }
+        }
+    }
+    return rst;
+}
+
 function getGLJBizType(orgType, orgCode, orgName) {
     let rst = orgType;
     if (orgName.indexOf("其他材料费") >= 0) {

+ 1 - 0
public/web/rpt_value_define.js

@@ -67,6 +67,7 @@ const JV = {
     PROP_HANDLE_TYPE_ADD_DUMMY: "增加Dummy数据",
     PROP_HANDLE_TYPE_ADJUST: "数据调整",
     PROP_HANDLE_TYPE_BILLS_DATA_MOVE: "量材数据转移",
+    PROP_HANDLE_TYPE_COMPONENT_REPLACEMENT: "组成物替换",
 
     PROP_ADJUST_COLLECTION: "数据调整集",
     PROP_ADJUST_ACTION: "action",

+ 1 - 1
web/maintain/report/html/rpt_tpl_main.html

@@ -53,7 +53,7 @@
             -->
             <div class="p-2">
                 <label id="id_after_saved_lbl" style="color:yellowgreen;font-weight:bold">...</label>
-                <button class="btn btn-primary btn-sm" onclick="tplHelper.saveRptTpl()">保存</button>
+                <button class="btn btn-primary btn-sm" onclick="tplHelper.saveRptTpl(false)">保存</button>
             </div>
         </nav>
     </div>

+ 1 - 0
web/maintain/report/html/rpt_tpl_script_text.html

@@ -2,6 +2,7 @@
     <div class="sub-button p-2">
         <button class="btn btn-primary" onclick="tplHelper.getJsTxt(document.getElementById('tplScriptTextContent'))">生成JS文本</button>
         <button class="btn btn-primary" onclick="tplHelper.setFromJsTxt(document.getElementById('tplScriptTextContent'))">导入JS文本</button>
+        <button class="btn btn-primary" onclick="tplHelper.saveDirectFromJs(document.getElementById('tplScriptTextContent'))">直接保存JS对象</button>
         <label id="id_after_js_load_lbl" style="color:yellowgreen;font-weight:bold">...</label>
     </div>
     <div class="main-data">

+ 35 - 4
web/maintain/report/js/rpt_tpl_helper.js

@@ -115,24 +115,55 @@ let tplHelper = {
         }
     },
 
-    saveRptTpl: function () {
+    saveRptTpl: function (directSave) {
         let me = this, params = null;
-        if (me.reCombineRptTpl()) {
+        if (directSave || me.reCombineRptTpl()) {
             displayMessage("正在保存...", "yellow", 1000);
             let rptTpl = zTreeOprObj.currentNode.rptTpl;
             params = {};
             params.rptTpl = JSON.stringify(rptTpl);
             CommonAjax.postEx("report_tpl_api/updateRptTpl", params, 20000, true, function(result){
                     if (result) {
-                        displayMessage("保存成功!", "green", 1000);
+                        displayMessage("保存成功!", "green", 3000);
                     } else {
-                        displayMessage("保存失败!", "red", 1000);
+                        displayMessage("保存失败!", "red", 3000);
                     }
                 }, null, null
             );
         }
     },
 
+    saveDirectFromJs: function (srcDom) {
+        if (confirm("将覆盖原模板所有信息并保存,请确认!")) {
+            let me = this;
+            try {
+                //1. 覆盖原模板信息
+                let rptTpl = JSON.parse(stringUtil.replaceAll(srcDom.value, "\t", " "));
+                // JSON.format()
+                delete rptTpl["__v"];
+                delete rptTpl["_id"];
+                rptTpl["ID"] = zTreeOprObj.currentNode.rptTpl["ID"];
+                //以下从zTreeOprObj.chkAndRreshRefTpl中参考
+                zTreeOprObj.currentNode.rptTpl = rptTpl;
+                zTreeOprObj.currentNode.rptTpl[JV.NODE_MAIN_INFO][JV.NODE_MAIN_INFO_RPT_NAME] = zTreeOprObj.currentNode.name;
+                if (zTreeOprObj.currentNode.rptTpl["GROUP_KEY"]) {
+                    let grp_keys = zTreeOprObj.currentNode.rptTpl["GROUP_KEY"].split('_');
+                    if (grp_keys.length > 0) {
+                        grp_keys[1] = zTreeOprObj.currentNode.name;
+                    }
+                    zTreeOprObj.currentNode.rptTpl["GROUP_KEY"] = grp_keys.join("_");
+                }
+                tplHelper.refreshTplView(zTreeOprObj.currentNode.rptTpl);
+                displayMessage("导入成功!", "green", 3000, "id_after_js_load_lbl");
+                //2. 直接保存
+                me.saveRptTpl(true);
+            } catch (ex) {
+                console.log(ex);
+                displayMessage("导入失败!请仔细检查JS对象的正确性!", "red", 3000, "id_after_js_load_lbl");
+            }
+        }
+    },
+
     reCombineRptTpl: function () {
         let rst = true;
         if (zTreeOprObj.currentNode && zTreeOprObj.currentNode.nodeType === RT.NodeType.TEMPLATE && zTreeOprObj.currentNode.rptTpl !== null) {