فهرست منبع

Merge branch 'master' of http://smartcost.f3322.net:3000/SmartCost/ConstructionOperation

TonyKang 7 سال پیش
والد
کامیت
267c4d7ec6
30فایلهای تغییر یافته به همراه724 افزوده شده و 297 حذف شده
  1. 1 1
      Dockerfile
  2. 1 1
      Dockerfile_qa
  3. 6 10
      config/db/db_manager.js
  4. 22 0
      logs/log4js.json
  5. 80 0
      logs/log_helper.js
  6. 34 0
      modules/common/std/schemas/std_labour_coes.js
  7. 50 0
      modules/common/std/std_labour_coes_model.js
  8. 16 4
      modules/users/controllers/compilation_controller.js
  9. 0 1
      modules/users/models/compilation_model.js
  10. 52 3
      modules/users/models/engineering_lib_model.js
  11. 5 0
      modules/users/models/schemas/engineering_lib.js
  12. 2 1
      operation.js
  13. 3 1
      package.json
  14. 1 1
      public/web/sheet/sheet_common.js
  15. 14 13
      web/maintain/bills_lib/html/neirong.html
  16. 25 50
      web/maintain/bills_lib/html/qingdan.html
  17. 16 12
      web/maintain/bills_lib/html/tezheng.html
  18. 3 3
      web/maintain/bills_lib/scripts/bills_lib_setting.js
  19. 97 80
      web/maintain/bills_lib/scripts/db_controller.js
  20. 1 1
      web/maintain/bills_lib/scripts/set_sheets.js
  21. 1 0
      web/maintain/ration_repository/dinge.html
  22. 1 1
      web/maintain/ration_repository/js/main.js
  23. 52 12
      web/maintain/ration_repository/js/ration.js
  24. 49 0
      web/maintain/ration_repository/js/rationUnits.js
  25. 41 22
      web/maintain/ration_repository/js/ration_glj.js
  26. 4 2
      web/maintain/std_glj_lib/js/glj.js
  27. 31 3
      web/users/js/compilation.js
  28. 12 3
      web/users/views/compilation/add.html
  29. 93 71
      web/users/views/compilation/engineering.html
  30. 11 1
      web/users/views/compilation/modal.html

+ 1 - 1
Dockerfile

@@ -1,4 +1,4 @@
-FROM server:2.0
+FROM server:3.0
 
 COPY . ConstructionOperation
 

+ 1 - 1
Dockerfile_qa

@@ -1,4 +1,4 @@
-FROM server:2.0
+FROM server:3.0
 
 COPY . ConstructionOperation
 

+ 6 - 10
config/db/db_manager.js

@@ -49,17 +49,13 @@ module.exports = {
     connect:function () {
         var config = require("../config.js");
         var dbURL = 'mongodb://' + config.current.server + ":" + config.current.port + '/scConstruct';
-
-        var db = mg.connect(dbURL, config.options, function(err) {
-            if (err) {
-                console.log('Could not connect to MongoDB!');
-                console.log(err);
-            }
-        });
-        mg.connection.on('error', function(err) {
-            console.log('MongoDB connection error:', err);
+        mg.connect(dbURL, config.options);
+        var db = mg.connection;
+        db.on("error",function (err) {
+            console.log('Could not connect to MongoDB!');
+            console.log(err);
             process.exit(-1);
-        });
+        })
         return mg;
     }
 };

+ 22 - 0
logs/log4js.json

@@ -0,0 +1,22 @@
+{
+  "customBaseDir" :"../logs/ConstructionOperation/",
+  "customDefaultAtt" :{
+    "type": "dateFile",
+    "alwaysIncludePattern": false,
+    "pattern":".yyyy-MM-dd hhhr"
+  },
+  "appenders": {
+    "console": { "type": "console" },
+    "logInfo":{"filename":"info.log"},
+    "logDebug":{"filename":"debug.log"},
+    "logWarn":{"filename":"warn.log"},
+    "logErr":{"filename":"err.log"}
+  },
+  "categories": {
+    "default": { "appenders": ["console"], "level": "debug"},
+    "logInfo":{ "appenders": ["logInfo","console"], "level": "debug"},
+    "logDebug":{ "appenders": ["logDebug","console"], "level": "debug"},
+    "logWarn":{ "appenders": ["logWarn"], "level": "debug"},
+    "logErr":{ "appenders": ["logErr"], "level": "debug"}
+  }
+}

+ 80 - 0
logs/log_helper.js

@@ -0,0 +1,80 @@
+/**
+ * Created by chen on 2017/9/4.
+ */
+let helper = {};
+module.exports.logger = helper;
+
+let log4js = require('log4js');
+let fs = require("fs");
+let path = require("path");
+
+// 加载配置文件
+let objConfig = JSON.parse(fs.readFileSync(__dirname+"/log4js.json", "utf8"));
+
+// 加载基础配置
+if(objConfig.appenders){
+    let baseDir = objConfig["customBaseDir"];
+    let defaultAtt = objConfig["customDefaultAtt"];
+    for(let key in objConfig.appenders){
+        var item = objConfig.appenders[key];
+        if(item["type"] == "console")
+            continue;
+        if(defaultAtt != null){
+            for(let att in defaultAtt){
+                if(item[att] == null)
+                    item[att] = defaultAtt[att];
+            }
+        }
+        if(baseDir != null){
+            if(item["filename"] == null)
+                item["filename"] = baseDir;
+            else
+                item["filename"] = baseDir + item["filename"];
+        }
+    }
+}
+
+
+log4js.configure(objConfig);
+
+let logDebug = log4js.getLogger('logDebug');
+let logInfo = log4js.getLogger('logInfo');
+let logWarn = log4js.getLogger('logWarn');
+let logErr = log4js.getLogger('logErr');
+
+console.log = logInfo.info.bind(logInfo);//把控制台信息输出到文件中
+
+helper.debug = function(msg){
+    if(msg == null)
+        msg = "";
+    logDebug.debug(msg);
+};
+
+helper.info = function(msg){
+    if(msg == null)
+        msg = "";
+    logInfo.info(msg);
+};
+
+helper.warn = function(msg){
+    if(msg == null)
+        msg = "";
+    logWarn.warn(msg);
+};
+
+helper.err = function(msg, exp){
+    if(msg == null)
+        msg = "";
+    if(exp != null)
+        msg += "\r\n" + exp;
+    logErr.error(msg);
+};
+
+// 配合express用的方法
+module.exports.use = function(app) {
+    //页面请求日志, level用auto时,默认级别是WARN
+    app.use(log4js.connectLogger(logDebug, {level:'debug', format:':method :url'}));
+}
+
+
+

+ 34 - 0
modules/common/std/schemas/std_labour_coes.js

@@ -0,0 +1,34 @@
+/**
+ * 人工系数数据模型
+ *
+ * @author CaiAoLin
+ * @date 2017/9/11
+ * @version
+ */
+import mongoose from "mongoose";
+
+let Schema = mongoose.Schema;
+let collectionName = 'std_labour_coes';
+let coesSchema = new Schema({
+    // 自增id
+    ID: Number,
+    // 父级id
+    ParentID: Number,
+    // 名称
+    name: String,
+    // 系数
+    coe: Number
+});
+let modelSchema = {
+    // 自增id
+    ID: Number,
+    // 所在地
+    region: String,
+    // 标准名称
+    libName: String,
+    // 人工系数数据
+    coes: [coesSchema]
+};
+
+let model = mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));
+export {model as default, collectionName as collectionName};

+ 50 - 0
modules/common/std/std_labour_coes_model.js

@@ -0,0 +1,50 @@
+/**
+ * 人工系数业务模型
+ *
+ * @author CaiAoLin
+ * @date 2017/9/11
+ * @version
+ */
+import BaseModel from "../base/base_model";
+import STDLabourCoesSchema from "./schemas/std_labour_coes";
+
+class STDLabourCoesModel extends BaseModel {
+
+    /**
+     * 构造函数
+     *
+     * @return {void}
+     */
+    constructor() {
+        let parent = super();
+        parent.model = STDLabourCoesSchema;
+        parent.init();
+    }
+
+    /**
+     * 获取人工系数列表
+     *
+     * @return {Promise}
+     */
+    async getLabourCoesList() {
+        let result = [];
+        let field = {ID: 1, libName: 1};
+        let feeRateList = await this.findDataByCondition({ID: {$ne: ''}}, field, false);
+
+        if (feeRateList === null) {
+            return result;
+        }
+        // 整理数据
+        for(let feeRate of feeRateList) {
+            let tmpData = {
+                id: feeRate.ID,
+                name: feeRate.libName
+            };
+            result.push(tmpData);
+        }
+        return result;
+    }
+
+}
+
+export default STDLabourCoesModel;

+ 16 - 4
modules/users/controllers/compilation_controller.js

@@ -15,6 +15,7 @@ import {default as EngineeringConst, List as EngineeringList} from "../../common
 import BillsTemplateModel from "../models/bills_template_model";
 import {default as BillsFixedFlagConst, List as BillsFixedFlagList} from "../../common/const/bills_fixed.js";
 import EngineeringLibModel from "../models/engineering_lib_model";
+import STDLabourCoesModel from "../../common/std/std_labour_coes_model";
 
 class CompilationController extends BaseController {
 
@@ -117,6 +118,7 @@ class CompilationController extends BaseController {
         let compilationList = [];
         let valuationData = {};
         let valuationList = {};
+        let libCount = {};
         try {
             let compilationModel = new CompilationModel();
             compilationList = await compilationModel.getCompilationList();
@@ -127,6 +129,9 @@ class CompilationController extends BaseController {
                 throw '不存在数据';
             }
 
+            // 获取计价规则中对应的标准库数据
+            let engineeringLibModel = new EngineeringLibModel();
+            libCount = await engineeringLibModel.getLibCount(valuationData);
         } catch (error) {
             console.log(error);
         }
@@ -138,6 +143,7 @@ class CompilationController extends BaseController {
             valuationData: valuationData,
             valuationList: valuationList,
             valuationId: valuationId,
+            libCount: libCount,
             section: section,
             layout: 'users/views/layout/layout'
         };
@@ -178,6 +184,7 @@ class CompilationController extends BaseController {
         let billsTemplateData = [];
         let valuationData = {};
         let valuationList = {};
+        let artificialCoefficientList = [];
         try {
             let compilationModel = new CompilationModel();
             compilationList = await compilationModel.getCompilationList();
@@ -194,10 +201,14 @@ class CompilationController extends BaseController {
             let stdGLJLibMapModel = new STDGLJLibMapModel();
             gljList = await stdGLJLibMapModel.getGLJLibList(selectedCompilation._id);
 
-            // 获取费率库
+            // 获取费率标准
             let stdFeeRateLibsModel = new STDFeeRateLibsModel();
             feeRateList = await stdFeeRateLibsModel.getFeeRateList();
 
+            // 获取人工系数标准库
+            let stdLabourCoesModel = new STDLabourCoesModel();
+            artificialCoefficientList = await stdLabourCoesModel.getLabourCoesList();
+
             // 获取对应的计价规则数据
             [valuationData, valuationList] = await compilationModel.getValuation(selectedCompilation._id, valuationId, section);
             if (Object.keys(valuationData).length <= 0) {
@@ -210,7 +221,7 @@ class CompilationController extends BaseController {
 
             // 获取清单模板数据
             let billsTemplateModel = new BillsTemplateModel();
-            billsTemplateData = await billsTemplateModel.getTemplateData(valuationId);
+            billsTemplateData = await billsTemplateModel.getTemplateData(valuationId, engineering);
 
         } catch (error) {
             console.log(error);
@@ -226,9 +237,10 @@ class CompilationController extends BaseController {
             billList: JSON.stringify(billList),
             rationList: JSON.stringify(rationList),
             gljList: JSON.stringify(gljList),
+            artificialCoefficientList: JSON.stringify(artificialCoefficientList),
             feeRateList: JSON.stringify(feeRateList),
             billsTemplateData: JSON.stringify(billsTemplateData),
-            mainTreeCol: JSON.stringify(valuationData.main_tree_col),
+            mainTreeCol: JSON.stringify(libData.main_tree_col),
             layout: 'users/views/layout/layout'
         };
         response.render('users/views/compilation/engineering', renderData);
@@ -453,7 +465,7 @@ class CompilationController extends BaseController {
 
             // 获取清单模板数据
             let billsTemplateModel = new BillsTemplateModel();
-            billsTemplateData = await billsTemplateModel.getTemplateData(valuationId);
+            billsTemplateData = await billsTemplateModel.getTemplateData(valuationId, engineering);
         } catch (error) {
             console.log(error);
         }

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

@@ -183,7 +183,6 @@ class CompilationModel extends BaseModel {
      */
     async getValuation(compilationId, id, section) {
         if (this.sectionList.indexOf(section) < 0) {
-            console.log('4');
             throw '数据有误';
         }
         let compilationData = await this.findDataByCondition({_id: compilationId});

+ 52 - 3
modules/users/models/engineering_lib_model.js

@@ -135,9 +135,12 @@ class EngineeringLibModel extends BaseModel {
         // 判断工料机库
         data.glj_lib = this._validLib(data.glj_lib);
 
-        // 判断费率
+        // 判断费率标准
         data.fee_lib = this._validLib(data.fee_lib);
 
+        // 判断人工系数
+        data.artificial_lib = this._validLib(data.artificial_lib);
+
         return data;
     }
 
@@ -149,9 +152,9 @@ class EngineeringLibModel extends BaseModel {
      */
     _validLib(libData) {
         let result = [];
-        // 判断费率
+        // 判断标准
         if (libData === undefined || libData === '') {
-            throw '判断费率库不能为空';
+            throw '标准库不能为空';
         }
         libData = libData instanceof Array ? libData : [libData];
         for(let tmp in libData) {
@@ -160,6 +163,52 @@ class EngineeringLibModel extends BaseModel {
         return result;
     }
 
+    /**
+     * 获取对应标准库数量
+     *
+     * @param {Object} valuationData
+     * @return {Object}
+     */
+    async getLibCount(valuationData) {
+        let result = {};
+        if (valuationData.engineering_list === undefined || valuationData.engineering_list.length <= 0) {
+            return result;
+        }
+
+        // 整理需要查找的数据
+        let findIdList = [];
+        for(let engineering of valuationData.engineering_list) {
+            findIdList.push(engineering.engineering_id);
+        }
+
+        let condition = {_id: {$in: findIdList}};
+        let libData = await this.findDataByCondition(condition, null, false);
+        if (libData === null) {
+            return result;
+        }
+
+        // 整理数据
+        let countData = {};
+        for(let tmp of libData) {
+            countData[tmp._id] = {
+                bill_count: tmp.bill_lib.length,
+                ration_count: tmp.ration_lib.length,
+                glj_count: tmp.glj_lib.length,
+                fee_count: tmp.fee_lib.length,
+                artificial_count: tmp.artificial_lib.length,
+            };
+        }
+
+
+        for(let engineering of valuationData.engineering_list) {
+            if (countData[engineering.engineering_id] !== undefined) {
+                result[engineering.engineering] = countData[engineering.engineering_id];
+            }
+        }
+
+        return result;
+    }
+
 }
 
 export default EngineeringLibModel;

+ 5 - 0
modules/users/models/schemas/engineering_lib.js

@@ -40,6 +40,11 @@ let modelSchema = {
     fee_lib: {
         type: Schema.Types.Mixed,
         default: []
+    },
+    // 人工系数标准库
+    artificial_lib: {
+        type: Schema.Types.Mixed,
+        default: []
     }
 };
 let model = mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));

+ 2 - 1
operation.js

@@ -9,6 +9,7 @@ let session = require('express-session');
 let DBStore = require('connect-mongo')(session);
 let fileUtils = require("./modules/common/fileUtils");
 let partials = require("express-partials");
+let log = require("./logs/log_helper");
 
 let URL = require('url');
 let fs = require('fs');
@@ -28,7 +29,7 @@ fileUtils.getGlobbedFiles('./modules/reports/models/*.js').forEach(function(mode
 let cfgCacheUtil = require("./config/cacheCfg");
 cfgCacheUtil.setupDftCache();
 
-
+log.use(app);
 app.use(express.static(_rootDir));
 
 app.set('views', path.join(__dirname, 'web'));

+ 3 - 1
package.json

@@ -21,8 +21,10 @@
     "glob": "~4.0.5"
   },
   "dependencies": {
+    "babel-core": "^6.26.0",
     "bluebird": "^3.5.0",
     "jszip": "^3.1.3",
-    "pdfkit": "^0.8.2"
+    "pdfkit": "^0.8.2",
+    "log4js":"~2.3.3"
   }
 }

+ 1 - 1
public/web/sheet/sheet_common.js

@@ -136,7 +136,7 @@ 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'){
+                    if(typeof setting.owner !== 'undefined' && setting.owner !== 'gljComponent'){
                         sheet.getCell(row, 0, GC.Spread.Sheets.SheetArea.viewport).locked(true);
                     }
                 }

+ 14 - 13
web/maintain/bills_lib/html/neirong.html

@@ -41,14 +41,14 @@
       <div class="content">
         <div class="container-fluid">
           <div class="row">
-            <div class="main-content col-lg-7 p-0">
+            <div class="main-content col-lg-12 p-0">
                 <nav class="tools-bar">
                 </nav>
                 <div class="main-data" id="spreadAllJobs">
                 </div>
             </div>
-            <div class="main-side col-lg-5 p-0">
-            </div>
+          <!--  <div class="main-side col-lg-5 p-0">
+            </div>-->
           </div>
         </div>
       </div>
@@ -261,8 +261,9 @@
         }
 
         function pasteJobs(sheet, totalJobs){
-            sheetJobsDatas = tools.getsheetDatas(sheet, 'total');
+           // sheetJobsDatas = tools.getsheetDatas(sheet, 'total');
             sheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, function (sender, args) {
+                sheetJobsDatas = tools.getsheetDatas(sheet, 'total');
                 let maxCol = args.cellRange.col + args.cellRange.colCount - 1;
                 //复制的列数超过正确的列数,不可复制
                 if(maxCol >= totalJobsSetting.cols.length){
@@ -290,27 +291,27 @@
                         }
                     }
                 }
-                //let pasteDatas = tools.uniqObjArr(pasteDatas);
-            //    tools.resetRowIdx(pasteDatas, orgRow);
-                for(let i=0; i< pasteDatas.length; i++){
+                let uniqPasteDatas = tools.uniqObjArr(pasteDatas);
+                tools.resetRowIdx(uniqPasteDatas, orgRow);
+                for(let i=0; i< uniqPasteDatas.length; i++){
                     let crossedData;
                     let flag = true;
                     sheetJobsDatas.forEach(function(orgData){
-                        if(pasteDatas[i].rowIdx === orgData.rowIdx && pasteDatas[i].colIdx === orgData.colIdx){
+                        if(uniqPasteDatas[i].rowIdx === orgData.rowIdx && uniqPasteDatas[i].colIdx === orgData.colIdx){
                             flag = false;
                             crossedData = {
                                 billsLibId: billsLibId,
-                                rowIdx: pasteDatas[i].rowIdx,
-                                colIdx: pasteDatas[i].colIdx,
-                                field: pasteDatas[i].field,
+                                rowIdx: uniqPasteDatas[i].rowIdx,
+                                colIdx: uniqPasteDatas[i].colIdx,
+                                field: uniqPasteDatas[i].field,
                                 orgId: orgData.id,
-                                data: pasteDatas[i].data,
+                                data: uniqPasteDatas[i].data,
                                 type: 'Update'
                             }
                         }
                     });
                     if(flag){
-                        uncrossedDatas.push(pasteDatas[i]);
+                        uncrossedDatas.push(uniqPasteDatas[i]);
                     }
                     else{
                         crossedDatas.push(crossedData);

+ 25 - 50
web/maintain/bills_lib/html/qingdan.html

@@ -68,14 +68,26 @@
             </div>
             <div class="main-side col-lg-5 p-0">
               <div class="container-fluid">
-                <div class="row">
-                  <div class="col" style="width:50%; height: 100%">
+                  <div  style="width:50%; height: 100%; float: left;">
+                      <h5>工作内容</h5>
+                      <div id="spreadJobs" class="ovf-hidden" style="width:97%; height: 300px;"></div>
+                  </div>
+                  <div  style="width:50%; height: 100%; float: left;">
+                      <h5>项目特征</h5>
+                      <div id="spreadItems" class="ovf-hidden" style="width: 97%; height: 300px;"></div>
+                  </div>
+                  <div class="form-group">
+                      <label for="exampleTextarea"><h5>补注:</h5></label>
+                      <textarea class="form-control" id="exampleTextarea" rows="8"></textarea>
+                  </div>
+               <!-- <div class="row">
+                  <div class="col ovf-hidden" style="width:50%; height: 100%; float: left;">
                       <h5>工作内容</h5>
                       <div id="spreadJobs"  style="width:97%; height: 300px;"></div>
                   </div>
-                  <div class="col" style="width:50%; height: 100%">
+                  <div class="col" style="width:50%; height: 100%; float: left;">
                     <h5>项目特征</h5>
-                      <div id="spreadItems" style="width: 97%; height: 300px;"></div>
+                      <div id="spreadItems" class="ovf-hidden" style="width: 97%; height: 300px;"></div>
                   </div>
                   <div class="w-100"></div>
                   <div class="col">
@@ -84,7 +96,7 @@
                       <textarea class="form-control" id="exampleTextarea" rows="8"></textarea>
                     </div>
                   </div>
-                </div>
+                </div>-->
               </div>
             </div>
           </div>
@@ -374,11 +386,7 @@
         let btnDownMove = $('#downMove');
         let btnUpLevel = $('#upLevel');
         let btnDownLevel = $('#downLevel');
-       // billsSheet.clearSelection();
-       // billsSheet.options.isProtected = true;
-       // controller.setTreeSelected(null);
         billsSheet.bind(GC.Spread.Sheets.Events.CellClick, function (sender, args) {
-           // if(billsSheet.options.isProtected){
                 jobsSheet.clearSelection();
                 itemsSheet.clearSelection();
                 billsSpread.focus(true);
@@ -392,21 +400,8 @@
                 btnDownLevel.attr('fcsOnBills', 'true');
                 btnUpMove.attr('fcsOnBills', 'true');
                 btnDownMove.attr('fcsOnBills', 'true');
-          //  }
-               // jobsSheet.clearSelection();
-               // itemsSheet.clearSelection();
-                //billsSheet.options.isProtected = false;
-               /* jobsSheet.options.isProtected = true;
-                itemsSheet.options.isProtected = true;
-                let activeRow = billsSheet.getActiveRowIndex();
-                let activeCol = billsSheet.getActiveColumnIndex();
-                billsSheet.setActiveCell(activeRow === 0 ? 1: 0, 0);
-                billsSheet.setActiveCell(activeRow, activeCol);*/
-               // controller.setTreeSelected(controller.tree.findNode(billsSheet.getTag(activeRow, activeCol)));
-          //  }
         });
         jobsSheet.bind(GC.Spread.Sheets.Events.CellClick, function (sender, args) {
-           // if(jobsSheet.options.isProtected){
                 itemsSheet.clearSelection();
                 jobsSpread.focus(true);
                 itemsSheet.options.isProtected = true;
@@ -427,18 +422,14 @@
                 let selected;
                 if(controller.tree.selected){
                     selected = controller.tree.selected.jobs[args.row];
-                    console.log(`selected`);
-                    console.log(selected);
                 }
                 if(tools.canUpMove(selected, controller.tree.selected.jobs)){
                     tools.btnAction(btnUpMove);
                     btnUpMove.attr('canMove', 'true');
-                    console.log(`canup`);
                 }
                 else{
                     tools.btnClose(btnUpMove);
                     btnUpMove.attr('canMove', 'false');
-                    console.log(`nocan`);
                 }
                 if(tools.canDownMove(selected, controller.tree.selected.jobs)){
                     tools.btnAction(btnDownMove);
@@ -448,19 +439,13 @@
                     tools.btnClose(btnDownMove);
                     btnDownMove.attr('canMove', 'false');
                 }
-            //}
         });
         itemsSheet.bind(GC.Spread.Sheets.Events.CellClick, function (sender, args) {
-           // if(itemsSheet.options.isProtected){
                 jobsSheet.clearSelection();
                 itemsSpread.focus(true);
                 jobsSheet.options.isProtected = true;
                 billsSheet.options.isProtected = true;
                 itemsSheet.options.isProtected = false;
-                /*let activeRow = itemsSheet.getActiveRowIndex();
-                let activeCol = itemsSheet.getActiveColumnIndex();
-                itemsSheet.setActiveCell(activeRow === 0 ? 1: 0, 0);
-                itemsSheet.setActiveCell(activeRow, activeCol);*/
 
                 controller.tree.selected.args = args;
                 controller.tree.selected.field = 'item';
@@ -494,7 +479,6 @@
                     tools.btnClose(btnDownMove);
                     btnDownMove.attr('canMove', 'false');
                 }
-            //}
         });
     };
 
@@ -516,14 +500,8 @@
             let showButton = function (show, btn) {
                 tools.btnAction($('#insert'), 'focusOnBills');
                 if (show) {
-                    //btn.show();
                     tools.btnAction(btn, 'doing');
-                    /*btn.css("opacity", "");
-                    btn.removeClass("disabled");*/
                 } else {
-                    //btn.hide();
-                    /*btn.css("opacity", "0.2");
-                    btn.addClass("disabled");*/
                     tools.btnClose(btn, 'doing');
                 }
             };
@@ -597,6 +575,9 @@
             if(arr.length > 0){
                 tools.orderReshowData(sheet, arr, setting, prefix,true);
             }
+            else{
+                setSheet.setMaxRowCount(sheet, []);
+            }
             if(recharge){
                 $('#exampleTextarea').val(recharge);
             }
@@ -616,7 +597,7 @@
                         tools.orderReshowData(sheet, jobs, setting, 'job', true);
                         orgJobData = sheet.getValue(0, 0);
                     }
-                    sheetDatas = tools.getsheetDatas(sheet, 'jobs');
+                    //sheetDatas = tools.getsheetDatas(sheet, 'jobs');
                 }
                 if(field === 'items'){
                     tools.clearData(sheet);
@@ -626,15 +607,15 @@
                         tools.orderReshowData(sheet, items, setting, 'item', true);
                         orgItemData = sheet.getValue(0, 0);
                     }
-                    sheetItemsDatas = tools.getsheetDatas(sheet, 'items');
+                    //sheetItemsDatas = tools.getsheetDatas(sheet, 'items');
                 }
             }
         });
     }
 
     function bindPasteBills(controller, sheet, setting){
-        sheetBillsDatas = tools.getsheetDatas(sheet, 'bills', controller);
         sheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, function (sender, args) {
+            sheetBillsDatas = tools.getsheetDatas(sheet, 'bills', controller);
             let maxCol = args.cellRange.col + args.cellRange.colCount - 1;
             //复制的列数超过正确的列数,不可复制
             if(maxCol >= billsLibSetting.cols.length){
@@ -682,7 +663,7 @@
         });
     }
     function bindPasteRel(sheet, controller, totalJobs, setting){
-        sheetDatas = tools.getsheetDatas(sheet, 'jobs');
+        //sheetDatas = tools.getsheetDatas(sheet, 'jobs');
         sheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, function (sender, args) {
             let maxCol = args.cellRange.col + args.cellRange.colCount - 1;
             sheetDatas = tools.getsheetDatas(sheet, 'jobs');
@@ -692,8 +673,6 @@
             }
         });
         sheet.bind(GC.Spread.Sheets.Events.ClipboardPasted, function(sender, args){
-          //  sheet.setColumnCount(2, GC.Spread.Sheets.SheetArea.viewport);
-           // sheet.setColumnCount(2, GC.Spread.Sheets.SheetArea.colHeader);
             if(controller.tree.selected){
                 let orgRow = args.cellRange.row, orgCol = args.cellRange.col, rowCount = args.cellRange.rowCount, colCount = args.cellRange.colCount;
                 let maxRow = orgRow + rowCount - 1, maxCol = orgCol + colCount -1;
@@ -746,7 +725,7 @@
         });
     }
     function bindPasteItemsRel(sheet, controller, totalItems, setting){
-        sheetItemsDatas = tools.getsheetDatas(sheet, 'items');
+        //sheetItemsDatas = tools.getsheetDatas(sheet, 'items');
         sheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, function (sender, args) {
             let maxCol = args.cellRange.col + args.cellRange.colCount - 1;
             sheetItemsDatas = tools.getsheetDatas(sheet, 'items');
@@ -756,8 +735,6 @@
             }
         });
         sheet.bind(GC.Spread.Sheets.Events.ClipboardPasted, function(sender, args){
-            //sheet.setColumnCount(2, GC.Spread.Sheets.SheetArea.viewport);
-           // sheet.setColumnCount(2, GC.Spread.Sheets.SheetArea.colHeader);
             if(controller.tree.selected){
                 let orgRow = args.cellRange.row, orgCol = args.cellRange.col, rowCount = args.cellRange.rowCount, colCount = args.cellRange.colCount;
                 let maxRow = orgRow + rowCount - 1, maxCol = orgCol + colCount -1;
@@ -787,7 +764,6 @@
                         }
                     });
                     if(flag){
-                        //let serialNo = tools.getSerialNo(controller.tree.selected.items);
                         serialNoUn ++;
                         console.log(serialNoUn);
                         uncrossedDatas.push({data: uniqPasteArr[j], serialNo: serialNoUn});
@@ -815,7 +791,6 @@
 
     function buildJobs(jobsSpread, setting){
         setSheet.initSheet(jobsSpread, setting, true);
-       // setSheet.setMaxRowCount(jobsSpread.getActiveSheet(), 10);
         jobsSpread.getActiveSheet().clearSelection();
         myKey.downKey(jobsSpread);
         myKey.enterKey(jobsSpread);

+ 16 - 12
web/maintain/bills_lib/html/tezheng.html

@@ -47,7 +47,7 @@
             </div>
             </div>
             <div class="main-side col-lg-5 p-0">
-              <div class="main-data" id="spreadEigenvalue" style="width: 95%">
+              <div class="main-data" id="spreadEigenvalue" >
               </div>
             </div>
           </div>
@@ -307,11 +307,15 @@
                     tools.reshowValue(sheet, valueArr, setting, true);
                 }
             }
+            else{
+                    setSheet.setMaxRowCount(sheet, []);
+            }
         }
 
         function pasteItems(sheet, totalItems){
-            totalItemsDatas = tools.getsheetDatas(sheet, 'total');
+            //totalItemsDatas = tools.getsheetDatas(sheet, 'total');
             sheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, function (sender, args) {
+                totalItemsDatas = tools.getsheetDatas(sheet, 'total');
                 let maxCol = args.cellRange.col + args.cellRange.colCount - 1;
                 //复制的列数超过正确的列数,不可复制
                 if(maxCol >= totalItemsSetting.cols.length){
@@ -339,27 +343,27 @@
                         }
                     }
                 }
-                //let pasteDatas = tools.uniqObjArr(pasteDatas);
-                //tools.resetRowIdx(pasteDatas, orgRow);
-                for(let i=0; i< pasteDatas.length; i++){
+                let uniqPasteDatas = tools.uniqObjArr(pasteDatas);
+                tools.resetRowIdx(uniqPasteDatas, orgRow);
+                for(let i=0; i< uniqPasteDatas.length; i++){
                     let crossedData;
                     let flag = true;
                     totalItemsDatas.forEach(function(orgData){
-                        if(pasteDatas[i].rowIdx === orgData.rowIdx && pasteDatas[i].colIdx === orgData.colIdx){
+                        if(uniqPasteDatas[i].rowIdx === orgData.rowIdx && uniqPasteDatas[i].colIdx === orgData.colIdx){
                             flag = false;
                             crossedData = {
                                 billsLibId: billsLibId,
-                                rowIdx: pasteDatas[i].rowIdx,
-                                colIdx: pasteDatas[i].colIdx,
-                                field: pasteDatas[i].field,
+                                rowIdx: uniqPasteDatas[i].rowIdx,
+                                colIdx: uniqPasteDatas[i].colIdx,
+                                field: uniqPasteDatas[i].field,
                                 orgId: orgData.id,
-                                data: pasteDatas[i].data,
+                                data: uniqPasteDatas[i].data,
                                 type: 'Update'
                             }
                         }
                     });
                     if(flag){
-                        uncrossedDatas.push(pasteDatas[i]);
+                        uncrossedDatas.push(uniqPasteDatas[i]);
                     }
                     else{
                         crossedDatas.push(crossedData);
@@ -379,6 +383,7 @@
 
         function pasteValue(sheet, totalItems){
             sheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, function (sender, args) {
+                valueDatas = tools.getsheetDatas(sheet, 'total');
                 let maxCol = args.cellRange.col + args.cellRange.colCount - 1;
                 //复制的列数超过正确的列数,不可复制
                 if(maxCol >= eigenValueSetting.cols.length){
@@ -387,7 +392,6 @@
             });
 
             sheet.bind(GC.Spread.Sheets.Events.ClipboardPasted, function(sender, args){
-                valueDatas = tools.getsheetDatas(sheet, 'total');
                 const colIdx = 1;
                 let orgRow = args.cellRange.row, orgCol = args.cellRange.col, rowCount = args.cellRange.rowCount, colCount = args.cellRange.colCount;
                 let maxRow = orgRow + rowCount - 1, maxCol = orgCol + colCount -1;

+ 3 - 3
web/maintain/bills_lib/scripts/bills_lib_setting.js

@@ -112,7 +112,7 @@ var jobsSetting = {
                 hAlign: 0,
                 font: 'Arial'
             },
-            width: 210
+            width: 200
         },
     ],
     headRows: 1,
@@ -155,7 +155,7 @@ var itemsSetting = {
                 hAlign: 0,
                 font: 'Arial'
             },
-            width: 210
+            width: 200
         },
     ],
     headRows: 1,
@@ -241,7 +241,7 @@ var totalItemsSetting = {
                 hAlign: 0,
                 font: 'Arial'
             },
-            width: 850
+            width: 800
         },
     ],
     headRows: 1,

+ 97 - 80
web/maintain/bills_lib/scripts/db_controller.js

@@ -151,7 +151,6 @@ var dbController = {
     delete: function(controller, btn, totalJobs, totalItems){
         tools.btnClose(btn);
         btn.attr('doing', 'true');
-        console.log(`beforeNodeId :${controller.tree.selected.getID()}`);
         var node = controller.tree.selected;
         if(node){
             var deleteIds = [];
@@ -372,7 +371,7 @@ var createObj = {
 
         TotalItems.prototype.findItem = function(id){
             return this.items[this.prefix + id] ? this.items[this.prefix + id] : null;
-        }
+        };
 
         TotalItems.prototype.loadItems = function (nodes, datas){
             var me = this;
@@ -419,6 +418,8 @@ var tools = {
         sheet.options.isProtected = true;
         let dataCode = args.col === 0 ? 'code' : 'content';
         let orgCode =  args.row < arr.length ? arr[args.row][field].data[dataCode] : '';
+        $('#alertCof').unbind('click');
+        $('#alertCls').unbind('click');
         $('#alertCls').click(function () {
             sheet.options.isProtected = false;
             sheet.getCell(args.row, args.col).value(orgCode);
@@ -434,6 +435,8 @@ var tools = {
         args.sheet.options.isProtected = true;
         let dataCode =  args.col === 0 ? 'code' : 'content';
         let orgCode =  args.row < arr.length ? arr[args.row].data[dataCode] : '';
+        $('#alertCof').unbind('click');
+        $('#alertCls').unbind('click');
         $('#alertCls').click(function () {
             args.sheet.options.isProtected = false;
             args.sheet.getCell(args.row, args.col).value(orgCode);
@@ -460,7 +463,7 @@ var tools = {
         btn.removeClass("disabled");
         //btn.attr(attr, 'false');
     },
-    isExist: function (totalArr, field, newData, orgData){
+    /*isExist: function (totalArr, field, newData, orgData){
         var isExist = false;
         if(totalArr.length > 0){
             totalArr.forEach(function(item){
@@ -470,10 +473,20 @@ var tools = {
             });
         }
         return isExist;
+    },*/
+    isExist: function (totalArr, field, newData){
+        var isExist = false;
+        if(totalArr.length > 0){
+            totalArr.forEach(function(item){
+                if(item.data[field] == newData){
+                    isExist = true;
+                }
+            });
+        }
+        return isExist;
     },
     isRepeat: function(arr, field, newData, ref, classify){
         var isRepeat = false;
-        if(field === 'code'){
             if(classify){
                 if(arr){
                     arr.forEach(function(item){
@@ -498,7 +511,6 @@ var tools = {
                     });
                 }
             }
-        }
         return isRepeat;
     },
 
@@ -1221,8 +1233,6 @@ var tools = {
                 rebuildArr.sort(myCompareCode);
                 if(rebuildArr[0].code){
                     maxItemsNumber = maxItemsNumber + 1 > rebuildArr[0].code ? maxItemsNumber  : rebuildArr[0].code;
-                    console.log(`maxJobs`);
-                    console.log(maxItemsNumber);
                 }
                 rebuildArr.forEach(function(data){
                     if(data.type !== 'CreateT' && data.field === 'content' ){
@@ -1535,7 +1545,6 @@ let pasteController = {
             }
         }
         setSheet.setMaxRowCount(sheet, totalJobs.jobsArr);
-        console.log(totalJobs);
         tools.reshowData(sheet, totalJobs.jobsArr, totalJobsSetting, true);
         sheetJobsDatas = tools.getsheetDatas(sheet, 'total');
     },
@@ -1553,19 +1562,19 @@ let pasteController = {
                         });
                     }
                    else if(datas[i].type === CreateT){
-                        newItemData = {id: datas[i].newItemId, content: datas[i].content, code: datas[i].code};
+                        newItemData = {id: datas[i].newItemId, content: datas[i].content, code: datas[i].code, itemValue: []};
                         newItem = createObj.newItem(newItemData);
                         totalItems.itemsArr.push(newItem);
                         totalItems.items[totalItems.prefix + datas[i].newItemId] = newItem;
                     }
                    else if(datas[i].type !== CreateT && datas[i].field === 'content'){
-                        newItemData = {id: datas[i].newItemId, content: datas[i].data, code: datas[i].code};
+                        newItemData = {id: datas[i].newItemId, content: datas[i].data, code: datas[i].code, itemValue: []};
                         newItem = createObj.newItem(newItemData);
                         totalItems.itemsArr.push(newItem);
                         totalItems.items[totalItems.prefix + datas[i].newItemId] = newItem;
                     }
                    else if(datas[i].type !== 'CreateT' && datas[i].field === 'code'){
-                        newItemData = {id: datas[i].newItemId, content: '', code: datas[i].data};
+                        newItemData = {id: datas[i].newItemId, content: '', code: datas[i].data, itemValue: []};
                         newItem = createObj.newItem(newItemData);
                         totalItems.itemsArr.push(newItem);
                         totalItems.items[totalItems.prefix + datas[i].newItemId] = newItem;
@@ -1597,7 +1606,7 @@ let pasteController = {
                             valuesArr.splice(index, 0, updateEle);
                         }
                     }
-                   else if(datas[i].type !== 'UpdateT' && datas[i].field === 'code'){
+                   else if(datas[i].type === 'Update' && datas[i].field === 'code'){
                         if(valuesArr){
                             for(let j=0; j< valuesArr.length; j++){
                                 if(datas[i].orgId === valuesArr[j].code){
@@ -1606,7 +1615,7 @@ let pasteController = {
                             }
                         }
                     }
-                   else if(datas[i].type !== 'UpdateT' && datas[i].field === 'value'){
+                   else if(datas[i].type === 'Update' && datas[i].field === 'value'){
                         if(valuesArr){
                             for(let j=0; j< valuesArr.length; j++){
                                 if(datas[i].orgId === valuesArr[j].code){
@@ -1620,11 +1629,11 @@ let pasteController = {
                         valuesArr.push(newValueData);
 
                     }
-                   else if(datas[i].type !== 'CreateT' && datas[i].field === 'value'){
+                   else if(datas[i].type === 'Create' && datas[i].field === 'value'){
                         let newValueData = {value: datas[i].data, code: datas[i].code};
                         valuesArr.push(newValueData);
                     }
-                   else if(datas[i].type !== 'CreateT' && datas[i].field === 'code'){
+                   else if(datas[i].type === 'Create' && datas[i].field === 'code'){
                         let newValueData = {value: '', code: datas[i].data};
                         valuesArr.push(newValueData);
                     }
@@ -1637,9 +1646,11 @@ let pasteController = {
 };
 
 var jobsController = {
+    currentEditData: null,
     editData: function(controller, sheet, totalJobs, setting){
-        sheet.bind(GC.Spread.Sheets.Events.EnterCell, function(sender, args){
-            orgJobData = sheet.getCell(args.row, args.col).value();
+        let me = jobsController;
+        sheet.bind(GC.Spread.Sheets.Events.EditStarting, function (sender, args) {
+           me.currentEditData = sheet.getValue(args.row, args.col);
         });
         sheet.bind(GC.Spread.Sheets.Events.EditEnded, function(sender, args) {
             var field, newData = args.editingText, id = sheet.getTag(args.row, args.col);
@@ -1648,8 +1659,8 @@ var jobsController = {
                     field = col.data.field;
                 }
             });
-            if (controller.tree.selected) {
-                var isExist = tools.isExist(totalJobs.jobsArr, field, newData, orgJobData);
+            if (controller.tree.selected && newData !== me.currentEditData) {
+                var isExist = tools.isExist(totalJobs.jobsArr, field, newData);
                 var isRepeat = tools.isRepeat(controller.tree.selected.jobs, field ,newData, 'reference', 'job');
                 //create
                 if(!id && newData && !isRepeat){
@@ -1661,22 +1672,16 @@ var jobsController = {
                         }
                 }
                 //update
-                else if(id && newData !== orgJobData && !isRepeat){
+                else if(id && !isRepeat){
                     jobsController.update(sheet, controller, totalJobs, field, newData, id, isExist, args, setting);
                 }
                 //处理重复
                 if(isRepeat){
-                    ///if(id && newData){
                        tools.alertOpr(args, sheet, '该工作内容已存在!', controller.tree.selected.jobs, 'job');
-                  //  }
-                  //  else {
-                        //sheet.getCell(args.row, args.col, GC.Spread.Sheets.SheetArea.viewport).value('');
-                      //  tools.alertOpr(sheet, controller.tree.selected.jobs, 'jobs');
-                   // }
                 }
             }
             else {
-                sheet.getCell(args.row, args.col).value('');
+                sheet.getCell(args.row, args.col).value(me.currentEditData ? me.currentEditData : '');
             }
         });
     },
@@ -1709,7 +1714,7 @@ var jobsController = {
             if(field === 'content'&& newData === job.data.content){
                 let serialNo = tools.getSerialNo(controller.tree.selected.jobs);//update--
                 //billsAjax.updateBills(billsLibId, controller.tree.selected.getID(), 'jobs', job.data.id);//update--
-                billsAjax.updateBills(billsLibId, controller.tree.selected.getID(), 'jobs', {id: job.data.id, serialNo: serialNo});//update--
+                billsAjax.updateBills(userAccount, billsLibId, controller.tree.selected.getID(), 'jobs', {id: job.data.id, serialNo: serialNo});//update--
                 job.count++;
                // controller.tree.selected.jobs.push(job);//update--
                 controller.tree.selected.jobs.push({job: job, serialNo: serialNo});//update--
@@ -1718,7 +1723,7 @@ var jobsController = {
             }
             else if(field == 'code' && newData == job.data.code){
                 let serialNo = tools.getSerialNo(controller.tree.selected.jobs);//update--
-                billsAjax.updateBills(billsLibId, controller.tree.selected.getID(), 'jobs', {id: job.data.id, serialNo: serialNo});//update--
+                billsAjax.updateBills(userAccount, billsLibId, controller.tree.selected.getID(), 'jobs', {id: job.data.id, serialNo: serialNo});//update--
                 job.count++;
                 controller.tree.selected.jobs.push({job: job, serialNo: serialNo});//update--
                // tools.reshowData(sheet, controller.tree.selected.jobs, setting, true);//update--
@@ -1856,10 +1861,12 @@ var jobsController = {
 };
 
 var itemsController = {
+    currentEditData: null,
     editData: function(controller, sheet, totalItems, setting){
-        sheet.bind(GC.Spread.Sheets.Events.EnterCell, function(sender, args){
-            orgItemData = sheet.getCell(args.row, args.col).value();
-        });
+        let me = itemsController;
+        sheet.bind(GC.Spread.Sheets.Events.EditStarting, function (sender, args) {
+            me.currentEditData = sheet.getValue(args.row, args.col);
+        })
         sheet.bind(GC.Spread.Sheets.Events.EditEnded, function(sender, args) {
             var field, newData = args.editingText, id = sheet.getTag(args.row, args.col);
             setting.cols.forEach(function (col, idx) {
@@ -1867,8 +1874,8 @@ var itemsController = {
                     field = col.data.field;
                 }
             });
-            if (controller.tree.selected) {
-                var isExist = tools.isExist(totalItems.itemsArr, field, newData, orgItemData);
+            if (controller.tree.selected && newData !== me.currentEditData) {
+                var isExist = tools.isExist(totalItems.itemsArr, field, newData);
                 var isRepeat = tools.isRepeat(controller.tree.selected.items, field ,newData, 'reference', 'item');
                 //create
                 if(!id && newData && !isRepeat){
@@ -1880,7 +1887,7 @@ var itemsController = {
                     }
                 }
                 //update
-                else if(id && newData !== orgItemData && !isRepeat){
+                else if(id && !isRepeat){
                     itemsController.update(sheet, controller, totalItems, field, newData, id, isExist, args, setting);
                 }
                 //处理重复
@@ -1889,7 +1896,7 @@ var itemsController = {
                 }
             }
             else {
-                sheet.getCell(args.row, args.col).value('');
+                sheet.getCell(args.row, args.col).value(me.currentEditData ? me.currentEditData : '');
             }
         });
     },
@@ -1898,7 +1905,6 @@ var itemsController = {
         if(field === 'content'){
             maxItemsNumber++;
             let serialNo = tools.getSerialNo(controller.tree.selected.items);
-            console.log(`billsLibId: ${billsLibId} billsId: ${controller.tree.selected.getID()} content: ${newData} code: ${maxItemsNumber}`);
             itemsAjax.edCreateItem(userAccount, billsLibId, controller.tree.selected.getID(), newData, maxItemsNumber, serialNo, function(newItemId){
                 let newItemData, newItem;
                 newItemData = {id: newItemId, content: newData, code: maxItemsNumber};
@@ -1920,14 +1926,14 @@ var itemsController = {
         totalItems.itemsArr.forEach(function(item){
             if(field === 'content'&& newData === item.data.content){
                 let serialNo = tools.getSerialNo(controller.tree.selected.items);
-                billsAjax.updateBills(billsLibId, controller.tree.selected.getID(), 'items', {id: item.data.id, serialNo: serialNo});
+                billsAjax.updateBills(userAccount, billsLibId, controller.tree.selected.getID(), 'items', {id: item.data.id, serialNo: serialNo});
                 item.count++;
                 controller.tree.selected.items.push({item: item, serialNo: serialNo});
                 tools.orderReshowData(sheet, controller.tree.selected.items, setting, 'item', true);
             }
             else if(field == 'code' && newData == item.data.code){
                 let serialNo = tools.getSerialNo(controller.tree.selected.items);
-                billsAjax.updateBills(billsLibId, controller.tree.selected.getID(), 'items', {id: item.data.id, serialNo: serialNo});
+                billsAjax.updateBills(userAccount, billsLibId, controller.tree.selected.getID(), 'items', {id: item.data.id, serialNo: serialNo});
                 item.count++;
                 controller.tree.selected.items.push({item: item, serialNo: serialNo});
                 tools.orderReshowData(sheet, controller.tree.selected.items, setting, 'item', true);
@@ -1978,14 +1984,6 @@ var itemsController = {
             else {
                 tools.alertOpr(args, sheet, '该编号不存在,请重新输入!', controller.tree.selected.items, 'item');
             }
-              /*  if(typeof newData === 'number'){
-                    sheet.getCell(args.row, args.col).value(orgItemData);
-                }
-                else {
-                    //编号只能为数字
-                    sheet.getCell(args.row, args.col).value('');
-                }
-            }*/
         }
     },
     upMove: function (controller, sheet) {
@@ -2054,37 +2052,42 @@ var itemsController = {
 };
 
 var valueController = {
+    currentEditData: null,
     editData: function(totalItems, sheet, setting){
-        sheet.bind(GC.Spread.Sheets.Events.EnterCell, function(sender, args){
-            orgValue = sheet.getValue(args.row, args.col);
-        });
+        let me = valueController;
+        sheet.bind(GC.Spread.Sheets.Events.EditStarting, function (sender, args) {
+            me.currentEditData = sheet.getValue(args.row, args.col);
+        })
         sheet.bind(GC.Spread.Sheets.Events.EditEnded, function(sender, args){
-            var newValue = sheet.getValue(args.row, args.col), tagId = sheet.getTag(args.row, args.col), field, isRepeat;
+            var newValue = args.editingText, tagId = sheet.getTag(args.row, args.col), field, isRepeat;
             setting.cols.forEach(function(col, colIdx){
                 if(args.col === colIdx){
                     field = col.data.field;
                 }
             });
-            if(selectedId){
+            if(selectedId && newValue!== me.currentEditData){
                 isRepeat = tools.isRepeat(valueController.getValues(totalItems, selectedId), field, newValue, 'document');
                 if(!tagId && !isRepeat && newValue){//create
-                        valueController.createValue(sheet, totalItems, selectedId, field, newValue);
+                        valueController.createValue(sheet, totalItems, selectedId, field, newValue, args);
                 }
-                else if(tagId && !isRepeat && newValue !== orgValue){//update
-                        valueController.updateValue(userAccount, totalItems, tagId, newValue, field);
+                else if(tagId && !isRepeat){//update
+                        valueController.updateValue(totalItems, tagId, newValue, field, args);
                 }
                 if(isRepeat){
                     if(tagId && newValue){
-                        sheet.getCell(args.row, args.col, GC.Spread.Sheets.SheetArea.viewport).value(orgValue);
+                        sheet.getCell(args.row, args.col, GC.Spread.Sheets.SheetArea.viewport).value(me.currentEditData);
                     }
                     else {
                         sheet.getCell(args.row, args.col, GC.Spread.Sheets.SheetArea.viewport).value('');
                     }
                 }
             }
+            else{
+                sheet.getCell(args.row, args.col).value(me.currentEditData ? me.currentEditData : '');
+            }
         });
     },
-    createValue: function(sheet, totalItems, id, field, newValue){
+    createValue: function(sheet, totalItems, id, field, newValue, args){
         var newData;
         if(field === 'value'){
             var newCode = valueController.getCode(totalItems, id);
@@ -2092,7 +2095,7 @@ var valueController = {
             tools.reSetCell(sheet, sheet.getActiveRowIndex(), 0, newCode, newCode);
         }
         else {
-            if(typeof newValue === 'number'){
+            if(!isNaN(newValue)){
                 newData = {code: newValue, value: ''};
                 tools.reSetCell(sheet, sheet.getActiveRowIndex(), null, null, newValue);
             }
@@ -2106,7 +2109,7 @@ var valueController = {
         valueDatas = tools.getsheetDatas(sheet, 'total');
     },
 
-    updateValue: function(totalItems, tagId, newData, field){
+    updateValue: function(totalItems, tagId, newData, field, args){
         var updateData = {code: tagId, newData: newData, field: field};
         var itemVals = totalItems.findItem(selectedId).data.itemValue;
         if(field === 'value'){
@@ -2178,26 +2181,33 @@ var valueController = {
 };
 
 var totalJobsController = {
+    currentEditData: null,
     eiditData: function(totalJobs, sheet, setting){
-        sheet.bind(GC.Spread.Sheets.Events.EnterCell, function(sender, args){
-            orgJobData = sheet.getCell(args.row, args.col).value();
-        });
+        let me = totalJobsController;
+        sheet.bind(GC.Spread.Sheets.Events.EditStarting, function (sender, args) {
+            me.currentEditData = sheet.getValue(args.row, args.col);
+        })
         sheet.bind(GC.Spread.Sheets.Events.EditEnded, function(sender, args){
-            var newData = sheet.getValue(args.row, args.col), tagId = sheet.getTag(args.row, args.col), field, isRepeat;
+            var newData = args.editingText, tagId = sheet.getTag(args.row, args.col), field, isRepeat;
             setting.cols.forEach(function(col, colIdx){
                 if(args.col === colIdx){
                     field = col.data.field;
                 }
             });
-            isRepeat = tools.isRepeat(totalJobs.jobsArr, field, newData, 'reference', null);
-            if(!tagId && !isRepeat && newData){//create
-                totalJobsController.createJob(sheet, totalJobs, field, newData, args);
-            }
-            else if(tagId && !isRepeat && newData !== orgJobData){//update
+            if(newData !== me.currentEditData){
+                isRepeat = tools.isRepeat(totalJobs.jobsArr, field, newData, 'reference', null);
+                if(!tagId && !isRepeat && newData){//create
+                    totalJobsController.createJob(sheet, totalJobs, field, newData, args);
+                }
+                else if(tagId && !isRepeat){//update
                     totalJobsController.updateJob(totalJobs, tagId, field, newData, args);
+                }
+                if(isRepeat){
+                    tools.alertTotalOpr(args, '该工作内容已存在!', totalJobs.jobsArr);
+                }
             }
-            if(isRepeat){
-                tools.alertTotalOpr(args, '该工作内容已存在!', totalJobs.jobsArr);
+            else{
+                sheet.getCell(args.row, args.col).value(me.currentEditData ? me.currentEditData : '');
             }
         });
     },
@@ -2259,26 +2269,33 @@ var totalJobsController = {
 };
 
 var totalItemsController = {
+    currentEditData: null,
     eiditData: function(totalItems, sheet, setting){
-        sheet.bind(GC.Spread.Sheets.Events.EnterCell, function(sender, args){
-            orgItemData = sheet.getCell(args.row, args.col).value();
+        let me = totalItemsController;
+        sheet.bind(GC.Spread.Sheets.Events.EditStarting, function (sender, args) {
+            me.currentEditData = sheet.getValue(args.row, args.col);
         });
         sheet.bind(GC.Spread.Sheets.Events.EditEnded, function(sender, args){
-            var newData = sheet.getValue(args.row, args.col), tagId = sheet.getTag(args.row, args.col), field, isRepeat;
+            var newData = args.editingText, tagId = sheet.getTag(args.row, args.col), field, isRepeat;
             setting.cols.forEach(function(col, colIdx){
                 if(args.col === colIdx){
                     field = col.data.field;
                 }
             });
-            isRepeat = tools.isRepeat(totalItems.itemsArr, field, newData, 'reference', null);
-            if(!tagId && !isRepeat && newData){//create
-                totalItemsController.createItem(sheet, totalItems, field, newData, args);
-            }
-            else if(tagId && !isRepeat && newData !== orgItemData){//update
+            if(newData !== me.currentEditData){
+                isRepeat = tools.isRepeat(totalItems.itemsArr, field, newData, 'reference', null);
+                if(!tagId && !isRepeat && newData){//create
+                    totalItemsController.createItem(sheet, totalItems, field, newData, args);
+                }
+                else if(tagId && !isRepeat ){//update
                     totalItemsController.updateItem(totalItems, tagId, field, newData, args);
+                }
+                else if(isRepeat){
+                    tools.alertTotalOpr(args, '该项目特征已存在!', totalItems.itemsArr);
+                }
             }
-            if(isRepeat){
-                tools.alertTotalOpr(args, '该项目特征已存在!', totalItems.itemsArr);
+            else{
+                sheet.getCell(args.row, args.col).value(me.currentEditData ? me.currentEditData : '');
             }
         });
     },

+ 1 - 1
web/maintain/bills_lib/scripts/set_sheets.js

@@ -6,7 +6,7 @@ var setSheet = {
         var spreadNS = GC.Spread.Sheets, sheet = spread.getActiveSheet();
         sheet.suspendPaint();
         spread.options.showHorizontalScrollbar = false;
-        spread.options.showVerticalScrollbar =false;
+        //spread.options.showVerticalScrollbar =false;
         spread.options.tabStripVisible = false;
         spread.options.scrollbarMaxAlign = true;
         spread.options.allowCopyPasteExcelStyle = false;

+ 1 - 0
web/maintain/ration_repository/dinge.html

@@ -499,6 +499,7 @@
         <script type="text/javascript" src="/web/maintain/ration_repository/js/section_tree.js"></script>
         <script type="text/javascript" src="/public/web/ztree_common.js"></script>
         <script type="text/javascript" src="/public/web/sheet/sheet_common.js"></script>
+        <script type="text/javascript" src="/web/maintain/ration_repository/js/rationUnits.js"></script>
         <script type="text/javascript" src="/web/maintain/ration_repository/js/ration.js"></script>
         <script type="text/javascript" src="/web/maintain/ration_repository/js/ration_glj.js"></script>
         <script type="text/javascript" src="/public/web/sheet/sheet_creater.js"></script>

+ 1 - 1
web/maintain/ration_repository/js/main.js

@@ -54,7 +54,7 @@ $(function () {
                 $("#renameText").val('');
             }
             else if(dispNameArr.indexOf(newName) !== -1){
-                alert("该工料机库已存在!");
+                alert("该定额库已存在!");
                 $("#renameText").val('');
             }
             else{

+ 52 - 12
web/maintain/ration_repository/js/ration.js

@@ -45,7 +45,6 @@ var rationOprObj = {
         let rationRepId = getQueryString("repository");
         var me = rationOprObj;
         let gljLibID = storageUtil.getSessionCache("gljLib", "repositoryID_" + rationRepId);
-        console.log(gljLibID);
         if(!gljLibID || typeof gljLibID === 'undefined' || gljLibID == -1){
             alert("没有引用工料机库!");
             window.location.href = "/rationRepository/main";
@@ -186,6 +185,7 @@ var rationOprObj = {
                 }
             }
             if(updateArr.length > 0 || removeArr.length > 0){
+                me.mixUpdate = 1;
                 me.mixUpdateRequest(updateArr, [], removeArr);
             }
 
@@ -296,19 +296,29 @@ var rationOprObj = {
             updateArr = [], addArr = [];
         let dataCode = me.setting.header[args.col].dataCode;
         me.editingRowIdx = args.row;
+        console.log(rObj);
         if (me.currentEditingRation["ID"]) {
             rObj["ID"] = me.currentEditingRation["ID"];
-            //updateArr.push(rObj);
-            for(let col =0; col< me.setting.header.length; col++){
-                if(me.currentEditingRation[me.setting.header[col].dataCode] !== rObj[me.setting.header[col].dataCode]){
+                if(me.currentEditingRation[dataCode] !== rObj[dataCode]){
                     me.addRationItem = rObj;
-                    if(rObj[me.setting.header[0].dataCode]){
+                    if(dataCode === 'code'){
+                        if(me.rationsCodes.indexOf(rObj.code) === -1){
+                            me.rationsCodes.splice(me.rationsCodes.indexOf(rObj.code), 1);
+                            me.rationsCodes.push(rObj.code);
+                            updateArr.push(rObj);
+                        }
+                        else{
+                            alert("编码已存在!");
+                            args.sheet.setValue(args.row, args.col, me.currentEditingRation[dataCode]);
+
+                        }
+                    }
+                    else{
                         updateArr.push(rObj);
-                        break;
                     }
                 }
-            }
-        } else if(!me.currentEditingRation["ID"]) {
+        }
+        else if(!me.currentEditingRation["ID"]) {
             if (!sheetCommonObj.chkIfEmpty(rObj, me.setting)) {
                 //addArr.push(rObj);
                 me.addRationItem = rObj;
@@ -318,7 +328,11 @@ var rationOprObj = {
                         me.rationsCodes.push(rObj.code);
                         me.addRationItem = null;
                     }
-                    else if(!rObj.code && rObj.code === ''){
+                    else{
+                        alert('编码已存在!');
+                        me.workBook.getSheet(0).setValue(args.row, args.col, '');
+                    }
+                    /*else if(!rObj.code && rObj.code === ''){
                         $('#alertModalBtn').click();
                         me.workBook.getSheet(0).options.isProtected = true;
                         $('#alertModalCls').click(function () {
@@ -333,7 +347,7 @@ var rationOprObj = {
                             me.workBook.getSheet(0).setValue(args.row, args.col, '');
                             me.workBook.getSheet(0).setActiveCell(args.row, args.col);
                         });
-                    }
+                    }*/
                 }
                 else if(rObj.code && rObj.code.trim().length === 0){
                     me.workBook.getSheet(0).setValue(args.row, args.col, '');
@@ -342,6 +356,7 @@ var rationOprObj = {
         }
         if (updateArr.length > 0 || addArr.length > 0) {
             me.currentEditingRation = null;
+            me.mixUpdate = 1;
             me.mixUpdateRequest(updateArr, addArr, []);
         }
     },
@@ -359,6 +374,9 @@ var rationOprObj = {
         let failPasteArr = [];
         for (var i = 0, rowIdx =info.cellRange.row; i < items.length; i++, rowIdx++) {
             if (cacheSection) {
+                if(!me.isValidUnit(items[i], rationUnits)){//无效单位
+                    items[i].unit = typeof cacheSection[rowIdx].unit !== 'undefined' && !cacheSection[rowIdx] ? cacheSection[rowIdx].unit : '';
+                };
                 //var hasCacheItem = false;
                 if(!cacheSection[rowIdx] && info.cellRange.col === 0 ){
                     if(me.rationsCodes.indexOf(items[i].code) === -1){
@@ -392,6 +410,9 @@ var rationOprObj = {
                 }
 
             } else {
+                if(!me.isValidUnit(items[i], rationUnits)){//无效单位
+                    items[i].unit = '';
+                };
                 //add
                 if(info.cellRange.col === 0){
                     //是否含有已存在的编号
@@ -408,9 +429,17 @@ var rationOprObj = {
             me.showRationItems(me.currentSectionId);
         }*/
          if (updateArr.length > 0 || addArr.length > 0) {
+             me.mixUpdate = 1;
             me.mixUpdateRequest(updateArr, addArr, []);
         }
     },
+    isValidUnit: function (rationObj, validUnits) {
+        let rst = true;
+        if(typeof rationObj.unit !== 'undefined' && rationObj.unit && validUnits.indexOf(rationObj.unit) === -1){//无效
+            rst = false;
+        }
+        return rst;
+    },
     getRationsCodes: function (repId) {
         let me = rationOprObj;
         $.ajax({
@@ -446,8 +475,8 @@ var rationOprObj = {
                         else if (a.code < b.code) rst = -1;
                         return rst;
                     });
-                    me.mixUpdate = 1;
                     me.showRationItems(me.currentSectionId);
+                    me.mixUpdate = 0;
                     me.workBook.getSheet(0).setActiveCell(me.activeCell.row, me.activeCell.col);
                 }
             },
@@ -499,6 +528,16 @@ var rationOprObj = {
             }
         }
     },
+    setCombo: function (sheet, items) {
+        sheet.suspendPaint();
+        for(let i = 0, len = sheet.getRowCount(); i < len; i++){
+            let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
+            combo.items(items);
+            combo.itemHeight(10);
+            sheet.getCell(i, 2).cellType(combo);
+        }
+        sheet.resumePaint();
+    },
     showRationItems: function(sectionID){
         var me = rationOprObj;
         if (me.workBook) {
@@ -506,7 +545,8 @@ var rationOprObj = {
                 var cacheSection = me.currentRations["_SEC_ID_" + sectionID];
                 sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
                 sheetCommonObj.showData(me.workBook.getSheet(0), me.setting, cacheSection);
-
+                //combo
+                me.setCombo(me.workBook.getActiveSheet(), rationUnits);
                 if(me.mixUpdate === 1){
                     rationGLJOprObj.getGljItems(cacheSection[cacheSection.length - 1], function () {
                         me.workBook.focus(true);

+ 49 - 0
web/maintain/ration_repository/js/rationUnits.js

@@ -0,0 +1,49 @@
+/**
+ * Created by Zhong on 2017/9/8.
+ * 定额列表单位下拉表
+ */
+let rationUnits =[
+    'm',
+    'km',
+    'm2',
+    'm3',
+    'kg',
+    't',
+    '10m',
+    '10m2',
+    '10m3',
+    '100m',
+    '100m2',
+    '100m3',
+    '1000m2',
+    '1000m3',
+    'à·km',
+    '总额',
+    '月',
+    '项',
+    '处',
+    '个',
+    '根',
+    '棵',
+    '块',
+    '每一试桩',
+    '桥长米',
+    '公路公里',
+    '株',
+    '组',
+    '座',
+    '元',
+    '工日',
+    '套',
+    '台班',
+    '艘班',
+    'm/处',
+    'm/道',
+    'm/座',
+    'm2/m',
+    'm3/m',
+    'm3/处',
+    '根/米',
+    '亩',
+    'm3/m2'
+];

+ 41 - 22
web/maintain/ration_repository/js/ration_glj.js

@@ -11,14 +11,15 @@ var rationGLJOprObj = {
         header:[
             {headerName:"编码",headerWidth:120,dataCode:"code", dataType: "String", formatter: "@"},
             {headerName:"名称",headerWidth:400,dataCode:"name", dataType: "String"},
+            {headerName:"规格",headerWidth:120,dataCode:"specs", dataType: "String"},
             {headerName:"单位",headerWidth:160,dataCode:"unit", dataType: "String"},
-            {headerName:"基价单",headerWidth:160, dataCode:"basePrice", dataType: "Number", formatter:"0.00",  precision: 2},
+            {headerName:"基价单",headerWidth:160, dataCode:"basePrice", dataType: "Number", formatter:"0.00",  precision: 2},
             {headerName:"定额消耗",headerWidth:160, dataCode:"consumeAmt", dataType: "Number", formatter: "0.000", precision: 3},
             {headerName:"类型",headerWidth:160,dataCode:"gljType", dataType: "String"}
         ],
         view:{
             comboBox:[],
-            lockColumns:[1,2,3,5]
+            lockColumns:[1,2,3,4,6]
         }
     },
     getDistTypeTree: function (gljDistType) {
@@ -177,9 +178,14 @@ var rationGLJOprObj = {
             let gljLibId = storageUtil.getSessionCache("gljLib", "repositoryID_" + repId);
             if(gljLibId){
                 if (info.cellRange.col == 0) {
+                    let cacheArr = me.cache["_GLJ_" + me.currentRationItem.ID];
                     var tmpCodes = sheetCommonObj.analyzePasteData({header:[{dataCode: "code"}] }, info);
                     var codes = [];
                     for (var i = 0; i < tmpCodes.length; i++) {
+                        let rowIdx = info.cellRange.row + i;
+                        if(rowIdx < cacheArr.length){//更新
+                            cacheArr.splice(rowIdx--, 1);
+                        }
                         codes.push(tmpCodes[i].code);
                     }
                     me.addGljItems(codes, gljLibId, info.cellRange);
@@ -215,8 +221,8 @@ var rationGLJOprObj = {
     },
     onCellEditEnd: function(sender, args){
         var me = rationGLJOprObj;
+        var cacheArr = me.cache["_GLJ_" + me.currentRationItem.ID];
         if (args.col != 0) {
-            var cacheArr = me.cache["_GLJ_" + me.currentRationItem.ID];
             if (args.row < cacheArr.length) {
                 var editGlj = cacheArr[args.row];
                 if (editGlj["consumeAmt"] != args.editingText) {
@@ -243,26 +249,36 @@ var rationGLJOprObj = {
                 }
             }
         } else {
-            //重新更新工料机
-            /*if (args.editingText == null || args.editingText.trim() == "") {
-                //delete
-                if (me.cache["_GLJ_" + me.currentRationItem.ID]) {
-                    var cacheArr = me.cache["_GLJ_" + me.currentRationItem.ID];
-                    if (args.row < cacheArr.length) {
-                        cacheArr.splice(args.row, 1);
-                        me.updateRationItem();
-                        sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
-                        me.showGljItems(me.currentRationItem.ID);
+            if(args.editingText && args.editingText.trim().length !== 0){
+                let isExist = false;
+                for(let i = 0, len = cacheArr.length; i < len; i++){
+                    if(cacheArr[i].code === args.editingText && i !== args.row){
+                        isExist = true;
+                        break;
                     }
                 }
-            } else*/
-            if(args.editingText !== null && args.editingText.trim().length !== 0){
-                let rationRepId = storageUtil.getSessionCache("RationGrp","repositoryID");
-                let gljLibID = storageUtil.getSessionCache("gljLib", "repositoryID_" + rationRepId);
-                if (gljLibID) {
-                    var codes = [];
-                    codes.push(args.editingText.trim());
-                    me.addGljItems(codes, gljLibID, args);
+                if(isExist){
+                    alert("该工料机已存在!");
+                    args.sheet.setValue(args.row, args.col, typeof cacheArr[args.row] !== 'undefined' ? cacheArr[args.row].code + '' : '');
+                }
+                else{
+                    if(args.row < cacheArr.length && args.editingText !== cacheArr[args.row].code){//更新
+                        cacheArr.splice(args.row, 1);
+                        let rationRepId = storageUtil.getSessionCache("RationGrp","repositoryID");
+                        let gljLibID = storageUtil.getSessionCache("gljLib", "repositoryID_" + rationRepId);
+                        let codes = [];
+                        codes.push(args.editingText.trim());
+                        me.addGljItems(codes, gljLibID, args);
+                    }
+                    else if(args.row >= cacheArr.length){//新增
+                            let rationRepId = storageUtil.getSessionCache("RationGrp","repositoryID");
+                            let gljLibID = storageUtil.getSessionCache("gljLib", "repositoryID_" + rationRepId);
+                            if (gljLibID) {
+                                var codes = [];
+                                codes.push(args.editingText.trim());
+                                me.addGljItems(codes, gljLibID, args);
+                            }
+                    }
                 }
             }
         }
@@ -461,7 +477,6 @@ var rationGLJOprObj = {
                 cache:false,
                 timeout:5000,
                 success:function(result){
-                    console.log(result);
                     sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
                     if (result) {
                         var cacheArr = [];
@@ -502,6 +517,10 @@ var rationGLJOprObj = {
         var me = this;
         if (me.cache["_GLJ_" + rationID]) {
             sheetCommonObj.showData(me.sheet, me.setting, me.cache["_GLJ_" + rationID], me.distTypeTree);
+            //lock
+            for(let i = 0, len = me.sheet.getRowCount(); i < len; i++){
+                me.sheet.getCell(i, 4).locked(true);
+            }
         }
     }
 }

+ 4 - 2
web/maintain/std_glj_lib/js/glj.js

@@ -34,7 +34,7 @@ let repositoryGljObj = {
     componentGljType: [201, 302, 303],//可成为组成物的工料机类型: 普通材料、 机械组成物、 机上人工
     distTypeTree: null,//add
     setting: {
-
+        owner: "glj",
         header:[
             {headerName:"编码",headerWidth:120,dataCode:"code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
             {headerName:"名称",headerWidth:260,dataCode:"name", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
@@ -1199,4 +1199,6 @@ let gljTypeTreeOprObj = {
         $("#addBtn_"+treeNode.tId).unbind().remove();
     }
 
-}
+};
+
+//export {repositoryGljObj};//测试用

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

@@ -133,7 +133,12 @@ $(document).ready(function() {
                 break;
             case 'fee':
                 $("#fee-area").show();
-                $("#add-compilation-title").text('添加费率库');
+                $("#add-compilation-title").text('添加费率标准');
+                break;
+            case 'artificial':
+                $("#artificial-area").show();
+                $("#add-compilation-title").text('添加人工系数');
+                break;
         }
 
         $("#addcompilation").modal('show');
@@ -229,6 +234,7 @@ function initCompilation() {
     let rationLibData = rationList === undefined ? [] : JSON.parse(rationList);
     let gljLibData = gljList === undefined ? [] : JSON.parse(gljList);
     let feeLibData = feeRateList === undefined ? [] : JSON.parse(feeRateList);
+    let artificialCoefficientData = artificialCoefficientList === undefined ? [] : JSON.parse(artificialCoefficientList);
 
     // 初始化 造价书列设置
     colSpread = TREE_SHEET_HELPER.createNewSpread($('#main-tree-col')[0]);
@@ -265,7 +271,7 @@ function initCompilation() {
     }
     $("select[name='glj_lib']").children("option").first().after(html);
 
-    // 费率库
+    // 费率标准
     html = '';
     for(let tmp of feeLibData) {
         let tmpHtml = '<option value="' + tmp.id + '">' + tmp.name + '</option>';
@@ -273,6 +279,14 @@ function initCompilation() {
     }
     $("select[name='fee_lib']").children("option").first().after(html);
 
+    // 人工系数标准库
+    html = '';
+    for(let tmp of artificialCoefficientData) {
+        let tmpHtml = '<option value="' + tmp.id + '">' + tmp.name + '</option>';
+        html += tmpHtml;
+    }
+    $("select[name='artificial_lib']").children("option").first().after(html);
+
 }
 
 /**
@@ -287,6 +301,7 @@ function getAndValidData(model) {
     let rationLib = $("select[name='ration_lib']").children("option:selected").val();
     let gljLib = $("select[name='glj_lib']").children("option:selected").val();
     let feeLib = $("select[name='fee_lib']").children("option:selected").val();
+    let artificialLib = $("select[name='artificial_lib']").children("option:selected").val();
 
     if (name === '' && model === 'all') {
         throw '编办名字不能为空';
@@ -305,6 +320,10 @@ function getAndValidData(model) {
     }
 
     if (model === 'fee' && (feeLib === '' || feeLib === undefined)) {
+        throw '请选择费率标准';
+    }
+
+    if (model === 'artificial' && (artificialLib === '' || artificialLib === undefined)) {
         throw '请选择费率库';
     }
 
@@ -312,6 +331,7 @@ function getAndValidData(model) {
     let rationLibString = $("select[name='ration_lib']").children("option:selected").text();
     let gljLibString = $("select[name='glj_lib']").children("option:selected").text();
     let feeLibString = $("select[name='fee_lib']").children("option:selected").text();
+    let artificialString = $("select[name='artificial_lib']").children("option:selected").text();
 
     let result = {
         name: name,
@@ -330,6 +350,10 @@ function getAndValidData(model) {
         fee: {
             id: feeLib,
             name: feeLibString
+        },
+        artificial: {
+            id: artificialLib,
+            name: artificialString
         }
     };
     return result;
@@ -362,7 +386,11 @@ function validLib() {
         }
 
         if ($("input:hidden[name='fee_lib']").length <= 0) {
-            throw '请添加费率库';
+            throw '请添加费率标准';
+        }
+
+        if ($("input:hidden[name='artificial_lib']").length <= 0) {
+            throw '请添加人工系数';
         }
 
         result = true;

+ 12 - 3
web/users/views/compilation/add.html

@@ -36,6 +36,8 @@
                                 <th>标准清单</th>
                                 <th>定额库</th>
                                 <th>工料机库</th>
+                                <th>费率标准</th>
+                                <th>人工系数</th>
                                 <th>操作</th>
                             </tr>
                             </thead>
@@ -43,9 +45,16 @@
                                 <% engineeringList.forEach(function(engineering) {%>
                                 <tr>
                                     <td><%= engineering.name %></td>
-                                    <td>0</td>
-                                    <td>0</td>
-                                    <td>0</td>
+                                    <td><%= libCount !== null && libCount[engineering.value + ''] !== undefined ?
+                                        libCount[engineering.value + ''].bill_count : 0 %></td>
+                                    <td><%= libCount !== null && libCount[engineering.value + ''] !== undefined ?
+                                        libCount[engineering.value + ''].ration_count : 0 %></td>
+                                    <td><%= libCount !== null && libCount[engineering.value + ''] !== undefined ?
+                                        libCount[engineering.value + ''].glj_count : 0 %></td>
+                                    <td><%= libCount !== null && libCount[engineering.value + ''] !== undefined ?
+                                        libCount[engineering.value + ''].fee_count : 0 %></td>
+                                    <td><%= libCount !== null && libCount[engineering.value + ''] !== undefined ?
+                                        libCount[engineering.value + ''].artificial_count : 0 %></td>
                                     <td><a href="/compilation/<%= section %>/<%= valuationId %>/<%= engineering.value %>">编辑</a></td>
                                 </tr>
                                 <% }) %>

+ 93 - 71
web/users/views/compilation/engineering.html

@@ -17,84 +17,105 @@
         <div class="c-body">
             <form method="post" action="/compilation/save-lib" enctype="application/x-www-form-urlencoded21">
                 <div class="row">
-                    <div class="col-md-4">
-                        <div class="form-group">
-                            <label>标准清单</label>
-                            <div class="bill-list">
-                                <% if (Object.keys(libData).length > 0 && libData.bill_lib.length > 0) { %>
-                                <% libData.bill_lib.forEach(function (bill, index){ %>
-                                <p class="form-control-static">
-                                    <a class="pull-right text-danger remove-lib" data-model="bill" title="移除">
-                                        <span class="glyphicon glyphicon-remove"></span>
-                                    </a>
-                                    <input type="hidden" name="bill_lib" data-id="<%= bill.id %>" value="<%= JSON.stringify({id: bill.id, name: bill.name}) %>">
-                                    <% if (index === 0) {%><i class="glyphicon glyphicon-flag"></i>&nbsp;<% } %><%= bill.name %>
-                                </p>
-                                <% }) %>
-                                <% } %>
+                    <div class="col-md-12">
+                        <div class="row">
+                            <div class="form-group col-md-4">
+                                <label>标准清单</label>
+                                <div class="bill-list">
+                                    <% if (Object.keys(libData).length > 0 && libData.bill_lib.length > 0) { %>
+                                    <% libData.bill_lib.forEach(function (bill, index){ %>
+                                    <p class="form-control-static">
+                                        <a class="pull-right text-danger remove-lib" data-model="bill" title="移除">
+                                            <span class="glyphicon glyphicon-remove"></span>
+                                        </a>
+                                        <input type="hidden" name="bill_lib" data-id="<%= bill.id %>" value="<%= JSON.stringify({id: bill.id, name: bill.name}) %>">
+                                        <% if (index === 0) {%><i class="glyphicon glyphicon-flag"></i>&nbsp;<% } %><%= bill.name %>
+                                    </p>
+                                    <% }) %>
+                                    <% } %>
+                                </div>
+                                <a class="btn btn-link btn-sm add-compilation" href="javascript:void(0)" data-model="bill">添加</a>
                             </div>
-                            <a class="btn btn-link btn-sm add-compilation" href="javascript:void(0)" data-model="bill">添加</a>
-                        </div>
-                        <div class="form-group">
-                            <label>定额库</label>
-                            <div class="ration-list">
-                                <% if (Object.keys(libData).length > 0 && libData.ration_lib.length > 0) { %>
-                                <% libData.ration_lib.forEach(function (ration, index){ %>
-                                <p class="form-control-static">
-                                    <a class="pull-right text-danger remove-lib" data-model="ration" title="移除" data-id="<%= ration.id %>">
-                                        <span class="glyphicon glyphicon-remove"></span>
-                                    </a>
-                                    <input type="hidden" name="ration_lib" data-id="<%= ration.id %>" value="<%= JSON.stringify({id: ration.id, name: ration.name}) %>">
-                                    <% if (index === 0) {%><i class="glyphicon glyphicon-flag"></i>&nbsp;<% } %><%= ration.name %>
-                                </p>
-                                <% }) %>
-                                <% } %>
+                            <div class="form-group col-md-4">
+                                <label>定额库</label>
+                                <div class="ration-list">
+                                    <% if (Object.keys(libData).length > 0 && libData.ration_lib.length > 0) { %>
+                                    <% libData.ration_lib.forEach(function (ration, index){ %>
+                                    <p class="form-control-static">
+                                        <a class="pull-right text-danger remove-lib" data-model="ration" title="移除" data-id="<%= ration.id %>">
+                                            <span class="glyphicon glyphicon-remove"></span>
+                                        </a>
+                                        <input type="hidden" name="ration_lib" data-id="<%= ration.id %>" value="<%= JSON.stringify({id: ration.id, name: ration.name}) %>">
+                                        <% if (index === 0) {%><i class="glyphicon glyphicon-flag"></i>&nbsp;<% } %><%= ration.name %>
+                                    </p>
+                                    <% }) %>
+                                    <% } %>
+                                </div>
+                                <a href="#" class="btn btn-link btn-sm add-compilation" data-model="ration">添加</a>
                             </div>
-                            <a href="#" class="btn btn-link btn-sm add-compilation" data-model="ration">添加</a>
-                        </div>
-                        <div class="form-group">
-                            <label>工料机库</label>
-                            <div class="glj-list">
-                                <% if (Object.keys(libData).length > 0 && libData.glj_lib.length > 0) { %>
-                                <% libData.glj_lib.forEach(function (glj, index){ %>
-                                <p class="form-control-static">
-                                    <a class="pull-right text-danger remove-lib" data-model="glj" title="移除" data-id="<%= glj.id %>">
-                                        <span class="glyphicon glyphicon-remove"></span>
-                                    </a>
-                                    <input type="hidden" name="glj_lib" data-id="<%= glj.id %>" value="<%= JSON.stringify({id: glj.id, name: glj.name}) %>">
-                                    <% if (index === 0) {%><i class="glyphicon glyphicon-flag"></i>&nbsp;<% } %><%= glj.name %>
-                                </p>
-                                <% }) %>
-                                <% } %>
+                            <div class="form-group col-md-4">
+                                <label>工料机库</label>
+                                <div class="glj-list">
+                                    <% if (Object.keys(libData).length > 0 && libData.glj_lib.length > 0) { %>
+                                    <% libData.glj_lib.forEach(function (glj, index){ %>
+                                    <p class="form-control-static">
+                                        <a class="pull-right text-danger remove-lib" data-model="glj" title="移除" data-id="<%= glj.id %>">
+                                            <span class="glyphicon glyphicon-remove"></span>
+                                        </a>
+                                        <input type="hidden" name="glj_lib" data-id="<%= glj.id %>" value="<%= JSON.stringify({id: glj.id, name: glj.name}) %>">
+                                        <% if (index === 0) {%><i class="glyphicon glyphicon-flag"></i>&nbsp;<% } %><%= glj.name %>
+                                    </p>
+                                    <% }) %>
+                                    <% } %>
+                                </div>
+                                <a href="#" class="btn btn-link btn-sm add-compilation" data-model="glj">添加</a>
                             </div>
-                            <a href="#" class="btn btn-link btn-sm add-compilation" data-model="glj">添加</a>
                         </div>
-                        <div class="form-group">
-                            <label>费率标准</label>
-                            <div class="fee-list">
-                                <% if (Object.keys(libData).length > 0 && libData.fee_lib.length > 0) { %>
-                                <% libData.fee_lib.forEach(function (fee, index){ %>
-                                <p class="form-control-static">
-                                    <a class="pull-right text-danger remove-lib" data-model="fee" title="移除" data-id="<%= fee.id %>">
-                                        <span class="glyphicon glyphicon-remove"></span>
-                                    </a>
-                                    <input type="hidden" name="fee_lib" data-id="<%= fee.id %>" value="<%= JSON.stringify({id: fee.id, name: fee.name}) %>">
-                                    <% if (index === 0) {%><i class="glyphicon glyphicon-flag"></i>&nbsp;<% } %><%= fee.name %>
-                                </p>
-                                <% }) %>
-                                <% } %>
+                        <div class="row">
+                            <div class="form-group col-md-4">
+                                <label>费率标准</label>
+                                <div class="fee-list">
+                                    <% if (Object.keys(libData).length > 0 && libData.fee_lib.length > 0) { %>
+                                    <% libData.fee_lib.forEach(function (fee, index){ %>
+                                    <p class="form-control-static">
+                                        <a class="pull-right text-danger remove-lib" data-model="fee" title="移除" data-id="<%= fee.id %>">
+                                            <span class="glyphicon glyphicon-remove"></span>
+                                        </a>
+                                        <input type="hidden" name="fee_lib" data-id="<%= fee.id %>" value="<%= JSON.stringify({id: fee.id, name: fee.name}) %>">
+                                        <% if (index === 0) {%><i class="glyphicon glyphicon-flag"></i>&nbsp;<% } %><%= fee.name %>
+                                    </p>
+                                    <% }) %>
+                                    <% } %>
+                                    <a href="#" class="btn btn-link btn-sm add-compilation" data-model="fee">添加</a>
+                                </div>
+                            </div>
+                            <div class="form-group col-md-4">
+                                <label>人工系数</label>
+                                <div class="artificial-list">
+                                    <% if (Object.keys(libData).length > 0 && libData.artificial_lib.length > 0) { %>
+                                    <% libData.artificial_lib.forEach(function (artificial, index){ %>
+                                    <p class="form-control-static">
+                                        <a class="pull-right text-danger remove-lib" data-model="artificial" title="移除" data-id="<%= artificial.id %>">
+                                            <span class="glyphicon glyphicon-remove"></span>
+                                        </a>
+                                        <input type="hidden" name="artificial_lib" data-id="<%= artificial.id %>" value="<%= JSON.stringify({id: artificial.id, name: artificial.name}) %>">
+                                        <% if (index === 0) {%><i class="glyphicon glyphicon-flag"></i>&nbsp;<% } %><%= artificial.name %>
+                                    </p>
+                                    <% }) %>
+                                    <% } %>
+                                    <a href="#" class="btn btn-link btn-sm add-compilation" data-model="artificial">添加</a>
+                                </div>
                             </div>
-                            <a href="#" class="btn btn-link btn-sm add-compilation" data-model="fee">添加</a>
                         </div>
                     </div>
-                    <div class="col-md-8">
-                        <legend>
-                            清单模板 / 造价书列
-                            <a href="javascript:void(0)" data-toggle="modal" data-target="#set-column" class="btn btn-primary btn-sm pull-right">设置</a>
-                            <a href="/compilation/template/<%= section %>/<%= valuationId %>/<%= engineeringInfo.id%>" data-toggle="modal" data-target="" class="btn btn-primary btn-sm pull-right" style="margin-right:5px">模板设置</a>
-                            <input type="hidden" name="main_tree_col" value="<%= mainTreeCol %>">
-                            <div id="main-tree-col">
-                            </div>
+                    <div class="col-md-12">
+                        <legend>清单模板 / 造价书列
+                        <a href="javascript:void(0)" data-toggle="modal" data-target="#set-column" class="btn btn-primary btn-sm pull-right">设置</a>
+                        <a href="/compilation/template/<%= section %>/<%= valuationId %>/<%= engineeringInfo.id%>"
+                               data-toggle="modal" data-target="" class="btn btn-primary btn-sm pull-right"
+                               style="margin-right:5px">模板设置</a>
+                        <input type="hidden" name="main_tree_col" value="<%= mainTreeCol %>">
+                        <div id="main-tree-col"></div>
                     </div>
                 </div>
                 <input type="hidden" name="engineering" value="<%= engineeringInfo.id %>" id="engineering">
@@ -109,6 +130,7 @@
     let rationList = '<%- rationList %>';
     let gljList = '<%- gljList %>';
     let feeRateList = '<%- feeRateList %>';
+    let artificialCoefficientList = '<%- artificialCoefficientList %>';
     let mainTreeCol = '<%- mainTreeCol %>';
     let billsTemplateData = '<%- billsTemplateData %>';
     let colSpread = null;

+ 11 - 1
web/users/views/compilation/modal.html

@@ -42,7 +42,7 @@
                     </div>
                 </div>
                 <div class="form-group" id="fee-area">
-                    <label>费率</label>
+                    <label>费率标准</label>
                     <div class="row">
                         <div class="col-xs-12">
                             <select class="form-control" name="fee_lib">
@@ -51,6 +51,16 @@
                         </div>
                     </div>
                 </div>
+                <div class="form-group" id="artificial-area">
+                    <label>人工系数</label>
+                    <div class="row">
+                        <div class="col-xs-12">
+                            <select class="form-control" name="artificial_lib">
+                                <option value="">请选择人工系数</option>
+                            </select>
+                        </div>
+                    </div>
+                </div>
             </div>
             <div class="modal-footer">
                 <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>