Просмотр исходного кода

Merge branch 'master' of http://192.168.1.41:3000/SmartCost/YangHuCost

chenshilong 5 лет назад
Родитель
Сommit
80b47e5ca8

+ 1 - 0
config/gulpConfig.js

@@ -83,6 +83,7 @@ module.exports = {
         'lib/pinyinjs/pinyin_dict_firstletter.js',
         'lib/pinyinjs/pinyinUtil.js',
         'web/building_saas/main/js/models/main_consts.js',
+        'web/building_saas/main/js/models/feeRateConsts.js',
         'public/web/common_util.js',
         'web/building_saas/glj/js/project_glj.js',
         'web/building_saas/glj/js/composition.js',

+ 36 - 11
public/web/sheet/sheet_common.js

@@ -211,7 +211,7 @@ var sheetCommonObj = {
             }
 
             if (setting.header[col].cellType === "tipsCell") {
-                this.setTipsCell(row, col, sheet, setting.header[col]);
+                this.setTipsCell(row, col, sheet);
             }
             if (setting.owner === 'gljTree') {
                 if (setting.header[col].cellType === "checkBox") {
@@ -223,6 +223,7 @@ var sheetCommonObj = {
                     val = distTypeVal;
                 }
             }
+            if(setting.setCellType) setting.setCellType(sheet,data[row],row,col)
             if (setting.header[col].getText) {
                 val = setting.getText[setting.header[col].getText](data[row], val)
             }
@@ -682,7 +683,7 @@ var sheetCommonObj = {
         sheet.setCellType(row, col, cellType, GC.Spread.Sheets.SheetArea.viewport);
     },
 
-    setTipsCell(row, col, sheet, header) {
+    setTipsCell(row, col, sheet,tips) {
         let TipCellType = function () { };
         TipCellType.prototype = new GC.Spread.Sheets.CellTypes.Text();
         TipCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
@@ -699,16 +700,20 @@ var sheetCommonObj = {
         };
         TipCellType.prototype.processMouseEnter = function (hitinfo) {
             let text = hitinfo.sheet.getText(hitinfo.row, hitinfo.col);
-            let value = hitinfo.sheet.getValue(hitinfo.row, hitinfo.col);
-            let tag = hitinfo.sheet.getTag(hitinfo.row, hitinfo.col);
-            let acStyle = hitinfo.sheet.getActualStyle(hitinfo.row, hitinfo.col),
-                zoom = hitinfo.sheet.zoom();
-            let textLength = this.getAutoFitWidth(value, text, acStyle, zoom, { sheet: hitinfo.sheet, row: hitinfo.row, col: hitinfo.col, sheetArea: GC.Spread.Sheets.SheetArea.viewport });
-            let cellWidth = hitinfo.sheet.getCell(-1, hitinfo.col).width();
+            console.log(tips);
             let setting = {};
-            if (textLength <= cellWidth) {
-                return;
+            if(!tips){
+                let value = hitinfo.sheet.getValue(hitinfo.row, hitinfo.col);
+                let tag = hitinfo.sheet.getTag(hitinfo.row, hitinfo.col);
+                let acStyle = hitinfo.sheet.getActualStyle(hitinfo.row, hitinfo.col),
+                    zoom = hitinfo.sheet.zoom();
+                let textLength = this.getAutoFitWidth(value, text, acStyle, zoom, { sheet: hitinfo.sheet, row: hitinfo.row, col: hitinfo.col, sheetArea: GC.Spread.Sheets.SheetArea.viewport });
+                let cellWidth = hitinfo.sheet.getCell(-1, hitinfo.col).width();
+                if (textLength <= cellWidth) {
+                    return;
+                }
             }
+            text = tips;
             if (sheet && sheet.getParent().qo) {
                 setting.pos = SheetDataHelper.getObjPos(sheet.getParent().qo);
             }
@@ -856,7 +861,7 @@ var sheetCommonObj = {
         }
         return new getTipsCombo();
     }, */
-    getTreeNodeCellType: function (datas, row, parentMap,treeCol, paintFunc) {// 2018-09-26  不用spreadjs默认的树结构,自定义控件
+    getTreeNodeCellType: function (datas, row, parentMap,treeCol, paintFunc,tips) {// 2018-09-26  不用spreadjs默认的树结构,自定义控件
         var ns = GC.Spread.Sheets;
         let rectW = 10;
         let rectH = 10;
@@ -921,6 +926,26 @@ var sheetCommonObj = {
                 sheetArea: context.sheetArea
             };
         }
+        if(tips){
+            TreeNodeCellType.prototype.processMouseEnter = function (hitinfo) {
+                let text = hitinfo.sheet.getText(hitinfo.row, hitinfo.col);
+                let setting = {};
+                text = tips;
+                if (hitinfo.sheet && hitinfo.sheet.getParent().qo) {
+                    setting.pos = SheetDataHelper.getObjPos(hitinfo.sheet.getParent().qo);
+                }
+    
+                TREE_SHEET_HELPER.showTipsDiv(text, setting, hitinfo);
+            };
+            TreeNodeCellType.prototype.processMouseLeave = function (hitinfo) {
+                TREE_SHEET_HELPER.tipDiv = 'hide';
+                if (TREE_SHEET_HELPER._toolTipElement) {
+                    $(TREE_SHEET_HELPER._toolTipElement).hide();
+                    TREE_SHEET_HELPER._toolTipElement = null;
+                };
+                TREE_SHEET_HELPER.tipDivCheck();//延时检查:当tips正在show的时候,就调用了hide方法,会导致tips一直存在,所以设置一个超时处理
+            };
+        }
         TreeNodeCellType.prototype.processMouseDown = function (hitinfo) {
             ////方框外1像素内都有效
             if (!_.isEmpty(this.rectInfo) && Math.floor(hitinfo.x) <= this.rectInfo.x + this.rectInfo.rectW + 2 && Math.floor(hitinfo.x) >= this.rectInfo.x - 2) {

+ 1 - 0
web/building_saas/main/html/main.html

@@ -2043,6 +2043,7 @@
     <script src="/lib/pinyinjs/pinyin_dict_firstletter.js"></script>
     <script src="/lib/pinyinjs/pinyinUtil.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/models/main_consts.js"></script>
+    <script type="text/javascript" src="/web/building_saas/main/js/models/feeRateConsts.js"></script>
     <script type="text/javascript" src="/public/web/common_util.js"></script>
     <script type="text/javascript" src="/web/building_saas/glj/js/project_glj.js"></script>
     <script type="text/javascript" src="/web/building_saas/glj/js/composition.js"></script>

Разница между файлами не показана из-за своего большого размера
+ 97 - 0
web/building_saas/main/js/models/feeRateConsts.js


+ 0 - 1
web/building_saas/main/js/models/ration.js

@@ -797,7 +797,6 @@ var Ration = {
             node.updateData.quantityEXP="QDL*"+contain;
             node.updateData.quantity=scMathUtil.roundForObj(billQuantity*contain,getDecimal("quantity",node));
             if(!gljUtil.isKGtoT(billNode.data.unit,node.data.unit)){
-              console.log('hehe')
               let times = parseInt(node.data.unit);
               if (!isNaN(times)) {
                   node.updateData.quantityEXP+='*'+times;

+ 6 - 3
web/building_saas/main/js/views/fee_rate_view.js

@@ -762,15 +762,18 @@ var feeRateObject={
     },
     setLocAndFeeRateSTD:function(){
         if(feeRateObject.feeRateSTDLoaded)  return;
-        let location = projectObj.project.projectInfo.location;
-        if(!location) location = defaultLocation;
+        let location = this.getLocation();
         $('#location').val(location);
         //养护的工程所在地下拉框不可选
         if(!commonUtil.isGLYun()) $('#location').attr("disabled","disabled");
         feeRateObject.setFeeRateSTD(location);
         feeRateObject.feeRateSTDLoaded = true;
     },
-
+    getLocation:function(){
+        let location = projectObj.project.projectInfo.location;
+        if(!location) location = defaultLocation;
+        return location;
+    },
     setFeeRateSTD(location){
         let feeRateFile = projectObj.project.FeeRate.getActivateFeeRate();
         $('#feeRateStandard').empty();

+ 82 - 7
web/building_saas/main/js/views/importBills.js

@@ -36,7 +36,8 @@ const importBills = (function () {
     }
     const fileType = {
         gcl: 0, //工程量清单
-        qdsl: 1 //清单示例
+        qdsl: 1, //清单示例
+        gclex: 2, // 单机版导出的工程量清单预算表,需要转换成清单示例表来处理
     };
     //获取列字段对应
     function getColMapping(type) {
@@ -50,6 +51,10 @@ const importBills = (function () {
         let cell = dataRow[0];
         return cell && cell.value === '工程量清单';
     }
+    function isGCLExtendHead(dataRow) {
+        let cell = dataRow[0];
+        return cell && cell.value === '工程量清单预算表';
+    }
     //分析文件,1、工程量清单 2、清单示例表
     function getFileType(sheetData) {
         let dataTable = sheetData.data.dataTable,
@@ -58,6 +63,9 @@ const importBills = (function () {
             if (isGCLHead(dataTable[row])) {
                 return fileType.gcl;
             }
+            if (isGCLExtendHead(dataTable[row])) {
+                return fileType.gclex;
+            }
         }
         return fileType.qdsl;
     }
@@ -166,18 +174,77 @@ const importBills = (function () {
         return match ? match[1] : null;
     }
 
+    // 示例列映射
+    const slColMap = { code: 0, name: 1, unit: 2, quantity: 3 };
+
+    function isValidGCLExRow(rowData) {
+        if (rowData[0] && /编制[::]/.test(rowData[0].value)) {
+            return false;
+        }
+        if (rowData[1] && /合计/.test(rowData[1].value)) {
+            return false;
+        }
+        if ((!rowData[slColMap.code] || !rowData[slColMap.code].value) &&
+            (!rowData[slColMap.name] || !rowData[slColMap.name].value) &&
+            (!rowData[slColMap.unit] || !rowData[slColMap.unit].value) &&
+            (!rowData[slColMap.quantity] || !rowData[slColMap.quantity].value)) {
+            return false;
+        }
+        return true;
+    }
+
+    // 将“工程量清单预算表”去掉表头表尾,并转换成清单示例表。
+    // 工程量清单预算表的格式可参考需求:BUG #3037
+    function transformGCLExToSL(sheetData) {
+        const rst = {
+            data: { dataTable: [] },
+            rowCount: 0,
+        };
+        const dataTable = sheetData.data.dataTable;
+        const rowCount = sheetData.rowCount;
+        let preRootName;
+        for (let row = 0; row < rowCount; row++) {
+            const rowData = dataTable[row];
+            if (isGCLExtendHead(rowData)) {
+                const rootRowdata = dataTable[row + 3];
+                const name = rootRowdata[0].value;
+                if (name) {
+                    const rootName = name.replace('工程量清单', '清单');
+                    if (rootName !== preRootName) {
+                        preRootName = rootName;
+                        rst.data.dataTable.push({
+                            [slColMap.name]: { value: rootName }
+                        });
+                    }
+                }
+                row += 4;
+                continue;
+            }
+            if (isValidGCLExRow(rowData)) {
+                const cellData = {
+                    [slColMap.code]: { value: rowData[slColMap.code] && rowData[slColMap.code].value || null },
+                    [slColMap.name]: { value: rowData[slColMap.name] && rowData[slColMap.name].value || null },
+                    [slColMap.unit]: { value: rowData[slColMap.unit] && rowData[slColMap.unit].value || null },
+                    [slColMap.quantity]: { value: rowData[slColMap.quantity] && rowData[slColMap.quantity].value || null },
+                };
+                rst.data.dataTable.push(cellData);
+            }
+        }
+        rst.rowCount = rst.data.dataTable.length;
+        return rst;
+    }
+
     //提取清单示例数据
     function extractSLDatas(sheetData) {
-        let colMapping = { code: 0, name: 1, unit: 2, quantity: 3 };
         let dataTable = sheetData.data.dataTable,
             rowCount = sheetData.rowCount;
         let rst = [];
         let curRoot = null;
         for (let row = 0; row < rowCount; row++) {
-            let code = dataTable[row][colMapping.code] && dataTable[row][colMapping.code].value ? String(dataTable[row][colMapping.code].value).trim() : null,
-                name = dataTable[row][colMapping.name] ? _deNR(dataTable[row][colMapping.name].value) : null,
-                unit = dataTable[row][colMapping.unit] ? dataTable[row][colMapping.unit].value : null,
-                quantity = dataTable[row][colMapping.quantity] ? dataTable[row][colMapping.quantity].value : null;
+            let code = dataTable[row][slColMap.code] && dataTable[row][slColMap.code].value ? String(dataTable[row][slColMap.code].value).trim() : null,
+                name = dataTable[row][slColMap.name] ? _deNR(dataTable[row][slColMap.name].value) : null,
+                unit = dataTable[row][slColMap.unit] ? dataTable[row][slColMap.unit].value : null,
+                quantity = dataTable[row][slColMap.quantity] ? dataTable[row][slColMap.quantity].value : null;
             if (!code) {    //没有编号的数据,名称必须为:清单 第xx章,认为新的表根节点
                 const reg = /清单\s+第[^章]+章/;
                 //if (name && /清单 第\d+章/.test(name)) {
@@ -243,7 +310,15 @@ const importBills = (function () {
             }
             curSheetType = sheetType;
             let colMapping = getColMapping(sheetType);
-            let datas = sheetType === fileType.gcl ? extractGCLDatas(sheetData, colMapping) : extractSLDatas(sheetData, colMapping);
+            let datas = [];
+            if (sheetType === fileType.gcl) {
+                datas = extractGCLDatas(sheetData, colMapping);
+            } else if (sheetType === fileType.qdsl) {
+                datas = extractSLDatas(sheetData, colMapping);
+            } else {
+                const slSheetData = transformGCLExToSL(sheetData);
+                datas = extractSLDatas(slSheetData, colMapping);
+            }
             rst = rst.concat(datas);
         }
         //编号去除空格 清除多余数据 设置数据

+ 1 - 1
web/building_saas/main/js/views/locate_view.js

@@ -59,7 +59,7 @@ let locateObject={
         settingList :[
             {background:"E2F2C5",describe:""},
             {background:"F9E2CF",describe:""},
-            {background:"F2EFD9",describe:"hehe"},
+            {background:"F2EFD9",describe:""},
             {background:"F5D1DA",describe:""},
             {background:"E3E3E3",describe:""},
             {background:"B6F3F2",describe:""},

+ 22 - 4
web/building_saas/main/js/views/sub_fee_rate_views.js

@@ -75,7 +75,7 @@ var subRateObject={
         this.subRateSheet.suspendPaint();
         this.subRateSheet.suspendEvent();
         for(let row =0; row < this.datas.length;row++){
-            this.setComboOptionCell(row,1,this.datas[row],this.subRateSheet);
+            this.setComboOptionCell(row,1,this.datas[row],this.subRateSheet,this.datas[row].name);
             this.setTreeNodeCellType(this.datas,row,parentMap,visibleMap,this.subRateSheet);
         }
         this.subRateSheet.resumeEvent();
@@ -87,9 +87,20 @@ var subRateObject={
     onSubRateSelectChanged:function (e,info) {
         info.sheet.repaint();
     },
+    getAreaTips:function(name){
+        let field = name === "冬季施工"?"temperatureArea":"rainfallArea";
+        let location = feeRateObject.getLocation();
+        let area = feeRateAreaMap[location];
+        return area[field]||null;
+    },
     setTreeNodeCellType:function (datas,row,parentMap,visibleMap,sheet) {
         delete parentMap.undefined;//去掉无用节点
-        let treeNode = sheetCommonObj.getTreeNodeCellType(datas,row,parentMap);
+        let treeNode = null;
+        if(datas[row].name == "冬季施工" || datas[row].name == "雨季施工"){
+            treeNode = sheetCommonObj.getTreeNodeCellType(datas,row,parentMap,null,null,this.getAreaTips(datas[row].name));
+        }else{
+            treeNode = sheetCommonObj.getTreeNodeCellType(datas,row,parentMap);
+        }
         treeNode.treeNodeType = false;
         if((datas[row].subList && datas[row].subList.length >0)||datas[row].isSub == true ){
             treeNode.treeNodeType = true;
@@ -98,13 +109,20 @@ var subRateObject={
         sheet.setCellType(row, 0, treeNode, GC.Spread.Sheets.SheetArea.viewport);
         if(visibleMap[datas[row].ParentID]) sheet.getRange(row , -1, 1, -1).visible(!visibleMap[datas[row].ParentID]);//显示或隐藏
     },
-    setComboOptionCell:function(row,col,subRate,sheet){
+    setComboOptionCell:function(row,col,subRate,sheet,name){
         let options=[];
         if(subRate.isSub == true) return;//是树节点的子节点;
         for(let op of subRate.optionList){
            options.push(op.name);
         }
-        let dynamicCombo = sheetCommonObj.getDynamicCombo();//new GC.Spread.Sheets.CellTypes.ComboBox();
+        let dynamicCombo =null;
+        if(name == "冬季施工" || name == "雨季施工"){
+            let tips = this.getAreaTips(name)
+            dynamicCombo = sheetCommonObj.getTipsCombo(true, tips, {})
+        }else{
+            dynamicCombo = sheetCommonObj.getDynamicCombo();//new GC.Spread.Sheets.CellTypes.ComboBox();
+        }
+         
         dynamicCombo.items(options);
         if(subRate.editable == true) dynamicCombo.editable(true);
         sheet.setCellType(row, col, dynamicCombo, GC.Spread.Sheets.SheetArea.viewport);