浏览代码

指标信息

zhongzewei 7 年之前
父节点
当前提交
46f2c85aca

+ 1 - 0
config/gulpConfig.js

@@ -100,6 +100,7 @@ module.exports = {
         'web/building_saas/main/js/views/project_property_decimal_view.js',
         'web/building_saas/main/js/views/project_property_basicInfo.js',
         'web/building_saas/main/js/views/project_property_projFeature.js',
+        'web/building_saas/main/js/views/project_property_indicativeInfo.js',
         'web/building_saas/main/js/views/project_property_display_view.js',
         'web/building_saas/main/js/main_ajax.js',
         'web/building_saas/main/js/main.js',

+ 17 - 33
public/web/sheet/sheet_common.js

@@ -395,7 +395,7 @@ var sheetCommonObj = {
     },
     //设置系统粘贴板数据,需要用户触发事件,直接调用会失败
     copyTextToClipboard: function(text) {
-        var textArea = document.createElement("textarea");
+        let textArea = document.createElement("textarea");
         textArea.style.position = 'fixed';
         textArea.style.top = 0;
         textArea.style.left = 0;
@@ -410,8 +410,8 @@ var sheetCommonObj = {
         document.body.appendChild(textArea);
         textArea.select();
         try {
-            var successful = document.execCommand('copy');
-            var msg = successful ? 'successful' : 'unsuccessful';
+            let successful = document.execCommand('copy');
+            let msg = successful ? 'successful' : 'unsuccessful';
             console.log('Copying text command was ' + msg);
         } catch (err) {
             console.log('Oops, unable to copy');
@@ -422,38 +422,22 @@ var sheetCommonObj = {
     getTableData: function (sheet, colSettings = null) {
         let rst = '';
         let sel = sheet.getSelections()[0];
-        let vRows = [];
-        for(let i = sel.row, len = sel.row + sel.rowCount; i < len; i++){
-            if(sheet.getCell(i, -1).visible()){
-                vRows.push(i);
-            }
-        }
-        for(let row of vRows){
-            rst += '\n';
-            for(let j = 0, jLen = sel.colCount; j <jLen; j++){
+        let pasteText = [];
+        for(let row = sel.row; row < sel.row + sel.rowCount; row++){
+            if(!sheet.getCell(row, -1).visible())
+                continue;
+            let rowText = [];
+            for(let j = 0; j < sel.colCount; j++){
                 let col = sel.col + j;
-                if(sheet.getCell(-1, col).visible()){
-                    let v = '';
-                    if(colSettings && (colSettings[col]['data']['field'] === 'itemCharacterText' || colSettings[col]['data']['field'] === 'jobContentText')){
-                       // v += sheet.getText(row, col) ? sheet.getText(row, col).replace(new RegExp('\n', 'g'), '\v') : '';
-                        v += sheet.getText(row, col) ? `"${sheet.getText(row, col)}"` : '';
-                        if(j !== jLen - 1){
-                            v += '\t';
-                        }
-                    }
-                    else {
-                        if(j === jLen - 1){
-                            v += sheet.getText(row, col) ? sheet.getText(row, col).replace('\n', '') : '';
-                        }
-                        else {
-                            v += sheet.getText(row, col) ? sheet.getText(row, col).replace('\n', '') + '\t' : '\t';
-                        }
-                    }
-                    rst += v;
-                }
+                if(!sheet.getCell(-1, col).visible())
+                    continue;
+                if(colSettings && (colSettings[col]['data']['field'] === 'itemCharacterText' || colSettings[col]['data']['field'] === 'jobContentText'))
+                    rowText.push(sheet.getText(row, col) ? `"${sheet.getText(row, col)}"` : '');
+                else
+                    rowText.push(sheet.getText(row, col) ? sheet.getText(row, col): '');
             }
+            pasteText.push(rowText.join('\t'));
         }
-        rst = rst.replace('\n', '');
-        return rst;
+        return pasteText.join('\n');
     }
 }

+ 4 - 5
web/building_saas/main/html/main.html

@@ -289,7 +289,7 @@
                             <ul class="nav flex-column nav-pills" role="tablist">
                                 <li class="nav-item"><a class="nav-link active" data-toggle="pill" href="#poj-settings-basicInfo" role="tab" id="tab_poj-settings-basicInfo">基本信息</a></li>
                                 <li class="nav-item"><a class="nav-link" data-toggle="pill" href="#poj-settings-projFeature" id="tab_poj-settings-projFeature" role="tab">工程特征</a></li>
-                                <li class="nav-item"><a class="nav-link" data-toggle="pill" href="#poj-settings-3" role="tab">指标信息</a></li>
+                                <li class="nav-item"><a class="nav-link" data-toggle="pill" href="#poj-settings-indicativeInfo" id="tab_poj-settings-indicativeInfo" role="tab">指标信息</a></li>
                                 <li class="nav-item"><a class="nav-link" data-toggle="pill" href="#poj-settings-4" id="about-calc" role="tab">关于计算</a></li>
                                 <li class="nav-item"><a class="nav-link" data-toggle="pill" href="#poj-settings-billsQuanDecimal" id="tab_poj-settings-bqDecimal" role="tab">清单工程量精度</a></li>
                                 <li class="nav-item"><a class="nav-link" data-toggle="pill" href="#poj-settings-decimal" role="tab" id="tab_poj-settings-decimal">小数位数</a></li>
@@ -307,13 +307,11 @@
                                 <!--工程特征-->
                                 <div class="tab-pane fade" id="poj-settings-projFeature" role="tabpanel">
                                     <div class="modal-auto-height" style="overflow: hidden" id="projFeatureSpread">
-                                        工程特征
                                     </div>
                                 </div>
                                 <!--指标信息-->
-                                <div class="tab-pane fade" id="poj-settings-3" role="tabpanel">
-                                    <div class="modal-auto-height">
-                                        指标信息
+                                <div class="tab-pane fade" id="poj-settings-indicativeInfo" role="tabpanel">
+                                    <div class="modal-auto-height" style="overflow:hidden" id="indicativeInfoSpread">
                                     </div>
                                 </div>
                                 <!--关于计算-->
@@ -1128,6 +1126,7 @@
         <script type="text/javascript" src="/web/building_saas/main/js/views/project_property_decimal_view.js"></script>
         <script type="text/javascript" src="/web/building_saas/main/js/views/project_property_basicInfo.js"></script>
         <script type="text/javascript" src="/web/building_saas/main/js/views/project_property_projFeature.js"></script>
+        <script type="text/javascript" src="/web/building_saas/main/js/views/project_property_indicativeInfo.js"></script>
         <script type="text/javascript" src="/web/building_saas/main/js/views/project_property_display_view.js"></script>
         <script type="text/javascript" src="/web/building_saas/main/js/main_ajax.js"></script>
         <script type="text/javascript" src="/web/building_saas/main/js/main.js"></script>

+ 172 - 0
web/building_saas/main/js/views/project_property_indicativeInfo.js

@@ -0,0 +1,172 @@
+/**
+ * Created by Zhong on 2018/3/7.
+ */
+let indicativeInfoObj = {
+    feeType: {common: 'common', labour: 'labour', material: 'material', machine: 'machine', mainMaterial: 'mainMaterial', equipment: 'equipment',
+        labourDiff: 'labourDiff', materialDiff: 'materialDiff', machineDiff: 'machineDiff', manage: 'manage', profit: 'profit'},
+    workBook: null,
+    setting:{
+        header: [
+            {name: '名称', dataCode: 'name', width: 200, vAlign: 'center', hAlign: 'left'},
+            {name: '金额', dataCode: 'price', width: 120, vAlign: 'center', hAlign: 'right'},
+            {name: '占造价比例(%)', dataCode: 'rate', width: 100, vAlign: 'center', hAlign: 'right'},
+            {name: '单方造价', dataCode: 'perCentiare', width: 80, vAlign: 'center', hAlign: 'right'}
+        ],
+        options: {
+            tabStripVisible:  false,
+            allowCopyPasteExcelStyle : false,
+            allowExtendPasteRange: false,
+            allowUserDragDrop : false,
+            allowUserDragFill: false,
+            scrollbarMaxAlign : true
+        }
+    },
+
+    renderSheetFuc: function (sheet, fuc) {
+        sheet.suspendPaint();
+        sheet.suspendEvent();
+        fuc();
+        sheet.resumePaint();
+        sheet.resumeEvent();
+    },
+
+    setOptions: function (workbook, opts) {
+        for(let opt in opts){
+            workbook.options[opt] = opts[opt];
+        }
+    },
+
+    buildHeader: function (sheet, headers) {
+        let me = projFeatureView;
+        let fuc = function () {
+            sheet.setColumnCount(headers.length);
+            sheet.setRowHeight(0, 40, GC.Spread.Sheets.SheetArea.colHeader);
+            for(let i = 0, len = headers.length; i < len; i++){
+                sheet.setValue(0, i, headers[i].name, GC.Spread.Sheets.SheetArea.colHeader);
+                sheet.setColumnWidth(i, headers[i].width, GC.Spread.Sheets.SheetArea.colHeader);
+            }
+        };
+        me.renderSheetFuc(sheet, fuc);
+    },
+
+    buildSheet: function () {
+        if(!this.workBook){
+            this.workBook = new GC.Spread.Sheets.Workbook($('#indicativeInfoSpread')[0], {sheetCount: 1});
+            this.setOptions(this.workBook, this.setting.options);
+            this.workBook.getSheet(0).options.isProtected = true;
+            this.buildHeader(this.workBook.getActiveSheet(), this.setting.header);
+        }
+    },
+    showData(datas){
+        let sheet = this.workBook.getActiveSheet();
+        let cols = this.setting.header;
+        let fuc = function () {
+            sheet.setRowCount(datas.length);
+            for(let col = 0, cLen = cols.length; col < cLen; col++){
+                sheet.getRange(-1, col, -1, 1, GC.Spread.Sheets.SheetArea.viewport).hAlign(GC.Spread.Sheets.HorizontalAlign[cols[col]['hAlign']]);
+                sheet.getRange(-1, col, -1, 1, GC.Spread.Sheets.SheetArea.viewport).vAlign(GC.Spread.Sheets.VerticalAlign[cols[col]['vAlign']]);
+                for(let row = 0, rLen = datas.length; row < rLen; row++){
+                    sheet.setValue(row, col, datas[row][cols[col]['dataCode']]);
+                }
+            }
+        };
+        this.renderSheetFuc(sheet, fuc);
+    },
+    //是清单
+    isBills: function (node) {
+        return node && node.sourceType === projectObj.project.Bills.getSourceType();
+    },
+    //是大项费用
+    isDXFY: function (node) {
+        return this.isBills(node) && node.data.type === billType.DXFY;
+    },
+    //是分部分项工程
+    isFBFX: function (node) {
+        return this.isDXFY(node) && node.data.flagsIndex && node.data.flagsIndex.fixed && node.data.flagsIndex.fixed.flag === fixedFlag.SUB_ENGINERRING;
+    },
+    //是措施项目
+    isCSXM: function (node) {
+        return this.isDXFY(node) && node.data.flagsIndex && node.data.flagsIndex.fixed && node.data.flagsIndex.fixed.flag === fixedFlag.MEASURE;
+    },
+    //是工程造价
+    isEngieeringCost: function (node) {
+        return this.isDXFY(node) && node.data.flagsIndex && node.data.flagsIndex.fixed && node.data.flagsIndex.fixed.flag === fixedFlag.ENGINEERINGCOST;
+    },
+    //存在某个费用
+    fee: function (node, feeType) {
+        return node && node.data.feesIndex && node.data.feesIndex[feeType] ? node.data.feesIndex[feeType].totalFee : 0;
+    },
+    //根据固定行ID获取固定行清单节点
+    getFixedBill: function (flag) {
+        for(let node of projectObj.project.mainTree.items){
+            if(node && node.data.flagsIndex && node.data.flagsIndex.fixed && node.data.flagsIndex.fixed.flag === flag){
+                return node;
+            }
+        }
+        return null;
+    },
+    getDXFY: function (node) {
+        let dxfy = Object.create(null);
+        let engCostFee = this.fee(this.getFixedBill(fixedFlag.ENGINEERINGCOST), this.feeType.common);
+        let commonFee = this.fee(node, this.feeType.common);
+        let buildingArea = projFeatureView.getFeature('projFeature', 'buildingArea');
+        let areaNum = !buildingArea.value || buildingArea.value == '' || isNaN(buildingArea.value) ? 0 : buildingArea.value;
+        dxfy.name = node.data.name;
+        dxfy.price = commonFee ? parseFloat(commonFee).toDecimal(decimalObj.bills.totalPrice) : 0;
+        dxfy.rate = engCostFee == 0 || this.isEngieeringCost(node) ? '' : parseFloat(dxfy.price/engCostFee*100).toDecimal(2);
+        dxfy.perCentiare = areaNum == 0 ? '' : parseFloat(dxfy.price/areaNum).toDecimal(decimalObj.bills.totalPrice);
+        return dxfy;
+    },
+    getIndicativeInfo: function () {
+        let rst = [];
+        for(let node of projectObj.project.mainTree.items){
+            if(this.isDXFY(node)){
+                if(this.isFBFX(node)){
+                    rst.push(this.getDXFY(node));
+                    rst.push({name: '其中:', price: '', rate: '', perCentiare: ''});
+                    rst.push({name: '       人工费', price: parseFloat(this.fee(node, this.feeType.labour)).toDecimal(decimalObj.bills.totalPrice), rate: '', perCentiare: ''});
+                    rst.push({name: '       材料费', price: parseFloat(this.fee(node, this.feeType.material)).toDecimal(decimalObj.bills.totalPrice), rate: '', perCentiare: ''});
+                    rst.push({name: '       机械费', price: parseFloat(this.fee(node, this.feeType.machine)).toDecimal(decimalObj.bills.totalPrice), rate: '', perCentiare: ''});
+                    rst.push({name: '       主材费', price: parseFloat(this.fee(node, this.feeType.mainMaterial)).toDecimal(decimalObj.bills.totalPrice), rate: '', perCentiare: ''});
+                    rst.push({name: '       设备费', price: parseFloat(this.fee(node, this.feeType.equipment)).toDecimal(decimalObj.bills.totalPrice), rate: '', perCentiare: ''});
+                    let labourDiff = this.fee(node, this.feeType.labourDiff),
+                        materialDiff = this.fee(node, this.feeType.materialDiff),
+                        machineDiff = this.fee(node, this.feeType.machineDiff),
+                        rcjDiff = labourDiff + materialDiff + machineDiff;
+                    rst.push({name: '人材机价差', price: parseFloat(rcjDiff).toDecimal(decimalObj.bills.totalPrice), rate: '', perCentiare: ''});
+                    rst.push({name: '企业管理费', price: parseFloat(this.fee(node, this.feeType.manage)).toDecimal(decimalObj.bills.totalPrice), rate: '', perCentiare: ''});
+                    rst.push({name: '利润', price: parseFloat(this.fee(node, this.feeType.profit)).toDecimal(decimalObj.bills.totalPrice), rate: '', perCentiare: ''});
+                }
+                else if(this.isCSXM(node)){
+                    rst.push(this.getDXFY(node));
+                    rst.push({name: '其中:', price: '', rate: '', perCentiare: ''});
+                    let safeConst = this.getDXFY(this.getFixedBill(fixedFlag.SAFETY_CONSTRUCTION));
+                    safeConst.name = `      ${safeConst.name}`;
+                    rst.push(safeConst);
+                }
+                else{
+                    rst.push(this.getDXFY(node));
+                }
+            }
+        }
+        return rst;
+    }
+};
+
+$(document).ready(function () {
+    $('#poj-set').on('shown.bs.modal', function () {
+        indicativeInfoObj.buildSheet();
+        indicativeInfoObj.showData(indicativeInfoObj.getIndicativeInfo());
+    });
+
+    $('#poj-set').on('hidden.bs.modal', function () {
+       if(indicativeInfoObj.workBook){
+           indicativeInfoObj.workBook.destroy();
+           indicativeInfoObj.workBook = null;
+       }
+    });
+
+    $('#tab_poj-settings-indicativeInfo').on('shown.bs.tab', function () {
+        indicativeInfoObj.workBook.refresh();
+    });
+});

+ 15 - 2
web/building_saas/main/js/views/project_property_projFeature.js

@@ -9,7 +9,7 @@ let projFeatureView = {
     setting:{
         header: [
             {name: '属性', dataCode: 'dispName', width: 200, vAlign: 'center', hAlign: 'left'},
-            {name: '值', dataCode: 'value', width: 120, vAlign: 'center', hAlign: 'left'}
+            {name: '值', dataCode: 'value', width: 120, vAlign: 'center', hAlign: 'center'}
         ],
         options: {
             tabStripVisible:  false,
@@ -110,7 +110,7 @@ let projFeatureView = {
             }
             for(let col = 0, cLen = cols.length; col < cLen; col++){
                 sheet.getRange(-1, col, -1, 1).hAlign(GC.Spread.Sheets.HorizontalAlign[cols[col]['hAlign']]);
-                sheet.getRange(-1, col, -1, 1).hAlign(GC.Spread.Sheets.VerticalAlign[cols[col]['vAlign']]);
+                sheet.getRange(-1, col, -1, 1).vAlign(GC.Spread.Sheets.VerticalAlign[cols[col]['vAlign']]);
                 for(let row = 0, rLen = datas.length; row < rLen; row++){
                     sheet.setValue(row, col, datas[row][cols[col]['dataCode']]);
                 }
@@ -188,6 +188,19 @@ let projFeatureView = {
         }
     },
 
+    getFeature: function (featureType, eigenKey) {
+        for(let feature of this.orgDatas){
+            if(feature.key === featureType){
+                for(let eigen of feature.items){
+                    if(eigen.key === eigenKey){
+                        return eigen;
+                    }
+                }
+            }
+        }
+        return null;
+    },
+
     isDef: function (v) {
         return v !== undefined && v !== null;
     },