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

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

zhangweicheng 7 лет назад
Родитель
Сommit
1942e67b08

Разница между файлами не показана из-за своего большого размера
+ 11 - 0
config/config.js


+ 23 - 0
modules/all_models/compleGlj_section.js

@@ -0,0 +1,23 @@
+'use strict';
+
+/**
+ *
+ *
+ * @author Zhong
+ * @date 2018/1/2
+ * @version
+ */
+
+import mongoose from 'mongoose';
+
+const Schema = mongoose.Schema;
+const compleGljSection = new Schema({
+    userId: String,
+    compilationId: String,
+    Name: String,
+    ID: String,
+    ParentID: String,
+    NextSiblingID: String,
+});
+
+mongoose.model('complementary_glj_section', compleGljSection, 'complementary_glj_section');

+ 30 - 0
modules/all_models/compleGlj_sectionTemplate.js

@@ -0,0 +1,30 @@
+'use strict';
+
+/**
+ *
+ *
+ * @author Zhong
+ * @date 2018/1/2
+ * @version
+ */
+
+/*
+ * 我的补充人材机库章节树模板,一个费用定额有一个模板
+ * 模板的生成目前由手工生成(借助定额库编辑器的章节树编辑)
+ * 新用户第一次进入某费用定额的补充定额库时,拷贝模板给该用户
+ *
+ * */
+
+import mongoose from 'mongoose';
+
+const Schema = mongoose.Schema;
+const compleGljSectionTemp = new Schema({
+    compilationId: String,
+    Name: String,
+    ID: Number,
+    ParentID: Number,
+    NextSiblingID: Number,
+});
+
+mongoose.model('complementary_glj_section_templates', compleGljSectionTemp, 'complementary_glj_section_templates');
+

+ 5 - 5
modules/all_models/comple_section_template.js

@@ -9,11 +9,11 @@
  */
 
 /*
-* 我的补充定额库章节树模板,一个费用定额有一个模板
-* 模板的生成目前由手工生成(借助定额库编辑器的章节树编辑)
-* 新用户第一次进入某费用定额的补充定额库时,拷贝模板给该用户
-*
-* */
+ * 我的补充定额库章节树模板,一个费用定额有一个模板
+ * 模板的生成目前由手工生成(借助定额库编辑器的章节树编辑)
+ * 新用户第一次进入某费用定额的补充定额库时,拷贝模板给该用户
+ *
+ * */
 
 import mongoose from 'mongoose';
 

+ 19 - 0
modules/ration_repository/controllers/ration_section_tree_controller.js

@@ -9,6 +9,25 @@ var callback = function(req,res,err,message, data){
 }
 
 class RationChapterTreeController extends BaseController{
+    //某费用定额下补充定额库章节树模板数据条数
+    async sectionTemplateCount(req, res) {
+        try {
+            let count = await rationChapterTreeData.sectionTemplateCount(req.params.compilationId);
+            callback(req, res, 0, 'success', {count});
+        } catch (err) {
+            callback(req, res, 1, err, {count: 0});
+        }
+    }
+    //将该标准定额库的章节树设置为该费用定额下补充定额章节树的模板
+    async initSectionTemplate(req, res) {
+        try {
+            let data = JSON.parse(req.body.data);
+            await rationChapterTreeData.initSectionTemplate(data.rationLibId, data.compilationId);
+            callback(req, res, 0, 'success', null);
+        } catch (err) {
+            callback(req, res, 1, err, null)
+        }
+    }
     getRationChapterTree(req,res){
         let data = JSON.parse(req.body.data);
         var rationLibId = data.rationLibId;

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

@@ -8,8 +8,30 @@ let counter = require('../../../public/counter/counter');
 let rationRepositoryDao = require('./repository_map');
 const rationChapterTreeModel = mongoose.model('std_ration_lib_ration_chapter_trees');
 const rationModel = mongoose.model('std_ration_lib_ration_items');
+const compleRationSectionTemp = mongoose.model('complementary_ration_section_templates');
 var rationChapterTreeDAO = function(){};
 
+rationChapterTreeDAO.prototype.sectionTemplateCount = async function (compilationId) {
+    return await compleRationSectionTemp.find({compilationId}).count();
+};
+
+rationChapterTreeDAO.prototype.initSectionTemplate = async function (rationLibId, compilationId) {
+    let sectionTempCount = await compleRationSectionTemp.find({compilationId}).count();
+    if (sectionTempCount > 0) {
+        await compleRationSectionTemp.remove({compilationId});
+    }
+    let bulks = [];
+    let stdRationSection = await rationChapterTreeModel.find({rationRepId: rationLibId});
+    for (let data of stdRationSection) {
+        delete data._doc._id;
+        data._doc.compilationId = compilationId;
+        bulks.push({insertOne: {document: data}});
+    }
+    if (bulks.length > 0) {
+        await compleRationSectionTemp.bulkWrite(bulks);
+    }
+};
+
 rationChapterTreeDAO.prototype.getRationChapterTree = function(rationLibId,callback){
     rationChapterTreeModel.find({"rationRepId": rationLibId, "$or": [{"isDeleted": null}, {"isDeleted": false} ]},function(err,data){
         if(data.length) callback(0,data);

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

@@ -32,8 +32,8 @@ module.exports =  function (app) {
 
     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);
+
     apiRouter.post("/getRationDisplayNames",rationRepositoryController.auth, rationRepositoryController.init, rationRepositoryController.getDisPlayRationLibs);
     apiRouter.post("/editRationLibs",rationRepositoryController.auth, rationRepositoryController.init, rationRepositoryController.updateRationRepositoryName);
     apiRouter.post("/addRationRepository",rationRepositoryController.auth, rationRepositoryController.init, rationRepositoryController.addRationRepository);
@@ -41,6 +41,8 @@ module.exports =  function (app) {
     apiRouter.post("/getRealLibName",rationRepositoryController.auth, rationRepositoryController.init, rationRepositoryController.getRealLibName);
     apiRouter.post("/getLibIDByName",rationRepositoryController.auth, rationRepositoryController.init, rationRepositoryController.getLibIDByName);
 
+    apiRouter.get('/sectionTemplateCount/:compilationId', rationChapterTreeController.auth, rationChapterTreeController.init, rationChapterTreeController.sectionTemplateCount);
+    apiRouter.post('/initSectionTemplate', rationChapterTreeController.auth, rationChapterTreeController.init, rationChapterTreeController.initSectionTemplate);
     apiRouter.post("/getRationTree",rationChapterTreeController.auth, rationChapterTreeController.init, rationChapterTreeController.getRationChapterTree);
     apiRouter.post("/getNewRationTreeID",rationChapterTreeController.auth, rationChapterTreeController.init, rationChapterTreeController.getNewRationTreeID);
     apiRouter.post("/createNewNode",rationChapterTreeController.auth, rationChapterTreeController.init, rationChapterTreeController.createNewNode);

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

@@ -11,6 +11,25 @@ let callback = function(req, res, err, message, data){
     res.json({error: err, message: message, data: data});
 };
 class GljMapController extends BaseController{
+    //该费用定额下补充人材机分类树模板数据条数
+    async classTemplateCount(req, res) {
+        try {
+            let count = await gljMapDao.classTemplateCount(req.params.compilationId);
+            callback(req, res, 0, 'success', {count});
+        } catch (err) {
+            callback(req, res, 1, err, {count: 0});
+        }
+    }
+    //将该标准人材机库的分类树设置为该费用定额下补充人材机分类树的模板
+    async initClassTemplate(req, res) {
+        try {
+            let data = JSON.parse(req.body.data);
+            await gljMapDao.initClassTemplate(data.gljLibId, data.compilationId);
+            callback(req, res, 0, 'success', null);
+        } catch (err) {
+            callback(req, res, 1, err, null);
+        }
+    }
     async getCompilationList(req, res){
         try{
             let compilationModel = new CompilationModel(), rst = [];

+ 21 - 29
modules/std_glj_lib/models/gljMapModel.js

@@ -5,9 +5,9 @@ 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 gljClassTemplateModel = mongoose.model('std_glj_lib_gljClassTemplate');
 const rationRepository = mongoose.model('std_ration_lib_map');
 const engLibModel = mongoose.model('engineering_lib');
+const compleGljClassTemp = mongoose.model('complementary_glj_section_templates');
 import moment from "moment";
 import counter from "../../../public/counter/counter";
 import async from "async";
@@ -121,34 +121,7 @@ class GljMapDao extends OprDao{
                         callback(err, '创建新工料机库失败!', null);
                     }
                     else{
-                        //创建分类模板
-                        gljClassTemplateModel.find({'$or': [{isDeleted: null}, {isDeleted: false}, {deleted: false}]}, function (err, datas) {
-                            if(err){
-                                callback(err, "获取工料机类型错误!", null);
-                            }
-                            else{
-                                let rst = [];
-                                async.each(datas, function (data, cb) {
-                                    let newClassObj = {};
-                                    newClassObj.ID = data.ID;
-                                    newClassObj.ParentID = data.ParentID;
-                                    newClassObj.NextSiblingID = data.NextSiblingID;
-                                    newClassObj.Name = data.Name;
-                                    newClassObj.repositoryId = newGljLib.ID;
-                                    newClassObj.deleted = false;
-                                    gljClassModel.create(newClassObj, function(err){
-                                        if(err)cb(err);
-                                        else{
-                                            rst.push(newClassObj);
-                                            cb(null);
-                                        }
-                                    });
-                                }, function (err) {
-                                    if(err) callback(err, "新增工料机类型错误!", null);
-                                    else callback(null, '创建成功', result);
-                                });
-                            }
-                        });
+                        callback(null, '创建成功', result);
                     }
                 });
             }
@@ -246,6 +219,25 @@ class GljMapDao extends OprDao{
             }
         });
     }
+    async classTemplateCount (compilationId) {
+        return await compleGljClassTemp.find({compilationId}).count();
+    }
+    async initClassTemplate (gljLibId, compilationId) {
+        let classTempCount = await compleGljClassTemp.find({compilationId}).count();
+        if (classTempCount > 0) {
+            await compleGljClassTemp.remove({compilationId});
+        }
+        let bulks = [];
+        let stdGljClass = await gljClassModel.find({repositoryId: gljLibId});
+        for (let data of stdGljClass) {
+            delete data._doc._id;
+            data._doc.compilationId = compilationId;
+            bulks.push({insertOne: {document: data}});
+        }
+        if (bulks.length > 0) {
+            await compleGljClassTemp.bulkWrite(bulks);
+        }
+    }
 }
 
 export {OprDao, GljMapDao};

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

@@ -5,7 +5,6 @@ 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 gljClassTemplateModel = mongoose.model('std_glj_lib_gljClassTemplate');
 const compilationModel = mongoose.model('compilation');
 const scMathUtil = require('../../../public/scMathUtil').getUtil();
 const rationModel = mongoose.model('std_ration_lib_ration_items');
@@ -15,48 +14,6 @@ import counter from "../../../public/counter/counter";
 import async from "async";
 
 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);
-            }
-        }
-        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++);
-        }
-        await gljModel.remove({ID: {$in: gljIDs}});
-        console.log('end');
-
-    }
-    //test
     getGljTypes (gljLibId, callback){
         gljClassModel.find({"repositoryId": gljLibId, "$or": [{"isDeleted": null}, {"isDeleted": false}, {deleted: false} ]},function(err,data){
             if(err) callback("获取工料机类型错误!",false)

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

@@ -17,6 +17,8 @@ module.exports = function (app) {
     app.get('/stdGljRepository/main', viewsController.auth, viewsController.init, viewsController.redirectMain);
     app.get('/stdGljRepository/glj', viewsController.auth, viewsController.init, viewsController.redirectGlj);
 
+    router.get('/classTemplateCount/:compilationId', gljMapController.auth, gljMapController.init, gljMapController.classTemplateCount);
+    router.post('/initClassTemplate', gljMapController.auth, gljMapController.init, gljMapController.initClassTemplate);
     router.post('/getCompilationList', gljMapController.auth, gljMapController.init, gljMapController.getCompilationList);
     router.post('/getGljLib', gljMapController.auth, gljMapController.init, gljMapController.getGljLib);
     router.post('/getAllGljLib', gljMapController.auth, gljMapController.init, gljMapController.getAllGljLib);

+ 1 - 1
web/maintain/billsGuidance_lib/js/billsGuidance.js

@@ -882,7 +882,7 @@ const billsGuidance = (function () {
         });
     }
     //编辑后自动去除换行符回车符
-    const deESC = /[\r, \n]/g;
+    const deESC = /[\n]/g;
     //项目指引编辑
     //@param {Object}sheet {Array}cells
     function edit(sheet, cells){

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

@@ -6,6 +6,8 @@ $(function () {
     let dispNameArr;
     let preDeleteId = null;
     let deleteCount = 0;
+    let selCompilationId,
+        compilationsArr = [];
     $('#del').on('hidden.bs.modal', function () {
         deleteCount = 0;
     });
@@ -124,7 +126,9 @@ $(function () {
         });
 
     });
-    getCompilationList();
+    getCompilationList(function (data) {
+        compilationsArr = data.compilation;
+    });
 
     // 导入原始数据按钮
     let rationRepId = 0;
@@ -216,6 +220,46 @@ $(function () {
         }
         window.location.href = '/rationRepository/api/export?rationRepId=' + id;
     });
+
+    //设置补充定额库章节树模板
+    $("#showArea").on("click", ".set-comple", function () {
+        let id = $(this).data("id");
+        id = parseInt(id);
+        if (isNaN(id) || id <= 0) {
+            return false;
+        }
+        rationRepId = id;
+        $('#templateA').addClass('disabled');
+        $('#template').modal('show');
+        $('#compilations').empty();
+        for (let data of compilationsArr) {
+            let $opt = $(`<option value="${data._id}">${data.name}</option>`);
+            $('#compilations').append($opt);
+        }
+        $('#compilations').change();
+    });
+    $('#compilations').change(function () {
+        selCompilationId = $(this).select().val();
+        CommonAjax.get(`api/sectionTemplateCount/${selCompilationId}`, function (rstData) {
+            rstData.data.count > 0 ?
+                $('#templateText').text('该费用定额下已有定额章节树模板数据,是否确认覆盖数据?') :
+                $('#templateText').text('确认是否将此库的章节树设置成该费用定额下补充定额章节树模板?');
+            $('#templateA').removeClass('disabled');
+        });
+    });
+    $('#templateA').click(function () {
+        if (rationRepId <= 0 && selCompilationId) {
+            return false;
+        }
+        $.bootstrapLoading.start();
+        CommonAjax.post('api/initSectionTemplate', {rationLibId: rationRepId, compilationId: selCompilationId}, function () {
+            $.bootstrapLoading.end();
+            $('#template').modal('hide');
+        }, function () {
+            $.bootstrapLoading.end();
+            $('#template').modal('hide');
+        });
+    });
 });
 
 function getAllRationLib(callback){
@@ -248,6 +292,7 @@ function getAllRationLib(callback){
                         "<td><a class='btn btn-secondary btn-sm import-source' 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-success btn-sm export' href='javacript:void(0);' data-toggle='modal' data-id='"+ 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='"+ 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>" +
                         "</tr>");
                     $("#tempId").attr("id", id);
                 }
@@ -256,13 +301,12 @@ function getAllRationLib(callback){
         }
     });
 }
-function getCompilationList(){
+function getCompilationList(callback){
     $.ajax({
         type: 'post',
         url: 'api/getCompilationList',
         dataType: 'json',
         success: function (result) {
-            console.log(result);
             //addoptions
             for(let i = 0; i < result.data.compilation.length; i++){
                 let $option =  $("<option >"+ result.data.compilation[i].name +"</option>");
@@ -274,7 +318,6 @@ function getCompilationList(){
                 let compilationId = result.data.compilation[0]._id;
                 //console.log(compilationId);
                 let gljLibOps = getGljLibOps(compilationId, result.data.gljLibs);
-                console.log(gljLibOps);
                 for(let i = 0; i < gljLibOps.length; i++){
                     let $option =  $("<option >"+ gljLibOps[i].dispName +"</option>");
                     $option.val(gljLibOps[i].ID);
@@ -292,6 +335,7 @@ function getCompilationList(){
                     $('#gljLibSels').append($option);
                 }
             });
+            callback(result.data);
         }
     });
 }
@@ -336,6 +380,7 @@ function createRationLib(rationObj, dispNamesArr){
                     "<td><a class='btn btn-secondary btn-sm import-source' 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-success btn-sm export' href='javacript:void(0);' data-toggle='modal' data-id='"+ 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='"+ 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>" +
                     "</tr>");
                 $("#tempId").attr("id", id);
             }

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

@@ -35,7 +35,7 @@
                   <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></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">
                         </tbody>
                       </table>
@@ -86,7 +86,7 @@
                             <input id="libNameTxt" class="form-control" placeholder="输入定额库名称" type="text">
                         </div>
                         <div class="form-group">
-                            <label>编办名称</label>
+                            <label>费用定额名称</label>
                             <select id="compilationSels" class="form-control"></select>
                         </div>
                         <div class="form-group">
@@ -229,6 +229,30 @@
             </div>
         </div>
     </div>
+    <!--弹出设置模板-->
+    <div class="modal fade" id="template" data-backdrop="static" style="display: none;" aria-hidden="true">
+        <div class="modal-dialog" role="document">
+            <div class="modal-content">
+                <div class="modal-header">
+                    <h5 class="modal-title">设置确认</h5>
+                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                        <span aria-hidden="true">×</span>
+                    </button>
+                </div>
+                <div class="modal-body">
+                    <h5 id="templateText">确认是否将此库的章节树设置成该费用定额下补充定额章节树模板?</h5>
+                    <div class="form-group">
+                        <label>费用定额名称</label>
+                        <select id="compilations" class="form-control"></select>
+                    </div>
+                </div>
+                <div class="modal-footer">
+                    <a id="templateA" href="javascript: void(0);" class="btn btn-primary">确认</a>
+                    <button id="templateCancel" 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>

+ 27 - 3
web/maintain/std_glj_lib/html/main.html

@@ -33,7 +33,7 @@
                   <div class="col-md-8">
                     <div class="warp-p2 mt-3">
                       <table class="table table-hover table-bordered">
-                        <thead><tr><th>人材机库名称</th><th>编办</th><th>定额库</th><th width="160">添加时间</th><th width="90">操作</th><th width="90">价格数据</th></tr></thead>
+                        <thead><tr><th>人材机库名称</th><th>费用定额</th><th>定额库</th><th width="160">添加时间</th><th width="90">操作</th><th width="90">价格数据</th><th width="90">补充模板</th></tr></thead>
                         <tbody id="showArea">
                       <!--    <tr><td><a href="gongliao.html">XX工料机库</a></td><td>重庆2018</td><td>XXX定额库(重庆2018)</td><td>2017-01-01 </td><td><a href="javacript:void(0);" data-toggle="modal" data-target="#edit" title="编辑"><i class="fa fa-pencil-square-o"></i></a> <a href="javacript:void(0);" data-toggle="modal" data-target="#del" class="text-danger" title="删除"><i class="fa fa-remove"></i></a></td></tr>
                           <tr><td><a href="gongliao.html">XX工料机库</a></td><td>重庆2018</td><td></td><td>2017-01-01 </td><td><a href="javacript:void(0);" data-toggle="modal" data-target="#edit" title="编辑"><i class="fa fa-pencil-square-o"></i></a> <a href="javacript:void(0);" data-toggle="modal" data-target="#del" class="text-danger" title="删除"><i class="fa fa-remove"></i></a></td></tr>
@@ -63,7 +63,7 @@
                       <input id="libNameTxt" class="form-control" placeholder="输入人材机库名称" type="text">
                     </div>
                     <div class="form-group">
-                      <label>编办名称</label>
+                      <label>费用定额名称</label>
                       <select id="compilationSels" class="form-control"></select>
                     </div>
                   </form>
@@ -92,7 +92,7 @@
                       <input class="form-control" id="renameText" placeholder="输入人材机库名称" type="text" value="">
                     </div>
                     <div class="form-group">
-                      <label>编办名称</label>
+                      <label>费用定额名称</label>
                       <select id="compilationEdit" class="form-control" disabled><option></option></select>
                     </div>
                   </form>
@@ -153,6 +153,30 @@
             </div>
         </div>
     </div>
+    <!--弹出设置模板-->
+    <div class="modal fade" id="template" data-backdrop="static" style="display: none;" aria-hidden="true">
+        <div class="modal-dialog" role="document">
+            <div class="modal-content">
+                <div class="modal-header">
+                    <h5 class="modal-title">设置确认</h5>
+                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                        <span aria-hidden="true">×</span>
+                    </button>
+                </div>
+                <div class="modal-body">
+                    <h5 id="templateText">确认是否将此库的分类树设置成该费用定额下补充人材机分类树模板?</h5>
+                    <div class="form-group">
+                        <label>费用定额名称</label>
+                        <select id="compilations" class="form-control"></select>
+                    </div>
+                </div>
+                <div class="modal-footer">
+                    <a id="templateA" href="javascript: void(0);" class="btn btn-primary">确认</a>
+                    <button id="templateCancel" 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>

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

@@ -1480,6 +1480,8 @@ let repositoryGljObj = {
         }
         if (updateArr.length > 0 || addArr.length > 0) {
             me.mixUpdateRequest(updateArr, addArr, []);
+        } else {
+            $.bootstrapLoading.end();
         }
         if(updateBasePrcArr.length > 0 && me.rationLibs.length > 0){
             me.updateRationBasePrcRq(updateBasePrcArr);
@@ -1488,7 +1490,9 @@ let repositoryGljObj = {
     updateRationBasePrcRq: function (basePrcArr, workBook, callback) {
         let me = this;
         me.prevent = true;
-        $.bootstrapLoading.start();
+        if (!$.bootstrapLoading.isLoading()) {
+            $.bootstrapLoading.start();
+        }
         $.ajax({
             type: 'post',
             url: 'api/updateRationBasePrc',
@@ -1508,7 +1512,9 @@ let repositoryGljObj = {
                 if(callback){
                     callback();
                 }
-                $.bootstrapLoading.end();
+                if ($.bootstrapLoading.isLoading()) {
+                    $.bootstrapLoading.end();
+                }
             }
         });
     },

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

@@ -7,6 +7,7 @@ $(function () {
     let usedCom;
     let deleteCount = 0;
     let preDeleteId = null;
+    let selCompilationId;
     $('#del').on('hidden.bs.modal', function () {
         deleteCount = 0;
     });
@@ -186,6 +187,45 @@ $(function () {
             $.bootstrapLoading.end();
         }
     });
+    //设置补充人材机库分类树模板
+    $("#showArea").on("click", ".set-comple", function () {
+        let id = $(this).data("id");
+        id = parseInt(id);
+        if (isNaN(id) || id <= 0) {
+            return false;
+        }
+        selLibId = id;
+        $('#templateA').addClass('disabled');
+        $('#template').modal('show');
+        $('#compilations').empty();
+        for (let data of compilationsArr) {
+            let $opt = $(`<option value="${data._id}">${data.name}</option>`);
+            $('#compilations').append($opt);
+        }
+        $('#compilations').change();
+    });
+    $('#compilations').change(function () {
+        selCompilationId = $(this).select().val();
+        CommonAjax.get(`api/classTemplateCount/${selCompilationId}`, function (rstData) {
+            rstData.data.count > 0 ?
+                $('#templateText').text('该费用定额下已有人材机分类树模板数据,是否确认覆盖数据?') :
+                $('#templateText').text('确认是否将此库的分类树设置成该费用定额下补充人材机分类树模板?');
+            $('#templateA').removeClass('disabled');
+        });
+    });
+    $('#templateA').click(function () {
+        if (selLibId <= 0 && selCompilationId) {
+            return false;
+        }
+        $.bootstrapLoading.start();
+        CommonAjax.post('api/initClassTemplate', {gljLibId: selLibId, compilationId: selCompilationId}, function () {
+            $.bootstrapLoading.end();
+            $('#template').modal('hide');
+        }, function () {
+            $.bootstrapLoading.end();
+            $('#template').modal('hide');
+        });
+    });
 });
 
 function getAllGljLib(callback){
@@ -203,6 +243,7 @@ function getAllGljLib(callback){
                     let libName = result.data[i].dispName;
                     let createDate = result.data[i].createDate.split(' ')[0];
                     let compilationName = result.data[i].compilationName;
+                    let compilationId = result.data[i].compilationId;
                     let rationLibs = result.data[i].rationLibs;
                     let rationLibsName = '';
                     for(let j = 0; j < rationLibs.length; j++){
@@ -210,7 +251,7 @@ function getAllGljLib(callback){
                     }
                     dispNames.push(result.data[i].dispName);
                     $("#showArea").append(
-                        "<tr id='tempId'>" +
+                        "<tr id='tempId' data-compilationId='"+ compilationId + "'>" +
                         "<td><a href='/stdGljRepository/glj'>"+libName+"</a></td>" +
                         "<td>"+compilationName+" </td>" +
                         "<td>"+rationLibsName+" </td>" +
@@ -219,6 +260,7 @@ function getAllGljLib(callback){
                         "<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 set-comple' href='javacript:void(0);' data-id='"+ id +"' title='将分类树设为补充模板数据'><i class='fa fa-sign-in fa-rotate-90'></i>设置</a></td>" +
                         "</tr>");
                     var newHref = "/stdGljRepository/glj?gljLibId="+id;
                     $("#tempId td:first a").attr("href", newHref);
@@ -262,7 +304,7 @@ function createGljLib(gljLibObj, dispNamesArr, usedCom){
                 dispNamesArr.push(libName);
                 usedCom.push(gljLibObj.compilationId);
                 $("#showArea").append(
-                    "<tr id='tempId'>" +
+                    "<tr id='tempId' data-compilationId='"+ gljLibObj.compilationId + "'>" +
                     "<td><a href='/stdGljRepository/glj'>"+libName+"</a></td>" +
                     "<td>"+compilationName+" </td>" +
                     "<td>"+''+" </td>" +
@@ -271,6 +313,7 @@ function createGljLib(gljLibObj, dispNamesArr, usedCom){
                     "<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 set-comple' href='javacript:void(0);' data-id='"+ id +"' title='将分类树设为补充模板数据'><i class='fa fa-sign-in fa-rotate-90'></i>设置</a></td>" +
                     "</tr>");
                 var newHref = "/stdGljRepository/glj?gljLibId="+id;
                 $("#tempId td:first a").attr("href", newHref);