Bladeren bron

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

TonyKang 7 jaren geleden
bovenliggende
commit
7b7ac7899b
56 gewijzigde bestanden met toevoegingen van 4916 en 460 verwijderingen
  1. 3 3
      Dockerfile
  2. 3 3
      config/menu.js
  3. 1 1
      modules/common/base/base_model.js
  4. 3 3
      modules/common/std/schemas/std_bills_lib_lists.js
  5. 37 0
      modules/common/std/schemas/std_glj_lib_map.js
  6. 3 3
      modules/common/std/schemas/std_ration_lib_map.js
  7. 9 5
      modules/common/std/std_bills_lib_lists_model.js
  8. 55 0
      modules/common/std/std_glj_lib_map_model.js
  9. 9 5
      modules/common/std/std_ration_lib_map_model.js
  10. 20 0
      modules/ration_repository/controllers/ration_repository_controller.js
  11. 0 1
      modules/ration_repository/controllers/repository_views_controller.js
  12. 3 2
      modules/ration_repository/models/repository_map.js
  13. 2 1
      modules/ration_repository/routes/ration_rep_routes.js
  14. 49 0
      modules/reports/util/pdf/rpt_pdf_consts.js
  15. 198 0
      modules/reports/util/pdf/rpt_pdf_util.js
  16. 112 0
      modules/std_glj_lib/controllers/gljController.js
  17. 66 0
      modules/std_glj_lib/controllers/gljMapController.js
  18. 23 0
      modules/std_glj_lib/controllers/viewsController.js
  19. 150 0
      modules/std_glj_lib/models/gljMapModel.js
  20. 334 0
      modules/std_glj_lib/models/gljModel.js
  21. 65 0
      modules/std_glj_lib/models/schemas.js
  22. 41 0
      modules/std_glj_lib/routes/routes.js
  23. 83 45
      modules/users/controllers/version_controller.js
  24. 74 25
      modules/users/models/version_model.js
  25. 23 4
      modules/users/models/schemas/version.js
  26. 27 0
      modules/users/routes/compilation_route.js
  27. 0 25
      modules/users/routes/version_route.js
  28. 1 0
      public/counter/counter.js
  29. 75 5
      public/web/sheet/sheet_common.js
  30. 22 18
      public/web/sheet/sheet_data_helper.js
  31. 18 6
      web/maintain/ration_repository/dinge.html
  32. 3 0
      web/maintain/ration_repository/gongliao.html
  33. 26 4
      web/maintain/ration_repository/js/main.js
  34. 7 5
      web/maintain/ration_repository/js/ration.js
  35. 2 1
      web/maintain/ration_repository/js/ration_coe.js
  36. 52 43
      web/maintain/ration_repository/js/ration_glj.js
  37. 187 39
      web/maintain/ration_repository/js/repository_glj.js
  38. 155 27
      web/maintain/ration_repository/js/section_tree.js
  39. 34 2
      web/maintain/ration_repository/main.html
  40. 279 0
      web/maintain/std_glj_lib/css/main.css
  41. 265 0
      web/maintain/std_glj_lib/html/gongliao.html
  42. 144 0
      web/maintain/std_glj_lib/html/main.html
  43. 1069 0
      web/maintain/std_glj_lib/js/glj.js
  44. 370 0
      web/maintain/std_glj_lib/js/gljComponent.js
  45. 42 0
      web/maintain/std_glj_lib/js/global.js
  46. 191 0
      web/maintain/std_glj_lib/js/main.js
  47. 1 2
      web/users/css/style.css
  48. 323 0
      web/users/js/col_setting.js
  49. 96 59
      web/users/js/version.js
  50. 42 14
      web/users/views/version/add.html
  51. 16 0
      web/users/views/compilation/common.html
  52. 19 12
      web/users/views/version/index.html
  53. 36 36
      web/users/views/version/modal.html
  54. 4 44
      web/users/views/layout/layout.html
  55. 44 1
      web/users/views/manager/index.html
  56. 0 16
      web/users/views/version/common.html

+ 3 - 3
Dockerfile

@@ -4,10 +4,10 @@ COPY . ConstructionOperation
 
 WORKDIR ConstructionOperation
 
-RUN cnpm install 
+RUN mkdir tmp
+
+RUN cnpm install
 
 EXPOSE 6080
 
 ENTRYPOINT babel-node operation.js
-
-

+ 3 - 3
config/menu.js

@@ -49,9 +49,9 @@ let menuData = {
         }
     },
     'version': {
-        title: '版本管理',
-        url: '/version',
-        name: 'version',
+        title: '编办管理',
+        url: '/compilation',
+        name: 'compilation',
         iconClass: 'glyphicon glyphicon-tag'
     },
     'tool': {

+ 1 - 1
modules/common/base/base_model.js

@@ -115,7 +115,7 @@ class BaseModel {
     /**
      * 更新数据
      *
-     * @param {Number} id
+     * @param {Number|String} id
      * @param {Object} updateData
      * @return {Promise}
      */

+ 3 - 3
modules/common/std/schemas/std_bills_lib_lists.js

@@ -18,9 +18,9 @@ let modelSchema = {
     createDate: String,
     // 名称
     billsLibName: String,
-    // 地区/省份字段
-    localeType: {
-        type: Number,
+    // 编办id
+    compilationId: {
+        type: String,
         index: true
     },
     // 是否被删除

+ 37 - 0
modules/common/std/schemas/std_glj_lib_map.js

@@ -0,0 +1,37 @@
+/**
+ * 工料机库数据模型
+ *
+ * @author CaiAoLin
+ * @date 2017/8/16
+ * @version
+ */
+/*
+import mongoose from "mongoose";
+
+let Schema = mongoose.Schema;
+let collectionName = 'std_glj_lib_map';
+let modelSchema = {
+    // 显示名称
+    dispName: String,
+    // 类型
+    appType: String,
+    // 是否被删除标记
+    deleted: Boolean,
+    // 自增ID
+    ID: Number,
+    // 创建时间
+    createDate: String,
+    // 创建者
+    creator: String,
+    // 最近一次操作
+    recentOpr: Schema.Types.Mixed,
+    // 编办id
+    compilationId: String,
+    // 编办名称
+    compilationName: String,
+    // 定额库
+    rationLibs: Schema.Types.Mixed
+};
+
+let model = mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));
+export {model as default, collectionName as collectionName};*/

+ 3 - 3
modules/common/std/schemas/std_ration_lib_map.js

@@ -19,9 +19,9 @@ let modelSchema = {
     dispName: String,
     // app类型
     appType: Number,
-    // 地区/省份类型
-    localeType: {
-        type: Number,
+    // 编办id
+    compilationId: {
+        type: String,
         index: true
     },
     descr: String,

+ 9 - 5
modules/common/std/std_bills_lib_lists_model.js

@@ -24,9 +24,10 @@ class STDBillsLibListsModel extends BaseModel {
     /**
      * 获取标准清单
      *
+     * @param {String} compilationId
      * @return {Promise}
      */
-    async getBillList() {
+    async getBillList(compilationId) {
         let result = false;
         let billLib = await this.findDataByCondition({deleted: false}, null, false);
         if (billLib.length <= 0) {
@@ -34,13 +35,16 @@ class STDBillsLibListsModel extends BaseModel {
         }
 
         // 整理数据
-        let billList = {};
+        let billList = [];
         for(let tmp of billLib) {
             let tmpRation = {id: tmp.billsLibId, name: tmp.billsLibName};
-            if (billList[tmp.localeType] === undefined) {
-                billList[tmp.localeType] = [tmpRation];
+            if (compilationId !== tmp.compilationId) {
+                continue;
+            }
+            if (billList.length <= 0) {
+                billList = [tmpRation];
             } else {
-                billList[tmp.localeType].push(tmpRation);
+                billList.push(tmpRation);
             }
         }
 

+ 55 - 0
modules/common/std/std_glj_lib_map_model.js

@@ -0,0 +1,55 @@
+/**
+ * 工料机库业务逻辑
+ *
+ * @author CaiAoLin
+ * @date 2017/8/16
+ * @version
+ */
+import BaseModel from "../../common/base/base_model";
+import STDGLJLibMapSchema from "./schemas/std_glj_lib_map";
+
+class STDGLJLibMapModel extends BaseModel {
+
+    /**
+     * 构造函数
+     *
+     * @return {void}
+     */
+    constructor() {
+        let parent = super();
+        parent.model = STDGLJLibMapSchema;
+        parent.init();
+    }
+
+    /**
+     * 获取对应的工料机库
+     *
+     * @param {String} compilationId
+     * @return {Promise}
+     */
+    async getGLJLibList(compilationId) {
+        let result = [];
+        let gliLib = await this.findDataByCondition({deleted: false, compilationId: compilationId.toString()}, null, false);
+
+        if (gliLib.length <= 0) {
+            return result;
+        }
+
+        // 整理数据
+        let gljList = [];
+        for(let tmp of gliLib) {
+            let tmpRation = {id: tmp.ID, name: tmp.dispName};
+            if (gljList.length <= 0) {
+                gljList = [tmpRation];
+            } else {
+                gljList.push(tmpRation);
+            }
+        }
+
+        result = gljList;
+        return result;
+    }
+
+}
+
+export default STDGLJLibMapModel;

+ 9 - 5
modules/common/std/std_ration_lib_map_model.js

@@ -24,9 +24,10 @@ class STDRationLibMapModel extends BaseModel {
     /**
      * 获取定额库
      *
+     * @param {String} compilationId
      * @return {Promise}
      */
-    async getRationLib() {
+    async getRationLib(compilationId) {
         let result = false;
         let rationLib = await this.findDataByCondition({deleted: false}, null, false);
         if (rationLib.length <= 0) {
@@ -34,13 +35,16 @@ class STDRationLibMapModel extends BaseModel {
         }
 
         // 整理数据
-        let rationData = {};
+        let rationData = [];
         for(let tmp of rationLib) {
             let tmpRation = {id: tmp.ID, name: tmp.dispName};
-            if (rationData[tmp.localeType] === undefined) {
-                rationData[tmp.localeType] = [tmpRation];
+            if (compilationId !== tmp.compilationId) {
+                continue;
+            }
+            if (rationData.length <= 0) {
+                rationData = [tmpRation];
             } else {
-                rationData[tmp.localeType].push(tmpRation);
+                rationData.push(tmpRation);
             }
         }
 

+ 20 - 0
modules/ration_repository/controllers/ration_repository_controller.js

@@ -3,11 +3,31 @@
  */
 var rationRepository = require("../models/repository_map");
 import baseController from "../../common/base/base_controller";
+import CompilationModel from "../../users/models/compilation_model";
 var callback = function(req, res, err, message, data){
     res.json({error: err, message: message, data: data});
 };
 
 class RationRepositoryController extends baseController{
+   async getCompilationList(req, res){
+       try{
+           let compilationModel = new CompilationModel(), rst = [];
+           let compilationList = await compilationModel.getCompilationList();
+           if(compilationList.length <= 0){
+               throw '没有数据';
+           }
+           else{
+
+               compilationList.forEach(function (compilation) {
+                   rst.push({_id: compilation._id, name: compilation.name});
+               })
+               callback(req, res, false, '', rst);
+           }
+       }
+        catch(err) {
+            callback(req, res, err, '没有数据', null);
+        }
+    }
     addRationRepository(req,res){
         var rationObj = JSON.parse(req.body.rationRepObj);
         rationRepository.addRationRepository(rationObj,function(err,data){

+ 0 - 1
modules/ration_repository/controllers/repository_views_controller.js

@@ -2,7 +2,6 @@
  * Created by Zhong on 2017/8/3.
  */
 import BaseController from "../../common/base/base_controller";
-
 class ViewsController extends BaseController{
     redirectMain(req, res){
         res.render('maintain/ration_repository/main.html',

+ 3 - 2
modules/ration_repository/models/repository_map.js

@@ -13,13 +13,14 @@ var RepositoryMapSchema = new Schema({
     "ID": Number,
     "dispName" : String,
     "appType" : String, //如:"建筑" / "公路"
-    "localeType": Number, //如 各个省份 / 部颁
+    "compilationId": Number, //编办
+    "compilationName": String,
     "descr" : String,
     "creator": String,
     "createDate": String,
     "recentOpr" :[],
     "deleted": Boolean
-});
+},  {versionKey: false});
 var counter = require('../../../public/counter/counter');
 
 var rationRepository = rationLibdb.model("std_ration_lib_map", RepositoryMapSchema, "std_ration_lib_map");

+ 2 - 1
modules/ration_repository/routes/ration_rep_routes.js

@@ -34,9 +34,10 @@ module.exports =  function (app) {
     app.get('/rationRepository/main', viewsController.auth, viewsController.init, viewsController.redirectMain);
     app.get('/rationRepository/ration',viewsController.auth, viewsController.init, viewsController.redirectRation);
     app.get('/rationRepository/lmm', viewsController.auth, viewsController.init, viewsController.redirectGlj);
-
     app.get('/rationRepository/coeList', viewsController.auth, viewsController.init, viewsController.redirectCoeList);
 
+    apiRouter.post("/getCompilationList", rationRepositoryController.auth, rationRepositoryController.init, rationRepositoryController.getCompilationList);
+
     apiRouter.post("/getRationDisplayNames",rationRepositoryController.auth, rationRepositoryController.init, rationRepositoryController.getDisPlayRationLibs);
     apiRouter.post("/editRationLibs",rationRepositoryController.auth, rationRepositoryController.init, rationRepositoryController.updateRationRepositoryName);
     apiRouter.post("/addRationRepository",rationRepositoryController.auth, rationRepositoryController.init, rationRepositoryController.addRationRepository);

+ 49 - 0
modules/reports/util/pdf/rpt_pdf_consts.js

@@ -0,0 +1,49 @@
+/**
+ * Created by zhang on 2017/8/14.
+ */
+module.exports={
+    JV:{
+        NODE_MAIN_INFO: "主信息",
+        NODE_PAGE_INFO: "打印页面_信息",
+        NODE_MARGINS: "页边距",
+
+        NODE_FONT_COLLECTION: "font_collection",
+        NODE_STYLE_COLLECTION: "style_collection",
+        NODE_CONTROL_COLLECTION: "control_collection",
+
+        BAND_PROP_MERGE_BAND: "MergeBand",
+
+        PROP_NAME: "Name",
+        PROP_VALUE: "Value",
+        PROP_FONT: "font",
+        PROP_CONTROL: "control",
+        PROP_STYLE: "style",
+        PROP_AREA: "area",
+        PROP_ID: "ID",
+        PROP_LEFT: "Left",
+        PROP_RIGHT: "Right",
+        PROP_TOP: "Top",
+        PROP_BOTTOM: "Bottom",
+
+        IDX_LEFT: 0,
+        IDX_TOP: 1,
+        IDX_RIGHT: 2,
+        IDX_BOTTOM: 3,
+
+        CONTROL_PROPS: ["Shrink", "ShowZero", "Horizon", "Vertical", "Wrap"],
+        BORDER_STYLE_PROPS: ["LineWeight", "DashStyle", "Color"],
+        PROP_LINE_WEIGHT: "LineWeight",
+        PROP_DASH_STYLE: "DashStyle",
+        PROP_COLOR: "Color",
+        FONT_PROPS: ["Name", "FontHeight", "FontColor", "FontBold", "FontItalic", "FontUnderline", "FontStrikeOut", "FontAngle"],
+
+        OUTPUT_OFFSET: [2,1,2,3],
+        OFFSET_IDX_LEFT: 0,
+        OFFSET_IDX_RIGHT: 1,
+        OFFSET_IDX_TOP: 2,
+        OFFSET_IDX_BOTTOM: 3,
+
+        VERTICAL_ANGLE: "90",
+        ANTI_VERTICAL_ANGLE: "-90"
+    }
+}

+ 198 - 0
modules/reports/util/pdf/rpt_pdf_util.js

@@ -0,0 +1,198 @@
+/**
+ * Created by zhang on 2017/8/14.
+ */
+
+const prf_cons = require('./rpt_pdf_consts');
+var pdf = require('pdfkit');
+var fs = require('fs');
+let reportO = require('./reportOj');
+
+let JV = prf_cons.JV;
+export_pdf_file();
+function export_pdf_file (data) {
+    let offsetX= 10;
+    let offsetY=10;
+    var doc = new pdf({autoFirstPage: false});
+    doc.pipe(fs.createWriteStream('导出.pdf'));
+    let pageObj = reportO.reportObj;
+   // doc.rect(5,5,1190,890).lineWidth(1).strokeColor('black').stroke();//边框
+
+    if (pageObj && pageObj.items.length > 0 ) {
+        for(let i=0;i<pageObj.items.length;i++){
+            doc.addPage({size:[1200,900]});
+            var page = pageObj.items[i],
+                fonts = pageObj[JV.NODE_FONT_COLLECTION],
+                styles = pageObj[JV.NODE_STYLE_COLLECTION],
+                controls = pageObj[JV.NODE_CONTROL_COLLECTION],
+                mergedBand = pageObj[JV.BAND_PROP_MERGE_BAND];
+
+            for (var j = 0; j < page.cells.length; j++) {
+                var cell = page.cells[j];
+                private_drawCell(cell, fonts, styles, controls, mergedBand);
+            }
+        }
+    }
+    doc.end();
+
+
+    function private_drawCell(cell, fonts, styles, controls, mergedBand) {
+        doc.save();
+        //doc.translate(0.5,0.5);
+        var style = styles[cell[JV.PROP_STYLE]];
+        if (style) {
+            private_drawLine(cell, doc, style, JV.PROP_TOP, [JV.PROP_LEFT, JV.PROP_TOP],[JV.PROP_RIGHT, JV.PROP_TOP], mergedBand, styles);
+            private_drawLine(cell, doc, style, JV.PROP_RIGHT, [JV.PROP_RIGHT, JV.PROP_TOP],[JV.PROP_RIGHT, JV.PROP_BOTTOM], mergedBand, styles);
+            private_drawLine(cell, doc, style, JV.PROP_BOTTOM, [JV.PROP_RIGHT, JV.PROP_BOTTOM],[JV.PROP_LEFT, JV.PROP_BOTTOM], mergedBand, styles);
+            private_drawLine(cell, doc, style, JV.PROP_LEFT, [JV.PROP_LEFT, JV.PROP_BOTTOM],[JV.PROP_LEFT, JV.PROP_TOP], mergedBand, styles);
+        }
+        private_drawCellText(cell, fonts, controls);
+        doc.restore();
+
+    }
+
+    function private_drawLine(cell, doc, style, styleBorderDest, startP, destP, mergedBand, styles) {
+        //doc.beginPath();
+        var destStyle = style;
+        if (mergedBand) {
+            if (mergedBand[styleBorderDest] == cell[JV.PROP_AREA][styleBorderDest]) {
+                destStyle = styles[mergedBand[JV.PROP_STYLE][JV.PROP_ID]];
+            }
+        }
+        doc.moveTo(cell[JV.PROP_AREA][startP[0]] + offsetX, cell[JV.PROP_AREA][startP[1]] + offsetY);
+        if (destStyle[styleBorderDest] && destStyle[styleBorderDest][JV.PROP_LINE_WEIGHT] != 0) {
+            doc.lineWidth(1.0 * destStyle[styleBorderDest][JV.PROP_LINE_WEIGHT]);
+            doc.lineTo(cell[JV.PROP_AREA][destP[0]] + offsetX, cell[JV.PROP_AREA][destP[1]] + offsetY);
+            doc.strokeColor(destStyle[styleBorderDest][JV.PROP_COLOR]);
+        }
+        doc.stroke();
+    }
+    function private_drawCellText(cell, fonts, controls) {
+        if (cell[JV.PROP_VALUE]) {
+            var values = ("" + cell[JV.PROP_VALUE]).split('|');
+            var font = fonts[cell[JV.PROP_FONT]];
+            var control = controls[cell[JV.PROP_CONTROL]];
+            var height = cell[JV.PROP_AREA][JV.PROP_BOTTOM] - cell[JV.PROP_AREA][JV.PROP_TOP];
+            var area = [cell[JV.PROP_AREA][JV.PROP_LEFT] + offsetX, cell[JV.PROP_AREA][JV.PROP_TOP] + offsetY, cell[JV.PROP_AREA][JV.PROP_RIGHT] + offsetX, cell[JV.PROP_AREA][JV.PROP_BOTTOM] + offsetY];
+            for (var i = 0; i < values.length; i++) {
+                area[JV.IDX_TOP] = cell[JV.PROP_AREA][JV.PROP_TOP] + i * (height / values.length) + offsetY;
+                area[JV.IDX_BOTTOM] = cell[JV.PROP_AREA][JV.PROP_TOP] + (i + 1) * (height / values.length) + offsetY;
+                private_drawText(values[i], area, font, control);
+            }
+        }
+    }
+
+    function private_drawText(val, area, font, control) {
+        var dftFontHeight = 12;
+        var output = [];
+        if (font) {
+            dftFontHeight = 1 * font[JV.FONT_PROPS[1]];
+            var dftOthers = "";
+            var dftFontBold = font[JV.FONT_PROPS[3]];
+            if (dftFontBold && dftFontBold == 'T') {
+                doc.font('simsunB.ttf');
+            }else {
+                doc.font('Smart.ttf');
+            }
+         /*   var dftFontItalic = font[JV.FONT_PROPS[4]]; 没有找到中文斜体的字库,暂不支持
+            if (dftFontItalic && dftFontItalic == 'T') {
+                dftOthers = dftOthers + "italic ";
+            }*/
+           // ctx.font = dftOthers + dftFontHeight + "px " + font[JV.PROP_NAME];
+            doc.fontSize(dftFontHeight);
+        }
+        var options={};
+        if (control) {
+            private_setupAreaH(area, control.Horizon, font.FontAngle, dftFontHeight, output,options);
+            private_setupAreaV(area, control.Vertical, font.FontAngle, dftFontHeight, output);
+        } else {
+            private_setupAreaH(area, "left", font.FontAngle, dftFontHeight, output,options);
+            private_setupAreaV(area, "bottom", font.FontAngle, dftFontHeight, output);
+        }
+        var w = area[JV.IDX_RIGHT] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_RIGHT] - area[JV.IDX_LEFT] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_RIGHT];
+        if (font.FontAngle != "0") {
+            w = area[JV.IDX_BOTTOM] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_BOTTOM] - area[JV.IDX_TOP] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_TOP];
+        }
+        doc.save();
+        //doc.translate(output[0], output[1]);
+        if (w >= doc.widthOfString(val)) {
+            options.width=w;
+            options.height=dftFontHeight;
+        } else {
+            while (true) {
+                dftFontHeight--;
+                doc.fontSize(dftFontHeight);
+                if (w >= doc.widthOfString(val) || dftFontHeight < 6) {
+                    options.width=w;
+                    options.height=dftFontHeight;
+                    break;
+                }
+            }
+        }
+
+        var rotateOptions;
+        if (font.FontAngle != "0") {
+            if (control){
+                rotateOptions=private_setupAreaRotateOption(area,w,control.Vertical,dftFontHeight, output);
+            }else {
+                rotateOptions=private_setupAreaRotateOption(area,w,"bottom",dftFontHeight, output);
+            }
+            doc.rotate(font.FontAngle,rotateOptions);
+        }
+        doc.text(val,output[0], output[1],options);
+        doc.restore();
+    }
+
+    function private_setupAreaH(area, type, fontAngle, dftFontHeight, outputPoint,options) {
+        var lType = type;
+        if (type != "left" && type != "right" && type != "center") lType = "left";
+        options.align=lType;
+        outputPoint[0]=1 * area[JV.IDX_LEFT]+ JV.OUTPUT_OFFSET[JV.OFFSET_IDX_LEFT];
+    }
+
+    function private_setupAreaV(area, type, fontAngle, dftFontHeight, outputPoint) {
+        var lType = type;
+        if (type != "top" && type != "bottom" && type != "center") lType = "top";
+         switch (lType) {
+             case "top":
+                 outputPoint[1] = 1 * area[JV.IDX_TOP] + JV.OUTPUT_OFFSET[JV.OFFSET_IDX_TOP];
+                 break;
+             case "bottom":
+                 outputPoint[1] = 1 * area[JV.IDX_BOTTOM] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_BOTTOM]-dftFontHeight;
+                 break;
+             case "center":
+                 outputPoint[1] = 1 * area[JV.IDX_TOP] + (1 * area[JV.IDX_BOTTOM]-1 * area[JV.IDX_TOP]- dftFontHeight) / 2;
+                 break;
+         }
+    }
+
+    function private_setupAreaRotateOption(area,w, type="top",dftFontHeight,outputPoint){
+        var x = (area[JV.IDX_RIGHT] - area[JV.IDX_LEFT])/2+area[JV.IDX_LEFT];
+        var y =(area[JV.IDX_BOTTOM] - area[JV.IDX_TOP])/2+ area[JV.IDX_TOP];
+        var rotateOptions = {origin:[x,y]};
+        var h = area[JV.IDX_RIGHT] - area[JV.IDX_LEFT];
+        outputPoint[0]=x-w/2+JV.OUTPUT_OFFSET[JV.OFFSET_IDX_LEFT];
+        var lType = type;
+        switch (lType) {
+            case "top":
+                outputPoint[1] = y- h/2+ JV.OUTPUT_OFFSET[JV.OFFSET_IDX_TOP];
+                break;
+            case "bottom":
+                outputPoint[1] = y+ h/2-JV.OUTPUT_OFFSET[JV.OFFSET_IDX_BOTTOM]-dftFontHeight;
+                break;
+            case "center":
+                outputPoint[1] = y+dftFontHeight/2;
+                break;
+        }
+        return rotateOptions;
+    }
+
+}
+
+
+
+
+
+
+
+
+

+ 112 - 0
modules/std_glj_lib/controllers/gljController.js

@@ -0,0 +1,112 @@
+/**
+ * Created by Zhong on 2017/8/11.
+ */
+
+import BaseController from "../../common/base/base_controller";
+import stdgljutil  from "../../../public/cache/std_glj_type_util";
+import GljDao from "../models/gljModel";
+
+let gljDao = new GljDao();
+let callback = function(req, res, err, message, data){
+    res.json({error: err, message: message, data: data});
+};
+
+class GljController extends BaseController{
+    getGljDistType (req, res) {
+        let gljDistTypeCache = stdgljutil.getStdGljTypeCacheObj().toArray();
+        if(gljDistTypeCache.length >0 ){
+            callback(req, res, null, '', gljDistTypeCache);
+        }
+        else {
+            callback(req, res, 1, 'Error', null);
+        }
+    }
+    getGljTree(req,res){
+        var gljLibId = req.body.gljLibId;
+        gljDao.getGljTypes(gljLibId,function(err,data){
+            callback(req,res,err, 'Get Tree', data)
+        });
+    }
+    createNewGljTypeNode(req, res) {
+        var repId = req.body.repositoryId;
+        var lastNodeId = req.body.lastNodeId;
+        let lastOpr = req.body.lastOpr;
+        var nodeData = JSON.parse(req.body.rawNodeData);
+        gljDao.createNewNode(repId, lastOpr, lastNodeId, nodeData, function(err, msg, data){
+            callback(req,res,err,msg, data)
+        });
+    }
+    updateGljNodes(req, res) {
+        var nodes = JSON.parse(req.body.nodes);
+        let repId = req.body.repId,
+            lastOpr = req.body.lastOpr;
+        gljDao.updateNodes(repId, lastOpr, nodes, function(err,results){
+            callback(req,res, err, results)
+        });
+    }
+    deleteGljNodes(req, res) {
+        var nodes = JSON.parse(req.body.nodes);
+        var preNodeId = req.body.preNodeId;
+        var preNodeNextId = req.body.preNodeNextId;
+        let repId = req.body.repId, lastOpr = req.body.lastOpr;
+        gljDao.removeNodes(repId, lastOpr, nodes, preNodeId, preNodeNextId, function(err,results){
+            callback(req,res, err, results)
+        });
+    }
+    getGljItems(req, res) {
+        var repId = req.body.repositoryId,
+            gljType = req.body.type,
+            gljCode = req.body.code;
+        if (gljCode) {
+            gljDao.getGljItem(repId, gljCode, function(err, data){
+                callback(req,res,err,'Get Items', data)
+            });
+        } else if (gljType) {
+            gljDao.getGljItemByType(repId, gljType, function(err, data){
+                callback(req,res,err,'Get Types', data)
+            });
+        } else {
+            gljDao.getGljItemsByRep(repId, function(err, data){
+                callback(req,res,err,'Get Items',data)
+            });
+        }
+    }
+    getGljItemsByIds(req, res) {
+        var gljIds = JSON.parse(req.body.gljIds);
+        gljDao.getGljItems(gljIds, function(err, data){
+            callback(req,res,err,'Get Items',data)
+        });
+    }
+    getGljItemsByCodes(req, res) {
+        var gljCodes = JSON.parse(req.body.gljCodes),
+            repId = req.body.repId;
+        gljDao.getGljItemsByCode(repId, gljCodes, function(err, data){
+            callback(req,res,err,'Get Items',data)
+        });
+    }
+    updateComponent(req, res){
+        let libId = req.body.libId,
+            updateArr = req.body.updateArr,
+            oprtor = req.body.oprtor;
+        gljDao.updateComponent(libId, oprtor, updateArr, function (err, message, rst) {
+            callback(req, res, err, message, rst);
+        })
+    }
+    mixUpdateGljItems(req, res){
+        var repId = req.body.repositoryId,
+            updateItems = JSON.parse(req.body.updateItems),
+            addItems = JSON.parse(req.body.addItems),
+            removeIds = JSON.parse(req.body.removeIds),
+            lastOpr = req.body.lastOpr;
+        gljDao.mixUpdateGljItems(repId, lastOpr, updateItems, addItems, removeIds, function(err, message, rst){
+            if (err) {
+                callback(req, res, err, message, null);
+            } else {
+                callback(req, res, err, message, rst);
+            }
+        });
+    }
+
+}
+
+export default GljController;

+ 66 - 0
modules/std_glj_lib/controllers/gljMapController.js

@@ -0,0 +1,66 @@
+/**
+ * Created by Zhong on 2017/8/11.
+ */
+
+import BaseController from "../../common/base/base_controller";
+import {GljMapDao} from "../models/gljMapModel";
+import CompilationModel from "../../users/models/compilation_model";
+let gljMapDao = new GljMapDao();
+
+let callback = function(req, res, err, message, data){
+    res.json({error: err, message: message, data: data});
+};
+class GljMapController extends BaseController{
+    async getCompilationList(req, res){
+        try{
+            let compilationModel = new CompilationModel(), rst = [];
+            let compilationList = await compilationModel.getCompilationList();
+            if(compilationList.length <= 0){
+                throw '没有数据';
+            }
+            else{
+
+                compilationList.forEach(function (compilation) {
+                    rst.push({_id: compilation._id, name: compilation.name});
+                })
+                callback(req, res, false, '', rst);
+            }
+        }
+        catch(err) {
+            callback(req, res, err, '没有数据', null);
+        }
+    }
+    getGljLib(req, res){
+        let libId = req.body.libId;
+        gljMapDao.getGljLib(libId, function (err, message, data) {
+            callback(req, res, err, message, data);
+        })
+    }
+    getAllGljLib(req, res){
+        gljMapDao.getAllGljLib(function (err, message, data) {
+            callback(req, res, err, message, data);
+        })
+    }
+    createGljLib(req, res){
+        let gljLibObj = JSON.parse(req.body.gljLibObj);
+        gljMapDao.createGljLib(gljLibObj, function (err, message, data) {
+            callback(req, res, err, message, data);
+        })
+    }
+    renameGljLib(req, res){
+        let oprtor = req.body.oprtor,
+            renameObj = JSON.parse(req.body.renameObj);
+        gljMapDao.renameGljLib(oprtor, renameObj, function (err, message) {
+            callback(req, res, err, message, null);
+        })
+    }
+    removeGljLib(req, res){
+        let oprtor = req.body.oprtor,
+            libId = req.body.libId;
+        gljMapDao.removeGljLib(oprtor, libId, function (err, message) {
+            callback(req, res, err, message, null);
+        });
+    }
+}
+
+export default GljMapController;

+ 23 - 0
modules/std_glj_lib/controllers/viewsController.js

@@ -0,0 +1,23 @@
+/**
+ * Created by Zhong on 2017/8/11.
+ * 标准工料机库页面控制器
+ */
+
+import BaseController from "../../common/base/base_controller";
+
+class ViewsController extends BaseController{
+    redirectMain(req, res){
+        res.render('maintain/std_glj_lib/html/main.html',
+        {
+            userAccount: req.session.managerData.username
+        });
+    }
+    redirectGlj(req, res){
+        res.render('maintain/std_glj_lib/html/gongliao.html',
+        {
+            userAccount: req.session.managerData.username
+        });
+    }
+}
+
+export default ViewsController;

+ 150 - 0
modules/std_glj_lib/models/gljMapModel.js

@@ -0,0 +1,150 @@
+/**
+ * Created by Zhong on 2017/8/11.
+ */
+import {gljMapModel} from "./schemas";
+import moment from "moment";
+import counter from "../../../public/counter/counter";
+import async from "async";
+
+class OprDao {
+    static updateOprArr(findSet, oprtor, date, cb){
+        let oprDate = moment(date).format('YYYY-MM-DD HH:mm:ss');
+        gljMapModel.find(findSet, function (err, result) {
+            if(err){
+                cb(err);
+            }
+            else{
+                if(result.length === 1){
+                    let recentOprArr = result[0].recentOpr;
+                    let isExist = false;
+                    for(let i =0 ; i<recentOprArr.length; i++){
+                        if(recentOprArr[i].operator === oprtor){
+                            recentOprArr[i].operateDate = oprDate;
+                            isExist = true;
+                        }
+                    }
+                    if(!isExist){
+                        if(recentOprArr.length < 5){
+                            recentOprArr.push({operator: oprtor, operateDate: oprDate});
+                        }
+                        else if(recentOprArr.length === 5){
+                            recentOprArr.sort(function (a, b) {
+                                if(a.operateDate > b.operateDate){
+                                    return -1;
+                                }else {
+                                    return 1;
+                                }
+                                return 0;
+                            });
+                            recentOprArr.splice(recentOprArr.length -1, 1);
+                            recentOprArr.splice(0, 1, {operator: oprtor, operateDate: oprDate});
+                        }
+                    }
+                    gljMapModel.update(findSet, {$set: {recentOpr: recentOprArr}}, function (err) {
+                        if(err){
+                            cb(err);
+                        }
+                        else{
+                            cb(null);
+                        }
+                    });
+                }
+                else{
+                    cb(err);
+                }
+            }
+        });
+    };
+}
+
+
+class GljMapDao extends OprDao{
+   static createNewLibModel(gljLibObj){
+        var rst = {};
+        rst.dispName = gljLibObj.dispName;
+        rst.appType = gljLibObj.appType?gljLibObj.appType:'construct';
+        rst.compilationId = gljLibObj.compilationId?gljLibObj.compilationId: -1;
+        rst.compilationName = gljLibObj.compilationName?gljLibObj.compilationName:'';
+        rst.creator = gljLibObj.creator;
+        rst.createDate = moment(Date.now()).format('YYYY-MM-DD HH:mm:ss');
+        rst.recentOpr = [{operator: gljLibObj.creator, operateDate: rst.createDate}];
+        rst.deleted = false;
+        return rst;
+    }
+
+    getGljLib(libId, callback){
+        gljMapModel.find({ID: libId}, function (err, result) {
+            if(err){
+                callback(err, '没有数据!', null);
+            }
+            else{
+                callback(null, '成功', result);
+            }
+        })
+    }
+    getAllGljLib(callback){
+        gljMapModel.find({deleted: false}, function (err, result) {
+            if(err){
+                callback(err, '没有定额库数据!', null);
+            }
+            else{
+                callback(null, '成功', result);
+            }
+        })
+    }
+    createGljLib(gljLibObj, callback){
+        counter.counterDAO.getIDAfterCount(counter.moduleName.stdGljLib, 1, function (err, result) {
+            if(err){
+                callback(err, '获取新ID失败!');
+            }
+            else{
+                let newGljLib = GljMapDao.createNewLibModel(gljLibObj);
+                newGljLib.ID = result.value.sequence_value;
+                gljMapModel.create(newGljLib, function (err, result) {
+                    if(err){
+                        callback(err, '创建新工料机库失败!', null);
+                    }
+                    else{
+                        callback(null, '创建成功!', result);
+                    }
+                });
+            }
+        })
+    }
+    renameGljLib(oprtor, renameObj, callback){
+        gljMapModel.update({ID: renameObj.ID, deleted: false}, {$set: {dispName: renameObj.newName}}, function (err) {
+            if(err){
+                callback(err, '重命名失败!');
+            }
+            else{
+                GljMapDao.updateOprArr({ID: renameObj.ID, deleted: false}, oprtor, Date.now(), function (err) {
+                    if(err){
+                        callback(err, '更新最近操作者失败!');
+                    }
+                    else{
+                        callback(null, '成功!');
+                    }
+                });
+            }
+        });
+    }
+    removeGljLib(oprtor, libId, callback){
+        GljMapDao.updateOprArr({ID: libId, deleted: false}, oprtor, Date.now(), function (err) {
+            if(err){
+                callback(err, '失败!')
+            }
+            else{
+                gljMapModel.update({ID: libId, deleted: false}, {$set: {deleted: true}}, function (err) {
+                    if(err){
+                        callback(err, '移除工料机库失败!');
+                    }
+                    else{
+                        callback(null, '成功!');
+                    }
+                });
+            }
+        });
+    }
+}
+
+export {OprDao, GljMapDao};

+ 334 - 0
modules/std_glj_lib/models/gljModel.js

@@ -0,0 +1,334 @@
+/**
+ * Created by Zhong on 2017/8/11.
+ */
+import {gljMapModel, gljModel, gljClassModel, gljClassTemplateModel} from "./schemas";
+import {OprDao} from  "./gljMapModel";
+import moment from "moment";
+import counter from "../../../public/counter/counter";
+import async from "async";
+
+class GljDao  extends OprDao{
+    getGljTypes (gljLibId, callback){
+        gljClassModel.find({"repositoryId": gljLibId, "$or": [{"isDeleted": null}, {"isDeleted": false} ]},function(err,data){
+            if(data.length) {
+                callback(false,data);
+            }
+            else  if(err) callback("获取工料机类型错误!",false)
+            else {
+                gljClassTemplateModel.find({'$or': [{isDeleted: null}, {isDeleted: false}]}, function (err, datas) {
+                    if(err){
+                        callback("获取工料机类型错误!", false);
+                    }
+                    else{
+                        let rst = [];
+                        async.each(datas, function (data, cb) {
+                            let newClassObj = {};
+                            newClassObj.ID = data.ID;
+                            newClassObj.ParentID = data.ParentID;
+                            newClassObj.NextSiblingID = data.NextSiblingID;
+                            newClassObj.Name = data.Name;
+                            newClassObj.repositoryId = gljLibId;
+                            gljClassModel.create(newClassObj, function(err){
+                                if(err)cb(err);
+                                else{
+                                    rst.push(newClassObj);
+                                    cb(null);
+                                }
+                            });
+                        }, function (err) {
+                            if(err) callback("新增工料机类型错误!", false);
+                            else callback(false, rst);
+                        });
+                    }
+                });
+            }
+        })
+    }
+
+    getGljItemsByRep(repositoryId,callback){
+        gljModel.find({"repositoryId": repositoryId},function(err,data){
+            if(err) callback(true, "")
+            else callback(false,data);
+        })
+    }
+
+    getGljItemByType (repositoryId, type, callback){
+        gljModel.find({"repositoryId": repositoryId, "gljType": type},function(err,data){
+            if(err) callback(true, "")
+            else callback(false, data);
+        })
+    };
+
+    getGljItem (repositoryId, code, callback){
+        gljModel.find({"repositoryId": repositoryId, "code": code},function(err,data){
+            if(err) callback(true, "")
+            else callback(false, data);
+        })
+    };
+
+    getGljItems (gljIds, callback){
+        gljModel.find({"ID": {"$in": gljIds}},function(err,data){
+            if(err) callback(true, "")
+            else callback(false, data);
+        })
+    };
+
+    getGljItemsByCode (repositoryId, codes, callback){
+        gljModel.find({"repositoryId": repositoryId,"code": {"$in": codes}},function(err,data){
+            if(err) callback(true, "")
+            else callback(false, data);
+        })
+    };
+
+    updateComponent(libId, oprtor, updateArr, callback){
+        let parallelFucs = [];
+        for(let i = 0; i < updateArr.length; i++){
+            parallelFucs.push((function(obj){
+                return function (cb) {
+                    if(typeof obj.component === 'undefined'){
+                        obj.component = [];
+                    }
+                    gljModel.update({repositoryId: libId, ID: obj.ID}, obj, function (err, result) {
+                        if(err){
+                            cb(err);
+                        }
+                        else{
+                            cb(null, obj);
+                        }
+                    })
+                }
+            })(updateArr[i]));
+        }
+        parallelFucs.push((function () {
+            return function (cb) {
+                GljDao.updateOprArr({ID: libId}, oprtor, moment(Date.now()).format('YYYY-MM-DD HH:mm:ss'), function (err) {
+                    if(err){
+                        cb(err);
+                    }
+                    else{
+                        cb(null);
+                    }
+                })
+            }
+        })());
+        async.parallel(parallelFucs, function (err, result) {
+            if(err){
+                callback(err, '更新组成物错误!', null);
+            }
+            else{
+                console.log(result);
+                callback(null, '成功!', result);
+            }
+        });
+    }
+
+    mixUpdateGljItems (repId, lastOpr, updateItems, addItems, rIds, callback) {
+        var me = this;
+        if (updateItems.length == 0 && rIds.length == 0) {
+            me.addGljItems(repId, lastOpr, addItems, callback);
+        } else {
+            me.removeGljItems(repId, lastOpr, rIds, function(err, message, docs) {
+                me.updateGljItems(repId, lastOpr, updateItems, function(err, results){
+                    if (err) {
+                        callback(true, "Fail to update", false);
+                    } else {
+                        if (addItems && addItems.length > 0) {
+                            me.addGljItems(repId, lastOpr, addItems, callback);
+                        } else {
+                            callback(false, "Save successfully", results);
+                        }
+                    }
+                });
+            });
+        }
+    };
+
+    removeGljItems (repId, lastOpr, rIds, callback) {
+        if (rIds && rIds.length > 0) {
+            gljModel.collection.remove({ID: {$in: rIds}}, null, function(err, docs){
+                if (err) {
+                    callback(true, "Fail to remove", false);
+                } else {
+                    GljDao.updateOprArr({ID: repId}, lastOpr, moment(Date.now()).format('YYYY-MM-DD HH:mm:ss'), function (err) {
+                        if(err){
+                            callback(true, "Fail to update operator", false);
+                        }
+                        else{
+                            callback(false, "Remove successfully", docs);
+                        }
+                    });
+                }
+            })
+        } else {
+            callback(false, "No records were deleted!", null);
+        }
+    }
+
+    addGljItems (repId, lastOpr, items, callback) {
+        if (items && items.length > 0) {
+            counter.counterDAO.getIDAfterCount(counter.moduleName.GLJ, items.length, function(err, result){
+                var maxId = result.value.sequence_value;
+                var arr = [];
+                for (var i = 0; i < items.length; i++) {
+                    var obj = new gljModel(items[i]);
+                    obj.ID = (maxId - (items.length - 1) + i);
+                    obj.repositoryId = repId;
+                    arr.push(obj);
+                }
+                gljModel.collection.insert(arr, null, function(err, docs){
+                    if (err) {
+                        callback(true, "Fail to add", false);
+                    } else {
+                        GljDao.updateOprArr({ID: repId}, lastOpr, moment(Date.now()).format('YYYY-MM-DD HH:mm:ss'), function (err) {
+                            if(err){
+                                callback(true, "Fail to update Operator", false);
+                            }
+                            else{
+                                callback(false, "Add successfully", docs);
+                            }
+                        });
+                    }
+                })
+            });
+        } else {
+            callback(true, "No source", false);
+        }
+    }
+
+    updateGljItems(repId, lastOpr, items, callback) {
+        var functions = [];
+        for (var i=0; i < items.length; i++) {
+            functions.push((function(doc) {
+                return function(cb) {
+                    var filter = {};
+                    if (doc.ID) {
+                        filter.ID = doc.ID;
+                    } else {
+                        filter.repositoryId = repId;
+                        filter.code = doc.code;
+                    }
+                    gljModel.update(filter, doc, cb);
+                };
+            })(items[i]));
+        }
+        functions.push((function () {
+            return function (cb) {
+                GljDao.updateOprArr({ID: repId}, lastOpr, moment(Date.now()).format('YYYY-MM-DD HH:mm:ss'), function (err) {
+                    if(err){
+                        cb(err);
+                    }
+                    else{
+                        cb(null);
+                    }
+                })
+            }
+        })());
+        async.parallel(functions, function(err, results) {
+            callback(err, results);
+        });
+    }
+
+    updateNodes (repId, lastOpr, nodes, callback) {
+        var functions = [];
+        for (var i=0; i < nodes.length; i++) {
+            functions.push((function(doc) {
+                return function(cb) {
+                    gljClassModel.update({ID: doc.ID}, doc, cb);
+                };
+            })(nodes[i]));
+        }
+        functions.push((function () {
+            return function (cb) {
+                GljDao.updateOprArr({ID: repId}, lastOpr, moment(Date.now()).format('YYYY-MM-DD HH:mm:ss'), function (err) {
+                    if(err){
+                        cb(err);
+                    }
+                    else{
+                        cb(null);
+                    }
+                })
+            }
+        })());
+        async.parallel(functions, function(err, results) {
+            callback(err, results);
+        });
+    }
+    removeNodes (repId, lastOpr, nodeIds, preNodeId, preNodeNextId, callback){
+        var functions = [];
+        if (preNodeId != -1) {
+            functions.push((function(nodeId, nextId) {
+                return function(cb) {
+                    gljClassModel.update({ID: nodeId}, {"NextSiblingID": nextId}, cb);
+                };
+            })(preNodeId, preNodeNextId));
+        }
+        for (var i=0; i < nodeIds.length; i++) {
+            functions.push((function(nodeId) {
+                return function(cb) {
+                    gljClassModel.update({ID: nodeId}, {"isDeleted": true}, cb);
+                };
+            })(nodeIds[i]));
+        }
+        functions.push((function () {
+            return function (cb) {
+                GljDao.updateOprArr({ID: repId}, lastOpr, moment(Date.now()).format('YYYY-MM-DD HH:mm:ss'), function (err) {
+                    if(err){
+                        cb(err);
+                    }
+                    else{
+                        cb(null);
+                    }
+                })
+            }
+        })());
+        async.parallel(functions, function(err, results) {
+            callback(err, results);
+        });
+    }
+
+    createNewNode(repId, lastOpr, lastNodeId, nodeData, callback) {
+        return counter.counterDAO.getIDAfterCount(counter.moduleName.GLJ, 1, function(err, result){
+            nodeData.repositoryId = repId;
+            nodeData.ID = result.value.sequence_value;
+            var node = new gljModel(nodeData);
+            async.parallel([
+                function (cb) {
+                    node.save(function (err, result) {
+                        if (err) {
+                            cb("章节树ID错误!", false);
+                        } else {
+                            if (lastNodeId > 0) {
+                                gljClassModel.update({ID: lastNodeId}, {"NextSiblingID": nodeData.ID}, function(err, rst){
+                                    if (err) {
+                                        cb("章节树ID错误!", false);
+                                    } else {
+                                        cb(false, result);
+                                    }
+                                });
+                            } else cb(false, result);
+                        }
+                    });
+                },
+                function (cb) {
+                    GljDao.updateOprArr({ID: repId}, lastOpr, moment(Date.now()).format('YYYY-MM-DD HH:mm:ss'), function (err) {
+                        if(err){
+                            cb(err);
+                        }
+                        else{
+                            cb(null);
+                        }
+                    })
+                }
+            ], function (err, result) {
+                if(err){
+                    callback(true, "章节树错误!", false);
+                }
+                else{
+                    callback(false, '', result[0]);
+                }
+            })
+        });
+    }
+}
+
+export default GljDao;

+ 65 - 0
modules/std_glj_lib/models/schemas.js

@@ -0,0 +1,65 @@
+/**
+ * Created by Zhong on 2017/8/11.
+ */
+import mongoose from "mongoose";
+let Schema = mongoose.Schema;
+let gljMapSchema = new Schema({
+    deleted: false,
+    ID: Number,
+    dispName: String,
+    appType: String,
+    creator: String,
+    createDate: String,
+    recentOpr: [],
+    compilationId: String,
+    compilationName: String
+},
+    {versionKey: false});
+
+let gjlComponentSchema = mongoose.Schema(
+    {
+        ID: Number,
+        consumeAmt: Number
+    },
+    {_id: false},
+    {versionKey: false}
+);
+
+let gljSchema = new Schema({
+    deleted: false,
+    repositoryId: Number,
+    ID: Number,
+    code: String,
+    name: String,
+    specs: String,
+    basePrice: Number,
+    gljClass: Number,
+    gljType: Number,
+    shortName: String,
+    component: [gjlComponentSchema]
+},{versionKey: false});
+
+let gljClassSchema = mongoose.Schema({
+    repositoryId: Number,
+    ID: Number,
+    ParentID: Number,
+    NextSiblingID: Number,
+    Name: String,
+    isDeleted: Boolean
+}, {versionKey: false});
+
+let gljClassTemplate = mongoose.Schema({
+    ID: Number,
+    ParentID: Number,
+    NextSiblingID: Number,
+    Name: String,
+    isDeleted: Boolean
+}, {versionKey: false});
+
+
+let gljMapModel = mongoose.model('std_glj_lib_map', gljMapSchema, 'std_glj_lib_map');
+let gljModel = mongoose.model('std_glj_lib_gljList', gljSchema, 'std_glj_lib_gljList');
+let gljClassModel = mongoose.model('std_glj_lib_gljClass', gljClassSchema, 'std_glj_lib_gljClass');
+let gljClassTemplateModel = mongoose.model('std_glj_lib_gljClassTemplate', gljClassTemplate, 'std_glj_lib_gljClassTemplate');
+
+export {gljMapModel, gljModel, gljClassModel, gljClassTemplateModel};

+ 41 - 0
modules/std_glj_lib/routes/routes.js

@@ -0,0 +1,41 @@
+/**
+ * Created by Zhong on 2017/8/11.
+ * 标准工料机库路由
+ */
+
+import express from "express";
+import ViewsController from "../controllers/viewsController";
+import GljMapController from "../controllers/gljMapController";
+import GljController from "../controllers/gljController";
+
+let router = express.Router();
+let viewsController = new ViewsController(),
+    gljMapController = new GljMapController(),
+    gljController = new GljController();
+
+module.exports = function (app) {
+    app.get('/stdGljRepository/main', viewsController.auth, viewsController.init, viewsController.redirectMain);
+    app.get('/stdGljRepository/glj', viewsController.auth, viewsController.init, viewsController.redirectGlj);
+
+    router.post('/getCompilationList', gljMapController.auth, gljMapController.init, gljMapController.getCompilationList);
+    router.post('/getGljLib', gljMapController.auth, gljMapController.init, gljMapController.getGljLib);
+    router.post('/getAllGljLib', gljMapController.auth, gljMapController.init, gljMapController.getAllGljLib);
+    router.post('/createGljLib', gljMapController.auth, gljMapController.init, gljMapController.createGljLib);
+    router.post('/renameGljLib', gljMapController.auth, gljMapController.init, gljMapController.renameGljLib);
+    router.post('/removeGljLib', gljMapController.auth, gljMapController.init, gljMapController.removeGljLib);
+
+
+    router.post("/createNewGljTypeNode",gljController.auth, gljController.init, gljController.createNewGljTypeNode);
+    router.post("/updateGljNodes",gljController.auth, gljController.init, gljController.updateGljNodes);
+    router.post("/deleteGljNodes",gljController.auth, gljController.init, gljController.deleteGljNodes);
+    router.post("/getGljDistType",gljController.auth, gljController.init, gljController.getGljDistType);
+    router.post("/getGljTree",gljController.auth, gljController.init, gljController.getGljTree);
+    router.post("/getGljItems",gljController.auth, gljController.init, gljController.getGljItems);
+    router.post("/updateComponent",gljController.auth, gljController.init, gljController.updateComponent);
+    router.post("/mixUpdateGljItems",gljController.auth, gljController.init, gljController.mixUpdateGljItems);
+    router.post("/getGljItemsByIds",gljController.auth, gljController.init, gljController.getGljItemsByIds);
+    router.post("/getGljItemsByCodes",gljController.auth, gljController.init, gljController.getGljItemsByCodes);
+
+    app.use("/stdGljRepository/api", router);
+
+};

+ 83 - 45
modules/users/controllers/version_controller.js

@@ -1,21 +1,21 @@
 /**
- * 版本控制控制器
+ * 编办控制控制器
  *
  * @author CaiAoLin
  * @date 2017/7/28
- * @version
+ * @compilation
  */
 import BaseController from "../../common/base/base_controller";
-import VersionModel from "../models/version_model";
+import CompilationModel from "../models/compilation_model";
 import STDRationLibMapModel from "../../common/std/std_ration_lib_map_model";
 import STDBillLibListsModel from "../../common/std/std_bills_lib_lists_model";
-import {default as ProvinceConst, List as ProvinceList} from "../../common/const/province_const";
+import STDGLJLibMapModel from "../../common/std/std_glj_lib_map_model";
 import {default as EngineeringConst, List as EngineeringList} from "../../common/const/engineering";
 
-class VersionController extends BaseController {
+class CompilationController extends BaseController {
 
     /**
-     * 版本控制页面
+     * 编办管理控制页面
      *
      * @param {object} request
      * @param {object} response
@@ -24,25 +24,25 @@ class VersionController extends BaseController {
     async index(request, response) {
         let id = request.query.id;
 
-        let versionList = [];
-        let selectedVersion = {};
+        let compilationList = [];
+        let selectedCompilation = {};
         try {
-            let versionModel = new VersionModel();
-            versionList = await versionModel.getVersionList();
+            let compilationModel = new CompilationModel();
+            compilationList = await compilationModel.getCompilationList();
 
-            if (versionList.length <= 0) {
+            if (compilationList.length <= 0) {
                 throw '没有数据';
             }
             // 循环查找数据
-            for (let tmp of versionList) {
+            for (let tmp of compilationList) {
                 if (tmp._id.toString() === id) {
-                    selectedVersion = tmp;
+                    selectedCompilation = tmp;
                     break;
                 }
             }
 
-            selectedVersion = Object.keys(selectedVersion).length <= 0 ? versionList[0] : selectedVersion;
-            request.session.selectedVersion = selectedVersion;
+            selectedCompilation = Object.keys(selectedCompilation).length <= 0 ? compilationList[0] : selectedCompilation;
+            request.session.selectedCompilation = selectedCompilation;
 
         } catch (error) {
             console.log(error);
@@ -50,12 +50,12 @@ class VersionController extends BaseController {
 
         let renderData = {
             id: id,
-            versionList: versionList,
-            selectedVersion: selectedVersion,
+            compilationList: compilationList,
+            selectedCompilation: selectedCompilation,
             layout: 'users/views/layout/layout'
         };
 
-        response.render('users/views/version/index', renderData);
+        response.render('users/views/compilation/index', renderData);
     }
 
     /**
@@ -83,8 +83,8 @@ class VersionController extends BaseController {
                 name: name,
             };
 
-            let versionModel = new VersionModel();
-            let result = await versionModel.addValuation(id, section, insertData);
+            let compilationModel = new CompilationModel();
+            let result = await compilationModel.addValuation(id, section, insertData);
 
             if (!result) {
                 throw '新增计价规则失败';
@@ -106,29 +106,34 @@ class VersionController extends BaseController {
      * @return {void}
      */
     async editValuation(request, response) {
-        let selectedVersion = request.session.selectedVersion;
+        let selectedCompilation = request.session.selectedCompilation;
         let valuationId = request.params.id;
         let section = request.params.section;
 
         let billList = {};
         let rationList = {};
-        let versionList = [];
+        let compilationList = [];
         let valuationData = {};
         let valuationList = {};
+        let gljList = [];
         try {
-            let versionModel = new VersionModel();
-            versionList = await versionModel.getVersionList();
+            let compilationModel = new CompilationModel();
+            compilationList = await compilationModel.getCompilationList();
 
             // 获取标准清单
             let stdBillLibListsModel = new STDBillLibListsModel();
-            billList = await stdBillLibListsModel.getBillList();
+            billList = await stdBillLibListsModel.getBillList(selectedCompilation._id);
 
             // 获取定额库
             let stdRationLibMapModel = new STDRationLibMapModel();
-            rationList = await stdRationLibMapModel.getRationLib();
+            rationList = await stdRationLibMapModel.getRationLib(selectedCompilation._id);
+
+            // 获取工料机库
+            let stdGLJLibMapModel = new STDGLJLibMapModel();
+            gljList = await stdGLJLibMapModel.getGLJLibList(selectedCompilation._id);
 
             // 获取对应的计价规则数据
-            [valuationData, valuationList] = await versionModel.getValuation(selectedVersion._id, valuationId, section);
+            [valuationData, valuationList] = await compilationModel.getValuation(selectedCompilation._id, valuationId, section);
             if (Object.keys(valuationData).length <= 0) {
                 throw '不存在数据';
             }
@@ -138,19 +143,20 @@ class VersionController extends BaseController {
         }
 
         let renderData = {
-            versionList: versionList,
+            compilationList: compilationList,
             billList: JSON.stringify(billList),
             rationList: JSON.stringify(rationList),
-            province: JSON.stringify(ProvinceList),
+            gljList: JSON.stringify(gljList),
+            mainTreeCol: JSON.stringify(valuationData.main_tree_col),
             engineeringList: EngineeringList,
-            selectedVersion: selectedVersion,
+            selectedCompilation: selectedCompilation,
             valuationData: valuationData,
             valuationList: valuationList,
             valuationId: valuationId,
             section: section,
             layout: 'users/views/layout/layout'
         };
-        response.render('users/views/version/add', renderData);
+        response.render('users/views/compilation/add', renderData);
     }
 
     /**
@@ -167,8 +173,8 @@ class VersionController extends BaseController {
                 throw 'id参数错误';
             }
 
-            let versionModel = new VersionModel();
-            let result = await versionModel.saveValuation(valuationId, request.body);
+            let compilationModel = new CompilationModel();
+            let result = await compilationModel.saveValuation(valuationId, request.body);
 
             if (!result) {
                 throw '保存失败';
@@ -191,15 +197,15 @@ class VersionController extends BaseController {
     async deleteValuation(request, response) {
         let id = request.params.id;
         let section = request.params.section;
-        let selectedVersion = request.session.selectedVersion;
+        let selectedCompilation = request.session.selectedCompilation;
 
         try {
             if (id === undefined || id === '' || section === undefined || section === '') {
                 throw '参数错误';
             }
 
-            let versionModel = new VersionModel();
-            let result = versionModel.deleteValuation(selectedVersion._id, id, section);
+            let compilationModel = new CompilationModel();
+            let result = compilationModel.deleteValuation(selectedCompilation._id, id, section);
 
             if (!result) {
                 throw '删除失败';
@@ -229,11 +235,43 @@ class VersionController extends BaseController {
             msg: ''
         };
         try {
-            let versionModel = new VersionModel();
-            let result = await versionModel.switchEnable(id, section, enable);
+            let compilationModel = new CompilationModel();
+            let result = await compilationModel.switchEnable(id, section, enable);
+
+            if (!result) {
+                throw '新增编办失败';
+            }
+        } catch (error) {
+            console.log(error);
+            responseData.err = 1;
+            responseData.msg = error;
+        }
+
+        response.json(responseData);
+    }
+
+    /**
+     * 发布/取消编办
+     *
+     * @param {object} request
+     * @param {object} response
+     * @return {void}
+     */
+    async release(request, response) {
+        let id = request.body.id;
+        let release = request.body.status;
+        release = parseInt(release);
+
+        let responseData = {
+            err: 0,
+            msg: ''
+        };
+        try {
+            let compilationModel = new CompilationModel();
+            let result = await compilationModel.release(id, release);
 
             if (!result) {
-                throw '新增版本失败';
+                throw '发布编办失败';
             }
         } catch (error) {
             console.log(error);
@@ -245,13 +283,13 @@ class VersionController extends BaseController {
     }
 
     /**
-     * 新增版本操作
+     * 新增编办操作
      *
      * @param {object} request
      * @param {object} response
      * @return {void}
      */
-    async addVersion(request, response) {
+    async addCompilation(request, response) {
         let name = request.body.name;
         let responseData = {
             err: 0,
@@ -264,11 +302,11 @@ class VersionController extends BaseController {
                 creator: sessionManager.userID
             };
 
-            let versionModel = new VersionModel();
-            let result = await versionModel.add(insertData);
+            let compilationModel = new CompilationModel();
+            let result = await compilationModel.add(insertData);
 
             if (!result) {
-                throw '新增版本失败';
+                throw '新增编办失败';
             }
         } catch (error) {
             console.log(error);
@@ -281,4 +319,4 @@ class VersionController extends BaseController {
 
 }
 
-export default VersionController;
+export default CompilationController;

+ 74 - 25
modules/users/models/version_model.js

@@ -1,14 +1,14 @@
 /**
- * 版本管理业务逻辑模型
+ * 编办管理业务逻辑模型
  *
  * @author CaiAoLin
  * @date 2017/7/28
  * @version
  */
 import BaseModel from "../../common/base/base_model";
-import VersionSchema from "./schemas/version";
+import CompilationSchema from "./schemas/compilation";
 
-class VersionModel extends BaseModel {
+class CompilationModel extends BaseModel {
 
     /**
      * 允许的块
@@ -24,22 +24,22 @@ class VersionModel extends BaseModel {
      */
     constructor() {
         let parent = super();
-        parent.model = VersionSchema;
+        parent.model = CompilationSchema;
         parent.init();
     }
 
     /**
-     * 获取版本列表
+     * 获取编办列表
      *
      * @return {Promise}
      */
-    async getVersionList() {
+    async getCompilationList() {
         // 筛选字段
-        let field = {_id: 1, name: 1, "ration_valuation._id": 1, "ration_valuation.name": 1, "ration_valuation.enable": 1,
+        let field = {_id: 1, name: 1, is_release: 1, "ration_valuation._id": 1, "ration_valuation.name": 1, "ration_valuation.enable": 1,
             "bill_valuation._id": 1, "bill_valuation.name": 1, "bill_valuation.enable": 1};
-        let versionData = await this.findDataByCondition({name: {$ne: ''}}, field, false);
+        let compilationData = await this.findDataByCondition({name: {$ne: ''}}, field, false);
 
-        return versionData === null ? [] : versionData;
+        return compilationData === null ? [] : compilationData;
     }
 
     /**
@@ -60,7 +60,7 @@ class VersionModel extends BaseModel {
     }
 
     /**
-     * 新增版本
+     * 新增编办
      *
      * @param {Object} data
      * @return {Promise}
@@ -87,8 +87,8 @@ class VersionModel extends BaseModel {
      */
     async addValuation(id, section, data) {
         let condition = {_id: id};
-        let versionData = await this.findDataByCondition(condition);
-        if (versionData === null || versionData.name === undefined) {
+        let compilationData = await this.findDataByCondition(condition);
+        if (compilationData === null || compilationData.name === undefined) {
             throw '没有找到对应的数据';
         }
 
@@ -122,8 +122,10 @@ class VersionModel extends BaseModel {
         let updateData = {};
         updateData[sectionString + ".$.bill_lib"] = data.bill_lib;
         updateData[sectionString + ".$.ration_lib"] = data.ration_lib;
+        updateData[sectionString + ".$.glj_lib"] = data.glj_lib;
         updateData[sectionString + ".$.name"] = data.name;
         updateData[sectionString + ".$.engineering"] = data.engineering;
+        updateData[sectionString + ".$.main_tree_col"] = JSON.parse(data.main_tree_col);
 
         let result = await this.db.update(condition, updateData);
 
@@ -183,7 +185,7 @@ class VersionModel extends BaseModel {
         for(let tmp in data.bill_lib) {
             data.bill_lib[tmp] = JSON.parse(data.bill_lib[tmp]);
         }
-        // 判断定额清单
+        // 判断定额
         if (data.ration_lib === undefined || data.ration_lib === '') {
             throw '判断标准清单不能为空';
         }
@@ -192,37 +194,46 @@ class VersionModel extends BaseModel {
             data.ration_lib[tmp] = JSON.parse(data.ration_lib[tmp]);
         }
 
+        // 判断工料机库
+        if (data.glj_lib === undefined || data.glj_lib === '') {
+            throw '判断工料机库不能为空';
+        }
+        data.glj_lib = data.glj_lib instanceof Array ? data.glj_lib : [data.glj_lib];
+        for(let tmp in data.glj_lib) {
+            data.glj_lib[tmp] = JSON.parse(data.glj_lib[tmp]);
+        }
+
         return data;
     }
 
     /**
      * 获取计价规则数据
      *
-     * @param {String} versionId
+     * @param {String} compilationId
      * @param {String} id
      * @param {String} section
      * @return {Promise|Array}
      */
-    async getValuation(versionId, id, section) {
+    async getValuation(compilationId, id, section) {
         if (this.sectionList.indexOf(section) < 0) {
             throw '数据有误';
         }
-        let versionData = await this.findDataByCondition({_id: versionId});
-        if (Object.keys(versionData).length <= 0) {
-            throw '版本数据有误';
+        let compilationData = await this.findDataByCondition({_id: compilationId});
+        if (Object.keys(compilationData).length <= 0) {
+            throw '编办数据有误';
         }
         let result = {};
         let sectionString = section + '_valuation';
 
-        for(let valuation of versionData[sectionString]) {
+        for(let valuation of compilationData[sectionString]) {
             if (valuation._id.toString() === id) {
                 result = valuation;
                 break;
             }
         }
 
-        return [result, versionData[sectionString]];
-        /* 数据库获取版本
+        return [result, compilationData[sectionString]];
+        /* 数据库获取编办
         let condition = {_id: versionId};
         let childCondition = {};
         childCondition[sectionString] = {$elemMatch: {_id: id}};
@@ -236,13 +247,13 @@ class VersionModel extends BaseModel {
     /**
      * 删除计价规则
      *
-     * @param {String} versionId
+     * @param {String} compilationId
      * @param {String} valuationId
      * @param {String} section
      * @return {Promise}
      */
-    async deleteValuation(versionId, valuationId, section) {
-        let condition = {_id: versionId};
+    async deleteValuation(compilationId, valuationId, section) {
+        let condition = {_id: compilationId};
         let sectionString = section + '_valuation';
         let deleteData = {};
         deleteData[sectionString] = {_id: valuationId};
@@ -253,6 +264,44 @@ class VersionModel extends BaseModel {
         return result !== null && result.ok === 1;
     }
 
+    /**
+     * 发布编办
+     *
+     * @param {String} id
+     * @param {Number} status
+     * @return {Promise}
+     */
+    async release(id, status) {
+        // 如果是发布编办则需要判断配置的内容是否满足发布条件
+        if (status) {
+            let compilationData = await this.findDataByCondition({_id: id});
+            // 最少需要有一个计价规则存在
+            if (compilationData.bill_valuation.length <= 0 && compilationData.ration_valuation.length <= 0) {
+                throw '至少需要一个计价规则';
+            }
+
+            // 判断是否全部禁止
+            let hasEnable = false;
+            let valuationList = compilationData.bill_valuation.concat(compilationData.ration_valuation);
+            for (let valuation of valuationList) {
+                if (valuation.enable) {
+                    hasEnable = true;
+                    break;
+                }
+            }
+
+            if (!hasEnable) {
+                throw '至少需要一个可用的计价规则';
+            }
+        }
+
+        let updateData = {
+            is_release: status === 1,
+            release_time: new Date().getTime()
+        };
+        return this.updateById(id, updateData);
+    }
+
 }
 
-export default VersionModel;
+export default CompilationModel;

+ 23 - 4
modules/users/models/schemas/version.js

@@ -1,5 +1,5 @@
 /**
- * 版本管理数据模型
+ * 编办管理数据模型
  *
  * @author CaiAoLin
  * @date 2017/7/28
@@ -8,7 +8,7 @@
 import mongoose from "mongoose";
 
 let Schema = mongoose.Schema;
-let collectionName = 'version';
+let collectionName = 'compilation';
 let childrenSchema = new Schema({
     // 计价名称
     name: String,
@@ -27,6 +27,11 @@ let childrenSchema = new Schema({
         type: Schema.Types.Mixed,
         default: []
     },
+    // 工料机库
+    glj_lib: {
+        type: Schema.Types.Mixed,
+        default: []
+    },
     // 是否启用
     enable: {
         type: Boolean,
@@ -35,6 +40,17 @@ let childrenSchema = new Schema({
     // 类型
     type: {
         type: Number
+    },
+    // 列设置
+    main_tree_col: {
+        type: Schema.Types.Mixed,
+        default: {
+            "emptyRows":3,
+            "headRows":0,
+            "treeCol": 0,
+            "headRowHeight":[],
+            "cols":[]
+        }
     }
 });
 let modelSchema = {
@@ -63,8 +79,11 @@ let modelSchema = {
     create_time: Number,
     // 创建者id
     creator: String,
-    // 最后修改时间
-    update_time: Number
+    // 发布时间
+    release_time: {
+        type: Number,
+        default: 0
+    }
 };
 let model = mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));
 export {model as default, collectionName as collectionName};

+ 27 - 0
modules/users/routes/compilation_route.js

@@ -0,0 +1,27 @@
+/**
+ * 版本管理路由
+ *
+ * @author CaiAoLin
+ * @date 2017/7/28
+ * @version
+ */
+import Express from "express";
+import CompilationController from "../controllers/compilation_controller";
+
+const router = Express.Router();
+const compilationController = new CompilationController();
+
+module.exports = function (app) {
+    // action定义区域
+    router.get('/', compilationController.auth, compilationController.init, compilationController.index);
+    router.get('/valuation/:section/:id', compilationController.auth, compilationController.init, compilationController.editValuation);
+    router.get('/valuation/:section/delete/:id', compilationController.auth, compilationController.init, compilationController.deleteValuation);
+
+    router.post('/release', compilationController.auth, compilationController.init, compilationController.release);
+    router.post('/add', compilationController.auth, compilationController.init, compilationController.addCompilation);
+    router.post('/add-valuation', compilationController.auth, compilationController.init, compilationController.addValuation);
+    router.post('/save-valuation', compilationController.auth, compilationController.init, compilationController.saveValuation);
+    router.post('/valuation/:section/enable', compilationController.auth, compilationController.init, compilationController.enableSwitch);
+
+    app.use("/compilation", router);
+};

+ 0 - 25
modules/users/routes/version_route.js

@@ -1,25 +0,0 @@
-/**
- * 版本管理路由
- *
- * @author CaiAoLin
- * @date 2017/7/28
- * @version
- */
-import Express from "express";
-import VersionController from "../controllers/version_controller";
-
-const router = Express.Router();
-const versionController = new VersionController();
-
-module.exports =function (app) {
-    // action定义区域
-    router.get('/', versionController.auth, versionController.init, versionController.index);
-    router.get('/valuation/:section/:id', versionController.auth, versionController.init, versionController.editValuation);
-    router.get('/valuation/:section/delete/:id', versionController.auth, versionController.init, versionController.deleteValuation);
-    router.post('/add', versionController.auth, versionController.init, versionController.addVersion);
-    router.post('/add-valuation', versionController.auth, versionController.init, versionController.addValuation);
-    router.post('/save-valuation', versionController.auth, versionController.init, versionController.saveValuation);
-    router.post('/valuation/:section/enable', versionController.auth, versionController.init, versionController.enableSwitch);
-
-    app.use("/version", router);
-};

+ 1 - 0
public/counter/counter.js

@@ -29,6 +29,7 @@ const COUNTER_MODULE_NAME = {
     unitPriceFile: 'unitPriceFile',
     unitPriceGLJ: 'unitPriceGLJ',
     template_bills: 'temp_bills',
+    stdGljLib: 'stdGljLib',
     billsLib: 'billsLib',
     billsLib_jobs: 'billsLib_jobs',
     billsLib_items: 'billsLib_items',

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

@@ -94,7 +94,12 @@ var sheetCommonObj = {
         var me = this, ch = GC.Spread.Sheets.SheetArea.viewport;
         sheet.suspendPaint();
         sheet.suspendEvent();
-        sheet.setRowCount(data.length + 5);
+        if(typeof setting.owner !== 'undefined' && setting.owner === 'gljComponent'){
+            sheet.setRowCount(data.length + 5);
+        }
+        else{
+            sheet.setRowCount(typeof repositoryGljObj !== 'undefined' && repositoryGljObj.currentOprParent === 1 ? data.length : data.length + 5);
+        }
         for (var col = 0; col < setting.header.length; col++) {
             var hAlign = "left", vAlign = "center";
             if (setting.header[col].hAlign) {
@@ -118,6 +123,7 @@ var sheetCommonObj = {
                 }
                 else {
                     sheet.setValue(row, col, data[row][setting.header[col].dataCode], ch);
+                    sheet.setTag(row, 0, data[row].ID, ch);
                 }
             }
         }
@@ -152,6 +158,7 @@ var sheetCommonObj = {
         return rst;
     },
     combineRowData: function(sheet, setting, row, repositoryGljObj) {
+        let me = this;
         var rst = {};
         let comboBoxCellType = sheet.getCellType(row, 5);
         let items = comboBoxCellType.items();
@@ -173,16 +180,20 @@ var sheetCommonObj = {
                         isExist = false;
                         for(let i=0; i< gljList.length; i++){
                             if(gljList[i].code === sheet.getValue(row, col) && sheet.getValue(row, col)!== orgCode){
+                                me.lockAllCells(sheet);
                                 $('#alertText').text("输入的编号已存在,请重新输入!");
                                 $('#codeAlertBtn').click();
-                                sheet.options.isProtected = true;
                                 $('#codAleConfBtn').click(function () {
-                                    sheet.options.isProtected = false;
+                                   // me.reLockSomeCodes(sheet, 0, repositoryGljObj.currentCache.length);
+                                    me.unLockAllCells(sheet);
+                                    me.reLockSomeCodes(sheet, 0, repositoryGljObj.currentCache.length);
                                     sheet.setValue(row, 0, orgCode);
                                     sheet.setActiveCell(row, 0);
                                 });
                                 $('#codAleClose').click(function () {
-                                    sheet.options.isProtected = false;
+                                    //me.reLockSomeCodes(sheet, 0, repositoryGljObj.currentCache.length);
+                                    me.unLockAllCells(sheet);
+                                    me.reLockSomeCodes(sheet, 0, repositoryGljObj.currentCache.length);
                                     sheet.setValue(row, 0, orgCode);
                                     sheet.setActiveCell(row, 0);
                                 });
@@ -217,6 +228,61 @@ var sheetCommonObj = {
     unShieldAllCells: function(sheet) {
         sheet.options.isProtected = false;
     },
+    reLockSomeCodes: function (sheet, beginRow, endRow) {
+        sheet.suspendPaint();
+        sheet.suspendEvent();
+        let defaultStyle = new GC.Spread.Sheets.Style();
+        defaultStyle.locked = false;
+        sheet.setDefaultStyle(defaultStyle, GC.Spread.Sheets.SheetArea.viewport);
+        let unLockStyle = new GC.Spread.Sheets.Style();
+        unLockStyle.locked = false;
+        let lockStyle = new GC.Spread.Sheets.Style();
+        lockStyle.locked = true;
+        for(let row = beginRow; row < endRow; row++){
+            sheet.setStyle(row, 0, lockStyle);
+        }
+        for(let row = endRow; row < sheet.getRowCount(); row++){
+            sheet.setStyle(row, 0, unLockStyle);
+        }
+        sheet.options.isProtected = true;
+        sheet.resumePaint();
+        sheet.resumeEvent();
+    },
+    unLockAllCells: function (sheet) {
+        let defaultStyle = new GC.Spread.Sheets.Style();
+        defaultStyle.locked = false;
+        sheet.setDefaultStyle(defaultStyle, GC.Spread.Sheets.SheetArea.viewport);
+        sheet.setStyle(-1, 0, defaultStyle);
+        sheet.options.isProtected = false;
+    },
+    lockAllCells: function (sheet) {
+        sheet.suspendPaint();
+        sheet.suspendEvent();
+        let defaultStyle = new GC.Spread.Sheets.Style();
+        defaultStyle.locked = true;
+        sheet.setDefaultStyle(defaultStyle, GC.Spread.Sheets.SheetArea.viewport);
+        for(let i = 0; i < sheet.getRowCount(); i++){
+            sheet.setStyle(i, 0, defaultStyle);
+        }
+        sheet.options.isProtected = true;
+        sheet.resumePaint();
+        sheet.resumeEvent();
+    },
+    lockSomeCodes: function (sheet, beginRow, endRow) {
+        let defaultStyle = new GC.Spread.Sheets.Style();
+        defaultStyle.locked = false;
+        sheet.setDefaultStyle(defaultStyle, GC.Spread.Sheets.SheetArea.viewport);
+        let style = new  GC.Spread.Sheets.Style();
+        style.locked = true;
+        sheet.suspendPaint();
+        sheet.suspendEvent();
+        for(let i = beginRow; i < endRow; i++){
+            sheet.setStyle(i, 0, style);
+        }
+        sheet.options.isProtected = true;
+        sheet.resumePaint();
+        sheet.resumeEvent();
+    },
     lockCodeCells: function (sheet, rowCount) {
         let sheetRowCount = sheet.getRowCount();
         let defaultStyle = new GC.Spread.Sheets.Style();
@@ -225,10 +291,14 @@ var sheetCommonObj = {
         let style = new GC.Spread.Sheets.Style();
         style.locked = true;
         sheet.setStyle(-1, 0, style);
-        for(let i =rowCount -1; i<sheetRowCount; i++){
+        sheet.suspendPaint();
+        sheet.suspendEvent();
+        for(let i =rowCount; i<sheetRowCount; i++){
             sheet.setStyle(i, -1, style);
         }
         sheet.options.isProtected = true;
+        sheet.resumePaint();
+        sheet.resumeEvent();
     },
     lockCells: function(sheet, setting){
         if (setting && setting.view.lockColumns && setting.view.lockColumns.length > 0) {

+ 22 - 18
public/web/sheet/sheet_data_helper.js

@@ -40,25 +40,29 @@ var SheetDataHelper = {
         return spread;
     },
     loadSheetHeader: function (setting, sheet) {
-        sheet.setColumnCount(setting.cols.length);
         sheet.setRowCount(setting.headRows, GC.Spread.Sheets.SheetArea.colHeader);
-        setting.headRowHeight.forEach(function (rowHeight, index) {
-            sheet.setRowHeight(index, rowHeight, GC.Spread.Sheets.SheetArea.colHeader);
-        })
-        setting.cols.forEach(function (col, index) {
-            var i, iRow = 0, cell;
-            for (i = 0; i < col.head.spanCols.length; i++) {
-                if (col.head.spanCols[i] !== 0) {
-                    cell = sheet.getCell(iRow, index, GC.Spread.Sheets.SheetArea.colHeader);
-                    cell.value(col.head.titleNames[i]).font(col.head.font).hAlign(col.head.hAlign[i]).vAlign(col.head.vAlign[i]);
-                }
-                if (col.head.spanCols[i] > 1 || col.head.spanRows[i] > 1) {
-                    sheet.addSpan(iRow, index, col.head.spanRows[i], col.head.spanCols[i], GC.Spread.Sheets.SheetArea.colHeader);
-                }
-                iRow += col.head.spanRows[i];
-            };
-            sheet.setColumnWidth(index, col.width);
-        });
+        if (setting.headRowHeight) {
+            setting.headRowHeight.forEach(function (rowHeight, index) {
+                sheet.setRowHeight(index, rowHeight, GC.Spread.Sheets.SheetArea.colHeader);
+            });
+        }
+        if (setting.cols) {
+            sheet.setColumnCount(setting.cols.length);
+            setting.cols.forEach(function (col, index) {
+                var i, iRow = 0, cell;
+                for (i = 0; i < col.head.spanCols.length; i++) {
+                    if (col.head.spanCols[i] !== 0) {
+                        cell = sheet.getCell(iRow, index, GC.Spread.Sheets.SheetArea.colHeader);
+                        cell.value(col.head.titleNames[i]).font(col.head.font).hAlign(col.head.hAlign[i]).vAlign(col.head.vAlign[i]);
+                    }
+                    if (col.head.spanCols[i] > 1 || col.head.spanRows[i] > 1) {
+                        sheet.addSpan(iRow, index, col.head.spanRows[i], col.head.spanCols[i], GC.Spread.Sheets.SheetArea.colHeader);
+                    }
+                    iRow += col.head.spanRows[i];
+                };
+                sheet.setColumnWidth(index, col.width);
+            });
+        }
     },
     protectdSheet: function (sheet) {
         var option = {

+ 18 - 6
web/maintain/ration_repository/dinge.html

@@ -14,7 +14,9 @@
     <!--zTree-->
   	<link rel="stylesheet" href="/lib/ztree/css/zTreeStyle.css" type="text/css">
     <link rel="stylesheet" href="/lib/spreadjs/sheets/css/gc.spread.sheets.excel2013lightGray.10.0.1.css" type="text/css">
-
+    <style type="text/css">
+        .ztree li span.button.add{margin-right:2px;background-position:-144px 0;vertical-align:top;*vertical-align:middle}
+    </style>
 </head>
 
 <body>
@@ -44,11 +46,11 @@
         <div class="content">
             <div class="container-fluid">
                 <div class="row">
-                  <div class="main-side col-lg-3 p-0">
+                  <div class="main-side col-lg-3 p-0" style="width: 100%; height: 100%; overflow: auto">
                       <div class="tab-bar">
-                          <a onclick="zTreeOprObj.addRootNode()" class="btn btn-secondary btn-sm">增加根节点</a>
+                          <a id="addRootA" onclick="zTreeOprObj.addRootNode()" class="btn btn-secondary btn-sm">增加根节点</a>
                       </div>
-                    <div class="tab-content" style="width: 100%; height: 100%; overflow: auto">
+                    <div class="tab-content">
                       <ul id="rationChapterTree" class="ztree"></ul>
                     </div>
                   </div>
@@ -516,6 +518,13 @@
                 },
                 edit: {
                     enable: true,
+                    drag: {
+                        isCopy: false,
+                        isMove: true,
+                        inner: true,
+                        prev: true,
+                        next: true
+                    },
                     editNameSelectAll: true,
                     showRemoveBtn: true,
                     showRenameBtn: true,
@@ -525,7 +534,7 @@
                 data: {
                     keep: {
                         parent:true,
-                        leaf:true
+                        leaf:false
                     },
                     key: {
                         children: "items"
@@ -542,7 +551,10 @@
                     beforeRename: zTreeOprObj.beforeRename,
                     beforeRemove: zTreeOprObj.onBeforeRemove,
                     onRemove: zTreeOprObj.onRemove,
-                    onRename: zTreeOprObj.onRename
+                    onRename: zTreeOprObj.onRename,
+                    beforeDrop: zTreeOprObj.beforeDrop,
+                    onDrop: zTreeOprObj.onDrop,
+
                 }
             };
             $(document).ready(function(){

+ 3 - 0
web/maintain/ration_repository/gongliao.html

@@ -12,6 +12,9 @@
     <link rel="stylesheet" href="/lib/spreadjs/sheets/css/gc.spread.sheets.excel2013lightGray.10.0.1.css" type="text/css">
     <!--zTree-->
   	<link rel="stylesheet" href="/lib/ztree/css/zTreeStyle.css" type="text/css">
+    <style type="text/css">
+        .ztree li span.button.add{margin-right:2px;background-position:-144px 0;vertical-align:top;*vertical-align:middle}
+    </style>
 </head>
 
 <body>

+ 26 - 4
web/maintain/ration_repository/js/main.js

@@ -2,6 +2,7 @@
  * Created by Syusuke on 2017/3/17.
  */
 $(function(){
+    getCompilationList();
     getRationLibs();
 })
 
@@ -62,6 +63,27 @@ $("#deleteLib").click(function(){
 
 
 });
+function getCompilationList(){
+    $.ajax({
+        type: 'post',
+        url: 'api/getCompilationList',
+        dataType: 'json',
+        success: function (result) {
+            //addoptions
+            for(let i = 0; i < result.data.length; i++){
+               let $option =  $("<option >"+ result.data[i].name +"</option>");
+                $option.val( result.data[i]._id);
+                $('#compilationSels').append($option);
+            }
+            $('#compilationSels').on("change", function () {
+
+               console.log(this.selectedOptions);
+               console.log(this.selectedOptions[0].text);
+               console.log(this.selectedOptions[0].value);
+            });
+        }
+    });
+}
 function getRationLibs(){
     $.ajax({
         type:"POST",
@@ -72,7 +94,7 @@ function getRationLibs(){
         success:function(result){
             $("tbody tr").html("");
             for(var i=0;i<result.data.length;i++){
-                addLibTag(result.data[i].dispName, result.data[i].ID);
+                addLibTag(result.data[i].dispName, result.data[i].ID, result.data[i].createDate);
                 storageUtil.setSessionCache("RationGrp","repositoryID_" + result.data[i].ID, result.data[i].dispName);
             }
             addEvent_Addressdirect();
@@ -85,7 +107,7 @@ function getRationLibs(){
     })
 }
 
-function addLibTag(string, ID){
+function addLibTag(string, ID, date){
     var $tr = $('<tr><td><a href="#"></a></td><td></td><td><a href="javacript:void(0);" data-toggle="modal" data-target="#edit" title="编辑"><i class="fa fa-pencil-square-o"></i></a> <a href="javacript:void(0);" data-toggle="modal"     data-target="#del" class="text-danger" title="删除"><i class="fa fa-remove"></i></a></td><td style="display:none"></td></tr>')
     var $td0 = $("td:eq(0)",$tr);
     var $td1 = $("td:eq(1)",$tr);
@@ -94,8 +116,8 @@ function addLibTag(string, ID){
     var str = string;
     a.text(str);
     $tdId.text(ID);
-    var date = new Date().Format("yyyy-MM-dd");
-    $td1.text(date);
+    var newDate = date.split(' ')[0];
+    $td1.text(newDate);
     $tr.appendTo("tbody");
 }
 

+ 7 - 5
web/maintain/ration_repository/js/ration.js

@@ -72,8 +72,12 @@ var rationOprObj = {
         if(!(args.sheetArea === GC.Spread.Sheets.SheetArea.colHeader || args.sheetArea === GC.Spread.Sheets.SheetArea.corner)){
             var cacheSection = me.getCache();
             if (cacheSection && args.row < cacheSection.length) {
-                rationGLJOprObj.getGljItems(cacheSection[args.row]);
-                rationCoeOprObj.getCoeItems(cacheSection[args.row]);
+                rationGLJOprObj.getGljItems(cacheSection[args.row], function () {
+                    me.workBook.focus(true);
+                });
+                rationCoeOprObj.getCoeItems(cacheSection[args.row], function () {
+                    me.workBook.focus(true);
+                });
                 rationAssistOprObj.getAssItems(cacheSection[args.row]);
             }
         };
@@ -437,9 +441,7 @@ var rationOprObj = {
                         return rst;
                     });
                     me.showRationItems(me.currentSectionId);
-                   /* me.workBook.getSheet(0).setActiveCell(me.activeCell.row, me.activeCell.col);
-                    let spreadBook = new GC.Spread.Sheets.Workbook(rationOprObj.sheet, { sheetCount: 1 });
-                    spreadBook.focus(true);*/
+                    me.workBook.getSheet(0).setActiveCell(me.activeCell.row, me.activeCell.col);
                 }
             },
             error:function(){

+ 2 - 1
web/maintain/ration_repository/js/ration_coe.js

@@ -163,7 +163,7 @@ var rationCoeOprObj = {
         };
     },
 
-    getCoeItems: function(ration) {
+    getCoeItems: function(ration, callback) {
         var me = this;
         me.curRation = ration;
 
@@ -198,6 +198,7 @@ var rationCoeOprObj = {
                         me.showCoeItems(ration.ID);
                     }
                     sheetCommonObj.lockCells(me.sheet, me.setting);
+                    callback();
                 },
                 error:function(err){
                     alert(err);

+ 52 - 43
web/maintain/ration_repository/js/ration_glj.js

@@ -56,9 +56,7 @@ var rationGLJOprObj = {
                 distTypeTree.comboDatas.push({text: distTypeObj.data.fullName, value: distTypeObj.data.ID});
             }
         });
-        //me.distTypeTree = distTypeTree;
         return distTypeTree;
-        //return distTypeTree.comboDatas;
     },
     getGljDistType: function (callback) {
         let me = this;
@@ -69,8 +67,6 @@ var rationGLJOprObj = {
             success: function (result) {
                 if(!result.error && callback){
                     me.distTypeTree = me.getDistTypeTree(result.data);
-                    console.log(`me.distTypeTree`);
-                    console.log(me.distTypeTree);
                     callback();
                 }
             }
@@ -92,22 +88,17 @@ var rationGLJOprObj = {
     rationGljDelOpr: function () {
         let me = rationGLJOprObj, spreadBook = me.sheet.getParent();
         spreadBook.commandManager().register('rationGljDelete', function () {
-            console.log(me.cache["_GLJ_" + me.currentRationItem.ID]);
             let sels = me.sheet.getSelections(), updateArr = [], removeArr = [], lockCols = me.setting.view.lockColumns;
             let cacheSection = me.cache["_GLJ_" + me.currentRationItem.ID], isUpdate = false;
-            console.log(`sels`);
-            console.log(sels);
             if(sels.length > 0){
                 for(let sel = 0; sel < sels.length; sel++){
                     if(sels[sel].colCount === me.setting.header.length){
                         if(cacheSection){
                             for(let i = 0; i < sels[sel].rowCount; i++){
                                 if(sels[sel].row + i < cacheSection.length){
-                                    //removeArr.push(cacheSection[sels[sel].row + i].ID);
                                     isUpdate = true;
                                     cacheSection.splice(sels[sel].row + i, 1);
                                     me.updateRationItem();
-                                    //me.rationsCodes.splice(me.rationsCodes.indexOf(cacheSection[sels[sel].row + i].code), 1);
                                 }
                             }
                         }
@@ -125,7 +116,6 @@ var rationGLJOprObj = {
                             });
                         }
                         else if(sels[sel].col !== 0 && sels[sel].col !== 5 && !(sels[sel].col === 1 && sels.col + sels[sel].colCount -1 === 3)){
-                            console.log(`enter`);
                             if(cacheSection){
                                 for(let i = sels[sel].row === -1 ? 1 : 0; i < sels[sel].rowCount; i++){
                                     if(sels[sel].row + i < cacheSection.length){
@@ -137,7 +127,6 @@ var rationGLJOprObj = {
                                             }
                                         }
                                     }
-                                    //updateArr.push(cacheSection[sels[sel].row + i]);
                                 }
                             }
                         }
@@ -250,7 +239,7 @@ var rationGLJOprObj = {
             }
         } else {
             //重新更新工料机
-            if (args.editingText == null || args.editingText.trim() == "") {
+            /*if (args.editingText == null || args.editingText.trim() == "") {
                 //delete
                 if (me.cache["_GLJ_" + me.currentRationItem.ID]) {
                     var cacheArr = me.cache["_GLJ_" + me.currentRationItem.ID];
@@ -261,12 +250,13 @@ var rationGLJOprObj = {
                         me.showGljItems(me.currentRationItem.ID);
                     }
                 }
-            } else {
+            } else*/
+            if(args.editingText !== null && args.editingText.trim().length !== 0){
                 var repId = storageUtil.getSessionCache("RationGrp","repositoryID");
                 if (repId) {
                     var codes = [];
                     codes.push(args.editingText.trim());
-                    me.addGljItems(codes, repId);
+                    me.addGljItems(codes, repId, args);
                 }
             }
         }
@@ -286,7 +276,7 @@ var rationGLJOprObj = {
         });
     },
 
-    addGljItems: function(codes, repId) {
+    addGljItems: function(codes, repId, args) {
         var me = this;
         $.ajax({
             type:"POST",
@@ -296,38 +286,56 @@ var rationGLJOprObj = {
             cache:false,
             timeout:5000,
             success:function(result){
-                sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
+                //sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
                 if (result) {
-                    var rstArr = [], dummyR = {gljId: 0, consumeAmt:0}, newAddArr = [];
-                    for (var i = 0; i < result.data.length; i++) {
-                        dummyR.gljId = result.data[i].ID;
-                        rstArr.push(me.createRationGljDisplayItem(dummyR, result.data[i]));
-                    }
-                    if (me.cache["_GLJ_" + me.currentRationItem.ID]) {
-                        var cacheArr = me.cache["_GLJ_" + me.currentRationItem.ID];
-                        for (var i = 0; i < rstArr.length; i++) {
-                            var hasDup = false;
-                            for (var j = 0; j < cacheArr.length; j++) {
-                                if (cacheArr[j].gljId == rstArr[i].gljId) {
-                                    hasDup = true;
-                                    break;
+                    if(result.data.length > 0){
+                        sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
+                        var rstArr = [], dummyR = {gljId: 0, consumeAmt:0}, newAddArr = [];
+                        for (var i = 0; i < result.data.length; i++) {
+                            dummyR.gljId = result.data[i].ID;
+                            rstArr.push(me.createRationGljDisplayItem(dummyR, result.data[i]));
+                        }
+                        if (me.cache["_GLJ_" + me.currentRationItem.ID]) {
+                            var cacheArr = me.cache["_GLJ_" + me.currentRationItem.ID];
+                            for (var i = 0; i < rstArr.length; i++) {
+                                var hasDup = false;
+                                for (var j = 0; j < cacheArr.length; j++) {
+                                    if (cacheArr[j].gljId == rstArr[i].gljId) {
+                                        hasDup = true;
+                                        break;
+                                    }
+                                }
+                                if (!hasDup) {
+                                    newAddArr.push(rstArr[i]);
                                 }
                             }
-                            if (!hasDup) {
-                                newAddArr.push(rstArr[i]);
-                            }
+                            me.cache["_GLJ_" + me.currentRationItem.ID] = cacheArr.concat(newAddArr);
+                            me.cache["_GLJ_" + me.currentRationItem.ID].sort(function(a, b) {
+                                var rst = 0;
+                                if (a.code > b.code) rst = 1
+                                else if (a.code < b.code) rst = -1;
+                                return rst;
+                            });
+                        }
+                        me.showGljItems(me.currentRationItem.ID);
+                        if (newAddArr.length > 0) {
+                            me.updateRationItem();
                         }
-                        cacheArr.sort(function(a, b) {
-                            var rst = 0;
-                            if (a.code > b.code) rst = 1
-                            else if (a.code < b.code) rst = -1;
-                            return rst;
-                        });
-                        me.cache["_GLJ_" + me.currentRationItem.ID] = cacheArr.concat(newAddArr);
                     }
-                    me.showGljItems(me.currentRationItem.ID);
-                    if (newAddArr.length > 0) {
-                        me.updateRationItem();
+                    else{
+                        $('#alertModalBtn').click();
+                        $('#alertText').text("工料机"+ codes + "不存在,请查找你所需要的工料机,或新增工料机");
+                        me.sheet.options.isProtected = true;
+                        $('#alertModalCls').click(function () {
+                            sheetCommonObj.lockCells(me.sheet, me.setting);
+                            me.showGljItems(me.currentRationItem.ID);
+                            args.sheet.setValue(args.row, args.col, '');
+                        });
+                        $('#alertModalCof').click(function () {
+                            sheetCommonObj.lockCells(me.sheet, me.setting);
+                            me.showGljItems(me.currentRationItem.ID);
+                           args.sheet.setValue(args.row, args.col, '');
+                        })
                     }
                 }
                 sheetCommonObj.lockCells(me.sheet, me.setting);
@@ -429,7 +437,7 @@ var rationGLJOprObj = {
         rst.gljType = repGlj.gljType;
         return rst;
     },
-    getGljItems: function(rationItem) {
+    getGljItems: function(rationItem, callback) {
         var me = this, rationID = rationItem.ID, rationGljList = rationItem.rationGljList;
         me.currentRationItem = rationItem;
         if (me.cache["_GLJ_" + rationID]) {
@@ -476,6 +484,7 @@ var rationGLJOprObj = {
                         me.showGljItems(rationID);
                     }
                     sheetCommonObj.lockCells(me.sheet, me.setting);
+                    callback();
                 },
                 error:function(err){
                     alert(err);

+ 187 - 39
web/maintain/ration_repository/js/repository_glj.js

@@ -26,8 +26,9 @@ var pageOprObj = {
             repositoryGljObj.getRationGljIds(rationLibId);
             repositoryGljObj.getGljDistType(function () {
                 repositoryGljObj.currentRepositoryId = parseInt(rationLibId);
-                repositoryGljObj.getGljTree(rationLibId);
-                repositoryGljObj.getGljItems(rationLibId);
+                repositoryGljObj.getGljTree(rationLibId, function () {
+                    repositoryGljObj.getGljItems(rationLibId);
+                });
                 sheetCommonObj.shieldAllCells(repositoryGljObj.workBook.getSheet(0), repositoryGljObj.setting);
             });
         }
@@ -86,11 +87,11 @@ var pageOprObj = {
             }
         });
         distTypeTree.distTypesArr.forEach(function (distTypeObj) {
-            if(distTypeObj.children.length === 0 && distTypeObj.data.fullName !== '普通机械' &&distTypeObj.data.fullName !== '机械组成物'
+            /*if(distTypeObj.children.length === 0 && distTypeObj.data.fullName !== '普通机械' &&distTypeObj.data.fullName !== '机械组成物'
             && distTypeObj.data.fullName !== '机上人工'){
                 distTypeTree.comboDatas.push({text: distTypeObj.data.fullName, value: distTypeObj.data.ID});
-            }
-            if(distTypeObj.data.fullName === '机械'){
+            }*/
+            if(distTypeObj.data.fullName !== '材料'){
                 distTypeTree.comboDatas.push({text: distTypeObj.data.fullName, value: distTypeObj.data.ID});
             }
         });
@@ -115,7 +116,7 @@ var pageOprObj = {
             }
         })
     },
-    getGljTree: function(rationLibId) {
+    getGljTree: function(rationLibId, callback) {
         var me = this;
         $.ajax({
             type:"POST",
@@ -132,6 +133,7 @@ var pageOprObj = {
                     } else {
                         gljTypeTreeOprObj.addRootNode();
                     }
+                    callback();
                 }
             },
             error:function(err){
@@ -153,7 +155,12 @@ var pageOprObj = {
                     me.gljList = result.data;
                     me.workBook.getSheet(0).setRowCount(result.data.length);
                     me.sortGlj();
-                    me.showGljItems(result.data, me.gljCurTypeId);
+                    let rootNode = me.treeObj.getNodes()[0];
+                    if(rootNode && rootNode.isParent && rootNode.isFirstNode){
+                        me.treeObj.selectNode(rootNode);
+                        gljTypeTreeOprObj.onClick(null, 'repositoryTree', rootNode);
+                    }
+                    //me.showGljItems(result.data, me.gljCurTypeId);
                 }
             },
             error:function(err){
@@ -176,17 +183,19 @@ var pageOprObj = {
             }
             sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
             sheetCommonObj.showData(me.workBook.getSheet(0), me.setting, cacheSection, me.distTypeTree);
+
             cacheSection = null;
         }
     },
     buildSheet: function(container) {
         var me = repositoryGljObj;
         me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30, me);
+        me.repositoryGljDelOpr();
         me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
         me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditStarting, me.onCellEditStart);
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
-        me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.RangeChanged, me.onRangeChanged);
+        //me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.RangeChanged, me.onRangeChanged);
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EnterCell, me.onEnterCell);
     },
      onEnterCell: function (sender, args) {
@@ -228,17 +237,24 @@ var pageOprObj = {
                  }
                  else {
                     $('#gljAlertBtn').click();
-                     me.workBook.getSheet(0).options.isProtected = true;
+                     //me.workBook.getSheet(0).options.isProtected = true;
+                     sheetCommonObj.lockAllCells(args.sheet);
                      $('#aleCanceBtn').click(function () {
-                         me.workBook.getSheet(0).options.isProtected = false;
+                        // me.workBook.getSheet(0).options.isProtected = false;
+                         sheetCommonObj.unLockAllCells(args.sheet);
+                         sheetCommonObj.reLockSomeCodes(args.sheet, 0, repositoryGljObj.currentCache.length);
                          me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
                      });
                      $('#gljAleClose').click(function () {
-                         me.workBook.getSheet(0).options.isProtected = false;
+                        // me.workBook.getSheet(0).options.isProtected = false;
+                         sheetCommonObj.unLockAllCells(args.sheet);
+                         sheetCommonObj.reLockSomeCodes(args.sheet, 0, repositoryGljObj.currentCache.length);
                          me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
                      });
                      $('#aleConfBtn').click(function () {
-                         me.workBook.getSheet(0).options.isProtected = false;
+                        // me.workBook.getSheet(0).options.isProtected = false;
+                         sheetCommonObj.unLockAllCells(args.sheet);
+                         sheetCommonObj.reLockSomeCodes(args.sheet, 0, repositoryGljObj.currentCache.length);
                          me.addGljObj = null;
                          for(let col=0; col<me.setting.header.length; col++){
                              let field = me.setting.header[col].dataCode;
@@ -277,8 +293,6 @@ var pageOprObj = {
             updateArr = [], addArr = [], updateBasePrcArr = [];
         me.editingRowIdx = args.row;
         rObj.basePrice = rObj.basePrice ? rObj.basePrice : 0;
-        console.log(`rObj`);
-        console.log(rObj);
         if (me.currentEditingGlj["ID"]) {
             rObj["ID"] = me.currentEditingGlj["ID"];
             rObj.gljClass = me.currentEditingGlj.gljClass;
@@ -334,13 +348,125 @@ var pageOprObj = {
             me.mixUpdateRequest(updateArr, addArr, []);
         }
     },
+     repositoryGljDelOpr: function () {
+        let me = repositoryGljObj;
+         me.workBook.commandManager().register('repositoryGljDel', function () {
+             let sheet = me.workBook.getSheet(0),
+                 updateArr = [], removeArr = [],
+                 tempRemoveArr= [],
+                 refGljCodes = [], //已被引用的工料机
+                 updateBasePrcArr = [],//删除基价单位后重新计算
+                 sels = sheet.getSelections(),
+                 cacheSection = me.currentCache;
+             if(sels.length > 0 && cacheSection.length > 0){
+                 for(let i = 0; i < sels.length; i++){
+                     if(sels[i].colCount === me.setting.header.length){
+                         for(let j = 0; j < sels[i].rowCount; j++){
+                             if(sels[i].row + j < cacheSection.length){
+                                 tempRemoveArr.push({ID: cacheSection[sels[i].row + j].ID, code: cacheSection[sels[i].row + j].code});
+                             }
+                         }
+                     }
+                     else{
+                         let maxCol = sels[i].col + sels[i].colCount - 1;
+                         if(sels[i].col >= 2 && maxCol <= 4){
+                             for(let j = 0; j < sels[i].rowCount; j++){
+                                 if(sels[i].row + j < cacheSection.length){
+                                     let updateObj = cacheSection[sels[i].row + j];
+                                     for(let col = sels[i].col; col <= maxCol; col++){
+                                         if(me.setting.header[col].dataCode === 'basePrice'){
+                                             updateObj[me.setting.header[col].dataCode] = 0;
+                                             updateBasePrcArr.push({gljId: updateObj.ID, gljType: updateObj.gljType, basePrice: 0});
+                                         }
+                                         else{
+                                             updateObj[me.setting.header[col].dataCode] = '';
+                                         }
+                                     }
+                                     updateArr.push(updateObj);
+                                 }
+                             }
+                         }
+                         //编号、名称、类型不可为空
+                         else{
+                             if(sels[i].row < cacheSection.length){
+                                 let text = '', cantNullStr =['编码', '名称', '类型'];
+                                 for(let col = sels[i].col; col <= sels[i].col + sels[i].colCount -1; col++){
+                                     if(cantNullStr.indexOf(me.setting.header[col].headerName) !== -1){
+                                         text += me.setting.header[col].headerName + " ";
+                                     }
+                                 }
+                                 $('#alertText').text(text + "不可为空!");
+                                 $('#codeAlertBtn').click();
+                                 sheet.options.isProtected = true;
+                                 $('#codAleConfBtn').click(function () {
+                                     sheetCommonObj.lockSomeCodes(sheet, 0, cacheSection.length);
+                                 });
+                                 $('#codAleClose').click(function () {
+                                     sheetCommonObj.lockSomeCodes(sheet, 0, cacheSection.length);
+                                 });
+                             }
+                         }
+                     }
+                 }
+                 //提取已被引用工料机
+                 if(tempRemoveArr.length > 0){
+                     for(let i = 0; i < tempRemoveArr.length; i++){
+                         if(me.rationGljIds.indexOf(tempRemoveArr[i].ID) !== -1){
+                             refGljCodes.push(tempRemoveArr[i].code);
+                             tempRemoveArr.splice(i--, 1);
+                         }
+                         else{
+                             removeArr.push(tempRemoveArr[i].ID);
+                         }
+                     }
+                 }
+                 //提示
+                 if(refGljCodes.length > 0){
+                     let alertText;
+                     if(refGljCodes.length > 3){
+                         alertText = "编号: " + refGljCodes[0]+" 、" + refGljCodes[1] + " 、" + refGljCodes[2] + "...等工料机已有定额引用,删除失败!";
+                     }
+                     else {
+                         let alertCode = " ";
+                         for(let i=0; i< refGljCodes.length; i++){
+                             alertCode += refGljCodes[i] + " 、";
+                         }
+                         alertText = "编号:" + alertCode + "工料机已有定额引用,删除失败!"
+                     }
+                     $('#alertText').text(alertText);
+                     $('#codeAlertBtn').click();
+                     sheet.options.isProtected = true;
+                     $('#codAleConfBtn').click(function () {
+                         sheetCommonObj.lockSomeCodes(sheet, 0, cacheSection.length);
+                         if(removeArr.length > 0){
+                             me.mixUpdateRequest(updateArr, [], removeArr);
+                         }
+                     });
+                     $('#codAleClose').click(function () {
+                         sheetCommonObj.lockSomeCodes(sheet, 0, cacheSection.length);
+                         me.mixUpdateRequest(updateArr, [], removeArr);
+                     });
+                 }
+                 else if(removeArr.length > 0 || updateArr.length > 0){
+                     me.mixUpdateRequest(updateArr, [], removeArr);
+                     if(updateBasePrcArr.length > 0){
+                         me.updateRationBasePrcRq(updateBasePrcArr);
+                     }
+                 }
+             }
+
+         });
+
+        me.workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
+        me.workBook.commandManager().setShortcutKey('repositoryGljDel', GC.Spread.Commands.Key.del, false, false, false, false);
+     },
      onRangeChanged: function(sender, args) {
          if (args.action == GC.Spread.Sheets.RangeChangedAction.clear) {
              var me = repositoryGljObj, updateArr = [], removeArr = [], cancelArr = [], isMisCode = true;
              var cacheSection = me.currentCache;
              if (cacheSection) {
                  for (var i = 0; i < args.rowCount; i++) {
-                     var hasUpdate = false, rObj = sheetCommonObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row + i),
+                     let rObj = sheetCommonObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row + i),
                          isEmpty = sheetCommonObj.chkIfEmpty(rObj, me.setting);
                      if(isEmpty){
                          if(args.row + i < cacheSection.length){
@@ -710,6 +836,9 @@ var pageOprObj = {
                     }
                     else{
                         me.currentCache = me.getCache();
+                        //sheetCommonObj.unLockAllCells(me.workBook.getSheet(0));
+                        sheetCommonObj.reLockSomeCodes(me.workBook.getSheet(0), 0, me.currentCache.length);
+                        //sheetCommonObj.lockSomeCodes(me.workBook.getSheet(0), 0, me.currentCache.length);
                     }
                     me.showGljItems(me.gljList, me.gljCurTypeId);
                 }
@@ -796,17 +925,22 @@ var gljTypeTreeOprObj = {
             gljTypeId = treeNode.ID;
         me.gljCurTypeId = treeNode.ID;
         //me.currentCache = me.getCache();
-        me.showGljItems(me.gljList, gljTypeId);
         if (me.parentNodeIds["_pNodeId_" + treeNode.ID]) {
             me.currentOprParent = 1;
             me.currentCache = me.getParentCache(me.parentNodeIds["_pNodeId_" + treeNode.ID]);
-            sheetCommonObj.lockCodeCells(me.workBook.getSheet(0), me.gljList.length);
+            sheetCommonObj.lockCodeCells(me.workBook.getSheet(0), me.currentCache.length);
+            me.workBook.getSheet(0).setRowCount(me.currentCache.length);
             //sheetCommonObj.shieldAllCells(me.workBook.getSheet(0), me.setting);
         } else {
             me.currentOprParent = 0;
             me.currentCache = me.getCache();
-            sheetCommonObj.unShieldAllCells(me.workBook.getSheet(0));
+            //sheetCommonObj.unShieldAllCells(me.workBook.getSheet(0));
+            /*sheetCommonObj.unLockAllCells(me.workBook.getSheet(0));
+            sheetCommonObj.lockSomeCodes(me.workBook.getSheet(0), 0, me.currentCache.length);*/
+            sheetCommonObj.unLockAllCells(me.workBook.getSheet(0));
+            sheetCommonObj.reLockSomeCodes(me.workBook.getSheet(0), 0, me.currentCache.length);
         }
+        me.showGljItems(me.gljList, gljTypeId);
     },
     beforeRename: function(treeId, treeNode, newName, isCancel) {
         if (newName.length == 0) {
@@ -820,6 +954,7 @@ var gljTypeTreeOprObj = {
         gljTypeTreeOprObj.updateNodes(nodes);
     },
     onBeforeRemove: function(treeId, treeNode){
+        let me = this;
         if (treeNode.ParentID == -1 && treeNode.isFirstNode) {
             alert("不允许删除全部!");
             return false;
@@ -929,29 +1064,42 @@ var gljTypeTreeOprObj = {
         })
     },
     addHoverDom: function(treeId, treeNode) {
-        var me = repositoryGljObj, sObj = $("#" + treeNode.tId + "_span");
-        if (treeNode.editNameFlag || $("#addBtn_"+treeNode.tId).length>0) return;
-        var addStr = "<span class='button add' id='addBtn_" + treeNode.tId + "' title='新增子节点' onfocus='this.blur();'></span>";
-        sObj.after(addStr);
-        var btn = $("#addBtn_"+treeNode.tId);
-        if (btn) btn.bind("click", function(){
-            var rawNode = {ParentID: treeNode.ID, NextSiblingID: -1, Name: "新增子节点"}, lastNodeId = -1;
-            if (treeNode.items.length > 0) {
-                lastNodeId = treeNode.items[treeNode.items.length - 1].ID;
-            }
-            gljTypeTreeOprObj.addNewNode(rawNode, lastNodeId, function(err, rst){
-                if (!(err)) {
-                    var newNodes = [], isSilent = false;
-                    newNodes.push({ repositoryId: rst.data.repositoryId, ID: rst.data.ID, ParentID: rst.data.ParentID, NextSiblingID:-1, Name:"新增子节点",isParent:false, items:[]});
-                    treeNode.isParent = true;
-                    if (me.treeObj) {
-                        me.treeObj.addNodes(treeNode, -1, newNodes, isSilent);
-                    } else {
-                        me.treeObj = $.fn.zTree.init($("#rationChapterTree"), gljSetting, newNodes);
-                    }
+        if(typeof treeNode.doing !== 'undefined' && treeNode.doing){
+            return false;
+        }
+        hoverOpr();
+        function hoverOpr(){
+            //console.log(treeNode);
+            var me = repositoryGljObj, sObj = $("#" + treeNode.tId + "_span");
+            if (treeNode.editNameFlag || $("#addBtn_"+treeNode.tId).length>0) return;
+            var addStr = "<span class='button add' id='addBtn_" + treeNode.tId + "' title='新增子节点' onfocus='this.blur();'></span>";
+            sObj.after(addStr);
+            var btn = $("#addBtn_"+treeNode.tId);
+            if (btn) btn.bind("click", function(){
+                treeNode.doing = true;
+                var rawNode = {ParentID: treeNode.ID, NextSiblingID: -1, Name: "新增子节点"}, lastNodeId = -1;
+                if (treeNode.items.length > 0) {
+                    lastNodeId = treeNode.items[treeNode.items.length - 1].ID;
                 }
+                gljTypeTreeOprObj.addNewNode(rawNode, lastNodeId, function(err, rst){
+                    if (!(err)) {
+                        var newNodes = [], isSilent = false;
+                        if(treeNode.items.length > 0){
+                            treeNode.items[treeNode.items.length - 1].NextSiblingID = rst.data.ID;
+                        }
+                        newNodes.push({ repositoryId: rst.data.repositoryId, ID: rst.data.ID, ParentID: rst.data.ParentID, NextSiblingID:-1, Name:"新增子节点",isParent:false, items:[]});
+                        treeNode.isParent = true;
+                        if (me.treeObj) {
+                            me.treeObj.addNodes(treeNode, -1, newNodes, isSilent);
+                        } else {
+                            me.treeObj = $.fn.zTree.init($("#rationChapterTree"), gljSetting, newNodes);
+                        }
+                        treeNode.doing = false;
+                        hoverOpr();
+                    }
+                });
             });
-        });
+        }
     },
     removeHoverDom: function(treeId, treeNode) {
         $("#addBtn_"+treeNode.tId).unbind().remove();

+ 155 - 27
web/maintain/ration_repository/js/section_tree.js

@@ -43,6 +43,8 @@ var zTreeOprObj = {
         })
     },
     addRootNode: function() {
+        $('#addRootA').css("opacity", "0.2");
+        $('#addRootA').addClass("disabled");
         var me = zTreeOprObj, rawNode = {ParentID: -1, NextSiblingID: -1, name: "新增节点"}, lastNodeId = -1;
         if (me.treeObj) {
             var rootNodes = me.treeObj.getNodes();
@@ -52,13 +54,18 @@ var zTreeOprObj = {
         }
         me.addNewNode(rawNode, lastNodeId, function(err, rst){
             if (!(err)) {
+                if(rootNodes.length > 0){
+                    rootNodes[rootNodes.length - 1].NextSiblingID = rst.data.ID;
+                }
                 var newNodes = [], isSilent = false;
-                newNodes.push({ rationRepId: rst.data.rationRepId, ID: rst.data.ID, ParentID:-1, NextSiblingID:-1, name:"新增节点",isParent:false, items:[]});
+                newNodes.push({ rationRepId: rst.data.rationRepId, Previous_ID: lastNodeId, ID: rst.data.ID, ParentID:-1, NextSiblingID:-1, name:"新增节点",isParent:false, items:[]});
                 if (me.treeObj) {
                     me.treeObj.addNodes(null, -1, newNodes, isSilent);
                 } else {
                     me.treeObj = $.fn.zTree.init($("#rationChapterTree"), setting, newNodes);
                 }
+                $('#addRootA').css("opacity", "");
+                $('#addRootA').removeClass("disabled");
             }
         });
     },
@@ -132,7 +139,114 @@ var zTreeOprObj = {
             //me.treeObj.updateNode(pNode, false); //这方法有后遗症,多次操作后会造成节点新增子节点时,父节点icon显示不正确
         }
     },
-    updateNodes: function(nodes){
+    beforeDrop: function (treeId, treeNodes, targetNode, moveType) {
+        let me = zTreeOprObj;
+        if(moveType){
+             me.treeObj.setting.edit.enable = false;
+            let treeNode = treeNodes[0], updateNodes = [];
+            //升级
+            if(treeNode.level !== targetNode.level && moveType === 'prev'){
+                if(treeNode.Previous_ID !== -1){
+                    treeNode.getPreNode().NextSiblingID = treeNode.NextSiblingID;
+                    updateNodes.push(treeNode.getPreNode());
+                }
+                if(treeNode.NextSiblingID !== -1){
+                    treeNode.getNextNode().Previous_ID = treeNode.Previous_ID;
+                }
+                if(targetNode.Previous_ID !== -1){
+                    targetNode.getPreNode().NextSiblingID = treeNode.ID;
+                    updateNodes.push(targetNode.getPreNode());
+                }
+                treeNode.ParentID = targetNode.getParentNode() ? targetNode.getParentNode().ID : -1;
+                treeNode.NextSiblingID = targetNode.ID;
+                treeNode.Previous_ID = targetNode.Previous_ID;
+                targetNode.Previous_ID = treeNode.ID;
+                updateNodes.push(treeNode);
+                //updateNodes.push(targetNode);
+            }
+            //升级
+            else if(treeNode.level !== targetNode.level && moveType === 'next'){
+                if(treeNode.Previous_ID !== -1){
+                    treeNode.getPreNode().NextSiblingID = treeNode.NextSiblingID;
+                    updateNodes.push(treeNode.getPreNode());
+                }
+                if(treeNode.NextSiblingID !== -1){
+                    treeNode.getNextNode().Previous_ID = treeNode.Previous_ID;
+                }
+                if(targetNode.NextSiblingID !== -1){
+                    targetNode.getNextNode().Previous_ID = treeNode.ID;
+                }
+                treeNode.NextSiblingID = targetNode.NextSiblingID;
+                treeNode.Previous_ID = targetNode.ID;
+                treeNode.ParentID = targetNode.getParentNode() ? targetNode.getParentNode().ID : -1;
+                targetNode.NextSiblingID = treeNode.ID;
+                updateNodes.push(treeNode);
+                updateNodes.push(targetNode);
+            }
+            //上移
+            else if(treeNode.level === targetNode.level && moveType === 'prev'){
+                    console.log(1);
+                    if(targetNode.Previous_ID !== -1){
+                        let targetPrev = me.treeObj.getNodeByParam('ID', targetNode.Previous_ID,  null);
+                        targetPrev.NextSiblingID = treeNode.ID;
+                        updateNodes.push(targetPrev);
+                    }
+                    targetNode.NextSiblingID = treeNode.NextSiblingID;
+                    treeNode.NextSiblingID = targetNode.ID;
+                    treeNode.Previous_ID = targetNode.Previous_ID;
+                    targetNode.Previous_ID = treeNode.ID;
+
+                    updateNodes.push(treeNode);
+                    updateNodes.push(targetNode);
+            }
+            //下移
+            else if(treeNode.level === targetNode.level && moveType === 'next'){
+                if(treeNode.Previous_ID !== -1){
+                    let treeNodePrev = me.treeObj.getNodeByParam('ID', treeNode.Previous_ID, null);
+                    treeNodePrev.NextSiblingID = targetNode.ID;
+                    updateNodes.push(treeNodePrev);
+                }
+                treeNode.Previous_ID = targetNode.ID;
+                treeNode.NextSiblingID = targetNode.NextSiblingID;
+                targetNode.Previous_ID = treeNode.Previous_ID;
+                targetNode.NextSiblingID = treeNode.ID;
+                updateNodes.push(treeNode);
+                updateNodes.push(targetNode);
+            }
+            //
+            else if(moveType === 'inner'){
+                if( treeNode.Previous_ID !== -1){
+                    treeNode.getPreNode().NextSiblingID = treeNode.NextSiblingID;
+                    updateNodes.push(treeNode.getPreNode());
+                }
+                if(treeNode.NextSiblingID !== -1){
+                    treeNode.getNextNode().Previous_ID = treeNode.Previous_ID;
+                }
+                if(targetNode.items.length > 0){
+                    targetNode.items[targetNode.items.length -1].NextSiblingID = treeNode.ID;
+                    treeNode.Previous_ID = targetNode.items[targetNode.items.length -1].ID;
+                    updateNodes.push(targetNode.items[targetNode.items.length -1]);
+                }
+                else{
+                    treeNode.Previous_ID = -1;
+                }
+                treeNode.ParentID = targetNode.ID;
+                treeNode.NextSiblingID = -1;
+                updateNodes.push(treeNode);
+
+            }
+            if(updateNodes.length > 0){
+                me.updateNodes(updateNodes, function () {
+                    me.treeObj.setting.edit.enable= true;
+                });
+            }
+        }
+    },
+
+    onDrop: function (event, treeId, treeNodes, targetNode, moveType) {
+
+    },
+    updateNodes: function(nodes, callback){
         if (nodes && nodes.length > 0) {
             var reqData = []
             for (var i = 0; i < nodes.length; i++) {
@@ -146,6 +260,7 @@ var zTreeOprObj = {
                 else node.__v = 0;
                 reqData.push(node);
             }
+            console.log(reqData);
             $.ajax({
                 type:"POST",
                 url:"api/updateNodes",
@@ -154,6 +269,9 @@ var zTreeOprObj = {
                 cache:false,
                 timeout:5000,
                 success:function(result,textStatus,status){
+                    if(callback){
+                        callback();
+                    }
                     console.log(status + ' : ' + result);
                 },
                 error:function(){
@@ -162,33 +280,43 @@ var zTreeOprObj = {
         }
     },
     addHoverDom: function(treeId, treeNode) {
-        var me = zTreeOprObj, sObj = $("#" + treeNode.tId + "_span");
-        if (treeNode.editNameFlag || $("#addBtn_"+treeNode.tId).length>0) return;
-        var addStr = "<span class='button add' id='addBtn_" + treeNode.tId + "' title='新增子节点' onfocus='this.blur();'></span>";
-        sObj.after(addStr);
-        var btn = $("#addBtn_"+treeNode.tId);
-        if (btn) btn.bind("click", function(){
-            var rawNode = {ParentID: treeNode.ID, NextSiblingID: -1, name: "新增子节点"}, lastNodeId = -1, lastNode = null;
-            if (treeNode.items.length > 0) {
-                lastNodeId = treeNode.items[treeNode.items.length - 1].ID;
-                lastNode = treeNode.items[treeNode.items.length - 1];
-            }
-            zTreeOprObj.addNewNode(rawNode, lastNodeId, function(err, rst){
-                if (!(err)) {
-                    var newNodes = [], isSilent = false;
-                    if (lastNode) {
-                        lastNode.NextSiblingID = rst.ID;
-                    }
-                    newNodes.push({ rationRepId: rst.data.rationRepId, ID: rst.data.ID, ParentID: rst.data.ParentID, NextSiblingID:-1, name:"新增子节点",isParent:false, items:[]});
-                    treeNode.isParent = true;
-                    if (me.treeObj) {
-                        me.treeObj.addNodes(treeNode, -1, newNodes, isSilent);
-                    } else {
-                        me.treeObj = $.fn.zTree.init($("#rationChapterTree"), setting, newNodes);
-                    }
+        if(typeof treeNode.doing !== 'undefined' && treeNode.doing){
+            return false;
+        }
+        hoverOpr();
+        function hoverOpr(){
+            var me = zTreeOprObj, sObj = $("#" + treeNode.tId + "_span");
+            if (treeNode.editNameFlag || $("#addBtn_"+treeNode.tId).length>0) return;
+            var addStr = "<span class='button add' id='addBtn_" + treeNode.tId + "' title='新增子节点' onfocus='this.blur();'></span>";
+            sObj.after(addStr);
+            var btn = $("#addBtn_"+treeNode.tId);
+            if (btn) btn.bind("click", function(){
+                treeNode.doing = true;
+                var rawNode = {ParentID: treeNode.ID, NextSiblingID: -1, name: "新增子节点"}, lastNodeId = -1, lastNode = null;
+                if (treeNode.items.length > 0) {
+                    lastNodeId = treeNode.items[treeNode.items.length - 1].ID;
+                    lastNode = treeNode.items[treeNode.items.length - 1];
                 }
+                zTreeOprObj.addNewNode(rawNode, lastNodeId, function(err, rst){
+                    if (!(err)) {
+                        var newNodes = [], isSilent = false;
+                        if (lastNode) {
+                            lastNode.NextSiblingID = rst.ID;
+                        }
+                        newNodes.push({ rationRepId: rst.data.rationRepId, ID: rst.data.ID, Previous_ID: lastNodeId, ParentID: rst.data.ParentID, NextSiblingID:-1, name:"新增子节点",isParent:false, items:[]});
+                        treeNode.isParent = true;
+                        console.log(newNodes);
+                        if (me.treeObj) {
+                            me.treeObj.addNodes(treeNode, -1, newNodes, isSilent);
+                        } else {
+                            me.treeObj = $.fn.zTree.init($("#rationChapterTree"), setting, newNodes);
+                        }
+                    }
+                    treeNode.doing = false;
+                    hoverOpr();
+                });
             });
-        });
+        }
     },
     removeHoverDom: function(treeId, treeNode) {
         $("#addBtn_"+treeNode.tId).unbind().remove();

+ 34 - 2
web/maintain/ration_repository/main.html

@@ -46,7 +46,7 @@
         </div>
     </div>
     <!--弹出添加-->
-    <div class="modal fade" id="add" data-backdrop="static" style="display: none;" aria-hidden="true">
+    <!--<div class="modal fade" id="add" data-backdrop="static" style="display: none;" aria-hidden="true">
         <div class="modal-dialog" role="document">
             <div class="modal-content">
                 <div class="modal-header">
@@ -69,6 +69,38 @@
                 </div>
             </div>
         </div>
+    </div>-->
+    <div class="modal fade" id="add" data-backdrop="static" style="display: none;" aria-hidden="true">
+        <div class="modal-dialog" role="document">
+            <div class="modal-content">
+                <div class="modal-header">
+                    <h5 class="modal-title">添加定额库</h5>
+                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                        <span aria-hidden="true">×</span>
+                    </button>
+                </div>
+                <div class="modal-body">
+                    <form>
+                        <div class="form-group">
+                            <label>定额库名称</label>
+                            <input class="form-control" placeholder="输入定额库名称" type="text">
+                        </div>
+                        <div class="form-group">
+                            <label>编办名称</label>
+                            <select id="compilationSels" class="form-control"></select>
+                        </div>
+                        <div class="form-group">
+                            <label>工料机库</label>
+                            <select id="gljLibSels" class="form-control"></select>
+                        </div>
+                    </form>
+                </div>
+                <div class="modal-footer">
+                    <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
+                    <a href="" class="btn btn-primary">新建</a>
+                </div>
+            </div>
+        </div>
     </div>
     <!--弹出编辑-->
     <div class="modal fade" id="edit" data-backdrop="static" style="display: none;" aria-hidden="true">
@@ -130,7 +162,7 @@
     <script type="text/javascript" src="/public/web/storageUtil.js"></script>
 </body>
 <script type="text/javascript">
-let userAccount = '<%=userAccount %>';
+    let userAccount = '<%=userAccount %>';
 </script>
 
 </html>

+ 279 - 0
web/maintain/std_glj_lib/css/main.css

@@ -0,0 +1,279 @@
+/*building SAAS 0.1*/
+/*bootstrap 初始化*/
+body {
+    font-size: 0.9rem
+}
+.dropdown-menu {
+    font-size: 0.9rem
+}
+/*自定义css*/
+.header {
+    background: #e1e1e1
+}
+.header .header-logo {
+    background: #ff6501;
+    color: #fff;
+    float: left;
+    padding-top: .25rem;
+    padding-bottom: .25rem;
+    margin-right: 1rem;
+    font-size: 1.25rem;
+    line-height: inherit
+}
+.top-msg{
+  position: fixed;
+  top:0;
+  width:100%;
+  z-index: 999
+}
+.in-1{padding-left:0rem!important}
+.in-2{padding-left:1rem!important}
+.in-3{padding-left:1.5rem!important}
+.in-4{padding-left:2rem!important}
+.in-5{padding-left:2.5rem!important}
+.in-6{padding-left:3rem!important}
+.main {
+    position: relative;
+    background: #f7f7f9;
+}
+.main-nav {
+    position: absolute;
+    text-align: center;
+    z-index: 999;
+    padding: 2px 0 0 2px
+}
+.main-nav .nav a {
+    display: block;
+    width: 28px;
+    text-align: center;
+    line-height: 18px;
+    color: #999;
+    padding: 10px 0;
+    border-right: 1px solid #ccc;
+}
+.main-nav .nav a:hover {
+    background: #fff;
+    color: #333;
+    text-decoration: none;
+}
+.main-nav .nav a.active {
+    border: 1px solid #ccc;
+    border-right: 1px solid #fff;
+    background: #fff;
+    color: #333
+}
+.content {
+    background: #fff
+}
+.tools-btn {
+    height: 30px;
+    line-height: 30px;
+}
+.toolsbar .tools-btn.btn:hover {
+    background: #f7f7f9;
+}
+.main-side {
+    border-right: 1px solid #ccc;
+    overflow:hidden;
+}
+.main-side .tab-bar {
+    padding:5px 10px;
+    height:38px;
+    position:fixed;
+}
+.main-side .tab-content {
+    margin-top: 38px
+}
+.top-content, .fluid-content {
+    overflow: hidden;
+    border-bottom: 1px solid #ccc;
+}
+.warp-p2 {
+    padding: 2px
+}
+.bottom-content .nav,.top-content .nav {
+    background: #f7f7f9;
+    padding:0 0 0 2px
+}
+.bottom-content .nav-tabs .nav-link, .side-tabs .nav-tabs .nav-link,.top-content .nav-tabs .nav-link {
+    border-radius: 0;
+    padding: 0.2em 0.5em
+}
+.side-tabs .nav-tabs .nav-item {
+  z-index: 999
+}
+.side-tabs .nav-tabs {
+    border-bottom: none;
+    margin-bottom: -1px
+}
+.side-tabs .nav-tabs .nav-link {
+    border-radius: 0;
+    padding: 0em 0.5em;
+    line-height: 30px;
+    z-index: 999
+}
+.bottom-content .nav-tabs .nav-link.active {
+    border-top: 1px solid #f7f7f9
+}
+.side-tabs .nav-tabs .nav-link.active {
+    border-top: none;
+    border-bottom:1px solid #fff
+}
+.side-tabs a.active, .sub-nav a.active {
+    background: #ccc
+}
+.poj-manage {
+    background: #fff
+}
+.slide-sidebar {
+    border-left: 1px solid #E1E1E1;
+    box-shadow: 0px 15px 15px rgba(0, 0, 0, 0.1);
+    background: none repeat scroll 0% 0% #ffffff;
+    overflow: hidden;
+    position: absolute;
+    right: 0px;
+    top: 0;
+    z-index: 999;
+    width: 0px;
+}
+.new-msg {
+    -webkit-animation: tada 1s infinite .2s ease both;
+    -moz-animation: tada 1s infinite .2s ease both;
+}
+@-webkit-keyframes tada {
+    0% {
+        -webkit-transform: scale(1)
+    }
+    10%, 20% {
+        -webkit-transform: scale(0.9) rotate(-3deg)
+    }
+    30%, 50%, 70%, 90% {
+        -webkit-transform: scale(1.1) rotate(3deg)
+    }
+    40%, 60%, 80% {
+        -webkit-transform: scale(1.1) rotate(-3deg)
+    }
+    100% {
+        -webkit-transform: scale(1) rotate(0)
+    }
+}
+@-moz-keyframes tada {
+    0% {
+        -moz-transform: scale(1)
+    }
+    10%, 20% {
+        -moz-transform: scale(0.9) rotate(-3deg)
+    }
+    30%, 50%, 70%, 90% {
+        -moz-transform: scale(1.1) rotate(3deg)
+    }
+    40%, 60%, 80% {
+        -moz-transform: scale(1.1) rotate(-3deg)
+    }
+    100% {
+        -moz-transform: scale(1) rotate(0)
+    }
+}
+.has-danger {
+    -webkit-animation: shake 1s .2s ease both;
+    -moz-animation: shake 1s .2s ease both;
+    animation: shake 1s .2s ease both;
+}
+@-webkit-keyframes shake {
+    0%, 100% {
+        -webkit-transform: translateX(0);
+    }
+    10%, 30%, 50%, 70%, 90% {
+        -webkit-transform: translateX(-10px);
+    }
+    20%, 40%, 60%, 80% {
+        -webkit-transform: translateX(10px);
+    }
+}
+@-moz-keyframes shake {
+    0%, 100% {
+        -moz-transform: translateX(0);
+    }
+    10%, 30%, 50%, 70%, 90% {
+        -moz-transform: translateX(-10px);
+    }
+    20%, 40%, 60%, 80% {
+        -moz-transform: translateX(10px);
+    }
+}
+@keyframes shake {
+    0%, 100% {
+        transform: translateX(0);
+    }
+    10%, 30%, 50%, 70%, 90% {
+        transform: translateX(-10px);
+    }
+    20%, 40%, 60%, 80% {
+        transform: translateX(10px);
+    }
+}
+.bottom-content {
+    height: 370px;
+    overflow: hidden;
+}
+.bottom-content .tab-content .main-data-bottom{
+    height: 340px;
+    overflow: auto;
+}
+.form-signin {
+    max-width: 500px;
+    margin: 150px auto;
+}
+.poj-list, .side-content {
+    overflow: auto;
+}
+.poj-list span.poj-icon {
+  padding-right:10px;
+  color:#ccc
+}
+.print-toolsbar{
+  padding:5px
+}
+.print-toolsbar .panel {
+  display:inline-block;
+  vertical-align:top;
+  background:#f7f7f9
+}
+.print-toolsbar .panel .panel-foot{
+  text-align: center;
+  font-size: 12px
+}
+.print-list {
+  border-right:1px solid #ccc
+}
+.print-list .form-list {
+  overflow: auto
+}
+.print-list .list-tools{
+  height:50px;
+  padding:10px 0;
+  border-bottom:1px solid #f2f2f2
+}
+.pageContainer {
+  background: #ededed;
+  text-align: center
+}
+.pageContainer .page{
+  border:9px solid transparent;
+  display: inline-block;
+}
+.pageContainer .page img{
+  width:inherit;
+  height: inherit;
+}
+.codeList{
+    max-height: 200px;
+    overflow:auto;
+}
+.main-data-top,.main-data-bottom,.main-data{
+  overflow: hidden;
+}
+.modal-fixed-height {
+    height:400px;
+    overflow-y:auto;
+}

+ 265 - 0
web/maintain/std_glj_lib/html/gongliao.html

@@ -0,0 +1,265 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
+    <meta http-equiv="x-ua-compatible" content="ie=edge">
+    <title>工料机库编辑器</title>
+    <link rel="stylesheet" href="/lib/bootstrap/css/bootstrap.min.css">
+    <link rel="stylesheet" href="/web/maintain/std_glj_lib/css/main.css">
+    <link rel="stylesheet" href="/lib/font-awesome/font-awesome.min.css">
+    <link rel="stylesheet" href="/lib/spreadjs/sheets/css/gc.spread.sheets.excel2013lightGray.10.0.1.css" type="text/css">
+    <style type="text/css">
+        .ztree li span.button.add{margin-right:2px;background-position:-144px 0;vertical-align:top;*vertical-align:middle}
+    </style>
+    <!--zTree-->
+  	<link rel="stylesheet" href="/lib/ztree/css/zTreeStyle.css" type="text/css">
+</head>
+
+<body>
+    <div class="header">
+        <nav class="navbar navbar-toggleable-lg navbar-light bg-faded p-0 ">
+            <span class="header-logo px-2">Smartcost</span>
+            <div class="navbar-text"></div>
+        </nav>
+        <nav class="navbar navbar-toggleable-lg justify-content-between navbar-light p-0">
+              <ul class="nav nav-tabs" role="tablist">
+                  <li class="nav-item">
+                      <a class="nav-link active px-3" href="javascript:void(0);">工料机</a>
+                  </li>
+              </ul>
+        </nav>
+    </div>
+    <div class="main">
+        <div class="content">
+            <div class="container-fluid">
+                <div class="row">
+                  <div class="main-side col-lg-3 p-0" style="width: 100%; height: 100%; overflow-y: auto">
+                        <ul id="repositoryTree" class="ztree"></ul>
+                  </div>
+                  <div class="main-content col-lg-7 p-0">
+                    <div id="GLJListSheet" class="main-data">
+                      <!--<table class="table table-sm table-bordered m-0">
+                      <thead>
+                        <tr>
+                          <th></th>
+                          <th>编码</th>
+                          <th>名称</th>
+                          <th>规格型号</th>
+                          <th>计量单位</th>
+                          <th>单价</th>
+                          <th>类型</th>
+                        </tr>
+                      </thead>
+                      <tbody>
+                        <tr>
+                          <td>1</td>
+                          <td>00010201</td>
+                          <td>土石方综合工日</td>
+                          <td></td>
+                          <td>工日</td>
+                          <td>22.00</td>
+                          <td>人工</td>
+                        </tr>
+                        <tr>
+                          <td>2</td>
+                          <td>03010101</td>
+                          <td>钢材</td>
+                          <td></td>
+                          <td>t</td>
+                          <td>2600.00</td>
+                          <td>材料</td>
+                        </tr>
+                        <tr>
+                          <td>3</td>
+                          <td>36290101</td>
+                          <td>水</td>
+                          <td></td>
+                          <td>m3</td>
+                          <td>2600.00</td>
+                          <td>材料</td>
+                        </tr>
+                        <tr>
+                          <td>4</td>
+                          <td></td>
+                          <td></td>
+                          <td></td>
+                          <td></td>
+                          <td></td>
+                          <td></td>
+                        </tr>
+                        <tr>
+                          <td>5</td>
+                          <td></td>
+                          <td></td>
+                          <td></td>
+                          <td></td>
+                          <td></td>
+                          <td></td>
+                        </tr>
+                        <tr>
+                          <td>6</td>
+                          <td></td>
+                          <td></td>
+                          <td></td>
+                          <td></td>
+                          <td></td>
+                          <td></td>
+                        </tr>
+                      </tbody>
+                    </table>-->
+                    </div>
+                  </div>
+                    <div id="gljComponentSheet" class="main-side col-lg-2 p-0">
+                     <!-- <table class="table table-sm table-bordered m-0">
+                        <thead>
+                          <tr><th></th><th>编码</th><th>名称</th><th>计量单位</th><th>单价</th><th>消耗量</th></tr>
+                        </thead>
+                        <tbody>
+                          <tr><td>1</td><td></td><td></td><td></td><td></td><td></td></tr>
+                          <tr><td>2</td><td></td><td></td><td></td><td></td><td></td></tr>
+                          <tr><td>3</td><td></td><td></td><td></td><td></td><td></td></tr>
+                          <tr><td>4</td><td></td><td></td><td></td><td></td><td></td></tr>
+                        </tbody>
+                      </table>
+                      <table class="table table-sm table-bordered m-0">
+                        <thead>
+                          <tr><th></th><th>编码</th><th>名称</th><th>计量单位</th><th>单价</th><th>消耗量</th></tr>
+                        </thead>
+                        <tbody>
+                          <tr><td>1</td><td>01010101</td><td>水泥32.5</td><td>kg</td><td>0.25</td><td>243.000</td></tr>
+                          <tr><td>2</td><td></td><td></td><td></td><td></td><td></td></tr>
+                          <tr><td>3</td><td></td><td></td><td></td><td></td><td></td></tr>
+                          <tr><td>4</td><td></td><td></td><td></td><td></td><td></td></tr>
+                        </tbody>
+                      </table>
+                      <table class="table table-sm table-bordered m-0">
+                        <thead>
+                          <tr><th></th><th>编码</th><th>名称</th><th>计量单位</th><th>单价</th><th>消耗量</th></tr>
+                        </thead>
+                        <tbody>
+                          <tr><td>1</td><td>xxx</td><td>机上人工</td><td>工日</td><td>28.00</td><td>2.540</td></tr>
+                          <tr><td>2</td><td></td><td></td><td></td><td></td><td></td></tr>
+                          <tr><td>3</td><td></td><td></td><td></td><td></td><td></td></tr>
+                          <tr><td>4</td><td></td><td></td><td></td><td></td><td></td></tr>
+                        </tbody>
+                      </table>-->
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+
+    <button id="gljAlertBtn" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#gljAlert" style="display: none"></button>
+    <button id="codeAlertBtn" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#codeAlert" style="display: none"></button>
+    <div class="modal fade" id="gljAlert" data-backdrop="static" style="display: none;" aria-hidden="true">
+        <input type="hidden" id="gdid" value="123">
+        <div class="modal-dialog" role="document">
+            <div class="modal-content">
+                <div class="modal-header">
+                    <h5 class="modal-title">取消确认</h5>
+                    <button type="button" id="gljAleClose" class="close" data-dismiss="modal" aria-label="Close">
+                        <span aria-hidden="true">×</span>
+                    </button>
+                </div>
+                <div class="modal-body">
+                    <h5 class="text-danger" id="alertGljTxt">编号和类型不可为空!是否取消操作?</h5>
+                </div>
+                <div class="modal-footer">
+                    <button type="button" class="btn btn-secondary" id="aleCanceBtn" data-dismiss="modal">取消</button>
+                    <a href="javascript: void(0);" id="aleConfBtn" class="btn btn-danger" data-dismiss="modal">确认</a>
+                </div>
+            </div>
+        </div>
+    </div>
+    <div class="modal" id="codeAlert" data-backdrop="static" style="display: none;" aria-hidden="true">
+        <input type="hidden" id="codedid" value="123">
+        <div class="modal-dialog" role="document">
+            <div class="modal-content">
+                <div class="modal-header">
+                    <h5 class="modal-title">警告</h5>
+                    <button type="button" id="codAleClose" class="close" data-dismiss="modal" aria-label="Close">
+                        <span aria-hidden="true">×</span>
+                    </button>
+                </div>
+                <div class="modal-body">
+                    <h5 class="text-danger" id="alertText">输入的编号已存在,请重新输入!</h5>
+                </div>
+                <div class="modal-footer">
+                    <button type="button" class="btn btn-danger" id="codAleConfBtn" data-dismiss="modal">确认</button>
+                </div>
+            </div>
+        </div>
+    </div>
+
+    <!-- JS. -->
+    <script src="/lib/jquery/jquery.min.js"></script>
+    <script src="/lib/tether/tether.min.js"></script>
+    <script src="/lib/bootstrap/bootstrap.min.js"></script>
+    <script src="/web/maintain/std_glj_lib/js/global.js"></script>
+    <!-- zTree -->
+    <script src = "/lib/spreadjs/sheets/gc.spread.sheets.all.10.0.1.min.js"></script>
+    <script>GC.Spread.Sheets.LicenseKey = "559432293813965#A0y3iTOzEDOzkjMyMDN9UTNiojIklkI1pjIEJCLi4TPB9mM5AFNTd4cvZ7SaJUVy3CWKtWYXx4VVhjMpp7dYNGdx2ia9sEVlZGOTh7NRlTUwkWR9wEV4gmbjBDZ4ElR8N7cGdHVvEWVBtCOwIGW0ZmeYVWVr3mI0IyUiwCMzETN8kzNzYTM0IicfJye&Qf35VfiEzRwEkI0IyQiwiIwEjL6ByUKBCZhVmcwNlI0IiTis7W0ICZyBlIsIyNyMzM5ADI5ADNwcTMwIjI0ICdyNkIsIibj9SbvNmL4N7bjRnch56ciojIz5GRiwiI8+Y9sWY9QmZ0Jyp96uL9v6L0wap9biY9qiq95q197Wr9g+89iojIh94Wiqi";</script>
+    <script type="text/javascript" src="/lib/ztree/jquery.ztree.core.js"></script>
+    <script type="text/javascript" src="/lib/ztree/jquery.ztree.excheck.js"></script>
+    <script type="text/javascript" src="/lib/ztree/jquery.ztree.exedit.js"></script>
+    <script type="text/javascript" src="/public/web/treeDataHelper.js"></script>
+    <script type="text/javascript" src="/public/web/QueryParam.js"></script>
+    <script type="text/javascript" src="/web/maintain/std_glj_lib/js/glj.js"></script>
+    <script type="text/javascript" src="/web/maintain/std_glj_lib/js/gljComponent.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="/public/web/storageUtil.js"></script>
+    <SCRIPT type="text/javascript">
+        let userAccount = '<%=userAccount %>';
+        var gljSetting = {
+            view: {
+                //addHoverDom: gljTypeTreeOprObj.addHoverDom,
+                //removeHoverDom: gljTypeTreeOprObj.removeHoverDom,
+                expandSpeed: "",
+                selectedMulti: false
+            },
+            edit: {
+                enable: false,
+                editNameSelectAll: true,
+                showRemoveBtn: true,
+                showRenameBtn: true,
+                removeTitle: "删除节点",
+                renameTitle: "更改名称"
+            },
+            data: {
+                keep: {
+                    parent:true,
+                    leaf:true
+                },
+                key: {
+                    children: "items",
+                    name: "Name"
+                },
+                simpleData: {
+                    enable: false,
+                    idKey: "ID",
+                    pIdKey: "ParentID",
+                    rootPId: -1
+                }
+            },
+            callback:{
+                beforeRename: gljTypeTreeOprObj.beforeRename,
+                onRename: gljTypeTreeOprObj.onRename,
+                beforeRemove: gljTypeTreeOprObj.onBeforeRemove,
+                onRemove: gljTypeTreeOprObj.onRemove,
+                onClick: gljTypeTreeOprObj.onClick
+            }
+        };
+        $(document).ready(function(){
+            pageOprObj.initPage($("#GLJListSheet")[0], $('#gljComponentSheet')[0]);
+            //repositoryGljObj.buildSheet($("#GLJListSheet")[0]);
+        });
+  	</SCRIPT>
+</body>
+<script type="text/javascript">
+    autoFlashHeight();
+</script>
+
+</html>

+ 144 - 0
web/maintain/std_glj_lib/html/main.html

@@ -0,0 +1,144 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
+    <meta http-equiv="x-ua-compatible" content="ie=edge">
+    <title>工料机库编辑器</title>
+    <link rel="stylesheet" href="/lib/bootstrap/css/bootstrap.min.css">
+    <link rel="stylesheet" href="/web/maintain/std_glj_lib/css/main.css">
+    <link rel="stylesheet" href="/lib/font-awesome/font-awesome.min.css">
+    <!--zTree-->
+  	<link rel="stylesheet" href="/lib/ztree/css/zTreeStyle.css" type="text/css">
+</head>
+
+<body>
+    <div class="header">
+        <nav class="navbar navbar-toggleable-lg navbar-light bg-faded p-0 ">
+            <span class="header-logo px-2">Smartcost</span>
+            <div class="navbar-text"></div>
+        </nav>
+        <nav class="navbar navbar-toggleable-lg justify-content-between navbar-light p-0">
+          <ul class="nav navbar-nav px-1">
+              <li class="nav-item">
+                  <a class="nav-link" href="javacript:void(0);" aria-haspopup="true" aria-expanded="false" data-toggle="modal" data-target="#add">新建工料机库</a>
+              </li>
+          </ul>
+        </nav>
+    </div>
+    <div class="main">
+        <div class="content">
+            <div class="container-fluid">
+                <div class="row">
+                  <div class="col-md-8">
+                    <div class="warp-p2 mt-3">
+                      <table class="table table-hover table-bordered">
+                        <thead><tr><th>工料机库名称</th><th>编办</th><th>定额库</th><th width="160">添加时间</th><th width="90">操作</th></tr></thead>
+                        <tbody id="showArea">
+                      <!--    <tr><td><a href="gongliao.html">XX工料机库</a></td><td>重庆2018</td><td>XXX定额库(重庆2018)</td><td>2017-01-01 </td><td><a href="javacript:void(0);" data-toggle="modal" data-target="#edit" title="编辑"><i class="fa fa-pencil-square-o"></i></a> <a href="javacript:void(0);" data-toggle="modal" data-target="#del" class="text-danger" title="删除"><i class="fa fa-remove"></i></a></td></tr>
+                          <tr><td><a href="gongliao.html">XX工料机库</a></td><td>重庆2018</td><td></td><td>2017-01-01 </td><td><a href="javacript:void(0);" data-toggle="modal" data-target="#edit" title="编辑"><i class="fa fa-pencil-square-o"></i></a> <a href="javacript:void(0);" data-toggle="modal" data-target="#del" class="text-danger" title="删除"><i class="fa fa-remove"></i></a></td></tr>
+                          <tr><td><a href="gongliao.html">XX工料机库</a></td><td>重庆2018</td><td></td><td>2017-01-01 </td><td><a href="javacript:void(0);" data-toggle="modal" data-target="#edit" title="编辑"><i class="fa fa-pencil-square-o"></i></a> <a href="javacript:void(0);" data-toggle="modal" data-target="#del" class="text-danger" title="删除"><i class="fa fa-remove"></i></a></td></tr>-->
+                        </tbody>
+                      </table>
+                    </div>
+                  </div>
+                </div>
+            </div>
+        </div>
+    </div>
+    <!--弹出添加-->
+    <div class="modal fade" id="add" data-backdrop="static" style="display: none;" aria-hidden="true">
+        <div class="modal-dialog" role="document">
+            <div class="modal-content">
+                <div class="modal-header">
+                  <h5 class="modal-title">添加工料机库</h5>
+                  <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                    <span aria-hidden="true">×</span>
+                  </button>
+                </div>
+                <div class="modal-body">
+                  <form>
+                    <div class="form-group">
+                      <label>工料机名称</label>
+                      <input id="libNameTxt" class="form-control" placeholder="输入工料机库名称" type="text">
+                    </div>
+                    <div class="form-group">
+                      <label>编办名称</label>
+                      <select id="compilationSels" class="form-control"></select>
+                    </div>
+                  </form>
+                </div>
+                <div class="modal-footer">
+                    <button type="button" id="cancelBtn" class="btn btn-secondary" data-dismiss="modal">取消</button>
+                    <a id="addBtn" href="javascript:void(0)" class="btn btn-primary">新建</a>
+                </div>
+            </div>
+        </div>
+    </div>
+    <!--弹出编辑-->
+    <div class="modal fade" id="edit" data-backdrop="static" style="display: none;" aria-hidden="true">
+        <div class="modal-dialog" role="document">
+            <div class="modal-content">
+                <div class="modal-header">
+                  <h5 class="modal-title">编辑工料机库</h5>
+                  <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                    <span aria-hidden="true">×</span>
+                  </button>
+                </div>
+                <div class="modal-body">
+                  <form>
+                    <div class="form-group">
+                      <label>工料机库名称</label>
+                      <input class="form-control" id="renameText" placeholder="输入工料机库名称" type="text" value="">
+                    </div>
+                    <div class="form-group">
+                      <label>编办名称</label>
+                      <select id="compilationEdit" class="form-control" disabled><option></option></select>
+                    </div>
+                  </form>
+                </div>
+                <div class="modal-footer">
+                    <button id="editCancelBtn" type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
+                    <a href="javascript: void(0);"  id="renameA" class="btn btn-primary">确定</a>
+                </div>
+            </div>
+        </div>
+    </div>
+
+    <!--弹出删除-->
+    <div class="modal fade" id="del" data-backdrop="static" style="display: none;" aria-hidden="true">
+        <div class="modal-dialog" role="document">
+            <div class="modal-content">
+                <div class="modal-header">
+                  <h5 class="modal-title">删除确认</h5>
+                  <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                    <span aria-hidden="true">×</span>
+                  </button>
+                </div>
+                <div class="modal-body">
+                    <h5 class="text-danger">删除后无法恢复,确认是否删除?</h5>
+                </div>
+                <div class="modal-footer">
+                    <button id="delCancelBtn" type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
+                    <a id="deleteA" href="javascript: void(0);" class="btn btn-danger">删除</a>
+                </div>
+            </div>
+        </div>
+    </div>
+    <!-- JS. -->
+    <script src="/lib/jquery/jquery.min.js"></script>
+    <script src="/lib/tether/tether.min.js"></script>
+    <script src="/lib/bootstrap/bootstrap.min.js"></script>
+    <script src="/web/maintain/std_glj_lib/js/global.js"></script>
+    <!-- zTree -->
+  	<script type="text/javascript" src="/lib/ztree/jquery.ztree.core.js"></script>
+  	<script type="text/javascript" src="/lib/ztree/jquery.ztree.excheck.js"></script>
+    <script type="text/javascript" src="/web/maintain/std_glj_lib/js/main.js"></script>
+
+</body>
+<script type="text/javascript">
+    let oprtor =  '<%= userAccount %>';
+    autoFlashHeight();
+</script>
+
+</html>

File diff suppressed because it is too large
+ 1069 - 0
web/maintain/std_glj_lib/js/glj.js


+ 370 - 0
web/maintain/std_glj_lib/js/gljComponent.js

@@ -0,0 +1,370 @@
+/**
+ * Created by Zhong on 2017/8/15.
+ */
+
+let gljComponentOprObj = {
+    workBook: null,
+    setting: {
+        owner: "gljComponent",
+        header:[
+            {headerName:"编码",headerWidth:50,dataCode:"code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
+            {headerName:"名称",headerWidth:60,dataCode:"name", dataType: "String", hAlign: "left", vAlign: "center"},
+            {headerName:"计量单位",headerWidth:60,dataCode:"unit", dataType: "String", hAlign: "center", vAlign: "center"},
+            {headerName:"单价",headerWidth:50,dataCode:"basePrice", dataType: "Number", formatter: "0.00", hAlign: "right", vAlign: "center"},
+            {headerName:"消耗量",headerWidth:55,dataCode:"consumeAmt", dataType: "Number", formatter: "0.000", hAlign: "right", vAlign: "center"}
+        ],
+        view: {
+            lockedCells:[1, 2, 3]
+        }
+    },
+    buildSheet: function(container) {
+        var me = gljComponentOprObj;
+        me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30, me);
+        me.workBook.getSheet(0).setColumnWidth(0, 20, GC.Spread.Sheets.SheetArea.rowHeader);
+        me.workBook.getSheet(0).setFormatter(-1, 0, "@", GC.Spread.Sheets.SheetArea.viewport);
+        me.workBook.getSheet(0).options.isProtected = true;
+        sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
+
+        me.gljComponentDelOpr();
+        me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
+        me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
+        me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditStarting, me.onCellEditStart);
+        me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
+       /* me.repositoryGljDelOpr();
+        me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
+        me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
+        me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditStarting, me.onCellEditStart);
+        me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
+        me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EnterCell, me.onEnterCell);*/
+    },
+    getRowData: function (sheet, row, setting) {
+        let rst = {};
+        for(let i = 0; i < setting.header.length; i++){
+            rst[setting.header[i].dataCode] = sheet.getValue(row, i);
+        }
+        return rst;
+    },
+    getComponent: function (sheet, rowCount) {
+        let component = [];
+        for(let row = 0; row < rowCount; row++){
+            let obj = {};
+            obj.consumeAmt = sheet.getValue(row, 4);
+            obj.ID = sheet.getTag(row, 0);
+            component.push(obj);
+        }
+        return component;
+    },
+    gljComponentDelOpr: function () {
+        let me = gljComponentOprObj, that = repositoryGljObj, updateArr = [], removeArr = [], isUpdate = false;
+        me.workBook.commandManager().register('gljComponentDel', function () {
+            let sels = me.workBook.getSheet(0).getSelections();
+            if(sels.length > 0 && that.currentComponent.length > 0){
+                let component = that.currentGlj.component;
+                for(let i = 0; i < sels.length > 0; i++){
+                    if(sels[i].colCount === me.setting.header.length){//可删除
+                        for(let j = 0; j < sels[i].rowCount; j++){
+                            if(sels[i].row + j < that.currentComponent.length){
+                                removeArr.push(that.currentComponent[sels[i].row + j].ID);
+
+                            }
+                        }
+                    }
+                    else if(sels[i].col === 0){
+                            //编码不可为空
+                            alert("编码不可为空!");
+
+                    }
+                    else if(sels[i].col === 4){//消耗量修改为0
+                        if(sels[i].row === -1){//全修改
+                           for(let j = 0; j < that.currentComponent.length; j++){
+                               isUpdate = true;
+                               that.currentComponent[j].consumeAmt = 0;
+                               for(let k = 0; k < component.length; k++){
+                                   if(component[k].ID === that.currentComponent[j].ID){
+                                       component[k].consumeAmt = 0;
+                                       break;
+                                   }
+                               }
+                           }
+                        }
+                        else{//部分修改
+                            for(let j = 0; j < sels[i].rowCount; j++){
+                                if(sels[i].row + j < that.currentComponent.length){
+                                    isUpdate = true;
+                                    that.currentComponent[sels[i].row + j].consumeAmt = 0;
+                                    for(let k = 0; k < component.length; k++){
+                                        if(component[k].ID === that.currentComponent[sels[i].row + j].ID){
+                                            component[k].consumeAmt = 0;
+                                            break;
+                                        }
+                                    }
+
+                                }
+                            }
+                        }
+                    }
+                }
+                if(removeArr.length > 0 || isUpdate){
+                    for(let i = 0; i < removeArr.length; i++){
+                        for(let j = 0; j < that.currentComponent.length; j++){
+                            if(that.currentComponent[j].ID === removeArr[i]){
+                                that.currentComponent.splice(j--, 1);
+                            }
+                        }
+                        for(let j = 0; j < component.length; j++){
+                            if(component[j].ID === removeArr[i]){
+                                component.splice(j--, 1);
+                            }
+                        }
+                    }
+                    //重新计算工料机
+                    let gljBasePrc = me.reCalGljBasePrc(that.currentComponent);
+                    that.currentGlj.basePrice = gljBasePrc;
+                    that.reshowGljBasePrc(that.currentGlj);
+                    updateArr.push(that.currentGlj);
+                    console.log(updateArr);
+                    me.updateComponent(updateArr);
+                }
+            }
+        });
+        me.workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
+        me.workBook.commandManager().setShortcutKey('gljComponentDel', GC.Spread.Commands.Key.del, false, false, false, false);
+    },
+    onCellEditStart: function(sender, args) {
+        let me = gljComponentOprObj, that = repositoryGljObj;
+        let rObj = me.getRowData(args.sheet, args.row, me.setting);
+        me.currentEditingComponent = rObj;
+    },
+    onCellEditEnd: function (sender, args) {
+        let me = gljComponentOprObj, that = repositoryGljObj;
+        let gljList = that.gljList, updateArr = [], materialComponent = [202, 203, 204], machineComponent = [302, 303];
+        if(args.editingText !== me.currentEditingComponent.code){
+            if(args.col === 0 && args.editingText && args.editingText.trim().length > 0){
+                let component = that.currentGlj.component, hasCode = false;
+                for(let i = 0; i < gljList.length; i++){
+                    if(gljList[i].code === args.editingText){//有效的组成物
+                        hasCode = true;
+                        if((materialComponent.indexOf(that.currentGlj.gljType) !== -1 && gljList[i].gljType === 201)
+                            || (that.currentGlj.gljType === 3 && machineComponent.indexOf(gljList[i].gljType) !== -1 )){//普通材料
+                            //是否与原有组成物不同
+                            let isExist = false;
+                            for(let j = 0; j < component.length; j++){
+                                if(component[j].ID === gljList[i].ID){
+                                    isExist = true;
+                                    break;
+                                }
+                            }
+                            if(!isExist){
+                                let rObj = {};
+                                rObj.ID = gljList[i].ID;
+                                //rObj.basePrice = gljList[i].basePrice;
+                                if(typeof that.currentComponent[args.row] !== 'undefined'){
+                                    rObj.consumeAmt = that.currentComponent[args.row].consumeAmt;
+                                    let index;
+                                    for(let j = 0; j < component.length; j++){
+                                        if(component[j].ID === that.currentComponent[args.row].ID){
+                                            index = j;
+                                            break;
+                                        }
+                                    }
+                                    component.splice(index, 1);
+                                    component.splice(index, 0, rObj);
+                                    updateArr.push(that.currentGlj);
+                                }
+                                else{
+                                    rObj.consumeAmt = 0;
+                                    component.push(rObj);
+                                    updateArr.push(that.currentGlj);
+                                }
+                                break;
+                            }
+                            else{
+                                //已存在
+                                alert("已存在!");
+                                args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
+                                    me.currentEditingComponent[me.setting.header[args.col].dataCode]: '');
+                            }
+
+                        }
+                        else{
+                            alert("无效!");
+                            args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
+                                me.currentEditingComponent[me.setting.header[args.col].dataCode]: '');
+                            //无效
+                        }
+                    }
+                }
+                if(!hasCode){
+                    alert("不存在,请添加!");
+                    args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
+                        me.currentEditingComponent[me.setting.header[args.col].dataCode] : '');
+                    //不存在
+                }
+            }
+            else if(args.col === 4 && me.currentEditingComponent.code && args.editingText && args.editingText.trim().length > 0){//消耗量
+                let consumeAmt = parseFloat(args.editingText);
+                if(!isNaN(consumeAmt) && consumeAmt !== me.currentEditingComponent.consumeAmt){
+                    let component = that.currentGlj.component;
+                    for(let i = 0; i < component.length; i++){
+                        if(component[i].ID === that.currentComponent[args.row].ID){
+                            component[i].consumeAmt = consumeAmt
+                        }
+                    }
+                    that.currentComponent[args.row].consumeAmt = consumeAmt;
+                    //计算工料机单价
+                    let gljBasePrc = me.reCalGljBasePrc(that.currentComponent);
+                    that.currentGlj.basePrice = gljBasePrc;
+                    that.reshowGljBasePrc(that.currentGlj);
+                    updateArr.push(that.currentGlj);
+                }
+                else{
+                    //只能输入数值
+                    args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
+                        me.currentEditingComponent[me.setting.header[args.col].dataCode]: 0);
+
+                }
+            }
+            else{
+                args.sheet.setValue(args.row, args.col, '');
+            }
+        }
+        if(updateArr.length > 0){
+            me.updateComponent(updateArr);
+            //保存
+        }
+    },
+    onClipboardPasting: function (sender, info) {
+
+    },
+    onClipboardPasted: function (sender, info) {
+        let me = gljComponentOprObj, that = repositoryGljObj, updateArr = [] ,materialComponent = [202, 203, 204], machineComponent = [302, 303],
+            component = that.currentGlj.component, newComponent = [], concatComponent = [], isChange = false;
+        let items = sheetCommonObj.analyzePasteData(me.setting, info);
+        let gljCache = that.gljList;
+        if(info.cellRange.col === 0){
+            for(let i = 0; i < items.length; i++){
+                for(let j = 0; j < gljCache.length; j++){
+                    if(items[i].code === gljCache[j].code){
+                        if((materialComponent.indexOf(that.currentGlj.gljType) !== -1 && gljCache[j].gljType === 201)
+                            || (that.currentGlj.gljType === 3 && machineComponent.indexOf(gljCache[j].gljType) !== -1 )){
+                            //是否与原有组成物不同
+                            let isExist = false;
+                            for(let k = 0; k < component.length; k++){
+                                if(component[k].ID === gljCache[j].ID){
+                                    isExist = true;
+                                    me.workBook.getSheet(0).setValue(info.cellRange.row + i, info.cellRange.col,
+                                        typeof that.currentComponent[info.cellRange.row + i] !== 'undefined'? that.currentComponent[info.cellRange.row + i].code : '');
+                                    break;
+                                }
+                            }
+                            if(!isExist){
+                                isChange = true;
+                                let obj = {};
+                                obj.ID = gljCache[j].ID;
+                                if(typeof that.currentComponent[info.cellRange.row + i] !== 'undefined'){//更新
+                                    obj.consumeAmt = that.currentComponent[info.cellRange.row + i].consumeAmt;
+                                    let index;
+                                    for(let k = 0; k < component.length; k++){
+                                        if(that.currentComponent[info.cellRange.row + i].ID === component[k].ID){
+                                            index = k;
+                                            break;
+                                        }
+                                    }
+                                    component.splice(index, 1);
+                                    component.splice(index, 0, obj);
+                                }
+                                else{//新增
+                                    obj.consumeAmt = 0;
+                                    component.push(obj);
+                                }
+                                break;
+                            }
+
+                        }
+                        else{
+                            me.workBook.getSheet(0).setValue(info.cellRange.row + i, info.cellRange.col,
+                            typeof that.currentComponent[info.cellRange.row + i] !== 'undefined'? that.currentComponent[info.cellRange.row + i].code : '');
+
+                        }
+
+                    }
+                    else{
+                        me.workBook.getSheet(0).setValue(info.cellRange.row + i, info.cellRange.col,
+                            typeof that.currentComponent[info.cellRange.row + i] !== 'undefined'? that.currentComponent[info.cellRange.row + i].code : '');
+                    }
+                }
+            }
+            if(isChange){
+                updateArr.push(that.currentGlj);
+            }
+        }
+        else if(info.cellRange.col === 4){
+            let items = sheetCommonObj.analyzePasteData(me.setting, info);
+            let row = info.cellRange.row;
+            for(let i = 0; i < items.length; i++){
+                if(row + i < that.currentComponent.length){
+                    let currentObj = that.currentComponent[row + i];
+                    if(items[i].consumeAmt.trim().length > 0 && items[i].consumeAmt !== currentObj.consumeAmt){
+                        isChange = true;
+                        currentObj.consumeAmt = items[i].consumeAmt;
+                        for(let j = 0; j < component.length; j++){
+                            if(component[j].ID === currentObj.ID){
+                                component[j].consumeAmt = currentObj.consumeAmt;
+                                break;
+                            }
+                        }
+                    }
+                    else{
+                        me.workBook.getSheet(0).setValue(row + i, info.cellRange.col, currentObj.consumeAmt);
+                    }
+                }
+                else{
+                    me.workBook.getSheet(0).setValue(row + i, info.cellRange.col, '');
+                }
+            }
+            if(isChange){
+                //计算工料机单价
+                let gljBasePrc = me.reCalGljBasePrc(that.currentComponent);
+                that.currentGlj.basePrice = gljBasePrc;
+                that.reshowGljBasePrc(that.currentGlj);
+                updateArr.push(that.currentGlj);
+            }
+        }
+        if(updateArr.length > 0){
+            me.updateComponent(updateArr);
+        }
+    },
+    updateComponent: function (updateArr) {
+        let me = gljComponentOprObj, that = repositoryGljObj;
+        $.ajax({
+            type: 'post',
+            url: 'api/updateComponent',
+            data: {libId: pageOprObj.gljLibId, updateArr: updateArr, oprtor: userAccount},
+            dataType: 'json',
+            success: function (result) {
+                console.log(result);
+                if(result.data.length > 0){
+                    if(result.data[0]){
+                        that.currentComponent =  that.getCurrentComponent(result.data[0].component);
+                        console.log(that.currentComponent);
+                        sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
+                        sheetCommonObj.showData(me.workBook.getSheet(0), me.setting, that.currentComponent);
+                    }
+                }
+            }
+        })
+    },
+    round: function (v, e) {
+        var t=1;
+        for(;e>0;t*=10,e--);
+        for(;e<0;t/=10,e++);
+        return Math.round(v*t)/t;
+    },
+    reCalGljBasePrc: function (component) {
+        let me = gljComponentOprObj, gljBasePrc = 0;
+        for(let i = 0; i < component.length; i++){
+            gljBasePrc += me.round(component[i].basePrice * component[i].consumeAmt, 2);
+        }
+        return gljBasePrc;
+    }
+};

+ 42 - 0
web/maintain/std_glj_lib/js/global.js

@@ -0,0 +1,42 @@
+/*全局自适应高度*/
+function autoFlashHeight(){
+    var headerHeight = $(".header").height();
+    var bottomContentHeight = $(".bottom-content").height();
+    var toolsBar = $(".tools-bar").height();
+    $(".content").height($(window).height()-headerHeight);
+    $(".main-side").height($(window).height()-headerHeight-2);
+    $(".fluid-content").height($(window).height()-headerHeight-1);
+    $(".side-content").height($(window).height()-headerHeight );
+    $(".poj-list").height($(window).height()-headerHeight);
+    $(".form-list").height($(window).height()-headerHeight-50 );
+    $(".main-data-top").height($(window).height()-headerHeight-toolsBar-bottomContentHeight-2);
+    $(".main-data").height($(window).height()-headerHeight);
+};
+$(window).resize(autoFlashHeight);
+/*全局自适应高度结束*/
+$(function(){
+/*侧滑*/
+$(".open-sidebar").click(function(){
+    $(".slide-sidebar").animate({width:"800"}).addClass("open");
+});
+$("body").click(function(event){
+        var e = event || window.event; //浏览器兼容性
+        if(!$(event.target).is('a')) {
+            var elem = event.target || e.srcElement;
+            while (elem) { //循环判断至跟节点,防止点击的是div子元素
+                if (elem.className == "open-sidebar" || elem.className == 'slide-sidebar open') {
+                    return false;
+                }
+                elem = elem.parentNode;
+            }
+            $(".slide-sidebar").animate({width:"0"}).removeClass("open")// 关闭处理
+        }
+
+    });
+/*侧滑*/
+/*工具提示*/
+$('*[data-toggle=tooltip]').mouseover(function() {
+ $(this).tooltip('show');
+  });
+/*工具提示*/
+});

+ 191 - 0
web/maintain/std_glj_lib/js/main.js

@@ -0,0 +1,191 @@
+/**
+ * Created by Zhong on 2017/8/14.
+ */
+$(function () {
+    let dispNameArr;
+    getAllGljLib(function (dispNames) {
+        dispNameArr = dispNames;
+        //添加
+        $('#addBtn').click(function () {
+            let compilationName = $('#compilationSels option:selected').text();
+            let compilationId = $('#compilationSels option:selected').val();
+            let libName = $('#libNameTxt').val();
+            if(libName.trim().length === 0){
+                alert('名称不可为空!');
+                $('#libNameTxt').val('')
+            }
+            else if(dispNames.indexOf(libName) !== -1){
+                alert('此工料机库已存在!');
+                $('#libNameTxt').val('')
+            }
+            else if(compilationName.trim().length === 0){
+                alert('编办不可为空!');
+            }
+            else{
+                let newGljLib = {};
+                newGljLib.dispName = libName;
+                newGljLib.compilationId = compilationId;
+                newGljLib.compilationName = compilationName;
+                newGljLib.creator = oprtor;
+                newGljLib.appType = "建筑";
+                $('#libNameTxt').val('');
+                createGljLib(newGljLib, dispNameArr);
+            }
+        });
+        //重命名
+        $("#showArea").on("click", "[data-target = '#edit']", function(){
+            let renameId = $(this).parent().parent().attr("id");
+            let compilationName = $(this).parent().parent().children()[1].textContent;
+            $('#compilationEdit option').text(compilationName);
+            $("#renameA").attr("renameId", renameId);
+        });
+        $("#renameA").click(function(){
+            let newName = $("#renameText").val();
+            let libId = $(this).attr("renameId");
+            let jqSel = "#" + libId + " td:first" + " a";
+            let orgName = $(jqSel).text();
+            if(newName.trim().length === 0){
+                alert("名称不可为空!");
+                $("#renameText").val('');
+            }
+            else if(dispNameArr.indexOf(newName) !== -1){
+                alert("该工料机库已存在!");
+                $("#renameText").val('');
+            }
+           else{
+               renameGljLib({ID: libId, newName: newName, orgName: orgName}, dispNameArr);
+            }
+        });
+        //删除
+        $("#showArea").on("click", "[data-target = '#del']", function(){
+            let deleteId = $(this).parent().parent().attr("id");
+            $("#deleteA").attr("deleteId", deleteId);
+        });
+        $("#deleteA").click(function(){
+            let deleteId = $(this).attr("deleteId");
+            let jqSel = "#" + deleteId + " td:first" + " a";
+            let libName = $(jqSel).text();
+            removeGljLib({libId: deleteId, libName: libName}, dispNameArr);
+        });
+
+
+    });
+    getCompilationList();
+});
+
+function getAllGljLib(callback){
+    $.ajax({
+        type: 'post',
+        url: 'api/getAllGljLib',
+        dataType: 'json',
+        success: function (result) {
+            let dispNames = [];
+            if(result.data.length > 0){
+                for(let i = 0; i < result.data.length; i++){
+                    let id = result.data[i].ID;
+                    let libName = result.data[i].dispName;
+                    let createDate = result.data[i].createDate.split(' ')[0];
+                    let compilationName = result.data[i].compilationName;
+                    dispNames.push(result.data[i].dispName);
+                    $("#showArea").append(
+                        "<tr id='tempId'>" +
+                        "<td><a href='/stdGljRepository/glj'>"+libName+"</a></td>" +
+                        "<td>"+compilationName+" </td>" +
+                        "<td>"+'xx定额库(xx)'+" </td>" +
+                        "<td>"+createDate+" </td>" +
+                        "<td><a href='javascript:void(0);' data-toggle='modal' data-target='#edit' title='编辑'>" +
+                        "<i class='fa fa-pencil-square-o'></i></a> <a href='javascript:void(0);' data-toggle='modal' data-target='#del' class='text-danger' title='删除'>" +
+                        "<i class='fa fa-remove'></i></a></td></tr>");
+                    var newHref = "/stdGljRepository/glj?gljLibId="+id;
+                    $("#tempId td:first a").attr("href", newHref);
+                    $("#tempId").attr("id", id);
+                }
+            }
+            callback(dispNames);
+        }
+    });
+}
+function getCompilationList(){
+    $.ajax({
+        type: 'post',
+        url: 'api/getCompilationList',
+        dataType: 'json',
+        success: function (result) {
+            //addoptions
+            for(let i = 0; i < result.data.length; i++){
+                let $option =  $("<option >"+ result.data[i].name +"</option>");
+                $option.val( result.data[i]._id);
+                $('#compilationSels').append($option);
+            }
+            $('#compilationSels').on("change", function () {
+            });
+        }
+    });
+}
+function createGljLib(gljLibObj, dispNamesArr){
+    $.ajax({
+        type: 'post',
+        url: 'api/createGljLib',
+        data: {gljLibObj: JSON.stringify(gljLibObj)},
+        dataType: 'json',
+        success: function (result) {
+            console.log(result);
+            if(result.data){
+                let id = result.data.ID;
+                let libName = result.data.dispName;
+                let createDate = result.data.createDate.split(' ')[0];
+                let compilationName = result.data.compilationName;
+                dispNamesArr.push(libName);
+                $("#showArea").append(
+                    "<tr id='tempId'>" +
+                    "<td><a href='/stdGljRepository/glj'>"+libName+"</a></td>" +
+                    "<td>"+compilationName+" </td>" +
+                    "<td>"+'xx定额库(xx)'+" </td>" +
+                    "<td>"+createDate+" </td>" +
+                    "<td><a href='javascript:void(0);' data-toggle='modal' data-target='#edit' title='编辑'>" +
+                    "<i class='fa fa-pencil-square-o'></i></a> <a href='javascript:void(0);' data-toggle='modal' data-target='#del' class='text-danger' title='删除'>" +
+                    "<i class='fa fa-remove'></i></a></td></tr>");
+                var newHref = "/stdGljRepository/glj?gljLibId="+id;
+                $("#tempId td:first a").attr("href", newHref);
+                $("#tempId").attr("id", id);
+            }
+            $('#cancelBtn').click();
+        }
+    })
+}
+function renameGljLib(renameObj, dispNames){
+    $.ajax({
+        type: 'post',
+        url: 'api/renameGljLib',
+        data: {oprtor: oprtor, renameObj: JSON.stringify(renameObj)},
+        dataType: 'json',
+        success: function (result) {
+            if(!result.error){
+                let jqSel = "#" + renameObj.ID + " td:first" + " a";
+                $(jqSel).text(renameObj.newName);
+                let index = dispNames.indexOf(renameObj.orgName);
+                dispNames.splice(index, 1);
+                dispNames.splice(index, 0, renameObj.newName);
+            }
+            $('#editCancelBtn').click();
+            $('#renameText').val('');
+        }
+    })
+}
+function removeGljLib(delObj, dispNames){
+    $.ajax({
+        type: 'post',
+        url: 'api/removeGljLib',
+        data: {oprtor: oprtor, libId: delObj.libId},
+        dataType: 'json',
+        success: function (result) {
+            if(!result.error){
+                var jqSel = "#"+ delObj.libId;
+                $(jqSel).remove();
+                let index = dispNames.indexOf(delObj.libName);
+                dispNames.splice(index, 1);
+                $('#delCancelBtn').click();
+            }
+        }
+    })
+}

+ 1 - 2
web/users/css/style.css

@@ -48,7 +48,7 @@ body{
 .header {
   background:#f4f5f5;
   position: fixed;
-  z-index: 10;
+  z-index: 500;
   width: 100%;
   height: 50px;
   top: 0;
@@ -57,7 +57,6 @@ body{
 }
 .main{
   position: relative;
-  z-index: 4;
 }
 .main-nav {
   position: fixed;

+ 323 - 0
web/users/js/col_setting.js

@@ -0,0 +1,323 @@
+/**
+ * Created by Mai on 2017/8/14.
+ */
+
+let ColSettingObj = {
+    colSetting: null,
+    DEFAULT_TITLE_STYLE: null,
+    DEFAULT_DATA_STYLE: null,
+    cellType: {
+        getText: null,
+        readOnly: null
+    },
+    Rows: {data: 0, filedName: 0, getText: 1, width: 2, readOnly: 3},
+    columnValueChanged: function (e, info) {
+        let that = ColSettingObj;
+        info.colList.forEach(function (iCol) {
+            info.sheet.setValue(that.colSetting.headRows + that.Rows.width, iCol, info.sheet.getColumnWidth(iCol), GC.Spread.Sheets.SheetArea.viewport);
+        });
+    },
+    valueChanged: function (e, info) {
+        let that = ColSettingObj;
+        if (info.row === that.colSetting.headRows + that.Rows.width) {
+            info.sheet.setColumnWidth(info.col, info.newValue, GC.Spread.Sheets.SheetArea.viewport);
+        }
+    },
+    selectionChanged: function (e, info) {
+        let that = ColSettingObj, sel = info.newSelections[0];
+        if (sel.row <= that.colSetting.headRows) {
+            $('.btn-toolbar').removeClass('disabled');
+            $('#font').val(info.sheet.getCell(sel.row, sel.col, GC.Spread.Sheets.SheetArea.viewport).font());
+        } else {
+            $('.btn-toolbar').addClass('disabled');
+        }
+    },
+    getCellStyle: function (font, hAlign, vAlign) {
+        var style = new GC.Spread.Sheets.Style();
+        style.font = font;
+        style.hAlign = hAlign;
+        style.vAlign = vAlign;
+        style.wordWrap = true;
+        return style;
+    },
+    initCellType: function () {
+        this.cellType.readOnly = new GC.Spread.Sheets.CellTypes.ComboBox();
+        this.cellType.readOnly.items([true, false,
+            'readOnly.bills', 'readOnly.ration', 'readOnly.volumePrice',
+            'readOnly.non_bills', 'readOnly.non_ration', 'readOnly.non_volumePrice',
+            'readOnly.billsParent', 'readOnly.forCalcBase'
+        ]);
+
+        this.cellType.getText = new GC.Spread.Sheets.CellTypes.ComboBox();
+        this.cellType.getText.items(['getText.type']);
+    },
+    initSheet: function (sheet, setting) {
+        sheet.setColumnCount(2, GC.Spread.Sheets.SheetArea.rowHeader);
+        sheet.setColumnWidth(0, 80, GC.Spread.Sheets.SheetArea.rowHeader);
+        sheet.setColumnWidth(1, 70, GC.Spread.Sheets.SheetArea.rowHeader);
+        sheet.setRowCount(setting.headRows + this.Rows.readOnly + 1);
+
+        sheet.setText(setting.headRows + this.Rows.data, 0, 'Data', GC.Spread.Sheets.SheetArea.rowHeader);
+        sheet.setStyle(setting.headRows + this.Rows.data, -1, this.DEFAULT_DATA_STYLE);
+        sheet.addSpan(setting.headRows + this.Rows.data, 0, 2, 1, GC.Spread.Sheets.SheetArea.rowHeader);
+
+        sheet.setText(setting.headRows + this.Rows.filedName, 1, 'FieldName', GC.Spread.Sheets.SheetArea.rowHeader);
+        sheet.setText(setting.headRows + this.Rows.getText, 1, 'getText', GC.Spread.Sheets.SheetArea.rowHeader);
+
+        sheet.setText(setting.headRows + this.Rows.width, 0, 'width', GC.Spread.Sheets.SheetArea.rowHeader);
+        sheet.addSpan(setting.headRows + this.Rows.width, 0, 1, 2, GC.Spread.Sheets.SheetArea.rowHeader);
+
+        sheet.setText(setting.headRows + this.Rows.readOnly, 0, 'ReadOnly', GC.Spread.Sheets.SheetArea.rowHeader);
+        sheet.addSpan(setting.headRows + this.Rows.readOnly, 0, 1, 2, GC.Spread.Sheets.SheetArea.rowHeader);
+    },
+    initColSetting: function (setting) {
+        this.DEFAULT_TITLE_STYLE = this.getCellStyle('Arial', GC.Spread.Sheets.HorizontalAlign.center, GC.Spread.Sheets.VerticalAlign.center);
+        this.DEFAULT_DATA_STYLE = this.getCellStyle('Arial', GC.Spread.Sheets.HorizontalAlign.left, GC.Spread.Sheets.VerticalAlign.center);
+        this.initCellType();
+
+        $('#empty-rows').val(setting.emptyRows);
+        $('#col-count').val(setting.cols ? setting.cols.length : 0);
+        $('#header-row-count').val(setting.headRows);
+
+        colEditSpread = new GC.Spread.Sheets.Workbook($('#colEditSpread')[0], {sheetCount: 1});
+        colEditSpread.options.tabStripVisible = false;
+        colEditSpread.bind(GC.Spread.Sheets.Events.ColumnWidthChanged, this.columnValueChanged);
+        colEditSpread.bind(GC.Spread.Sheets.Events.ValueChanged, this.valueChanged);
+        colEditSpread.bind(GC.Spread.Sheets.Events.SelectionChanged, this.selectionChanged);
+
+        this.initSheet(colEditSpread.getActiveSheet(), setting);
+        this.setColCount(this.colSetting.cols.length);
+        this.setHeaderRowCount(this.colSetting.headRows);
+
+        if (setting.cols) {
+            let sheet = colEditSpread.getActiveSheet(), iRow;
+            for (let iCol = 0; iCol < setting.cols.length; iCol++) {
+                let col = setting.cols[iCol], iRow = 0;
+                // header
+                for (let i in col.head.spanCols) {
+                    if (col.head.spanCols[i] !== 0) {
+                        let cell = sheet.getCell(iRow, iCol, GC.Spread.Sheets.SheetArea.viewport);
+                        cell.value(col.head.titleNames[i]).font(col.head.font[i]).hAlign(col.head.hAlign[i]).vAlign(col.head.vAlign[i]);
+                    }
+                    if (col.head.spanCols[i] > 1 || col.head.spanRows[i] > 1) {
+                        sheet.addSpan(iRow, iCol, col.head.spanRows[i], col.head.spanCols[i], GC.Spread.Sheets.SheetArea.viewport);
+                    }
+                    iRow += col.head.spanRows[i];
+                };
+                // data
+                // field
+                let cell = sheet.getCell(this.colSetting.headRows + this.Rows.data, iCol, GC.Spread.Sheets.SheetArea.viewport);
+                cell.value(col.data.field).font(col.data.font).hAlign(col.head.hAlign).vAlign(col.data.vAlign);
+                // getText
+                cell = sheet.getCell(this.colSetting.headRows + this.Rows.getText, iCol, GC.Spread.Sheets.SheetArea.viewport);
+                cell.cellType(this.cellType.getText).value(col.data.getText).hAlign(GC.Spread.Sheets.HorizontalAlign.right);
+                // 列宽
+                sheet.setColumnWidth(iCol, col.width);
+                sheet.setValue(this.colSetting.headRows + this.Rows.width, iCol, sheet.getColumnWidth(iCol), GC.Spread.Sheets.SheetArea.viewport);
+                // readonly
+                cell = sheet.getCell(this.colSetting.headRows + this.Rows.readOnly, iCol, GC.Spread.Sheets.SheetArea.viewport);
+                cell.cellType(this.cellType.readOnly).value(col.readOnly).hAlign(GC.Spread.Sheets.HorizontalAlign.right);
+            }
+        }
+        let cell = info.sheet.getCell(0, 0, GC.Spread.Sheets.SheetArea.viewport);
+        if (cell) {
+            $('#font').val(cell.font());
+        }
+    },
+    setColCount: function (count) {
+        let sheet = colEditSpread.getActiveSheet();
+        sheet.setColumnCount(count);
+        for (let iCol = 0; iCol < sheet.getColumnCount(); iCol++) {
+            sheet.setValue(this.colSetting.headRows + this.Rows.width, iCol, sheet.getColumnWidth(iCol), GC.Spread.Sheets.SheetArea.viewport);
+            sheet.getCell(this.colSetting.headRows + this.Rows.readOnly, iCol, GC.Spread.Sheets.SheetArea.viewport).cellType(this.cellType.readOnly);
+            sheet.setValue(this.colSetting.headRows + this.Rows.readOnly, iCol, false, GC.Spread.Sheets.SheetArea.viewport);
+        }
+    },
+    setHeaderRowCount: function (count) {
+        let sheet = colEditSpread.getActiveSheet(), orgCount = this.colSetting.headRows;
+        if (count < orgCount) {
+            sheet.deleteRows(count, orgCount - count);
+        } else if (count > orgCount) {
+            sheet.addRows(orgCount, count - orgCount);
+            sheet.addSpan(0, 0, count, 1, GC.Spread.Sheets.SheetArea.rowHeader);
+            for (let iRow = orgCount; iRow < count; iRow++) {
+                sheet.setStyle(iRow, -1, this.DEFAULT_TITLE_STYLE);
+            }
+        }
+    },
+    getActualCellRange: function (cellRange, rowCount, columnCount) {
+        if (cellRange.row == -1 && cellRange.col == -1) {
+            return new spreadNS.Range(0, 0, rowCount, columnCount);
+        }
+        else if (cellRange.row == -1) {
+            return new spreadNS.Range(0, cellRange.col, rowCount, cellRange.colCount);
+        }
+        else if (cellRange.col == -1) {
+            return new spreadNS.Range(cellRange.row, 0, cellRange.rowCount, columnCount);
+        }
+
+        return cellRange;
+    },
+    // 批量操作Spread选择的单元格
+    controlSelectCells: function (spread, control) {
+        let sheet = colEditSpread.getActiveSheet();
+        let sel = sheet.getSelections(), i, j;
+
+        sel = this.getActualCellRange(sel[sel.length - 1], sheet.getRowCount(), sheet.getColumnCount());
+        for (i = 0; i < sel.rowCount; i++) {
+            for (j = 0; j < sel.colCount; j++) {
+                control(sheet.getCell(sel.row + i, sel.col + j));
+            }
+        }
+    },
+    generateColSetting: function () {
+        let setting = {}, sheet = colEditSpread.getActiveSheet();
+        setting.emptyRows = parseInt($('#empty-rows').val());
+        setting.headRows = parseInt($('#header-row-count').val());
+        if ($('#is-tree').checked) {
+            setting.treeCol = parseInt($('#treeCol').val());
+        }
+        setting.headRowHeight = [];
+        for (let iRow = 0; iRow < setting.headRows; iRow++) {
+            setting.headRowHeight.push(sheet.getRowHeight(iRow, GC.Spread.Sheets.SheetArea.viewport));
+        };
+        setting.cols = [];
+        for (let iCol = 0; iCol < sheet.getColumnCount(); iCol++) {
+            let col = {};
+            col.width = sheet.getColumnWidth(iCol);
+            col.readOnly = sheet.getValue(setting.headRows + this.Rows.readOnly, iCol) || false;
+
+            col.head = {};
+            col.head.titleNames = [];
+            col.head.spanCols = [];
+            col.head.spanRows = [];
+            col.head.vAlign = [];
+            col.head.hAlign = [];
+            col.head.font = [];
+            for (let iRow = 0; iRow < setting.headRows; iRow++) {
+                let cell = sheet.getCell(iRow, iCol);
+                col.head.titleNames.push(cell.text());
+                let span = sheet.getSpan(iRow, iCol);
+                if (span) {
+                    if (span.col === iCol && span.row === iRow) {
+                        col.head.spanCols.push(span.colCount);
+                        col.head.spanRows.push(span.rowCount);
+                    } else {
+                        col.head.spanCols.push(0);
+                        col.head.spanRows.push(1);
+                    }
+                } else {
+                    col.head.spanCols.push(1);
+                    col.head.spanRows.push(1);
+                }
+                col.head.vAlign.push(cell.vAlign());
+                col.head.hAlign.push(cell.hAlign());
+                col.head.font.push(cell.font());
+            }
+
+            col.data = {};
+            let cell = sheet.getCell(setting.headRows, iCol);
+            col.data.field = cell.text();
+            col.data.vAlign = cell.vAlign();
+            col.data.hAlign = cell.hAlign();
+            col.data.font = cell.font();
+            // getText
+            cell = sheet.getCell(setting.headRows + this.Rows.getText, iCol);
+            if (cell.text() !== '') {
+                col.data.getText = cell.text();
+            }
+            setting.cols.push(col);
+        }
+        return setting;
+    }
+};
+
+$('#set-column').on('shown.bs.modal', function () {
+    if (!colEditSpread) {
+        ColSettingObj.colSetting = JSON.parse(mainTreeCol);
+        ColSettingObj.initColSetting(ColSettingObj.colSetting);
+    }
+});
+$('#col-count').change(function () {
+    ColSettingObj.setColCount(parseInt($(this).val()));
+});
+$('#header-row-count').change(function () {
+    ColSettingObj.setHeaderRowCount(parseInt($(this).val()));
+    ColSettingObj.colSetting.headRows = parseInt($(this).val());
+});
+$('#merge').click(function () {
+    let sheet = colEditSpread.getActiveSheet();
+    let sel = sheet.getSelections();
+
+    if (sel.length > 0) {
+        sel = ColSettingObj.getActualCellRange(sel[sel.length - 1], sheet.getRowCount(), sheet.getColumnCount());
+        if (sel.row + sel.rowCount > ColSettingObj.colSetting.headRows) {
+            alert('仅HeaderTitle部分可以合并单元格');
+        } else {
+            sheet.addSpan(sel.row, sel.col, sel.rowCount, sel.colCount);
+            //sheet.setTag(sel.row, sel.col, 1);
+        }
+    }
+});
+$('#unmerge').click(function () {
+    let sheet = colEditSpread.getActiveSheet();
+    let sel = sheet.getSelections();
+
+    if (sel.length > 0) {
+        sel = ColSettingObj.getActualCellRange(sel[sel.length - 1], sheet.getRowCount(), sheet.getColumnCount());
+        sheet.suspendPaint();
+        for (var i = 0; i < sel.rowCount; i++) {
+            for (var j = 0; j < sel.colCount; j++) {
+                sheet.removeSpan(i + sel.row, j + sel.col);
+            }
+        }
+        sheet.resumePaint();
+    }
+});
+$('#save-col-setting').click(function () {
+    ColSettingObj.colSetting = ColSettingObj.generateColSetting();
+    mainTreeCol = JSON.stringify(ColSettingObj.colSetting);
+    $('input:hidden[name="main_tree_col"]').val(mainTreeCol);
+    $('#set-column').modal('hide');
+    SheetDataHelper.loadSheetHeader(ColSettingObj.colSetting, colSpread.getActiveSheet());
+});
+
+$('#h-left').click(function () {
+    ColSettingObj.controlSelectCells(colEditSpread, function (cell) {
+        cell.hAlign(GC.Spread.Sheets.HorizontalAlign.left);
+    });
+});
+$('#h-center').click(function () {
+    ColSettingObj.controlSelectCells(colEditSpread, function (cell) {
+        cell.hAlign(GC.Spread.Sheets.HorizontalAlign.center);
+    });
+});
+
+$('#h-right').click(function () {
+    ColSettingObj.controlSelectCells(colEditSpread, function (cell) {
+        cell.hAlign(GC.Spread.Sheets.HorizontalAlign.right);
+    });
+});
+
+$('#v-top').click(function () {
+    ColSettingObj.controlSelectCells(colEditSpread, function (cell) {
+        cell.vAlign(GC.Spread.Sheets.VerticalAlign.top);
+    });
+});
+$('#v-center').click(function () {
+    ColSettingObj.controlSelectCells(colEditSpread, function (cell) {
+        cell.vAlign(GC.Spread.Sheets.VerticalAlign.center);
+    });
+});
+$('#v-bottom').click(function () {
+    ColSettingObj.controlSelectCells(colEditSpread, function (cell) {
+        cell.vAlign(GC.Spread.Sheets.VerticalAlign.bottom);
+    });
+});
+
+$('#set-font').click(function () {
+    var sFont = $('#font').val();
+    ColSettingObj.controlSelectCells(colEditSpread, function (cell) {
+        cell.font(sFont);
+    });
+});

+ 96 - 59
web/users/js/version.js

@@ -1,5 +1,5 @@
 /**
- * 版本管理相关js
+ * 编办管理相关js
  *
  * @author CaiAoLin
  * @date 2017/7/28
@@ -9,11 +9,11 @@ $(document).ready(function() {
     let isAdding = false;
     let model = '';
     let section = 'bill';
-    let id = $("#version-id").val();
+    let id = $("#compilation-id").val();
 
     // 计价规则页面初始化数据
     if ($("#section").length > 0) {
-        initVersion();
+        initCompilation();
     }
 
     // 计价类型选择
@@ -21,14 +21,14 @@ $(document).ready(function() {
         section = $(this).attr("aria-controls");
     });
 
-    // 新增版本
-    $("#add-version").click(function() {
+    // 新增编办
+    $("#add-compilation").click(function() {
         try {
-            let [name, standardBill, rationLib, standardBillString, rationLibString] = getAndValidData(model);
+            let [name, standardBill, rationLib, gljLib, standardBillString, rationLibString, gljLibString] = getAndValidData(model);
 
-            let url = '/version/add';
+            let url = '/compilation/add';
             if (model === 'all') {
-                // 新增版本操作
+                // 新增编办操作
                 $.ajax({
                     url: url,
                     type: 'post',
@@ -64,6 +64,9 @@ $(document).ready(function() {
                         addLib.name = rationLibString;
                         addLib.id = rationLib;
                         break;
+                    case 'glj':
+                        addLib.name = gljLibString;
+                        addLib.id = gljLib;
                 }
                 // 判断是否有重复的数据
                 if ($("input:hidden[name='"+ model +"_lib'][data-id='"+ addLib.id +"']").length > 0) {
@@ -76,7 +79,7 @@ $(document).ready(function() {
                 let tmpHtml = '<p class="form-control-static">' + removeHtml + addLib.name +
                     '<input type="hidden" data-id="'+ addLib.id +'" name=\'' + model + '_lib\' value=\'' + JSON.stringify(addLib) + '\'>' + '</p>';
                 $("." + model + "-list").append(tmpHtml);
-                $('#addversion').modal('hide');
+                $('#addcompilation').modal('hide');
             }
 
         } catch (error) {
@@ -96,7 +99,7 @@ $(document).ready(function() {
             }
 
             $.ajax({
-                url: '/version/add-valuation',
+                url: '/compilation/add-valuation',
                 type: 'post',
                 data: {name: name, id: id, section: section},
                 error: function() {
@@ -121,58 +124,40 @@ $(document).ready(function() {
         }
     });
 
-    // 选择省份后读取数据
-    $("select[name='standard_bill_province'],select[name='ration_lib_province']").change(function() {
-        let name = $(this).attr('name');
-
-        let billListData = billList === undefined ? [] : JSON.parse(billList);
-        let rationLibData = rationList === undefined ? [] : JSON.parse(rationList);
-        if (billListData.length <= 0 || rationLibData.length <= 0) {
-            return false;
-        }
-        let sourceData = name === 'standard_bill_province' ? billListData : rationLibData;
-        let selectedId = $(this).val();
-        if (sourceData[selectedId] === undefined) {
-            return false;
-        }
-        let defaultString = name === 'standard_bill_province' ? '请选择标准清单' : '请选择定额库';
-        let html = '<option value="">' + defaultString + '</option>';
-        for(let tmp of sourceData[selectedId]) {
-            let tmpHtml = '<option value="' + tmp.id + '">' + tmp.name + '</option>';
-            html += tmpHtml;
-        }
-
-        // 渲染
-        let targetSelector = name === 'standard_bill_province' ? $("select[name='standard_bill']") : $("select[name='ration_lib']");
-        targetSelector.children('option').remove();
-        targetSelector.html(html);
-    });
-
     // 添加
-    $(".add-version").click(function() {
+    $(".add-compilation").click(function() {
         model = $(this).data('model');
         switch (model) {
             case 'all':
                 $("#name-area").show();
                 $("#bill-area").hide();
                 $("#ration-area").hide();
-                $("#add-version-title").text('添加新版本');
+                $("#glj-area").hide();
+                $("#add-compilation-title").text('添加新编办');
                 break;
             case 'bill':
                 $("#name-area").hide();
                 $("#bill-area").show();
                 $("#ration-area").hide();
-                $("#add-version-title").text('添加标准清单');
+                $("#glj-area").hide();
+                $("#add-compilation-title").text('添加标准清单');
                 break;
             case 'ration':
                 $("#name-area").hide();
                 $("#bill-area").hide();
                 $("#ration-area").show();
-                $("#add-version-title").text('添加定额库');
+                $("#glj-area").hide();
+                $("#add-compilation-title").text('添加定额库');
                 break;
+            case 'glj':
+                $("#name-area").hide();
+                $("#bill-area").hide();
+                $("#ration-area").hide();
+                $("#glj-area").show();
+                $("#add-compilation-title").text('添加定额库');
         }
 
-        $("#addversion").modal('show');
+        $("#addcompilation").modal('show');
     });
 
     // 保存计价规则
@@ -195,7 +180,7 @@ $(document).ready(function() {
             return false;
         }
         $.ajax({
-            url: '/version/valuation/' + section + '/enable',
+            url: '/compilation/valuation/' + section + '/enable',
             type: 'post',
             dataType: "json",
             data: {id: id, enable: goingChangeStatus},
@@ -216,6 +201,38 @@ $(document).ready(function() {
         });
     });
 
+    // 发布编办
+    $("#release").click(function() {
+        let id = $(this).data("id");
+        let status = $(this).data("status");
+        status = parseInt(status);
+        if (isAdding || id === '' || isNaN(status)) {
+            return false;
+        }
+
+        $.ajax({
+            url: '/compilation/release',
+            type: 'post',
+            data: {id: id, status: status},
+            dataType: "json",
+            error: function() {
+                isAdding = false;
+            },
+            beforeSend: function() {
+                isAdding = true;
+            },
+            success: function(response) {
+                isAdding = false;
+                if (response.err === 0) {
+                    window.location.reload();
+                } else {
+                    let msg = response.msg === undefined ? "未知错误" : response.msg;
+                    alert(msg);
+                }
+            }
+        });
+
+    });
 
 });
 
@@ -224,28 +241,42 @@ $(document).ready(function() {
  *
  * @return {void|boolean}
  */
-function initVersion() {
-    if (province === undefined) {
-        alert('初始化失败!');
-        return false;
-    }
+function initCompilation() {
+    let billListData = billList === undefined ? [] : JSON.parse(billList);
+    let rationLibData = rationList === undefined ? [] : JSON.parse(rationList);
+    let gljLibData = gljList === undefined ? [] : JSON.parse(gljList);
 
-    province = JSON.parse(province);
-    if (province.length <= 0) {
-        alert('省份数据加载失败!');
+    if (billListData.length <= 0 || rationLibData.length <= 0 || gljLibData.length <= 0) {
         return false;
     }
+    // 初始化 造价书列设置
+    colSpread = SheetDataHelper.createNewSpread($('#main-tree-col')[0]);
+    SheetDataHelper.loadSheetHeader(JSON.parse(mainTreeCol), colSpread.getActiveSheet());
 
-    let billProvinceElement = $("select[name='standard_bill_province']");
-    let rationProvinceElement = $("select[name='ration_lib_province']");
+    // 标准清单
     let html = '';
-    for (let tmp of province) {
+    for(let tmp of billListData) {
         let tmpHtml = '<option value="' + tmp.id + '">' + tmp.name + '</option>';
         html += tmpHtml;
     }
+    $("select[name='standard_bill']").children("option").first().after(html);
+
+    // 定额库
+    html = '';
+    for(let tmp of rationLibData) {
+        let tmpHtml = '<option value="' + tmp.id + '">' + tmp.name + '</option>';
+        html += tmpHtml;
+    }
+    $("select[name='ration_lib']").children("option").first().after(html);
+
+    // 工料机库
+    html = '';
+    for(let tmp of gljLibData) {
+        let tmpHtml = '<option value="' + tmp.id + '">' + tmp.name + '</option>';
+        html += tmpHtml;
+    }
+    $("select[name='glj_lib']").children("option").first().after(html);
 
-    billProvinceElement.children('option').first().after(html);
-    rationProvinceElement.children('option').first().after(html);
 }
 
 /**
@@ -255,12 +286,13 @@ function initVersion() {
  * @return {Array}
  */
 function getAndValidData(model) {
-    let name = $("input[name='version_name']").val();
+    let name = $("input[name='compilation_name']").val();
     let standardBill = $("select[name='standard_bill']").children("option:selected").val();
     let rationLib = $("select[name='ration_lib']").children("option:selected").val();
+    let gljLib = $("select[name='glj_lib']").children("option:selected").val();
 
     if (name === '' && model === 'all') {
-        throw '版本名字不能为空';
+        throw '编办名字不能为空';
     }
 
     if ( model === 'bill' && (standardBill === '' || standardBill === undefined)) {
@@ -271,10 +303,15 @@ function getAndValidData(model) {
         throw '请选择定额库';
     }
 
+    if (model === 'glj' && (gljLib === '' || gljLib === undefined)) {
+        throw '请选择工料机库';
+    }
+
     let standardBillString = $("select[name='standard_bill']").children("option:selected").text();
     let rationLibString = $("select[name='ration_lib']").children("option:selected").text();
+    let gljLibString = $("select[name='glj_lib']").children("option:selected").text();
 
-    return [name, standardBill, rationLib, standardBillString, rationLibString];
+    return [name, standardBill, rationLib, gljLib, standardBillString, rationLibString, gljLibString];
 }
 
 /**

+ 42 - 14
web/users/views/version/add.html

@@ -2,19 +2,25 @@
 <div class="panel-content">
     <div class="panel-title">
         <div class="title-main">
-            <h2>重庆版<span class="text-muted pull-right">已发布 2017-08-04</span><a href="javascript:void(0);" class="btn btn-primary btn-sm pull-right" id="save">发布版本</a></h2>
+            <h2>
+                <%= selectedCompilation.name %>
+                <% if(selectedCompilation.is_release) {%>
+                <span class="text-muted" style="margin-left: 5px;">已发布 <%= moment(selectedCompilation.update_time).format('YYYY-MM-DD')%></span>
+                <% } %>
+                <a href="javascript:void(0);" data-id="<%= selectedCompilation._id %>" data-status="<%= selectedCompilation.is_release ? 0 : 1 %>" class="btn btn-primary btn-sm pull-right" id="release"><% if(selectedCompilation.is_release) {%>取消<% }else{ %>发布<% } %>版本</a>
+            </h2>
         </div>
     </div>
     <div class="content-wrap">
         <div class="c-header" style="padding:0">
             <ul class="nav nav-tabs">
                 <% valuationList.forEach(function(valuation) { %>
-                <li role="presentation" <% if (valuation._id.toString() === valuationId) { %>class="active"<% } %>><a href="/version/valuation/<%= section %>/<%= valuation._id %>"><%= valuation.name %></a></li>
+                <li role="presentation" <% if (valuation._id.toString() === valuationId) { %>class="active"<% } %>><a href="/compilation/valuation/<%= section %>/<%= valuation._id %>"><%= valuation.name %></a></li>
                 <% }) %>
             </ul>
         </div>
         <div class="c-body">
-            <form method="post" action="/version/save-valuation" enctype="application/x-www-form-urlencoded21">
+            <form method="post" action="/compilation/save-valuation" enctype="application/x-www-form-urlencoded21">
                 <div class=" row">
                     <div class="col-md-4">
                         <div class="form-group">
@@ -22,7 +28,7 @@
                             <div class="input-group">
                                 <input type="text" class="form-control" value="<%= valuationData.name %>" name="name">
                                 <span class="input-group-btn">
-                                     <button class="btn btn-default" type="button" id="save-valuation">保存</button>
+                                     <button class="btn btn-default" type="button" id="save-valuation">保存全部</button>
                                 </span>
                             </div>
                         </div>
@@ -47,41 +53,58 @@
                             <label>标准清单</label>
                             <div class="bill-list">
                                 <% if (valuationData.bill_lib.length > 0) { %>
-                                <% valuationData.bill_lib.forEach(function (bill){ %>
+                                <% valuationData.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}) %>">
-                                    <%= bill.name %>
+                                    <% if (index === 0) {%><i class="glyphicon glyphicon-flag"></i>&nbsp;<% } %><%= bill.name %>
                                 </p>
                                 <% }) %>
                                 <% } %>
                             </div>
-                            <a class="btn btn-link btn-sm add-version" href="javascript:void(0)" data-model="bill">添加</a>
+                            <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 (valuationData.ration_lib.length > 0) { %>
-                                <% valuationData.ration_lib.forEach(function (ration){ %>
+                                <% valuationData.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}) %>">
-                                    <%= 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-version" data-model="ration">添加</a>
+                            <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 (valuationData.glj_lib.length > 0) { %>
+                                <% valuationData.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>
                     </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></legend>
-                        <div>
-                            S JS预览在此
+                        <input type="hidden" name="main_tree_col" value="<%= mainTreeCol %>">
+                        <div id="main-tree-col">
                         </div>
                     </div>
                 </div>
@@ -92,8 +115,13 @@
     </div>
 </div>
 <script type="text/javascript">
-    let province = '<%- province %>';
     let billList = '<%- billList %>';
     let rationList = '<%- rationList %>';
+    let gljList = '<%- gljList %>';
+    let mainTreeCol = '<%- mainTreeCol %>';
+    let colSpread = null;
+    let colEditSpread = null;
 </script>
-<script type="text/javascript" src="/web/users/js/version.js"></script>
+<script type="text/javascript" src="/public/web/sheet/sheet_data_helper.js"></script>
+<script type="text/javascript" src="/web/users/js/compilation.js"></script>
+<%include ../compilation/modal.html %>

+ 16 - 0
web/users/views/compilation/common.html

@@ -0,0 +1,16 @@
+<div class="panel-sidebar">
+    <div class="panel-title">
+        <div class="title-bar">
+            <h2><a class="pull-right add-compilation" title="添加新编办" href="javascript:void(0)" data-model="all"><span class="glyphicon glyphicon-plus"></span></a>编办管理</h2>
+        </div>
+    </div>
+    <div class="scrollbar-auto">
+        <div class="nav-box">
+            <ul class="nav-list list-unstyled" id="version-select">
+                <% compilationList.forEach(function (compilation){ %>
+                <li <% if(selectedCompilation._id.toString() === compilation._id.toString()) { %>class="active"<% } %>><a href="/compilation?id=<%= compilation._id %>"><span><%= compilation.name %></span><% if (!compilation.is_release) { %><span class="text-muted">(未发布)</span><% } %></a></li>
+                <% }) %>
+            </ul>
+        </div>
+    </div>
+</div>

+ 19 - 12
web/users/views/version/index.html

@@ -1,9 +1,15 @@
 <%include ./common.html %>
 <div class="panel-content">
-    <% if(Object.keys(selectedVersion).length > 0) {%>
+    <% if(Object.keys(selectedCompilation).length > 0) {%>
     <div class="panel-title">
         <div class="title-main">
-            <h2>重庆版<span class="text-muted pull-right">已发布 2017-08-04</span><a href="javascript:void(0);" class="btn btn-primary btn-sm pull-right" id="save">发布版本</a></h2>
+            <h2>
+                <%= selectedCompilation.name %>
+                <% if(selectedCompilation.is_release) {%>
+                <span class="text-muted" style="margin-left: 5px;">已发布 <%= moment(selectedCompilation.update_time).format('YYYY-MM-DD')%></span>
+                <% } %>
+                <a href="javascript:void(0);" data-id="<%= selectedCompilation._id %>" data-status="<%= selectedCompilation.is_release ? 0 : 1 %>" class="btn btn-primary btn-sm pull-right" id="release"><% if(selectedCompilation.is_release) {%>取消<% }else{ %>发布<% } %>编办</a>
+            </h2>
         </div>
     </div>
     <div class="content-wrap">
@@ -25,8 +31,8 @@
                     </tr>
                     </thead>
                     <tbody>
-                    <% if (selectedVersion.bill_valuation.length > 0) { %>
-                    <% selectedVersion.bill_valuation.forEach(function(bill) { %>
+                    <% if (selectedCompilation.bill_valuation.length > 0) { %>
+                    <% selectedCompilation.bill_valuation.forEach(function(bill) { %>
                     <tr>
                         <td><%= bill.name %></td>
                         <td>
@@ -43,8 +49,8 @@
                             <% } %>
                         </td>
                         <td>
-                            <a href="/version/valuation/bill/<%= bill.id %>" class="btn btn-sm">编辑</a>
-                            <a href="/version/valuation/bill/delete/<%= bill.id %>" class="btn btn-sm text-danger">删除</a>
+                            <a href="/compilation/valuation/bill/<%= bill.id %>" class="btn btn-sm">编辑</a>
+                            <a href="/compilation/valuation/bill/delete/<%= bill.id %>" class="btn btn-sm text-danger">删除</a>
                         </td>
                     </tr>
                     <% }) %>
@@ -63,8 +69,8 @@
                     </tr>
                     </thead>
                     <tbody>
-                    <% if (selectedVersion.ration_valuation.length > 0) { %>
-                    <% selectedVersion.ration_valuation.forEach(function(ration) { %>
+                    <% if (selectedCompilation.ration_valuation.length > 0) { %>
+                    <% selectedCompilation.ration_valuation.forEach(function(ration) { %>
                     <tr>
                         <td><%= ration.name %></td>
                         <td>
@@ -81,8 +87,8 @@
                             <% } %>
                         </td>
                         <td>
-                            <a href="/version/valuation/ration/<%= ration.id %>" class="btn btn-sm">编辑</a>
-                            <a href="/version/valuation/ration/delete/<%= ration.id %>" class="btn btn-sm text-danger">删除</a>
+                            <a href="/compilation/valuation/ration/<%= ration.id %>" class="btn btn-sm">编辑</a>
+                            <a href="/compilation/valuation/ration/delete/<%= ration.id %>" class="btn btn-sm text-danger">删除</a>
                         </td>
                     </tr>
                     <% }) %>
@@ -91,8 +97,9 @@
                 </table>
             </div>
         </div>
-        <input type="hidden" name="id" value="<%= selectedVersion._id %>" id="version-id">
+        <input type="hidden" name="id" value="<%= selectedCompilation._id %>" id="compilation-id">
         <% } %>
 	</div>
 </div>
-<script type="text/javascript" src="/web/users/js/version.js"></script>
+<script type="text/javascript" src="/web/users/js/compilation.js"></script>
+<%include ../compilation/modal.html %>

+ 36 - 36
web/users/views/version/modal.html

@@ -1,25 +1,20 @@
-<!-- 弹窗新增版本 -->
-<div class="modal fade" id="addversion" tabindex="-1" role="dialog">
+<!-- 弹窗新增编办 -->
+<div class="modal fade" id="addcompilation" tabindex="-1" role="dialog">
     <div class="modal-dialog" role="document">
         <div class="modal-content">
             <div class="modal-header">
                 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
-                <h4 class="modal-title" id="add-version-title">添加新版本</h4>
+                <h4 class="modal-title" id="add-compilation-title">添加新编办</h4>
             </div>
             <div class="modal-body">
                 <div class="form-group" id="name-area">
-                    <label>版本名称</label>
-                    <input class="form-control" placeholder="" name="version_name">
+                    <label>编办名称</label>
+                    <input class="form-control" placeholder="" name="compilation_name">
                 </div>
                 <div class="form-group" id="bill-area">
                     <label>标准清单</label>
                     <div class="row">
-                        <div class="col-xs-4">
-                            <select class="form-control" name="standard_bill_province">
-                                <option value="">请选择省份</option>
-                            </select>
-                        </div>
-                        <div class="col-xs-8">
+                        <div class="col-xs-12">
                             <select class="form-control" name="standard_bill">
                                 <option value="">请选择标准清单</option>
                             </select>
@@ -29,22 +24,27 @@
                 <div class="form-group" id="ration-area">
                     <label>定额库</label>
                     <div class="row">
-                        <div class="col-xs-4">
-                            <select class="form-control" name="ration_lib_province">
-                                <option value="">请选择省份</option>
-                            </select>
-                        </div>
-                        <div class="col-xs-8">
+                        <div class="col-xs-12">
                             <select class="form-control" name="ration_lib">
                                 <option value="">请选择定额库</option>
                             </select>
                         </div>
                     </div>
                 </div>
+                <div class="form-group" id="glj-area">
+                    <label>工料机库</label>
+                    <div class="row">
+                        <div class="col-xs-12">
+                            <select class="form-control" name="glj_lib">
+                                <option value="">请选择工料机库</option>
+                            </select>
+                        </div>
+                    </div>
+                </div>
             </div>
             <div class="modal-footer">
                 <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
-                <button type="button" class="btn btn-primary" id="add-version">确定添加</button>
+                <button type="button" class="btn btn-primary" id="add-compilation">确定添加</button>
             </div>
         </div>
     </div>
@@ -85,25 +85,25 @@
                     <div class="col-md-3">
                         <div class="input-group">
                             <span class="input-group-addon" id="basic-addon1">空行</span>
-                            <input type="number" class="form-control input-sm" value="3">
+                            <input type="number" class="form-control input-sm" value="3" id="empty-rows">
                         </div>
                     </div>
                     <div class="col-md-3">
                         <div class="input-group">
                             <span class="input-group-addon" id="basic-addon1">数据绑定列数</span>
-                            <input type="number" class="form-control input-sm" value="4">
+                            <input type="number" class="form-control input-sm" value="4" id="col-count">
                         </div>
                     </div>
                     <div class="col-md-3">
                         <div class="input-group">
                             <span class="input-group-addon" id="basic-addon1">表头行数</span>
-                            <input type="number" class="form-control input-sm" value="1">
+                            <input type="number" class="form-control input-sm" value="1" id="header-row-count">
                         </div>
                     </div>
                     <div class="col-md-3">
                         <div class="checkbox">
                             <label>
-                                <input type="checkbox"> 是否包含树结构
+                                <input type="checkbox" id="is-tree"> 是否包含树结构
                             </label>
                         </div>
                     </div>
@@ -111,38 +111,38 @@
                 <div class="">
                     <div class="btn-toolbar" role="toolbar">
                         <div class="btn-group" role="group" >
-                            <a href="#" class="btn btn-default btn-sm">合并</a>
-                            <a href="#" class="btn btn-default btn-sm">拆分</a>
+                            <a href="#" class="btn btn-default btn-sm" id="merge">合并</a>
+                            <a href="#" class="btn btn-default btn-sm" id="unmerge">拆分</a>
                         </div>
                         <div class="btn-group" role="group">
-                            <a href="#" class="btn btn-default btn-sm">左对齐</a>
-                            <a href="#" class="btn btn-default btn-sm">居中</a>
-                            <a href="#" class="btn btn-default btn-sm">右对齐</a>
+                            <a href="#" class="btn btn-default btn-sm" id="h-left">左对齐</a>
+                            <a href="#" class="btn btn-default btn-sm" id="h-center">居中</a>
+                            <a href="#" class="btn btn-default btn-sm" id="h-right">右对齐</a>
                         </div>
                         <div class="btn-group" role="group">
-                            <a href="#" class="btn btn-default btn-sm">上对齐</a>
-                            <a href="#" class="btn btn-default btn-sm">垂直居中</a>
-                            <a href="#" class="btn btn-default btn-sm">下对齐</a>
+                            <a href="#" class="btn btn-default btn-sm" id="v-top">上对齐</a>
+                            <a href="#" class="btn btn-default btn-sm" id="v-center">垂直居中</a>
+                            <a href="#" class="btn btn-default btn-sm" id="v-bottom">下对齐</a>
                         </div>
                         <div class="btn-group" role="group">
                             <div class="input-group">
                                 <span class="input-group-addon" id="basic-addon1">字体</span>
-                                <input type="text" class="form-control input-sm" >
+                                <input type="text" class="form-control input-sm" id="font">
                                 <div class="input-group-btn">
-                                    <a href="#" class="btn btn-default btn-sm">设置</a>
+                                    <a href="#" class="btn btn-default btn-sm" id="set-font">设置</a>
                                 </div>
                             </div>
                         </div>
                     </div>
                 </div>
-                <div>
-                    S JS在此
+                <div id="colEditSpread">
                 </div>
             </div>
             <div class="modal-footer">
                 <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
-                <button type="button" class="btn btn-primary">确定</button>
+                <button type="button" class="btn btn-primary" id="save-col-setting">确定</button>
             </div>
         </div>
     </div>
-</div>
+</div>
+<script type="text/javascript" src="/web/users/js/col_setting.js"></script>

+ 4 - 44
web/users/views/layout/layout.html

@@ -9,6 +9,7 @@
     <meta name=copyright content="smartcost.com.cn">
     <link rel="stylesheet" href="/web/users/css/bootstrap.min.css">
     <link rel="stylesheet" href="/web/users/css/style.css">
+    <link rel="stylesheet" href="/lib/spreadjs/sheets/css/gc.spread.sheets.excel2013lightGray.10.0.1.css" type="text/css">
     <script src="/lib/jquery/jquery.min.js"></script>
     <script src="/web/users/js/lib/bootstrap.min.js"></script>
     <script src="/web/users/js/global.js"></script>
@@ -16,6 +17,9 @@
     <script src="/web/users/js/lib/validate.extend.js"></script>
     <script src="/web/users/js/lib/messages_zh.js"></script>
     <script src="/web/users/js/lib/bootstrap-paginator.js"></script>
+    <!-- spreadJs -->
+    <script type="text/javascript" src="/lib/spreadjs/sheets/gc.spread.sheets.all.10.0.1.min.js"></script>
+    <script>GC.Spread.Sheets.LicenseKey = "559432293813965#A0y3iTOzEDOzkjMyMDN9UTNiojIklkI1pjIEJCLi4TPB9mM5AFNTd4cvZ7SaJUVy3CWKtWYXx4VVhjMpp7dYNGdx2ia9sEVlZGOTh7NRlTUwkWR9wEV4gmbjBDZ4ElR8N7cGdHVvEWVBtCOwIGW0ZmeYVWVr3mI0IyUiwCMzETN8kzNzYTM0IicfJye&Qf35VfiEzRwEkI0IyQiwiIwEjL6ByUKBCZhVmcwNlI0IiTis7W0ICZyBlIsIyNyMzM5ADI5ADNwcTMwIjI0ICdyNkIsIibj9SbvNmL4N7bjRnch56ciojIz5GRiwiI8+Y9sWY9QmZ0Jyp96uL9v6L0wap9biY9qiq95q197Wr9g+89iojIh94Wiqi";</script>
 </head>
 <body>
 <div class="header">
@@ -55,48 +59,4 @@
         <%- body %>
     </div>
 </div>
-<div class="modal fade" id="edit-account" tabindex="-1" role="dialog">
-    <div class="modal-dialog" role="document">
-        <div class="modal-content">
-            <div class="modal-header">
-                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
-                <h4 class="modal-title">编辑账号</h4>
-            </div>
-            <div class="modal-body">
-                <div class="form-group">
-                    <label>权限</label>
-                    <div class="checkbox">
-                        <label>
-                            <input type="checkbox" name="permission[]" data-permission="manager"> 用户管理
-                        </label>&nbsp;
-                        <label>
-                            <input type="checkbox" name="permission[]" data-permission="notify"> 通知管理
-                        </label>&nbsp;
-                        <label>
-                            <input type="checkbox" name="permission[]" data-permission="stdBillsmain"> 清单规则编辑器
-                        </label>&nbsp;
-                        <label>
-                            <input type="checkbox" name="permission[]" data-permission="rationRepository"> 定额编辑器
-                        </label>&nbsp;
-                        <label>
-                            <input type="checkbox" name="permission[]" data-permission="report"> 报表模板
-                        </label>
-                    </div>
-                </div>
-                <div class="form-group">
-                    <label>禁止登录</label>
-                    <div class="checkbox">
-                        <label>
-                            <input type="checkbox" name="can_login"> 是
-                        </label>
-                    </div>
-                </div>
-            </div>
-            <div class="modal-footer">
-                <button type="button" class="btn btn-primary" id="save-manager">确定</button>
-            </div>
-        </div>
-    </div>
-</div>
-<%include ../version/modal.html %>
 </body>

+ 44 - 1
web/users/views/manager/index.html

@@ -53,4 +53,47 @@
         </div>
     </div>
 </div>
-<script type="text/javascript" src="/web/users/js/manager.js"></script>
+<script type="text/javascript" src="/web/users/js/manager.js"></script>
+<div class="modal fade" id="edit-account" tabindex="-1" role="dialog">
+    <div class="modal-dialog" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
+                <h4 class="modal-title">编辑账号</h4>
+            </div>
+            <div class="modal-body">
+                <div class="form-group">
+                    <label>权限</label>
+                    <div class="checkbox">
+                        <label>
+                            <input type="checkbox" name="permission[]" data-permission="manager"> 用户管理
+                        </label>&nbsp;
+                        <label>
+                            <input type="checkbox" name="permission[]" data-permission="notify"> 通知管理
+                        </label>&nbsp;
+                        <label>
+                            <input type="checkbox" name="permission[]" data-permission="stdBillsmain"> 清单规则编辑器
+                        </label>&nbsp;
+                        <label>
+                            <input type="checkbox" name="permission[]" data-permission="rationRepository"> 定额编辑器
+                        </label>&nbsp;
+                        <label>
+                            <input type="checkbox" name="permission[]" data-permission="report"> 报表模板
+                        </label>
+                    </div>
+                </div>
+                <div class="form-group">
+                    <label>禁止登录</label>
+                    <div class="checkbox">
+                        <label>
+                            <input type="checkbox" name="can_login"> 是
+                        </label>
+                    </div>
+                </div>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-primary" id="save-manager">确定</button>
+            </div>
+        </div>
+    </div>
+</div>

+ 0 - 16
web/users/views/version/common.html

@@ -1,16 +0,0 @@
-<div class="panel-sidebar">
-    <div class="panel-title">
-        <div class="title-bar">
-            <h2><a class="pull-right add-version" title="添加新版本" href="javascript:void(0)" data-model="all"><span class="glyphicon glyphicon-plus"></span></a>版本管理</h2>
-        </div>
-    </div>
-    <div class="scrollbar-auto">
-        <div class="nav-box">
-            <ul class="nav-list list-unstyled" id="version-select">
-                <% versionList.forEach(function (version){ %>
-                <li <% if(selectedVersion._id.toString() === version._id.toString()) { %>class="active"<% } %>><a href="/version?id=<%= version._id %>"><span><%= version.name %></span><% if (!version.is_release) { %><span class="text-muted">(未发布)</span><% } %></a></li>
-                <% }) %>
-            </ul>
-        </div>
-    </div>
-</div>