소스 검색

Merge branch '1.0.0_online' of http://192.168.1.41:3000/SmartCost/ConstructionOperation into 1.0.0_online

TonyKang 6 년 전
부모
커밋
1724522c0d
30개의 변경된 파일663개의 추가작업 그리고 329개의 파일을 삭제
  1. 12 0
      modules/bills_template_lib/controllers/bills_template_controller.js
  2. 17 0
      modules/bills_template_lib/facade/bills_template_facade.js
  3. 1 0
      modules/bills_template_lib/routes/bills_template_routes.js
  4. 28 65
      modules/ration_repository/controllers/ration_repository_controller.js
  5. 1 0
      modules/ration_repository/models/glj_repository.js
  6. 32 3
      modules/ration_repository/models/installation.js
  7. 36 0
      modules/ration_repository/models/ration_item.js
  8. 21 0
      modules/ration_repository/models/ration_section_tree.js
  9. 1 0
      modules/ration_repository/routes/ration_rep_routes.js
  10. 11 0
      modules/std_glj_lib/controllers/gljController.js
  11. 35 1
      modules/std_glj_lib/models/gljModel.js
  12. 1 0
      modules/std_glj_lib/routes/routes.js
  13. 4 1
      public/web/PerfectLoad.js
  14. 37 1
      web/maintain/bill_template_lib/html/main.html
  15. 22 0
      web/maintain/bill_template_lib/js/bills_template.js
  16. 2 2
      web/maintain/bills_lib/html/qingdan.html
  17. 2 1
      web/maintain/bills_lib/scripts/db_controller.js
  18. 2 82
      web/maintain/ration_repository/dinge.html
  19. 29 0
      web/maintain/ration_repository/js/explanatory.js
  20. 16 50
      web/maintain/ration_repository/js/gljSelect.js
  21. 88 0
      web/maintain/ration_repository/js/init.js
  22. 66 1
      web/maintain/ration_repository/js/main.js
  23. 0 15
      web/maintain/ration_repository/js/ration.js
  24. 11 29
      web/maintain/ration_repository/js/ration_glj.js
  25. 11 17
      web/maintain/ration_repository/js/ration_installation.js
  26. 47 58
      web/maintain/ration_repository/js/section_tree.js
  27. 44 1
      web/maintain/ration_repository/main.html
  28. 26 0
      web/maintain/std_glj_lib/css/main.css
  29. 16 0
      web/maintain/std_glj_lib/html/gongliao.html
  30. 44 2
      web/maintain/std_glj_lib/js/glj.js

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

@@ -153,6 +153,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;

+ 17 - 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,21 @@ 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);
 

+ 28 - 65
modules/ration_repository/controllers/ration_repository_controller.js

@@ -17,12 +17,25 @@ const fs = require("fs");
 // excel解析
 const excel = require("node-xlsx");
 const rationItem = require("../models/ration_item");
+const rationSectionTree = require('../models/ration_section_tree');
 const rationLibModel = mongoose.model('std_ration_lib_map');
 const rationItemModel = mongoose.model('std_ration_lib_ration_items');
 import STDGLJListModel from '../../std_glj_lib/models/gljModel';
 let logger = require('../../../logs/log_helper').logger;
 
 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);
@@ -195,9 +208,21 @@ class RationRepositoryController extends baseController {
                 if (sheet[0] === undefined || sheet[0].data === undefined) {
                     throw 'excel没有对应数据';
                 }
-                const failGLJList = type === 'source_file' ?
-                    await rationItem.batchAddFromExcel(rationRepId, sheet[0].data) :
-                    await rationItem.batchUpdateSectionIdFromExcel(sheet[0].data);
+                let failGLJList;
+                switch (type) {
+                    // 导入原始数据
+                    case 'source_file':
+                        failGLJList = await rationItem.batchAddFromExcel(rationRepId, sheet[0].data);
+                        break;
+                    // 导入内部数据
+                    case 'import_data':
+                        failGLJList = await rationItem.batchUpdateSectionIdFromExcel(sheet[0].data);
+                        break;
+                    // 导入章节数据(一列文本,生成兄弟节点树)
+                    case 'section_file':
+                        await rationSectionTree.importSection(rationRepId, sheet[0].data);
+                        break;
+                }
                 if (Array.isArray(failGLJList) && failGLJList.length > 0) {
                     responseData.msg = failGLJList.join("<br/>");
                 }
@@ -301,65 +326,3 @@ class RationRepositoryController extends baseController {
 }
 
 export default RationRepositoryController;
-/*
-module.exports = {
-    addRationRepository:function(req,res){
-        var rationObj = JSON.parse(req.body.rationRepObj);
-        rationRepository.addRationRepository(rationObj,function(err,data){
-            if (data) {
-                callback(req, res, err, "has data", data);
-            } else {
-                callback(req, res, err, "no data", null);
-            }
-        })
-    },
-    getDisPlayRationLibs: function(req, res){
-        rationRepository.getDisplayRationLibs(function(err, data){
-            if (data) {
-                callback(req, res, err, "has data",data);
-            } else {
-                callback(req, res, err, "no data", null);
-            }
-        });
-    },
-    getRealLibName:function(req,res){
-        var libName = req.body.rationName;
-        rationRepository.getRealLibName(libName,function(err,data){
-            if (data) {
-                callback(req, res, err, "has data", data);
-            } else {
-                callback(req, res, err, "no data", null);
-            }
-        })
-    },
-    getLibIDByName:function(req,res){
-        rationRepository.getLibIDByName(req.body.libName, function(err,data){
-            if (data) {
-                callback(req, res, err, "has ID", data);
-            } else {
-                callback(req, res, err, "no ID", null);
-            }
-        })
-    },
-    deleteRationLib:function(req,res){
-        var rationName = req.body.rationName;
-        rationRepository.deleteRationLib(rationName,function(err,data){
-            if (data) {
-                callback(req, res, err, "has data", data);
-            } else {
-                callback(req, res, err, "no data", null);
-            }
-        })
-    },
-    updateRationRepositoryName: function(req, res) {
-        var orgName = req.body.rationName;
-        var newName = req.body.newName;
-        rationRepository.updateName(orgName, newName, function(err, data){
-            if (data) {
-                callback(req, res, err, "has data", data);
-            } else {
-                callback(req, res, err, "no data", null);
-            }
-        });
-    }
-}*/

+ 1 - 0
modules/ration_repository/models/glj_repository.js

@@ -12,6 +12,7 @@ const gljModel = mongoose.model('std_glj_lib_gljList');
 const gljClassModel = mongoose.model('std_glj_lib_gljClass');
 
 var gljItemDAO = function(){};
+
 gljItemDAO.prototype.getGljTypes = function(gljLibID, callback){
     gljClassModel.find({"repositoryId": gljLibID, "$or": [{"isDeleted": null}, {"isDeleted": false} ]},function(err,data){
         if(data.length) callback(false,data);

+ 32 - 3
modules/ration_repository/models/installation.js

@@ -9,14 +9,43 @@ 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}]});
+            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);
+        }
+    }
+    /*async getInstallation(rationRepId, callback){
+        try {
+            let feeItems = await installFeeItemModel.find({rationRepId: rationRepId});
             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}]});
+                    let sections = await installSectionModel.find({ID: {$in: sids}});
                     feeItem._doc.section = sections;
                 }
             }
@@ -25,7 +54,7 @@ class InstallationDao{
         catch(err){
             callback(err, null);
         }
-    }
+    }*/
 
     async updateSection(updateData, callback){
         try{

+ 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.getRationItemsByLib = async function (rationRepId, showHint = null, returnFields = '') {
     let rationLib = await stdRationLibModel.findOne({ID: rationRepId, deleted: false});
     if(!rationLib){

+ 21 - 0
modules/ration_repository/models/ration_section_tree.js

@@ -11,6 +11,27 @@ const rationModel = mongoose.model('std_ration_lib_ration_items');
 const compleRationSectionTemp = mongoose.model('complementary_ration_section_templates');
 var rationChapterTreeDAO = function(){};
 
+rationChapterTreeDAO.prototype.importSection = async function (rationRepId, sheetData) {
+    const counterRst = await counter.counterDAO.getIDAfterCount(counter.moduleName.rationTree, sheetData.length);
+    const insertData = [];
+    const beginID = counterRst.sequence_value - (sheetData.length - 1);
+    for (let i = 0; i < sheetData.length; i++) {
+        const curData = sheetData[i];
+        const nextData = sheetData[i + 1];
+        const curID = beginID + i;
+        const nextID = nextData ? curID + 1 : -1;
+        const name = curData[0];
+        insertData.push({
+            rationRepId,
+            name,
+            ID: curID,
+            NextSiblingID: nextID,
+            ParentID: -1
+        });
+    }
+    await rationChapterTreeModel.insertMany(insertData);
+};
+
 rationChapterTreeDAO.prototype.sectionTemplateCount = async function (compilationId) {
     return await compleRationSectionTemp.find({compilationId}).count();
 };

+ 1 - 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);

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

@@ -201,6 +201,17 @@ 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: 'fail', data: null});
+        }
+    }
+
     async importPrice(request, response) {
         let responseData = {
             err: 0,

+ 35 - 1
modules/std_glj_lib/models/gljModel.js

@@ -8,12 +8,44 @@ const gljClassModel = mongoose.model('std_glj_lib_gljClass');
 const compilationModel = mongoose.model('compilation');
 const scMathUtil = require('../../../public/scMathUtil').getUtil();
 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";
 
 class GljDao  extends OprDao{
+    async getReference(repositoryId, gljId) {
+        const gljLib = await gljMapModel.findOne({ID: repositoryId});
+        const rationLibIds = [];
+        const rationLibNameMapping = {};
+        gljLib.rationLibs.forEach(item => {
+            rationLibIds.push(item.ID);
+            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] = [];
+        }
+        complementaryRations.forEach(ration => rst[complementaryLib].push({code: ration.code}));
+        return rst;
+    }
+
+    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){
@@ -44,7 +76,9 @@ class GljDao  extends OprDao{
             }
         }
     }
-
+    async getGljItemsSync(gljLibId) {
+         return await gljModel.find({repositoryId: gljLibId}, '-_id', {lean: true});
+    }
     async getGljItemsByRep(repositoryId,callback = null){
         try {
             let rst = await gljModel.find({repositoryId: repositoryId}).lean();

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

@@ -42,6 +42,7 @@ 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);
 

+ 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);
 
                     },

+ 37 - 1
web/maintain/bill_template_lib/html/main.html

@@ -19,7 +19,15 @@
                 <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="60">操作</th>
+                                    <th width="60">复制</th>
+                                </tr>
+                            </thead>
                             <tbody id="showArea">
                             <% for(let lib of templateLibs){ %>
                             <tr class="libTr">
@@ -30,6 +38,9 @@
                                     <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>
                                 </td>
+                                <td>
+                                    <a href="javascript:void(0);" onclick="showCopyModal('<%= lib.ID %>')" class="btn btn-secondary btn-sm copy-data" title="复制数据"><i class="fa fa-clone"></i>复制</a>
+                                </td>
                             </tr>
                             <% } %>
                             </tbody>
@@ -123,6 +134,31 @@
         </div>
     </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="/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>

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

@@ -52,6 +52,23 @@ $(document).ready(function() {
            }
         }
     });
+
+    //复制库
+    $('#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 +83,9 @@ function showDeleteModal(ID){
     $("#libID_del").val(ID);
     $("#delCount").val(0);
     $("#del").modal({show:true});
+}
+
+function showCopyModal(ID) {
+    $('#libID').val(ID);
+    $('#copy').modal('show');
 }

+ 2 - 2
web/maintain/bills_lib/html/qingdan.html

@@ -461,7 +461,6 @@
 
     function showBillsSheet(datas, jobsSheet, itemsSheet, setting) {
         let 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);
         setSheet.initSheet(billsSpread, setting, true);
@@ -727,7 +726,8 @@
             }
             if(controller.tree.selected  && args.oldSelections[0].row !== args.newSelections[0].row|| controller.tree.selected && args.oldSelections[0].row === 0){
                 //rechargeArea
-                codeEditor.setValue(controller.tree.selected.data.recharge);
+                const recharge = controller.tree.selected.data.recharge || '';
+                codeEditor.setValue(recharge);
                 //$('#exampleTextarea').val(controller.tree.selected.data.recharge);
                 if(field === 'jobs'){
                     tools.clearData(sheet);

+ 2 - 1
web/maintain/bills_lib/scripts/db_controller.js

@@ -244,7 +244,8 @@ var dbController = {
                 let nowNode = controller.tree.selected ;
                 if(nowNode){
                     let jobs = controller.tree.selected.jobs;
-                    codeEditor.setValue(controller.tree.selected.data.recharge);
+                    const recharge = controller.tree.selected.data.recharge || '';
+                    codeEditor.setValue(recharge);
                     //$('#exampleTextarea').val(controller.tree.selected.data.recharge);
                     setSheet.setMaxRowCount(jobsSheet, jobs);
                     tools.orderReshowData(jobsSheet, jobs, jobsSetting, 'job', false);

+ 2 - 82
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>
@@ -683,88 +684,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">

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

@@ -3,10 +3,39 @@
  */
 //定额章节节点说明、计算规则
 let explanatoryOprObj = {
+    exEditor: null,
+    calcEditor: null,
     preTreeNode: null,
     currentTreeNode: null,//定额章节树节点
     currentExplanation: null,
     currentRuleText: null,
+    // 初始化说明、计算规则编辑器
+    initEditor: function () {
+        const 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);
+        });
+        this.exEditor = exEditor;
+        const 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);
+        });
+        this.calcEditor = calcEditor;
+    },
     setAttribute: function (preNode, currentNode, explanation, ruleText) {
         let me = explanatoryOprObj;
         me.preTreeNode = preNode;

+ 16 - 50
web/maintain/ration_repository/js/gljSelect.js

@@ -39,58 +39,24 @@ let gljSelOprObj = {
             delete glj.ID;
         }
     },
-    getSelGljItems: function(stdGljLibId, callback) {
-        $.bootstrapLoading.start();
-        let me = this;
-        $.ajax({
-            type:"POST",
-            url:"/stdGljRepository/api/getGljItems",
-            data:{"repositoryId": stdGljLibId},
-            dataType:"json",
-            cache:false,
-            timeout:240000,
-            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();
-                    }
-                }
-                $.bootstrapLoading.end();
-            },
-            error:function(err){
-                $.bootstrapLoading.end();
-                alert('获取人材机失败');
+    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;

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

@@ -0,0 +1,88 @@
+'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;
+
+            $("#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();
+    });
+})();

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

@@ -154,6 +154,15 @@ $(function () {
         rationRepId = id;
         $("#import2").modal("show");
     });
+    // 导入章节数据
+    $('#showArea').on('click', '.import-section', function () {
+        let id = $(this).data('id');
+        id = parseInt(id);
+        if (isNaN(id) || id <= 0) {
+            return false;
+        }
+        rationRepId = id;
+    });
 
     // 导入原始数据确认
     $("#source-import,#data-import").click(function() {
@@ -213,7 +222,63 @@ $(function () {
             alert(error);
         }
     });
-
+    // 导入章节数据确认
+    $('#import-section-confirm').click(function() {
+        $.bootstrapLoading.start();
+        const self = $(this);
+        const dialog = $('#section');
+        try {
+            const formData = new FormData();
+            const file = $('input[name=section_file]')[0];
+            if (file.files.length <= 0) {
+                throw '请选择文件!';
+            }
+            formData.append('file', file.files[0]);
+            formData.append('type', 'section_file');
+            // 获取定额库id
+            if (rationRepId <= 0) {
+                return false;
+            }
+            formData.append('rationRepId', rationRepId);
+            $.ajax({
+                url: '/rationRepository/api/upload',
+                type: 'POST',
+                data: formData,
+                cache: false,
+                contentType: false,
+                processData: false,
+                beforeSend: function() {
+                    self.attr('disabled', 'disabled');
+                    self.text('上传中...');
+                },
+                success: function(response){
+                    self.removeAttr('disabled');
+                    self.text('确定导入');
+                    if (response.err === 0) {
+                        $.bootstrapLoading.end();
+                        const message = response.msg !== undefined ? response.msg : '';
+                        if (message !== '') {
+                            alert(message);
+                        }
+                        // 成功则关闭窗体
+                        dialog.modal("hide");
+                    } else {
+                        $.bootstrapLoading.end();
+                        const message = response.msg !== undefined ? response.msg : '上传失败!';
+                        alert(message);
+                    }
+                },
+                error: function(){
+                    $.bootstrapLoading.end();
+                    alert("与服务器通信发生错误");
+                    self.removeAttr('disabled');
+                    self.text('确定导入');
+                }
+            });
+        } catch(error) {
+            alert(error);
+        }
+    });
     // 导出数据
     $("#showArea").on("click", ".export", function () {
         let id = $(this).data("id");

+ 0 - 15
web/maintain/ration_repository/js/ration.js

@@ -95,7 +95,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');
@@ -626,20 +625,6 @@ let rationOprObj = {
         }
         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);

+ 11 - 29
web/maintain/ration_repository/js/ration_glj.js

@@ -25,7 +25,6 @@ var rationGLJOprObj = {
         }
     },
     getDistTypeTree: function (gljDistType) {
-        let me = this;
         let distType;
         let distTypeTree = {
             prefix : 'gljDistType',
@@ -61,36 +60,19 @@ 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 () {
-           // gljSelOprObj.getGljClassTree(pageOprObj.gljLibId, function () {
-                //gljSelOprObj.getSelGljItems(pageOprObj.gljLibId, 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();

+ 11 - 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 () {

+ 47 - 58
web/maintain/ration_repository/js/section_tree.js

@@ -8,42 +8,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 +228,30 @@ 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;
+        const $searchInput = $('#rationSearch');
+        if (hash) {
+            const rationCode = hash.replace('#', '');
+            $searchInput.val(rationCode);
+            this.locateToSection(rationCode);
+        }
     },
-    
     initTree: function (datas) {
         this.tree = idTree.createNew(this.setting.tree);
         this.tree.loadDatas(datas);
@@ -611,7 +597,7 @@ let sectionTreeObj = {
         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);
@@ -678,6 +664,7 @@ let sectionTreeObj = {
     locateToSection: function (rationCode) {
         let me = this;
         //去后台搜索该定额
+        $.bootstrapLoading.start();
         CommonAjax.post('/rationRepository/api/getRationItem', {rationLibId: pageOprObj.rationLibId, code: rationCode}, function (rstData) {
             if (!rstData) {
                 alert(`不存在定额${rationCode}`);
@@ -695,6 +682,7 @@ let sectionTreeObj = {
             let sectionRow = sectionNode.serialNo();
             me.sheet.setActiveCell(sectionRow, 1);
             me.sheet.showRow(sectionRow, GC.Spread.Sheets.VerticalPosition.top);
+            $.bootstrapLoading.end();
             let doAfterGetRation = function (rations) {
                 let findRation = _.find(rations, {code: rationCode}),
                     rIdx = rations.indexOf(findRation),
@@ -705,6 +693,7 @@ let sectionTreeObj = {
             };
             me.initSelection(sectionNode, doAfterGetRation);
         }, function () {
+            $.bootstrapLoading.end();
         });
     }
 };

+ 44 - 1
web/maintain/ration_repository/main.html

@@ -49,7 +49,19 @@
                   <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="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>定额库编码</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>
+                                <th width="90">补充模板</th>
+                            </tr>
+                        </thead>
                         <tbody id="showArea">
                         <% for(let lib of rationLibs){ %>
                         <tr id="<%= lib.ID %>">
@@ -70,6 +82,9 @@
                                 <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>
                             </td>
                             <td>
+                                <a class="btn btn-secondary btn-sm import-section" data-toggle="modal" data-target="#section" 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>
                             </td>
                         </tr>
@@ -274,6 +289,34 @@
             </div>
         </div>
     </div>
+    <!--导入章节树-->
+    <div class="modal fade" id="section" data-backdrop="static" style="display: none;" aria-hidden="true">
+        <div class="modal-dialog" role="document">
+            <div class="modal-content">
+                <div class="modal-header">
+                    <h5 class="modal-title">导入章节数据</h5>
+                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                        <span aria-hidden="true">×</span>
+                    </button>
+                </div>
+                <div class="modal-body">
+                    <div class="alert alert-warning" role="alert">
+                        导入操作会覆盖数据,请谨慎操作!!
+                    </div>
+                    <form>
+                        <div class="form-group">
+                            <label>请选择Excel格式文件</label>
+                            <input class="form-control-file" type="file" name="section_file" accept=".xlsx,.xls">
+                        </div>
+                    </form>
+                </div>
+                <div class="modal-footer">
+                    <button type="button" class="btn btn-primary" id="import-section-confirm">确定导入</button>
+                    <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
+                </div>
+            </div>
+        </div>
+    </div>
     <!--弹出设置模板-->
     <div class="modal fade" id="template" data-backdrop="static" style="display: none;" aria-hidden="true">
         <div class="modal-dialog" role="document">

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

@@ -276,4 +276,30 @@ 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;
 }

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

@@ -189,6 +189,22 @@
             </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>
     <!-- JS. -->
     <script src="/lib/jquery/jquery.min.js"></script>
     <script src="/lib/jquery-contextmenu/jquery.contextMenu.min.js"></script>

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

@@ -1100,7 +1100,7 @@ let repositoryGljObj = {
                     return {
                         callback: function(){},
                         items: {
-                            "delete": {
+                            delete: {
                                 name: "删除",
                                 disabled: function () {
                                     return !(me.currentCache && me.currentCache[target.row]);
@@ -1110,7 +1110,19 @@ let repositoryGljObj = {
                                     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);
+                                }
+                            },
                         }
                     };
                 }
@@ -1120,6 +1132,36 @@ 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}#${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();
+        });
+    },
     validUpdateObj: function (pasteObj, rowIdx) {
         let rst = {updateGlj: [], updateBasePrcArr: []}, backUpObj = {},
             me = repositoryGljObj,