Ver código fonte

解决冲突

olym 8 anos atrás
pai
commit
def66e99ab

+ 2 - 0
Dockerfile

@@ -10,4 +10,6 @@ RUN cnpm install
 
 EXPOSE 6080
 
+ENV NODE_ENV=prod
+
 ENTRYPOINT babel-node operation.js

+ 15 - 0
Dockerfile_qa

@@ -0,0 +1,15 @@
+FROM server:2.0
+
+COPY . ConstructionOperation
+
+WORKDIR ConstructionOperation
+
+RUN mkdir tmp
+
+RUN cnpm install
+
+EXPOSE 6080
+
+ENV NODE_ENV=qa
+
+ENTRYPOINT babel-node operation.js

+ 4 - 14
config/config.js

@@ -3,20 +3,10 @@ module.exports = {
     local: {server: "localhost", port: "27017"},
     qa: {server: "192.168.1.184", port: "60666"},
     prod: {server: "", port: ""},
-    setToLocalDb: function() {
-        var me = this;
-        me.current.server = me.local.server;
-        me.current.port = me.local.port;
-    },
-    setToQaDb: function() {
-        var me = this;
-        me.current.server = me.qa.server;
-        me.current.port = me.qa.port;
-    },
-    setToProdDb: function() {
-        var me = this;
-        me.current.server = me.prod.server;
-        me.current.port = me.prod.port;
+    setupDb:function (env="local") {
+        let me = this;
+        me.current.server = me[env].server;
+        me.current.port = me[env].port;
     },
     pageSize: 30
 }

+ 64 - 0
modules/common/const/bills_fixed.js

@@ -0,0 +1,64 @@
+/**
+ * Created by Mai on 2017/8/29.
+ */
+
+const fixedFlag = {
+    // 分部分项工程
+    SUB_ENGINERRING: 1,
+    // 措施项目
+    MEASURE: 2,
+    // 施工技术措施项目
+    CONSTRUCTION_TECH: 3,
+    // 安全文明施工按实计算费用
+    SAFETY_CONSTRUCTION_ACTUAL: 4,
+    // 施工组织措施专项费用
+    CONSTRUCTION_ORGANIZATION: 5,
+    // 安全文明施工专项费用
+    SAFETY_CONSTRUCTION: 6,
+    // 其他项目
+    OTHER: 7,
+    // 暂列金额
+    PROVISIONAL: 8,
+    // 暂估价
+    ESTIMATE: 9,
+    // 材料(工程设备)暂估价
+    MATERIAL_PROVISIONAL: 10,
+    // 专业工程暂估价
+    ENGINEERING_ESITIMATE: 11,
+    // 计日工
+    DAYWORK: 12,
+    // 总承包服务费
+    TURN_KEY_CONTRACT: 13,
+    // 索赔与现场签证
+    CLAIM_VISA: 14,
+    // 规费
+    CHARGE: 15,
+    // 社会保险费及住房公积金 Social insurance fee and housing accumulation fund
+    SOCIAL_INSURANCE_HOUSING_FUND: 16,
+    // 工程排污费 charges for disposing pollutants
+    POLLUTANTS: 17,
+    // 税金
+    TAX: 18
+};
+const fixedFlagList = [
+    {name: "分部分项工程", value: fixedFlag.SUB_ENGINERRING},
+    {name: "措施项目", value: fixedFlag.MEASURE},
+    {name: "施工技术措施项目", value: fixedFlag.CONSTRUCTION_TECH},
+    {name: "安全文明施工按实计算费用", value: fixedFlag.SAFETY_CONSTRUCTION_ACTUAL},
+    {name: "施工组织措施专项费用", value: fixedFlag.CONSTRUCTION_ORGANIZATION},
+    {name: "安全文明施工专项费用", value: fixedFlag.SAFETY_CONSTRUCTION},
+    {name: "其他项目", value: fixedFlag.OTHER},
+    {name: "暂列金额", value: fixedFlag.PROVISIONAL},
+    {name: "暂估价", value: fixedFlag.ESTIMATE},
+    {name: "材料(工程设备)暂估价", value: fixedFlag.MATERIAL_PROVISIONAL},
+    {name: "专业工程暂估价", value: fixedFlag.ENGINEERING_ESITIMATE},
+    {name: "计日工", value: fixedFlag.DAYWORK},
+    {name: "总承包服务费", value: fixedFlag.TURN_KEY_CONTRACT},
+    {name: "索赔与现场签证", value: fixedFlag.CLAIM_VISA},
+    {name: "规费", value: fixedFlag.CHARGE},
+    {name: "社会保险费及住房公积金", value: fixedFlag.SOCIAL_INSURANCE_HOUSING_FUND},
+    {name: "工程排污费", value: fixedFlag.POLLUTANTS},
+    {name: "税金", value: fixedFlag.TAX}
+];
+
+export {fixedFlag as default, fixedFlagList as List};

+ 0 - 44
modules/templates/controllers/bills_template_controller.js

@@ -1,44 +0,0 @@
-/**
- * 清单模板控制器
- * Created by Mai on 2017/4/17.
- */
-
-import BillsTemplateModel from "../../templates/models/bills_template_model";
-
-let callback = function(req, res, err, message, data){
-    res.json({error: err, message: message, data: data});
-};
-
-class BillsTemplateController {
-    /**
-     * 清单模板编辑页面
-     * @param req
-     * @param res
-     */
-    async index(req, res) {
-        let id = req.query.id;
-        let billsTemplateModel = new BillsTemplateModel();
-        let billsTemplateData = await billsTemplateModel.getTemplateData(id);
-
-        let renderData = {
-            valuationId: id,
-            billsTemplateData: billsTemplateData,
-            layout: 'users/views/layout/layout'
-        };
-        res.render('maintain/templates/html/bills', renderData);
-    };
-
-    async updateBillsTemplate (req, res) {
-        let data = JSON.parse(req.body.data);
-        let billsTemplateModel = new BillsTemplateModel();
-        let result = await billsTemplateModel.updateTemplate(data.user_id, data.valuationId, data.updateData);
-
-        if (result) {
-            callback(req, res, 0, '', data);
-        } else {
-            callback(req, res, 1, '更新数据错误', null);
-        }
-    };
-};
-
-export default BillsTemplateController;

+ 0 - 26
modules/templates/routes/bills_template_router.js

@@ -1,26 +0,0 @@
-/**
- * Created by Mai on 2017/4/17.
- */
-
-import Express from "express";
-import baseController from './../../common/base/base_controller.js';
-import billsTemplateController from './../controllers/bills_template_controller';
-
-const router = Express.Router();
-const BaseController = new baseController();
-const BillsTemplateController = new billsTemplateController();
-
-module.exports = function (app) {
-    app.get('/template/bills/:id', BaseController.auth, BaseController.init, BillsTemplateController.index);
-
-    router.post('/updateBillsTemplate', BaseController.auth, BaseController.init, BillsTemplateController.updateBillsTemplate);
-    app.use('/template/bills/api', router);
-}
-
-
-
-
-
-
-
-

+ 10 - 8
modules/users/controllers/compilation_controller.js

@@ -12,7 +12,8 @@ import STDBillLibListsModel from "../../common/std/std_bills_lib_lists_model";
 import STDGLJLibMapModel from "../../common/std/std_glj_lib_map_model";
 import STDFeeRateLibsModel from "../../common/std/std_fee_rate_libs_model";
 import {default as EngineeringConst, List as EngineeringList} from "../../common/const/engineering";
-import BillsTemplateModel from "../../templates/models/bills_template_model";
+import BillsTemplateModel from "../models/bills_template_model";
+import {default as BillsFixedFlagConst, List as BillsFixedFlagList} from "../../common/const/bills_fixed.js";
 
 class CompilationController extends BaseController {
 
@@ -369,6 +370,7 @@ class CompilationController extends BaseController {
         let renderData = {
             billList: JSON.stringify(billList),
             billsTemplateData: JSON.stringify(billsTemplateData),
+            billsFixedFlagList: JSON.stringify(BillsFixedFlagList),
             valuationData: valuationData,
             valuationList: valuationList,
             selectedCompilation: selectedCompilation,
@@ -390,16 +392,16 @@ class CompilationController extends BaseController {
         let valuationId = request.params.id;
         let section = request.params.section;
         let data = JSON.parse(request.body.data);
-        console.log('hello');
+
         let billsTemplateModel = new BillsTemplateModel();
         let result = await billsTemplateModel.updateTemplate(valuationId, data);
 
-        // if (result) {
-        //     callback(request, response, 0, '', data);
-        // } else {
-        //     callback(request, response, 1, '更新数据错误', null);
-        // }
-        response.end('success');
+        if (result) {
+            response.json({error: 0, message: '', data: data});
+        } else {
+            response.json({error: 1, message: '更新数据错误', data: null});
+        }
+
     }
 
 }

+ 12 - 7
modules/templates/models/bills_template_model.js

@@ -24,7 +24,7 @@ class BillsTemplateModel extends BaseModel {
      */
     async getTemplateData (valuationId) {
         // 筛选字段
-        let field = {_id: 1, valuationId: 1, ID: 1, ParentID: 1, NextSiblingID: 1, code: 1, name: 1, unit: 1};
+        let field = {_id: 1, valuationId: 1, ID: 1, ParentID: 1, NextSiblingID: 1, code: 1, name: 1, unit: 1, flags: 1};
         let data = await this.findDataByCondition({valuationId: valuationId}, field, false);
 
         return data === null ? [] : data;
@@ -37,7 +37,7 @@ class BillsTemplateModel extends BaseModel {
      */
     async getTemplateDataForNewProj (valuationId) {
         // 筛选字段
-        let field = {ID: 1, ParentID: 1, NextSiblingID: 1, code: 1, name: 1, unit: 1};
+        let field = {ID: 1, ParentID: 1, NextSiblingID: 1, code: 1, name: 1, unit: 1, flags: 1};
         let data = await this.findDataByCondition({valuationId: valuationId}, field, false);
 
         return data === null ? [] : data;
@@ -46,18 +46,23 @@ class BillsTemplateModel extends BaseModel {
     async updateTemplate (valuationId, datas) {
         try {
             for (let data of datas) {
-                data.valuationId = valuationId;
+                data.data.valuationId = valuationId;
                 let condition = {valuationId: valuationId, ID: data.data.ID}, result;
                 if (data.type === 'update') {
-                    console.log('test');
                     result = await this.db.update(condition, data.data);
+                    if (result === undefined || result.ok ===undefined || !result.ok) {
+                        throw '更新数据错误';
+                    }
                 } else if (data.type === 'new') {
                     result = await this.db.create(data.data);
+                    if (!result) {
+                        throw '新增数据错误';
+                    }
                 } else if (data.type === 'delete') {
                     result = await this.db.delete(condition);
-                }
-                if (result === undefined || result.ok ===undefined || !result.ok) {
-                    throw '更新数据错误';
+                    if (result === undefined || result.ok ===undefined || !result.ok) {
+                        throw '删除数据错误';
+                    }
                 }
             }
             return true;

+ 1 - 0
modules/users/models/compilation_model.js

@@ -73,6 +73,7 @@ class CompilationModel extends BaseModel {
 
         this.setScene('add');
         data.create_time = new Date().getTime();
+        console.log(data);
         result = this.db.create(data);
         return result;
     }

+ 10 - 0
modules/templates/models/schemas/bills_template.js

@@ -6,6 +6,11 @@ let Schema = mongoose.Schema;
 
 let collectionName = 'temp_bills';
 
+// 标记字段
+let flagsSchema = new Schema({
+    fieldName: String,
+    flag: Number
+});
 let BillsTemplateSchema = {
     // 树结构所需ID
     ID: Number,
@@ -17,6 +22,11 @@ let BillsTemplateSchema = {
     name: String,
     // 单位
     unit: String,
+    // 标记
+    flags:{
+        type: [flagsSchema],
+        default: []
+    },
     // 所属计价ID
     valuationId: String
 };

+ 1 - 1
operation.js

@@ -1,7 +1,7 @@
 let express = require('express');
 
 let config = require("./config/config.js");
-config.setToQaDb();
+config.setupDb(process.env.NODE_ENV);
 let dbm = require("./config/db/db_manager");
 
 let path = require('path');

+ 5 - 0
public/web/sheet/sheet_common.js

@@ -136,6 +136,9 @@ var sheetCommonObj = {
                 else {
                     sheet.setValue(row, col, data[row][setting.header[col].dataCode], ch);
                     sheet.setTag(row, 0, data[row].ID, ch);
+                    if(typeof setting.owner === 'undefined'){
+                        sheet.getCell(row, 0, GC.Spread.Sheets.SheetArea.viewport).locked(true);
+                    }
                 }
             }
             for(let i = data.length; i < sheet.getRowCount(); i++){
@@ -203,6 +206,7 @@ var sheetCommonObj = {
                                     me.unLockAllCells(sheet);
                                     me.reLockSomeCodes(sheet, 0, repositoryGljObj.currentCache.length);
                                     sheet.setValue(row, 0, orgCode);
+                                    sheet.getCell(row, 0).formatter("@");
                                     sheet.setActiveCell(row, 0);
                                 });
                                 $('#codAleClose').click(function () {
@@ -210,6 +214,7 @@ var sheetCommonObj = {
                                     me.unLockAllCells(sheet);
                                     me.reLockSomeCodes(sheet, 0, repositoryGljObj.currentCache.length);
                                     sheet.setValue(row, 0, orgCode);
+                                    sheet.getCell(row, 0).formatter("@");
                                     sheet.setActiveCell(row, 0);
                                 });
                                 // sheet.setValue(row, col, orgCode);

+ 3 - 0
public/web/tree_sheet/tree_sheet_helper.js

@@ -109,6 +109,9 @@ var TREE_SHEET_HELPER = {
                 } else {
                     cell.value(getFieldText2());
                 }
+                if (colSetting.data.cellType) {
+                    cell.cellType(colSetting.data.cellType);
+                }
             });
             if (recursive) {
                 TREE_SHEET_HELPER.refreshTreeNodeData(setting, sheet, node.children, recursive);

+ 17 - 15
web/maintain/ration_repository/js/ration_glj.js

@@ -190,7 +190,8 @@ var rationGLJOprObj = {
                         let maxCount = info.cellRange.row + info.cellRange.rowCount -1 > me.cache["_GLJ_" + me.currentRationItem.ID].length -1 ?
                         me.cache["_GLJ_" + me.currentRationItem.ID].length - info.cellRange.row : info.cellRange.rowCount;
                         for(let i = 0; i < maxCount; i++){
-                            me.cache["_GLJ_" + me.currentRationItem.ID][info.cellRange.row + i].consumeAmt = tempConsumes[i].consumeAmt;
+                            let roundCons = me.round(tempConsumes[i].consumeAmt, 3);
+                            me.cache["_GLJ_" + me.currentRationItem.ID][info.cellRange.row + i].consumeAmt = roundCons;
                         }
                         me.updateRationItem();
                         if(info.cellRange.row + info.cellRange.rowCount -1 >= me.cache["_GLJ_" + me.currentRationItem.ID].length -1){
@@ -235,7 +236,8 @@ var rationGLJOprObj = {
                     }
                     else{
                         args.sheet.setValue(args.row, args.col, parseNum);
-                        editGlj["consumeAmt"] = parseNum;
+                        let roundNum = me.round(parseNum, 3);
+                        editGlj["consumeAmt"] = roundNum;
                         me.updateRationItem();
                     }
                 }
@@ -349,26 +351,25 @@ var rationGLJOprObj = {
             }
         })
     },
-
+    round(v, e){
+        var t=1;
+        for(;e>0;t*=10,e--);
+        for(;e<0;t/=10,e++);
+        return Math.round(v*t)/t;
+    },
     rationCal: function () {
-        let me = this;
+        let me = rationGLJOprObj;
         let price = {gljType1: [], gljType2: [], gljType3: []}, rst = {labourPrice: 0, materialPrice: 0, machinePrice: 0}, rationBasePrc = 0;
-        function round(v,e){
-            var t=1;
-            for(;e>0;t*=10,e--);
-            for(;e<0;t/=10,e++);
-            return Math.round(v*t)/t;
-        }
         if(me.currentRationItem && me.cache['_GLJ_' + me.currentRationItem.ID]){
             let cacheArr = me.cache['_GLJ_' + me.currentRationItem.ID];
             cacheArr.forEach(function (gljData) {
                 if(gljData.gljType && gljData.basePrice && gljData.consumeAmt){
                     let parent = me.distTypeTree.distTypes[me.distTypeTree.prefix + gljData.gljType].parent;
                     if(parent && parent.data.ID <= 3){
-                        price['gljType' + parent.data.ID].push(round( gljData.basePrice * gljData.consumeAmt, 3));//取三位
+                        price['gljType' + parent.data.ID].push(me.round( gljData.basePrice * gljData.consumeAmt, 3));//取三位
                     }
                     if(!parent && gljData.gljType <= 3){
-                        price['gljType' + gljData.gljType].push(round( gljData.basePrice * gljData.consumeAmt, 3));//取三位
+                        price['gljType' + gljData.gljType].push(me.round( gljData.basePrice * gljData.consumeAmt, 3));//取三位
                     }
                 }
             });
@@ -377,7 +378,7 @@ var rationGLJOprObj = {
                 price.gljType1.forEach(function (singlePrc) {
                     labourPrice += singlePrc;
                 });
-                let roundPrice = round(labourPrice, 2);
+                let roundPrice = me.round(labourPrice, 2);
                 rst.labourPrice = roundPrice;
                 rationBasePrc += roundPrice;
             }
@@ -386,7 +387,7 @@ var rationGLJOprObj = {
                 price.gljType2.forEach(function (singlePrc) {
                     materialPrice += singlePrc;
                 });
-                let roundPrice = round(materialPrice, 2);
+                let roundPrice = me.round(materialPrice, 2);
                 rst.materialPrice = roundPrice;
                 rationBasePrc += roundPrice;
             }
@@ -395,7 +396,7 @@ var rationGLJOprObj = {
                 price.gljType3.forEach(function (singlePrc) {
                     machinePrice += singlePrc;
                 });
-                let roundPrice = round(machinePrice, 2);
+                let roundPrice = me.round(machinePrice, 2);
                 rst.machinePrice = roundPrice;
                 rationBasePrc += roundPrice;
             }
@@ -460,6 +461,7 @@ var rationGLJOprObj = {
                 cache:false,
                 timeout:5000,
                 success:function(result){
+                    console.log(result);
                     sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
                     if (result) {
                         var cacheArr = [];

+ 1 - 1
web/maintain/std_glj_lib/html/gongliao.html

@@ -213,7 +213,7 @@
     <script type="text/javascript" src="/public/web/storageUtil.js"></script>
     <SCRIPT type="text/javascript">
         let userAccount = '<%=userAccount %>';
-        var gljSetting = {
+        let gljSetting = {
             view: {
                 //addHoverDom: gljTypeTreeOprObj.addHoverDom,
                 //removeHoverDom: gljTypeTreeOprObj.removeHoverDom,

+ 36 - 23
web/maintain/std_glj_lib/js/glj.js

@@ -377,9 +377,12 @@ let repositoryGljObj = {
                             let field = me.setting.header[col].dataCode;
                             if(field === 'gljType'){
                                 me.workBook.getSheet(0).getCell(me.editingRowIdx, col).value(
-                                    me.distTypeTree.distTypes[me.distTypeTree.prefix + me.currentEditingGlj[field]].data.fullName);
+                                    typeof me.currentEditingGlj[field] !== 'undefined'?
+                                        me.distTypeTree.distTypes[me.distTypeTree.prefix + me.currentEditingGlj[field]].data.fullName
+                                        : '');
                             }
                             else{
+                                me.workBook.getSheet(0).getCell(me.editingRowIdx, 0).formatter("@");
                                 me.workBook.getSheet(0).getCell(me.editingRowIdx, col).value(me.currentEditingGlj[me.setting.header[col].dataCode]);
                             }
                         }
@@ -415,10 +418,9 @@ let repositoryGljObj = {
         if (me.currentEditingGlj["ID"]) {
             rObj["ID"] = me.currentEditingGlj["ID"];
             rObj.gljClass = me.currentEditingGlj.gljClass;
-            for(let col =0; col< me.setting.header.length; col++){
-                if(me.currentEditingGlj[me.setting.header[col].dataCode] !== rObj[me.setting.header[col].dataCode]){
-                    me.addGljObj = rObj;
-                    if(rObj[me.setting.header[0].dataCode] && rObj[me.setting.header[1].dataCode] && rObj[me.setting.header[5].dataCode]){
+                if(me.currentEditingGlj[me.setting.header[args.col].dataCode] !== rObj[me.setting.header[args.col].dataCode]){
+                    if(rObj[me.setting.header[0].dataCode] && rObj[me.setting.header[1].dataCode] && rObj[me.setting.header[5].dataCode] &&
+                        rObj[me.setting.header[0].dataCode].toString().trim().length !== 0 && rObj[me.setting.header[1].dataCode].toString().trim().length !== 0 && rObj[me.setting.header[5].dataCode].toString().trim().length !== 0){
                         if(rObj.gljType !== me.currentEditingGlj.gljType){//修改了工料机类型
                             if(me.currentGlj){
                                 me.currentGlj.component = [];
@@ -451,14 +453,21 @@ let repositoryGljObj = {
                                     updateArr.push(updateGljs.updateBasePrcArr[i]);
                                 }
                             }
-                            rObj.basePrice = !isNaN(parseFloat(rObj.basePrice)) && (rObj.basePrice && typeof rObj.basePrice !== 'undefined') ? parseFloat(rObj.basePrice) : 0;
+                            rObj.basePrice = !isNaN(parseFloat(rObj.basePrice)) && (rObj.basePrice && typeof rObj.basePrice !== 'undefined') ? that.round(parseFloat(rObj.basePrice), 2) : 0;
                         }
                         rObj.component = me.currentGlj.component;
                         updateArr.push(rObj);
-                        break;
+                    }
+                    else{
+                        if(me.setting.header[args.col].dataCode === 'gljType'){
+                            let distTypeVal =  me.distTypeTree.distTypes[me.distTypeTree.prefix + me.currentEditingGlj[me.setting.header[args.col].dataCode]].data.fullName;
+                            args.sheet.setValue(args.row, args.col, distTypeVal);
+                        }
+                        else{
+                            args.sheet.setValue(args.row, args.col, me.currentEditingGlj[me.setting.header[args.col].dataCode]);
+                        }
                     }
                 }
-            }
             //--------------------------------------
             if(me.currentEditingGlj.basePrice !== rObj.basePrice){
                 //update basePrice of ration when editting basePrice of glj
@@ -491,20 +500,22 @@ let repositoryGljObj = {
         }
         //新增
         else {
-            me.addGljObj = rObj;
-            let isCanSav = true;
-            if(!rObj[me.setting.header[0].dataCode] || !rObj[me.setting.header[1].dataCode] || !rObj[me.setting.header[5].dataCode]){
-                isCanSav = false;
-            }
-            if(isCanSav){
-                me.addGljObj = null;
-                rObj.component = [];
-                //如果类型为混凝土、砂浆、配合比、机械台班时,添加时填写的单价清空
-                if(me.allowComponent.indexOf(rObj.gljType) !== -1){
-                    rObj.basePrice = 0;
+            if(typeof rObj.code !== 'undefined'){
+                me.addGljObj = rObj;
+                let isCanSav = true;
+                if(!rObj[me.setting.header[0].dataCode] || !rObj[me.setting.header[1].dataCode] || !rObj[me.setting.header[5].dataCode]){
+                    isCanSav = false;
+                }
+                if(isCanSav){
+                    me.addGljObj = null;
+                    rObj.component = [];
+                    //如果类型为混凝土、砂浆、配合比、机械台班时,添加时填写的单价清空
+                    if(me.allowComponent.indexOf(rObj.gljType) !== -1){
+                        rObj.basePrice = 0;
+                    }
+                    rObj.basePrice = !isNaN(parseFloat(rObj.basePrice)) && (rObj.basePrice && typeof rObj.basePrice !== 'undefined') ? parseFloat(rObj.basePrice) : 0;
+                    addArr.push(rObj);
                 }
-                rObj.basePrice = !isNaN(parseFloat(rObj.basePrice)) && (rObj.basePrice && typeof rObj.basePrice !== 'undefined') ? parseFloat(rObj.basePrice) : 0;
-                addArr.push(rObj);
             }
         }
         if(me.gljCurTypeId !== 732){
@@ -620,6 +631,7 @@ let repositoryGljObj = {
     validUpdateObj: function (pasteObj, rowIdx) {
         let rst = {updateGlj: [], updateBasePrcArr: []}, backUpObj = {},
             me = repositoryGljObj,
+            that = gljComponentOprObj,
             tempObj = me.currentCache[rowIdx],
             reCalBasePrc = false,
             isValid = true;
@@ -684,7 +696,7 @@ let repositoryGljObj = {
             if(!isExsit) isValid = false;
         }
         //
-        pasteObj.basePrice = !isNaN(parseFloat(pasteObj.basePrice)) && (pasteObj.basePrice && typeof pasteObj.basePrice !== 'undefined') ? parseFloat(pasteObj.basePrice) :
+        pasteObj.basePrice = !isNaN(parseFloat(pasteObj.basePrice)) && (pasteObj.basePrice && typeof pasteObj.basePrice !== 'undefined') ? that.round(parseFloat(pasteObj.basePrice), 2) :
             me.currentCache[rowIdx].basePrice;
         if(pasteObj.basePrice !== me.currentCache[rowIdx].basePrice){
             reCalBasePrc = true;
@@ -748,6 +760,7 @@ let repositoryGljObj = {
         return true;
     },
     onClipboardPasting: function(sender, args) {
+        console.log(`oncp`);
         let me = repositoryGljObj;
         /*if (args.cellRange.colCount != me.setting.header.length || me.gljCurTypeId < 0 || me.parentNodeIds["_pNodeId_" + me.gljCurTypeId]) {
          args.cancel = true;
@@ -773,7 +786,6 @@ let repositoryGljObj = {
                 //updateItems = items;
                 for(let i = 0; i < items.length; i++){
                     let updateObj = me.validUpdateObj(items[i], info.cellRange.row + i);
-                    console.log(updateObj);
                     if(updateObj && typeof updateObj.updateGlj !== 'undefined'){
                         updateArr = updateObj.updateGlj;
                         if(typeof updateObj.updateBasePrc !== 'undefined'){
@@ -1008,6 +1020,7 @@ let gljTypeTreeOprObj = {
             that = gljComponentOprObj,
             gljTypeId = treeNode.ID;
         me.gljCurTypeId = treeNode.ID;
+        me.addGljObj = null;
         //me.currentCache = me.getCache();
         sheetCommonObj.cleanSheet(that.workBook.getSheet(0), that.setting, 5);
         that.workBook.getSheet(0).getRange(-1, 0 , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(true);

+ 95 - 94
web/maintain/std_glj_lib/js/gljComponent.js

@@ -143,121 +143,121 @@ let gljComponentOprObj = {
     onCellEditEnd: function (sender, args) {
         let me = gljComponentOprObj, that = repositoryGljObj, updateBasePrc = [];
         let gljList = that.gljList, updateArr = [], materialComponent = [202, 203, 204], machineComponent = [302, 303];
-        if(args.editingText !== me.currentEditingComponent.code){
-            if(args.col === 0 && args.editingText && args.editingText.trim().length > 0){
-                let component = that.currentGlj.component, hasCode = false;
-                for(let i = 0; i < gljList.length; i++){
-                    if(gljList[i].code === args.editingText){//有效的组成物
-                        hasCode = true;
-                        if((materialComponent.indexOf(that.currentGlj.gljType) !== -1 && gljList[i].gljType === 201)
-                            || (that.currentGlj.gljType === 301 && machineComponent.indexOf(gljList[i].gljType) !== -1 )){//普通材料
-                            //是否与原有组成物不同
-                            let isExist = false;
-                            for(let j = 0; j < component.length; j++){
-                                if(component[j].ID === gljList[i].ID){
-                                    isExist = true;
-                                    break;
-                                }
+        //if(args.editingText !== me.currentEditingComponent.code){
+        if(args.col === 0 && args.editingText && args.editingText.trim().length > 0 && args.editingText !== me.currentEditingComponent.code){
+            let component = that.currentGlj.component, hasCode = false;
+            for(let i = 0; i < gljList.length; i++){
+                if(gljList[i].code === args.editingText){//有效的组成物
+                    hasCode = true;
+                    if((materialComponent.indexOf(that.currentGlj.gljType) !== -1 && gljList[i].gljType === 201)
+                        || (that.currentGlj.gljType === 301 && machineComponent.indexOf(gljList[i].gljType) !== -1 )){//普通材料
+                        //是否与原有组成物不同
+                        let isExist = false;
+                        for(let j = 0; j < component.length; j++){
+                            if(component[j].ID === gljList[i].ID){
+                                isExist = true;
+                                break;
                             }
-                            if(!isExist){
-                                let rObj = {};
-                                rObj.ID = gljList[i].ID;
-                                //rObj.basePrice = gljList[i].basePrice;
-                                if(typeof that.currentComponent[args.row] !== 'undefined'){
-                                    rObj.consumeAmt = that.currentComponent[args.row].consumeAmt;
-                                    let index;
-                                    for(let j = 0; j < component.length; j++){
-                                        if(component[j].ID === that.currentComponent[args.row].ID){
-                                            index = j;
-                                            break;
-                                        }
-                                    }
-                                    component.splice(index, 1);
-                                    component.splice(index, 0, rObj);
-                                    //计算工料机单价
-                                    let gljBasePrc = me.reCalGljBasePrc(that.getCurrentComponent(component));
-                                    if(gljBasePrc !== that.currentGlj.basePrice){
-                                        that.currentGlj.basePrice = gljBasePrc;
-                                        that.reshowGljBasePrc(that.currentGlj);
-                                        //工料机单价改变,重算引用了该工料机的定额单价
-                                        updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
+                        }
+                        if(!isExist){
+                            let rObj = {};
+                            rObj.ID = gljList[i].ID;
+                            //rObj.basePrice = gljList[i].basePrice;
+                            if(typeof that.currentComponent[args.row] !== 'undefined'){
+                                rObj.consumeAmt = that.currentComponent[args.row].consumeAmt;
+                                let index;
+                                for(let j = 0; j < component.length; j++){
+                                    if(component[j].ID === that.currentComponent[args.row].ID){
+                                        index = j;
+                                        break;
                                     }
-                                    updateArr.push(that.currentGlj);
                                 }
-                                else{
-                                    rObj.consumeAmt = 0;
-                                    component.push(rObj);
-                                    //计算工料机单价
-                                    let gljBasePrc = me.reCalGljBasePrc(that.getCurrentComponent(component));
-                                    if(gljBasePrc !== that.currentGlj.basePrice){
-                                        that.currentGlj.basePrice = gljBasePrc;
-                                        that.reshowGljBasePrc(that.currentGlj);
-                                        //工料机单价改变,重算引用了该工料机的定额单价
-                                        updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
-                                    }
-                                    updateArr.push(that.currentGlj);
+                                component.splice(index, 1);
+                                component.splice(index, 0, rObj);
+                                //计算工料机单价
+                                let gljBasePrc = me.reCalGljBasePrc(that.getCurrentComponent(component));
+                                if(gljBasePrc !== that.currentGlj.basePrice){
+                                    that.currentGlj.basePrice = gljBasePrc;
+                                    that.reshowGljBasePrc(that.currentGlj);
+                                    //工料机单价改变,重算引用了该工料机的定额单价
+                                    updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
                                 }
-                                break;
+                                updateArr.push(that.currentGlj);
                             }
                             else{
-                                //已存在
-                                alert("已存在!");
-                                args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
-                                    me.currentEditingComponent[me.setting.header[args.col].dataCode]: '');
+                                rObj.consumeAmt = 0;
+                                component.push(rObj);
+                                //计算工料机单价
+                                let gljBasePrc = me.reCalGljBasePrc(that.getCurrentComponent(component));
+                                if(gljBasePrc !== that.currentGlj.basePrice){
+                                    that.currentGlj.basePrice = gljBasePrc;
+                                    that.reshowGljBasePrc(that.currentGlj);
+                                    //工料机单价改变,重算引用了该工料机的定额单价
+                                    updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
+                                }
+                                updateArr.push(that.currentGlj);
                             }
-
+                            break;
                         }
                         else{
-                            if(materialComponent.indexOf(that.currentGlj.gljType) === 1){
-                                alert("该组成物只能是普通材料!");
-                            }
-                            else if(that.currentGlj.gljType === 301){
-                                alert("该组成物只能是机械组成物或机上人工!")
-                            }
+                            //已存在
+                            alert("已存在!");
                             args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
                                 me.currentEditingComponent[me.setting.header[args.col].dataCode]: '');
-                            //无效
                         }
+
                     }
-                }
-                if(!hasCode){
-                    alert("不存在此工料机,请先添加!");
-                    args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
-                        me.currentEditingComponent[me.setting.header[args.col].dataCode] : '');
-                    //不存在
-                }
-            }
-            else if(args.col === 4 && me.currentEditingComponent.code && args.editingText && args.editingText.trim().length > 0){//消耗量
-                let consumeAmt = parseFloat(args.editingText);
-                if(!isNaN(consumeAmt) && consumeAmt !== me.currentEditingComponent.consumeAmt){
-                    let component = that.currentGlj.component;
-                    for(let i = 0; i < component.length; i++){
-                        if(component[i].ID === that.currentComponent[args.row].ID){
-                            component[i].consumeAmt = consumeAmt
+                    else{
+                        if(materialComponent.indexOf(that.currentGlj.gljType) === 1){
+                            alert("该组成物只能是普通材料!");
+                        }
+                        else if(that.currentGlj.gljType === 301){
+                            alert("该组成物只能是机械组成物或机上人工!")
                         }
+                        args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
+                            me.currentEditingComponent[me.setting.header[args.col].dataCode]: '');
+                        //无效
                     }
-                    that.currentComponent[args.row].consumeAmt = consumeAmt;
-                    //计算工料机单价
-                    let gljBasePrc = me.reCalGljBasePrc(that.currentComponent);
-                    if(gljBasePrc !== that.currentGlj.basePrice){
-                        that.currentGlj.basePrice = gljBasePrc;
-                        that.reshowGljBasePrc(that.currentGlj);
-                        //工料机单价改变,重算引用了该工料机的定额单价
-                        updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
+                }
+            }
+            if(!hasCode){
+                alert("不存在此工料机,请先添加!");
+                args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
+                    me.currentEditingComponent[me.setting.header[args.col].dataCode] : '');
+                //不存在
+            }
+        }
+        else if(args.col === 4 && me.currentEditingComponent.code && args.editingText && args.editingText.trim().length > 0){//消耗量
+            let consumeAmt = parseFloat(args.editingText);
+            if(!isNaN(consumeAmt) && consumeAmt !== me.currentEditingComponent.consumeAmt){
+                let roundCons = me.round(consumeAmt, 3);
+                let component = that.currentGlj.component;
+                for(let i = 0; i < component.length; i++){
+                    if(component[i].ID === that.currentComponent[args.row].ID){
+                        component[i].consumeAmt = roundCons;
                     }
-                    updateArr.push(that.currentGlj);
                 }
-                else{
-                    //只能输入数值
-                    args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
-                        me.currentEditingComponent[me.setting.header[args.col].dataCode]: 0);
-
+                that.currentComponent[args.row].consumeAmt = roundCons;
+                //计算工料机单价
+                let gljBasePrc = me.reCalGljBasePrc(that.currentComponent);
+                if(gljBasePrc !== that.currentGlj.basePrice){
+                    that.currentGlj.basePrice = gljBasePrc;
+                    that.reshowGljBasePrc(that.currentGlj);
+                    //工料机单价改变,重算引用了该工料机的定额单价
+                    updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
                 }
+                updateArr.push(that.currentGlj);
             }
             else{
-                args.sheet.setValue(args.row, args.col, '');
+                //只能输入数值
+                args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
+                    me.currentEditingComponent[me.setting.header[args.col].dataCode]: 0);
+
             }
         }
+        else{
+            args.sheet.setValue(args.row, args.col, '');
+        }
         if(updateArr.length > 0){
             me.updateComponent(updateArr);
             if(updateBasePrc.length > 0){
@@ -349,8 +349,9 @@ let gljComponentOprObj = {
                 if(row + i < that.currentComponent.length){
                     let currentObj = that.currentComponent[row + i];
                     if(items[i].consumeAmt.trim().length > 0 && items[i].consumeAmt !== currentObj.consumeAmt){
+                        let roundCons = me.round(items[i].consumeAmt, 3);
                         isChange = true;
-                        currentObj.consumeAmt = items[i].consumeAmt;
+                        currentObj.consumeAmt = roundCons;
                         for(let j = 0; j < component.length; j++){
                             if(component[j].ID === currentObj.ID){
                                 component[j].consumeAmt = currentObj.consumeAmt;

+ 4 - 3
web/users/js/compilation.js

@@ -244,9 +244,6 @@ function initCompilation() {
     let gljLibData = gljList === undefined ? [] : JSON.parse(gljList);
     let feeLibData = feeRateList === undefined ? [] : JSON.parse(feeRateList);
 
-    if (billListData.length <= 0 || rationLibData.length <= 0 || gljLibData.length <= 0) {
-        return false;
-    }
     // 初始化 造价书列设置
     colSpread = TREE_SHEET_HELPER.createNewSpread($('#main-tree-col')[0]);
     let billsTemplateTree = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1});
@@ -254,6 +251,10 @@ function initCompilation() {
     TREE_SHEET_HELPER.loadSheetHeader(JSON.parse(mainTreeCol), colSpread.getActiveSheet());
     TREE_SHEET_HELPER.showTreeData(JSON.parse(mainTreeCol), colSpread.getActiveSheet(), billsTemplateTree);
 
+    if (billListData.length <= 0 || rationLibData.length <= 0 || gljLibData.length <= 0) {
+        return false;
+    }
+
     // 标准清单
     let html = '';
     for(let tmp of billListData) {

+ 84 - 8
web/users/js/template.js

@@ -9,7 +9,7 @@ let TEMPLATE_BILLS_SETTING = {
     "treeCol": 0,
     "cols":[{
         "width":200,
-        "readOnly":null,
+        "readOnly":false,
         "head":{
             "titleNames":["编号"],
             "spanCols":[1],
@@ -26,7 +26,7 @@ let TEMPLATE_BILLS_SETTING = {
         }
     }, {
         "width":300,
-        "readOnly":null,
+        "readOnly":false,
         "head":{
             "titleNames":["名称"],
             "spanCols":[1],
@@ -43,7 +43,7 @@ let TEMPLATE_BILLS_SETTING = {
         }
     }, {
         "width":50,
-        "readOnly":null,
+        "readOnly":false,
         "head":{
             "titleNames":["单位"],
             "spanCols":[1],
@@ -59,6 +59,23 @@ let TEMPLATE_BILLS_SETTING = {
             "font":"Arail"
         }
     }, {
+        "width":200,
+        "readOnly":false,
+        "head":{
+            "titleNames":["清单固定类别"],
+            "spanCols":[1],
+            "spanRows":[1],
+            "vAlign":[1],
+            "hAlign":[1],
+            "font":["Arial"]
+        },
+        "data":{
+            "field":"flagsIndex.fixed.flag",
+            "vAlign":0,
+            "hAlign":3,
+            "font":"Arail",
+        }
+    }, {
         "width":50,
         "readOnly":true,
         "head":{
@@ -135,6 +152,52 @@ $(document).ready(function () {
             }
         });
     };
+    let getFixedFlagCellType = function () {
+        let billsFixedFlagData = JSON.parse(billsFixedFlagList);
+        let comboItems = [];
+        for (let data of billsFixedFlagData) {
+            comboItems.push({text: data.name, value: data.value});
+        }
+        let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
+        combo.editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.value)
+            .items(comboItems);
+        return combo;
+    };
+    let setFee = function (data, fullField, value) {
+        let fields = fullField.split('.'), valueField = data;
+        for (let i in fields) {
+            if (valueField[fields[i]]) {
+                if (i == fields.length - 1) {
+                    valueField[fields[i]] = value;
+                } else {
+                    valueField = valueField[fields[i]];
+                }
+            } else {
+                if (i == fields.length - 1) {
+                    valueField[fields[i]] = value;
+                } else {
+                    valueField[fields[i]] = {};
+                };
+                valueField = valueField[fields[i]];
+            }
+        }
+    }
+
+    let templateData = JSON.parse(billsTemplateData);
+    for (let data of templateData) {
+        if (data.flags) {
+            data.flagsIndex = {};
+            for (let flag of data.flags) {
+                data.flagsIndex[flag.fieldName] = flag;
+            }
+        }
+    }
+
+    for (col of TEMPLATE_BILLS_SETTING.cols) {
+        if (col.data.field === 'flagsIndex.fixed.flag' && TEMPLATE_BILLS_SETTING.cols.indexOf(col) !== TEMPLATE_BILLS_SETTING.treeCol) {
+            col.data.cellType = getFixedFlagCellType();
+        }
+    }
 
     let tree = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1, autoUpdate: true});
     let billsSpread = TREE_SHEET_HELPER.createNewSpread($('#billsSpread')[0]);
@@ -146,10 +209,16 @@ $(document).ready(function () {
         var node = controller.tree.items[info.row];
         var fieldName = controller.setting.cols[info.col].data.field;
         var data = {type: 'update', data: {ID: node.getID()}};
-        data.data[fieldName] = info.editingText;
+        if (/flagsIndex/.test(fieldName)) {
+            data.data.flags = [];
+            let flagField = fieldName.split('.');
+            data.data.flags.push({fieldName: flagField[1], flag: info.editingText});
+        } else {
+            setFee(data.data, fieldName, info.editingText);
+        }
         var updateData = [data];
         CommonAjax.post(updateUrl, updateData, function (data) {
-            node.data[fieldName] = info.editingText;
+            setFee(node.data, fieldName, info.editingText);
             controller.refreshTreeNode([node], false);
         }, function () {
             controller.refreshTreeNode([node], false);
@@ -166,7 +235,14 @@ $(document).ready(function () {
                 for (iCol = 0; iCol < info.cellRange.colCount; iCol++) {
                     curCol = info.cellRange.col + iCol;
                     fieldName = controller.setting.cols[curCol].data.field;
-                    data.data[fieldName] = info.sheet.getText(curRow, curCol);
+
+                    if (/flagsIndex/.test(fieldName)) {
+                        data.data.flags = [];
+                        let flagField = fieldName.split('.');
+                        data.data.flags.push({fieldName: flagField[1],flag: info.sheet.getText(curRow, curCol)});
+                    } else {
+                        setFee(data.data, fieldName, info.sheet.getText(curRow, curCol));
+                    }
                 }
                 datas.push(data);
             }
@@ -179,7 +255,7 @@ $(document).ready(function () {
         });
     });
 
-    tree.loadDatas(JSON.parse(billsTemplateData));
+    tree.loadDatas(templateData);
     controller.showTreeData();
     RefreshBaseActn(tree);
 
@@ -190,7 +266,7 @@ $(document).ready(function () {
         } else {
             updateData = controller.tree.getInsertData();
         }
-        if (updateData.updateData.length > 0) {
+        if (updateData.length > 0) {
             CommonAjax.post(updateUrl, updateData, function (data) {
                 controller.insert();
                 controller.showTreeData();

+ 1 - 0
web/users/views/compilation/template.html

@@ -52,6 +52,7 @@
 </div>
 <script>
     let billsTemplateData = '<%- billsTemplateData %>';
+    let billsFixedFlagList = '<%- billsFixedFlagList %>';
     let updateUrl = '/compilation/template/<%= section %>/<%= valuationId %>/update';
 </script>
 <script type="text/javascript" src="/public/web/id_tree.js"></script>