Просмотр исходного кода

Merge branch 'master' of http://192.168.1.41:3000/SmartCost/YangHuOperation

TonyKang 5 лет назад
Родитель
Сommit
f42ba1dcef
91 измененных файлов с 1824 добавлено и 883 удалено
  1. 1 1
      config/config.js
  2. 1 1
      modules/all_models/stdRation_ration.js
  3. 12 0
      modules/bills_lib/controllers/bills_lib_controllers.js
  4. 3 0
      modules/bills_lib/controllers/stdBillsLib_permissionController.js
  5. 99 0
      modules/bills_lib/models/bills_lib_interfaces.js
  6. 1 0
      modules/bills_lib/routes/bills_lib_routes.js
  7. 12 0
      modules/bills_template_lib/controllers/bills_template_controller.js
  8. 18 0
      modules/bills_template_lib/facade/bills_template_facade.js
  9. 1 0
      modules/bills_template_lib/routes/bills_template_routes.js
  10. 10 0
      modules/ration_repository/controllers/coe_controller.js
  11. 12 0
      modules/ration_repository/controllers/ration_repository_controller.js
  12. 16 12
      modules/ration_repository/controllers/repository_views_controller.js
  13. 6 1
      modules/ration_repository/models/coe.js
  14. 19 9
      modules/ration_repository/models/installation.js
  15. 36 0
      modules/ration_repository/models/ration_item.js
  16. 1 2
      modules/ration_repository/models/repository_map.js
  17. 2 0
      modules/ration_repository/routes/ration_rep_routes.js
  18. 21 0
      modules/std_glj_lib/controllers/gljController.js
  19. 64 37
      modules/std_glj_lib/models/gljModel.js
  20. 4 0
      modules/std_glj_lib/routes/routes.js
  21. 22 1
      public/common_util.js
  22. 4 1
      public/web/PerfectLoad.js
  23. 109 0
      public/web/lock_util.js
  24. 11 10
      web/maintain/bill_template_lib/html/edit.html
  25. 43 4
      web/maintain/bill_template_lib/html/main.html
  26. 27 0
      web/maintain/bill_template_lib/js/bills_template.js
  27. 13 16
      web/maintain/bill_template_lib/js/bills_template_edit.js
  28. 5 0
      web/maintain/billsGuidance_lib/css/main.css
  29. 11 1
      web/maintain/billsGuidance_lib/html/main.html
  30. 11 10
      web/maintain/billsGuidance_lib/html/zhiyin.html
  31. 14 7
      web/maintain/billsGuidance_lib/js/billsGuidance.js
  32. 10 4
      web/maintain/billsGuidance_lib/js/main.js
  33. 5 0
      web/maintain/bills_lib/css/main.css
  34. 79 29
      web/maintain/bills_lib/html/main.html
  35. 5 2
      web/maintain/bills_lib/html/neirong.html
  36. 21 11
      web/maintain/bills_lib/html/qingdan.html
  37. 5 2
      web/maintain/bills_lib/html/tezheng.html
  38. 52 27
      web/maintain/bills_lib/scripts/bills_lib_ajax.js
  39. 11 10
      web/maintain/calc_program_lib/html/edit.html
  40. 6 4
      web/maintain/calc_program_lib/html/main.html
  41. 4 0
      web/maintain/calc_program_lib/js/calc_program.js
  42. 2 0
      web/maintain/calc_program_lib/js/calc_program_edit.js
  43. 6 0
      web/maintain/common/css/main.css
  44. 11 10
      web/maintain/fee_rate_lib/html/edit.html
  45. 7 5
      web/maintain/fee_rate_lib/html/main.html
  46. 5 0
      web/maintain/fee_rate_lib/js/fee_rate.js
  47. 2 1
      web/maintain/fee_rate_lib/js/fee_rate_edit.js
  48. 5 4
      web/maintain/main_col_lib/html/edit.html
  49. 6 4
      web/maintain/main_col_lib/html/main.html
  50. 2 0
      web/maintain/main_col_lib/js/main_col_edit.js
  51. 4 0
      web/maintain/main_col_lib/js/main_col_lib.js
  52. 1 1
      web/maintain/material_replace_lib/html/edit.html
  53. 6 4
      web/maintain/material_replace_lib/html/main.html
  54. 4 0
      web/maintain/material_replace_lib/js/material_replace.js
  55. 3 3
      web/maintain/material_replace_lib/js/material_replace_edit.js
  56. 5 4
      web/maintain/progressive_lib/html/edit.html
  57. 6 4
      web/maintain/progressive_lib/html/main.html
  58. 4 0
      web/maintain/progressive_lib/js/progressive_interval.js
  59. 2 0
      web/maintain/progressive_lib/js/progressive_interval_edit.js
  60. 12 16
      web/maintain/project_feature_lib/html/edit.html
  61. 6 4
      web/maintain/project_feature_lib/html/main.html
  62. 4 0
      web/maintain/project_feature_lib/js/project_feature.js
  63. 2 0
      web/maintain/project_feature_lib/js/project_feature_edit.js
  64. 1 0
      web/maintain/ration_repository/anzhuang.html
  65. 31 0
      web/maintain/ration_repository/css/main.css
  66. 39 94
      web/maintain/ration_repository/dinge.html
  67. 81 17
      web/maintain/ration_repository/js/coe.js
  68. 32 0
      web/maintain/ration_repository/js/explanatory.js
  69. 21 47
      web/maintain/ration_repository/js/gljSelect.js
  70. 95 0
      web/maintain/ration_repository/js/init.js
  71. 28 9
      web/maintain/ration_repository/js/installation.js
  72. 4 1
      web/maintain/ration_repository/js/main.js
  73. 26 48
      web/maintain/ration_repository/js/ration.js
  74. 6 1
      web/maintain/ration_repository/js/ration_assist.js
  75. 3 0
      web/maintain/ration_repository/js/ration_coe.js
  76. 227 268
      web/maintain/ration_repository/js/ration_glj.js
  77. 14 17
      web/maintain/ration_repository/js/ration_installation.js
  78. 1 1
      web/maintain/ration_repository/js/ration_template.js
  79. 56 67
      web/maintain/ration_repository/js/section_tree.js
  80. 21 8
      web/maintain/ration_repository/main.html
  81. 36 1
      web/maintain/std_glj_lib/css/main.css
  82. 47 6
      web/maintain/std_glj_lib/html/gongliao.html
  83. 13 1
      web/maintain/std_glj_lib/html/main.html
  84. 83 8
      web/maintain/std_glj_lib/js/glj.js
  85. 3 0
      web/maintain/std_glj_lib/js/gljClassTree.js
  86. 5 4
      web/maintain/std_glj_lib/js/gljComponent.js
  87. 22 15
      web/maintain/std_glj_lib/js/main.js
  88. 5 4
      web/maintain/vehicleVesselTax_lib/html/edit.html
  89. 6 4
      web/maintain/vehicleVesselTax_lib/html/main.html
  90. 4 0
      web/maintain/vehicleVesselTax_lib/js/vvTax.js
  91. 2 0
      web/maintain/vehicleVesselTax_lib/js/vvTax_edit.js

+ 1 - 1
config/config.js

@@ -11,7 +11,7 @@ module.exports = {
             auth: {
                 "authdb": "admin"
             },
-            connectTimeoutMS: 20000,
+            connectTimeoutMS: 60000,
             useMongoClient: true
         }
     },

+ 1 - 1
modules/all_models/stdRation_ration.js

@@ -7,7 +7,7 @@ const Schema = mongoose.Schema;
 const rationGljItemSchema = new Schema({
     gljId: Number,
     consumeAmt: Number,
-    proportion: Number //配合比,暂时无需使用,默认0
+    proportion: {type: Number, default: 0} //配合比,暂时无需使用,默认0
 }, { _id: false });
 
 const rationAssItemSchema = new Schema({

+ 12 - 0
modules/bills_lib/controllers/bills_lib_controllers.js

@@ -8,6 +8,18 @@ let callback = function(req, res, err, message, data){
 }
 
 module.exports = {
+    copyStdBillsLib: async function (req, res) {
+        try {
+            const data = JSON.parse(req.body.data);
+            const userName = req.session.managerData.username;
+            const libName = data.libName;
+            const libId = data.libId;
+            const newLibData = await billsLibDao.copyLib(userName, libName, libId);
+            callback(req, res, 0, 'copyLib success', [newLibData]);
+        } catch (err) {
+            callback(req, res, 1, 'copyLib fail', null);
+        }
+    },
     getMaxNumber: function(req, res){
         let data = JSON.parse(req.body.data);
         billsLibDao.getMaxNumber(data, function(err, message, maxNumber){

+ 3 - 0
modules/bills_lib/controllers/stdBillsLib_permissionController.js

@@ -40,6 +40,9 @@ class billsLibPermContr extends baseController{
     createStdBillsLib(req, res){
         billsController.createStdBillsLib(req, res);
     }
+    copyStdBillsLib(req, res) {
+        billsController.copyStdBillsLib(req, res);
+    }
     deleteStdBillsLib(req, res){
         billsController.deleteStdBillsLib(req, res);
     }

+ 99 - 0
modules/bills_lib/models/bills_lib_interfaces.js

@@ -14,6 +14,91 @@ const engLibModel = mongoose.model('engineering_lib');
 let uuid = require('uuid');
 let billsLibDao = function(){};
 
+billsLibDao.prototype.copyLib = async function (userName, libName, fromLibId) {
+    const libData = await this.createStdBillsLibSync(userName, libName);
+    const newLibId = libData.billsLibId;
+    //插入工作内容
+    let orgJobs = await JobContent.find({billsLibId: fromLibId}).lean();
+    let jobCounter = await counter.counterDAO.getIDAfterCount(counter.moduleName.billsLib_jobs, orgJobs.length);
+    let maxJobId = jobCounter.sequence_value;
+    let jobTask = [],
+        orgNewJobMapping = {};
+    for (let i = 0; i < orgJobs.length; i++) {
+        let jobData = orgJobs[i];
+        delete jobData._id;
+        let newID = (maxJobId - (orgJobs.length - 1) + i);
+        orgNewJobMapping[jobData.id] = newID;
+        jobData.id = newID;
+        jobData.billsLibId = newLibId;
+        jobTask.push({insertOne: {document: jobData}});
+    }
+    if (jobTask.length > 0) {
+        await JobContent.bulkWrite(jobTask);
+    }
+    //插入项目特征
+    let orgItems = await ItemCharacter.find({billsLibId: fromLibId}).lean();
+    let itemCounter = await counter.counterDAO.getIDAfterCount(counter.moduleName.billsLib_items, orgItems.length);
+    let maxItemId = itemCounter.sequence_value;
+    let itemTask = [],
+        orgNewItemMapping = {};
+    for (let i = 0; i < orgItems.length; i++) {
+        let itemData = orgItems[i];
+        delete itemData._id;
+        let newID = (maxItemId - (orgItems.length - 1) + i);
+        orgNewItemMapping[itemData.id] = newID;
+        itemData.id = newID;
+        itemData.billsLibId = newLibId;
+        itemTask.push({insertOne: {document: itemData}});
+    }
+    if (itemTask.length > 0) {
+        await ItemCharacter.bulkWrite(itemTask);
+    }
+    //插入清单
+    let billsTask = [];
+    let bills = await Bills.find({billsLibId: fromLibId}).lean();
+    let IDMapping = {},
+        billsDatas = [];
+    for (let b of bills) {
+        let bData = b;
+        delete bData._id;
+        bData.billsLibId = newLibId;
+        billsDatas.push(bData);
+        IDMapping[bData.ID] = uuid.v1();
+    }
+    for (let bD of billsDatas) {
+        bD.ID = IDMapping[bD.ID];
+        if (IDMapping[bD.NextSiblingID]) {
+            bD.NextSiblingID = IDMapping[bD.NextSiblingID];
+        }
+        if (IDMapping[bD.ParentID]) {
+            bD.ParentID = IDMapping[bD.ParentID];
+        }
+        // 更新sectionInfo数据
+        if (bD.sectionInfo) {
+            const first = IDMapping[bD.sectionInfo.first];
+            const second = IDMapping[bD.sectionInfo.second];
+            const third = IDMapping[bD.sectionInfo.third];
+            bD.sectionInfo.first = first || null;
+            bD.sectionInfo.second = second || null;
+            bD.sectionInfo.third = third || null;
+        }
+        for (let subJob of bD.jobs) {
+            if (orgNewJobMapping[subJob.id]) {
+                subJob.id = orgNewJobMapping[subJob.id];
+            }
+        }
+        for (let subItem of bD.items) {
+            if (orgNewItemMapping[subItem.id]) {
+                subItem.id = orgNewItemMapping[subItem.id];
+            }
+        }
+        billsTask.push({insertOne: {document: bD}});
+    }
+    if (billsTask.length > 0) {
+        await Bills.bulkWrite(billsTask);
+    }
+    return libData;
+};
 
 billsLibDao.prototype.getMaxNumber = function(gData, callback){
     let billsLibId = gData.billsLibId;
@@ -65,6 +150,20 @@ billsLibDao.prototype.getStdBillsLib = function(callback){
     });
 };
 
+billsLibDao.prototype.createStdBillsLibSync = async function (userName, libName) {
+    const counterRst = await counter.counterDAO.getIDAfterCount(counter.moduleName.billsLib, 1);
+    const dateStr = moment().format('YYYY-MM-DD HH:mm:ss');
+    const libData = {
+        creator: userName,
+        createDate: dateStr,
+        recentOpr: [{operator: userName, operateDate: dateStr}],
+        billsLibId: counterRst.sequence_value,
+        billsLibName: libName,
+        deleted: false
+    };
+    await StdBillsLib.create(libData);
+    return libData;
+};
 
 billsLibDao.prototype.createStdBillsLib = function(clibData, callback){
     counter.counterDAO.getIDAfterCount(counter.moduleName.billsLib, 1, function(err, result){

+ 1 - 0
modules/bills_lib/routes/bills_lib_routes.js

@@ -26,6 +26,7 @@ module.exports =function (app) {
     billsRouter.post('/getABillsLib', billsLibContr.auth, billsLibContr.init, billsLibContr.getABillsLib);
     billsRouter.post("/getStdBillsLib", billsLibContr.auth, billsLibContr.init, billsLibContr.getStdBillsLib);
     billsRouter.post("/createStdBillsLib", billsLibContr.auth, billsLibContr.init, billsLibContr.createStdBillsLib);
+    billsRouter.post("/copyStdBillsLib", billsLibContr.auth, billsLibContr.init, billsLibContr.copyStdBillsLib);
     billsRouter.post("/deleteStdBillsLib", billsLibContr.auth, billsLibContr.init, billsLibContr.deleteStdBillsLib);
     billsRouter.post("/renameStdBillsLib", billsLibContr.auth, billsLibContr.init, billsLibContr.renameStdBillsLib);
     billsRouter.post("/getStdBillsLibName", billsLibContr.auth, billsLibContr.init, billsLibContr.getStdBillsLibName);

+ 12 - 0
modules/bills_template_lib/controllers/bills_template_controller.js

@@ -151,6 +151,18 @@ class BillsTemplateController extends BaseController {
         }
         response.redirect(request.headers.referer);
     }
+
+    async copyLib(req, res) {
+        try {
+            const data = JSON.parse(req.body.data);
+            const userName = req.session.managerData.username;
+            await billsTemplateFacade.copyLib(data.libID, data.name, userName);
+            res.json({error: 0, data: null, message: 'success'})
+        } catch (err) {
+            console.log(err);
+            res.json({error: 1, data: null, message: 'fail'});
+        }
+    }
 }
 
 export default BillsTemplateController;

+ 18 - 0
modules/bills_template_lib/facade/bills_template_facade.js

@@ -11,6 +11,7 @@ let billTemplateItemsModel = mongoose.model("std_bills_template_items");
 
 let billTemplate={
     addLib:addLib,
+    copyLib: copyLib,
     getAllLibs:getAllLibs,
     getLibByID:getLibByID,
     saveLib:saveLib,
@@ -95,5 +96,22 @@ async function addLib(data){
     }
 }
 
+async function copyLib(libID, name, userName) {
+    const lib = await billTemplateLibModel.findOne({ID: libID}, '-_id').lean();
+    const libItems = await billTemplateItemsModel.find({libID}, '-_id').lean();
+    lib.creator = userName;
+    lib.createDate = Date.now();
+    lib.recentOpr = [{operator: userName, operator: moment(lib.createDate).format('YYYY-MM-D HH:mm:ss')}];
+    lib.name = name;
+    lib.ID = uuidV1();
+    await billTemplateLibModel.create(lib);
+    libItems.forEach(item => {
+        item.libID = lib.ID;
+    });
+    if (libItems.length) {
+        await billTemplateItemsModel.insertMany(libItems);
+    }
+}
+
 
 export default  billTemplate

+ 1 - 0
modules/bills_template_lib/routes/bills_template_routes.js

@@ -16,6 +16,7 @@ module.exports =function (app) {
     templateRouter.post("/saveLib", billsTemplateController.auth, billsTemplateController.init, billsTemplateController.saveLib);
     templateRouter.post("/deleteLibByID", billsTemplateController.auth, billsTemplateController.init, billsTemplateController.deleteLibByID);
     templateRouter.post("/add-lib", billsTemplateController.auth, billsTemplateController.init, billsTemplateController.addLib);
+    templateRouter.post("/copyLib", billsTemplateController.auth, billsTemplateController.init, billsTemplateController.copyLib);
     templateRouter.post("/updateBillsTemplateItem/:libID", billsTemplateController.auth, billsTemplateController.init, billsTemplateController.updateBillsTemplateItem);
     app.use("/billsTemplate", templateRouter);
 

+ 10 - 0
modules/ration_repository/controllers/coe_controller.js

@@ -8,6 +8,16 @@ var callback = function(req,res,err,message, data){
 }
 
 class CoeListController extends BaseController{
+    async getCoeReference(req, res) {
+        try {
+            const { rationRepId, coeID } = JSON.parse(req.body.data);
+            const rst = await coeList.getCoeReference(rationRepId, coeID);
+            res.json({ error: 0, message: 'success', data: rst });
+        } catch (err) {
+            res.json({ error: 1, message: err.message, data: null });
+        }
+    }
+
     getCoeList(req,res){
         coeList.getCoesByLibID(req.body.libID, function(err,data){
             callback(req, res, err, 'Get coes', data);

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

@@ -21,6 +21,18 @@ const rationItemModel = mongoose.model('std_ration_lib_ration_items');
 import STDGLJListModel from '../../std_glj_lib/models/gljModel';
 
 class RationRepositoryController extends baseController {
+    // 定额页面初始化数据
+    async prepareInitData(req, res) {
+        try {
+            const data = JSON.parse(req.body.data);
+            const rst = await rationItem.prepareInitData(data.rationRepId);
+            res.json({error: 0, message: 'success', data: rst});
+        } catch (err) {
+            console.log(err);
+            res.json({error: 1, message: 'fail', data: null});
+        }
+    }
+
     async getRationLibsByCompilation(req, res){
         try{
             let data = JSON.parse(req.body.data);

+ 16 - 12
modules/ration_repository/controllers/repository_views_controller.js

@@ -35,9 +35,10 @@ class ViewsController extends BaseController{
     }
     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}`;
+        const locked = req.query.locked || 'true';
+        const redirectGlj = `/rationRepository/lmm?repository=${repId}&locked=${locked}`;
+        const redirectCoe = `/rationRepository/coeList?repository=${repId}&locked=${locked}`;
+        const redirectInstallation = `/rationRepository/installation?repository=${repId}&locked=${locked}`;
         let overWriteUrl = null;
         let priceProperties = [];
         let stdRationLib = await rationLibModel.findOne({ID: repId});
@@ -60,9 +61,10 @@ class ViewsController extends BaseController{
     }
     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}`;
+        const locked = req.query.locked || 'true';
+        const redirectRation = `/rationRepository/ration?repository=${repId}&locked=${locked}`;
+        const redirectCoe = `/rationRepository/coeList?repository=${repId}&locked=${locked}`;
+        const redirectInstallation = `/rationRepository/installation?repository=${repId}&locked=${locked}`;
         let overWriteUrl = null;
         let priceProperties = [];
         let stdRationLib = await rationLibModel.findOne({ID: repId});
@@ -86,9 +88,10 @@ class ViewsController extends BaseController{
     }
     redirectCoeList(req, res){
         const repId = req.query.repository;
-        const redirectGlj = `/rationRepository/lmm?repository=${repId}`;
-        const redirectRation = `/rationRepository/ration?repository=${repId}`;
-        const redirectInstallation = `/rationRepository/installation?repository=${repId}`;
+        const locked = req.query.locked || 'true';
+        const redirectGlj = `/rationRepository/lmm?repository=${repId}&locked=${locked}`;
+        const redirectRation = `/rationRepository/ration?repository=${repId}&locked=${locked}`;
+        const redirectInstallation = `/rationRepository/installation?repository=${repId}&locked=${locked}`;
         res.render('maintain/ration_repository/fuzhu.html',
             {
                 userAccount: req.session.managerData.username,
@@ -101,9 +104,10 @@ class ViewsController extends BaseController{
     }
     async redirectInstallation(req, res){
         const repId = req.query.repository;
-        const redirectGlj = `/rationRepository/lmm?repository=${repId}`;
-        const redirectCoe = `/rationRepository/coeList?repository=${repId}`;
-        const redirectRation = `/rationRepository/ration?repository=${repId}`;
+        const locked = req.query.locked || 'true';
+        const redirectGlj = `/rationRepository/lmm?repository=${repId}&locked=${locked}`;
+        const redirectCoe = `/rationRepository/coeList?repository=${repId}&locked=${locked}`;
+        const redirectRation = `/rationRepository/ration?repository=${repId}&locked=${locked}`;
         let stdRationLib = await rationLibModel.findOne({ID: repId});
         res.render('maintain/ration_repository/anzhuang.html',
             {

+ 6 - 1
modules/ration_repository/models/coe.js

@@ -5,11 +5,16 @@
 //modiyied by zhong on 2017/9/21
 const mongoose = require('mongoose');
 const coeListModel = mongoose.model('std_ration_lib_coe_list');
-let counter = require('../../../public/counter/counter');
+const counter = require('../../../public/counter/counter');
+const rationModel = mongoose.model('std_ration_lib_ration_items');
 import async from 'async';
 
 let coeListDAO = function(){};
 
+coeListDAO.prototype.getCoeReference = async function (rationRepId, coeID) {
+    return await rationModel.find({rationRepId, 'rationCoeList.ID': coeID}, '-_id code').sort({code: 1});
+};
+
 coeListDAO.prototype.getCoe = function (data, callback) {
     coeListModel.findOne({
             "libID": data.libID,

+ 19 - 9
modules/ration_repository/models/installation.js

@@ -9,20 +9,30 @@ const installSectionModel = mongoose.model('std_ration_lib_installationSection')
 class InstallationDao{
     async getInstallation(rationRepId, callback){
         try {
-            let feeItems = await installFeeItemModel.find({rationRepId: rationRepId, $or: [{deleted: false}, {deleted: null}]});
-            for(let feeItem of feeItems){
-                let sids = [];
-                for(let sec of feeItem.section){
-                    sids.push(sec.ID);
-                }
-                if(sids.length > 0){
-                    let sections = await installSectionModel.find({ID: {$in: sids}, $or: [{deleted: false}, {deleted: null}]});
-                    feeItem._doc.section = sections;
+            const feeItems = await installFeeItemModel.find({ rationRepId }).lean();
+            const feeItemMap = {};
+            const sectionIds = [];
+            feeItems.forEach(item => {
+                feeItemMap[item.ID] = item;
+                item.section.forEach(s => sectionIds.push(s.ID));
+                item.section = [];
+            });
+            const sections = await installSectionModel.find({ID: {$in: sectionIds}});
+            sections.forEach(section => {
+                const matchFeeItem = feeItemMap[section.feeItemId];
+                if (matchFeeItem) {
+                    matchFeeItem.section.push(section);
                 }
+            });
+            if (!callback) {
+                return feeItems;
             }
             callback(0, feeItems);
         }
         catch(err){
+            if (!callback) {
+                return [];
+            }
             callback(err, null);
         }
     }

+ 36 - 0
modules/ration_repository/models/ration_item.js

@@ -13,9 +13,45 @@ const stdRationLibModel = mongoose.model('std_ration_lib_map');
 const stdRationSectionModel = mongoose.model('std_ration_lib_ration_chapter_trees');
 const compleRationModel = mongoose.model('complementary_ration_items');
 import STDGLJListModel from '../../std_glj_lib/models/gljModel';
+import InstallationDao from '../models/installation';
+const installationDao = new InstallationDao();
+import GljDao from "../../std_glj_lib/models/gljModel";
+const stdGljDao = new GljDao();
+import stdgljutil  from "../../../public/cache/std_glj_type_util";
 
 var rationItemDAO = function(){};
 
+rationItemDAO.prototype.prepareInitData = async function (rationRepId) {
+    // 定额库
+    const libTask = stdRationLibModel.findOne({ID: rationRepId}, '-_id ID dispName gljLib');
+    // 定额编码
+    const codesTask = rationItemModel.find({rationRepId}, '-_id code', {lean: true});
+    // 定额章节树
+    const sectionTreeTask = stdRationSectionModel.find({rationRepId}, '-_id', {lean: true});
+    // 安装增加费
+    const installationTask = installationDao.getInstallation(rationRepId);
+    const [libInfo, codesArr, sectionTree, installationList] = await Promise.all([libTask, codesTask, sectionTreeTask, installationTask]);
+    const rationsCodes = codesArr.reduce((acc, cur) => {
+        acc.push(cur.code);
+        return acc;
+    }, []);
+    // 人材机分类树
+    const gljLibId = libInfo.gljLib;
+    const gljTreeTask = stdGljDao.getGljTreeSync(gljLibId);
+    const gljTask = stdGljDao.getGljItemsSync(gljLibId);
+    const [gljTree, gljList] = await Promise.all([gljTreeTask, gljTask]);
+    const gljDistTypeList = stdgljutil.getStdGljTypeCacheObj().toArray();
+    return {
+        libInfo,
+        rationsCodes,
+        sectionTree,
+        installationList,
+        gljTree,
+        gljList,
+        gljDistTypeList
+    };
+};
+
 //将消耗量为负的人材机改为正的
 rationItemDAO.prototype.toPositive = async function (rationRepId) {
     let rations = await rationItemModel.find({rationRepId: rationRepId, 'rationGljList.consumeAmt': {$lt: 0}});

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

@@ -186,8 +186,7 @@ rationRepositoryDao.prototype.updateName = function(oprtor, renameObj, callback)
     rationRepository.update({ID: renameObj.ID, deleted: false}, {$set: {dispName: renameObj.newName}}, function (err) {
         if(err){
             callback(err, '重命名失败!');
-        }
-        else{
+        } else{
             new rationRepositoryDao().updateOprArr({ID: renameObj.ID, deleted: false}, oprtor, moment(Date.now()).format('YYYY-MM-DD HH:mm:ss'), function (err) {
                 if(err){
                     callback(err, '更新最近操作者失败!');

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

@@ -30,6 +30,7 @@ module.exports =  function (app) {
     app.get('/rationRepository/coeList', viewsController.auth, viewsController.init, viewsController.redirectCoeList);
     app.get('/rationRepository/installation', viewsController.auth, viewsController.init, viewsController.redirectInstallation);
 
+    apiRouter.post("/prepareInitData", rationRepositoryController.auth, rationRepositoryController.init, rationRepositoryController.prepareInitData);
     apiRouter.post("/getCompilationList", rationRepositoryController.auth, rationRepositoryController.init, rationRepositoryController.getCompilationList);
     apiRouter.post("/getRationLibsByCompilation", rationRepositoryController.auth, rationRepositoryController.init, rationRepositoryController.getRationLibsByCompilation);
     apiRouter.post("/getRationLib",rationRepositoryController.auth, rationRepositoryController.init, rationRepositoryController.getRationLib);
@@ -73,6 +74,7 @@ module.exports =  function (app) {
     apiRouter.post("/getGljItemsByIds",repositoryGljController.auth, gljController.init, gljController.getGljItemsByIds);
     apiRouter.post("/getGljItemsByCodes",repositoryGljController.auth, gljController.init, gljController.getGljItemsByCodes);
 
+    apiRouter.post("/getCoeReference",coeListController.auth, coeListController.init, coeListController.getCoeReference);
     apiRouter.post("/getCoeList",coeListController.auth, coeListController.init, coeListController.getCoeList);
     apiRouter.post("/saveCoeList",coeListController.auth, coeListController.init, coeListController.saveCoeList);
     apiRouter.post("/getCoeItemsByIDs",coeListController.auth, coeListController.init, coeListController.getCoeItemsByIDs);

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

@@ -190,6 +190,27 @@ class GljController extends BaseController{
             res.json({error: 1, message: error, data: null});
         }
     }
+
+    async getReference(req, res) {
+        try {
+            const {repositoryId, gljId} = JSON.parse(req.body.data);
+            const info = await gljDao.getReference(repositoryId, gljId);
+            res.json({error: 0, message: 'success', data: info});
+        } catch (err) {
+            res.json({error: 1, message: String(err), data: null});
+        }
+    }
+
+    async getUsedInfo(req, res) {
+        try {
+            const {repositoryId, gljId} = JSON.parse(req.body.data);
+            const info = await gljDao.getUsedInfo(repositoryId, gljId);
+            res.json({error: 0, message: 'success', data: info});
+        } catch (err) {
+            res.json({error: 1, message: String(err), data: null});
+        }
+    }
+
     async importPrice(request, response) {
         let responseData = {
             err: 0,

+ 64 - 37
modules/std_glj_lib/models/gljModel.js

@@ -5,58 +5,81 @@ const mongoose = require('mongoose');
 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 projectGLJModel = mongoose.model('glj_list');
+const projectModel = mongoose.model('projects');
+const userModel = mongoose.model('users');
 const gljClassTemplateModel = mongoose.model('std_glj_lib_gljClassTemplate');
 const compilationModel = mongoose.model('compilation');
 const scMathUtil = require('../../../public/scMathUtil').getUtil();
+const rationMapModel = mongoose.model('std_ration_lib_map');
 const rationModel = mongoose.model('std_ration_lib_ration_items');
+const complementaryRationModel = mongoose.model('complementary_ration_items');
 import {OprDao} from  "./gljMapModel";
 import moment from "moment";
 import counter from "../../../public/counter/counter";
 import async from "async";
+let _ = require("lodash");
 
 class GljDao  extends OprDao{
-    //test
-    async deSomething (libID){
-        let pClass = await gljClassModel.find({repositoryId: libID, Name: '2013全省材料预算价格'});
-        let classIDs = [],
-            pClassIDs = [];
-        for (let p of pClass) {
-            let p1Class = await gljClassModel.find({repositoryId: libID, ParentID: p.ID});
-            for (let c of p1Class) {
-                pClassIDs.push(c.ID);
+    async getReference(repositoryId, gljId) {
+        const gljLib = await gljMapModel.findOne({ID: repositoryId});
+        const rationLibIds = gljLib.rationLibs.map(lib => lib.ID);
+        const rationLibs = await rationMapModel.find({ID: {$in: rationLibIds}}, '-_id ID dispName');
+        const rationLibNameMapping = {};
+        rationLibs.forEach(item => {
+            rationLibNameMapping[item.ID] = item.dispName;
+        });
+        const stdRations = await rationModel.find({rationRepId: {$in: rationLibIds}, 'rationGljList.gljId': gljId}, '-_id code rationRepId');
+        const rst = {};
+        const unknownLib = '未知定额库';
+        const complementaryLib = '补充定额库';
+        stdRations.forEach(ration => {
+            const libName = rationLibNameMapping[ration.rationRepId] || unknownLib;
+            if (!rst[libName]) {
+                rst[libName] = [];
             }
+            rst[libName].push(ration);
+        });
+        const complementaryRations = await complementaryRationModel.find({'rationGljList.gljId': gljId}, '-_id code');
+        if (complementaryRations.length) {
+            rst[complementaryLib] = [];
         }
-        let subClass = await gljClassModel.find({repositoryId: libID, ParentID: {$in: pClassIDs}});
-        for (let s of subClass) {
-            classIDs.push(s.ID);
-        }
-        let subSonClass = await gljClassModel.find({repositoryId: libID, ParentID: {$in: classIDs}});
-        for (let ss of subSonClass){
-            classIDs.push(ss.ID);
-        }
-        classIDs = Array.from(new Set(classIDs));
-        //相关人材机
-        let gljs = await gljModel.find({repositoryId: libID, gljClass: {$in: classIDs}}, '-_id gljClass ID');
-        let gljIDs = [];
-        for (let g of gljs) {
-            gljIDs.push(g.ID);
-        }
-        let gljLib = await gljMapModel.findOne({ID: libID});
-        let refRationLibIDs = [];
-        for (let rl of gljLib.rationLibs) {
-            refRationLibIDs.push(rl.ID);
-        }
-        let i = 0;
-        for (let rationLibID of refRationLibIDs) {
-            await rationModel.update({rationRepId: rationLibID, 'rationGljList.gljId': {$in: gljIDs}}, {$pull: {rationGljList: {gljId: {$in: gljIDs}}}}, {multi: true});
-            console.log(`i++======================`);
-            console.log(i++);
+        complementaryRations.forEach(ration => rst[complementaryLib].push({code: ration.code}));
+        return rst;
+    }
+
+    async getUsedInfo(repositoryId, gljId) {
+        let userMap = {};
+        let userIDList = [];
+        let projectList = await projectGLJModel.find({"glj_id":gljId},'-_id project_id').lean();
+        if(projectList.length > 0){
+            let projectUserList =  await projectModel.find({'ID':{$in:_.map(projectList,"project_id")}},'-_id ID userID').lean();
+            for(let p of projectUserList){
+                if(!userMap[p.userID]){
+                    userMap[p.userID] = true;
+                    userIDList.push(p.userID);
+                }
+            }
+            let userList = await userModel.find({'_id':{$in:userIDList}},'_id username mobile').lean();
+            for(let u of userList){
+                userMap[u._id.toString()] = u;
+            }
+            for(let p of projectUserList){
+                p.username = userMap[p.userID].username;
+                p.mobile = userMap[p.userID].mobile;
+            }
+           return projectUserList
         }
-        await gljModel.remove({ID: {$in: gljIDs}});
-        console.log('end');
 
+
+        return [];
     }
-    //test
+
+
+    async getGljTreeSync(gljLibId) {
+        return await gljClassModel.find({repositoryId: gljLibId});
+    }
+
     getGljTypes (gljLibId, callback){
         gljClassModel.find({"repositoryId": gljLibId, "$or": [{"isDeleted": null}, {"isDeleted": false}, {deleted: false} ]},
             '-_id', {lean: true}, function(err,data){
@@ -88,6 +111,10 @@ class GljDao  extends OprDao{
         }
     }
 
+    async getGljItemsSync(gljLibId) {
+        return await gljModel.find({repositoryId: gljLibId}, '-_id', {lean: true});
+    }
+
     async getGljItemsByRep(repositoryId,callback = null){
    /*     let me = this;
         if (callback === null) {

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

@@ -42,9 +42,13 @@ 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("/getReference",gljController.auth, gljController.init, gljController.getReference);
     router.post('/importPrice', gljController.auth, gljController.init, gljController.importPrice);
     router.post('/importComponents', gljController.auth, gljController.init, gljController.importComponents);
 
+    // 查找用户使用
+    router.post("/getUsedInfo",gljController.auth, gljController.init, gljController.getUsedInfo);
 
     app.use("/stdGljRepository/api", router);
 

+ 22 - 1
public/common_util.js

@@ -17,4 +17,25 @@ function deleteEmptyObject(arr) {
             i = i - 1;
         };
     };
-};
+};
+
+((factory) => {
+    if (typeof module !== 'undefined') {
+        module.exports = factory();
+    } else {
+        window.commonUtil = factory();
+    }
+})(() => {
+    function isDef(val) {
+        return typeof val !== 'undefined' && val !== null;
+    }
+
+    function isEmptyVal(val) {
+        return val === null || val === undefined || val === '';
+    }
+
+    return {
+        isDef,
+        isEmptyVal
+    };
+});

+ 4 - 1
public/web/PerfectLoad.js

@@ -71,7 +71,10 @@ jQuery.bootstrapLoading = {
 
                             });
                         setTimeout(function () {
-                            $('#loadingFocus')[0].focus();
+                            const $loadingFocus = $('#loadingFocus')[0];
+                            if ($loadingFocus) {
+                                $loadingFocus.focus();
+                            }
                         }, 200);
 
                     },

+ 109 - 0
public/web/lock_util.js

@@ -0,0 +1,109 @@
+'use strict';
+
+/**
+ *
+ *
+ * @author Zhong
+ * @date 2019/11/14
+ * @version
+ */
+
+const lockUtil = (() => {
+    // 从地址栏获取是否锁定
+    function getLocked() {
+        const search = window.location.search;
+        const reg = /locked=(false|true)/;
+        const match = search.match(reg);
+        return match ? JSON.parse(match[1]) : true;
+    }
+    function lockTools($range, locked) {
+        const $btns = $range.find('.lock-btn-control');
+        const toolList = [];
+        for (const $btn of $btns) {
+            toolList.push({$ref: $($btn), type: 'button'});
+        }
+        const $texts = $range.find('.lock-text-control');
+        for (const $text of $texts) {
+            toolList.push({$ref: $($text), type: 'text'});
+        }
+        toolList.forEach(item => {
+            switch (item.type) {
+                case 'button':
+                    locked ? item.$ref.addClass('disabled') : item.$ref.removeClass('disabled');
+                    break;
+                case 'text':
+                    item.$ref.prop('readOnly', locked);
+                    break;
+            }
+        });
+    }
+    function lockSpreads(spreads, locked) {
+        if (!locked) {
+            return;
+        }
+        spreads.forEach(spread => {
+            spread.unbind(GC.Spread.Sheets.Events.ButtonClicked);
+            const sheetCount = spread.getSheetCount();
+            for(let i = 0; i < sheetCount; i++){
+                const sheet = spread.getSheet(i);
+                sheet.unbind(GC.Spread.Sheets.Events.ButtonClicked);
+                sheet.unbind(GC.Spread.Sheets.Events.EditStarting);
+                sheet.unbind(GC.Spread.Sheets.Events.EditEnded);
+                sheet.unbind(GC.Spread.Sheets.Events.RangeChanged);
+                sheet.unbind(GC.Spread.Sheets.Events.ClipboardChanging);
+                sheet.unbind(GC.Spread.Sheets.Events.ClipboardChanged);
+                sheet.unbind(GC.Spread.Sheets.Events.CellDoubleClick);
+                sheet.unbind(GC.Spread.Sheets.Events.CellClick);
+                sheet.unbind(GC.Spread.Sheets.Events.ValueChanged);
+                sheet.suspendPaint();
+                sheet.suspendEvent();
+                sheet.options.isProtected = true;
+                const rowCount = sheet.getRowCount();
+                const colCount = sheet.getColumnCount();
+                for(let row = 0; row < rowCount; row++){
+                    for(let col = 0; col < colCount; col++){
+                        sheet.getCell(row, col).locked(true);
+                    }
+                }
+                sheet.resumePaint();
+                sheet.resumeEvent();
+            }
+        });
+    }
+    function lockURL(locked, $url) {
+        const originURL = $url.prop('href');
+        const originLocked = !locked;
+        const reg = new RegExp(`locked=${originLocked}`);
+        const curURL = reg.test(originURL) ? originURL.replace(reg, `locked=${locked}`) : `${originURL}&locked=${locked}`;
+        $url.prop('href', curURL);
+    }
+    // 库列表页面,锁定按钮点击操作
+    function handleLockClick($lock) {
+        const curLocked = !$lock.data().locked;
+        $lock.data('locked', curLocked);
+        const innerHtml = curLocked ? '<i class="fa fa-unlock-alt"></i>' : '<i class="fa fa-lock"></i>';
+        $lock.html(innerHtml);
+        const title = curLocked ? '解锁' : '锁定';
+        $lock.prop('title', title);
+        const $url = $lock.parent().parent().children(':first-child').children(':first-child');
+        lockURL(curLocked, $url);
+        const $range = $lock.parent().parent();
+        lockTools($range, curLocked);
+    }
+    function lockSpreadsAndTools(spreads, $range, locked) {
+        if (!locked) {
+            return;
+        }
+        lockSpreads(spreads, locked);
+        lockTools($range, locked);
+    }
+
+    return {
+        getLocked,
+        lockTools,
+        lockSpreads,
+        lockURL,
+        handleLockClick,
+        lockSpreadsAndTools
+    }
+})();

+ 11 - 10
web/maintain/bill_template_lib/html/edit.html

@@ -12,16 +12,16 @@
             <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="" class="btn btn-sm"><i class="fa fa-files-o" aria-hidden="true"></i> 复制</a>
-                        <a href="" class="btn btn-sm"><i class="fa fa-scissors" aria-hidden="true"></i> 剪切</a>
-                        <a href="" class="btn btn-sm"><i class="fa fa-clipboard" aria-hidden="true"></i> 粘贴</a>
-                        <a href="javascript:void(0)" class="btn btn-sm" id="insert"><i class="fa fa-sign-in" aria-hidden="true"></i> 插入</a>
-                        <a href="javascript:void(0)" class="btn btn-sm" id="m_insert" data-toggle="modal" data-target="#insertInputDiv"><i class="fa fa-sign-in" aria-hidden="true"></i> 插入多行</a>
-                        <a href="javascript:void(0)" class="btn btn-sm" id="delete"><i class="fa fa-remove" aria-hidden="true"></i> 删除</a>
-                        <a href="javascript:void(0)" class="btn btn-sm" id="upLevel"><i class="fa fa-arrow-left" aria-hidden="true"></i> 升级</a>
-                        <a href="javascript:void(0)" class="btn btn-sm" id="downLevel"><i class="fa fa-arrow-right" aria-hidden="true"></i> 降级</a>
-                        <a href="javascript:void(0)" class="btn btn-sm" id="downMove"><i class="fa fa-arrow-down" aria-hidden="true"></i> 下移</a>
-                        <a href="javascript:void(0)" class="btn btn-sm" id="upMove"><i class="fa fa-arrow-up" aria-hidden="true"></i> 上移</a>
+                        <a class="lock-btn-control" href="" class="btn btn-sm"><i class="fa fa-files-o" aria-hidden="true"></i> 复制</a>
+                        <a class="lock-btn-control" href="" class="btn btn-sm"><i class="fa fa-scissors" aria-hidden="true"></i> 剪切</a>
+                        <a class="lock-btn-control" href="" class="btn btn-sm"><i class="fa fa-clipboard" aria-hidden="true"></i> 粘贴</a>
+                        <a href="javascript:void(0)" class="btn btn-sm lock-btn-control" id="insert"><i class="fa fa-sign-in" aria-hidden="true"></i> 插入</a>
+                        <a href="javascript:void(0)" class="btn btn-sm lock-btn-control" id="m_insert" data-toggle="modal" data-target="#insertInputDiv"><i class="fa fa-sign-in" aria-hidden="true"></i> 插入多行</a>
+                        <a href="javascript:void(0)" class="btn btn-sm lock-btn-control" id="delete"><i class="fa fa-remove" aria-hidden="true"></i> 删除</a>
+                        <a href="javascript:void(0)" class="btn btn-sm lock-btn-control" id="upLevel"><i class="fa fa-arrow-left" aria-hidden="true"></i> 升级</a>
+                        <a href="javascript:void(0)" class="btn btn-sm lock-btn-control" id="downLevel"><i class="fa fa-arrow-right" aria-hidden="true"></i> 降级</a>
+                        <a href="javascript:void(0)" class="btn btn-sm lock-btn-control" id="downMove"><i class="fa fa-arrow-down" aria-hidden="true"></i> 下移</a>
+                        <a href="javascript:void(0)" class="btn btn-sm lock-btn-control" id="upMove"><i class="fa fa-arrow-up" aria-hidden="true"></i> 上移</a>
                     </div>
                 </div>
             </nav>
@@ -71,4 +71,5 @@
 <script type="text/javascript" src="/public/web/tree_sheet/tree_sheet_helper.js"></script>
 <script type="text/javascript" src="/public/web/tree_sheet/tree_sheet_controller.js"></script>
 <script type="text/javascript" src="/public/web/common_ajax.js"></script>
+<script src="/public/web/lock_util.js"></script>
 <script type="text/javascript" src="/web/maintain/bill_template_lib/js/bills_template_edit.js"></script>

+ 43 - 4
web/maintain/bill_template_lib/html/main.html

@@ -19,16 +19,28 @@
                 <div class="col-md-8">
                     <div class="warp-p2 mt-3">
                         <table class="table table-hover table-bordered">
-                            <thead><tr><th>清单模板名称</th><th width="160">编办</th><th width="160">添加时间</th><th width="90">操作</th></tr></thead>
+                            <thead>
+                                <tr>
+                                    <th>清单模板名称</th>
+                                    <th width="160">编办</th>
+                                    <th width="160">添加时间</th>
+                                    <th width="70">操作</th>
+                                    <th width="60">复制</th>
+                                </tr>
+                            </thead>
                             <tbody id="showArea">
                             <% for(let lib of templateLibs){ %>
                             <tr class="libTr">
-                                <td id="<%= lib.ID%>"><a href="/billsTemplate/editTemplate/<%= lib.ID%>"><%= lib.name%></a></td>
+                                <td id="<%= lib.ID%>"><a href="/billsTemplate/editTemplate/<%= lib.ID%>?locked=true"><%= lib.name%></a></td>
                                 <td><%= lib.compilationName%></td>
                                 <td><%= moment(lib.createDate).format('YYYY-MM-DD')%></td>
                                 <td>
-                                    <a href="javacript:void(0);" onclick='getTemplateLib("<%= lib.ID%>")' title="编辑"><i class="fa fa-pencil-square-o"></i></a>
-                                    <a href="javacript:void(0);" onclick='showDeleteModal("<%= lib.ID%>")'class="text-danger" title="删除"><i class="fa fa-remove"></i></a>
+                                    <a class="lock-btn-control disabled" href="javacript:void(0);" onclick='getTemplateLib("<%= lib.ID%>")' title="编辑"><i class="fa fa-pencil-square-o"></i></a>
+                                    <a class="text-danger lock-btn-control disabled" href="javacript:void(0);" onclick='showDeleteModal("<%= lib.ID%>")' title="删除"><i class="fa fa-remove"></i></a>
+                                    <a class="lock" data-locked="true" href="javascript:void(0);" title="解锁"><i class="fa fa-unlock-alt"></i></a>
+                                </td>
+                                <td>
+                                    <a class="btn btn-secondary btn-sm copy-data lock-btn-control disabled" href="javascript:void(0);" onclick="showCopyModal('<%= lib.ID %>')" title="复制数据"><i class="fa fa-clone"></i>复制</a>
                                 </td>
                             </tr>
                             <% } %>
@@ -124,5 +136,32 @@
     </div>
 </div>
 
+<!--弹出复制-->
+<div class="modal fade" id="copy" 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="form-group">
+                    <label>清单模板名称</label>
+                    <input id="copyName" name="name" class="form-control" placeholder="输入清单模板名称" type="text" autofocus>
+                    <small class="form-text text-danger" id="copyNameError" style="display: none">请输入模板名称。</small>
+                </div>
+            </div>
+            <div class="modal-footer">
+                <a id="copyTemplate"  href="javascript:void(0);" class="btn btn-primary">复制</a>
+                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
+            </div>
+        </div>
+    </div>
+</div>
+
+<script src="/public/web/PerfectLoad.js"></script>
+<script src="/public/web/lock_util.js"></script>
 <script src="/web/maintain/bills_lib/scripts/bills_lib_ajax.js"></script>
 <script type="text/javascript" src="/web/maintain/bill_template_lib/js/bills_template.js"></script>

+ 27 - 0
web/maintain/bill_template_lib/js/bills_template.js

@@ -52,6 +52,28 @@ $(document).ready(function() {
            }
         }
     });
+
+    // 锁定、解锁
+    $('.lock').click(function () {
+        lockUtil.handleLockClick($(this));
+    });
+
+    //复制库
+    $('#copyTemplate').click(function () {
+        const libID = $('#libID').val();
+        const name = $('#copyName').val();
+        if (!name) {
+            $('#copyNameError').show();
+            return;
+        }
+        $.bootstrapLoading.start();
+        CommonAjax.post('/billsTemplate/copyLib', {libID, name}, function () {
+            $.bootstrapLoading.end();
+            window.location.reload();
+        }, function () {
+            $.bootstrapLoading.end();
+        });
+    });
 });
 
 function getTemplateLib (ID) {
@@ -66,4 +88,9 @@ function showDeleteModal(ID){
     $("#libID_del").val(ID);
     $("#delCount").val(0);
     $("#del").modal({show:true});
+}
+
+function showCopyModal(ID) {
+    $('#libID').val(ID);
+    $('#copy').modal('show');
 }

+ 13 - 16
web/maintain/bill_template_lib/js/bills_template_edit.js

@@ -2,7 +2,7 @@
  * Created by zhang on 2018/7/13.
  */
 
-
+const locked = lockUtil.getLocked();
 let TEMPLATE_BILLS_SETTING = {
     "emptyRows":1,
     "headRows":1,
@@ -10,7 +10,7 @@ let TEMPLATE_BILLS_SETTING = {
     "treeCol": 1,
     "cols":[{
         "width":80,
-        "readOnly":false,
+        "readOnly":locked,
         "head":{
             "titleNames":["类别"],
             "spanCols":[1],
@@ -27,7 +27,7 @@ let TEMPLATE_BILLS_SETTING = {
         }
     }, {
         "width":200,
-        "readOnly":false,
+        "readOnly":locked,
         "head":{
             "titleNames":["编号"],
             "spanCols":[1],
@@ -45,7 +45,7 @@ let TEMPLATE_BILLS_SETTING = {
         }
     }, {
         "width":300,
-        "readOnly":false,
+        "readOnly":locked,
         "head":{
             "titleNames":["名称"],
             "spanCols":[1],
@@ -62,7 +62,7 @@ let TEMPLATE_BILLS_SETTING = {
         }
     }, {
         "width":50,
-        "readOnly":false,
+        "readOnly":locked,
         "head":{
             "titleNames":["单位"],
             "spanCols":[1],
@@ -79,7 +79,7 @@ let TEMPLATE_BILLS_SETTING = {
         }
     }, {
             "width":80,
-            "readOnly":false,
+            "readOnly":locked,
             "head":{
                 "titleNames":["工程量"],
                 "spanCols":[1],
@@ -97,7 +97,7 @@ let TEMPLATE_BILLS_SETTING = {
             }
     }, {
         "width":200,
-        "readOnly":false,
+        "readOnly":locked,
         "head":{
             "titleNames":["清单固定类别"],
             "spanCols":[1],
@@ -114,7 +114,7 @@ let TEMPLATE_BILLS_SETTING = {
         }
     }, {
         "width":250,
-        "readOnly":false,
+        "readOnly":locked,
         "head":{
             "titleNames":["计算基数"],
             "spanCols":[1],
@@ -131,7 +131,7 @@ let TEMPLATE_BILLS_SETTING = {
         }
     }, {
         "width":50,
-        "readOnly":false,
+        "readOnly":locked,
         "head":{
             "titleNames":["费率ID"],
             "spanCols":[1],
@@ -204,13 +204,9 @@ let TEMPLATE_BILLS_SETTING = {
 $(document).ready(function () {
     autoFlashHeight();
     let RefreshBaseActn = function (tree) {
-        /*  let showButton = function (show, btn) { 隐藏改成灰显
-         if (show) {
-         btn.show();
-         } else {
-         btn.hide();
-         }
-         };*/
+        if (locked) {
+            return;
+        }
         let setButtonValid = function (valid, btn) {
             if (valid) {
                 btn.removeClass('disabled');
@@ -420,6 +416,7 @@ $(document).ready(function () {
     let sel = billsSpread.getActiveSheet().getSelections()[0];
     controller.setTreeSelected(tree.items[sel.row == -1?0:sel.row]);//初始化选中项
     RefreshBaseActn(tree);
+    lockUtil.lockSpreadsAndTools([billsSpread], $(document.body), locked);
     $('#insert').click(function () {
         let me = this;
         $(me).addClass('disabled');

+ 5 - 0
web/maintain/billsGuidance_lib/css/main.css

@@ -316,4 +316,9 @@ div.resize{
     font:0.9rem Calibri;
     box-shadow:2px 2px 6px #ccc;
     color:#fff;
+}
+.disabled {
+    pointer-events: none;
+    opacity: .65;
+    color:#666;
 }

+ 11 - 1
web/maintain/billsGuidance_lib/html/main.html

@@ -31,7 +31,16 @@
                   <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>类型</th><th width="160">添加时间</th><th width="90">操作</th></tr></thead>
+                        <thead>
+                            <tr>
+                                <th>清单指引名称</th>
+                                <th>编办</th>
+                                <th>清单规则</th>
+                                <th>类型</th>
+                                <th width="160">添加时间</th>
+                                <th width="70">操作</th>
+                            </tr>
+                        </thead>
                         <tbody>
                         </tbody>
                       </table>
@@ -152,6 +161,7 @@
     <script src="/web/maintain/billsGuidance_lib/js/global.js"></script>
     <script src="/public/web/uuid.js"></script>
     <script src="/public/web/common_ajax.js"></script>
+    <script src="/public/web/lock_util.js"></script>
     <script src="/web/maintain/billsGuidance_lib/js/main.js"></script>
 
 </body>

+ 11 - 10
web/maintain/billsGuidance_lib/html/zhiyin.html

@@ -38,7 +38,7 @@
                         <div id="billsSpread" class="main-side-top">
                         </div>
                         <div class="main-side-bottom">
-                            <textarea class="form-control"></textarea>
+                            <textarea class="form-control lock-text-control"></textarea>
                         </div>
                     </div>
                   <div class="main-content p-0" id="midContent" style="width: 34%">
@@ -46,12 +46,12 @@
                       <div style="width: 99%; float: left">
                           <div class="toolsbar px-1 d-flex justify-content-between">
                               <div class="tools-btn btn-group align-top">
-                                  <a id="insert" href="javascript:void(0);" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="插入"><i class="fa fa-reply-all" aria-hidden="true"></i> 插入</a>
-                                  <a id="del" href="javascript:void(0);" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="删除"><i class="fa fa-remove" aria-hidden="true"></i></a>
-                                  <a id="upLevel" href="javascript:void(0);" class="btn btn-sm disabled" data-toggle="tooltip" data-placement="bottom" title="升级"><i class="fa fa-arrow-left" aria-hidden="true"></i></a>
-                                  <a id="downLevel" href="javascript:void(0);" class="btn btn-sm disabled" data-toggle="tooltip" data-placement="bottom" title="降级"><i class="fa fa-arrow-right" aria-hidden="true"></i></a>
-                                  <a id="downMove" href="javascript:void(0);" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="下移"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
-                                  <a id="upMove" href="javascript:void(0);" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="上移"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
+                                  <a id="insert" href="javascript:void(0);" class="btn btn-sm lock-btn-control" data-toggle="tooltip" data-placement="bottom" title="插入"><i class="fa fa-reply-all" aria-hidden="true"></i> 插入</a>
+                                  <a id="del" href="javascript:void(0);" class="btn btn-sm lock-btn-control" data-toggle="tooltip" data-placement="bottom" title="删除"><i class="fa fa-remove" aria-hidden="true"></i></a>
+                                  <a id="upLevel" href="javascript:void(0);" class="btn btn-sm lock-btn-control disabled " data-toggle="tooltip" data-placement="bottom" title="升级"><i class="fa fa-arrow-left" aria-hidden="true"></i></a>
+                                  <a id="downLevel" href="javascript:void(0);" class="btn btn-sm lock-btn-control disabled" data-toggle="tooltip" data-placement="bottom" title="降级"><i class="fa fa-arrow-right" aria-hidden="true"></i></a>
+                                  <a id="downMove" href="javascript:void(0);" class="btn btn-sm lock-btn-control" data-toggle="tooltip" data-placement="bottom" title="下移"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
+                                  <a id="upMove" href="javascript:void(0);" class="btn btn-sm lock-btn-control" data-toggle="tooltip" data-placement="bottom" title="上移"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
                                   <a id="expandContract" href="javascript:void(0);" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="收起定额"><i class="fa fa-minus-square-o" aria-hidden="true"></i> 收起定额</a>
                               </div>
                           </div>
@@ -59,7 +59,7 @@
                               <div id="guideItemSpread" class="main-data"></div>
                           </div>
                           <div class="main-bottom-content">
-                              <textarea class="form-control"></textarea>
+                              <textarea class="form-control lock-text-control"></textarea>
                           </div>
                       </div>
                   </div>
@@ -81,10 +81,10 @@
                                     <div class="col-3">
                                         <div class="row">
                                             <div class="col-5 pl-0">
-                                                <button id="insertRation" class="btn btn-primary btn-sm" type="button">插入定额</button>
+                                                <button id="insertRation" class="btn btn-primary btn-sm lock-btn-control" type="button">插入定额</button>
                                             </div>
                                             <div class="col-5">
-                                                <button id="insertAll" class="btn btn-primary btn-sm" type="button">插入全部</button>
+                                                <button id="insertAll" class="btn btn-primary btn-sm lock-btn-control" type="button">插入全部</button>
                                             </div>
                                         </div>
                                     </div>
@@ -146,6 +146,7 @@
     <script src="/public/web/sheet/sheet_data_helper.js"></script>
     <script src="/public/web/QueryParam.js"></script>
     <script src="/public/web/common_ajax.js"></script>
+    <script src="/public/web/lock_util.js"></script>
     <script src="/web/maintain/billsGuidance_lib/js/global.js"></script>
     <script src="/public/web/PerfectLoad.js"></script>
     <script src="/public/web/id_tree.js"></script>

+ 14 - 7
web/maintain/billsGuidance_lib/js/billsGuidance.js

@@ -11,6 +11,7 @@ const billsGuidance = (function () {
     function _isDef(v) {
         return typeof v !== 'undefined' && v !== null;
     }
+    const locked = lockUtil.getLocked();
     let moduleName = 'stdBillsGuidance';
     //上下拖动的拖动条高度
     const verticalResize = 10;
@@ -111,7 +112,7 @@ const billsGuidance = (function () {
             defaultRowHeight: 21,
             cols: [{
                 width: 400,
-                readOnly: false,
+                readOnly: locked,
                 head: {
                     titleNames: ["项目指引"],
                     spanCols: [1],
@@ -293,7 +294,7 @@ const billsGuidance = (function () {
             }
             else if(module === ration){
                 sheet.options.isProtected = true;
-                sheet.getRange(-1, 0, -1, 1).locked(false);
+                sheet.getRange(-1, 0, -1, 1).locked(locked);
                 sheet.getRange(-1, 1, -1, -1).locked(true);
             }
             else if(module === guideItem){
@@ -303,6 +304,7 @@ const billsGuidance = (function () {
             buildHeader(module.workBook.getActiveSheet(), module.headers);
             bindEvent(module.workBook, module.events);
         }
+        lockUtil.lockSpreads([module.workBook], locked);
     }
     //清空表数据
     //@param {Object}sheet {Array}headers {Number}rowCount @return {void}
@@ -440,6 +442,9 @@ const billsGuidance = (function () {
     //刷新按钮有效性
     //@param {Object}node @return {void}
     function refreshBtn(node){
+        if (locked) {
+            return;
+        }
         //全部设为无效
         $('.tools-btn').children().addClass('disabled');
         $('#insertRation').addClass('disabled');
@@ -1374,10 +1379,11 @@ const billsGuidance = (function () {
                     return {
                         callback: function(){},
                         items: {
+
                             "copy": {
                                 name: "复制整块",
                                 disabled: function () {
-                                    return !canCopyBlock(blockNodes);
+                                    return locked || !canCopyBlock(blockNodes);
                                 },
                                 icon: "fa-copy",
                                 callback: function (key, opt) {
@@ -1387,7 +1393,7 @@ const billsGuidance = (function () {
                                 name: "粘贴整块",
                                 disabled: function () {
                                     let pasteNode = bills.tree.selected.guidance.tree.items[target.row];
-                                    return !canPasteBlock(pasteNode);
+                                    return locked || !canPasteBlock(pasteNode);
                                 },
                                 icon: "fa-paste",
                                 callback: function (key, opt) {
@@ -1398,7 +1404,7 @@ const billsGuidance = (function () {
                                 name: '删除',
                                 disabled: function () {
                                     let node = bills.tree.selected.guidance.tree.items[target.row];
-                                    return !node
+                                    return locked || !node
                                 },
                                 icon: "fa-arrow-left",
                                 callback: function (key, opt) {
@@ -1409,7 +1415,7 @@ const billsGuidance = (function () {
                                 name: '插入行',
                                 disabled: function () {
                                     let node = bills.tree.selected.guidance.tree.items[target.row];
-                                    return !node || node.data.type !== itemType.job;
+                                    return locked || !node || node.data.type !== itemType.job;
                                 },
                                 icon: "fa-arrow-left",
                                 callback: function (key, opt) {
@@ -1420,7 +1426,7 @@ const billsGuidance = (function () {
                                 name: '插入子项',
                                 disabled: function () {
                                     let node = bills.tree.selected.guidance.tree.items[target.row];
-                                    return !node || node.data.type !== itemType.job || !allJobChildren(node);
+                                    return locked || !node || node.data.type !== itemType.job || !allJobChildren(node);
                                 },
                                 icon: 'fa-arrow-left',
                                 callback: function (key, opt) {
@@ -1688,6 +1694,7 @@ const billsGuidance = (function () {
     function initViews(){
         let modules = [bills, guideItem, section, ration];
         initWorkBooks(modules);
+        lockUtil.lockTools($(document.body), locked);
         getLibWithBills(libID);
         initBtn();
         initContextMenu();

+ 10 - 4
web/maintain/billsGuidance_lib/js/main.js

@@ -45,13 +45,16 @@ const billsGuidanceMain = (function () {
     function addLibToView(tbody, lib){
         let type = lib.type && typeString[lib.type] ? typeString[lib.type] : ''
         let tr = `<tr id="${lib.ID}">
-            <td><a href="/billsGuidance/guidance/?libID=${lib.ID}">${lib.name}</a>
+            <td><a href="/billsGuidance/guidance/?libID=${lib.ID}&locked=true">${lib.name}</a>
             <td>${lib.compilationName}</td>
             <td>${lib.billsLibName}</td>
             <td>${type}</td>
             <td>${lib.createDate.split(' ')[0]}</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>`;
+            <td>
+            <a class="lock-btn-control disabled" href="javascript:void(0);" data-toggle="modal" data-target="#edit" title="编辑"><i class="fa fa-pencil-square-o"></i></a>
+            <a class="lock-btn-control disabled text-danger" href="javascript:void(0);" data-toggle="modal" data-target="#del" title="删除"><i class="fa fa-remove"></i></a>
+            <a class="lock" data-locked="true" href="javascript:void(0);" title="解锁"><i class="fa fa-unlock-alt"></i></a>
+            </td></tr>`;
         tbody.append(tr);
     }
     //获取清单指引库
@@ -212,7 +215,10 @@ const billsGuidanceMain = (function () {
         $('#del').on('hidden.bs.modal', function () {
             deleteCount = 0;
         });
-
+        // 锁定、解锁
+        $('.main').find('tbody').on('click', '.lock', function () {
+            lockUtil.handleLockClick($(this));
+        });
     }
 
     return {getComBillsLibInfo, getLibs, eventListener};

+ 5 - 0
web/maintain/bills_lib/css/main.css

@@ -276,4 +276,9 @@ body {
 .modal-fixed-height {
     height:400px;
     overflow-y:auto;
+}
+.disabled {
+    pointer-events: none;
+    opacity: .65;
+    color:#666;
 }

+ 79 - 29
web/maintain/bills_lib/html/main.html

@@ -32,11 +32,16 @@
                   <div class="col-md-8">
                     <div class="warp-p2 mt-3">
                       <table class="table table-hover table-bordered">
-                        <thead><tr><th>清单规则名称</th><th width="160">添加时间</th><th width="90">操作</th><th width="90">导入</th></tr></thead>
+                        <thead>
+                            <tr>
+                                <th>清单规则名称</th>
+                                <th width="160">添加时间</th>
+                                <th width="70">操作</th>
+                                <th width="90">导入</th>
+                                <th width="90">复制</th>
+                            </tr>
+                        </thead>
                         <tbody id="showArea">
-                          <!--<tr><td><a href="qingdan.html">XX清单规则</a></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="qingdan.html">XX清单规则</a></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="qingdan.html">XX清单规则</a></td><td>2017-01-01 </td><td><a href="javacript:void(0);" data-toggle="modal" data-target="#edit" title="编辑"><i class="fa fa-pencil-square-o"></i></a> <a href="javacript:void(0);" data-toggle="modal" data-target="#del" class="text-danger" title="删除"><i class="fa fa-remove"></i></a></td></tr>-->
                         </tbody>
                       </table>
                     </div>
@@ -144,12 +149,38 @@
             </div>
         </div>
     </div>
+    <!--弹出复制库-->
+    <div class="modal fade" id="copy" data-backdrop="static" 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="copyName" class="form-control" autofocus placeholder="输入清单规则名称" type="text">
+                        </div>
+                    </form>
+                </div>
+                <div class="modal-footer">
+                    <a id="copyA"  href="javascript:void(0);" class="btn btn-primary">确定</a>
+                    <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>
     <script src="/lib/bootstrap/bootstrap.min.js"></script>
     <script src="/public/web/PerfectLoad.js"></script>
     <script src="/public/web/common_ajax.js"></script>
+    <script src="/public/web/lock_util.js"></script>
     <script src="/web/maintain/bills_lib/scripts/global.js"></script>
     <script src="/web/maintain/bills_lib/scripts/bills_lib_ajax.js"></script>
     <script src="/web/maintain/bills_lib/scripts/tools.js"></script>
@@ -168,24 +199,24 @@
         //main 增删改
         $("#createA").click(function(){
             let billsLibName = $("#createText").val();
-         /*   let compilationName = $('#compilationSels option:selected').text();
-            let compilationId = $('#compilationSels option:selected').val();*/
+            /*   let compilationName = $('#compilationSels option:selected').text();
+             let compilationId = $('#compilationSels option:selected').val();*/
             if(billsLibName.trim().length === 0){
                 alert("请输入清单规则名称!");
             }
-          /*  else if(compilationName.trim().length === 0){
-                alert("编办不可为空!");
-            }*/
+            /*  else if(compilationName.trim().length === 0){
+             alert("编办不可为空!");
+             }*/
             else {
                 mainAjax.createStdBillsLib(userAccount, billsLibName);
                 $("#createText").val("");
             }
         });
 
-       $("#showArea").on("click", "[data-target = '#del']", function(){
-           let deleteId = $(this).parent().parent().attr("id");
-           $("#deleteA").attr("deleteId", deleteId);
-       });
+        $("#showArea").on("click", "[data-target = '#del']", function(){
+            let deleteId = $(this).parent().parent().attr("id");
+            $("#deleteA").attr("deleteId", deleteId);
+        });
         $("#deleteA").click(function(){
             let deleteId = $(this).attr("deleteId");
             if(preDeleteId && preDeleteId !== deleteId){
@@ -218,28 +249,32 @@
             deleteCount = 0;
         });
 
-       $("#showArea").on("click", "[data-target = '#edit']", function(){
-           let renameId = $(this).parent().parent().attr("id");
-           $('#renameText').val($(this).parent().parent().find('td:first-child').text());
-           $("#renameA").attr("renameId", renameId);
+        $("#showArea").on("click", "[data-target = '#edit']", function(){
+            let renameId = $(this).parent().parent().attr("id");
+            $('#renameText').val($(this).parent().parent().find('td:first-child').text());
+            $("#renameA").attr("renameId", renameId);
 
-       });
+        });
+        // 锁定、解锁
+        $('#showArea').on('click', '.lock', function () {
+            lockUtil.handleLockClick($(this));
+        });
 
-       $('#edit').on('shown.bs.modal', function () {
-           setTimeout(function () {
+        $('#edit').on('shown.bs.modal', function () {
+            setTimeout(function () {
                 $('#renameText').focus();
-           }, 100);
-       });
+            }, 100);
+        });
 
-       $('#add').on('shown.bs.modal', function () {
-           setTimeout(function () {
+        $('#add').on('shown.bs.modal', function () {
+            setTimeout(function () {
                 $('#createText').focus();
-           }, 100);
-       });
+            }, 100);
+        });
 
-       $('#add').on('hidden.bs.modal', function () {
-           $('#createText').val('');
-       });
+        $('#add').on('hidden.bs.modal', function () {
+            $('#createText').val('');
+        });
 
         $("#renameA").click(function(){
             let newName = $("#renameText").val();
@@ -318,6 +353,21 @@
                 $.bootstrapLoading.end();
             }
         });
+        // 复制库
+        $("#showArea").on("click", ".copy-data", function () {
+            let id = $(this).data("id");
+            id = parseInt(id);
+            if (isNaN(id) || id <= 0) {
+                return false;
+            }
+            selLibId = id;
+            $("#copy").modal("show");
+        });
+        $('#copyA').click(function () {
+            const libId = selLibId;
+            const libName = $('#copyName').val();
+            mainAjax.copyBillsLib(libId, libName);
+        });
     });
 </script>
 

+ 5 - 2
web/maintain/bills_lib/html/neirong.html

@@ -215,6 +215,7 @@
     <script src="/web/maintain/bills_lib/scripts/global.js"></script>
     <script src="/public/web/PerfectLoad.js"></script>
     <script src="/public/web/common_ajax.js"></script>
+    <script src="/public/web/lock_util.js"></script>
     <script src="/public/web/sheet/sheet_common.js"></script>
     <script src="/web/maintain/bills_lib/scripts/set_sheets.js"></script>
     <script src="/web/maintain/bills_lib/scripts/bills_lib_ajax.js"></script>
@@ -223,6 +224,7 @@
     <script src="/web/maintain/bills_lib/scripts/bills_lib_setting.js"></script>
     <script src="/web/maintain/bills_lib/scripts/db_controller.js"></script>
     <SCRIPT type="text/javascript">
+        const locked = lockUtil.getLocked();
         let billsLibId = getQueryString("billsLibId");
         tools.redirect(billsLibId, 'stdBillsmain');
         let userAccount = '<%= userAccount%>'
@@ -234,13 +236,14 @@
         let sheetJobsDatas;
         $(document).ready(function(){
             $('#aStdBills').attr('href', function(){
-                return 'stdBills?billsLibId=' + billsLibId;
+                return `stdBills?billsLibId=${billsLibId}&locked=${locked}`;
             });
             $('#aStdItems').attr('href', function(){
-                return 'stdItems?billsLibId=' + billsLibId;
+                return `stdItems?billsLibId=${billsLibId}&locked=${locked}`;
             });
             billsAjax.getStdBillsLibName(billsLibId);
             buildAllJobs(spreadAllJobs, totalJobsSetting);
+            lockUtil.lockSpreads([spreadAllJobs], locked);
         });
         function buildAllJobs(spreadAllJobs, setting){
             setSheet.initSheet(spreadAllJobs, setting, true);

+ 21 - 11
web/maintain/bills_lib/html/qingdan.html

@@ -45,22 +45,22 @@
                   <div class="collapse navbar-collapse" id="navbarNav">
                       <ul class="navbar-nav">
                           <li class="nav-item">
-                              <a class="nav-link text-primary" doing="false" fcsOnBills="true" id="insert" href="javascript: void(0);"><i class="fa fa-share" aria-hidden="true"></i>插入</a>
+                              <a class="nav-link text-primary lock-btn-control" doing="false" fcsOnBills="true" id="insert" href="javascript: void(0);"><i class="fa fa-share" aria-hidden="true"></i>插入</a>
                           </li>
                           <li class="nav-item">
-                              <a class="nav-link text-primary" doing="false" fcsOnBills="true" id ="delete" href="javascript:void (0)"><i class="fa fa-remove" aria-hidden="true"></i>删除</a>
+                              <a class="nav-link text-primary lock-btn-control" doing="false" fcsOnBills="true" id ="delete" href="javascript:void (0)"><i class="fa fa-remove" aria-hidden="true"></i>删除</a>
                           </li>
                           <li class="nav-item">
-                              <a class="nav-link text-primary" doing="false" fcsOnBills="true" id="upLevel"  href="javascript: void(0);"><i class="fa fa-arrow-left" aria-hidden="true"></i>升级</a>
+                              <a class="nav-link text-primary lock-btn-control" doing="false" fcsOnBills="true" id="upLevel"  href="javascript: void(0);"><i class="fa fa-arrow-left" aria-hidden="true"></i>升级</a>
                           </li>
                           <li class="nav-item">
-                              <a class="nav-link text-primary" doing="false" fcsOnBills="true" id="downLevel" href="javascript: void(0);"><i class="fa fa-arrow-right" aria-hidden="true"></i>降级</a>
+                              <a class="nav-link text-primary lock-btn-control" doing="false" fcsOnBills="true" id="downLevel" href="javascript: void(0);"><i class="fa fa-arrow-right" aria-hidden="true"></i>降级</a>
                           </li>
                           <li class="nav-item">
-                              <a class="nav-link text-primary" doing="false" fcsOnBills="true" canMove="false" id="upMove" href="javascript: void(0);"><i class="fa fa-arrow-up" aria-hidden="true"></i>上移</a>
+                              <a class="nav-link text-primary lock-btn-control" doing="false" fcsOnBills="true" canMove="false" id="upMove" href="javascript: void(0);"><i class="fa fa-arrow-up" aria-hidden="true"></i>上移</a>
                           </li>
                           <li class="nav-item">
-                              <a class="nav-link text-primary" doing="false" fcsOnBills="true" canMove="false" id="downMove" href="javascript: void(0);"><i class="fa fa-arrow-down" aria-hidden="true"></i>下移</a>
+                              <a class="nav-link text-primary lock-btn-control" doing="false" fcsOnBills="true" canMove="false" id="downMove" href="javascript: void(0);"><i class="fa fa-arrow-down" aria-hidden="true"></i>下移</a>
                           </li>
                       </ul>
                   </div>
@@ -85,7 +85,7 @@
                   </div>-->
                   <div class="form-group">
                       <a class="pull-right" href="javacript:void(0);" data-toggle="modal" data-target="#help" >html怎么写?</a>
-                      <a trigger="billsRecharge" class="pull-right mr-3 uploadImgTrigger" href="javacript:void(0);" data-toggle="modal" data-target="#uploadimg" ><i class="fa fa-image"></i>上传图片</a>
+                      <a trigger="billsRecharge" class="pull-right mr-3 uploadImgTrigger lock-btn-control" href="javacript:void(0);" data-toggle="modal" data-target="#uploadimg" ><i class="fa fa-image"></i>上传图片</a>
                       <label for="exampleTextarea">补注:</label>
                       <textarea class="form-control" id="exampleTextarea" rows="8"></textarea>
                   </div>
@@ -341,6 +341,7 @@
     <script src="/web/maintain/bills_lib/scripts/global.js"></script>
     <script src="/public/web/PerfectLoad.js"></script>
     <script src="/public/web/common_ajax.js"></script>
+    <script src="/public/web/lock_util.js"></script>
     <script src="/public/web/sheet/sheet_common.js"></script>
     <script src="/web/maintain/bills_lib/scripts/set_sheets.js"></script>
     <script src="/web/maintain/bills_lib/scripts/bills_lib_ajax.js"></script>
@@ -357,10 +358,12 @@
     <script src="/web/common/js/uploadImg.js"></script>
 </body>
 <script type="text/javascript">
+    const locked = lockUtil.getLocked();
     var codeEditor = CodeMirror.fromTextArea(document.getElementById("exampleTextarea"), {
         mode: "text/html",
         lineNumbers: true,
-        theme:"material"
+        theme:"material",
+        readOnly: locked
     });
     codeEditor.setSize('auto','350px');
     autoFlashHeight();
@@ -376,20 +379,24 @@
     let sheetItemsDatas;
     let sheetBillsDatas;
     tools.redirect(billsLibId, 'stdBillsmain');
+    let billsSpread;
     let jobsSpread = new GC.Spread.Sheets.Workbook($("#spreadJobs")[0], {sheetCount: 1});
     sheetCommonObj.bindEscKey(jobsSpread, [{sheet: jobsSpread.getSheet(0), editStarting: jobsController.onEditStart, editEnded: jobsController.onEditEnded}]);
     let itemsSpread = new GC.Spread.Sheets.Workbook($("#spreadItems")[0], {sheetCount: 1});
     sheetCommonObj.bindEscKey(itemsSpread, [{sheet: itemsSpread.getSheet(0), editStarting: itemsController.onEditStart, editEnded: itemsController.onEditEnded}]);
     $(document).ready(function(){
         $("#aStdJobs").attr('href', function(){
-            return 'stdJobs?billsLibId=' + billsLibId;
+            return `stdJobs?billsLibId=${billsLibId}&locked=${locked}`;
         });
         $('#aStdItems').attr('href', function(){
-            return 'stdItems?billsLibId=' + billsLibId;
+            return `stdItems?billsLibId=${billsLibId}&locked=${locked}`;
         });
         billsAjax.getStdBillsLibName(billsLibId);
         billsAjax.getBills(billsLibId, function(bills){
             showBillsSheet(bills, jobsSpread.getActiveSheet(), itemsSpread.getActiveSheet(), billsLibSetting)
+            const spreads = [billsSpread, jobsSpread, itemsSpread];
+            const $range = $(document.body);
+            lockUtil.lockSpreadsAndTools(spreads, $range, locked);
         });
         buildJobs(jobsSpread, jobsSetting);
         buildItems(itemsSpread, itemsSetting);
@@ -468,7 +475,7 @@
         sheet.resumeEvent();
     }
     function showBillsSheet(datas, jobsSheet, itemsSheet, setting) {
-        let billsSpread = new GC.Spread.Sheets.Workbook($('#spreadBills')[0], {sheetCount: 1});
+        billsSpread = new GC.Spread.Sheets.Workbook($('#spreadBills')[0], {sheetCount: 1});
         let billsSheet = billsSpread.getSheet(0);
         sheetCommonObj.bindEscKey(billsSpread, [{sheet: billsSpread.getSheet(0), editStarting: dbController.onEditStart, editEnded: dbController.onEditEnded}]);
         billsSpread.focus(true);
@@ -635,6 +642,9 @@
     }
 
     function refreshBtn(controller){
+        if (locked) {
+            return;
+        }
         controller.bind('refreshBaseActn', function (tree) {
             let showButton = function (show, btn) {
                 tools.btnAction($('#insert'), 'focusOnBills');

+ 5 - 2
web/maintain/bills_lib/html/tezheng.html

@@ -216,6 +216,7 @@
     <script src="/web/maintain/bills_lib/scripts/global.js"></script>
     <script src="/public/web/PerfectLoad.js"></script>
     <script src="/public/web/common_ajax.js"></script>
+    <script src="/public/web/lock_util.js"></script>
     <script src="/public/web/sheet/sheet_common.js"></script>
     <script src="/web/maintain/bills_lib/scripts/set_sheets.js"></script>
     <script src="/web/maintain/bills_lib/scripts/bills_lib_ajax.js"></script>
@@ -224,6 +225,7 @@
     <script src="/web/maintain/bills_lib/scripts/bills_lib_setting.js"></script>
     <script src="/web/maintain/bills_lib/scripts/db_controller.js"></script>
     <SCRIPT type="text/javascript">
+        const locked = lockUtil.getLocked();
         let spread = new GC.Spread.Sheets.Workbook($('#spreadAllItems')[0], {sheetCount: 1});
         sheetCommonObj.bindEscKey(spread, [{sheet: spread.getSheet(0), editStarting: totalItemsController.onEditStart, editEnded: totalItemsController.onEditEnded}]);
         let spreadVal = new GC.Spread.Sheets.Workbook($('#spreadEigenvalue')[0], {sheetCount: 1});
@@ -239,15 +241,16 @@
         let valueDatas;
   		$(document).ready(function(){
             $('#aStdBills').attr('href', function(){
-                return 'stdBills?billsLibId=' + billsLibId;
+                return `stdBills?billsLibId=${billsLibId}&locked=${locked}`;
             });
             $('#aStdJobs').attr('href', function(){
-                return 'stdJobs?billsLibId=' + billsLibId;
+                return `stdJobs?billsLibId=${billsLibId}&locked=${locked}`;
             });
 
             billsAjax.getStdBillsLibName(billsLibId);
             buildAllItems(spread, totalItemsSetting);
             buildEigenvalue(spreadVal, eigenValueSetting);
+            lockUtil.lockSpreads([spread, spreadVal], locked);
   		});
         function buildAllItems(spread, setting){
             setSheet.initSheet(spread, setting, true);

+ 52 - 27
web/maintain/bills_lib/scripts/bills_lib_ajax.js

@@ -50,34 +50,46 @@ var mainAjax = {
             }
         });
     },
+    getLibsHtml: function (data) {
+        const libHtml = data.reduce((acc, libData) => {
+            const id = libData.billsLibId;
+            const billsLibName = libData.billsLibName;
+            const createDateFmt = new Date(libData.createDate).format("yyyy-MM-dd");
+            const html =
+                `<tr id="${id}">
+                    <td><a href="/stdBills?billsLibId=${id}&locked=true">${billsLibName}</a></td>
+                    <td>${createDateFmt}</td>
+                    <td>
+                        <a class="lock-btn-control disabled" data-toggle="modal" data-target="#edit" href="javascript:void(0);" title="编辑"><i class="fa fa-pencil-square-o"></i></a>
+                        <a class="text-danger lock-btn-control disabled" data-toggle="modal" data-target="#del" href="javascript:void(0);" title="删除"><i class="fa fa-remove"></i></a>
+                        <a class="lock" data-locked="true" href="javascript:void(0);" title="解锁"><i class="fa fa-unlock-alt"></i></a>
+                    </td>
+                    <td>
+                        <a class="btn btn-secondary btn-sm import-data lock-btn-control disabled" data-id="${id}" href="javascript:void(0);" title="导入数据"><i class="fa fa-sign-in fa-rotate-90"></i>导入</a>
+                    </td>
+                    <td>
+                        <a class="btn btn-secondary btn-sm copy-data lock-btn-control disabled" data-id="${id}" href="javascript:void(0);" title="复制数据"><i class="fa fa-clone"></i>复制</a>
+                    </td>
+                 </tr>`;
+            return acc += html;
+        }, '');
+        return libHtml;
+    },
     getStdBillsLib: function(){
+        const me = this;
         $.ajax({
             type: "post",
             url: "/stdBillsEditor/getStdBillsLib",
             dataType: "json",
             success: function(result){
                 if(result.data){
-                    for(var i=0; i<result.data.length; i++){
-                        var id = result.data[i].billsLibId;
-                        var billsLibName = result.data[i].billsLibName;
-                        var createDate = result.data[i].createDate;
-                        var createDateFmt = new Date(createDate).format("yyyy-MM-dd");
-                        $("#showArea").append(
-                            "<tr id='"+ id +"'>" +
-                            "<td><a href='stdBills?billsLibId=" + id + "'>"+billsLibName+"</a></td>" +
-                            "<td>"+createDateFmt+" </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>" +
-                            "<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>");
-                    }
+                    $('#showArea').append(me.getLibsHtml(result.data));
                 }
-
             }
         });
     },
     createStdBillsLib: function(userAccount, billsLibName){
+        const me = this;
         $.ajax({
             type: "POST",
             url: "/stdBillsEditor/createStdBillsLib",
@@ -85,18 +97,31 @@ var mainAjax = {
             dataType: "json",
             success: function(result){
                 if(!result.error){
-                    var id = result.data[0].billsLibId;
-                    var createDate = result.data[0].createDate;
-                    var createDateFmt = new Date(createDate).format("yyyy-MM-dd");
-                    $("#showArea").append(
-                        "<tr id='" + id + "'><td><a href='stdBills?billsLibId=" + id + "'>"+billsLibName+"</a></td><td>"+createDateFmt+" </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>" +
-                        "<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>"
-                    );
-                    $('#cancelBtn').click();
+                    $('#showArea').append(me.getLibsHtml(result.data));
+                    $('#add').modal('hide');
+                }
+            }
+        });
+    },
+    copyBillsLib: function (libId, libName) {
+        const me = this;
+        $.ajax({
+            type: 'post',
+            url: '/stdBillsEditor/copyStdBillsLib',
+            data: {data: JSON.stringify({libId, libName})},
+            dataType: 'json',
+            timeout: 150000,
+            beforeSend: function () {
+                $('#copy').modal('hide');
+                $.bootstrapLoading.start();
+            },
+            success: function (result) {
+                if (!result.error) {
+                    $('#showArea').append(me.getLibsHtml(result.data));
                 }
+            },
+            complete: function () {
+                $.bootstrapLoading.end();
             }
         });
     },

+ 11 - 10
web/maintain/calc_program_lib/html/edit.html

@@ -9,17 +9,17 @@
 <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 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 lock-btn-control" id="format"><i class="fa fa-list-alt" aria-hidden="true"></i> 校验格式</a>
+                            <a href="javascript:void(0)" class="btn btn-sm lock-btn-control" id="save"><i class="fa fa-floppy-o" aria-hidden="true"></i> 保存</a>
+                        </div>
                     </div>
-                </div>
-            </nav>
-            <textarea class="form-control" id="templateList" rows="38"></textarea>
-        </div>
+                </nav>
+                <textarea class="form-control lock-text-control" id="templateList" rows="38"></textarea>
+            </div>
         </div>
         <input type="hidden" id="libID" value="<%= libID %>">
         <input type="hidden" id="originalTemplates" value="<%= templateList %>">
@@ -32,4 +32,5 @@
 
 </script>
 <script type="text/javascript" src="/lib/json/json2.js"></script>
+<script src="/public/web/lock_util.js"></script>
 <script type="text/javascript" src="/web/maintain/calc_program_lib/js/calc_program_edit.js"></script>

+ 6 - 4
web/maintain/calc_program_lib/html/main.html

@@ -19,17 +19,18 @@
                 <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>
+                            <thead><tr><th>库名称</th><th>自定义显示名称</th><th >费用定额</th><th width="160">添加时间</th><th width="70">操作</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 id="<%= lib.ID%>"><a href="/calcProgram/edit/<%= lib.ID%>?locked=true"><%= 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>
+                                    <a class="lock-btn-control disabled" href="javascript:void(0);" style="color: #0275d8" onclick='getCalcProgramLib("<%= lib.ID%>")' title="编辑"><i class="fa fa-pencil-square-o"></i></a>
+                                    <a class="text-danger lock-btn-control disabled" href="javascript:void(0);" style="color: #0275d8" onclick='showDeleteModal("<%= lib.ID%>")' title="删除"><i class="fa fa-remove"></i></a>
+                                    <a class="lock" data-locked="true" href="javascript:void(0);" title="解锁"><i class="fa fa-unlock-alt"></i></a>
                                 </td>
                             </tr>
                             <% } %>
@@ -135,4 +136,5 @@
     </div>
 </div>
 
+<script src="/public/web/lock_util.js"></script>
 <script type="text/javascript" src="/web/maintain/calc_program_lib/js/calc_program.js"></script>

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

@@ -64,6 +64,10 @@ $(document).ready(function() {
         }
     });
 
+    // 锁定、解锁
+    $('.lock').click(function () {
+        lockUtil.handleLockClick($(this));
+    });
 });
 
 

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

@@ -4,6 +4,8 @@
 
 
 $(document).ready(function () {
+    const locked = lockUtil.getLocked();
+    lockUtil.lockTools($(document.body), locked);
     try {
         let tem = sortJson(JSON.parse($("#originalTemplates").val()));
         $("#templateList").val(JSON.stringify(tem,null,4));

+ 6 - 0
web/maintain/common/css/main.css

@@ -355,4 +355,10 @@ input[type=checkbox]{
     text-shadow: 0 1px 0 #fff;
     filter: alpha(opacity=20);
     opacity: .2;
+}
+
+.disabled {
+    pointer-events: none;
+    opacity: .65;
+    color:#666;
 }

+ 11 - 10
web/maintain/fee_rate_lib/html/edit.html

@@ -9,17 +9,17 @@
 <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 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 lock-btn-control" id="format"><i class="fa fa-list-alt" aria-hidden="true"></i> 校验格式</a>
+                            <a href="javascript:void(0)" class="btn btn-sm lock-btn-control" id="save"><i class="fa fa-floppy-o" aria-hidden="true"></i> 保存</a>
+                        </div>
                     </div>
-                </div>
-            </nav>
-            <textarea class="form-control" id="rateList" rows="38"></textarea>
-        </div>
+                </nav>
+                <textarea class="form-control lock-text-control" id="rateList" rows="38"></textarea>
+            </div>
         </div>
         <input type="hidden" id="libID" value="<%= libID %>">
         <input type="hidden" id="originalRates" value="<%= rateList %>">
@@ -32,4 +32,5 @@
 
 </script>
 <script type="text/javascript" src="/lib/json/json2.js"></script>
+<script src="/public/web/lock_util.js"></script>
 <script type="text/javascript" src="/web/maintain/fee_rate_lib/js/fee_rate_edit.js"></script>

+ 7 - 5
web/maintain/fee_rate_lib/html/main.html

@@ -19,16 +19,17 @@
                 <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>
+                            <thead><tr><th>库名称</th><th >费用定额</th><th width="160">添加时间</th><th width="70">操作</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 id="<%= lib.ID%>"><a href="/feeRate/edit/<%= lib.ID%>?locked=true"><%= 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>
+                                    <a class="lock-btn-control disabled" href="javascript:void(0);" style="color: #0275d8" onclick='getFeeRateLib("<%= lib.ID%>")' title="编辑"><i class="fa fa-pencil-square-o"></i></a>
+                                    <a class="text-danger lock-btn-control disabled" href="javascript:void(0);" style="color: #0275d8" onclick='showDeleteModal("<%= lib.ID%>")' title="删除"><i class="fa fa-remove"></i></a>
+                                    <a class="lock" data-locked="true" href="javascript:void(0);" title="解锁"><i class="fa fa-unlock-alt"></i></a>
                                 </td>
                             </tr>
                             <% } %>
@@ -124,4 +125,5 @@
     </div>
 </div>
 
-<script type="text/javascript" src="/web/maintain/fee_rate_lib/js/fee_rate.js"></script>
+<script src="/public/web/lock_util.js"></script>
+<script type="text/javascript" src="/web/maintain/fee_rate_lib/js/fee_rate.js"></script>

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

@@ -57,6 +57,11 @@ $(document).ready(function() {
             }
         }
     });
+
+    // 锁定、解锁
+    $('.lock').click(function () {
+        lockUtil.handleLockClick($(this));
+    });
 });
 
 async function getFeeRateLib (ID) {

+ 2 - 1
web/maintain/fee_rate_lib/js/fee_rate_edit.js

@@ -2,7 +2,8 @@
  * Created by zhang on 2018/9/11.
  */
 $(document).ready(function () {
-
+    const locked = lockUtil.getLocked();
+    lockUtil.lockTools($(document.body), locked);
     try {
         let tem = sortJson(JSON.parse($("#originalRates").val()));
         $("#rateList").val(JSON.stringify(tem,null,4));

+ 5 - 4
web/maintain/main_col_lib/html/edit.html

@@ -13,13 +13,13 @@
             <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>
+                        <a href="javascript:void(0)" class="btn btn-sm lock-btn-control" id="createNormal"><i class="fa fa-list-alt" aria-hidden="true"></i> 生成默认</a>
+                        <a href="javascript:void(0)" class="btn btn-sm lock-btn-control" id="format"><i class="fa fa-list-alt" aria-hidden="true"></i> 校验格式</a>
+                        <a href="javascript:void(0)" class="btn btn-sm lock-btn-control" 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>
+            <textarea class="form-control lock-text-control" id="mainTreeCol" rows="38"></textarea>
         </div>
         </div>
         <input type="hidden" id="libID" value="<%= libID %>">
@@ -33,4 +33,5 @@
 
 </script>
 <script type="text/javascript" src="/lib/json/json2.js"></script>
+<script src="/public/web/lock_util.js"></script>
 <script type="text/javascript" src="/web/maintain/main_col_lib/js/main_col_edit.js"></script>

+ 6 - 4
web/maintain/main_col_lib/html/main.html

@@ -5,16 +5,17 @@
                 <div class="col-md-8">
                     <div class="warp-p2 mt-3">
                         <table class="table table-hover table-bordered">
-                            <thead><tr><th>列设置名称</th><th width="160">编办</th><th width="160">添加时间</th><th width="90">操作</th></tr></thead>
+                            <thead><tr><th>列设置名称</th><th width="160">编办</th><th width="160">添加时间</th><th width="70">操作</th></tr></thead>
                             <tbody id="showArea">
                             <% for(let lib of mainColLibs){ %>
                             <tr class="libTr">
-                                <td id="<%= lib.ID%>"><a href="/mainTreeCol/edit/<%= lib.ID%>"><%= lib.name%></a></td>
+                                <td id="<%= lib.ID%>"><a href="/mainTreeCol/edit/<%= lib.ID%>?locked=true"><%= lib.name%></a></td>
                                 <td><%= lib.compilationName%></td>
                                 <td><%= moment(lib.createDate).format('YYYY-MM-DD')%></td>
                                 <td>
-                                    <a style="color: #0275d8" onclick='getMainColLib("<%= 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>
+                                    <a class="lock-btn-control disabled" href="javascript:void(0);" style="color: #0275d8" onclick='getMainColLib("<%= lib.ID%>")' title="编辑"><i class="fa fa-pencil-square-o"></i></a>
+                                    <a class="text-danger lock-btn-control disabled" href="javascript:void(0);" style="color: #0275d8"  onclick='showDeleteModal("<%= lib.ID%>")' title="删除"><i class="fa fa-remove"></i></a>
+                                    <a class="lock" data-locked="true" href="javascript:void(0);" title="解锁"><i class="fa fa-unlock-alt"></i></a>
                                 </td>
                             </tr>
                             <% } %>
@@ -174,6 +175,7 @@
 </div>
 <script src = "/lib/spreadjs/sheets/gc.spread.sheets.all.11.1.2.min.js"></script>
 <script>GC.Spread.Sheets.LicenseKey =  '<%- LicenseKey %>';</script>
+<script src="/public/web/lock_util.js"></script>
 <script src="/web/maintain/bills_lib/scripts/bills_lib_ajax.js"></script>
 <script type="text/javascript" src="/web/maintain/main_col_lib/js/main_tree_col.js"></script>
 <script type="text/javascript" src="/web/maintain/main_col_lib/js/main_col_lib.js"></script>

+ 2 - 0
web/maintain/main_col_lib/js/main_col_edit.js

@@ -3,6 +3,8 @@
  */
 
 $(document).ready(function () {
+    const locked = lockUtil.getLocked();
+    lockUtil.lockTools($(document.body), locked);
     try {
         let tem = JSON.parse($("#originalMainCol").val());
         tem = sortJson(tem);

+ 4 - 0
web/maintain/main_col_lib/js/main_col_lib.js

@@ -37,6 +37,10 @@ $(document).ready(function() {
         }
     });
 
+    $('.lock').click(function () {
+        lockUtil.handleLockClick($(this));
+    });
+
 });
 
 let colEditSpread = null;

+ 1 - 1
web/maintain/material_replace_lib/html/edit.html

@@ -63,5 +63,5 @@
 <script type="text/javascript" src="/lib/jquery-contextmenu/jquery.contextMenu.js"></script>
 <script type="text/javascript" src="/public/web/sheet/sheet_common.js"></script>
 <script type="text/javascript" src="/public/web/sheet/sheet_data_helper.js"></script>
-
+<script src="/public/web/lock_util.js"></script>
 <script type="text/javascript" src="/web/maintain/material_replace_lib/js/material_replace_edit.js"></script>

+ 6 - 4
web/maintain/material_replace_lib/html/main.html

@@ -5,17 +5,18 @@
                 <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>
+                            <thead><tr><th>库名称</th><th>清单规则</th><th >费用定额</th><th width="160">添加时间</th><th width="70">操作</th></tr></thead>
                             <tbody id="showArea">
                             <% for(let lib of materialLibs){ %>
                             <tr class="libTr">
-                                <td id="<%= lib.ID%>"><a href="/materialReplace/edit/<%= lib.ID%>"><%= lib.name%></a></td>
+                                <td id="<%= lib.ID%>"><a href="/materialReplace/edit/<%= lib.ID%>?locked=true"><%= lib.name%></a></td>
                                 <td><%= lib.billsLibName%></td>
                                 <td><%= lib.compilationName%></td>
                                 <td><%= moment(lib.createDate).format('YYYY-MM-DD')%></td>
                                 <td>
-                                    <a style="color: #0275d8" onclick='getMaterialLib("<%= 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>
+                                    <a class="lock-btn-control disabled" href="javascript:void(0);" style="color: #0275d8" onclick='getMaterialLib("<%= lib.ID%>")' title="编辑"><i class="fa fa-pencil-square-o"></i></a>
+                                    <a class="text-danger lock-btn-control disabled" href="javascript:void(0);" style="color: #0275d8" onclick='showDeleteModal("<%= lib.ID%>")' title="删除"><i class="fa fa-remove"></i></a>
+                                    <a class="lock" data-locked="true" href="javascript:void(0);" title="解锁"><i class="fa fa-unlock-alt"></i></a>
                                 </td>
                             </tr>
                             <% } %>
@@ -115,4 +116,5 @@
     </div>
 </div>
 
+<script src="/public/web/lock_util.js"></script>
 <script type="text/javascript" src="/web/maintain/material_replace_lib/js/material_replace.js"></script>

+ 4 - 0
web/maintain/material_replace_lib/js/material_replace.js

@@ -66,6 +66,10 @@ $(document).ready(function() {
         }
     });
 
+    // 锁定、解锁
+    $('.lock').click(function () {
+        lockUtil.handleLockClick($(this));
+    });
 
 })
 

+ 3 - 3
web/maintain/material_replace_lib/js/material_replace_edit.js

@@ -1,7 +1,7 @@
 /**
  * Created by zhang on 2018/8/23.
  */
-
+const locked = lockUtil.getLocked();
 let materialOjb = {
     billsSpread:null,
     materialSpread:null,
@@ -100,7 +100,7 @@ let materialOjb = {
                     name: "删除",
                     icon: 'fa-trash-o',
                     disabled: function () {
-                        return !me.canDelete(sheet);
+                        return locked || !me.canDelete(sheet);
                     },
                     callback: function (key, opt) {
                         sheet.name() == 'billsSheet' ? me.deleteBills(sheet):me.deleteMaterial(sheet);
@@ -432,4 +432,4 @@ function isDef(obj) {
 }
 
 materialOjb.initSpread();
-
+lockUtil.lockSpreads([materialOjb.billsSpread, materialOjb.materialSpread], locked);

+ 5 - 4
web/maintain/progressive_lib/html/edit.html

@@ -13,13 +13,13 @@
             <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>
+                        <a href="javascript:void(0)" class="btn btn-sm lock-btn-control" id="createNormal"><i class="fa fa-list-alt" aria-hidden="true"></i> 生成默认</a>
+                        <a href="javascript:void(0)" class="btn btn-sm lock-btn-control" id="format"><i class="fa fa-list-alt" aria-hidden="true"></i> 校验格式</a>
+                        <a href="javascript:void(0)" class="btn btn-sm lock-btn-control" id="save"><i class="fa fa-floppy-o" aria-hidden="true"></i> 保存</a>
                     </div>
                 </div>
             </nav>
-            <textarea class="form-control" id="progressiveList" rows="38"></textarea>
+            <textarea class="form-control lock-text-control" id="progressiveList" rows="38"></textarea>
         </div>
         </div>
         <input type="hidden" id="libID" value="<%= libID %>">
@@ -33,4 +33,5 @@
 
 </script>
 <script type="text/javascript" src="/lib/json/json2.js"></script>
+<script src="/public/web/lock_util.js"></script>
 <script type="text/javascript" src="/web/maintain/progressive_lib/js/progressive_interval_edit.js"></script>

+ 6 - 4
web/maintain/progressive_lib/html/main.html

@@ -5,15 +5,16 @@
                 <div class="col-md-5">
                     <div class="warp-p2 mt-3">
                         <table class="table table-hover table-bordered">
-                            <thead><tr><th >库名称</th><th width="160">添加时间</th><th width="120">操作</th></tr></thead>
+                            <thead><tr><th >库名称</th><th width="160">添加时间</th><th width="70">操作</th></tr></thead>
                             <tbody id="showArea">
                             <% for(let lib of progressiveLibs){ %>
                             <tr class="libTr">
-                                <td id="<%= lib.ID%>"><a href="/progressive/edit/<%= lib.ID%>"><%= lib.name%></a></td>
+                                <td id="<%= lib.ID%>"><a href="/progressive/edit/<%= lib.ID%>?locked=true"><%= lib.name%></a></td>
                                 <td><%= moment(lib.createDate).format('YYYY-MM-DD')%></td>
                                 <td>
-                                    <a style="color: #0275d8" onclick='getProgressiveLib("<%= 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>
+                                    <a class="lock-btn-control disabled" href="javascript:;" style="color: #0275d8" onclick='getProgressiveLib("<%= lib.ID%>")' title="编辑"><i class="fa fa-pencil-square-o"></i></a>
+                                    <a class="text-danger lock-btn-control disabled" href="javascript:;" style="color: #0275d8" onclick='showDeleteModal("<%= lib.ID%>")' title="删除"><i class="fa fa-remove"></i></a>
+                                    <a class="lock" data-locked="true" href="javascript:void(0);" title="解锁"><i class="fa fa-unlock-alt"></i></a>
                                 </td>
                             </tr>
                             <% } %>
@@ -105,4 +106,5 @@
     </div>
 </div>
 
+<script src="/public/web/lock_util.js"></script>
 <script type="text/javascript" src="/web/maintain/progressive_lib/js/progressive_interval.js"></script>

+ 4 - 0
web/maintain/progressive_lib/js/progressive_interval.js

@@ -52,6 +52,10 @@ $(document).ready(function() {
             }
         }
     });
+    // 锁定、解锁
+    $('.lock').click(function () {
+        lockUtil.handleLockClick($(this));
+    });
 });
 
 async function getProgressiveLib (ID) {

+ 2 - 0
web/maintain/progressive_lib/js/progressive_interval_edit.js

@@ -3,6 +3,8 @@
  */
 
 $(document).ready(function () {
+    const locked = lockUtil.getLocked();
+    lockUtil.lockTools($(document.body), locked);
     try {
         let tem = sortJson(JSON.parse($("#originalInterval").val()));
         $("#progressiveList").val(JSON.stringify(tem,null,4));

+ 12 - 16
web/maintain/project_feature_lib/html/edit.html

@@ -9,28 +9,24 @@
 <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 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 lock-btn-control" id="createNormal"><i class="fa fa-list-alt" aria-hidden="true"></i> 生成默认</a>
+                            <a href="javascript:void(0)" class="btn btn-sm lock-btn-control" id="format"><i class="fa fa-list-alt" aria-hidden="true"></i> 校验格式</a>
+                            <a href="javascript:void(0)" class="btn btn-sm lock-btn-control" id="save"><i class="fa fa-floppy-o" aria-hidden="true"></i> 保存</a>
+                        </div>
                     </div>
-                </div>
-            </nav>
-            <textarea class="form-control" id="featureList" rows="38"></textarea>
-        </div>
+                </nav>
+                <textarea class="form-control lock-text-control" id="featureList" rows="38"></textarea>
+            </div>
         </div>
         <input type="hidden" id="libID" value="<%= libID %>">
         <input type="hidden" id="originalFeature" value="<%= featureList %>">
     </div>
 </div>
 
-
-
-<script type="text/javascript">
-
-</script>
 <script type="text/javascript" src="/lib/json/json2.js"></script>
+<script src="/public/web/lock_util.js"></script>
 <script type="text/javascript" src="/web/maintain/project_feature_lib/js/project_feature_edit.js"></script>

+ 6 - 4
web/maintain/project_feature_lib/html/main.html

@@ -19,16 +19,17 @@
                 <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>
+                            <thead><tr><th >库名称</th><th>费用定额</th><th width="160">添加时间</th><th width="70">操作</th></tr></thead>
                             <tbody id="showArea">
                             <% for(let lib of featureLibs){ %>
                             <tr class="libTr">
-                                <td id="<%= lib.ID%>"><a href="/projectFeature/edit/<%= lib.ID%>"><%= lib.name%></a></td>
+                                <td id="<%= lib.ID%>"><a href="/projectFeature/edit/<%= lib.ID%>?locked=true"><%= lib.name%></a></td>
                                 <td><%= lib.compilationName%></td>
                                 <td><%= moment(lib.createDate).format('YYYY-MM-DD')%></td>
                                 <td>
-                                    <a style="color: #0275d8" onclick='getFeatureLib("<%= 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>
+                                    <a class="lock-btn-control disabled" href="javascript:void(0);" style="color: #0275d8" onclick='getFeatureLib("<%= lib.ID%>")' title="编辑"><i class="fa fa-pencil-square-o"></i></a>
+                                    <a class="text-danger lock-btn-control disabled" href="javascript:void(0);" onclick='showDeleteModal("<%= lib.ID%>")' title="删除"><i class="fa fa-remove"></i></a>
+                                    <a class="lock" data-locked="true" href="javascript:void(0);" title="解锁"><i class="fa fa-unlock-alt"></i></a>
                                 </td>
                             </tr>
                             <% } %>
@@ -129,4 +130,5 @@
     </div>
 </div>
 
+<script src="/public/web/lock_util.js"></script>
 <script type="text/javascript" src="/web/maintain/project_feature_lib/js/project_feature.js"></script>

+ 4 - 0
web/maintain/project_feature_lib/js/project_feature.js

@@ -52,6 +52,10 @@ $(document).ready(function() {
             }
         }
     });
+    // 锁定、解锁
+    $('.lock').click(function () {
+        lockUtil.handleLockClick($(this));
+    });
 });
 
 async function getFeatureLib (ID) {

+ 2 - 0
web/maintain/project_feature_lib/js/project_feature_edit.js

@@ -3,6 +3,8 @@
  */
 
 $(document).ready(function () {
+    const locked = lockUtil.getLocked();
+    lockUtil.lockTools($(document.body), locked);
     try {
         let tem = sortJson(JSON.parse($("#originalFeature").val()));
         $("#featureList").val(JSON.stringify(tem,null,4));

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

@@ -173,6 +173,7 @@
     <script src="/public/web/uuid.js"></script>
     <script src="/public/web/scMathUtil.js"></script>
     <script src="/public/common_util.js"></script>
+    <script src="/public/web/lock_util.js"></script>
     <script src="/public/web/storageUtil.js"></script>
     <script  src="/public/web/id_tree.js"></script>
     <script src="/public/web/tree_sheet/tree_sheet_controller.js"></script>

+ 31 - 0
web/maintain/ration_repository/css/main.css

@@ -294,3 +294,34 @@ div.resize-x{
     cursor: w-resize;
     float: left;
 }
+.reset *{
+    margin: 0;
+    padding: 0;
+}
+.info-list {
+    max-height: 300px;
+    overflow: auto;
+}
+.info-list .list-title{
+    font-weight: bold;
+}
+.info-list li{
+    list-style: none;
+    display: flex;
+}
+.info-list li:hover{
+    background-color: #eee;
+}
+.info-list li span {
+    flex: 1;
+}
+.info-list li a {
+    float: right;
+    width: 30px;
+    text-decoration: none;
+}
+.disabled {
+    pointer-events: none;
+    opacity: .65;
+    color:#666;
+}

+ 39 - 94
web/maintain/ration_repository/dinge.html

@@ -22,6 +22,7 @@
     </style>
     <script type="text/javascript">
         let priceProperties = JSON.parse('<%- priceProperties %>');
+        let userAccount = '<%=userAccount %>';
         console.log(priceProperties);
     </script>
 </head>
@@ -62,12 +63,12 @@
                         <div style="width: 99%; float: left">
                             <div class="tab-bar row">
                                 <div>
-                                    <a href="javascript:void(0);" id="tree_Insert" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="插入"><i class="fa fa-plus" aria-hidden="true"></i></a>
-                                    <a href="javascript:void(0);" id="tree_remove" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="删除"><i class="fa fa-remove" aria-hidden="true"></i></a>
-                                    <a href="javascript:void(0);" id="tree_upLevel" class="btn btn-sm " data-toggle="tooltip" data-placement="bottom" title="" data-original-title="升级"><i class="fa fa-arrow-left" aria-hidden="true"></i></a>
-                                    <a href="javascript:void(0);" id="tree_downLevel" class="btn btn-sm " data-toggle="tooltip" data-placement="bottom" title="" data-original-title="降级"><i class="fa fa-arrow-right" aria-hidden="true"></i></a>
-                                    <a href="javascript:void(0);" id="tree_downMove" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="下移"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
-                                    <a href="javascript:void(0);" id="tree_upMove" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="上移"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
+                                    <a href="javascript:void(0);" id="tree_Insert" class="btn btn-sm lock-btn-control" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="插入"><i class="fa fa-plus" aria-hidden="true"></i></a>
+                                    <a href="javascript:void(0);" id="tree_remove" class="btn btn-sm lock-btn-control" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="删除"><i class="fa fa-remove" aria-hidden="true"></i></a>
+                                    <a href="javascript:void(0);" id="tree_upLevel" class="btn btn-sm lock-btn-control" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="升级"><i class="fa fa-arrow-left" aria-hidden="true"></i></a>
+                                    <a href="javascript:void(0);" id="tree_downLevel" class="btn btn-sm lock-btn-control" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="降级"><i class="fa fa-arrow-right" aria-hidden="true"></i></a>
+                                    <a href="javascript:void(0);" id="tree_downMove" class="btn btn-sm lock-btn-control" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="下移"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
+                                    <a href="javascript:void(0);" id="tree_upMove" class="btn btn-sm lock-btn-control" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="上移"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
                                 </div>
                                 <div>
                                     <input type="text" class="form-control form-control-sm" placeholder="搜索定额" value="" id="rationSearch">
@@ -135,7 +136,7 @@
                             <div class="tab-pane" id="tsm" role="tabpanel">
                                 <div class="main-data">
                                 <div class="main-content m-2">
-                                    <a trigger="rationExplanation" class="mr-3 uploadImgTrigger" href="javacript:void(0);" data-toggle="modal" data-target="#uploadimg" ><i class="fa fa-image"></i>上传图片</a><a href="javacript:void(0);" data-toggle="modal" data-target="#help" >html怎么写?</a></p>
+                                    <a trigger="rationExplanation" class="mr-3 uploadImgTrigger lock-btn-control" href="javacript:void(0);" data-toggle="modal" data-target="#uploadimg" ><i class="fa fa-image"></i>上传图片</a><a href="javacript:void(0);" data-toggle="modal" data-target="#help" >html怎么写?</a></p>
                                     <textarea id="explanationShow" name="editor" class="form-control "></textarea>
                                     <!--<h5>说明</h5>
                                     <textarea id="explanationShow" class="form-control" style="background: white;"></textarea>-->
@@ -147,7 +148,7 @@
                                 <div class="main-data">
                                     <!--         <div class="m-2"><a href="javacript:void(0);" data-toggle="modal" data-target="#editTjs" title="编辑">编辑计算规则</a></div>-->
                                     <div class="main-content m-2">
-                                        <a trigger="rationRuleText" class="mr-3 uploadImgTrigger" href="javacript:void(0);" data-toggle="modal" data-target="#uploadimg" ><i class="fa fa-image"></i>上传图片</a><a href="javacript:void(0);" data-toggle="modal" data-target="#help" >html怎么写?</a></p>
+                                        <a trigger="rationRuleText" class="mr-3 uploadImgTrigger lock-btn-control" href="javacript:void(0);" data-toggle="modal" data-target="#uploadimg" ><i class="fa fa-image"></i>上传图片</a><a href="javacript:void(0);" data-toggle="modal" data-target="#help" >html怎么写?</a></p>
                                         <textarea id="ruleTextShow" name="editor" class="form-control "></textarea>
                                         <!--<h5>计算规则</h5>
                                         <textarea id="ruleTextShow" class="form-control" style="background: white;"></textarea>-->
@@ -157,11 +158,14 @@
                             <!--工作内容-->
                             <div class="tab-pane" id="tgz" role="tabpanel">
                                 <div class="main-data">
-                                    <div class="form-check m-2"><label class="form-check-label"><input type="radio" class="form-check-input" name="optionsRadios" value="ALL" disabled=""> 适合本项所有定额</label>&nbsp;&nbsp;<label class="form-check-label"><input type="radio" class="form-check-input" name="optionsRadios" value="PARTIAL" disabled> 适合本项部分定额</label></div>
+                                    <div class="form-check m-2">
+                                        <label class="form-check-label lock-btn-control"><input type="radio" class="form-check-input" name="optionsRadios" value="ALL" disabled=""> 适合本项所有定额</label>&nbsp;&nbsp;
+                                        <label class="form-check-label lock-btn-control"><input type="radio" class="form-check-input" name="optionsRadios" value="PARTIAL" disabled> 适合本项部分定额</label>
+                                    </div>
                                     <!-- <p class="m-2">适合本项所有定额</p> -->
                                     <table class="table table-sm table-bordered m-0" id="tableAll">
                                         <tr>
-                                            <td><textarea class="form-control" rows="30" id="txtareaAll"></textarea></td>
+                                            <td><textarea class="form-control lock-text-control" rows="30" id="txtareaAll"></textarea></td>
                                         </tr>
                                     </table>
                                     <table class="table table-sm table-bordered m-0" id="tablePartial">
@@ -171,11 +175,14 @@
                             <!--附注-->
                             <div class="tab-pane" id="tfz" role="tabpanel">
                                 <div class="main-data">
-                                    <div class="form-check m-2"><label class="form-check-label"><input type="radio" class="form-check-input" name="fzRadios" value="ALL" disabled=""> 适合本项所有定额</label>&nbsp;&nbsp;<label class="form-check-label"><input type="radio" class="form-check-input" name="fzRadios" value="PARTIAL" disabled> 适合本项部分定额</label></div>
+                                    <div class="form-check m-2">
+                                        <label class="form-check-label lock-btn-control"><input type="radio" class="form-check-input" name="fzRadios" value="ALL" disabled=""> 适合本项所有定额</label>&nbsp;&nbsp;
+                                        <label class="form-check-label lock-btn-control"><input type="radio" class="form-check-input" name="fzRadios" value="PARTIAL" disabled> 适合本项部分定额</label>
+                                    </div>
                                     <!-- <p class="m-2">适合本项所有定额</p> -->
                                     <table class="table table-sm table-bordered m-0" id="fzTableAll">
                                         <tr>
-                                            <td><textarea class="form-control" rows="30" id="fzTxtareaAll"></textarea></td>
+                                            <td><textarea class="form-control lock-text-control" rows="30" id="fzTxtareaAll"></textarea></td>
                                         </tr>
                                     </table>
                                     <table class="table table-sm table-bordered m-0" id="fzTablePartial">
@@ -555,6 +562,23 @@
                 </div>
             </div>
         </div>
+        <!--查找引用-->
+        <div class="modal fade" id="info" 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 typeClose" data-dismiss="modal" aria-label="Close">
+                            <span aria-hidden="true">×</span>
+                        </button>
+                    </div>
+                    <div class="modal-body reset">
+                        <ul id="infoBody" class="info-list">
+                        </ul>
+                    </div>
+                </div>
+            </div>
+        </div>
         <%include ../../common/html/uploadImg.html %>
         <!--弹出html填写帮助-->
         <!--弹出html填写帮助-->
@@ -645,7 +669,9 @@
         <script src="/lib/bootstrap/bootstrap.min.js"></script>
         <script src="/lib/lodash/lodash.js"></script>
         <script type="text/javascript" src="/web/maintain/ration_repository/js/global.js"></script>
+        <script src="/public/web/lock_util.js"></script>
         <script src="/public/web/PerfectLoad.js"></script>
+        <script src="/public/common_util.js"></script>
         <!-- zTree -->
         <script type="text/javascript" src="/lib/ztree/jquery.ztree.core.js"></script>
         <script type="text/javascript" src="/lib/ztree/jquery.ztree.excheck.js"></script>
@@ -680,88 +706,7 @@
         <script src="/web/common/js/uploadImg.js"></script>
         <script src="/web/common/js/slideResize.js"></script>
         <script src="/web/maintain/ration_repository/js/ration_template.js"></script>
-        <script type="text/javascript">
-            var exEditor = CodeMirror.fromTextArea(document.getElementById("explanationShow"), {
-                mode: "text/html",
-                lineNumbers: true,
-                theme:"material"
-            });
-            exEditor.setSize('auto','500px');
-            $('#explanationLink').click(function () {
-                setTimeout(function () {
-                    exEditor.refresh();
-                }, 100);
-            });
-            var calcEditor = CodeMirror.fromTextArea(document.getElementById("ruleTextShow"), {
-                mode: 'text/html',
-                lineNumbers: true,
-                theme: 'material'
-            });
-            calcEditor.setSize('auto', '500px');
-            $('#ruleTextLink').click(function () {
-                setTimeout(function () {
-                    calcEditor.refresh();
-                }, 100);
-            });
-
-            let userAccount = '<%=userAccount %>';
-            $(document).ready(function(){
-                rationOprObj.buildSheet($("#rationItemsSheet")[0]);
-                // tabPanel 下有多个Spread时,相互之间不能正确显示。改成一个Spread下多个Sheet。
-                var rdSpread = sheetCommonObj.createSpread($("#rdSpread")[0], 5);
-                rationGLJOprObj.buildSheet(rdSpread.getSheet(0));
-
-                rationAssistOprObj.buildSheet(rdSpread.getSheet(1));
-
-                rationCoeOprObj.buildSheet(rdSpread.getSheet(2));
-                rationInstObj.buildSheet(rdSpread.getSheet(3));
-                RationTemplate.buildSheet(rdSpread.getSheet(4));
-                rationInstObj.getInstallation(parseInt(getQueryString("repository")));
-                pageOprObj.initPage();
-
-                let rdSpreadEscSheets = [];
-                rdSpreadEscSheets.push({sheet: rdSpread.getSheet(0), editStarting: rationGLJOprObj.onEditStarting, editEnded: rationGLJOprObj.onCellEditEnd});
-                rdSpreadEscSheets.push({sheet: rdSpread.getSheet(1), editStarting: rationAssistOprObj.onEditStarting, editEnded: rationAssistOprObj.onEditEnded});
-                rdSpreadEscSheets.push({sheet: rdSpread.getSheet(2), editStarting: rationCoeOprObj.onEditStarting, editEnded: rationCoeOprObj.onEditEnded});
-                rdSpreadEscSheets.push({sheet: rdSpread.getSheet(3), editStarting: rationInstObj.onEditStarting, editEnded: rationInstObj.onEditEnded});
-                rdSpreadEscSheets.push({sheet: rdSpread.getSheet(4), editStarting: null, editEnded: RationTemplate.events.onEditEnded});
-                sheetCommonObj.bindEscKey(rdSpread, rdSpreadEscSheets);
-
-                $("#linkGLJ").click(function(){
-                    rationGLJOprObj.bindRationGljDelOpr();
-                    rdSpread.setActiveSheetIndex(0);
-                });
-
-                $("#linkFZDE").click(function(){
-                    rationAssistOprObj.bindRationAssDel();
-                    rdSpread.setActiveSheetIndex(1);
-                });
-
-                $("#linkFZTJ").click(function(){
-                    rationCoeOprObj.bindRationCoeDel();
-                    rdSpread.setActiveSheetIndex(2);
-                });
-                $("#linkAZZJ").click(function(){
-                    rationInstObj.bindRationInstDel();
-                    rdSpread.setActiveSheetIndex(3);
-                });
-                $("#linkMBGL").click(function(){
-                    RationTemplate.bindRationTempDel();
-                    rdSpread.setActiveSheetIndex(4);
-                });
-                //解决spreadjs sheet初始化没高度宽度
-                $('#modalCon').width($(window).width()*0.5);
-                $('#gljSelTreeDiv').height($(window).height() - 300);
-                $("#gljSelSheet").height($("#gljSelTreeDiv").height()-21.6);
-                $("#gljSelSheet").width($('#modalCon').width() * 0.63);
-                $(window).resize(function () {
-                    $('#modalCon').width($(window).width()*0.5);
-                    $('#gljSelTreeDiv').height($(window).height() - 300);
-                    $("#gljSelSheet").height($("#gljSelTreeDiv").height()-21.6);
-                    $("#gljSelSheet").width($('#modalCon').width()* 0.63);
-                });
-            });
-        </script>
+        <script src="/web/maintain/ration_repository/js/init.js"></script>
     </div>
 </body>
 <script type="text/javascript">

+ 81 - 17
web/maintain/ration_repository/js/coe.js

@@ -172,7 +172,7 @@ var pageObj = {
         gljAdjOprObj.buildSheet($('#contentSpread')[0]);
         coeOprObj.getCoeList();
         gljAdjOprObj.getGljItemsOcc();
-
+        lockUtil.lockSpreads([coeOprObj.workBook, gljAdjOprObj.workBook], locked);
     },
     showData: function(sheet, setting, data) {
         let me = pageObj, ch = GC.Spread.Sheets.SheetArea.viewport;
@@ -230,31 +230,35 @@ let coeOprObj = {
         me.workSheet = me.workBook.getSheet(0);
         me.workSheet.options.isProtected = true;
         me.onDelOpr(me.workBook, me.setting);
+        me.initContextMenu();
         me.workSheet.bind(GC.Spread.Sheets.Events.SelectionChanged, me.onSelectionChanged);
         me.workSheet.bind(GC.Spread.Sheets.Events.EditEnded, me.onEditEnded);
         me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
         me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
     },
     onSelectionChanged: function (sender, info) {
-        let me = coeOprObj, that = gljAdjOprObj;
         if(info.oldSelections.length === 0 && info.newSelections.length > 0 || info.oldSelections[0].row !== info.newSelections[0].row){
-            let row = info.newSelections[0].row;
-            if(row < me.currentCoeList.length){
-                me.currentCoe = me.currentCoeList[row];
-                that.currentGljAdjList = me.currentCoe.coes;
-                that.buildDynamicComboBox(that.workSheet);
-            }
-            else{
-                me.currentCoe = null;
-                that.currentGljAdjList = [];
-                that.buildBaseCell(that.workSheet);
-            }
-            //refresh & show coes
-            sheetCommonObj.cleanSheet(that.workSheet, that.setting, -1);
-            me.workBook.focus(true);
-            that.show(that.currentGljAdjList);
+            const row = info.newSelections[0].row;
+            coeOprObj.coeSelInit(row);
         }
     },
+    coeSelInit: function (row) {
+        const me = coeOprObj;
+        const adj = gljAdjOprObj;
+        if(row < me.currentCoeList.length){
+            me.currentCoe = me.currentCoeList[row];
+            adj.currentGljAdjList = me.currentCoe.coes;
+            adj.buildDynamicComboBox(adj.workSheet);
+        } else{
+            me.currentCoe = null;
+            adj.currentGljAdjList = [];
+            adj.buildBaseCell(adj.workSheet);
+        }
+        //refresh & show coes
+        sheetCommonObj.cleanSheet(adj.workSheet, adj.setting, -1);
+        me.workBook.focus(true);
+        adj.show(adj.currentGljAdjList);
+    },
     onEditEnded: function (sender, args) {
         let me = coeOprObj, addArr = [], updateArr = [], dataCode = me.setting.header[args.col].dataCode;
         if(args.editingText && args.editingText.toString().trim().length > 0){
@@ -411,6 +415,66 @@ let coeOprObj = {
         workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
         workBook.commandManager().setShortcutKey('coeListDel', GC.Spread.Commands.Key.del, false, false, false, false);
     },
+    initContextMenu: function () {
+        const me = this;
+        $.contextMenu({
+            selector: '#mainSpread',
+            build: function($triggerElement, e){
+                //控制允许右键菜单在哪个位置出现
+                const target = SheetDataHelper.safeRightClickSelection($triggerElement, e, me.workBook);
+                const sheet = me.workBook.getSheet(0);
+                if(target.hitTestType === 3){//在表格内&& typeof target.row !== 'undefined' && typeof target.col !== 'undefined'
+                    if(typeof target.row !== 'undefined'){
+                        //控制按钮是否可用
+                        sheet.setActiveCell(target.row, target.col);
+                        me.coeSelInit(target.row);
+                    }
+                    return {
+                        callback: function(){},
+                        items: {
+                            getReference: {
+                                name: '查找引用',
+                                disabled: function () {
+                                    return !me.currentCoeList || !me.currentCoeList[target.row];
+                                },
+                                icon: 'fa-search',
+                                callback: function () {
+                                    const coe = me.currentCoeList[target.row];
+                                    me.getReference(coe.ID);
+                                }
+                            },
+                        }
+                    };
+                }
+                else{
+                    return false;
+                }
+            }
+        });
+    },
+    getReference: function (coeID) {
+        const $info = $('#info');
+        const $infoBody = $('#infoBody');
+        $.bootstrapLoading.start();
+        CommonAjax.post('/rationRepository/api/getCoeReference', { rationRepId: pageOprObj.rationLibId, coeID }, function (info) {
+            let htmlArr = [];
+            if (!info || !info.length) {
+                htmlArr.push('<li>无引用数据</li>');
+            } else {
+                htmlArr = info.map(ration => {
+                    return `<li>
+                             <span>${ration.code}</span>
+                             <a data-dismiss="modal" href="javascript:;" onclick="sectionTreeObj.locateToSection('${ration.code}')">定位</a>
+                        </li>`;
+                });
+            }
+            $infoBody.html(htmlArr.join(''));
+            $info.modal('show');
+            $.bootstrapLoading.end();
+        }, function () {
+            $.bootstrapLoading.end();
+        });
+    },
     //粘贴的数据,编号唯一化,去除编号重复的项
     makeUniqItems: function (items) {
         let rst = [];

+ 32 - 0
web/maintain/ration_repository/js/explanatory.js

@@ -3,10 +3,42 @@
  */
 //定额章节节点说明、计算规则
 let explanatoryOprObj = {
+    exEditor: null,
+    calcEditor: null,
     preTreeNode: null,
     currentTreeNode: null,//定额章节树节点
     currentExplanation: null,
     currentRuleText: null,
+    // 初始化说明、计算规则编辑器
+    initEditor: function () {
+        const locked = lockUtil.getLocked();
+        const exEditor = CodeMirror.fromTextArea(document.getElementById("explanationShow"), {
+            mode: "text/html",
+            lineNumbers: true,
+            theme:"material",
+            readOnly: locked
+        });
+        exEditor.setSize('auto','500px');
+        $('#explanationLink').click(function () {
+            setTimeout(function () {
+                exEditor.refresh();
+            }, 100);
+        });
+        this.exEditor = exEditor;
+        const calcEditor = CodeMirror.fromTextArea(document.getElementById("ruleTextShow"), {
+            mode: 'text/html',
+            lineNumbers: true,
+            theme: 'material',
+            readOnly: locked
+        });
+        calcEditor.setSize('auto', '500px');
+        $('#ruleTextLink').click(function () {
+            setTimeout(function () {
+                calcEditor.refresh();
+            }, 100);
+        });
+        this.calcEditor = calcEditor;
+    },
     setAttribute: function (preNode, currentNode, explanation, ruleText) {
         let me = explanatoryOprObj;
         me.preTreeNode = preNode;

+ 21 - 47
web/maintain/ration_repository/js/gljSelect.js

@@ -39,55 +39,24 @@ let gljSelOprObj = {
             delete glj.ID;
         }
     },
-    getSelGljItems: function(stdGljLibId, callback) {
-        let me = this;
-        $.ajax({
-            type:"POST",
-            url:"/stdGljRepository/api/getGljItems",
-            data:{"repositoryId": stdGljLibId},
-            dataType:"json",
-            cache:false,
-            timeout:20000,
-            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.stdGljList = result.data;
-                    me.switchToGljId(me.stdGljList);
-                    me.sortGlj(me.stdGljList);
-                    if(callback){
-                        callback();
-                    }
-                }
-            },
-            error:function(err){
-                alert(err.responseJSON.error);
+    initGljList: function(gljList) {
+        if(priceProperties && priceProperties.length){
+            const priceField = priceProperties[0].price.dataCode;
+            for(let glj of gljList){
+                glj.basePrice = glj.priceProperty && glj.priceProperty[priceField] ? glj.priceProperty[priceField] : 0;
             }
-        });
+        }
+        this.stdGljList = gljList;
+        this.switchToGljId(this.stdGljList);
+        this.sortGlj(this.stdGljList);
     },
-    getGljClassTree: function (gljLibId, callback) {
-        let me = this;
-        let url = '/stdGljRepository/api/getGljTree';
-        let postData = {gljLibId: gljLibId};
-        let sucFunc = function (rstData) {
-            zTreeHelper.createTree(rstData, gljSelTreeOprObj.setting, "selGljTree", gljSelOprObj);
-            let rootNode = gljSelOprObj.treeObj.getNodes()[0];
-            if(rootNode && rootNode.isParent && rootNode.isFirstNode){
-                gljSelOprObj.rootNode = rootNode;
-            }
-            gljSelOprObj.buildSheet($('#gljSelSheet')[0]);
-            if(callback){
-                callback();
-            }
-        };
-        let errFunc = function () {
-
-        };
-        CommonAjax.post(url, postData, sucFunc, errFunc);
+    initGljClassTree: function (gljTree) {
+        zTreeHelper.createTree(gljTree, gljSelTreeOprObj.setting, "selGljTree", gljSelOprObj);
+        const rootNode = gljSelOprObj.treeObj.getNodes()[0];
+        if(rootNode && rootNode.isParent && rootNode.isFirstNode){
+            gljSelOprObj.rootNode = rootNode;
+        }
+        gljSelOprObj.buildSheet($('#gljSelSheet')[0]);
     },
     buildSheet: function (container) {
         let me = gljSelOprObj;
@@ -336,4 +305,9 @@ $(document).ready(function () {
             return false;
         }
     });
+    $('#selGlj').on('shown.bs.modal', function () {
+        if (gljSelOprObj.workBook) {
+            gljSelOprObj.workBook.refresh();
+        }
+    });
 });

+ 95 - 0
web/maintain/ration_repository/js/init.js

@@ -0,0 +1,95 @@
+'use strict';
+
+/**
+ *
+ *
+ * @author Zhong
+ * @date 2019/10/30
+ * @version
+ */
+
+const initialization = (() => {
+    function initData() {
+        const rationRepId = +getQueryString('repository');
+        $.bootstrapLoading.start();
+        CommonAjax.post('/rationRepository/api/prepareInitData', { rationRepId }, rstData => {
+            pageOprObj.initPage(rstData.libInfo);
+            rationOprObj.buildSheet($("#rationItemsSheet")[0]);
+            // tabPanel 下有多个Spread时,相互之间不能正确显示。改成一个Spread下多个Sheet。
+            const rdSpread = sheetCommonObj.createSpread($("#rdSpread")[0], 5);
+            rationGLJOprObj.buildSheet(rdSpread.getSheet(0));
+            rationAssistOprObj.buildSheet(rdSpread.getSheet(1));
+            rationCoeOprObj.buildSheet(rdSpread.getSheet(2));
+            rationInstObj.buildSheet(rdSpread.getSheet(3));
+            RationTemplate.buildSheet(rdSpread.getSheet(4));
+
+            const rdSpreadEscSheets = [];
+            rdSpreadEscSheets.push({sheet: rdSpread.getSheet(0), editStarting: rationGLJOprObj.onEditStarting, editEnded: rationGLJOprObj.onCellEditEnd});
+            rdSpreadEscSheets.push({sheet: rdSpread.getSheet(1), editStarting: rationAssistOprObj.onEditStarting, editEnded: rationAssistOprObj.onEditEnded});
+            rdSpreadEscSheets.push({sheet: rdSpread.getSheet(2), editStarting: rationCoeOprObj.onEditStarting, editEnded: rationCoeOprObj.onEditEnded});
+            rdSpreadEscSheets.push({sheet: rdSpread.getSheet(3), editStarting: rationInstObj.onEditStarting, editEnded: rationInstObj.onEditEnded});
+            rdSpreadEscSheets.push({sheet: rdSpread.getSheet(4), editStarting: null, editEnded: RationTemplate.events.onEditEnded});
+            sheetCommonObj.bindEscKey(rdSpread, rdSpreadEscSheets);
+
+            // 初始化定额章节树
+            sectionTreeObj.initSectionTree(rstData.sectionTree);
+            // 初始化人材机类型
+            rationGLJOprObj.initGljDistType(rstData.gljDistTypeList);
+            // 初始化人材机分类树
+            gljSelOprObj.initGljClassTree(rstData.gljTree);
+            // 初始化人材机
+            gljSelOprObj.initGljList(rstData.gljList);
+            // 初始化安装增加费
+            rationInstObj.initInstallation(rstData.installationList);
+            //初始化已使用的定额编码
+            rationOprObj.rationsCodes = rstData.rationsCodes;
+            const lockedSpreads = [
+                sectionTreeObj.workBook,
+                rationOprObj.workBook,
+                rdSpread
+            ];
+            const $range = $(document.body);
+            lockUtil.lockSpreadsAndTools(lockedSpreads, $range, locked);
+
+            $("#linkGLJ").click(function(){
+                rationGLJOprObj.bindRationGljDelOpr();
+                rdSpread.setActiveSheetIndex(0);
+            });
+
+            $("#linkFZDE").click(function(){
+                rationAssistOprObj.bindRationAssDel();
+                rdSpread.setActiveSheetIndex(1);
+            });
+            $("#linkFZTJ").click(function(){
+                rationCoeOprObj.bindRationCoeDel();
+                rdSpread.setActiveSheetIndex(2);
+            });
+            $("#linkAZZJ").click(function(){
+                rationInstObj.bindRationInstDel();
+                rdSpread.setActiveSheetIndex(3);
+            });
+            $("#linkMBGL").click(function(){
+                RationTemplate.bindRationTempDel();
+                rdSpread.setActiveSheetIndex(4);
+            });
+            //解决spreadjs sheet初始化没高度宽度
+            $('#modalCon').width($(window).width()*0.5);
+            $('#gljSelTreeDiv').height($(window).height() - 300);
+            $("#gljSelSheet").height($("#gljSelTreeDiv").height()-21.6);
+            $("#gljSelSheet").width($('#modalCon').width() * 0.63);
+            $(window).resize(function () {
+                $('#modalCon').width($(window).width()*0.5);
+                $('#gljSelTreeDiv').height($(window).height() - 300);
+                $("#gljSelSheet").height($("#gljSelTreeDiv").height()-21.6);
+                $("#gljSelSheet").width($('#modalCon').width()* 0.63);
+            });
+            $.bootstrapLoading.end();
+        }, () => $.bootstrapLoading.end());
+    }
+    
+    $(document).ready(() => {
+        // 初始化编辑
+        explanatoryOprObj.initEditor();
+        initData();
+    });
+})();

+ 28 - 9
web/maintain/ration_repository/js/installation.js

@@ -1,9 +1,15 @@
 /**
  * Created by Zhong on 2018/1/19.
  **/
-
+const locked = lockUtil.getLocked();
 $(document).ready(function () {
     feeItemObj.buildSheet();
+    const lockedSpreads = [
+        feeItemObj.workBook,
+        sectionObj.workBook,
+        feeRuleObj.workBook
+    ];
+    lockUtil.lockSpreads(lockedSpreads, locked);
     $('#sectionTreeModal').on('shown.bs.modal', function (e) {
         batchSectionObj.workBook.refresh();
         //bind confirm btn
@@ -305,6 +311,9 @@ let feeItemObj = {
         }
     },
     feeItemDelOpr: function () {
+        if (locked) {
+            return;
+        }
         let me = this;
         me.workBook.commandManager().register('feeItemDel', function () {
             curDeleteType = me.deleteType;
@@ -450,17 +459,21 @@ let sectionObj = {
                 if(target.hitTestType === 3 && me.isDef(target.row) && me.isDef(target.col)){//在表格内
                     sheet.setActiveCell(target.row, target.col);
                     me.initSelection(me.cache[target.row]);
-                    //控制按钮是否可用
-                    let refDis = false;
-                    if(target.row >= me.cache.length){
-                        refDis = true;
-                    }
                     return {
                         callback: function(){},
                         items: {
-                            "ref": {name: "批量关联至定额", disabled: refDis, icon: "fa-arrow-left", callback: function (key, opt) {
-                                $('#sectionTreeModal').modal('show');
-                            }}
+                            "ref": {
+                                name: "批量关联至定额",
+                                disabled: function () {
+                                    const inValidCell = !commonUtil.isDef(target.row) || !commonUtil.isDef(target.col);
+                                    const inValidData = target.row >= me.cache.length;
+                                    return locked || inValidCell || inValidData;
+                                },
+                                icon: "fa-arrow-left",
+                                callback: function (key, opt) {
+                                    $('#sectionTreeModal').modal('show');
+                                }
+                            }
                         }
                     };
                 }
@@ -565,6 +578,9 @@ let sectionObj = {
         }
     },
     sectionDelOpr: function () {
+        if (locked) {
+            return;
+        }
         let me = this;
         me.workBook.commandManager().register('sectionDel', function () {
             curDeleteType = me.deleteType;
@@ -1013,6 +1029,9 @@ let feeRuleObj = {
         }
     },
     feeRuleDelOpr: function () {
+        if (locked) {
+            return;
+        }
         let me = feeRuleObj, se = sectionObj;
         me.workBook.commandManager().register('feeRuleDel', function () {
             me.toUpdate = false;

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

@@ -121,7 +121,10 @@ $(function () {
             $('#reCalcConfirm').removeClass('disabled')
         });
     });
-
+    // 锁定、解锁
+    $('#showArea').on('click', '.lock', function () {
+        lockUtil.handleLockClick($(this));
+    });
     getCompilationList(function (data) {
         compilationsArr = data.compilation;
     });

+ 26 - 48
web/maintain/ration_repository/js/ration.js

@@ -92,7 +92,6 @@ let rationOprObj = {
         let me = rationOprObj;
         me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30);
         sheetCommonObj.bindEscKey(me.workBook, [{sheet: me.workBook.getSheet(0), editStarting: me.onCellEditStart, editEnded: me.onCellEditEnd}]);
-        me.getRationsCodes(rationRepId);
         me.onContextmenuOpr();
         me.rationDelOpr();
         me.setCombo(me.workBook.getSheet(0), 'dynamic');
@@ -253,41 +252,36 @@ let rationOprObj = {
                 //控制允许右键菜单在哪个位置出现
                 let target = SheetDataHelper.safeRightClickSelection($triggerElement, e, me.workBook);
                 let sheet = me.workBook.getSheet(0);
-                let  delDis = false;
                 let cacheSection = me.getCache();
                 let ration = cacheSection[target.row];
                 if(target.hitTestType === 3){//在表格内&& typeof target.row !== 'undefined' && typeof target.col !== 'undefined'
                     if(typeof target.row !== 'undefined'){
                         //控制按钮是否可用
                         sheet.setActiveCell(target.row, target.col);
-                        if(!cacheSection ||target.row >= cacheSection.length){//右键定位在有数据的行,删除键才显示可用
-                            delDis = true;
-                        }
-                        else{//有数据
-                            if(typeof target.col === 'undefined'){//定位不在表格内
-                                delDis = true;
-                            }
-                        }
-                    }
-                    else{
-                        delDis = true;
                     }
                     return {
                         callback: function(){},
                         items: {
-                            "delete": {name: "删除", disabled: delDis, icon: "fa-remove", callback: function (key, opt) {
-
-                                let removeInfo = `确定要删除定额 “${ration.code}” 及其下的所有数据吗?`;
-                                $('#delRationAlert').find('.modal-body h5').text(removeInfo);
-                                $('#delRationAlert').modal('show');
-                                $('#delRationConfirm').bind('click', function () {
-                                    me.rationsCodes.splice(me.rationsCodes.indexOf(ration.code.toString()), 1);
-                                    me.mixDel = 1;
-                                    me.mixUpdateRequest([], [], [ration.ID]);
-                                    $('#delRationConfirm').unbind('click');
-                                    $('#delRationAlert').modal('hide');
-                                });
-                            }}
+                            "delete": {
+                                name: "删除",
+                                disabled: function () {
+                                    const inValidCell = !commonUtil.isDef(target.row) || !commonUtil.isDef(target.col);
+                                    const inValidData = !cacheSection ||target.row >= cacheSection.length;
+                                    return locked || inValidCell || inValidData;
+                                },
+                                icon: "fa-remove",
+                                callback: function (key, opt) {
+                                    let removeInfo = `确定要删除定额 “${ration.code}” 及其下的所有数据吗?`;
+                                    $('#delRationAlert').find('.modal-body h5').text(removeInfo);
+                                    $('#delRationAlert').modal('show');
+                                    $('#delRationConfirm').bind('click', function () {
+                                        me.rationsCodes.splice(me.rationsCodes.indexOf(ration.code.toString()), 1);
+                                        me.mixDel = 1;
+                                        me.mixUpdateRequest([], [], [ration.ID]);
+                                        $('#delRationConfirm').unbind('click');
+                                        $('#delRationAlert').modal('hide');
+                                    });
+                                }}
                         }
                     };
                 }
@@ -298,6 +292,9 @@ let rationOprObj = {
         });
     },
     rationDelOpr: function () {
+        if (locked) {
+            return;
+        }
         let me = rationOprObj;
         me.workBook.commandManager().register('rationDelete', function () {
             let rationSheet = me.workBook.getActiveSheet();
@@ -612,27 +609,6 @@ let rationOprObj = {
         obj.machinePrice = 0;
         obj.basePrice = 0;
     },
-    isValidUnit: function (rationObj, validUnits) {
-        let rst = true;
-        if(typeof rationObj.unit !== 'undefined' && rationObj.unit && validUnits.indexOf(rationObj.unit) === -1){//无效
-            rst = false;
-        }
-        return rst;
-    },
-    getRationsCodes: function (repId) {
-        let me = rationOprObj;
-        $.ajax({
-            type: 'post',
-            url: 'api/getRationsCodes',
-            data: {data: JSON.stringify({repId: repId})},
-            dataType: 'json',
-            success: function (result) {
-                if(!result.error){
-                    me.rationsCodes = result.data;
-                }
-            }
-        })
-    },
     mixUpdateRequest: function(updateArr, addArr, removeIds, callback) {
         let me = rationOprObj;
         me.saveInString(updateArr);
@@ -709,7 +685,9 @@ let rationOprObj = {
                         annotationOprObj.rationAnnotationOpr(me.currentRations["_SEC_ID_" + sectionID]);
                         me.showRationItems(sectionID);
                     }
-                    sectionTreeObj.removeBtn.removeClass('disabled');
+                    if (!locked) {
+                        sectionTreeObj.removeBtn.removeClass('disabled');
+                    }
                     if(callback) {
                         callback(result.data);
                     }

+ 6 - 1
web/maintain/ration_repository/js/ration_assist.js

@@ -146,6 +146,9 @@ var rationAssistOprObj = {
         };
     },
     bindRationAssDel: function () {
+        if (locked) {
+            return;
+        }
         let me = rationAssistOprObj;
         let workBook = me.sheet.getParent();
         workBook.commandManager().register('rationAssDel', function () {
@@ -180,7 +183,9 @@ var rationAssistOprObj = {
         me.ration = ration;
 
         sheetCommonObj.cleanData(me.sheet, me.setting, -1);
-        sheetCommonObj.unShieldAllCells(me.sheet);
+        if (!locked) {
+            sheetCommonObj.unShieldAllCells(me.sheet);
+        }
 
         if (ration == undefined || ration.rationAssList == undefined ||
             ration.rationAssList.length == 0){

+ 3 - 0
web/maintain/ration_repository/js/ration_coe.js

@@ -260,6 +260,9 @@ var rationCoeOprObj = {
     },
 
     bindRationCoeDel: function () {
+        if (locked) {
+            return;
+        }
         let me = rationCoeOprObj;
         let workBook = me.sheet.getParent();
         workBook.commandManager().register('rationCoeDel', function () {

+ 227 - 268
web/maintain/ration_repository/js/ration_glj.js

@@ -17,7 +17,8 @@ var rationGLJOprObj = {
             {headerName:"单位",headerWidth:60,dataCode:"unit", dataType: "String", hAlign: "center", vAlign: "center"},
             {headerName:"定额价",headerWidth:80, dataCode:"basePrice", dataType: "Number", formatter:"0.00",  precision: 2},
             {headerName:"定额消耗",headerWidth:80, dataCode:"consumeAmt", dataType: "Number", formatter: "0.000", precision: 3},
-            {headerName:"类型",headerWidth:70,dataCode:"gljType", dataType: "String", hAlign: "center", vAlign: "center"}
+            {headerName:"类型",headerWidth:70,dataCode:"gljType", dataType: "String", hAlign: "center", vAlign: "center"},
+            {headerName:"配合比",headerWidth:70,dataCode:"proportion", dataType: "Number", formatter:"0.00",  precision: 2}
         ],
         view:{
             comboBox:[],
@@ -25,7 +26,6 @@ var rationGLJOprObj = {
         }
     },
     getDistTypeTree: function (gljDistType) {
-        let me = this;
         let distType;
         let distTypeTree = {
             prefix : 'gljDistType',
@@ -61,66 +61,41 @@ var rationGLJOprObj = {
         });
         return distTypeTree;
     },
-    getGljDistType: function (callback) {
-        let me = this;
-        $.ajax({
-            type: 'post',
-            url: "api/getGljDistType",
-            dataType: 'json',
-            success: function (result) {
-                if(!result.error && callback){
-                    me.distTypeTree = me.getDistTypeTree(result.data);
-                    callback();
-                }
-            }
-        })
+    initGljDistType: function (gljDistTypeList) {
+        this.distTypeTree = this.getDistTypeTree(gljDistTypeList);
+
     },
     buildSheet: function(sheet) {
-        var me = this;
-        me.sheet = sheet;
-        me.getGljDistType(function () {
-            sheetCommonObj.initSheet(me.sheet, me.setting, 30);
-            me.onContextmenuOpr();
-            me.bindRationGljDelOpr();
-            me.sheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
-            me.sheet.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
-            me.sheet.bind(GC.Spread.Sheets.Events.EditStarting, me.onEditStarting);
-            me.sheet.bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
-        });
+        this.sheet = sheet;
+        sheetCommonObj.initSheet(this.sheet, this.setting, 30);
+        this.onContextmenuOpr();
+        this.bindRationGljDelOpr();
+        this.sheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, this.onClipboardPasting);
+        this.sheet.bind(GC.Spread.Sheets.Events.ClipboardPasted, this.onClipboardPasted);
+        this.sheet.bind(GC.Spread.Sheets.Events.EditStarting, this.onEditStarting);
+        this.sheet.bind(GC.Spread.Sheets.Events.EditEnded, this.onCellEditEnd);
     },
     bindRationGljDelOpr: function () {
-        let me = rationGLJOprObj, spreadBook = me.sheet.getParent();
+        if (locked) {
+            return;
+        }
+        const me = rationGLJOprObj;
+        const spreadBook = me.sheet.getParent();
         spreadBook.commandManager().register('rationGljDelete', function () {
-            let sels = me.sheet.getSelections(), lockCols = me.setting.view.lockColumns;
-            let cacheSection = me.cache["_GLJ_" + me.currentRationItem.ID], isUpdate = false;
-            if(sels.length > 0){
-                for(let sel = 0; sel < sels.length; sel++){
-                    if(sels[sel].colCount === me.setting.header.length){
-                        if(cacheSection && sels[sel].row < cacheSection.length){
-                            isUpdate = true;
-                            cacheSection.splice(sels[sel].row, sels[sel].rowCount);
-                        }
-                    }
-                    else{
-                         if(sels[sel].col !== 0 && sels[sel].col !== 5 && !(sels[sel].col === 1 && sels.col + sels[sel].colCount -1 === 3)){
-                            if(cacheSection){
-                                for(let i = sels[sel].row === -1 ? 1 : 0; i < sels[sel].rowCount; i++){
-                                    if(sels[sel].row + i < cacheSection.length){
-                                        for(let col = sels[sel].col; col <= sels[sel].col + sels[sel].colCount - 1; col++){
-                                            if(lockCols.indexOf(col) === -1){
-                                                isUpdate = true;
-                                                cacheSection[sels[sel].row + i][me.setting.header[col].dataCode] = 0;
-                                                me.sheet.setValue(sels[sel].row + i, col, 0.00);
-                                            }
-                                        }
-                                    }
-                                }
-                            }
-                        }
-                    }
+            const cacheSection = me.cache["_GLJ_" + me.currentRationItem.ID];
+            const sels = me.sheet.getSelections();
+            if (!cacheSection || !sels.length) {
+                return;
+            }
+            let isUpdate = false;
+            for (const sel of sels) {
+                const deleteRow = sel.colCount === me.setting.header.length && sel.row < cacheSection.length;
+                if (deleteRow) {
+                    isUpdate = true;
+                    cacheSection.splice(sel.row, sel.rowCount);
                 }
             }
-            if(isUpdate){
+            if (isUpdate) {
                 me.updateRationItem(function () {
                     me.sheet.getParent().focus(true);
                 });
@@ -132,155 +107,123 @@ var rationGLJOprObj = {
         spreadBook.commandManager().setShortcutKey('rationGljDelete', GC.Spread.Commands.Key.del, false, false, false, false);
     },
     onClipboardPasting: function(sender, args) {
-        var me = rationGLJOprObj;
-        let rationSection = rationOprObj.getCache();
-        let rationRow = rationOprObj.workBook.getSheet(0).getSelections()[0].row;
-        me.currentRationItem = rationRow < rationSection.length ? rationSection[rationRow] : null;
+        const me = rationGLJOprObj;
+        const rationCache = rationOprObj.getCache();
+        const rationRow = rationOprObj.workBook.getSheet(0).getSelections()[0].row;
+        me.currentRationItem = rationRow < rationCache.length ? rationCache[rationRow] : null;
         if(me.currentRationItem && typeof me.cache["_GLJ_" + me.currentRationItem.ID] === 'undefined'){
             me.cache["_GLJ_" + me.currentRationItem.ID] = [];
         }
-        if (!(args.cellRange.col === 0 || args.cellRange.col === 5) || !(me.currentRationItem)) {
+        const field = me.setting.header[args.cellRange.col].dataCode;
+        const canPasteFields = ['code', 'consumeAmt', 'proportion'];
+        if (!me.currentRationItem || !(canPasteFields.includes(field) && args.cellRange.colCount === 1)) {
             args.cancel = true;
         }
     },
     onClipboardPasted: function(e, info) {
-        var me = rationGLJOprObj, repId = pageOprObj.rationLibId;
+        const me = rationGLJOprObj;
         me.tempCacheArr = [];
-        if (repId) {
-            let gljLibId = pageOprObj.gljLibId;
-            if(gljLibId){
-                if (info.cellRange.col == 0) {
-                    let cacheArr = me.cache["_GLJ_" + me.currentRationItem.ID];
-                    var tmpCodes = sheetCommonObj.analyzePasteData({header:[{dataCode: "code"}] }, info);
-                    var codes = [];
-                    for (var i = 0; i < tmpCodes.length; i++) {
-                        let rowIdx = info.cellRange.row + i;
-                        if(rowIdx < cacheArr.length){//更新
-                            me.tempCacheArr.push({org: cacheArr[rowIdx], newCode: tmpCodes[i].code});
-                            cacheArr.splice(rowIdx--, 1);
-                        }
-                        codes.push(tmpCodes[i].code);
-                    }
-                    me.addGljItems(codes, gljLibId, info.cellRange);
-                } else {
-                    //修改用量
-                    if(me.cache["_GLJ_" + me.currentRationItem.ID] && info.cellRange.row < me.cache["_GLJ_" + me.currentRationItem.ID].length){
-                        let tempConsumes = sheetCommonObj.analyzePasteData(me.setting, info);
-                        let maxCount = info.cellRange.row + info.cellRange.rowCount -1 > me.cache["_GLJ_" + me.currentRationItem.ID].length -1 ?
-                        me.cache["_GLJ_" + me.currentRationItem.ID].length - info.cellRange.row : info.cellRange.rowCount;
-                        for(let i = 0; i < maxCount; i++){
-                            let roundCons = scMathUtil.roundTo(tempConsumes[i].consumeAmt, -3);
-                            me.cache["_GLJ_" + me.currentRationItem.ID][info.cellRange.row + i].consumeAmt = roundCons;
-                        }
-                        me.updateRationItem(function () {
-                            me.sheet.getParent().focus(true);
-                        });
-                        if(info.cellRange.row + info.cellRange.rowCount -1 >= me.cache["_GLJ_" + me.currentRationItem.ID].length -1){
-                            me.sheet.suspendPaint();
-                            for(let rowIdx = me.cache["_GLJ_" + me.currentRationItem.ID].length; rowIdx <= info.cellRange.row + info.cellRange.rowCount -1; rowIdx++){
-                                me.sheet.setValue(rowIdx, info.cellRange.col, '');
-                            }
-                            me.sheet.resumePaint();
-                        }
-                    }
-                    else if(info.cellRange.row >= me.cache["_GLJ_" + me.currentRationItem.ID].length){
-                        me.sheet.suspendPaint();
-                        for(let rowIdx = info.cellRange.row; rowIdx <= info.cellRange.row + info.cellRange.rowCount -1; rowIdx ++){
-                            me.sheet.setValue(rowIdx, info.cellRange.col, '');
-                        }
-                        me.sheet.resumePaint();
-                    }
+        const gljCache = me.cache["_GLJ_" + me.currentRationItem.ID];
+        const field = me.setting.header[info.cellRange.col].dataCode;
+        if (field === 'code') {
+            const pasteList = sheetCommonObj.analyzePasteData({header:[{dataCode: "code"}] }, info);
+            const codes = [];
+            for (let i = 0; i < pasteList.length; i++) {
+                let rowIdx = info.cellRange.row + i;
+                if(rowIdx < gljCache.length){//更新
+                    me.tempCacheArr.push({org: gljCache[rowIdx], newCode: pasteList[i].code});
+                    gljCache.splice(rowIdx--, 1);
+                }
+                codes.push(pasteList[i].code);
+            }
+            me.addGljItems(codes, pageOprObj.gljLibId, info.cellRange);
+        } else if (gljCache && info.cellRange.row < gljCache.length) {
+            const pasteList = sheetCommonObj.analyzePasteData(me.setting, info);
+            const maxCount = info.cellRange.row + info.cellRange.rowCount -1 > gljCache.length -1 ?
+                gljCache.length - info.cellRange.row : info.cellRange.rowCount;
+            const precision = me.setting.header[info.cellRange.col].precision;
+            for (let i = 0; i < maxCount; i++) {
+                let roundCons = scMathUtil.roundTo(pasteList[i][field], -precision);
+                gljCache[info.cellRange.row + i][field] = roundCons;
+            }
+            me.updateRationItem(function () {
+                me.sheet.getParent().focus(true);
+            });
+            if (info.cellRange.row + info.cellRange.rowCount -1 >= gljCache.length -1) {
+                me.sheet.suspendPaint();
+                for(let rowIdx = gljCache.length; rowIdx <= info.cellRange.row + info.cellRange.rowCount -1; rowIdx++){
+                    me.sheet.setValue(rowIdx, info.cellRange.col, '');
                 }
+                me.sheet.resumePaint();
+            }
+        } else if (info.cellRange.row >= gljCache.length) {
+            me.sheet.suspendPaint();
+            for(let rowIdx = info.cellRange.row; rowIdx <= info.cellRange.row + info.cellRange.rowCount -1; rowIdx ++){
+                me.sheet.setValue(rowIdx, info.cellRange.col, '');
             }
+            me.sheet.resumePaint();
         }
     },
     onEditStarting: function (sender, args) {
-        let me = rationGLJOprObj;
-        let rationSection = rationOprObj.getCache();
-        let rationRow = rationOprObj.workBook.getSheet(0).getSelections()[0].row;
+        const me = rationGLJOprObj;
+        const rationSection = rationOprObj.getCache();
+        const rationRow = rationOprObj.workBook.getSheet(0).getSelections()[0].row;
         me.currentRationItem = rationRow < rationSection.length ? rationSection[rationRow] : null;
         if(me.currentRationItem && typeof me.cache["_GLJ_" + me.currentRationItem.ID] === 'undefined'){
             me.cache["_GLJ_" + me.currentRationItem.ID] = [];
         }
-        if(!me.currentRationItem){
-            args.cancel = true;
+        const isEmptyRation = !me.currentRationItem;
+        if (isEmptyRation) {
+            return args.cancel = true;
         }
-        else {
-            if(args.col !== 0 && args.col !== 5 || args.col === 5 && args.row >= me.cache["_GLJ_" + me.currentRationItem.ID].length){
-                args.cancel = true;
-            }
+        const canEditFields = ['code', 'consumeAmt', 'proportion'];
+        const emptyGLJCanEditFields = ['code'];
+        const isEmptyGLJ = args.row >= me.cache["_GLJ_" + me.currentRationItem.ID].length;
+        const editingField = me.setting.header[args.col].dataCode;
+        const isValidField =  isEmptyGLJ && emptyGLJCanEditFields.includes(editingField) || !isEmptyGLJ && canEditFields.includes(editingField);
+        if (!isValidField) {
+            return args.cancel = true;
         }
     },
-    onCellEditEnd: function(sender, args){
-        var me = rationGLJOprObj;
-        if(me.currentRationItem) {
-            var cacheArr = me.cache["_GLJ_" + me.currentRationItem.ID];
-            me.tempCacheArr = [];
-            if (args.col != 0) {
-                if (args.row < cacheArr.length) {
-                    var editGlj = cacheArr[args.row];
-                    if (editGlj["consumeAmt"] != args.editingText) {
-                        let parseNum = parseFloat(args.editingText);
-                        if (isNaN(parseFloat(args.editingText))) {
-                            $('#alertModalBtn').click();
-                            $('#alertText').text("定额消耗只能输入数值!");
-                            $('#alertModalCls').click(function () {
-                                args.sheet.setValue(args.row, args.col, editGlj['consumeAmt']);
-                            });
-                            $('#alertModalCof').click(function () {
-                                args.sheet.setValue(args.row, args.col, editGlj['consumeAmt']);
-                            })
-                        }
-                        else {
-                            args.sheet.setValue(args.row, args.col, parseNum);
-                            let roundNum = scMathUtil.roundTo(parseNum, -3);
-                            editGlj["consumeAmt"] = roundNum;
-                            me.updateRationItem(function () {
-                                me.sheet.getParent().focus(true);
-                            });
-                        }
-                    }
-                }
+    onCellEditEnd: function(sender, args) {
+        const me = rationGLJOprObj;
+        me.tempCacheArr = [];
+        const cacheArr = me.cache["_GLJ_" + me.currentRationItem.ID];
+        const editingField = me.setting.header[args.col].dataCode;
+        const trimText = args.editingText ? args.editingText.trim() : '';
+        const curGLJ = cacheArr[args.row];
+        const originText = curGLJ  && !commonUtil.isEmptyVal(curGLJ[editingField]) ? String(curGLJ[editingField]) : '';
+        if (!trimText || trimText === originText) {
+            args.sheet.setValue(args.row, args.col, originText);
+            return;
+        }
+        if (editingField === 'code') {
+            const matchGLJ = cacheArr.find((item, index) => item.code === trimText && index !== args.row);
+            if (matchGLJ) {
+                alert("该人材机已存在!");
+                args.sheet.setValue(args.row, args.col, originText);
+                return;
+            }
+            if (args.row < cacheArr.length) { // 替换人材机
+                me.tempCacheArr.push({org: cacheArr[args.row], newCode: args.editingText.toString().trim()});
+                cacheArr.splice(args.row, 1);
+            }
+            me.addGljItems([trimText], pageOprObj.gljLibId)
+        } else {
+            const fieldName = me.setting.header[args.col].headerName;
+            if (isNaN(trimText)) {
+                $('#alertText').text(`${fieldName}只能输入数值。`);
+                $('#alertModal').modal('show');
+                args.sheet.setValue(args.row, args.col, originText);
             } else {
-                if (args.editingText && args.editingText.toString().trim().length !== 0) {
-                    let isExist = false;
-                    for (let i = 0, len = cacheArr.length; i < len; i++) {
-                        if (cacheArr[i].code === args.editingText && i !== args.row) {
-                            isExist = true;
-                            break;
-                        }
-                    }
-                    if (isExist) {
-                        alert("该人材机已存在!");
-                        args.sheet.setValue(args.row, args.col, typeof cacheArr[args.row] !== 'undefined' ? cacheArr[args.row].code + '' : '');
-                    }
-                    else {
-                        if (args.row < cacheArr.length && args.editingText !== cacheArr[args.row].code) {//更新
-                            me.tempCacheArr.push({org: cacheArr[args.row], newCode: args.editingText.toString().trim()});
-                            cacheArr.splice(args.row, 1);
-                            let gljLibID = pageOprObj.gljLibId;
-                            let codes = [];
-                            codes.push(args.editingText.toString().trim());
-                            me.addGljItems(codes, gljLibID, args);
-                        }
-                        else if (args.row >= cacheArr.length) {//新增
-                            let gljLibID = pageOprObj.gljLibId;
-                            if (gljLibID) {
-                                var codes = [];
-                                codes.push(args.editingText.toString().trim());
-                                me.addGljItems(codes, gljLibID, args);
-                            }
-                        }
-                    }
-                }
-                else {
-                    args.sheet.setValue(args.row, args.col, args.row < cacheArr.length ? cacheArr[args.row].code : '');
-                }
+                const precision = me.setting.header[args.col].precision;
+                const roundText = scMathUtil.roundTo(trimText, -precision);
+                curGLJ[editingField] = roundText;
+                me.updateRationItem(function () {
+                    me.sheet.getParent().focus(true);
+                });
             }
         }
-        else {
-            args.sheet.setValue(args.row, args.col, '');
-        }
     },
     onContextmenuOpr: function () {//右键菜单
         let me = this;
@@ -291,57 +234,58 @@ var rationGLJOprObj = {
                 //控制允许右键菜单在哪个位置出现
                 let target = SheetDataHelper.safeRightClickSelection($triggerElement, e, me.sheet.getParent());
                 let sheet = me.sheet;
-                let addDis = false, delDis = false;
-                let rationGlj = [];
                 if(me.sheet.getParent().getActiveSheetIndex() === 0 && target.hitTestType === 3){//在表格内&& typeof target.row !== 'undefined' && typeof target.col !== 'undefined'
                     //rationGlj表
                     if(typeof target.row !== 'undefined'){
                         //控制按钮是否可用
                         sheet.setActiveCell(target.row, target.col);
-                        console.log(me.currentRationItem);
-                        if(me.currentRationItem){
-                            rationGlj =  me.cache['_GLJ_' + me.currentRationItem.ID];
-                            if(!rationGlj ||target.row >= rationGlj.length){//右键定位在有数据的行,删除键才显示可用
-                                delDis = true;
-                            }
-                            else{//有数据
-                                if(typeof target.col === 'undefined'){//定位不在表格内
-                                    delDis = true;
-                                }
-                            }
-                        }
-                        else{
-                            addDis = true;
-                            delDis = true;
-                        }
-                    }
-                    else{
-                        addDis = true;
-                        delDis = true;
                     }
                     return {
                         callback: function(){},
                         items: {
-                            "add": {name: "添加人材机", disabled: addDis, icon: "fa-plus", callback: function (key, opt) {
-                                //默认radio所有工料机
-                                gljSelOprObj.initRadio();
-                                gljSelOprObj.gljCurTypeId = null;
-                                //默认点击树根节点
-                                if(gljSelOprObj.rootNode){
-                                    gljSelOprObj.treeObj.selectNode(gljSelOprObj.rootNode);
-                                    gljSelTreeOprObj.setting.callback.onClick(null, 'componentTree', gljSelOprObj.rootNode);
-                                }
-                                //弹出窗口
-                                $('#selGlj').modal('show');
-                            }},
-                            "delete": {name: "删除人材机", disabled: delDis, icon: "fa-remove", callback: function (key, opt) {
-                                rationGlj.splice(target.row, 1);
-                                me.updateRationItem(function(){
-                                    me.sheet.getParent().focus();
-                                });
-                                sheetCommonObj.cleanData(me.sheet, me.setting, -1);
-                                me.showGljItems(me.currentRationItem.ID);
-                            }},
+                            "add": {
+                                name: "添加人材机",
+                                disabled: function () {
+                                    const inValidCell = !commonUtil.isDef(target.row) || !commonUtil.isDef(target.col);
+                                    if (locked || inValidCell || !me.currentRationItem) {
+                                        return true;
+                                    }
+                                    return false;
+                                },
+                                icon: "fa-plus",
+                                callback: function (key, opt) {
+                                    //默认radio所有工料机
+                                    gljSelOprObj.initRadio();
+                                    gljSelOprObj.gljCurTypeId = null;
+                                    //默认点击树根节点
+                                    if(gljSelOprObj.rootNode){
+                                        gljSelOprObj.treeObj.selectNode(gljSelOprObj.rootNode);
+                                        gljSelTreeOprObj.setting.callback.onClick(null, 'componentTree', gljSelOprObj.rootNode);
+                                    }
+                                    //弹出窗口
+                                    $('#selGlj').modal('show');
+                                }},
+                            "delete": {
+                                name: "删除人材机",
+                                disabled: function () {
+                                    const inValidCell = !commonUtil.isDef(target.row) || !commonUtil.isDef(target.col);
+                                    const rationGlj =  me.cache['_GLJ_' + me.currentRationItem.ID];
+                                    const inValidData = !rationGlj || target.row >= rationGlj.length;
+                                    if (locked || inValidCell || !me.currentRationItem || inValidData) {
+                                        return true;
+                                    }
+                                    return false;
+                                },
+                                icon: "fa-remove",
+                                callback: function (key, opt) {
+                                    const rationGlj =  me.cache['_GLJ_' + me.currentRationItem.ID];
+                                    rationGlj.splice(target.row, 1);
+                                    me.updateRationItem(function(){
+                                        me.sheet.getParent().focus();
+                                    });
+                                    sheetCommonObj.cleanData(me.sheet, me.setting, -1);
+                                    me.showGljItems(me.currentRationItem.ID);
+                                }},
                         }
                     };
                 }
@@ -349,55 +293,65 @@ var rationGLJOprObj = {
                 else if(me.sheet.getParent().getActiveSheetIndex() === 2 && target.hitTestType === 3 && typeof target.row !== 'undefined' && typeof target.col !== 'undefined'){
                     let currentCache = raCoe.curRation && raCoe.isDef(raCoe.cache["_Coe_" + raCoe.curRation.ID])  ? raCoe.cache["_Coe_" + raCoe.curRation.ID] : [];
                     sheet.setActiveCell(target.row, target.col);
-                    //控制按钮是否可用
-                    let upDis = false,
-                        downDis = false,
-                        refDis = false;
-                    if(target.row >= currentCache.length){
-                        upDis = true;
-                        downDis = true;
-                        refDis = true;
-                    }
-                    else {
-                        if(!raCoe.isDef(currentCache[target.row - 1])){
-                            upDis = true;
-                        }
-                        if(!raCoe.isDef(currentCache[target.row + 1])){
-                            downDis = true;
-                        }
-                    }
                     return {
                         callback: function(){},
                         items: {
-                            "upMove": {name: "上移", disabled: upDis, icon: "fa-arrow-up", callback: function (key, opt) {
-                                raCoe.upMove(currentCache[target.row], currentCache[target.row - 1], {row: target.row - 1, col: target.col});
-                            }},
-                            "downMove": {name: "下移", disabled: downDis, icon: "fa-arrow-down", callback: function (key, opt) {
-                                raCoe.downMove(currentCache[target.row], currentCache[target.row + 1], {row: target.row + 1, col: target.col});
-                            }},
-                            "ref": {name: "添加到本节其他定额", disabled: refDis, icon: "fa-arrow-left", callback: function (key, opt) {
-                                raCoe.updateSectionRation(rationOprObj.currentRations["_SEC_ID_" + rationOprObj.currentSectionId], currentCache[target.row], function (updateArr) {
-                                    for(let i = 0, len = updateArr.length; i < len; i++){
-                                        let ration = updateArr[i];
-                                        let rationCoeList = updateArr[i].rationCoeList;
-                                        let newNo = 1;
-                                        for(let j = 0, jLen = rationCoeList.length; j < jLen; j++){
-                                            if(rationCoeList[j].no >= newNo){
-                                                newNo = rationCoeList[j].no + 1;
+                            "upMove": {
+                                name: "上移",
+                                disabled: function () {
+                                    const inValidCell = !commonUtil.isDef(target.row) || !commonUtil.isDef(target.col);
+                                    const inValidData = target.row >= currentCache.length || !raCoe.isDef(currentCache[target.row - 1]);
+                                    return locked || inValidCell || inValidData
+                                },
+                                icon: "fa-arrow-up",
+                                callback: function (key, opt) {
+                                    raCoe.upMove(currentCache[target.row], currentCache[target.row - 1], {row: target.row - 1, col: target.col});
+                                }
+                            },
+                            "downMove": {
+                                name: "下移",
+                                disabled: function () {
+                                    const inValidCell = !commonUtil.isDef(target.row) || !commonUtil.isDef(target.col);
+                                    const inValidData = target.row >= currentCache.length || !raCoe.isDef(currentCache[target.row + 1]);
+                                    return locked || inValidCell || inValidData;
+                                },
+                                icon: "fa-arrow-down",
+                                callback: function (key, opt) {
+                                    raCoe.downMove(currentCache[target.row], currentCache[target.row + 1], {row: target.row + 1, col: target.col});
+                                }
+                            },
+                            "ref": {
+                                name: "添加到本节其他定额",
+                                disabled: function () {
+                                    const inValidCell = !commonUtil.isDef(target.row) || !commonUtil.isDef(target.col);
+                                    const inValidData = target.row >= currentCache.length;
+                                    return locked || inValidCell || inValidData;
+                                },
+                                icon: "fa-arrow-left",
+                                callback: function (key, opt) {
+                                    raCoe.updateSectionRation(rationOprObj.currentRations["_SEC_ID_" + rationOprObj.currentSectionId], currentCache[target.row], function (updateArr) {
+                                        for(let i = 0, len = updateArr.length; i < len; i++){
+                                            let ration = updateArr[i];
+                                            let rationCoeList = updateArr[i].rationCoeList;
+                                            let newNo = 1;
+                                            for(let j = 0, jLen = rationCoeList.length; j < jLen; j++){
+                                                if(rationCoeList[j].no >= newNo){
+                                                    newNo = rationCoeList[j].no + 1;
+                                                }
                                             }
-                                        }
-                                        let theCache = raCoe.cache["_Coe_" + ration.ID];
-                                        if(theCache !== undefined && theCache !== null){
-                                            let newCoe = {};
-                                            for(let attr in currentCache[target.row]){
-                                                newCoe[attr] = currentCache[target.row][attr];
+                                            let theCache = raCoe.cache["_Coe_" + ration.ID];
+                                            if(theCache !== undefined && theCache !== null){
+                                                let newCoe = {};
+                                                for(let attr in currentCache[target.row]){
+                                                    newCoe[attr] = currentCache[target.row][attr];
+                                                }
+                                                newCoe.no = newNo;
+                                                theCache.push(newCoe);
                                             }
-                                            newCoe.no = newNo;
-                                            theCache.push(newCoe);
                                         }
-                                    }
-                                });
-                            }}
+                                    });
+                                }
+                            }
                         }
                     };
                 }
@@ -423,7 +377,7 @@ var rationGLJOprObj = {
         }
         return rst;
     },
-    addGljItems: function(codes, repId, args) {
+    addGljItems: function(codes, repId) {
         var me = this;
         $.ajax({
             type:"POST",
@@ -547,7 +501,11 @@ var rationGLJOprObj = {
         if (me.currentRationItem && me.cache["_GLJ_" + me.currentRationItem.ID]) {
             var cacheArr = me.cache["_GLJ_" + me.currentRationItem.ID];
             for (var i = 0; i < cacheArr.length; i++) {
-                rst.push({gljId: cacheArr[i].gljId, consumeAmt: cacheArr[i].consumeAmt, proportion: 0});
+                rst.push({
+                    gljId: cacheArr[i].gljId,
+                    consumeAmt: cacheArr[i].consumeAmt,
+                    proportion: cacheArr[i].proportion
+                });
             }
         }
         return rst;
@@ -557,6 +515,7 @@ var rationGLJOprObj = {
         var rst = {};
         rst.gljId = rItem.gljId;
         rst.consumeAmt = rItem.consumeAmt;
+        rst.proportion = rItem.proportion;
         rst.code = repGlj.code;
         rst.name = repGlj.name;
         rst.specs = repGlj.specs;

+ 14 - 17
web/maintain/ration_repository/js/ration_installation.js

@@ -45,23 +45,17 @@ let rationInstObj = {
     isDef: function (v) {
         return v !== undefined && v !== null;
     },
-    getInstallation: function (rationRepId, callback) {
-        let me = this;
-        CommonAjax.post('/rationRepository/api/getInstallation', {rationRepId: rationRepId}, function (rstData) {
-            //建立name - ID 映射, ID - name 映射
-            me.feeItem = {};
-            me.IDMapping = {feeItem: {}, section: {}};
-            for(let feeItem of rstData){
-                me.feeItem[feeItem.feeItem] = {ID: feeItem.ID, section: {}};
-                me.IDMapping['feeItem'][feeItem.ID] = feeItem.feeItem;
-                for(let section of feeItem.section){
-                    me.feeItem[feeItem.feeItem]['section'][section.name] = section.ID;
-                    me.IDMapping['section'][section.ID] = section.name;
-                }
-            }
-            if(callback){
-                callback(rstData);
-            }
+    initInstallation: function (installationList) {
+        //建立name - ID 映射, ID - name 映射
+        this.feeItem = {};
+        this.IDMapping = {feeItem: {}, section: {}};
+        installationList.forEach(item => {
+            this.feeItem[item.feeItem] = {ID: item.ID, section: {}};
+            this.IDMapping.feeItem[item.ID] = item.feeItem;
+            item.section.forEach(section => {
+                this.feeItem[item.feeItem].section[section.name] = section.ID;
+                this.IDMapping.section[section.ID] = section.name;
+            });
         });
     },
     getFeeItemCombo: function () {
@@ -219,6 +213,9 @@ let rationInstObj = {
         return obj;
     },
     bindRationInstDel: function () {
+        if (locked) {
+            return;
+        }
         let me = this;
         let workBook = me.sheet.getParent();
         workBook.commandManager().register('rationInstDel', function () {

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

@@ -142,7 +142,7 @@ const RationTemplate = (function () {
     //重新绑定del建
     //@return {void}
     function bindRationTempDel() {
-        if (!templateSheet) {
+        if (locked || !templateSheet) {
             return;
         }
         let workBook = templateSheet.getParent();

+ 56 - 67
web/maintain/ration_repository/js/section_tree.js

@@ -1,6 +1,7 @@
 /**
  * Created by Zhong on 2017/12/18.
  */
+const locked = lockUtil.getLocked();
 const moduleName = 'stdRation';
 //上下拖动div节点的高度
 const verticalResize = 10;
@@ -8,42 +9,27 @@ let pageOprObj = {
     rationLibName : null,
     rationLibId : null,
     gljLibId: null,
-    initPage : function() {
-        let me = this, rationLibId = getQueryString("repository");
-        me.getRationLibInfo(rationLibId, function (rstData) {
-            if(rstData.length > 0){
-                me.rationLibName = rstData[0].dispName;
-                me.gljLibId = rstData[0].gljLib;
-                if(!me.gljLibId || typeof me.gljLibId === 'undefined' || me.gljLibId == -1){
-                    alert("没有引用人材机库!");
-                    window.location.href = "/rationRepository/main";
-                }
-                if (me.rationLibName) {
-                    var html = $("#rationname")[0].outerHTML;
-                    html = html.replace("XXX定额库", me.rationLibName);
-                    $("#rationname")[0].outerHTML = html;
-                    me.rationLibId = rationLibId;
-                    sectionTreeObj.getSectionTree(rationLibId);
-                    //job
-                    jobContentOprObj.radiosChange(jobContentOprObj.radios, jobContentOprObj.tableAll, jobContentOprObj.tablePartial);
-                    $('#addConBtn').click(jobContentOprObj.bindAddConBtn());
-                    $('#updateConBtn').click(jobContentOprObj.bindUpdateConBtn());
-                    jobContentOprObj.bindAllEvents($('#txtareaAll'));
-                    //fz
-                    annotationOprObj.radiosChange(annotationOprObj.radios, annotationOprObj.fzTableAll, annotationOprObj.fzTablePartial);
-                    $('#fzAddConBtn').click(annotationOprObj.bindAddConBtn());
-                    $('#fzUpdateConBtn').click(annotationOprObj.bindUpdateConBtn());
-                    annotationOprObj.bindAllEvents($('#fzTxtareaAll'));
-                }
-                gljSelOprObj.getGljClassTree(pageOprObj.gljLibId, function () {
-                    gljSelOprObj.getSelGljItems(pageOprObj.gljLibId, function () {})});
-            }
-        });
+    initPage : function(libInfo) {
+        this.rationLibId = libInfo.ID;
+        this.gljLibId = libInfo.gljLib;
+        this.rationLibName = libInfo.dispName;
+        $('#rationname').html(`<a href="main">定额库</a><i class="fa fa-angle-right fa-fw"></i>${this.rationLibName}`);
+        if (!this.gljLibId || this.gljLibId === -1) {
+            alert('没有引用人材机库');
+            setTimeout(() => window.location.href = '/rationRepository/main', 2000);
+        }
+        //job
+        jobContentOprObj.radiosChange(jobContentOprObj.radios, jobContentOprObj.tableAll, jobContentOprObj.tablePartial);
+        $('#addConBtn').click(jobContentOprObj.bindAddConBtn());
+        $('#updateConBtn').click(jobContentOprObj.bindUpdateConBtn());
+        jobContentOprObj.bindAllEvents($('#txtareaAll'));
+        //fz
+        annotationOprObj.radiosChange(annotationOprObj.radios, annotationOprObj.fzTableAll, annotationOprObj.fzTablePartial);
+        $('#fzAddConBtn').click(annotationOprObj.bindAddConBtn());
+        $('#fzUpdateConBtn').click(annotationOprObj.bindUpdateConBtn());
+        annotationOprObj.bindAllEvents($('#fzTxtareaAll'));
     },
-    getRationLibInfo: function (rationLibId, callback) {
-        CommonAjax.post('api/getRationLib', {libId: rationLibId}, callback);
-    }
-}
+};
 
 let sectionTreeObj = {
     cache: null,//ref to tree.items
@@ -243,29 +229,28 @@ let sectionTreeObj = {
             sheetCommonObj.setColumnWidthByRate($('#sectionSpread').width() - 65, this.workBook, [{rateWidth: IDRate}, {rateWidth: nameRate}]);
         }
     },
-    getSectionTree: function (repId) {
-        let me = sectionTreeObj;
-        let url = 'api/getRationTree';
-        let postData = {rationLibId: repId};
-        let sucFunc = function (rstData) {
-            //init
-            me.buildSheet();
-            me.initTree(rstData);
-            me.cache = me.tree.items;
-            me.bindBtn();
-            me.initController(me.tree, me.sheet, me.setting.sheet);
-            me.controller.showTreeData();
-            me.sheet.setFormatter(-1, 0, '@');
-            me.initSelection(me.tree.selected);
-            explanatoryOprObj.bindEvents(exEditor, calcEditor);
-            me.loadRateWidth();
-        };
-        let errFunc = function () {
-
-        };
-        CommonAjax.post(url, postData, sucFunc, errFunc);
+    initSectionTree: function (sectionTree) {
+        //init
+        this.buildSheet();
+        this.initTree(sectionTree);
+        this.cache = this.tree.items;
+        this.bindBtn();
+        this.initController(this.tree, this.sheet, this.setting.sheet);
+        this.controller.showTreeData();
+        this.sheet.setFormatter(-1, 0, '@');
+        this.initSelection(this.tree.selected);
+        explanatoryOprObj.bindEvents(explanatoryOprObj.exEditor, explanatoryOprObj.calcEditor);
+        this.loadRateWidth();
+        this.autoLocate();
+    },
+    //自动定位
+    autoLocate: function () {
+        const hash = window.location.hash;
+        if (hash) {
+            const rationCode = hash.replace('#', '');
+            this.locateToSection(rationCode);
+        }
     },
-    
     initTree: function (datas) {
         this.tree = idTree.createNew(this.setting.tree);
         this.tree.loadDatas(datas);
@@ -277,6 +262,9 @@ let sectionTreeObj = {
     },
     
     refreshBtn: function (selected) {
+        if (locked) {
+            return;
+        }
         let me = this;
         me.insertBtn.removeClass('disabled');
         me.removeBtn.removeClass('disabled');
@@ -610,8 +598,7 @@ let sectionTreeObj = {
     initTools: function (node) {
         if(this.isDef(node)){
             explanatoryOprObj.setAttribute(explanatoryOprObj.currentTreeNode ? explanatoryOprObj.currentTreeNode : node, node, node.data.explanation, node.data.ruleText);
-            //explanatoryOprObj.clickUpdate($('#explanationShow'), $('#ruleTextShow'));
-            explanatoryOprObj.showText(exEditor, calcEditor, node.data.explanation, node.data.ruleText);
+            explanatoryOprObj.showText(explanatoryOprObj.exEditor, explanatoryOprObj.calcEditor, node.data.explanation, node.data.ruleText);
             //job
             jobContentOprObj.currentSituation = typeof node.data.jobContentSituation !== 'undefined'? node.data.jobContentSituation : jobContentOprObj.situations.ALL;
             jobContentOprObj.setAttribute(jobContentOprObj.currentTreeNode ? jobContentOprObj.currentTreeNode : node, node);
@@ -676,7 +663,9 @@ let sectionTreeObj = {
     },
     //根据定额定位至章节树
     locateToSection: function (rationCode) {
-        let me = this;
+        const me = this;
+        const $seach = $('#rationSearch');
+        $seach.val(rationCode);
         //去后台搜索该定额
         CommonAjax.post('/rationRepository/api/getRationItem', {rationLibId: pageOprObj.rationLibId, code: rationCode}, function (rstData) {
             if (!rstData) {
@@ -684,21 +673,21 @@ let sectionTreeObj = {
                 return;
             }
             //定位至相关章节
-            let sectionId = rstData.sectionId;
+            const sectionId = rstData.sectionId;
             if (!sectionId) {
                 return;
             }
-            let sectionNode = me.tree.nodes[`id_${sectionId}`];
+            const sectionNode = me.tree.nodes[`id_${sectionId}`];
             if (!sectionNode) {
                 return;
             }
-            let sectionRow = sectionNode.serialNo();
+            const sectionRow = sectionNode.serialNo();
             me.sheet.setActiveCell(sectionRow, 1);
             me.sheet.showRow(sectionRow, GC.Spread.Sheets.VerticalPosition.top);
-            let doAfterGetRation = function (rations) {
-                let findRation = _.find(rations, {code: rationCode}),
-                    rIdx = rations.indexOf(findRation),
-                    rationSheet = rationOprObj.workBook.getActiveSheet();
+            const doAfterGetRation = function (rations) {
+                const findRation = _.find(rations, {code: rationCode});
+                const rIdx = rations.indexOf(findRation);
+                const rationSheet = rationOprObj.workBook.getActiveSheet();
                 rationSheet.setActiveCell(rIdx, 0);
                 rationOprObj.rationSelInit(rIdx, true);
                 rationOprObj.workBook.getActiveSheet().showRow(rIdx, GC.Spread.Sheets.VerticalPosition.top);

+ 21 - 8
web/maintain/ration_repository/main.html

@@ -50,26 +50,38 @@
                 <div class="col-md-8">
                     <div class="warp-p2 mt-3">
                         <table class="table table-hover table-bordered">
-                            <thead><tr><th>定额库名称</th><th width="160">费用定额</th><th width="160">添加时间</th><th width="90">操作</th><th width="90">原始数据</th><th width="150">内部数据</th><th width="90">补充模板</th></tr></thead>
+                            <thead>
+                                <tr>
+                                    <th>定额库名称</th>
+                                    <th width="160">费用定额</th>
+                                    <th width="160">添加时间</th>
+                                    <th width="90">操作</th>
+                                    <th width="90">原始数据</th>
+                                    <th width="150">内部数据</th>
+                                    <th width="90">补充模板</th>
+                                </tr>
+                            </thead>
                             <tbody id="showArea">
                             <% for(let lib of rationLibs){ %>
                             <tr id="<%= lib.ID %>">
-                                <td><a href="/rationRepository/ration?repository=<%= lib.ID%>"><%= lib.dispName%></a></td>
+                                <td><a href="/rationRepository/ration?repository=<%= lib.ID%>&locked=true"><%= lib.dispName%></a></td>
                                 <td><%= lib.compilationName%></td>
                                 <td><%= moment(lib.createDate).format('YYYY-MM-DD')%></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>
+                                    <a class="lock-btn-control disabled" href="javacript:void(0);" data-toggle="modal" data-target="#edit" title="编辑"><i class="fa fa-pencil-square-o"></i></a>
+                                    <a class="text-danger lock-btn-control disabled" href="javacript:void(0);" data-toggle="modal" data-target="#del" title="删除"><i class="fa fa-remove"></i></a>
+                                    <a class="lock-btn-control disabled" data-toggle="modal" data-target="#reCalcAll" href="javascript:void(0);" title="全部计算"><i class="fa fa-calculator"></i></a>
+                                    <a class="lock" data-locked="true" href="javascript:void(0);" title="解锁"><i class="fa fa-unlock-alt"></i></a>
                                 </td>
                                 <td>
-                                    <a class="btn btn-secondary btn-sm import-source" href="javacript:void(0);" data-id="<%= lib.ID %>" title="导入原始数据"><i class="fa fa-sign-in fa-rotate-90"></i>导入</a>
+                                    <a class="btn btn-secondary btn-sm import-source lock-btn-control disabled" href="javacript:void(0);" data-id="<%= lib.ID %>" title="导入原始数据"><i class="fa fa-sign-in fa-rotate-90"></i>导入</a>
                                 </td>
                                 <td>
-                                    <a class="btn btn-success btn-sm export" href="javacript:void(0);" data-toggle="modal" data-id="<%= lib.ID %>" data-target="#emport" title="导出内部数据"><i class="fa fa-sign-out fa-rotate-270"></i>导出</a>
-                                    <a class="btn btn-secondary btn-sm import-data" href="javacript:void(0);" data-id="<%= lib.ID %>" title="导入内部数据"><i class="fa fa-sign-in fa-rotate-90"></i>导入</a>
+                                    <a class="btn btn-success btn-sm export lock-btn-control disabled" href="javacript:void(0);" data-toggle="modal" data-id="<%= lib.ID %>" data-target="#emport" title="导出内部数据"><i class="fa fa-sign-out fa-rotate-270"></i>导出</a>
+                                    <a class="btn btn-secondary btn-sm import-data lock-btn-control disabled" href="javacript:void(0);" data-id="<%= lib.ID %>" title="导入内部数据"><i class="fa fa-sign-in fa-rotate-90"></i>导入</a>
                                 </td>
                                 <td>
-                                    <a class="btn btn-secondary btn-sm set-comple" href="javacript:void(0);" data-id="<%= lib.ID %>" title="将章节树设为补充模板数据"><i class="fa fa-sign-in fa-rotate-90"></i>设置</a>
+                                    <a class="btn btn-secondary btn-sm set-comple lock-btn-control disabled" href="javacript:void(0);" data-id="<%= lib.ID %>" title="将章节树设为补充模板数据"><i class="fa fa-sign-in fa-rotate-90"></i>设置</a>
                                 </td>
                             </tr>
                             <% } %>
@@ -328,6 +340,7 @@
 <script src="/public/web/PerfectLoad.js"></script>
 <script src="/web/maintain/ration_repository/js/global.js"></script>
 <script src="/public/web/common_ajax.js"></script>
+<script src="/public/web/lock_util.js"></script>
 <script src="/lib/spreadjs/sheets/gc.spread.sheets.all.11.1.2.min.js"></script>
 <script src="/lib/spreadjs/sheets/interop/gc.spread.excelio.11.1.2.min.js"></script>
 <script>GC.Spread.Sheets.LicenseKey =  '<%- LicenseKey %>';</script>

+ 36 - 1
web/maintain/std_glj_lib/css/main.css

@@ -276,4 +276,39 @@ body {
 .modal-fixed-height {
     height:400px;
     overflow-y:auto;
-}
+}
+.reset *{
+    margin: 0;
+    padding: 0;
+}
+.info-list {
+    max-height: 300px;
+    overflow: auto;
+}
+.info-list .list-title{
+    font-weight: bold;
+}
+.info-list li{
+    list-style: none;
+    display: flex;
+}
+.info-list li:hover{
+    background-color: #eee;
+}
+.info-list li span {
+    flex: 1;
+}
+.info-list li a {
+    float: right;
+    width: 30px;
+    text-decoration: none;
+}
+.disabled {
+    pointer-events: none;
+    opacity: .65;
+    color:#666;
+}
+
+.usedInfo td{
+    padding: .3rem;
+}

+ 47 - 6
web/maintain/std_glj_lib/html/gongliao.html

@@ -45,12 +45,12 @@
                     <!--org 3:7:2-->
                   <div class="main-side p-0" id="leftContent" style="width: 25%; height: 100%; overflow: hidden">
                       <div class="tab-bar">
-                          <a href="javascript:void(0);" id="tree_Insert" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="插入"><i class="fa fa-plus" aria-hidden="true"></i></a>
-                          <a href="javascript:void(0);" id="tree_remove" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="删除"><i class="fa fa-remove" aria-hidden="true"></i></a>
-                          <a href="javascript:void(0);" id="tree_upLevel" class="btn btn-sm " data-toggle="tooltip" data-placement="bottom" title="" data-original-title="升级"><i class="fa fa-arrow-left" aria-hidden="true"></i></a>
-                          <a href="javascript:void(0);" id="tree_downLevel" class="btn btn-sm " data-toggle="tooltip" data-placement="bottom" title="" data-original-title="降级"><i class="fa fa-arrow-right" aria-hidden="true"></i></a>
-                          <a href="javascript:void(0);" id="tree_downMove" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="下移"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
-                          <a href="javascript:void(0);" id="tree_upMove" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="上移"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
+                          <a href="javascript:void(0);" id="tree_Insert" class="btn btn-sm lock-btn-control" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="插入"><i class="fa fa-plus" aria-hidden="true"></i></a>
+                          <a href="javascript:void(0);" id="tree_remove" class="btn btn-sm lock-btn-control" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="删除"><i class="fa fa-remove" aria-hidden="true"></i></a>
+                          <a href="javascript:void(0);" id="tree_upLevel" class="btn btn-sm lock-btn-control" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="升级"><i class="fa fa-arrow-left" aria-hidden="true"></i></a>
+                          <a href="javascript:void(0);" id="tree_downLevel" class="btn btn-sm lock-btn-control" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="降级"><i class="fa fa-arrow-right" aria-hidden="true"></i></a>
+                          <a href="javascript:void(0);" id="tree_downMove" class="btn btn-sm lock-btn-control" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="下移"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
+                          <a href="javascript:void(0);" id="tree_upMove" class="btn btn-sm lock-btn-control" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="上移"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
                       </div>
                       <div class="tab-content" id="gljClassSpread" style="overflow: hidden">
                       </div>
@@ -189,6 +189,46 @@
             </div>
         </div>
     </div>
+    <div class="modal fade" id="info" 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 typeClose" data-dismiss="modal" aria-label="Close">
+                        <span aria-hidden="true">×</span>
+                    </button>
+                </div>
+                <div class="modal-body reset">
+                    <ul id="infoBody" class="info-list">
+                    </ul>
+                </div>
+            </div>
+        </div>
+    </div>
+
+    <div class="modal fade" id="usedInfo" 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 typeClose" data-dismiss="modal" aria-label="Close">
+                        <span aria-hidden="true">×</span>
+                    </button>
+                </div>
+                <div class="modal-body reset">
+                    <div class="warp-p2 mt-3">
+                        <label id="usedTotal"></label>
+                        <table class="table table-hover table-bordered usedInfo">
+                            <thead><tr><th>项目ID</th><th>用户名称</th><th>电话号码</th></tr></thead>
+                            <tbody id="userInfoShowArea">
+                            </tbody>
+                        </table>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+
     <!-- JS. -->
     <script src="/lib/jquery/jquery.min.js"></script>
     <script src="/lib/jquery-contextmenu/jquery.contextMenu.min.js"></script>
@@ -209,6 +249,7 @@
     <script type="text/javascript" src="/public/web/treeDataHelper.js"></script>
     <script type="text/javascript" src="/public/web/QueryParam.js"></script>
     <script type="text/javascript" src="/public/web/common_ajax.js"></script>
+    <script src="/public/web/lock_util.js"></script>
     <script type="text/javascript" src="/public/web/id_tree.js"></script>
     <script type="text/javascript" src="/public/web/tools_const.js"></script>
     <script type="text/javascript" src="/public/web/tree_sheet/tree_sheet_controller.js"></script>

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

@@ -33,7 +33,18 @@
                 <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><th width="90">价格数据</th><th width="100">组成物数据</th><th width="90">补充模板</th></tr></thead>
+                            <thead>
+                                <tr>
+                                    <th>人材机库名称</th>
+                                    <th>费用定额</th>
+                                    <th>定额库</th>
+                                    <th width="160">添加时间</th>
+                                    <th width="70">操作</th>
+                                    <th width="90">价格数据</th>
+                                    <th width="100">组成物数据</th>
+                                    <th width="90">补充模板</th>
+                                </tr>
+                            </thead>
                             <tbody id="showArea">
                             </tbody>
                         </table>
@@ -180,6 +191,7 @@
 <script src="/lib/bootstrap/bootstrap.min.js"></script>
 <script src="/web/maintain/std_glj_lib/js/global.js"></script>
 <script src="/public/web/common_ajax.js"></script>
+<script src="/public/web/lock_util.js"></script>
 <script src="/public/web/PerfectLoad.js"></script>
 <!-- zTree -->
 <script type="text/javascript" src="/lib/ztree/jquery.ztree.core.js"></script>

+ 83 - 8
web/maintain/std_glj_lib/js/glj.js

@@ -1,7 +1,7 @@
 /**
  * Created by Zhong on 2017/8/14.
  */
-
+const locked = lockUtil.getLocked();
 $(document).ready(function () {
     let moduleName = 'stdGLj';
     function refreshALlWorkBook() {
@@ -70,11 +70,12 @@ let pageOprObj = {
             //repositoryGljObj.getRationGljIds(gljLibId);
             repositoryGljObj.getGljDistType(function () {
                 repositoryGljObj.currentRepositoryId = parseInt(gljLibId);
-              /*  repositoryGljObj.getGljTree(gljLibId, function () {
-                    repositoryGljObj.getGljItems(gljLibId);
-                });*/
                 repositoryGljObj.getGljItems(gljLibId, function () {
-                    gljClassTreeObj.getGljClassTree(gljLibId);
+                    gljClassTreeObj.getGljClassTree(gljLibId, function () {
+                        const spreads = [gljClassTreeObj.workBook, repositoryGljObj.workBook, gljComponentOprObj.workBook];
+                        const $range = $(document.body);
+                        lockUtil.lockSpreadsAndTools(spreads, $range, locked);
+                    });
                 })
             });
         });
@@ -1014,6 +1015,9 @@ let repositoryGljObj = {
     },
     //删除人材机前需要判断人材机是否有被引用,被引用了则不可删除
     repositoryGljDelOpr: function () {
+        if (locked) {
+            return;
+        }
         let me = repositoryGljObj;
         me.workBook.commandManager().register('repositoryGljDel', function () {
             let sels = me.workBook.getActiveSheet().getSelections();
@@ -1050,17 +1054,40 @@ let repositoryGljObj = {
                     return {
                         callback: function(){},
                         items: {
-                            "delete": {
+                            delete: {
                                 name: "删除",
                                 disabled: function () {
-                                    return !(me.currentCache && me.currentCache[target.row]);
+                                    return locked || !(me.currentCache && me.currentCache[target.row]);
                                 },
                                 icon: "fa-remove",
                                 callback: function (key, opt) {
                                     let curSel = _.cloneDeep(sheet.getSelections()[0]);
                                     curSel.colCount = me.setting.header.length;
                                     me.delGljs([curSel]);
-                                }}
+                                }
+                            },
+                            getReference: {
+                                name: '查找引用',
+                                disabled: function () {
+                                    return !(me.currentCache && me.currentCache[target.row]);
+                                },
+                                icon: 'fa-search',
+                                callback: function () {
+                                    const glj = me.currentCache[target.row];
+                                    me.getReference(glj);
+                                }
+                            },
+                            getUsedInfo: {
+                                name: '查找用户使用情况',
+                                disabled: function () {
+                                    return !(me.currentCache && me.currentCache[target.row]);
+                                },
+                                icon: 'fa-search',
+                                callback: function () {
+                                    const glj = me.currentCache[target.row];
+                                    me.getUsedInfo(glj);
+                                }
+                            }
                         }
                     };
                 }
@@ -1070,6 +1097,54 @@ let repositoryGljObj = {
             }
         });
     },
+    getReference: function (glj) {
+        const $info = $('#info');
+        const $infoBody = $('#infoBody');
+        $.bootstrapLoading.start();
+        CommonAjax.post('/stdGljRepository/api/getReference', {repositoryId: glj.repositoryId, gljId: glj.ID}, function (info) {
+            const htmlArr = [];
+            if (!info || !Object.keys(info).length) {
+                htmlArr.push('<li>无引用数据</li>');
+            }
+            for (let libName in info) {
+                htmlArr.push(`<li class="list-title">${libName}</li>`);
+                const rations = info[libName];
+                const rationList = rations.map(ration => {
+                    if (ration.rationRepId) {
+                        return `<li>
+                                    <span>${ration.code}</span>
+                                    <a target="_blank" href="/rationRepository/ration?repository=${ration.rationRepId}&locked=${locked}#${ration.code}">定位</a>
+                                </li>`;
+                    }
+                    return `<li><span>${ration.code}</span></li>`;
+                });
+                htmlArr.push(...rationList);
+            }
+            $infoBody.html(htmlArr.join(''));
+            $info.modal('show');
+            $.bootstrapLoading.end();
+        }, function () {
+            $.bootstrapLoading.end();
+        });
+    },
+    getUsedInfo:function (glj) {
+        $.bootstrapLoading.start();
+        $("#usedInfo").modal('show');
+        CommonAjax.post('/stdGljRepository/api/getUsedInfo', {repositoryId: glj.repositoryId, gljId: glj.ID}, function (info) {
+            $("#usedTotal").html(`共${info.length}项记录`);
+            let htmlString = "";
+            for(let u of info){
+                htmlString += `<tr><td>${u.ID}</td><td>${u.username}</td> <td>${u.mobile}</td></tr>`;
+            }
+            $("#userInfoShowArea").html(htmlString);
+
+            $.bootstrapLoading.end();
+        }, function () {
+            $.bootstrapLoading.end();
+        });
+    },
+
+
     validUpdateObj: function (pasteObj, rowIdx) {
         let rst = {updateGlj: [], updateBasePrcArr: []}, backUpObj = {},
             me = repositoryGljObj,

+ 3 - 0
web/maintain/std_glj_lib/js/gljClassTree.js

@@ -206,6 +206,9 @@ let gljClassTreeObj = {
     },
 
     refreshBtn: function (selected) {
+        if (locked) {
+            return;
+        }
         let me = this;
         me.insertBtn.removeClass('disabled');
         me.removeBtn.removeClass('disabled');

+ 5 - 4
web/maintain/std_glj_lib/js/gljComponent.js

@@ -182,6 +182,9 @@ let gljComponentOprObj = {
         return _.isEqual(consumeAmtA.consumeAmtProperty, consumeAmtB.consumeAmtProperty);
     },
     gljComponentDelOpr: function () {
+        if (locked) {
+            return;
+        }
         let me = gljComponentOprObj, that = repositoryGljObj, updateArr = [], removeArr = [], isUpdate = false, updateBasePrc= [];
         me.workBook.commandManager().register('gljComponentDel', function () {
             let sels = me.workBook.getSheet(0).getSelections();
@@ -277,12 +280,10 @@ let gljComponentOprObj = {
                     //控制按钮是否可用
                     let insertDis = false,
                         delDis = false;
-                    if(!(that.currentGlj && allowComponent.includes(that.currentGlj.gljType)) || //机械组成物,应可选择无组成物的普通材料
-                        ([4].includes(that.currentGlj.gljType) && that.isComponent(that.currentGlj.ID, that.gljList))){
+                    if(locked || !(that.currentGlj && allowComponent.includes(that.currentGlj.gljType)) || (that.currentGlj.gljType === 4 && that.isComponent(that.currentGlj.ID, that.gljList))){
                         insertDis = true;
                     }
-                    if(!that.currentGlj || typeof that.currentComponent === 'undefined' ||
-                        (typeof that.currentComponent !== 'undefined' && target.row >= that.currentComponent.length)){//右键定位在有组成物的行,删除键才显示可用
+                    if(locked || !that.currentGlj || typeof that.currentComponent === 'undefined' || (typeof that.currentComponent !== 'undefined' && target.row >= that.currentComponent.length)){//右键定位在有组成物的行,删除键才显示可用
                         delDis = true;
                     }
                     return {

+ 22 - 15
web/maintain/std_glj_lib/js/main.js

@@ -117,7 +117,10 @@ $(function () {
                     deleteCount = 0;
                 }
             });
-
+            // 锁定、解锁
+            $('#showArea').on('click', '.lock', function () {
+                lockUtil.handleLockClick($(this));
+            });
 
         });
     });
@@ -278,16 +281,18 @@ function getAllGljLib(callback){
                     dispNames.push(result.data[i].dispName);
                     $("#showArea").append(
                         "<tr id='"+id+"' data-compilationId='"+ compilationId + "'>" +
-                        "<td><a href='/stdGljRepository/glj?gljLibId="+id+"'>"+libName+"</a></td>" +
+                        "<td><a href='/stdGljRepository/glj?gljLibId="+id+"&locked=true'>"+libName+"</a></td>" +
                         "<td>"+compilationName+" </td>" +
                         "<td>"+rationLibsName+" </td>" +
                         "<td>"+createDate+" </td>" +
-                        "<td><a href='javascript:void(0);' data-toggle='modal' data-target='#edit' title='编辑'>" +
-                        "<i class='fa fa-pencil-square-o'></i></a> <a href='javascript:void(0);' data-toggle='modal' data-target='#del' class='text-danger' title='删除'>" +
-                        "<i class='fa fa-remove'></i></a></td>" +
-                        "<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>" +
-                        "<td><a class='btn btn-secondary btn-sm import-components' href='javacript:void(0);' data-id='"+ id +"' title='导入组成物'><i class='fa fa-sign-in fa-rotate-90'></i>导入</a></td>" +
-                        "<td><a class='btn btn-secondary btn-sm set-comple' href='javacript:void(0);' data-id='"+ id +"' title='将分类树设为补充模板数据'><i class='fa fa-sign-in fa-rotate-90'></i>设置</a></td>" +
+                        "<td><a class='lock-btn-control disabled' 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 lock-btn-control disabled' title='删除'>" +
+                        "<i class='fa fa-remove'></i></a> " +
+                        "<a class='lock' data-locked='true' href='javascript:void(0);' title='解锁'><i class='fa fa-unlock-alt'></i></a>" +
+                        "</td>" +
+                        "<td><a class='btn btn-secondary btn-sm import-data lock-btn-control disabled' href='javacript:void(0);' data-id='"+ id +"' title='导入数据'><i class='fa fa-sign-in fa-rotate-90'></i>导入</a></td>" +
+                        "<td><a class='btn btn-secondary btn-sm import-components lock-btn-control disabled' href='javacript:void(0);' data-id='"+ id +"' title='导入组成物'><i class='fa fa-sign-in fa-rotate-90'></i>导入</a></td>" +
+                        "<td><a class='btn btn-secondary btn-sm set-comple lock-btn-control disabled' href='javacript:void(0);' data-id='"+ id +"' title='将分类树设为补充模板数据'><i class='fa fa-sign-in fa-rotate-90'></i>设置</a></td>" +
                         "</tr>");
                 }
             }
@@ -328,16 +333,18 @@ function createGljLib(gljLibObj, dispNamesArr, usedCom){
                 usedCom.push(gljLibObj.compilationId);
                 $("#showArea").append(
                     "<tr id='"+id+"' data-compilationId='"+ gljLibObj.compilationId + "'>" +
-                    "<td><a href='/stdGljRepository/glj?gljLibId="+id+"'>"+libName+"</a></td>" +
+                    "<td><a href='/stdGljRepository/glj?gljLibId="+id+"&locked=true'>"+libName+"</a></td>" +
                     "<td>"+compilationName+" </td>" +
                     "<td>"+''+" </td>" +
                     "<td>"+createDate+" </td>" +
-                    "<td><a href='javascript:void(0);' data-toggle='modal' data-target='#edit' title='编辑'>" +
-                    "<i class='fa fa-pencil-square-o'></i></a> <a href='javascript:void(0);' data-toggle='modal' data-target='#del' class='text-danger' title='删除'>" +
-                    "<i class='fa fa-remove'></i></a></td>" +
-                    "<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>" +
-                    "<td><a class='btn btn-secondary btn-sm import-components' href='javacript:void(0);' data-id='"+ id +"' title='导入组成物'><i class='fa fa-sign-in fa-rotate-90'></i>导入</a></td>" +
-                    "<td><a class='btn btn-secondary btn-sm set-comple' href='javacript:void(0);' data-id='"+ id +"' title='将分类树设为补充模板数据'><i class='fa fa-sign-in fa-rotate-90'></i>设置</a></td>" +
+                    "<td><a class='lock-btn-control disabled' 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 lock-btn-control disabled' title='删除'>" +
+                    "<i class='fa fa-remove'></i></a>" +
+                    "<a class='lock' data-locked='true' href='javascript:void(0);' title='解锁'><i class='fa fa-unlock-alt'></i></a>" +
+                    "</td>" +
+                    "<td><a class='btn btn-secondary btn-sm import-data lock-btn-control disabled' href='javacript:void(0);' data-id='"+ id +"' title='导入数据'><i class='fa fa-sign-in fa-rotate-90'></i>导入</a></td>" +
+                    "<td><a class='btn btn-secondary btn-sm import-components lock-btn-control disabled' href='javacript:void(0);' data-id='"+ id +"' title='导入组成物'><i class='fa fa-sign-in fa-rotate-90'></i>导入</a></td>" +
+                    "<td><a class='btn btn-secondary btn-sm set-comple lock-btn-control disabled' href='javacript:void(0);' data-id='"+ id +"' title='将分类树设为补充模板数据'><i class='fa fa-sign-in fa-rotate-90'></i>设置</a></td>" +
                     "</tr>");
             }
             $('#cancelBtn').click();

+ 5 - 4
web/maintain/vehicleVesselTax_lib/html/edit.html

@@ -13,13 +13,13 @@
             <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>
+                        <a href="javascript:void(0)" class="btn btn-sm lock-btn-control" id="createNormal"><i class="fa fa-list-alt" aria-hidden="true"></i> 生成默认</a>
+                        <a href="javascript:void(0)" class="btn btn-sm lock-btn-control" id="format"><i class="fa fa-list-alt" aria-hidden="true"></i> 校验格式</a>
+                        <a href="javascript:void(0)" class="btn btn-sm lock-btn-control" id="save"><i class="fa fa-floppy-o" aria-hidden="true"></i> 保存</a>
                     </div>
                 </div>
             </nav>
-            <textarea class="form-control" id="vvTaxList" rows="38"></textarea>
+            <textarea class="form-control lock-text-control" id="vvTaxList" rows="38"></textarea>
         </div>
         </div>
         <input type="hidden" id="libID" value="<%= libID %>">
@@ -34,4 +34,5 @@
 </script>
 <script type="text/javascript" src="/public/web/PerfectLoad.js"></script>
 <script type="text/javascript" src="/lib/json/json2.js"></script>
+<script src="/public/web/lock_util.js"></script>
 <script type="text/javascript" src="/web/maintain/vehicleVesselTax_lib/js/vvTax_edit.js"></script>

+ 6 - 4
web/maintain/vehicleVesselTax_lib/html/main.html

@@ -5,15 +5,16 @@
                 <div class="col-md-5">
                     <div class="warp-p2 mt-3">
                         <table class="table table-hover table-bordered">
-                            <thead><tr><th >库名称</th><th width="160">添加时间</th><th width="120">操作</th></tr></thead>
+                            <thead><tr><th >库名称</th><th width="160">添加时间</th><th width="70">操作</th></tr></thead>
                             <tbody id="showArea">
                             <% for(let lib of vvTaxLibs){ %>
                             <tr class="libTr">
-                                <td id="<%= lib.ID%>"><a href="/vvTax/edit/<%= lib.ID%>"><%= lib.name%></a></td>
+                                <td id="<%= lib.ID%>"><a href="/vvTax/edit/<%= lib.ID%>?locked=true"><%= lib.name%></a></td>
                                 <td><%= moment(lib.createDate).format('YYYY-MM-DD')%></td>
                                 <td>
-                                    <a style="color: #0275d8" onclick='getVVTaxLib("<%= 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>
+                                    <a class="lock-btn-control disabled" href="javascript:;" style="color: #0275d8" onclick='getVVTaxLib("<%= lib.ID%>")' title="编辑"><i class="fa fa-pencil-square-o"></i></a>
+                                    <a class="text-danger lock-btn-control disabled" href="javascript:;" style="color: #0275d8" onclick='showDeleteModal("<%= lib.ID%>")' title="删除"><i class="fa fa-remove"></i></a>
+                                    <a class="lock" data-locked="true" href="javascript:void(0);" title="解锁"><i class="fa fa-unlock-alt"></i></a>
                                 </td>
                             </tr>
                             <% } %>
@@ -105,4 +106,5 @@
     </div>
 </div>
 
+<script src="/public/web/lock_util.js"></script>
 <script type="text/javascript" src="/web/maintain/vehicleVesselTax_lib/js/vvTax.js"></script>

+ 4 - 0
web/maintain/vehicleVesselTax_lib/js/vvTax.js

@@ -52,6 +52,10 @@ $(document).ready(function() {
             }
         }
     });
+    // 锁定、解锁
+    $('.lock').click(function () {
+        lockUtil.handleLockClick($(this));
+    });
 });
 
 async function getVVTaxLib (ID) {

+ 2 - 0
web/maintain/vehicleVesselTax_lib/js/vvTax_edit.js

@@ -3,6 +3,8 @@
  */
 
 $(document).ready(function () {
+    const locked = lockUtil.getLocked();
+    lockUtil.lockTools($(document.body), locked);
     try {
         let tem = sortJson(JSON.parse($("#originalVVTax").val()), compareVVTax);
         $("#vvTaxList").val(JSON.stringify(tem,null,4));