Преглед на файлове

Merge branch '1.0.0_online' of http://smartcost.f3322.net:3000/SmartCost/ConstructionOperation into 1.0.0_online

TonyKang преди 6 години
родител
ревизия
31b9c6576a
променени са 55 файла, в които са добавени 2276 реда и са изтрити 458 реда
  1. 7 3
      modules/common/std/schemas/std_calc_program.js
  2. 8 3
      modules/common/std/schemas/std_fee_rate_libs.js
  3. 100 0
      modules/calc_program_lib/controllers/calc_program_controller.js
  4. 54 0
      modules/calc_program_lib/facade/calc_program_facade.js
  5. 19 0
      modules/calc_program_lib/routes/calc_program_routes.js
  6. 2 2
      modules/common/std/std_calc_program_model.js
  7. 2 2
      modules/common/std/std_fee_rate_libs_model.js
  8. 100 0
      modules/fee_rate_lib/controllers/fee_rate_controller.js
  9. 50 0
      modules/fee_rate_lib/facade/fee_rate_facade.js
  10. 21 0
      modules/fee_rate_lib/routes/fee_rate_routes.js
  11. 26 7
      modules/main_col_lib/controllers/main_col_controller.js
  12. 1 0
      modules/main_col_lib/routes/main_col_routes.js
  13. 0 8
      modules/project_feature_lib/routes/project_feature_router.js
  14. 28 5
      modules/ration_repository/controllers/repository_views_controller.js
  15. 12 0
      modules/std_billsGuidance_lib/controllers/libController.js
  16. 66 1
      modules/std_billsGuidance_lib/facade/facades.js
  17. 11 9
      modules/std_billsGuidance_lib/routes/routes.js
  18. 57 1
      modules/std_glj_lib/controllers/gljController.js
  19. 81 0
      modules/std_glj_lib/models/gljModel.js
  20. 2 0
      modules/std_glj_lib/routes/routes.js
  21. 4 2
      public/counter/counter.js
  22. 3 2
      public/web/common_ajax.js
  23. 13 1
      public/web/sheet/sheet_common.js
  24. 16 8
      public/web/tree_sheet/tree_sheet_controller.js
  25. 8 0
      public/web/tree_sheet/tree_sheet_helper.js
  26. 3 0
      web/maintain/billsGuidance_lib/js/billsGuidance.js
  27. 1 1
      web/maintain/bills_lib/scripts/tools.js
  28. 35 0
      web/maintain/calc_program_lib/html/edit.html
  29. 124 0
      web/maintain/calc_program_lib/html/main.html
  30. 90 0
      web/maintain/calc_program_lib/js/calc_program.js
  31. 37 0
      web/maintain/calc_program_lib/js/calc_program_edit.js
  32. 1 1
      web/maintain/common/html/edit_layout.html
  33. 1 0
      web/maintain/common/html/layout.html
  34. 45 0
      web/maintain/common/js/util.js
  35. 35 0
      web/maintain/fee_rate_lib/html/edit.html
  36. 113 0
      web/maintain/fee_rate_lib/html/main.html
  37. 81 0
      web/maintain/fee_rate_lib/js/fee_rate.js
  38. 36 0
      web/maintain/fee_rate_lib/js/fee_rate_edit.js
  39. 36 0
      web/maintain/main_col_lib/html/edit.html
  40. 1 1
      web/maintain/main_col_lib/html/main.html
  41. 50 0
      web/maintain/main_col_lib/js/main_col_edit.js
  42. 4 9
      web/maintain/project_feature_lib/js/project_feature_edit.js
  43. 4 0
      web/maintain/ration_repository/dinge.html
  44. 4 0
      web/maintain/ration_repository/gongliao.html
  45. 6 0
      web/maintain/ration_repository/js/ration_glj.js
  46. 6 0
      web/maintain/ration_repository/js/repository_glj.js
  47. 3 5
      web/maintain/std_glj_lib/html/gongliao.html
  48. 29 1
      web/maintain/std_glj_lib/html/main.html
  49. 85 27
      web/maintain/std_glj_lib/js/components.js
  50. 392 229
      web/maintain/std_glj_lib/js/glj.js
  51. 244 110
      web/maintain/std_glj_lib/js/gljComponent.js
  52. 73 2
      web/maintain/std_glj_lib/js/main.js
  53. 30 16
      web/maintain/std_glj_lib/js/sheetsOpr.js
  54. 2 2
      web/over_write/js/jiangxi_2017.js
  55. 14 0
      web/users/views/tool/index.html

+ 7 - 3
modules/common/std/schemas/std_calc_program.js

@@ -9,6 +9,7 @@ import mongoose from "mongoose";
 
 let Schema = mongoose.Schema;
 let collectionName = 'std_calc_programs';
+const oprSchema = require('../all_schemas/opr_schema');
 let modelSchema = {
     // 自增id
     ID: Number,
@@ -23,9 +24,12 @@ let modelSchema = {
         type: String,
         index: true
     },
+    compilationName:String,
     // 模板数据
-    templates: Schema.Types.Mixed
+    templates: {type:[Schema.Types.Mixed],default:[]},
+    creator: String,
+    createDate: Number,
+    recentOpr: [oprSchema]
 };
 
-let model = mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));
-export {model as default, collectionName as collectionName};
+mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));

+ 8 - 3
modules/common/std/schemas/std_fee_rate_libs.js

@@ -9,6 +9,7 @@ import mongoose from "mongoose";
 
 let Schema = mongoose.Schema;
 let collectionName = 'std_fee_rate_libs';
+const oprSchema = require('../all_schemas/opr_schema');
 
 let optionSchema = new Schema({
     name:String,
@@ -53,9 +54,13 @@ let modelSchema = {
         type: String,
         index: true
     },
+    compilationName:String,
     // 费率数据
-    rates: [ratesSchema]
+    rates: {type:[ratesSchema],default:[]},
+    creator: String,
+    createDate: Number,
+    recentOpr: [oprSchema]
 };
 
-let model = mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));
-export {model as default, collectionName as collectionName};
+ mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));
+

+ 100 - 0
modules/calc_program_lib/controllers/calc_program_controller.js

@@ -0,0 +1,100 @@
+/**
+ * Created by zhang on 2018/9/11.
+ */
+import BaseController from "../../common/base/base_controller";
+let config = require("../../../config/config.js");
+import calcProgramFacade from "../facade/calc_program_facade";
+
+class CalcProgramController extends BaseController {
+    async main(request, response) {
+        let calcProgramLibs = await calcProgramFacade.findByCondition({}, {templates: 0}, false);
+        let randerData = {
+            title: '计算程序模板库',
+            userAccount: request.session.managerData.username,
+            userID: request.session.managerData.userID,
+            calcProgramLibs: calcProgramLibs,
+            layout: 'maintain/common/html/layout'
+        };
+        response.render("maintain/calc_program_lib/html/main", randerData);
+    }
+    async addLib(request, response){
+        try {
+            await calcProgramFacade.addLib(request.body);
+        }catch (error) {
+            console.log(error);
+        }
+        response.redirect(request.headers.referer);
+    }
+    async findLib(request, response){
+        let result={
+            error:0
+        };
+        try {
+            let data = request.body.data;
+            data = JSON.parse(data);
+            let conditions={ID:data.ID};
+            let resultData = await calcProgramFacade.findByCondition(conditions);
+            result.data=resultData;
+        }catch (err){
+            console.log(err);
+            result.error=1;
+            result.message = err.message;
+        }
+        response.json(result);
+    }
+    async saveLib(request, response){
+        let result={
+            error:0
+        };
+        try {
+            let data = request.body.data;
+            data = JSON.parse(data);
+            let resultData= await calcProgramFacade.saveLib(data);
+            result.data=resultData;
+        }catch (err){
+            console.log(err);
+            result.error=1;
+            result.message = err.message;
+        }
+        response.json(result);
+    }
+    async deleteLibByID(request,response){
+        let result={
+            error:0
+        };
+        try {
+            let data = request.body.data;
+            data = JSON.parse(data);
+            let resultData= await calcProgramFacade.deleteLibByID(data.ID);
+            result.data=resultData;
+        }catch (err){
+            console.log(err);
+            result.error=1;
+            result.message = err.message;
+        }
+        response.json(result);
+    }
+    async edit(request,response){
+        //先取出替换库信息:
+        let libID = request.params.libID;
+        let programLib = await calcProgramFacade.findByCondition({'ID':libID});
+        if(programLib){
+            let randerData = {
+                title:'计算程序模板库',
+                mainURL:'/calcProgram/main',
+                libName:programLib.libName,
+                userAccount: request.session.managerData.username,
+                userID: request.session.managerData.userID,
+                templateList:JSON.stringify(programLib.templates),
+                libID:libID,
+                LicenseKey:config.getLicenseKey(process.env.NODE_ENV),
+                layout: 'maintain/common/html/edit_layout'
+            };
+            response.render("maintain/calc_program_lib/html/edit", randerData);
+        }else {
+            response.redirect(request.headers.referer);
+        }
+    }
+}
+
+export default CalcProgramController;

+ 54 - 0
modules/calc_program_lib/facade/calc_program_facade.js

@@ -0,0 +1,54 @@
+/**
+ * Created by zhang on 2018/9/11.
+ */
+
+import mongoose from "mongoose";
+
+const uuidV1 = require('uuid/v1');
+let moment = require("moment");
+let calcProgramModel = mongoose.model("std_calc_programs");
+let compilationModel = mongoose.model("compilation");
+const _ = require('lodash');
+let counter = require('../../../public/counter/counter');
+
+let calcProgramLib = {
+    findByCondition:async function(conditions,options,single=true){
+        if(single == true){
+            return await calcProgramModel.findOne(conditions,options);
+        }else {
+            return await  calcProgramModel.find(conditions,options);
+        }
+    },
+    addLib : async function (data){
+        let now = new Date().getTime();
+        let dateStr = moment(now).format('YYYY-MM-DD HH:mm:ss');
+        //取编办信息
+        let compilation = await compilationModel.findOne({_id:data.compilationId});
+        if(compilation){
+            let IDcounter = await counter.counterDAO.getIDAfterCount(counter.moduleName.stdCalcProgram,1);
+            let newLib = {
+                creator: data.userAccount,
+                createDate: now,
+                recentOpr: [{operator: data.userAccount, operateDate: dateStr}],
+                libName: data.name,
+                displayName:data.displayName,
+                compilationId: data.compilationId,
+                compilationName: compilation.name,
+                templates:[]
+            };
+            newLib.ID = IDcounter.sequence_value;
+            return await calcProgramModel.create(newLib);
+        }else {
+            throw  new Error("没有找到该编办!");
+        }
+
+    },
+    saveLib:async function(param) {
+        return await calcProgramModel.findOneAndUpdate(param.query,param.data,{new:true});
+    },
+    deleteLibByID:async function(ID){
+        return await calcProgramModel.deleteOne({ID:ID});
+    },
+};
+
+export default calcProgramLib

+ 19 - 0
modules/calc_program_lib/routes/calc_program_routes.js

@@ -0,0 +1,19 @@
+/**
+ * Created by zhang on 2018/9/11.
+ */
+
+let express = require("express");
+let calcProgramRouter =express.Router();
+import CalcProgramController from "../controllers/calc_program_controller";
+let calcProgramController = new CalcProgramController();
+
+module.exports =function (app) {
+
+    calcProgramRouter.get("/main", calcProgramController.auth, calcProgramController.init, calcProgramController.main);
+    calcProgramRouter.post("/addLib", calcProgramController.auth, calcProgramController.init, calcProgramController.addLib);
+    calcProgramRouter.post("/findLib", calcProgramController.auth, calcProgramController.init, calcProgramController.findLib);
+    calcProgramRouter.post("/saveLib", calcProgramController.auth, calcProgramController.init, calcProgramController.saveLib);
+    calcProgramRouter.post("/deleteLibByID", calcProgramController.auth, calcProgramController.init, calcProgramController.deleteLibByID);
+    calcProgramRouter.get("/edit/:libID", calcProgramController.auth, calcProgramController.init, calcProgramController.edit);
+    app.use("/calcProgram", calcProgramRouter);
+};

+ 2 - 2
modules/common/std/std_calc_program_model.js

@@ -6,7 +6,7 @@
  * @version
  */
 import BaseModel from "../base/base_model";
-import STDCalcProgramSchema from "./schemas/std_calc_program";
+import mongoose from "mongoose";
 
 class STDCalcProgramModel extends BaseModel {
 
@@ -17,7 +17,7 @@ class STDCalcProgramModel extends BaseModel {
      */
     constructor() {
         let parent = super();
-        parent.model = STDCalcProgramSchema;
+        parent.model = mongoose.model("std_calc_programs");
         parent.init();
     }
 

+ 2 - 2
modules/common/std/std_fee_rate_libs_model.js

@@ -6,7 +6,7 @@
  * @version
  */
 import BaseModel from "../base/base_model";
-import STDFeeRateLibsSchema from "./schemas/std_fee_rate_libs";
+import mongoose from "mongoose";
 
 class STDFeeRateLibsModel extends BaseModel {
 
@@ -17,7 +17,7 @@ class STDFeeRateLibsModel extends BaseModel {
      */
     constructor() {
         let parent = super();
-        parent.model = STDFeeRateLibsSchema;
+        parent.model = mongoose.model("std_fee_rate_libs");
         parent.init();
     }
 

+ 100 - 0
modules/fee_rate_lib/controllers/fee_rate_controller.js

@@ -0,0 +1,100 @@
+/**
+ * Created by zhang on 2018/9/10.
+ */
+import BaseController from "../../common/base/base_controller";
+let config = require("../../../config/config.js");
+import feeRateFacade from "../facade/fee_rate_facade";
+
+class FeeRateController extends BaseController{
+    async main(request, response) {
+        let feeRateLibs = await feeRateFacade.findByCondition({},{rates:0},false);
+        let randerData = {
+            title:'费率标准库',
+            userAccount: request.session.managerData.username,
+            userID: request.session.managerData.userID,
+            feeRateLibs:feeRateLibs,
+            layout: 'maintain/common/html/layout'
+        };
+        response.render("maintain/fee_rate_lib/html/main", randerData);
+    }
+    async addLib(request, response){
+        try {
+            await feeRateFacade.addLib(request.body);
+        }catch (error) {
+            console.log(error);
+        }
+        response.redirect(request.headers.referer);
+    }
+    async findLib(request, response){
+        let result={
+            error:0
+        };
+        try {
+            let data = request.body.data;
+            data = JSON.parse(data);
+            let conditions={ID:data.ID};
+            let resultData = await feeRateFacade.findByCondition(conditions);
+            result.data=resultData;
+        }catch (err){
+            console.log(err);
+            result.error=1;
+            result.message = err.message;
+        }
+        response.json(result);
+    }
+    async saveLib(request, response){
+        let result={
+            error:0
+        };
+        try {
+            let data = request.body.data;
+            data = JSON.parse(data);
+            let resultData= await feeRateFacade.saveLib(data);
+            result.data=resultData;
+        }catch (err){
+            console.log(err);
+            result.error=1;
+            result.message = err.message;
+        }
+        response.json(result);
+    }
+    async deleteLibByID(request,response){
+        let result={
+            error:0
+        };
+        try {
+            let data = request.body.data;
+            data = JSON.parse(data);
+            let resultData= await feeRateFacade.deleteLibByID(data.ID);
+            result.data=resultData;
+        }catch (err){
+            console.log(err);
+            result.error=1;
+            result.message = err.message;
+        }
+        response.json(result);
+    }
+    async edit(request,response){
+        //先取出替换库信息:
+        let libID = request.params.libID;
+        let feeRateLib = await feeRateFacade.findByCondition({'ID':libID});
+        if(feeRateLib){
+            let randerData = {
+                title:'费率标准库',
+                mainURL:'/feeRate/main',
+                libName:feeRateLib.libName,
+                userAccount: request.session.managerData.username,
+                userID: request.session.managerData.userID,
+                rateList:JSON.stringify(feeRateLib.rates),
+                libID:libID,
+                LicenseKey:config.getLicenseKey(process.env.NODE_ENV),
+                layout: 'maintain/common/html/edit_layout'
+            };
+            response.render("maintain/fee_rate_lib/html/edit", randerData);
+        }else {
+            response.redirect(request.headers.referer);
+        }
+    }
+}
+
+export default FeeRateController;

+ 50 - 0
modules/fee_rate_lib/facade/fee_rate_facade.js

@@ -0,0 +1,50 @@
+/**
+ * Created by zhang on 2018/9/10.
+ */
+
+import mongoose from "mongoose";
+
+const uuidV1 = require('uuid/v1');
+let moment = require("moment");
+let feeRateModel = mongoose.model('std_fee_rate_libs');
+let compilationModel = mongoose.model("compilation");
+const _ = require('lodash');
+
+let feeRateLib = {
+    findByCondition:async function(conditions,options,single=true){
+        if(single == true){
+            return await feeRateModel.findOne(conditions,options);
+        }else {
+            return await  feeRateModel.find(conditions,options);
+        }
+    },
+    addLib : async function (data){
+        let now = new Date().getTime();
+        let dateStr = moment(now).format('YYYY-MM-DD HH:mm:ss');
+        //取编办信息
+        let compilation = await compilationModel.findOne({_id:data.compilationId});
+        if(compilation){
+            let newLib = {
+                creator: data.userAccount,
+                createDate: now,
+                recentOpr: [{operator: data.userAccount, operateDate: dateStr}],
+                libName: data.name,
+                compilationId: data.compilationId,
+                compilationName: compilation.name,
+            };
+            newLib.ID = uuidV1();
+            return await feeRateModel.create(newLib);
+        }else {
+            throw  new Error("没有找到该编办!");
+        }
+
+    },
+    saveLib:async function(param) {
+        return await feeRateModel.findOneAndUpdate(param.query,param.data,{new:true});
+    },
+    deleteLibByID:async function(ID){
+        return await feeRateModel.deleteOne({ID:ID});
+    },
+};
+
+export default feeRateLib

+ 21 - 0
modules/fee_rate_lib/routes/fee_rate_routes.js

@@ -0,0 +1,21 @@
+/**
+ * Created by zhang on 2018/9/10.
+ */
+
+let express = require("express");
+let feeRateRouter =express.Router();
+import FeeRateController from "../controllers/fee_rate_controller";
+let feeRateController = new FeeRateController();
+
+module.exports =function (app) {
+
+    feeRateRouter.get("/main", feeRateController.auth, feeRateController.init, feeRateController.main);
+    feeRateRouter.post("/addLib", feeRateController.auth, feeRateController.init, feeRateController.addLib);
+    feeRateRouter.post("/findLib", feeRateController.auth, feeRateController.init, feeRateController.findLib);
+    feeRateRouter.post("/saveLib", feeRateController.auth, feeRateController.init, feeRateController.saveLib);
+    feeRateRouter.post("/deleteLibByID", feeRateController.auth, feeRateController.init, feeRateController.deleteLibByID);
+    feeRateRouter.get("/edit/:libID", feeRateController.auth, feeRateController.init, feeRateController.edit);
+
+
+    app.use("/feeRate", feeRateRouter);
+};

+ 26 - 7
modules/main_col_lib/controllers/main_col_controller.js

@@ -12,13 +12,6 @@ let config = require("../../../config/config.js");
 
 class MainColController extends BaseController {
 
-    /**
-     * 修改计价规则页面
-     *
-     * @param {object} request
-     * @param {object} response
-     * @return {void}
-     */
     async main(request, response) {
         let mainColLibs = await mainColFacade.getAllLibs();
         let randerData = {
@@ -93,6 +86,32 @@ class MainColController extends BaseController {
         response.json(result);
     }
 
+    async edit(request,response){
+        let result = {
+            error:0
+        }
+        //先取出替换库信息:
+        let libID = request.params.libID;
+        let colLib = await mainColFacade.getLibByID(libID);
+        if(colLib){
+            let randerData = {
+                title:'列设置库',
+                mainURL:'/mainTreeCol/main',
+                libName:colLib.name,
+                userAccount: request.session.managerData.username,
+                userID: request.session.managerData.userID,
+                main_tree_col:JSON.stringify(colLib.main_tree_col),
+                libID:libID,
+                LicenseKey:config.getLicenseKey(process.env.NODE_ENV),
+                layout: 'maintain/common/html/edit_layout'
+            };
+            response.render("maintain/main_col_lib/html/edit", randerData);
+        }else {
+            response.redirect(request.headers.referer);
+        }
+
+    }
+
     /*async updateBillsTemplateItem(request, response) {
         let libID = request.params.libID;
         let result = {error: 1, message: '更新数据错误', data: null};

+ 1 - 0
modules/main_col_lib/routes/main_col_routes.js

@@ -15,6 +15,7 @@ module.exports =function (app) {
     colRouter.post("/deleteLibByID", mainColController.auth, mainColController.init, mainColController.deleteLibByID);
     colRouter.post("/getLibByID", mainColController.auth, mainColController.init, mainColController.getLibByID);
     colRouter.post("/saveLib", mainColController.auth, mainColController.init, mainColController.saveLib);
+    colRouter.get("/edit/:libID", mainColController.auth, mainColController.init, mainColController.edit);
     /*colRouter.get("/editTemplate/:libID", mainColController.auth, mainColController.init, mainColController.editTemplate);
     colRouter.post("/getLibByID", mainColController.auth, mainColController.init, mainColController.getLibByID);
     colRouter.post("/saveLib", mainColController.auth, mainColController.init, mainColController.saveLib);

+ 0 - 8
modules/project_feature_lib/routes/project_feature_router.js

@@ -15,14 +15,6 @@ module.exports =function (app){
     featureRouter.post("/saveLib", featureController.auth, featureController.init, featureController.saveLib);
     featureRouter.post("/deleteLibByID", featureController.auth, featureController.init, featureController.deleteLibByID);
     featureRouter.get("/edit/:libID", featureController.auth, featureController.init, featureController.edit);
-/*    repRouter.get("/edit/:libID", replaceController.auth, replaceController.init, replaceController.edit);
-    repRouter.post("/findLib", replaceController.auth, replaceController.init, replaceController.findLib);
-    repRouter.post("/addLib", replaceController.auth, replaceController.init, replaceController.addLib);
-    repRouter.post("/saveLib", replaceController.auth, replaceController.init, replaceController.saveLib);
-    repRouter.post("/deleteLibByID", replaceController.auth, replaceController.init, replaceController.deleteLibByID);
-    repRouter.post("/saveBills", replaceController.auth, replaceController.init, replaceController.saveBills);
-    repRouter.post("/saveMaterial", replaceController.auth, replaceController.init, replaceController.saveMaterial);
-    repRouter.post("/findMaterial", replaceController.auth, replaceController.init, replaceController.findMaterial);*/
     app.use("/projectFeature", featureRouter);
 };
 

+ 28 - 5
modules/ration_repository/controllers/repository_views_controller.js

@@ -3,6 +3,10 @@
  */
 import BaseController from "../../common/base/base_controller";
 let config = require("../../../config/config.js");
+import mongoose from 'mongoose';
+const compilationModel = mongoose.model('compilation');
+const rationLibModel = mongoose.model('std_ration_lib_map');
+const fs = require('fs');
 class ViewsController extends BaseController{
     redirectMain(req, res){
         res.render('maintain/ration_repository/main.html',
@@ -11,12 +15,20 @@ class ViewsController extends BaseController{
                 userID: req.session.managerData.userID
             });
     }
-    //rationRepository/lmm rationRepository/coeList rationRepository/installation
-    redirectRation(req, res){
+    async redirectRation(req, res){
         const repId = req.query.repository;
         const redirectGlj = `/rationRepository/lmm?repository=${repId}`;
         const redirectCoe = `/rationRepository/coeList?repository=${repId}`;
         const redirectInstallation = `/rationRepository/installation?repository=${repId}`;
+        let overWriteUrl = null;
+        let priceProperties = [];
+        let stdRationLib = await rationLibModel.findOne({ID: repId});
+        if(stdRationLib){
+            let compilation = await compilationModel.findOne({_id: mongoose.Types.ObjectId(stdRationLib.compilationId)});
+            priceProperties = compilation.priceProperties ? compilation.priceProperties : [];
+            let absoluteUrl = compilation.overWriteUrl ? req.app.locals.rootDir + compilation.overWriteUrl : req.app.locals.rootDir;
+            overWriteUrl = fs.existsSync(absoluteUrl) && fs.statSync(absoluteUrl).isFile()? compilation.overWriteUrl : null;
+        }
         res.render('maintain/ration_repository/dinge.html',
             {
                 userAccount: req.session.managerData.username,
@@ -24,14 +36,24 @@ class ViewsController extends BaseController{
                 redirectGlj: redirectGlj,
                 redirectCoe: redirectCoe,
                 redirectInstallation: redirectInstallation,
-                LicenseKey:config.getLicenseKey(process.env.NODE_ENV)
+                LicenseKey:config.getLicenseKey(process.env.NODE_ENV),
+                priceProperties: JSON.stringify(priceProperties)
             });
     }
-    redirectGlj(req, res){
+    async redirectGlj(req, res){
         const repId = req.query.repository;
         const redirectRation = `/rationRepository/ration?repository=${repId}`;
         const redirectCoe = `/rationRepository/coeList?repository=${repId}`;
         const redirectInstallation = `/rationRepository/installation?repository=${repId}`;
+        let overWriteUrl = null;
+        let priceProperties = [];
+        let stdRationLib = await rationLibModel.findOne({ID: repId});
+        if(stdRationLib){
+            let compilation = await compilationModel.findOne({_id: mongoose.Types.ObjectId(stdRationLib.compilationId)});
+            priceProperties = compilation.priceProperties ? compilation.priceProperties : [];
+            let absoluteUrl = compilation.overWriteUrl ? req.app.locals.rootDir + compilation.overWriteUrl : req.app.locals.rootDir;
+            overWriteUrl = fs.existsSync(absoluteUrl) && fs.statSync(absoluteUrl).isFile()? compilation.overWriteUrl : null;
+        }
         res.render('maintain/ration_repository/gongliao.html',
             {
                 userAccount: req.session.managerData.username,
@@ -39,7 +61,8 @@ class ViewsController extends BaseController{
                 redirectRation: redirectRation,
                 redirectCoe: redirectCoe,
                 redirectInstallation: redirectInstallation,
-                LicenseKey:config.getLicenseKey(process.env.NODE_ENV)
+                LicenseKey:config.getLicenseKey(process.env.NODE_ENV),
+                priceProperties: JSON.stringify(priceProperties)
             });
     }
     redirectCoeList(req, res){

+ 12 - 0
modules/std_billsGuidance_lib/controllers/libController.js

@@ -87,6 +87,18 @@ class BillsGuideLibController extends BaseController{
             callback(req, res, 1, err, null);
         }
     }
+
+    async testItems(req, res){
+        try{
+            let data = JSON.parse(req.body.data);
+            let rst = await billsGuidanceFacade.testItems(data.libID);
+            res.json({error: 0, data: rst, message: ''});
+        }
+        catch (error){
+            res.json({error: 1, data: null, message: error});
+
+        }
+    }
 }
 
 export default BillsGuideLibController;

+ 66 - 1
modules/std_billsGuidance_lib/facade/facades.js

@@ -28,7 +28,8 @@ module.exports = {
     updateBillsGuideLib,
     getLibWithBills,
     getItemsBybills,
-    updateItems
+    updateItems,
+    testItems
 };
 
 async function getCompilationList() {
@@ -238,4 +239,68 @@ async function updateItems(updateDatas) {
     if(bulkArr.length > 0){
         await billsGuideItemsModel.bulkWrite(bulkArr);
     }
+}
+
+async function testItems(libID) {
+    let items = await billsGuideItemsModel.find({libID: libID});
+    //删除垃圾数据
+    let delBulk = [];
+    let itemsMapping = {};
+    for(let item of items){
+        itemsMapping[item.ID] = true;
+    }
+    for(let item of items){
+        if(item.ParentID != -1 && !itemsMapping[item.ParentID]){
+            delBulk.push({
+                deleteOne: {
+                    filter: {ID: item.ID}
+                }
+            });
+        }
+    }
+    if(delBulk.length > 0){
+        console.log(`delBulk.length`);
+        console.log(delBulk.length);
+        await billsGuideItemsModel.bulkWrite(delBulk);
+    }
+ /*   //查找同层节点含有相同NextSiblingID的节点
+    let rst = [];
+    let billsGroup = {};
+    for(let item of items){
+        if(!billsGroup[item.billsID]){
+            billsGroup[item.billsID] = [item];
+        }
+        else {
+            billsGroup[item.billsID].push(item);
+        }
+    }
+    for(let bGroup in billsGroup){
+        let group = billsGroup[bGroup];
+        let parentGroup = {};
+        for(let gItem of group){
+            if(!parentGroup[gItem.ParentID]){
+                parentGroup[gItem.ParentID] = [gItem]
+            }
+            else {
+                parentGroup[gItem.ParentID].push(gItem);
+            }
+        }
+        for(let pGroup in parentGroup){
+            let pGroupData = parentGroup[pGroup];
+            let nextGroup = {};
+            for(let nItem of pGroupData){
+                let sameNext = _.filter(pGroupData, {NextSiblingID: nItem.NextSiblingID});
+                if(sameNext.length > 1){
+                    console.log(`sameNext`);
+                    console.log(sameNext);
+                    if(!nextGroup[nItem.ParentID + nItem.NextSiblingID]){
+                        rst.push({NextSiblingID: nItem.NextSiblingID, ParentID: nItem.ParentID});
+                        nextGroup[nItem.ParentID + nItem.NextSiblingID] = 1;
+                    }
+                }
+            }
+        }
+
+    }*/
+    return delBulk.length;
 }

+ 11 - 9
modules/std_billsGuidance_lib/routes/routes.js

@@ -15,15 +15,17 @@ const billsGuideLibController = new BillsGuideLibController();
 const viewsController = new ViewsController();
 
 module.exports = function (app) {
-  app.get('/billsGuidance/main', viewsController.auth, viewsController.init, viewsController.redirectMain);
-  app.get('/billsGuidance/guidance', viewsController.auth, viewsController.init, viewsController.redirectGuidance);
-  router.post('/getComBillsLibInfo', billsGuideLibController.auth, billsGuideLibController.init, billsGuideLibController.getComBillsLibInfo);
-  router.post('/getBillsGuideLibs', billsGuideLibController.auth, billsGuideLibController.init, billsGuideLibController.getBillsGuideLibs);
-  router.post('/updateBillsGuideLib', billsGuideLibController.auth, billsGuideLibController.init, billsGuideLibController.updateBillsGuideLib);
-  router.post('/getLibWithBills', billsGuideLibController.auth, billsGuideLibController.init, billsGuideLibController.getLibWithBills);
-  router.post('/getItemsByBills', billsGuideLibController.auth, billsGuideLibController.init, billsGuideLibController.getItemsByBills);
-  router.post('/updateItems', billsGuideLibController.auth, billsGuideLibController.init, billsGuideLibController.updateItems);
+    app.get('/billsGuidance/main', viewsController.auth, viewsController.init, viewsController.redirectMain);
+    app.get('/billsGuidance/guidance', viewsController.auth, viewsController.init, viewsController.redirectGuidance);
+    router.post('/getComBillsLibInfo', billsGuideLibController.auth, billsGuideLibController.init, billsGuideLibController.getComBillsLibInfo);
+    router.post('/getBillsGuideLibs', billsGuideLibController.auth, billsGuideLibController.init, billsGuideLibController.getBillsGuideLibs);
+    router.post('/updateBillsGuideLib', billsGuideLibController.auth, billsGuideLibController.init, billsGuideLibController.updateBillsGuideLib);
+    router.post('/getLibWithBills', billsGuideLibController.auth, billsGuideLibController.init, billsGuideLibController.getLibWithBills);
+    router.post('/getItemsByBills', billsGuideLibController.auth, billsGuideLibController.init, billsGuideLibController.getItemsByBills);
+    router.post('/updateItems', billsGuideLibController.auth, billsGuideLibController.init, billsGuideLibController.updateItems);
+    //test
+    router.post('/testItems', billsGuideLibController.auth, billsGuideLibController.init, billsGuideLibController.testItems);
 
 
-  app.use('/billsGuidance/api', router);
+    app.use('/billsGuidance/api', router);
 };

+ 57 - 1
modules/std_glj_lib/controllers/gljController.js

@@ -7,10 +7,12 @@ import stdgljutil  from "../../../public/cache/std_glj_type_util";
 import GljDao from "../models/gljModel";
 import rationItemDao from "../../ration_repository/models/ration_item";
 const multiparty = require("multiparty");
+const excel = require("node-xlsx");
 const LZString = require('lz-string');
 const gljModel = mongoose.model('std_glj_lib_gljList');
 const stdRationModel = mongoose.model('std_ration_lib_ration_items');
 const cplRationModel = mongoose.model('complementary_ration_items');
+const fs = require('fs');
 
 let gljDao = new GljDao();
 let callback = function(req, res, err, message, data){
@@ -133,7 +135,7 @@ class GljController extends BaseController{
                 let updateDatas = JSON.parse(LZString.decompressFromUTF16(compressData));
                 let bulkArr = [];
                 for(let uData of updateDatas){
-                    bulkArr.push({updateOne: {filter: {ID: uData.ID}, update: {$set: {component: uData.component, basePrice: uData.basePrice}}}});
+                    bulkArr.push({updateOne: {filter: {ID: uData.ID}, update: {$set: {component: uData.component}}}});
                 }
                 if(bulkArr.length > 0){
                     await gljModel.bulkWrite(bulkArr);
@@ -188,6 +190,60 @@ class GljController extends BaseController{
             res.json({error: 1, message: error, data: null});
         }
     }
+    async importPrice(request, response) {
+        let responseData = {
+            err: 0,
+            msg: ''
+        };
+        const allowHeader = ['application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'];
+        const uploadOption = {
+            uploadDir: './public'
+        };
+        const form = new multiparty.Form(uploadOption);
+        let uploadFullName;
+        form.parse(request, async function(err, fields, files) {
+            try{
+                const gljLibId = fields.gljLibId !== undefined && fields.gljLibId.length > 0 ?
+                    fields.gljLibId[0] : 0;
+                if (gljLibId <= 0) {
+                    throw '参数错误';
+                }
+                const file = files.file !== undefined ? files.file[0] : null;
+                if (err || file === null) {
+                    throw '上传失败';
+                }
+                // 判断类型
+                if (file.headers['content-type'] === undefined || allowHeader.indexOf(file.headers['content-type']) < 0) {
+                    throw '不支持该类型';
+                }
+                // 重命名文件名
+                uploadFullName = uploadOption.uploadDir + '/' + file.originalFilename;
+                fs.renameSync(file.path, uploadFullName);
+
+                const sheet = excel.parse(uploadFullName);
+                if (sheet[0] === undefined || sheet[0].data === undefined || sheet[0].data.length <= 0) {
+                    throw 'excel没有对应数据';
+                }
+                //更新人材机价格
+                await gljDao.batchUpdateGljPrice(gljLibId, sheet[0].data);
+
+                // 删除文件
+                if(uploadFullName && fs.existsSync(uploadFullName)){
+                    fs.unlink(uploadFullName);
+                }
+                response.json(responseData);
+            }
+            catch (error){
+                console.log(error);
+                if(uploadFullName && fs.existsSync(uploadFullName)){
+                    fs.unlink(uploadFullName);
+                }
+                responseData.err = 1;
+                responseData.msg = error;
+                response.json(responseData);
+            }
+        });
+    }
 }
 
 export default GljController;

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

@@ -6,6 +6,8 @@ const gljMapModel = mongoose.model('std_glj_lib_map');
 const gljModel = mongoose.model('std_glj_lib_gljList');
 const gljClassModel = mongoose.model('std_glj_lib_gljClass');
 const gljClassTemplateModel = mongoose.model('std_glj_lib_gljClassTemplate');
+const compilationModel = mongoose.model('compilation');
+const scMathUtil = require('../../../public/scMathUtil').getUtil();
 import {OprDao} from  "./gljMapModel";
 import moment from "moment";
 import counter from "../../../public/counter/counter";
@@ -496,6 +498,85 @@ class GljDao  extends OprDao{
     async getGljItemsByRepId(repositoryId, returnFields = ''){
          return gljModel.find({"repositoryId": repositoryId}, returnFields);
     }
+
+    async batchUpdateGljPrice(gljLibId, sheetData){
+        let gljLib = await gljMapModel.findOne({ID: gljLibId});
+        if(!gljLib){
+            throw '不存在此人材机库';
+        }
+        let compilation = await compilationModel.findOne({_id: mongoose.Types.ObjectId(gljLib.compilationId)});
+        if(!compilation){
+            throw '不存在此费用定额';
+        }
+        let priceProperties = compilation.priceProperties ? compilation.priceProperties : [];
+        //根据第一行数据,获取列下标与字段名映射
+        let colMapping = {};
+        for(let col = 0; col < sheetData[0].length; col++){
+            let cData = sheetData[0][col];
+            if(cData === '编码'){
+                colMapping['code'] = col;
+            }
+            else {
+                if(priceProperties.length === 0){
+                    if(cData === '定额价'){
+                        colMapping['basePrice'] = col;
+                        break;
+                    }
+                }
+                else {
+                    for(let priceProp of priceProperties){
+                        if(priceProp.price.dataName === cData){
+                            colMapping[priceProp.price.dataCode] = col;
+                            break;
+                        }
+                    }
+                }
+            }
+        }
+        let colMappingKeys = Object.keys(colMapping);
+        if(colMappingKeys.length < 2){
+            throw 'excel数据不正确'
+        }
+        let updateBulk = [];
+        //避免重复
+        let updateCodes = [];
+        for(let row = 0; row < sheetData.length; row++){
+            if(row === 0){
+                continue;
+            }
+            let gljCode = sheetData[row][colMapping.code];
+            if(gljCode && gljCode !== '' && !updateCodes.includes(gljCode)){
+                if(priceProperties.length > 0){
+                    let priceProperty = {};
+                    for(let priceProp of priceProperties){
+                        let dataCode = priceProp.price.dataCode;
+                        let priceCellData = sheetData[row][colMapping[dataCode]];
+                        priceProperty[dataCode] = colMapping[dataCode] && priceCellData && !isNaN(priceCellData) ?
+                            scMathUtil.roundTo(parseFloat(priceCellData), -2) : 0;
+                    }
+                    updateCodes.push(gljCode);
+                    updateBulk.push({
+                        updateOne: {filter: {repositoryId: gljLibId, code: gljCode}, update: {$set: {priceProperty: priceProperty}}}
+                    });
+                }
+                else {
+                    if(colMapping.basePrice){
+                        let priceCellData = sheetData[row][colMapping.basePrice];
+                        let basePrice = priceCellData  && !isNaN(priceCellData) ?
+                            scMathUtil.roundTo(priceCellData, -2) : 0;
+                        updateCodes.push(gljCode);
+                        updateBulk.push({
+                            updateOne: {filter: {repositoryId: gljLibId, code: gljCode}, update: {$set: {basePrice: basePrice}}}
+                        });
+                    }
+                }
+            }
+        }
+        if(updateBulk.length > 0){
+            await gljModel.bulkWrite(updateBulk);
+        }
+
+    }
 }
 
 export default GljDao;

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

@@ -40,6 +40,8 @@ module.exports = function (app) {
     router.post("/getGljItemsByCodes",gljController.auth, gljController.init, gljController.getGljItemsByCodes);
     router.post("/getGljItemsOccupied",gljController.auth, gljController.init, gljController.getGljItemsOccupied);
     router.post("/isUsed",gljController.auth, gljController.init, gljController.isUsed);//工料机是否被引用
+    router.post('/importPrice', gljController.auth, gljController.init, gljController.importPrice);
+
 
     app.use("/stdGljRepository/api", router);
 

+ 4 - 2
public/counter/counter.js

@@ -23,7 +23,8 @@ const COUNTER_MODULE_NAME = {
     billsLib_jobs: 'billsLib_jobs',
     billsLib_items: 'billsLib_items',
     coeList: 'coeList',
-    installation: 'installation'
+    installation: 'installation',
+    stdCalcProgram:'std_calc_programs'
 }
 /*const PROJECT_COUNTER = 'projects', USER_COUNTER = 'users', BILL_COUNTER = 'bills', RATION_COUNTER = 'rations',
     REPORT_COUNTER = 'rptTemplates', FEE_COUNTER = 'fees'*/
@@ -43,7 +44,8 @@ counterDAO.prototype.getIDAfterCount = async function(moduleName, stepCount, cal
         sc = Math.round(stepCount + 0.5);
     }
     if (callback === null) {
-        return await counterModel.findOneAndUpdate({_id: moduleName}, { $inc: { sequence_value: sc } }, {'new':true});
+        let result = await counterModel.findOneAndUpdate({_id: moduleName}, { $inc: { sequence_value: sc } }, {'new':true});
+        return result
     } else {
         counterModel.findOneAndUpdate({_id: moduleName}, { $inc: { sequence_value: sc } }, {'new':true}, callback);
     }

+ 3 - 2
public/web/common_ajax.js

@@ -39,7 +39,7 @@ var CommonAjax = {
             data: {'data': JSON.stringify(data)},
             dataType: 'json',
             cache: false,
-            timeout: 50000,
+            timeout: 150000,
             success: function(result){
                 if (result.error === 0) {
                     if (successCallback) {
@@ -152,4 +152,5 @@ function ajaxErrorInfo(jqXHR, textStatus, errorThrown) {
     }else {
         alert('url: ' + url +' error ' + textStatus + " " + errorThrown);
     }
-}
+}
+

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

@@ -427,5 +427,17 @@ var sheetCommonObj = {
         });
         workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.esc, false, false, false, false);
         workBook.commandManager().setShortcutKey('myEsc', GC.Spread.Commands.Key.esc, false, false, false, false);
-    }
+    },
+    //生成列字段与列号映射
+    initColMapping: function (obj, headers) {
+        //colToField 列下标与列字段映射
+        //fieldToCol 列字段与列下标映射
+        let colMapping = {colToField: {}, fieldToCol: {}};
+        for(let header of headers){
+            colMapping['colToField'][headers.indexOf(header)] = header.dataCode;
+            colMapping['fieldToCol'][header.dataCode] = headers.indexOf(header);
+        }
+        console.log(colMapping);
+        obj.colMapping = colMapping
+    },
 }

+ 16 - 8
public/web/tree_sheet/tree_sheet_controller.js

@@ -207,29 +207,37 @@ var TREE_SHEET_CONTROLLER = {
         controller.prototype.upMove = function () {
             var that = this, sels = this.sheet.getSelections();
             if (this.tree.selected) {
-                if (this.tree.selected.upMove()) {
-                    TREE_SHEET_HELPER.massOperationSheet(this.sheet, function () {
+                TREE_SHEET_HELPER.massOperationSheet(this.sheet, function () {
+                    TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet,that.tree,that.tree.selected,that.tree.selected.serialNo(),true);//为了处理移动前子项是隐藏的情况,先把所有的列设置为显示
+                    TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet,that.tree,that.tree.selected.preSibling,that.tree.selected.preSibling.serialNo(),true);
+                    if (that.tree.selected.upMove()) {
                         TREE_SHEET_HELPER.refreshTreeNodeData(that.setting, that.sheet, [that.tree.selected, that.tree.selected.nextSibling], true);
+                        TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet,that.tree,that.tree.selected,that.tree.selected.serialNo());
+                        TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet,that.tree,that.tree.selected.nextSibling,that.tree.selected.nextSibling.serialNo());
                         that.sheet.setSelection(that.tree.selected.serialNo(), sels[0].col, 1, 1);
                         if (that.event.refreshBaseActn) {
                             that.event.refreshBaseActn(that.tree);
                         }
-                    });
-                }
+                    }
+                });
             }
         };
         controller.prototype.downMove = function () {
             var that = this, sels = this.sheet.getSelections();
             if (this.tree.selected) {
-                if (this.tree.selected.downMove()) {
-                    TREE_SHEET_HELPER.massOperationSheet(this.sheet, function () {
+                TREE_SHEET_HELPER.massOperationSheet(this.sheet, function () {
+                    TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet,that.tree,that.tree.selected,that.tree.selected.serialNo(),true);//为了处理移动前子项是隐藏的情况,先把所有的列设置为显示
+                    TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet,that.tree,that.tree.selected.nextSibling,that.tree.selected.nextSibling.serialNo(),true);
+                    if (that.tree.selected.downMove()) {
                         TREE_SHEET_HELPER.refreshTreeNodeData(that.setting, that.sheet, [that.tree.selected, that.tree.selected.preSibling], true);
+                        TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet,that.tree,that.tree.selected,that.tree.selected.serialNo());
+                        TREE_SHEET_HELPER.refreshChildrenVisiable(that.sheet,that.tree,that.tree.selected.preSibling,that.tree.selected.preSibling.serialNo());
                         that.sheet.setSelection(that.tree.selected.serialNo(), sels[0].col, 1, 1);
                         if (that.event.refreshBaseActn) {
                             that.event.refreshBaseActn(that.tree);
                         }
-                    });
-                }
+                    }
+                });
             }
         };
 

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

@@ -156,6 +156,14 @@ var TREE_SHEET_HELPER = {
             }
         });
     },
+    refreshChildrenVisiable:function(sheet,tree,node,row,visiable){
+        let iCount = node.posterityCount(), i, child;
+        for (i = 0; i < iCount; i++) {
+            child = tree.items[row + i +1];
+            sheet.setRowVisible(row + i + 1, visiable?visiable:child.visible, GC.Spread.Sheets.SheetArea.viewport);
+        }
+        sheet.invalidateLayout();
+    },
     showTreeData: function (setting, sheet, tree) {
         var indent = 20;
         var halfBoxLength = 5;

+ 3 - 0
web/maintain/billsGuidance_lib/js/billsGuidance.js

@@ -1056,4 +1056,7 @@ const billsGuidance = (function () {
 
 $(document).ready(function () {
     billsGuidance.initViews();
+    CommonAjax.post('/billsGuidance/api/testItems', {libID: getQueryString('libID')}, function (rstData) {
+        console.log(rstData);
+    });
 });

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

@@ -27,4 +27,4 @@ function getQueryString(name)
     var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
     var r = window.location.search.substr(1).match(reg);
     if(r!=null)return  unescape(r[2]); return null;
-}
+}

+ 35 - 0
web/maintain/calc_program_lib/html/edit.html

@@ -0,0 +1,35 @@
+<nav class="navbar navbar-toggleable-lg justify-content-between navbar-light p-0 second_header">
+    <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 class="main">
+    <div class="content" >
+        <div class="container-fluid" >
+        <div class=" col-lg-12 p-0">
+            <nav class="navbar sticky-top navbar-toggleable-md navbar-light bg-faded tools-bar">
+                <div class="collapse navbar-collapse" id="navbarNav">
+                    <div class="tools-btn btn-group align-top">
+                        <a href="javascript:void(0)" class="btn btn-sm" id="format"><i class="fa fa-list-alt" aria-hidden="true"></i> 校验格式</a>
+                        <a href="javascript:void(0)" class="btn btn-sm" id="save"><i class="fa fa-floppy-o" aria-hidden="true"></i> 保存</a>
+                    </div>
+                </div>
+            </nav>
+            <textarea class="form-control" id="templateList" rows="38"></textarea>
+        </div>
+        </div>
+        <input type="hidden" id="libID" value="<%= libID %>">
+        <input type="hidden" id="originalTemplates" value="<%= templateList %>">
+    </div>
+</div>
+
+
+
+<script type="text/javascript">
+
+</script>
+<script type="text/javascript" src="/lib/json/json2.js"></script>
+<script type="text/javascript" src="/web/maintain/calc_program_lib/js/calc_program_edit.js"></script>

+ 124 - 0
web/maintain/calc_program_lib/html/main.html

@@ -0,0 +1,124 @@
+<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="120">操作</th></tr></thead>
+                            <tbody id="showArea">
+                            <% for(let lib of calcProgramLibs){ %>
+                            <tr class="libTr">
+                                <td id="<%= lib.ID%>"><a href="/calcProgram/edit/<%= lib.ID%>"><%= lib.libName%></a></td>
+                                <td><%= lib.displayName%></td>
+                                <td><%= lib.compilationName%></td>
+                                <td><%= moment(lib.createDate).format('YYYY-MM-DD')%></td>
+                                <td>
+                                    <a style="color: #0275d8" onclick='getCalcProgramLib("<%= lib.ID%>")' title="编辑"><i class="fa fa-pencil-square-o"></i></a>
+                                    <a style="color: #0275d8" onclick='showDeleteModal("<%= lib.ID%>")' 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 id="addLibForm" method="post" action="/calcProgram/addLib" enctype="application/x-www-form-urlencoded21">
+                    <div class="form-group">
+                        <label>库名称</label>
+                        <input id="name" name="name" class="form-control" placeholder="请输入计算程序模板库名称" type="text">
+                        <small class="form-text text-danger" id="nameError" style="display: none">请输入费率标准库名称。</small>
+                    </div>
+                    <div class="form-group">
+                        <label>自定义显示名称</label>
+                        <input id="displayName" name="displayName" class="form-control" placeholder="请输入自定义显示名称" type="text">
+                        <small class="form-text text-danger" id="displayNameError" style="display: none">请输入自定义显示名称。</small>
+                    </div>
+                    <div class="form-group">
+                        <label>编办名称</label>
+                        <select id="compilationSels" name="compilationId" class="form-control"></select>
+                    </div>
+                    <input type="hidden" name = "userAccount" value="<%= userAccount%>">
+                </form>
+            </div>
+            <div class="modal-footer">
+                <button id="addLibs"  class="btn btn-primary">新建</button>
+                <button type="button" id="cancelBtn" class="btn btn-secondary" data-dismiss="modal">取消</button>
+            </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 id="renameText" class="form-control" placeholder="输入名称" type="text" value="">
+                        <small class="form-text text-danger" id="renameError" style="display: none">请输入名称。</small>
+                        <input id="libID" type="hidden">
+                    </div>
+                    <div class="form-group">
+                        <label>自定义显示名称</label>
+                        <input id="renameDisplayText" class="form-control" placeholder="输入自定义名称" type="text" value="">
+                        <small class="form-text text-danger" id="renameDisplayError" style="display: none">请输入自定义名称。</small>
+                    </div>
+                </form>
+            </div>
+            <div class="modal-footer">
+                <a id="rename" href="javascript: void(0);" class="btn btn-primary" >确定</a>
+                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
+            </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>
+                <input type="hidden" id="libID_del">
+                <input type="hidden" id="delCount">
+            </div>
+            <div class="modal-footer">
+                <a id="delete" href="javascript:void(0);" class="btn btn-danger" >确认</a>
+                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
+            </div>
+        </div>
+    </div>
+</div>
+
+<script type="text/javascript" src="/web/maintain/calc_program_lib/js/calc_program.js"></script>

+ 90 - 0
web/maintain/calc_program_lib/js/calc_program.js

@@ -0,0 +1,90 @@
+/**
+ * Created by zhang on 2018/9/11.
+ */
+
+$(document).ready(function() {
+    $('#add').on('show.bs.modal',async function () {
+        await initCompilationSelect();
+    });
+
+    // 保存按钮
+    $("#addLibs").click(async function() {
+        let name = $('#name').val();
+        let displayName = $('#displayName').val();
+        if(name==''){
+            $("#nameError").show();
+            return;
+        }if(displayName==''){
+            $("#displayNameError").show();
+            return;
+        }else {
+            $("#addLibs").attr("disabled",true);//防止重复提交
+            $("#addLibForm").submit();
+        }
+    });
+
+    $("#rename").click(async function() {
+        let libID = $("#libID").val();
+        let name = $('#renameText').val();
+        let displayName = $('#renameDisplayText').val();
+        if(libID!=''){
+            if(name ==''){
+                $("#renameError").show();
+                return;
+            }else {
+                try {
+                    let calcProgram = await ajaxPost("/calcProgram/saveLib",{query:{ID:parseInt(libID)},data:{libName:name,displayName:displayName}});
+                    $("#"+libID).children("a").text(calcProgram.libName);
+                    $("#"+libID).next("td").text(calcProgram.displayName);
+                    $("#edit").modal('hide');
+                }catch(err) {
+                    console.log(err);
+                }
+            }
+        }
+    });
+
+    $("#delete").click(async function() {
+        let libID = $("#libID_del").val();
+        let delCount = parseInt($("#delCount").val());
+        delCount = delCount+1;
+        $("#delCount").val(delCount);
+        if(delCount == 3){
+            if(libID!=""){
+                try {
+                    let result = await ajaxPost("/calcProgram/deleteLibByID",{ID:libID});
+                    if(result.ok){
+                        $("#"+libID).parent(".libTr").remove();
+                    }
+                    $("#del").modal('hide');
+                }catch (err){
+                    console.log(err);
+                }
+            }
+        }
+    });
+
+});
+
+
+async function getCalcProgramLib (ID) {
+    try {
+        let lib = await ajaxPost("/calcProgram/findLib",{ID:ID});
+        if(lib){
+            $("#renameText").val(lib.libName);
+            $("#renameDisplayText").val(lib.displayName);
+            $("#libID").val(ID);
+            $("#edit").modal({show:true});
+        }else {
+            alert("没有找到材料库");
+        }
+    }catch (err){
+        console.log(err);
+    }
+}
+
+function showDeleteModal(ID){
+    $("#libID_del").val(ID);
+    $("#delCount").val(0);
+    $("#del").modal({show:true});
+}

+ 37 - 0
web/maintain/calc_program_lib/js/calc_program_edit.js

@@ -0,0 +1,37 @@
+/**
+ * Created by zhang on 2018/9/11.
+ */
+
+
+$(document).ready(function () {
+    try {
+        let tem = sortJson(JSON.parse($("#originalTemplates").val()));
+        $("#templateList").val(JSON.stringify(tem,null,4));
+    }catch (err){
+        console.log(err);
+    }
+
+    $("#format").click( function() {
+        try {
+            let jsonText =  $("#templateList").val();
+            $("#templateList").val(JSON.stringify(JSON.parse(jsonText),null,4));
+        }catch (err){
+            console.log(err);
+            alert("输入的JSON格式有误,请重新输入!");
+        }
+    });
+    $("#save").click(async function() {
+        try {
+            let libID = $("#libID").val();
+            let jsonText =  $("#templateList").val();
+            if(jsonText.indexOf("'")!=-1){
+                alert("输入的格式不能包含 ' 位于:"+jsonText.substr(jsonText.indexOf("'")-15,18));
+                return;
+            }
+            let template = await ajaxPost("/calcProgram/saveLib",{query:{ID: parseInt(libID)},data:{templates:JSON.parse(jsonText)}});
+        }catch (err){
+            console.log(err);
+            alert("保存失败,请查看输入数据");
+        }
+    });
+});

+ 1 - 1
web/maintain/common/html/edit_layout.html

@@ -27,7 +27,7 @@
 <script src="/web/maintain/bills_lib/scripts/bills_lib_ajax.js"></script>
 <script src="/public/web/common_ajax.js"></script>
 <script src="/public/web/commonAlert.js"></script>
-
+<script src="/web/maintain/common/js/util.js"></script>
 
 <body>
 <div class="header">

+ 1 - 0
web/maintain/common/html/layout.html

@@ -35,6 +35,7 @@
 <script src="/public/web/common_ajax.js"></script>
 <script src="/web/maintain/bills_lib/scripts/global.js"></script>
 <script src="/web/maintain/bills_lib/scripts/tools.js"></script>
+<script src="/web/maintain/common/js/util.js"></script>
 <%- body %>
 </body>
 

+ 45 - 0
web/maintain/common/js/util.js

@@ -0,0 +1,45 @@
+/**
+ * Created by zhang on 2018/9/11.
+ */
+
+
+async function initCompilationSelect() {
+    try {
+        $('#compilationSels').empty();
+        let result = await ajaxPost("/stdBillsEditor/getCompilationList");
+        for(let r of result){
+            let $option =  $("<option >"+r.name +"</option>");
+            $option.val( r._id);
+            $('#compilationSels').append($option);
+        }
+    }catch (err){
+        alert("取编办信息有误");
+        console.log(err)
+    }
+}
+
+//对JSON对象排序,按属性key的顺序显示
+function sortJson(obj) {
+    if(obj === null){
+        return null;
+    }
+    if(obj instanceof Array){
+        for(let o in obj){
+            obj[o] = sortJson(obj[o]);
+        }
+        return obj;
+    }else if(typeof obj == 'object'){
+        let arr=[];
+        let newOjb ={};
+        for(let key in obj){
+            arr.push(key);
+        }
+        arr.sort();
+        for(let a of arr){
+            newOjb[a]= sortJson(obj[a]);
+        }
+        return newOjb;
+    }else {
+        return obj;
+    }
+}

+ 35 - 0
web/maintain/fee_rate_lib/html/edit.html

@@ -0,0 +1,35 @@
+<nav class="navbar navbar-toggleable-lg justify-content-between navbar-light p-0 second_header">
+    <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 class="main">
+    <div class="content" >
+        <div class="container-fluid" >
+        <div class=" col-lg-12 p-0">
+            <nav class="navbar sticky-top navbar-toggleable-md navbar-light bg-faded tools-bar">
+                <div class="collapse navbar-collapse" id="navbarNav">
+                    <div class="tools-btn btn-group align-top">
+                        <a href="javascript:void(0)" class="btn btn-sm" id="format"><i class="fa fa-list-alt" aria-hidden="true"></i> 校验格式</a>
+                        <a href="javascript:void(0)" class="btn btn-sm" id="save"><i class="fa fa-floppy-o" aria-hidden="true"></i> 保存</a>
+                    </div>
+                </div>
+            </nav>
+            <textarea class="form-control" id="rateList" rows="38"></textarea>
+        </div>
+        </div>
+        <input type="hidden" id="libID" value="<%= libID %>">
+        <input type="hidden" id="originalRates" value="<%= rateList %>">
+    </div>
+</div>
+
+
+
+<script type="text/javascript">
+
+</script>
+<script type="text/javascript" src="/lib/json/json2.js"></script>
+<script type="text/javascript" src="/web/maintain/fee_rate_lib/js/fee_rate_edit.js"></script>

+ 113 - 0
web/maintain/fee_rate_lib/html/main.html

@@ -0,0 +1,113 @@
+<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 width="160">添加时间</th><th width="120">操作</th></tr></thead>
+                            <tbody id="showArea">
+                            <% for(let lib of feeRateLibs){ %>
+                            <tr class="libTr">
+                                <td id="<%= lib.ID%>"><a href="/feeRate/edit/<%= lib.ID%>"><%= lib.libName%></a></td>
+                                <td><%= lib.compilationName%></td>
+                                <td><%= moment(lib.createDate).format('YYYY-MM-DD')%></td>
+                                <td>
+                                    <a style="color: #0275d8" onclick='getFeeRateLib("<%= lib.ID%>")' title="编辑"><i class="fa fa-pencil-square-o"></i></a>
+                                    <a style="color: #0275d8" onclick='showDeleteModal("<%= lib.ID%>")' 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 id="addLibForm" method="post" action="/feeRate/addLib" enctype="application/x-www-form-urlencoded21">
+                    <div class="form-group">
+                        <label>库名称</label>
+                        <input id="name" name="name" class="form-control" placeholder="请输入费率标准库名称" type="text">
+                        <small class="form-text text-danger" id="nameError" style="display: none">请输入费率标准库名称。</small>
+                    </div>
+                    <div class="form-group">
+                        <label>编办名称</label>
+                        <select id="compilationSels" name="compilationId" class="form-control"></select>
+                    </div>
+                    <input type="hidden" name = "userAccount" value="<%= userAccount%>">
+                </form>
+            </div>
+            <div class="modal-footer">
+                <button id="addLibs"  class="btn btn-primary">新建</button>
+                <button type="button" id="cancelBtn" class="btn btn-secondary" data-dismiss="modal">取消</button>
+            </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 id="renameText" class="form-control" placeholder="输入名称" type="text" value="">
+                        <small class="form-text text-danger" id="renameError" style="display: none">请输入名称。</small>
+                        <input id="libID" type="hidden">
+                    </div>
+                </form>
+            </div>
+            <div class="modal-footer">
+                <a id="rename" href="javascript: void(0);" class="btn btn-primary" >确定</a>
+                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
+            </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>
+                <input type="hidden" id="libID_del">
+                <input type="hidden" id="delCount">
+            </div>
+            <div class="modal-footer">
+                <a id="delete" href="javascript:void(0);" class="btn btn-danger" >确认</a>
+                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
+            </div>
+        </div>
+    </div>
+</div>
+
+<script type="text/javascript" src="/web/maintain/fee_rate_lib/js/fee_rate.js"></script>

+ 81 - 0
web/maintain/fee_rate_lib/js/fee_rate.js

@@ -0,0 +1,81 @@
+/**
+ * Created by zhang on 2018/9/11.
+ */
+
+$(document).ready(function() {
+    $('#add').on('show.bs.modal',async function () {
+        await initCompilationSelect();
+    });
+
+    // 保存按钮
+    $("#addLibs").click(async function() {
+        let name = $('#name').val();
+        if(name==''){
+            $("#nameError").show();
+            return;
+        }else {
+            $("#addLibs").attr("disabled",true);//防止重复提交
+            $("#addLibForm").submit();
+        }
+    });
+
+    $("#rename").click(async function() {
+        let libID = $("#libID").val();
+        let name = $('#renameText').val();
+        if(libID!=''){
+            if(name ==''){
+                $("#renameError").show();
+                return;
+            }else {
+                try {
+                    let newFeeRate = await ajaxPost("/feeRate/saveLib",{query:{ID:libID},data:{libName:name}});
+                    $("#"+libID).children("a").text(newFeeRate.libName);
+                    $("#edit").modal('hide');
+                }catch(err) {
+                    console.log(err);
+                }
+            }
+        }
+    });
+
+    $("#delete").click(async function() {
+        let libID = $("#libID_del").val();
+        let delCount = parseInt($("#delCount").val());
+        delCount = delCount+1;
+        $("#delCount").val(delCount);
+        if(delCount == 3){
+            if(libID!=""){
+                try {
+                    let result = await ajaxPost("/feeRate/deleteLibByID",{ID:libID});
+                    if(result.ok){
+                        $("#"+libID).parent(".libTr").remove();
+                    }
+                    $("#del").modal('hide');
+                }catch (err){
+                    console.log(err);
+                }
+            }
+        }
+    });
+});
+
+async function getFeeRateLib (ID) {
+    try {
+        let lib = await ajaxPost("/feeRate/findLib",{ID:ID});
+        if(lib){
+            $("#renameText").val(lib.libName);
+            $("#libID").val(ID);
+            $("#edit").modal({show:true});
+        }else {
+            alert("没有找到材料库");
+        }
+    }catch (err){
+        console.log(err);
+    }
+}
+
+function showDeleteModal(ID){
+    $("#libID_del").val(ID);
+    $("#delCount").val(0);
+    $("#del").modal({show:true});
+}

+ 36 - 0
web/maintain/fee_rate_lib/js/fee_rate_edit.js

@@ -0,0 +1,36 @@
+/**
+ * Created by zhang on 2018/9/11.
+ */
+$(document).ready(function () {
+
+    try {
+        let tem = sortJson(JSON.parse($("#originalRates").val()));
+        $("#rateList").val(JSON.stringify(tem,null,4));
+    }catch (err){
+        console.log(err);
+    }
+
+    $("#format").click( function() {
+        try {
+            let jsonText =  $("#rateList").val();
+            $("#rateList").val(JSON.stringify(JSON.parse(jsonText),null,4));
+        }catch (err){
+            console.log(err);
+            alert("输入的JSON格式有误,请重新输入!");
+        }
+    });
+    $("#save").click(async function() {
+        try {
+            let libID = $("#libID").val();
+            let jsonText =  $("#rateList").val();
+            if(jsonText.indexOf("'")!=-1){
+                alert("输入的格式不能包含 ' 位于:"+jsonText.substr(jsonText.indexOf("'")-15,18));
+                return;
+            }
+            let newFeeRate = await ajaxPost("/feeRate/saveLib",{query:{ID:libID},data:{rates:JSON.parse(jsonText)}});
+        }catch (err){
+            console.log(err);
+            alert("保存失败,请查看输入数据");
+        }
+    });
+});

+ 36 - 0
web/maintain/main_col_lib/html/edit.html

@@ -0,0 +1,36 @@
+<nav class="navbar navbar-toggleable-lg justify-content-between navbar-light p-0 second_header">
+    <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 class="main">
+    <div class="content" >
+        <div class="container-fluid" >
+        <div class=" col-lg-12 p-0">
+            <nav class="navbar sticky-top navbar-toggleable-md navbar-light bg-faded tools-bar">
+                <div class="collapse navbar-collapse" id="navbarNav">
+                    <div class="tools-btn btn-group align-top">
+                        <a href="javascript:void(0)" class="btn btn-sm" id="createNormal"><i class="fa fa-list-alt" aria-hidden="true"></i> 生成默认</a>
+                        <a href="javascript:void(0)" class="btn btn-sm" id="format"><i class="fa fa-list-alt" aria-hidden="true"></i> 校验格式</a>
+                        <a href="javascript:void(0)" class="btn btn-sm" id="save"><i class="fa fa-floppy-o" aria-hidden="true"></i> 保存</a>
+                    </div>
+                </div>
+            </nav>
+            <textarea class="form-control" id="mainTreeCol" rows="38"></textarea>
+        </div>
+        </div>
+        <input type="hidden" id="libID" value="<%= libID %>">
+        <input type="hidden" id="originalMainCol" value="<%= main_tree_col %>">
+    </div>
+</div>
+
+
+
+<script type="text/javascript">
+
+</script>
+<script type="text/javascript" src="/lib/json/json2.js"></script>
+<script type="text/javascript" src="/web/maintain/main_col_lib/js/main_col_edit.js"></script>

+ 1 - 1
web/maintain/main_col_lib/html/main.html

@@ -9,7 +9,7 @@
                             <tbody id="showArea">
                             <% for(let lib of mainColLibs){ %>
                             <tr class="libTr">
-                                <td id="<%= lib.ID%>"><%= lib.name%></td>
+                                <td id="<%= lib.ID%>"><a href="/mainTreeCol/edit/<%= lib.ID%>"><%= lib.name%></a></td>
                                 <td><%= lib.compilationName%></td>
                                 <td><%= moment(lib.createDate).format('YYYY-MM-DD')%></td>
                                 <td>

Файловите разлики са ограничени, защото са твърде много
+ 50 - 0
web/maintain/main_col_lib/js/main_col_edit.js


+ 4 - 9
web/maintain/project_feature_lib/js/project_feature_edit.js

@@ -1,15 +1,12 @@
 /**
  * Created by zhang on 2018/9/3.
  */
-featureObj = {
-
-};
 
 $(document).ready(function () {
     try {
-        $("#featureList").val(JSON.stringify(JSON.parse($("#originalFeature").val()),null,4));
+        let tem = sortJson(JSON.parse($("#originalFeature").val()));
+        $("#featureList").val(JSON.stringify(tem,null,4));
     }catch (err){
-        $("#featureList").val(featureList);
         console.log(err);
     }
 
@@ -21,8 +18,7 @@ $(document).ready(function () {
            console.log(err);
            alert("输入的JSON格式有误,请重新输入!");
        }
-
-   })
+   });
     $("#save").click(async function() {
         try {
             let libID = $("#libID").val();
@@ -36,7 +32,7 @@ $(document).ready(function () {
             console.log(err);
             alert("保存失败,请查看输入数据");
         }
-    })
+    });
     $("#createNormal").click(async function() {
         let projectFeature = [
             {dispName: '工程专业', key: 'engineering', value: ''},//只读,用户新建单位工程时选择的值
@@ -71,4 +67,3 @@ $(document).ready(function () {
 
 
 });
-//featureObj.initSpread();

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

@@ -18,6 +18,10 @@
         .ztree li span.button.add{margin-right:2px;background-position:-144px 0;vertical-align:top;*vertical-align:middle}
         .modal-lg{max-width: 1000px}
     </style>
+    <script type="text/javascript">
+        let priceProperties = JSON.parse('<%- priceProperties %>');
+        console.log(priceProperties);
+    </script>
 </head>
 
 <body>

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

@@ -15,6 +15,10 @@
     <style type="text/css">
         .ztree li span.button.add{margin-right:2px;background-position:-144px 0;vertical-align:top;*vertical-align:middle}
     </style>
+    <script type="text/javascript">
+        let priceProperties = JSON.parse('<%- priceProperties %>');
+        console.log(priceProperties);
+    </script>
 </head>
 
 <body>

+ 6 - 0
web/maintain/ration_repository/js/ration_glj.js

@@ -651,6 +651,12 @@ var rationGLJOprObj = {
                     success:function(result){
                         sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
                         if (result) {
+                            if(priceProperties && priceProperties.length > 0){
+                                let priceField = priceProperties[0].price.dataCode;
+                                for(let glj of result.data){
+                                    glj.basePrice = glj.priceProperty && glj.priceProperty[priceField] ? glj.priceProperty[priceField] : 0;
+                                }
+                            }
                             var cacheArr = [];
                             for (var i = 0; i < result.data.length; i++) {
                                 for (var j = 0; j < rationGljList.length; j++) {

+ 6 - 0
web/maintain/ration_repository/js/repository_glj.js

@@ -142,6 +142,12 @@ repositoryGljObj = {
             timeout:10000,
             success:function(result){
                 if(!result.error) {
+                    if(priceProperties && priceProperties.length > 0){
+                        let priceField = priceProperties[0].price.dataCode;
+                        for(let glj of result.data){
+                            glj.basePrice = glj.priceProperty && glj.priceProperty[priceField] ? glj.priceProperty[priceField] : 0;
+                        }
+                    }
                     me.gljList = result.data;
                     me.workBook.getSheet(0).setRowCount(result.data.length);
                     me.sortGlj();

+ 3 - 5
web/maintain/std_glj_lib/html/gongliao.html

@@ -119,8 +119,8 @@
                     <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>
+                    <button type="button" class="btn btn-secondary" id="aleCanceBtn" data-dismiss="modal">取消</button>
                 </div>
             </div>
         </div>
@@ -299,10 +299,8 @@
             }
         };
         $(document).ready(function(){
-            let a = {a: 1, b: 2};
-            let b = {b:2, a: 1};
-            console.log(_.isEqual(a, b));
-            console.log(Object.keys(a));
+            let test = '1-1';
+            console.log(test.split('-'));
             //解决spreadjs sheet初始化没高度宽度
             $('#modalCon').width($(window).width()*0.5);
             $('#componentTreeDiv').height($(window).height() - 300);

+ 29 - 1
web/maintain/std_glj_lib/html/main.html

@@ -33,7 +33,7 @@
                   <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>
+                        <thead><tr><th>人材机库名称</th><th>编办</th><th>定额库</th><th width="160">添加时间</th><th width="90">操作</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>
@@ -125,6 +125,34 @@
             </div>
         </div>
     </div>
+    <!--弹出导入数据-->
+    <div class="modal fade" id="import" 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">
+                    <div class="alert alert-warning" role="alert">
+                        导入操作会覆盖数据,请谨慎操作!!
+                    </div>
+                    <form>
+                        <div class="form-group">
+                            <label>请选择Excel格式文件</label>
+                            <input class="form-control-file" type="file" accept=".xlsx,.xls" name="import_data"/>
+                        </div>
+                    </form>
+                </div>
+                <div class="modal-footer">
+                    <button type="button" class="btn btn-primary" id="data-import">确定导入</button>
+                    <button type="button" class="btn btn-secondary" 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>

+ 85 - 27
web/maintain/std_glj_lib/js/components.js

@@ -21,9 +21,51 @@ let componentOprObj = {
             {headerName:"类型",headerWidth:80,dataCode:"gljType", dataType: "String",  hAlign: "center", vAlign: "center"}
         ]
     },
+    //生成列头(多单价)
+    initHeaders: function (priceProperties) {
+        let headers = [
+            {headerName:"选择", headerWidth: 40, dataCode: "select", hAlign: "center", vAlign: "center"},
+            {headerName:"编码",headerWidth:80,dataCode:"code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
+            {headerName:"名称",headerWidth:120,dataCode:"name", dataType: "String", hAlign: "left", vAlign: "center"},
+            {headerName:"规格型号",headerWidth:80,dataCode:"specs", dataType: "String", hAlign: "center", vAlign: "center"},
+            {headerName:"单位",headerWidth:80,dataCode:"unit", dataType: "String", hAlign: "center", vAlign: "center"},
+            {headerName:"类型",headerWidth:80,dataCode:"gljType", dataType: "String",  hAlign: "center", vAlign: "center"}
+
+        ];
+        //生成单价列
+        if(!priceProperties || priceProperties.length === 0){
+            headers.push({headerName:"定额价",headerWidth:80,dataCode:"basePrice", dataType: "Number", formatter: "0.00", hAlign: "right", vAlign: "center"});
+        }
+        else {
+            for(let priceProp of priceProperties){
+                let colData = {
+                    headerName: priceProp.price.dataName,
+                    headerWidth: 100,
+                    dataCode: priceProp.price.dataCode,
+                    dataType: 'Number',
+                    formatter: '0.00',
+                    hAlign: 'right',
+                    vAlign: 'center'
+                };
+                headers.push(colData);
+            }
+        }
+        let tailHeaders = [
+        ];
+        headers = headers.concat(tailHeaders);
+        return headers;
+    },
     buildSheet: function (container) {
         let me = componentOprObj;
+        //生成人材机组成物表格列头
+        me.setting.header = me.initHeaders(priceProperties);
+        //生成人材机组成物列映射
+        sheetCommonObj.initColMapping(me, me.setting.header);
+        repositoryGljObj.initPriceCols.call(me, priceProperties, me.colMapping);
         me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30);
+        if(priceProperties && priceProperties.length > 0){
+            me.workBook.getSheet(0).frozenColumnCount(6);
+        }
         me.workBook.getSheet(0).setColumnWidth(0, 20, GC.Spread.Sheets.SheetArea.rowHeader);
         me.workBook.getSheet(0).setFormatter(-1, 1, "@", GC.Spread.Sheets.SheetArea.viewport);
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditStarting, me.onCellEditStart);
@@ -134,8 +176,9 @@ let componentOprObj = {
         let me = componentOprObj, re = repositoryGljObj;
         if (me.workBook) {
             let cacheSection = data;
+            re.sortGljDeep.call(me, data);
             sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
-            sheetsOprObj.showData(me.workBook.getSheet(0), me.setting, cacheSection, re.distTypeTree);
+            sheetsOprObj.showData(me, me.workBook.getSheet(0), me.setting, cacheSection, re.distTypeTree);
             me.workBook.getSheet(0).setRowCount(cacheSection.length);
             cacheSection = null;
         }
@@ -145,7 +188,6 @@ let componentOprObj = {
         $.bootstrapLoading.start();
         let me = componentOprObj, that = gljComponentOprObj, re = repositoryGljObj,
             updateArr = [],
-            updateBasePrc = [],
             IDMapping = {};
         let formData = new FormData();
         //当前工料机的工料机类型
@@ -167,24 +209,44 @@ let componentOprObj = {
                         }
                     }
                     if(!isExist){
-                        newComponent.push({ID: selectedComponent.ID, consumeAmt: 0});
+                        let newComponentObj = {ID: selectedComponent.ID};
+                        that.initConsumeAmt(newComponentObj);
+                        newComponent.push(newComponentObj);
                     }
                 }
                 newComponent = newComponent.concat(gljComponent);
             }
             else if(me.insertType === 'batchClear'){//去除消耗量为0的组成物
                 for(let gljPerComponent of gljComponent){
-                    if(gljPerComponent.consumeAmt && gljPerComponent.consumeAmt != 0){
-                        newComponent.push({ID: gljPerComponent.ID, consumeAmt: gljPerComponent.consumeAmt});
+                    if(hasConsumeAmt(gljPerComponent)){
+                        if(!consumeAmtProperties || consumeAmtProperties.length === 0){
+                            newComponent.push({ID: gljPerComponent.ID, consumeAmt: gljPerComponent.consumeAmt});
+                        }
+                        else {
+                            newComponent.push({ID: gljPerComponent.ID, consumeAmtProperty: gljPerComponent.consumeAmtProperty});
+                        }
                     }
                 }
             }
-            let gljBasePrc = that.reCalGljBasePrc(re.getCurrentComponent(newComponent));
-            if(gljBasePrc != glj.basePrice){
-                updateBasePrc.push({gljId: glj.ID, gljType: currentGljType, basePrice: gljBasePrc});
+            function hasConsumeAmt(component){
+                if(!consumeAmtProperties || consumeAmtProperties.length === 0){
+                    if(component.consumeAmt && component.consumeAmt != 0){
+                        return true;
+                    }
+                }
+                else {
+                    if(component.consumeAmtProperty){
+                        for(let field in component.consumeAmtProperty){
+                            if(component.consumeAmtProperty[field] != 0){
+                                return true;
+                            }
+                        }
+                    }
+                }
+                return false;
             }
-            IDMapping[glj.ID] = {component : newComponent, basePrice: gljBasePrc};
-            updateArr.push({ID: glj.ID, component: newComponent, basePrice: gljBasePrc});
+            IDMapping[glj.ID] = {component : newComponent};
+            updateArr.push({ID: glj.ID, component: newComponent});
         }
         formData.append('compressData', LZString.compressToUTF16(JSON.stringify(updateArr)));
         $.ajax({
@@ -201,20 +263,14 @@ let componentOprObj = {
                         if(glj.ID === re.currentGlj.ID){
                             re.currentComponent =  re.getCurrentComponent(IDMapping[glj.ID]['component']);
                             sheetCommonObj.cleanData(that.workBook.getSheet(0), that.setting, -1);
-                            sheetsOprObj.showData(that.workBook.getSheet(0), that.setting, re.currentComponent);
+                            sheetsOprObj.showData(that, that.workBook.getSheet(0), that.setting, re.currentComponent);
                         }
                         glj.component = IDMapping[glj.ID]['component'];
-                        glj.basePrice = IDMapping[glj.ID]['basePrice'];
                     }
-                    re.reSetGljBasePrc(thisTypeGljList);
                     if($('#component').is(':visible')){
                         $('#component').modal('hide');
                     }
                     $.bootstrapLoading.end();
-                    //更新定额
-                    if(updateBasePrc.length > 0){
-                        re.updateRationBasePrcRq(updateBasePrc, that.workBook);
-                    }
                 } else {
                     if($('#component').is(':visible')){
                         $('#component').modal('hide');
@@ -243,27 +299,28 @@ let componentOprObj = {
                     let isExist = false;
                     for(let j = 0, jLen = re.currentGlj.component.length; j < jLen; j++){
                         if(me.selectedList[i].ID === re.currentGlj.component[j].ID){
-                            newComponent.push({ID: me.selectedList[i].ID, consumeAmt: re.currentGlj.component[j].consumeAmt});
+                            if(!consumeAmtProperties || consumeAmtProperties.length === 0){
+                                let consumeAmt = typeof re.currentGlj.component[j].consumeAmt !== 'undefined' ? re.currentGlj.component[j].consumeAmt : 0;
+                                newComponent.push({ID: me.selectedList[i].ID, consumeAmt: consumeAmt});
+                            }
+                            else{
+                                let consumeAmtProperty = typeof re.currentGlj.component[j].consumeAmtProperty !== 'undefined' ? re.currentGlj.component[j].consumeAmtProperty : {};
+                                newComponent.push({ID: me.selectedList[i].ID, consumeAmt: 0, consumeAmtProperty: consumeAmtProperty});
+                            }
                             isExist = true;
                             break;
                         }
                     }
                     if(!isExist){
-                        newComponent.push({ID: me.selectedList[i].ID, consumeAmt: 0});
+                        let obj = {ID: me.selectedList[i].ID};
+                        that.initConsumeAmt(obj);
+                        newComponent.push(obj);
                     }
                 }
                 re.currentGlj.component = newComponent;
-                let gljBasePrc = that.reCalGljBasePrc(re.getCurrentComponent(re.currentGlj.component));
-                if(gljBasePrc !== re.currentGlj.basePrice){
-                    re.currentGlj.basePrice = gljBasePrc;
-                    re.reshowGljBasePrc(re.currentGlj);
-                    updateBasePrc.push({gljId: re.currentGlj.ID, gljType: re.currentGlj.gljType, basePrice: gljBasePrc});
-                    re.updateRationBasePrcRq(updateBasePrc, that.workBook);
-                }
                 updateArr.push(re.currentGlj);
                 that.updateComponent(updateArr);
                 $('#component').modal('hide');
-                //$('#componentsCacnel').click();
             }
             else {
                 me.batchUpdateComponent();
@@ -281,6 +338,7 @@ let componentTypeTreeOprObj = {
                 me.currentOprParent = 1;
                 me.currentCache = me.getParentCache(re.parentNodeIds["_pNodeId_" + treeNode.ID]);
             } else {
+                me.currentOprParent = 0;
                 me.currentCache = me.getCache();
             }
         }

Файловите разлики са ограничени, защото са твърде много
+ 392 - 229
web/maintain/std_glj_lib/js/glj.js


+ 244 - 110
web/maintain/std_glj_lib/js/gljComponent.js

@@ -18,10 +18,75 @@ let gljComponentOprObj = {
             lockedCols:[1, 2, 3]
         }
     },
+    //生成列头(多单价)(多消耗量)
+    initHeaders: function (priceProperties, consumeAmtProperties) {
+        let headers = [
+            {headerName:"编码",headerWidth:80,dataCode:"code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
+            {headerName:"名称",headerWidth:90,dataCode:"name", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
+            {headerName:"单位",headerWidth:45,dataCode:"unit", dataType: "String", hAlign: "center", vAlign: "center"},
+        ];
+        //生成消耗量列
+        if(!consumeAmtProperties || consumeAmtProperties.length === 0){
+            headers.push({headerName:"消耗量",headerWidth:70,dataCode:"consumeAmt", dataType: "Number", formatter: "0.000", hAlign: "right", vAlign: "center"});
+        }
+        else {
+            for(let consumeAmtProp of consumeAmtProperties){
+                let colData = {
+                    headerName: consumeAmtProp.consumeAmt.dataName,
+                    headerWidth: 60,
+                    dataCode: consumeAmtProp.consumeAmt.dataCode,
+                    dataType: 'Number',
+                    formatter: '0.000',
+                    hAlign: 'right',
+                    vAlign: 'center'
+                };
+                headers.push(colData);
+            }
+        }
+        //生成单价列
+        if(!priceProperties || priceProperties.length === 0){
+            headers.push({headerName:"定额价",headerWidth:80,dataCode:"basePrice", dataType: "Number", formatter: "0.00", hAlign: "right", vAlign: "center"});
+        }
+        else {
+            for(let priceProp of priceProperties){
+                let colData = {
+                    headerName: priceProp.price.dataName,
+                    headerWidth: 100,
+                    dataCode: priceProp.price.dataCode,
+                    dataType: 'Number',
+                    formatter: '0.00',
+                    hAlign: 'right',
+                    vAlign: 'center'
+                };
+                headers.push(colData);
+            }
+        }
+        return headers;
+    },
+    setFrozen: function (sheet) {
+        const fixedHeadersLen = 3;
+        let frozenCol = 0;
+        if(consumeAmtProperties && consumeAmtProperties.length > 0){
+            frozenCol = fixedHeadersLen + consumeAmtProperties.length;
+        }
+        else if(priceProperties && priceProperties.length > 0){
+            frozenCol = fixedHeadersLen + 1;
+        }
+        if(frozenCol > 0){
+            sheet.frozenColumnCount(frozenCol);
+        }
+    },
     buildSheet: function(container) {
         let me = gljComponentOprObj;
+        //生成人材机组成物表格列头
+        me.setting.header = me.initHeaders(priceProperties, consumeAmtProperties);
+        //生成人材机组成物列映射
+        sheetCommonObj.initColMapping(me, me.setting.header);
+        repositoryGljObj.initPriceCols.call(me, priceProperties, me.colMapping);
+        me.initConsumeAmtCols(consumeAmtProperties, me.colMapping);
         me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30, me);
-        //sheetCommonObj.bindEscKey(me.workBook, [{sheet: me.workBook.getSheet(0), editStarting: me.onCellEditStart, editEnded: me.onCellEditEnd}]);
+        me.setFrozen(me.workBook.getSheet(0));
+        sheetCommonObj.bindEscKey(me.workBook, [{sheet: me.workBook.getSheet(0), editStarting: me.onCellEditStart, editEnded: me.onCellEditEnd}]);
         me.workBook.getSheet(0).setColumnWidth(0, 20, GC.Spread.Sheets.SheetArea.rowHeader);
         me.workBook.getSheet(0).setFormatter(-1, 0, "@", GC.Spread.Sheets.SheetArea.viewport);
         sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
@@ -34,9 +99,18 @@ let gljComponentOprObj = {
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
     },
     getRowData: function (sheet, row, setting) {
-        let rst = {};
+        let rst = {priceProperty: {}, consumeAmtProperty: {}};
         for(let i = 0; i < setting.header.length; i++){
-            rst[setting.header[i].dataCode] = sheet.getValue(row, i);
+            let v = sheet.getValue(row, i);
+            if(this.pricePropertyCols.includes(i)){
+                rst.priceProperty[setting.header[i].dataCode] = v && v !== '' ? v : 0;
+            }
+            else if(this.consumeAmtPropertyCols.includes(i)){
+                rst.consumeAmtProperty[setting.header[i].dataCode] = v && v !== '' ? v : 0;
+            }
+            else {
+                rst[setting.header[i].dataCode] = v;
+            }
         }
         return rst;
     },
@@ -50,6 +124,63 @@ let gljComponentOprObj = {
         }
         return component;
     },
+    //根据消耗量字段设置组成物消耗量
+    setConsumeAmt: function (component, field, value) {
+        const compareStr = 'consumeAmt';
+        if(field.includes(compareStr)){
+            if(field === compareStr){
+                component[field] = value;
+            }
+            else {
+                component['consumeAmtProperty'][field] = value;
+            }
+        }
+    },
+    initConsumeAmtCols: function (consumeAmtProperties, colMapping) {
+        let consumeAmtCols = [],
+            consumeAmtPropertyCols = [];
+        if(!consumeAmtProperties || consumeAmtProperties.length === 0){
+            consumeAmtCols.push(colMapping.fieldToCol['consumeAmt']);
+        }
+        for(let consumeAmtProp of consumeAmtProperties){
+            consumeAmtPropertyCols.push(colMapping.fieldToCol[consumeAmtProp.consumeAmt.dataCode]);
+            consumeAmtCols.push(colMapping.fieldToCol[consumeAmtProp.consumeAmt.dataCode]);
+        }
+        this.consumeAmtCols = consumeAmtCols;
+        this.consumeAmtPropertyCols = consumeAmtPropertyCols;
+    },
+    //消耗量赋初值
+    initConsumeAmt: function (component) {
+        if(!consumeAmtProperties || consumeAmtProperties.length === 0){
+            component.consumeAmt = 0;
+        }
+        else {
+            let consumeAmtProperty = {};
+            for(let consumeAmtProp of consumeAmtProperties){
+                consumeAmtProperty[consumeAmtProp.consumeAmt.dataCode] = 0;
+            }
+            component.consumeAmtProperty = consumeAmtProperty;
+        }
+    },
+    consumeAmtChanged: function (component, consumeAmt, col) {
+        if(!consumeAmtProperties || consumeAmtProperties.length === 0){
+            if(consumeAmt !== component.consumeAmt){
+                return true;
+            }
+        }
+        else {
+            if(consumeAmt !== component.consumeAmtProperty[this.colMapping.colToField[col]]){
+                return true;
+            }
+        }
+        return false;
+    },
+    consumeAmtIsEqual: function (consumeAmtA, consumeAmtB) {
+        if(!consumeAmtProperties || consumeAmtProperties.length === 0){
+            return consumeAmtA.consumeAmt === consumeAmtB.consumeAmt;
+        }
+        return _.isEqual(consumeAmtA.consumeAmtProperty, consumeAmtB.consumeAmtProperty);
+    },
     gljComponentDelOpr: function () {
         let me = gljComponentOprObj, that = repositoryGljObj, updateArr = [], removeArr = [], isUpdate = false, updateBasePrc= [];
         me.workBook.commandManager().register('gljComponentDel', function () {
@@ -57,6 +188,7 @@ let gljComponentOprObj = {
             if(sels.length > 0 && that.currentComponent.length > 0){
                 let component = that.currentGlj.component;
                 for(let i = 0; i < sels.length > 0; i++){
+                    let selField = me.colMapping.colToField(sels[i].col);
                     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){
@@ -65,19 +197,21 @@ let gljComponentOprObj = {
                             }
                         }
                     }
-                    else if(sels[i].col === 0){
+                    else if(selField === 'code'){
                             //编码不可为空
                             alert("编码不可为空!");
 
                     }
-                    else if(sels[i].col === 4){//消耗量修改为0
+                    else if(selField.includes('consumeAmt')){//消耗量修改为0
                         if(sels[i].row === -1){//全修改
                            for(let j = 0; j < that.currentComponent.length; j++){
                                isUpdate = true;
-                               that.currentComponent[j].consumeAmt = 0;
+                               //that.currentComponent[j].consumeAmt = 0;
+                               me.setConsumeAmt(that.currentComponent[j], selField, 0);
                                for(let k = 0; k < component.length; k++){
                                    if(component[k].ID === that.currentComponent[j].ID){
-                                       component[k].consumeAmt = 0;
+                                       //component[k].consumeAmt = 0;
+                                       me.setConsumeAmt(component[k], selField, 0);
                                        break;
                                    }
                                }
@@ -87,10 +221,12 @@ let gljComponentOprObj = {
                             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;
+                                    me.setConsumeAmt(that.currentComponent[sels[i].row + j], selField, 0);
+                                    //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;
+                                            //component[k].consumeAmt = 0;
+                                            me.setConsumeAmt(component[k], selField, 0);
                                             break;
                                         }
                                     }
@@ -113,18 +249,8 @@ let gljComponentOprObj = {
                             }
                         }
                     }
-                    //重新计算工料机
-                    let gljBasePrc = me.reCalGljBasePrc(that.currentComponent);
-                    if(gljBasePrc !== that.currentGlj.basePrice){
-                        that.currentGlj.basePrice = gljBasePrc;
-                        that.reshowGljBasePrc(that.currentGlj);
-                        updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
-                    }
                     updateArr.push(that.currentGlj);
                     me.updateComponent(updateArr);
-                    if(updateBasePrc.length > 0){
-                        that.updateRationBasePrcRq(updateBasePrc, me.workBook);
-                    }
                 }
             }
         });
@@ -195,18 +321,8 @@ let gljComponentOprObj = {
                                         break;
                                     }
                                 }
-                                //重新计算工料机
-                                let gljBasePrc = me.reCalGljBasePrc(that.getCurrentComponent(gljComponent));
-                                if(gljBasePrc !== that.currentGlj.basePrice){
-                                    that.currentGlj.basePrice = gljBasePrc;
-                                    that.reshowGljBasePrc(that.currentGlj);
-                                    updateBasePrcArr.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
-                                }
                                 updateArr.push(that.currentGlj);
                                 me.updateComponent(updateArr);
-                                if(updateBasePrcArr.length > 0 && that.rationLibs.length > 0){
-                                    that.updateRationBasePrcRq(updateBasePrcArr, me.workBook);
-                                }
                             }},
                             "batchClear": {name: '批量删除消耗量为0的组成物', disabled: insertDis, icon: 'fa-remove', callback: function (key, opt) {
                                 co.insertType = 'batchClear';
@@ -223,6 +339,7 @@ let gljComponentOprObj = {
     },
     onCellEditStart: function(sender, args) {
         let me = gljComponentOprObj, that = repositoryGljObj;
+        console.log(me.colMapping);
         if(me.isPending){
             args.cancel = true;
         }
@@ -231,7 +348,8 @@ let gljComponentOprObj = {
         let thatRow = that.workBook.getSheet(0).getSelections()[0].row;
         if(thatRow < that.currentCache.length){
             that.currentGlj = that.currentCache[thatRow];
-            if(me.setting.view.lockedCols.indexOf(args.col) !== -1 || !allowComponent.includes(that.currentGlj.gljType) ||
+            //编码和消耗量可编辑
+            if(!(me.colMapping.colToField[args.col] === 'code' || me.colMapping.colToField[args.col].includes('consumeAmt')) || !allowComponent.includes(that.currentGlj.gljType) ||
                 (that.currentGlj.gljType === 4 && that.isComponent(that.currentGlj.ID, that.gljList)) ||
                 (args.col === 4 && (!that.currentComponent|| args.row >= that.currentComponent.length))){
                 args.cancel = true;
@@ -244,8 +362,10 @@ let gljComponentOprObj = {
     onCellEditEnd: function (sender, args) {
         let me = gljComponentOprObj, that = repositoryGljObj, updateBasePrc = [];
         let gljList = that.gljList, updateArr = [];
+        let dataCode = me.colMapping.colToField[args.col];
         //if(args.editingText !== me.currentEditingComponent.code){
-        if(args.col === 0 && args.editingText && args.editingText.trim().length > 0 && args.editingText !== me.currentEditingComponent.code){
+        //编辑编码
+        if(dataCode === 'code' && args.editingText && args.editingText.trim().length > 0 && args.editingText !== me.currentEditingComponent.code){
             let component = that.currentGlj.component, hasCode = false;
             for(let i = 0; i < gljList.length; i++){
                 if(gljList[i].code === args.editingText){//有效的组成物
@@ -266,7 +386,13 @@ let gljComponentOprObj = {
                             rObj.ID = gljList[i].ID;
                             //rObj.basePrice = gljList[i].basePrice;
                             if(typeof that.currentComponent[args.row] !== 'undefined'){
-                                rObj.consumeAmt = that.currentComponent[args.row].consumeAmt;
+                                if(!consumeAmtProperties || consumeAmtProperties.length === 0){
+                                    rObj.consumeAmt = that.currentComponent[args.row].consumeAmt;
+                                }
+                                else{
+                                    rObj.consumeAmtProperty = that.currentComponent[args.row].consumeAmtProperty;
+                                }
+                                //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){
@@ -276,27 +402,12 @@ let gljComponentOprObj = {
                                 }
                                 component.splice(index, 1);
                                 component.splice(index, 0, rObj);
-                                //计算工料机单价
-                                let gljBasePrc = me.reCalGljBasePrc(that.getCurrentComponent(component));
-                                if(gljBasePrc !== that.currentGlj.basePrice){
-                                    that.currentGlj.basePrice = gljBasePrc;
-                                    that.reshowGljBasePrc(that.currentGlj);
-                                    //工料机单价改变,重算引用了该工料机的定额单价
-                                    updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
-                                }
                                 updateArr.push(that.currentGlj);
                             }
                             else{
-                                rObj.consumeAmt = 0;
+                                me.initConsumeAmt(rObj);
+                                //rObj.consumeAmt = 0;
                                 component.push(rObj);
-                                //计算工料机单价
-                                let gljBasePrc = me.reCalGljBasePrc(that.getCurrentComponent(component));
-                                if(gljBasePrc !== that.currentGlj.basePrice){
-                                    that.currentGlj.basePrice = gljBasePrc;
-                                    that.reshowGljBasePrc(that.currentGlj);
-                                    //工料机单价改变,重算引用了该工料机的定额单价
-                                    updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
-                                }
                                 updateArr.push(that.currentGlj);
                             }
                             break;
@@ -329,41 +440,34 @@ let gljComponentOprObj = {
                 //不存在
             }
         }
-        else if(args.col === 4 && me.currentEditingComponent.code && args.editingText && args.editingText.trim().length > 0){//消耗量
+        //编辑消耗量
+        else if(dataCode.includes('consumeAmt') && me.currentEditingComponent.code && args.editingText && args.editingText.trim().length > 0){//消耗量
             let consumeAmt = parseFloat(args.editingText);
-            if(!isNaN(consumeAmt) && consumeAmt !== me.currentEditingComponent.consumeAmt){
+            if(!isNaN(consumeAmt) && me.consumeAmtChanged(me.currentEditingComponent, consumeAmt, args.col)){
                 let roundCons = scMathUtil.roundTo(parseFloat(consumeAmt), -3);
                 let component = that.currentGlj.component;
                 for(let i = 0; i < component.length; i++){
                     if(component[i].ID === that.currentComponent[args.row].ID){
-                        component[i].consumeAmt = roundCons;
+                        me.setConsumeAmt(component[i], dataCode, roundCons);
+                        //component[i].consumeAmt = roundCons;
                     }
                 }
-                that.currentComponent[args.row].consumeAmt = roundCons;
-                //计算工料机单价
-                let gljBasePrc = me.reCalGljBasePrc(that.currentComponent);
-                if(gljBasePrc !== that.currentGlj.basePrice){
-                    that.currentGlj.basePrice = gljBasePrc;
-                    that.reshowGljBasePrc(that.currentGlj);
-                    //工料机单价改变,重算引用了该工料机的定额单价
-                    updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
-                }
+                //that.currentComponent[args.row].consumeAmt = roundCons;
+                me.setConsumeAmt(that.currentComponent[args.row], dataCode, roundCons);
                 updateArr.push(that.currentGlj);
             }
             else{
                 //只能输入数值
-                args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
-                    me.currentEditingComponent[me.setting.header[args.col].dataCode]: 0);
+                sheetsOprObj.showData(me, me.workBook.getSheet(0), me.setting, that.currentComponent);
 
             }
         }
         else{
-            args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
-            me.currentEditingComponent[me.setting.header[args.col].dataCode]: '');
+            sheetsOprObj.showData(me, me.workBook.getSheet(0), me.setting, that.currentComponent);
         }
         if(updateArr.length > 0){
             me.updateComponent(updateArr);
-            if(updateBasePrc.length > 0){
+            if(updateBasePrc.length > 0 && that.rationLibs.length > 0){
                 me.isPending = true;
                 that.updateRationBasePrcRq(updateBasePrc, me.workBook, function () {
                     me.isPending = false;
@@ -384,8 +488,17 @@ let gljComponentOprObj = {
         }
         let that = repositoryGljObj;
         let maxCol = info.cellRange.col + info.cellRange.colCount - 1;
+        //粘贴的字段只能含有编码和消耗量
+        for(let i = 0; i < info.cellRange.colCount; i++){
+            let col = info.cellRange.col + i;
+            let dataCode = me.colMapping.colToField[col];
+            if(dataCode !== 'code' && !dataCode.includes('consumeAmt')){
+                info.cancel = true;
+                return;
+            }
+        }
         //复制的列数超过正确的列数,不可复制
-        if(info.cellRange.col !== 0 && info.cellRange.col !== 4 || info.cellRange.colCount > 1 || (that.currentGlj.gljType === 4 && that.isComponent(that.currentGlj.ID, that.gljList))){
+        if(maxCol > me.setting.header.length - 1){
             info.cancel = true;
         }
     },
@@ -418,7 +531,13 @@ let gljComponentOprObj = {
                                 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;
+                                    //obj.consumeAmt = that.currentComponent[info.cellRange.row + i].consumeAmt;
+                                    if(!consumeAmtProperties || consumeAmtProperties.length === 0){
+                                        obj.consumeAmt = that.currentComponent[info.cellRange.row + i].consumeAmt;
+                                    }
+                                    else{
+                                        obj.consumeAmtProperty = that.currentComponent[info.cellRange.row + i].consumeAmtProperty;
+                                    }
                                     let index;
                                     for(let k = 0; k < component.length; k++){
                                         if(that.currentComponent[info.cellRange.row + i].ID === component[k].ID){
@@ -430,7 +549,7 @@ let gljComponentOprObj = {
                                     component.splice(index, 0, obj);
                                 }
                                 else{//新增
-                                    obj.consumeAmt = 0;
+                                    me.initConsumeAmt(obj);
                                     component.push(obj);
                                 }
                                 break;
@@ -444,10 +563,6 @@ let gljComponentOprObj = {
                         }
 
                     }
-                  /*  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(!existCode){
                     me.workBook.getSheet(0).setValue(info.cellRange.row + i, info.cellRange.col,
@@ -455,35 +570,47 @@ let gljComponentOprObj = {
                 }
             }
             if(isChange){
-                //计算工料机单价
-                let gljBasePrc = me.reCalGljBasePrc(that.getCurrentComponent(component));
-                if(gljBasePrc !== that.currentGlj.basePrice){
-                    that.currentGlj.basePrice = gljBasePrc;
-                    that.reshowGljBasePrc(that.currentGlj);
-                    updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
-                }
                 updateArr.push(that.currentGlj);
             }
         }
-        else if(info.cellRange.col === 4){
+        //消耗量
+        else if(me.colMapping.colToField[info.cellRange.col].includes('consumeAmt')){
             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){
-                        let roundCons = scMathUtil.roundTo(parseFloat(items[i].consumeAmt), -3);
+                    if(!me.consumeAmtIsEqual(items[i], currentObj)){
                         isChange = true;
-                        currentObj.consumeAmt = roundCons;
-                        for(let j = 0; j < component.length; j++){
-                            if(component[j].ID === currentObj.ID){
-                                component[j].consumeAmt = currentObj.consumeAmt;
-                                break;
+                        if(!consumeAmtProperties || consumeAmtProperties.length === 0){
+                            let roundCons = scMathUtil.roundTo(parseFloat(items[i].consumeAmt), -3);
+                            currentObj.consumeAmt = roundCons;
+                            for(let j = 0; j < component.length; j++){
+                                if(component[j].ID === currentObj.ID){
+                                    component[j].consumeAmt = currentObj.consumeAmt;
+                                    break;
+                                }
+                            }
+                        }
+                        else{
+                            for(let attr in items[i]){
+                                //是消耗量字段
+                                if(attr.includes('consumeAmt') && items[i][attr] && !isNaN(parseFloat(items[i][attr]))){
+                                    let roundCons = scMathUtil.roundTo(parseFloat(items[i][attr]), -3);
+                                    currentObj.consumeAmtProperty[attr] =roundCons;
+                                }
+                            }
+                            for(let j = 0; j < component.length; j++){
+                                if(component[j].ID === currentObj.ID){
+                                    component[j].consumeAmtProperty = currentObj.consumeAmtProperty;
+                                    break;
+                                }
                             }
                         }
                     }
                     else{
-                        me.workBook.getSheet(0).setValue(row + i, info.cellRange.col, currentObj.consumeAmt);
+                        sheetsOprObj.showData(me, me.workBook.getSheet(0), me.setting, that.currentComponent);
+                        //me.workBook.getSheet(0).setValue(row + i, info.cellRange.col, currentObj.consumeAmt);
                     }
                 }
                 else{
@@ -491,13 +618,6 @@ let gljComponentOprObj = {
                 }
             }
             if(isChange){
-                //计算工料机单价
-                let gljBasePrc = me.reCalGljBasePrc(that.currentComponent);
-                if(gljBasePrc !== that.currentGlj.basePrice){
-                    that.currentGlj.basePrice = gljBasePrc;
-                    that.reshowGljBasePrc(that.currentGlj);
-                    updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
-                }
                 updateArr.push(that.currentGlj);
             }
         }
@@ -512,7 +632,7 @@ let gljComponentOprObj = {
         }
         else {
             sheetCommonObj.cleanData(me.workBook.getSheet(0), me.setting, -1);
-            sheetsOprObj.showData(me.workBook.getSheet(0), me.setting, that.currentComponent);
+            sheetsOprObj.showData(me, me.workBook.getSheet(0), me.setting, that.currentComponent);
         }
         let focusInter = setInterval(function () {
             if(!$('#loadingPage').is(':visible')){
@@ -534,23 +654,37 @@ let gljComponentOprObj = {
                     if(result.data[0]){
                         that.currentComponent =  that.getCurrentComponent(result.data[0].component);
                         sheetCommonObj.cleanData(me.workBook.getSheet(0), me.setting, -1);
-                        sheetsOprObj.showData(me.workBook.getSheet(0), me.setting, that.currentComponent);
+                        sheetsOprObj.showData(me, me.workBook.getSheet(0), me.setting, that.currentComponent);
                     }
                 }
             }
         })
     },
-    reCalGljBasePrc: function (component) {
-        let me = gljComponentOprObj, gljBasePrc = 0;
-        for(let i = 0; i < component.length; i++){
-            let roundBasePrc = scMathUtil.roundTo(parseFloat(component[i].basePrice), -2);
-            let roundConsumeAmt = scMathUtil.roundTo(parseFloat(component[i].consumeAmt), -3);
-            //gljBasePrc = scMathUtil.roundTo(scMathUtil.roundTo(roundBasePrc * parseFloat(component[i].consumeAmt), -2) + gljBasePrc, -2); 旧算法
-            gljBasePrc = scMathUtil.roundTo(scMathUtil.roundTo(roundBasePrc * roundConsumeAmt, me.processDecimal) + gljBasePrc, me.processDecimal);
-        }
-        console.log(`scMathUtil.roundTo(gljBasePrc, -2)`);
-        console.log(scMathUtil.roundTo(gljBasePrc, -2));
-        console.log(scMathUtil.roundTo(gljBasePrc, -3));
-        return scMathUtil.roundTo(gljBasePrc, -2);
+    reCalGljBasePrc: function (components) {
+        let me = gljComponentOprObj, re = repositoryGljObj;
+        //只有一个单价的情况,只有一个单价则只有一个消耗量
+        if(!priceProperties || priceProperties.length === 0){
+            let gljBasePrc = 0;
+            for(let i = 0; i < components.length; i++){
+                let roundBasePrc = scMathUtil.roundTo(parseFloat(components[i].basePrice), -2);
+                let roundConsumeAmt = scMathUtil.roundTo(parseFloat(components[i].consumeAmt), -3);
+                gljBasePrc = scMathUtil.roundTo(scMathUtil.roundTo(roundBasePrc * roundConsumeAmt, me.processDecimal) + gljBasePrc, me.processDecimal);
+            }
+            return scMathUtil.roundTo(gljBasePrc, -2);
+        }
+        //多单价的情况
+        else {
+            let gljPriceProperty = re.getPriceProperty(priceProperties);
+            for(let priceProp in gljPriceProperty){
+                let consumeAmtField = re.getConsumeAmtField(consumeAmtProperties, priceProp);
+                for(let component of components){
+                    let roundBasePrc = scMathUtil.roundTo(parseFloat(component['priceProperty'][priceProp]), -2);
+                    let roundConsumeAmt = scMathUtil.roundTo(parseFloat(component['consumeAmtProperty'][consumeAmtField]), -3);
+                    gljPriceProperty[priceProp] = scMathUtil.roundTo(scMathUtil.roundTo(roundBasePrc * roundConsumeAmt, me.processDecimal) + gljPriceProperty[priceProp], me.processDecimal);
+                }
+                scMathUtil.roundTo(gljPriceProperty[priceProp], -2);
+            }
+            return gljPriceProperty;
+        }
     }
 };

+ 73 - 2
web/maintain/std_glj_lib/js/main.js

@@ -120,6 +120,72 @@ $(function () {
 
         });
     });
+    let selLibId = -1;
+    $("#showArea").on("click", ".import-data", function () {
+        let id = $(this).data("id");
+        id = parseInt(id);
+        if (isNaN(id) || id <= 0) {
+            return false;
+        }
+        selLibId = id;
+        $("#import").modal("show");
+    });
+    //导入单价数据
+    $("#data-import").click(function() {
+        $.bootstrapLoading.start();
+        const self = $(this);
+        try {
+            let formData = new FormData();
+            let file = $("input[name='import_data']")[0];
+            if (file.files.length <= 0) {
+                throw '请选择文件!';
+            }
+            formData.append('file', file.files[0]);
+            // 获取人材机库id
+            if (selLibId <= 0) {
+                return false;
+            }
+            formData.append('gljLibId', selLibId);
+            $.ajax({
+                url: 'api/importPrice',
+                type: 'POST',
+                data: formData,
+                cache: false,
+                contentType: false,
+                processData: false,
+                beforeSend: function() {
+                    self.attr('disabled', 'disabled');
+                    self.text('上传中...');
+                },
+                success: function(response){
+                    self.removeAttr('disabled');
+                    self.text('确定导入');
+                    if (response.err === 0) {
+                        $.bootstrapLoading.end();
+                        const message = response.msg !== undefined ? response.msg : '';
+                        if (message !== '') {
+                            alert(message);
+                        }
+                        // 成功则关闭窗体
+                        $('#import').modal("hide");
+                    } else {
+                        $.bootstrapLoading.end();
+                        const message = response.msg !== undefined ? response.msg : '上传失败!';
+                        alert(message);
+                    }
+                },
+                error: function(){
+                    $.bootstrapLoading.end();
+                    alert("与服务器通信发生错误");
+                    self.removeAttr('disabled');
+                    self.text('确定导入');
+                }
+            });
+        } catch(error) {
+            alert(error);
+            $.bootstrapLoading.end();
+        }
+    });
 });
 
 function getAllGljLib(callback){
@@ -151,7 +217,9 @@ function getAllGljLib(callback){
                         "<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>");
+                        "<i class='fa fa-remove'></i></a></td>" +
+                        "<td><a class='btn btn-secondary btn-sm import-data' href='javacript:void(0);' data-id='"+ id +"' title='导入数据'><i class='fa fa-sign-in fa-rotate-90'></i>导入</a></td>" +
+                        "</tr>");
                     var newHref = "/stdGljRepository/glj?gljLibId="+id;
                     $("#tempId td:first a").attr("href", newHref);
                     $("#tempId").attr("id", id);
@@ -201,7 +269,9 @@ function createGljLib(gljLibObj, dispNamesArr, usedCom){
                     "<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>");
+                    "<i class='fa fa-remove'></i></a></td>" +
+                    "<td><a class='btn btn-secondary btn-sm import-data' href='javacript:void(0);' data-id='"+ id +"' title='导入数据'><i class='fa fa-sign-in fa-rotate-90'></i>导入</a></td>" +
+                    "</tr>");
                 var newHref = "/stdGljRepository/glj?gljLibId="+id;
                 $("#tempId td:first a").attr("href", newHref);
                 $("#tempId").attr("id", id);
@@ -257,4 +327,5 @@ function removeGljLib(delObj, dispNames){
             $.bootstrapLoading.end();
         }
     })
+
 }

+ 30 - 16
web/maintain/std_glj_lib/js/sheetsOpr.js

@@ -22,7 +22,7 @@ let sheetsOprObj = {
             area.vAlign(GC.Spread.Sheets.VerticalAlign.center);
         }
     },
-    showData: function(sheet, setting, data, distTypeTree, materialTypeIdx, machineModelIdx) {
+    showData: function(obj, sheet, setting, data, distTypeTree, materialTypeIdx, machineModelIdx) {
         var me = this, ch = GC.Spread.Sheets.SheetArea.viewport;
         sheet.suspendPaint();
         sheet.suspendEvent();
@@ -45,9 +45,19 @@ let sheetsOprObj = {
                 sheet.setFormatter(-1, col, setting.header[col].formatter, GC.Spread.Sheets.SheetArea.viewport);
             }
             for (var row = 0; row < data.length; row++) {
-               // console.log(row);
-                //var cell = sheet.getCell(row, col, GC.Spread.Sheets.SheetArea.viewport);
-                if(setting.header[col].dataCode === 'gljType' && data[row].gljType){
+                if(obj.pricePropertyCols.includes(col)){
+                    let price = data[row]['priceProperty'] && data[row]['priceProperty'][obj.colMapping.colToField[col]] !== undefined
+                        && data[row]['priceProperty'][obj.colMapping.colToField[col]] !== null
+                        ? data[row]['priceProperty'][obj.colMapping.colToField[col]] : '';
+                    sheet.setValue(row, col, price);
+                }
+                else if(obj.consumeAmtPropertyCols && obj.consumeAmtPropertyCols.includes(col)){
+                    let consumeAmt = data[row]['consumeAmtProperty'] && data[row]['consumeAmtProperty'][obj.colMapping.colToField[col]] !== undefined
+                    && data[row]['consumeAmtProperty'][obj.colMapping.colToField[col]] !== null
+                        ? data[row]['consumeAmtProperty'][obj.colMapping.colToField[col]] : '';
+                    sheet.setValue(row, col, consumeAmt);
+                }
+                else if(setting.header[col].dataCode === 'gljType' && data[row].gljType){
                     let distTypeVal =  distTypeTree.distTypes[distTypeTree.prefix + data[row].gljType].data.fullName;
                     sheet.setValue(row, col, distTypeVal, ch);
                 }
@@ -73,14 +83,18 @@ let sheetsOprObj = {
     },
     combineRowData: function(sheet, setting, row, repositoryGljObj) {
         let me = this;
-        var rst = {};
-        let comboBoxCellType = sheet.getCellType(row, 5);
-        let items = comboBoxCellType.items();
-        let materialTypeCombo = sheet.getCellType(row, 7);
+        var rst = {priceProperty: {}};
+        let gljTypeCombo = sheet.getCellType(row, repositoryGljObj.colMapping.fieldToCol['gljType']);
+        let items = gljTypeCombo.items();
+        let materialTypeCombo = sheet.getCellType(row, repositoryGljObj.colMapping.fieldToCol['materialType']);
         let materialItems = materialTypeCombo.items();
-        let machineItems = sheet.getCellType(row, 9).items();
+        let machineItems = sheet.getCellType(row, repositoryGljObj.colMapping.fieldToCol['model']).items();
         for (var col = 0; col < setting.header.length; col++) {
-            if(setting.header[col].dataCode === 'gljType'){
+            if(repositoryGljObj.pricePropertyCols.includes(col)){
+                v = sheet.getValue(row, col);
+                rst.priceProperty[setting.header[col].dataCode] = v && v !== '' ? v : 0;
+            }
+            else if(setting.header[col].dataCode === 'gljType'){
                 items.forEach(function(item){
                     if(sheet.getValue(row, col) === item.text){
                         rst[setting.header[col].dataCode] = item.value;
@@ -114,14 +128,14 @@ let sheetsOprObj = {
                             $('#alertText').text("输入的编号已存在,请重新输入!");
                             $('#codeAlertBtn').click();
                             $('#codAleConfBtn').click(function () {
-                                sheet.setValue(row, 0, orgCode);
-                                sheet.getCell(row, 0).formatter("@");
-                                sheet.setActiveCell(row, 0);
+                                sheet.setValue(row, col, orgCode);
+                                sheet.getCell(row, col).formatter("@");
+                                sheet.setActiveCell(row, col);
                             });
                             $('#codAleClose').click(function () {
-                                sheet.setValue(row, 0, orgCode);
-                                sheet.getCell(row, 0).formatter("@");
-                                sheet.setActiveCell(row, 0);
+                                sheet.setValue(row, col, orgCode);
+                                sheet.getCell(row, col).formatter("@");
+                                sheet.setActiveCell(row, col);
                             });
                             isExist = true
                         }

+ 2 - 2
web/over_write/js/jiangxi_2017.js

@@ -37,7 +37,7 @@ const consumeAmtPropertiesTemplate = [
         taxModel: taxModel.common,
         consumeAmt: {
             dataCode: 'consumeAmt1',
-            dataName: '消耗-一般',
+            dataName: '消耗-一般',
             refPrice: 'price1' //关联的单价字段
         }
     },
@@ -46,7 +46,7 @@ const consumeAmtPropertiesTemplate = [
         taxModel: taxModel.simple,
         consumeAmt: {
             dataCode: 'consumeAmt2',
-            dataName: '消耗-简易',
+            dataName: '消耗-简易',
             refPrice: 'price2' //关联的单价字段
         }
     }

+ 14 - 0
web/users/views/tool/index.html

@@ -76,6 +76,20 @@
                     </h2>
                 </div>
             </div>
+            <div class="col-xs-6 mb-30 ">
+                <div class="c-body">
+                    <h2>费率标准库
+                        <a id="feeRate" href="/feeRate/main" target="_blank" class="btn btn-primary pull-right">进入</a>
+                    </h2>
+                </div>
+            </div>
+            <div class="col-xs-6 mb-30 ">
+                <div class="c-body">
+                    <h2>计算程序模板库
+                        <a id="calcProgram" href="/calcProgram/main" target="_blank" class="btn btn-primary pull-right">进入</a>
+                    </h2>
+                </div>
+            </div>
         </div>
     </div>
 </div>