瀏覽代碼

1.编办信息添加序号。2.编办列表按照序号进行排序

lishihao 1 年之前
父節點
當前提交
5a9f934528

+ 2 - 0
modules/all_models/compilation.js

@@ -78,6 +78,8 @@ let modelSchema = {
     example: Array,
     // 版本号
     edition: String,
+    // 序号(用于排序)
+    serialNumber: Number,
     // 发布时间
     release_time: {
         type: Number,

+ 12 - 0
modules/users/controllers/compilation_controller.js

@@ -820,6 +820,18 @@ class CompilationController extends BaseController {
             response.json({err: 1, msg: err, data: null});
         }
     }
+    async setSerialNumber(request, response) {
+        let compilationId = request.body.id;
+        let serialNumber = request.body.serialNumber;
+        try {
+            let compilationModel = new CompilationModel();
+            await compilationModel.setSerialNumber(compilationId, serialNumber);
+            response.json({ err: 0, msg: '', data: null });
+        }
+        catch (err) {
+            response.json({ err: 1, msg: err, data: null });
+        }
+    }
 }
 
 export default CompilationController;

+ 70 - 51
modules/users/models/compilation_model.js

@@ -7,7 +7,7 @@
  */
 import mongoose from "mongoose";
 import BaseModel from "../../common/base/base_model";
-import  uuidV1  from 'uuid/v1';
+import uuidV1 from 'uuid/v1';
 
 class CompilationModel extends BaseModel {
 
@@ -36,7 +36,8 @@ class CompilationModel extends BaseModel {
      */
     async getCompilationList(fields = null) {
         // 筛选字段
-        let field = fields == null ? {_id: 1, name: 1, is_release: 1,release_time:1, defaultLocation:1,categoryID: 1, description: 1,overWriteUrl: 1,example: 1,edition: 1,freeUse:1,
+        let field = fields == null ? {
+            _id: 1, name: 1, is_release: 1, release_time: 1, defaultLocation: 1, categoryID: 1, description: 1, overWriteUrl: 1, example: 1, edition: 1, freeUse: 1,
             "ration_valuation.id": 1, "ration_valuation.name": 1, "ration_valuation.enable": 1,
             "suggestion_valuation.id": 1, "suggestion_valuation.name": 1, "suggestion_valuation.enable": 1,
             "feasibility_valuation.id": 1, "feasibility_valuation.name": 1, "feasibility_valuation.enable": 1,
@@ -44,10 +45,18 @@ class CompilationModel extends BaseModel {
             "bill_valuation.id": 1, "bill_valuation.name": 1, "bill_valuation.enable": 1,
             "estimation_valuation.id": 1, "estimation_valuation.name": 1, "estimation_valuation.enable": 1,
             "bill_valuation.fileTypes": 1
-            } : fields;
-        let compilationData = await this.findDataByCondition({name: {$ne: ''}}, field, false);
-
-        return compilationData === null ? [] : compilationData;
+        } : fields;
+        // 一定要查询序号,然后排序输出
+        field.serialNumber = 1;
+        let compilationData = await this.findDataByCondition({ name: { $ne: '' } }, field, false);
+        if (compilationData) {
+            // 按照序号排序
+            compilationData.sort((aa, bb) => {
+                return (aa.serialNumber || 99999) - (bb.serialNumber || 99999);
+            });
+            return compilationData;
+        }
+        return [];
     }
 
     /**
@@ -57,8 +66,8 @@ class CompilationModel extends BaseModel {
      */
     async getList() {
         // 筛选字段
-        let field = {_id: 1, name: 1, is_release: 1, description: 1, categoryID: 1};
-        let compilationData = await this.findDataByCondition({name: {$ne: ''}, is_release: true}, field, false);
+        let field = { _id: 1, name: 1, is_release: 1, description: 1, categoryID: 1 };
+        let compilationData = await this.findDataByCondition({ name: { $ne: '' }, is_release: true }, field, false);
 
         return compilationData === null ? [] : compilationData;
     }
@@ -70,9 +79,9 @@ class CompilationModel extends BaseModel {
      * @return {Promise}
      */
     async getCompilationById(id) {
-        let condition = {_id: id, is_release: true};
+        let condition = { _id: id, is_release: true };
         let compilationData = await this.findDataByCondition(condition);
-        if (!compilationData  || compilationData.bill_valuation === undefined) {
+        if (!compilationData || compilationData.bill_valuation === undefined) {
             return compilationData;
         }
 
@@ -141,14 +150,14 @@ class CompilationModel extends BaseModel {
     * @param {String} description
     * @return {Promise}
     * */
-    async setDescription(compilationId, description){
-        return await this.updateById(compilationId, {description: description});
+    async setDescription(compilationId, description) {
+        return await this.updateById(compilationId, { description: description });
     }
     /*
         设置代码覆盖路径
      */
-    async setOverWriteUrl(compilationId, overWriteUrl, priceProp, consumeAmtProp){
-        return await this.updateById(compilationId, {overWriteUrl: overWriteUrl, priceProperties: priceProp, consumeAmtProperties: consumeAmtProp});
+    async setOverWriteUrl(compilationId, overWriteUrl, priceProp, consumeAmtProp) {
+        return await this.updateById(compilationId, { overWriteUrl: overWriteUrl, priceProperties: priceProp, consumeAmtProperties: consumeAmtProp });
     }
 
     /*
@@ -164,7 +173,7 @@ class CompilationModel extends BaseModel {
                 data.push(parseInt(projId));
             }
         }
-        return await this.updateById(compilationId, {example: data});
+        return await this.updateById(compilationId, { example: data });
     }
 
     /**
@@ -176,7 +185,7 @@ class CompilationModel extends BaseModel {
      * @return {Promise}
      */
     async addValuation(id, section, data) {
-        let condition = {_id: id};
+        let condition = { _id: id };
         let compilationData = await this.findDataByCondition(condition);
         if (compilationData === null || compilationData.name === undefined) {
             throw '没有找到对应的数据';
@@ -240,7 +249,7 @@ class CompilationModel extends BaseModel {
         return result !== null && result.ok === 1;
     }
 
- 
+
     /**
      * 设置计价规则适用类型
      *
@@ -249,7 +258,7 @@ class CompilationModel extends BaseModel {
      * @param {String} setFileTypes
      * @return {Promise}
      */
-     async setFileTypes(valuationId, section, fileTypes) {
+    async setFileTypes(valuationId, section, fileTypes) {
         let sectionString = section + "_valuation";
         let condition = {};
         condition[sectionString + ".id"] = valuationId;
@@ -299,14 +308,14 @@ class CompilationModel extends BaseModel {
         if (this.sectionList.indexOf(section) < 0) {
             throw '数据有误';
         }
-        let compilationData = await this.findDataByCondition({_id: compilationId});
+        let compilationData = await this.findDataByCondition({ _id: compilationId });
         if (Object.keys(compilationData).length <= 0) {
             throw '编办数据有误';
         }
         let result = {};
         let sectionString = section + '_valuation';
 
-        for(let valuation of compilationData[sectionString]) {
+        for (let valuation of compilationData[sectionString]) {
             if (valuation.id.toString() === id) {
                 result = valuation;
                 break;
@@ -334,10 +343,10 @@ class CompilationModel extends BaseModel {
      * @return {Promise}
      */
     async deleteValuation(compilationId, valuationId, section) {
-        let condition = {_id: compilationId};
+        let condition = { _id: compilationId };
         let sectionString = section + '_valuation';
         let deleteData = {};
-        deleteData[sectionString] = {id: valuationId};
+        deleteData[sectionString] = { id: valuationId };
 
         // 利用pull删除嵌套数据
         let result = await this.db.deleteSet(condition, deleteData);
@@ -355,7 +364,7 @@ class CompilationModel extends BaseModel {
     async release(id, status) {
         // 如果是发布编办则需要判断配置的内容是否满足发布条件
         if (status) {
-            let compilationData = await this.findDataByCondition({_id: id});
+            let compilationData = await this.findDataByCondition({ _id: id });
             // 最少需要有一个计价规则存在
             if (compilationData.suggestion_valuation.length <= 0 &&
                 compilationData.feasibility_valuation.length <= 0 &&
@@ -405,8 +414,8 @@ class CompilationModel extends BaseModel {
             throw '不存在对应编办';
         }
         let valuationData = null;
-        for(let valuation of compilationData[sectionString]) {
-            if(valuation.id === valuationId) {
+        for (let valuation of compilationData[sectionString]) {
+            if (valuation.id === valuationId) {
                 valuationData = valuation;
             }
         }
@@ -418,7 +427,7 @@ class CompilationModel extends BaseModel {
         // 判断是否已有对应数据
         let engineeringList = valuationData.engineering_list;
         let engineeringLib = null;
-        for(let tmpEngineering of engineeringList) {
+        for (let tmpEngineering of engineeringList) {
             if (tmpEngineering.engineering === engineering) {
                 engineeringLib = tmpEngineering;
                 break;
@@ -456,42 +465,52 @@ class CompilationModel extends BaseModel {
      * @return {Promise}
      * */
     async updateCategory(compilationId, category) {
-        return await this.updateById(compilationId, {categoryID: category});
+        return await this.updateById(compilationId, { categoryID: category });
     }
 
-     /*
-     * 设置工程默认所在地
-     *
-     * @param {String} compilationId
-     * @param {int} location
-     * @return {Promise}
-     * */
+    /*
+    * 设置工程默认所在地
+    *
+    * @param {String} compilationId
+    * @param {int} location
+    * @return {Promise}
+    * */
     async updateLocation(compilationId, location) {
-        return await this.updateById(compilationId, {defaultLocation: location});
+        return await this.updateById(compilationId, { defaultLocation: location });
     }
 
-     /*
-     * 设置是否提供免费版
-     *
-     * @param {String} compilationId
-     * @param {int} location
-     * @return {Promise}
-     * */
-     async updateFreeUse(compilationId, freeUse) {
-        return await this.updateById(compilationId, {freeUse: freeUse});
+    /*
+    * 设置是否提供免费版
+    *
+    * @param {String} compilationId
+    * @param {int} location
+    * @return {Promise}
+    * */
+    async updateFreeUse(compilationId, freeUse) {
+        return await this.updateById(compilationId, { freeUse: freeUse });
+    }
+
+    /*
+      * 设置版本号
+      *
+      * @param {String} compilationId
+      * @param {String} edition
+      * @return {Promise}
+      * */
+    async setEdition(compilationId, edition) {
+        return await this.updateById(compilationId, { edition: edition });
     }
 
-  /*
-    * 设置版本号
+    /*
+    * 设置
     *
     * @param {String} compilationId
-    * @param {String} edition
+    * @param {Number} serialNumber
     * @return {Promise}
     * */
-  async setEdition(compilationId, edition){
-    return await this.updateById(compilationId, {edition: edition});
-   }
-
+    async setSerialNumber(compilationId, serialNumber) {
+        return await this.updateById(compilationId, { serialNumber: serialNumber });
+    }
 }
 
 export default CompilationModel;

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

@@ -38,5 +38,6 @@ module.exports = function (app) {
     router.post('/changeLocation', compilationController.auth, compilationController.init, compilationController.changeLocation);
     router.post('/changeFreeUse', compilationController.auth, compilationController.init, compilationController.changeFreeUse);
     router.post('/setEdition', compilationController.auth, compilationController.init, compilationController.setEdition);
+    router.post('/setSerialNumber', compilationController.auth, compilationController.init, compilationController.setSerialNumber);
     app.use("/compilation", router);
 };

+ 236 - 220
web/users/js/compilation.js

@@ -18,7 +18,7 @@ function delayKeyup(callback) {
     }, delayTime);
 }
 
-$(document).ready(function() {
+$(document).ready(function () {
     let isAdding = false;
     let model = '';
     let section = $(".nav-tabs li.active > a").text() === '建议估算' ? 'suggestion' : 'bill';
@@ -30,12 +30,12 @@ $(document).ready(function() {
     }
 
     // 计价类型选择
-    $(".nav-tabs li > a").click(function() {
+    $(".nav-tabs li > a").click(function () {
         section = $(this).attr("aria-controls");
     });
 
     // 新增编办
-    $("#add-compilation").click(function() {
+    $("#add-compilation").click(function () {
         try {
             let data = getAndValidData(model);
             let url = '/compilation/add'
@@ -44,14 +44,14 @@ $(document).ready(function() {
                 $.ajax({
                     url: url,
                     type: 'post',
-                    data: {name: data.name},
-                    error: function() {
+                    data: { name: data.name },
+                    error: function () {
                         isAdding = false;
                     },
-                    beforeSend: function() {
+                    beforeSend: function () {
                         isAdding = true;
                     },
-                    success: function(response) {
+                    success: function (response) {
                         isAdding = false;
                         if (response.err === 0) {
                             window.location.reload();
@@ -68,15 +68,15 @@ $(document).ready(function() {
                     id: data[model].id
                 };
                 // 判断是否有重复的数据
-                if ($("input:hidden[name='"+ model +"_lib'][data-id='"+ addLib.id +"']").length > 0) {
+                if ($("input:hidden[name='" + model + "_lib'][data-id='" + addLib.id + "']").length > 0) {
                     alert('重复添加数据!');
                     return false;
                 }
 
-                let removeHtml = '<a class="pull-right text-danger remove-lib" data-model="'+model+'" ' +
+                let removeHtml = '<a class="pull-right text-danger remove-lib" data-model="' + model + '" ' +
                     'title="移除"><span class="glyphicon glyphicon-remove"></span></a>';
                 let tmpHtml = '<p class="form-control-static">' + removeHtml + addLib.name +
-                    '<input type="hidden" data-id="'+ addLib.id +'" name=\'' + model + '_lib\' value=\'' + JSON.stringify(addLib) + '\'>' + '</p>';
+                    '<input type="hidden" data-id="' + addLib.id + '" name=\'' + model + '_lib\' value=\'' + JSON.stringify(addLib) + '\'>' + '</p>';
                 $("." + model + "-list").append(tmpHtml);
                 $('#addcompilation').modal('hide');
             }
@@ -96,37 +96,37 @@ $(document).ready(function() {
     });
 
     //新增计税组合
-    $("#add-group").click(function() {
-        let taxMap = {"1":"一般计税","2":"简易计税" };
+    $("#add-group").click(function () {
+        let taxMap = { "1": "一般计税", "2": "简易计税" };
         let actionType = $('#groupEditType').val();
         let groupData = getTaxGroupData();
         let groupIndex = getGroupIndex(groupData);//用来做重复判断
-        if(!_.isEmpty(groupData)){
+        if (!_.isEmpty(groupData)) {
             //重复判断 todo
-            if($("input[data-id = "+groupIndex+"]").length <= 0){
-                let taxName = groupData.taxType?taxMap[groupData.taxType]:'';
-                let p_name = groupData.program_lib?groupData.program_lib.displayName:"";
-                let t_name = groupData.template_lib?groupData.template_lib.name:"";
-                let c_name = groupData.col_lib?groupData.col_lib.name:"";
-                let f_name = groupData.fee_lib?groupData.fee_lib.name:"";
-                let htmlString = "<tr class='taxGroup_tr'><td><span>"+taxName+"</span></td>" +
-                    "<td><span>"+p_name+"</span></td>" +
-                    "<td><span>"+t_name+"</span></td>" +
-                    "<td><span>"+c_name+"</span></td>" +
-                    "<td><span>"+f_name+"</span></td>" +
+            if ($("input[data-id = " + groupIndex + "]").length <= 0) {
+                let taxName = groupData.taxType ? taxMap[groupData.taxType] : '';
+                let p_name = groupData.program_lib ? groupData.program_lib.displayName : "";
+                let t_name = groupData.template_lib ? groupData.template_lib.name : "";
+                let c_name = groupData.col_lib ? groupData.col_lib.name : "";
+                let f_name = groupData.fee_lib ? groupData.fee_lib.name : "";
+                let htmlString = "<tr class='taxGroup_tr'><td><span>" + taxName + "</span></td>" +
+                    "<td><span>" + p_name + "</span></td>" +
+                    "<td><span>" + t_name + "</span></td>" +
+                    "<td><span>" + c_name + "</span></td>" +
+                    "<td><span>" + f_name + "</span></td>" +
                     "<td> <a class='btn btn-link btn-sm' style='padding: 0px' onclick='editTaxGroup(this)'> 编辑</a>/<a class='btn btn-link btn-sm ' style='padding: 0px' onclick='deleteTableTr(this,\"taxGroup_tr\")'>删除</a> " +
-                    "<input type='hidden' name='tax_group' data-id ='"+groupIndex+"' value='"+JSON.stringify(groupData)+"'>"+
+                    "<input type='hidden' name='tax_group' data-id ='" + groupIndex + "' value='" + JSON.stringify(groupData) + "'>" +
                     "</td>" +
                     "</tr>";
-                if(actionType == "add"){
+                if (actionType == "add") {
                     $("#tax_group_tbody").append(htmlString);
-                }else if(actionType == "modify"){
+                } else if (actionType == "modify") {
                     let oldIndex = $("#groupIndex").val();
-                    let parentTr = $("input[data-id = "+oldIndex+"]").parents(".taxGroup_tr");
+                    let parentTr = $("input[data-id = " + oldIndex + "]").parents(".taxGroup_tr");
                     parentTr.after(htmlString);
                     parentTr.remove();
                 }
-            }else {
+            } else {
                 alert("已存在相同的组合!");
             }
         }
@@ -240,12 +240,12 @@ $(document).ready(function() {
         $(this).removeClass('highlight');
         $(this).after($(dragged));
     });
-    
+
 
 
 
     // 新增计价规则
-    $("#add-valuation").click(function() {
+    $("#add-valuation").click(function () {
         try {
             if (id === '') {
                 throw '页面数据有误';
@@ -258,14 +258,14 @@ $(document).ready(function() {
             $.ajax({
                 url: '/compilation/add-valuation',
                 type: 'post',
-                data: {name: name, id: id, section: section},
-                error: function() {
+                data: { name: name, id: id, section: section },
+                error: function () {
                     isAdding = false;
                 },
-                beforeSend: function() {
+                beforeSend: function () {
                     isAdding = true;
                 },
-                success: function(response) {
+                success: function (response) {
                     isAdding = false;
                     if (response.err === 0) {
                         window.location.reload();
@@ -282,7 +282,7 @@ $(document).ready(function() {
     });
 
     // 添加
-    $(".add-compilation").click(function() {
+    $(".add-compilation").click(function () {
         model = $(this).data('model');
         $("#addcompilation .modal-body > div").hide();
         switch (model) {
@@ -337,25 +337,25 @@ $(document).ready(function() {
             case 'billCode':
                 $("#billCode-area").show();
                 $("#add-compilation-title").text('添加递延清单库');
-                break;    
+                break;
         }
 
         $("#addcompilation").modal('show');
     });
 
     // 保存专业工程标准库
-    $("#save-lib").click(function() {
+    $("#save-lib").click(function () {
         if (validLib()) {
             $("form").submit();
         }
     });
     // 保存计价规则
-    $("#save-valuation").click(function() {
+    $("#save-valuation").click(function () {
         $("#saveValuation").submit();
     });
 
     // 移除操作
-    $(".bill-list, .ration-list, .glj-list, .fee-list, .artificial-list, .program-list, .billsGuidance-list,.feature-list,.info-list,.progressive-list,.vvTax-list,.billCode-list").on("click", ".remove-lib", function() {
+    $(".bill-list, .ration-list, .glj-list, .fee-list, .artificial-list, .program-list, .billsGuidance-list,.feature-list,.info-list,.progressive-list,.vvTax-list,.billCode-list").on("click", ".remove-lib", function () {
         $(this).parent().remove();
     });
 
@@ -366,8 +366,8 @@ $(document).ready(function() {
             url: '/compilation/setDescription',
             type: 'post',
             dataType: "json",
-            data: {id: id, description: description},
-            success: function(response) {
+            data: { id: id, description: description },
+            success: function (response) {
                 if (response.err !== 0) {
                     alert('更改失败');
                 }
@@ -378,13 +378,13 @@ $(document).ready(function() {
     //更改代码覆盖路径
     $('#overWriteUrl').change(function () {
         let overWriteUrl = $(this).val();
-        if(overWriteUrl=="") overWriteUrl = undefined;
+        if (overWriteUrl == "") overWriteUrl = undefined;
         $.ajax({
             url: '/compilation/setOverWriteUrl',
             type: 'post',
             dataType: "json",
-            data: {id: id, overWriteUrl: overWriteUrl},
-            success: function(response) {
+            data: { id: id, overWriteUrl: overWriteUrl },
+            success: function (response) {
                 if (response.err !== 0) {
                     alert('更改失败');
                 }
@@ -409,8 +409,8 @@ $(document).ready(function() {
                 url: '/compilation/setExample',
                 type: 'post',
                 dataType: "json",
-                data: {id: id, example: example},
-                success: function(response) {
+                data: { id: id, example: example },
+                success: function (response) {
                     if (response.err !== 0) {
                         alert('更改失败');
                     }
@@ -420,7 +420,7 @@ $(document).ready(function() {
     });
 
     // 计价规则启用/禁止
-    $(".enable").click(function() {
+    $(".enable").click(function () {
         let goingChangeStatus = switchChange($(this));
         let id = $(this).data('id');
         if (id === undefined || id === '' || isAdding) {
@@ -430,15 +430,15 @@ $(document).ready(function() {
             url: '/compilation/valuation/' + section + '/enable',
             type: 'post',
             dataType: "json",
-            data: {id: id, enable: goingChangeStatus},
-            error: function() {
+            data: { id: id, enable: goingChangeStatus },
+            error: function () {
                 isAdding = false;
                 switchChange($(this));
             },
-            beforeSend: function() {
+            beforeSend: function () {
                 isAdding = true;
             },
-            success: function(response) {
+            success: function (response) {
                 isAdding = false;
                 if (response.err !== 0) {
                     switchChange($(this));
@@ -450,45 +450,45 @@ $(document).ready(function() {
 
 
     // 设置适用类型
-    $(".fileType").change(function() {
-       
+    $(".fileType").change(function () {
+
         let id = $(this).data('id');
         if (id === undefined || id === '' || isAdding) {
             return false;
         }
         let fileTypes = [];
         let oldVal = $(this).attr("checked");
-        if(oldVal){
-            $(this).removeAttr("checked") 
-        }else{
-           $(this).attr("checked","checked")
+        if (oldVal) {
+            $(this).removeAttr("checked")
+        } else {
+            $(this).attr("checked", "checked")
         }
 
-        if($('#'+id+'_suggest_gusuan').attr("checked")) fileTypes.push(16);
-        if($('#'+id+'_gusuan').attr("checked")) fileTypes.push(15);
-        if($('#'+id+'_estimate').attr("checked")) fileTypes.push(5);
-        if($('#'+id+'_submission').attr("checked")) fileTypes.push(1);
-        if($('#'+id+'_three_bill_budget').attr("checked")) fileTypes.push(18);
-        if($('#'+id+'_bill_budget').attr("checked")) fileTypes.push(19);
-        if($('#'+id+'_changeBudget').attr("checked")) fileTypes.push(4);
-        if($('#'+id+'_settlement').attr("checked")) fileTypes.push(10);
+        if ($('#' + id + '_suggest_gusuan').attr("checked")) fileTypes.push(16);
+        if ($('#' + id + '_gusuan').attr("checked")) fileTypes.push(15);
+        if ($('#' + id + '_estimate').attr("checked")) fileTypes.push(5);
+        if ($('#' + id + '_submission').attr("checked")) fileTypes.push(1);
+        if ($('#' + id + '_three_bill_budget').attr("checked")) fileTypes.push(18);
+        if ($('#' + id + '_bill_budget').attr("checked")) fileTypes.push(19);
+        if ($('#' + id + '_changeBudget').attr("checked")) fileTypes.push(4);
+        if ($('#' + id + '_settlement').attr("checked")) fileTypes.push(10);
         let current = $(this);
 
-        console.log(id,this);
+        console.log(id, this);
         $.ajax({
             url: '/compilation/valuation/' + section + '/fileTypes',
             type: 'post',
             dataType: "json",
-            data: {id: id, fileTypes: fileTypes},
-            error: function() {
+            data: { id: id, fileTypes: fileTypes },
+            error: function () {
                 //恢复原值
-               if(oldVal){
-                current.attr("checked","checked")
-               }else{
-                current.removeAttr("checked") 
-               }
+                if (oldVal) {
+                    current.attr("checked", "checked")
+                } else {
+                    current.removeAttr("checked")
+                }
             },
-            success: function(response) {
+            success: function (response) {
                 if (response.err !== 0) {
                     switchChange($(this));
                     alert('更改失败');
@@ -509,7 +509,7 @@ $(document).ready(function() {
     });
 
     // 发布编办
-    $("#release").click(function() {
+    $("#release").click(function () {
         let id = $(this).data("id");
         let status = $(this).data("status");
         status = parseInt(status);
@@ -520,15 +520,15 @@ $(document).ready(function() {
         $.ajax({
             url: '/compilation/release',
             type: 'post',
-            data: {id: id, status: status},
+            data: { id: id, status: status },
             dataType: "json",
-            error: function() {
+            error: function () {
                 isAdding = false;
             },
-            beforeSend: function() {
+            beforeSend: function () {
                 isAdding = true;
             },
-            success: function(response) {
+            success: function (response) {
                 isAdding = false;
                 if (response.err === 0) {
                     window.location.reload();
@@ -542,24 +542,24 @@ $(document).ready(function() {
     });
 
     //添加工程专业
-    $("#addEngineerConfirm").click(async function() {
-        if($('#name').val() == ''){
+    $("#addEngineerConfirm").click(async function () {
+        if ($('#name').val() == '') {
             $("#nameError").show();
             return;
         }
-        if($('#feeName').val() == ''){
+        if ($('#feeName').val() == '') {
             $("#feeNameError").show();
             return;
         }
-        if($('#engineeringInput').val() == ''){
+        if ($('#engineeringInput').val() == '') {
             $("#engineeringError").show();
             return;
         }
-        if($('#projectEngineering').val() == ''){
+        if ($('#projectEngineering').val() == '') {
             $("#projectError").show();
             return;
         }
-        $("#addEngineerConfirm").attr("disabled",true);//防止重复提交
+        $("#addEngineerConfirm").attr("disabled", true);//防止重复提交
         $("#addEngineerForm").submit();
     });
     //
@@ -569,9 +569,9 @@ $(document).ready(function() {
         $.ajax({
             url: '/compilation/changeCategory',
             type: 'post',
-            data: {id: id, category: $(this).val()},
+            data: { id: id, category: $(this).val() },
             dataType: "json",
-            success: function(response) {
+            success: function (response) {
                 if (response.error !== 0) {
                     alert('更改失败');
                 }
@@ -584,9 +584,9 @@ $(document).ready(function() {
         $.ajax({
             url: '/compilation/changeLocation',
             type: 'post',
-            data: {id: id, location: $(this).val()},
+            data: { id: id, location: $(this).val() },
             dataType: "json",
-            success: function(response) {
+            success: function (response) {
                 if (response.error !== 0) {
                     alert('更改失败');
                 }
@@ -599,9 +599,9 @@ $(document).ready(function() {
         $.ajax({
             url: '/compilation/changeFreeUse',
             type: 'post',
-            data: {id: id, freeUse: $(this).prop('checked')},
+            data: { id: id, freeUse: $(this).prop('checked') },
             dataType: "json",
-            success: function(response) {
+            success: function (response) {
                 if (response.error !== 0) {
                     alert('更改失败');
                 }
@@ -624,6 +624,22 @@ $(document).ready(function() {
             }
         });
     });
+
+    //更改序号
+    $('#serialNumber').change(function () {
+        let serialNumber = Number($(this).val());
+        $.ajax({
+            url: '/compilation/setSerialNumber',
+            type: 'post',
+            dataType: "json",
+            data: { id: id, serialNumber: serialNumber },
+            success: function (response) {
+                if (response.err !== 0) {
+                    alert('更改失败');
+                }
+            }
+        });
+    });
 });
 
 /**
@@ -640,12 +656,12 @@ function initCompilation() {
     let programData = programList === undefined ? [] : JSON.parse(programList);
     let billsGuidanceData = billsGuidanceList === undefined ? [] : JSON.parse(billsGuidanceList);
     let billTemplateData = billTemplateList == undefined ? [] : JSON.parse(billTemplateList);
-    let mainTreeColData= mainTreeColList == undefined ? [] : JSON.parse(mainTreeColList);
-    let featureData = featureList == undefined?[]: JSON.parse(featureList);
+    let mainTreeColData = mainTreeColList == undefined ? [] : JSON.parse(mainTreeColList);
+    let featureData = featureList == undefined ? [] : JSON.parse(featureList);
     let infoData = infoList == undefined ? [] : JSON.parse(infoList);
-    let progressiveData = progressiveList == undefined?[]: JSON.parse(progressiveList);
-    let vvTaxData = vvTaxList == undefined?[]: JSON.parse(vvTaxList);
-    let billCodeData = billCodeList == undefined?[]: JSON.parse(billCodeList);
+    let progressiveData = progressiveList == undefined ? [] : JSON.parse(progressiveList);
+    let vvTaxData = vvTaxList == undefined ? [] : JSON.parse(vvTaxList);
+    let billCodeData = billCodeList == undefined ? [] : JSON.parse(billCodeList);
     /*mainTreeCol = mainTreeCol !== '' ? mainTreeCol.replace(/\n/g, '\\n') : mainTreeCol;
     billsTemplateData = billsTemplateData.replace(/\n/g, '\\n');
 
@@ -667,14 +683,14 @@ function initCompilation() {
 
     // 标准清单
     let html = '';
-    for(let tmp of billListData) {
+    for (let tmp of billListData) {
         let tmpHtml = '<option value="' + tmp.id + '">' + tmp.name + '</option>';
         html += tmpHtml;
     }
     $("select[name='standard_bill']").children("option").first().after(html);
     // 定额库
     html = '';
-    for(let tmp of rationLibData) {
+    for (let tmp of rationLibData) {
         let tmpHtml = '<option value="' + tmp.id + '">' + tmp.name + '</option>';
         html += tmpHtml;
     }
@@ -682,7 +698,7 @@ function initCompilation() {
 
     // 工料机库
     html = '';
-    for(let tmp of gljLibData) {
+    for (let tmp of gljLibData) {
         let tmpHtml = '<option value="' + tmp.id + '">' + tmp.name + '</option>';
         html += tmpHtml;
     }
@@ -690,7 +706,7 @@ function initCompilation() {
 
     // 清单指引库
     html = '';
-    for(let tmp of billsGuidanceData) {
+    for (let tmp of billsGuidanceData) {
         let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + '</option>';
         html += tmpHtml;
     }
@@ -699,7 +715,7 @@ function initCompilation() {
 
     // 人工系数标准库
     html = '';
-    for(let tmp of artificialCoefficientData) {
+    for (let tmp of artificialCoefficientData) {
         let tmpHtml = '<option value="' + tmp.id + '">' + tmp.name + '</option>';
         html += tmpHtml;
     }
@@ -707,7 +723,7 @@ function initCompilation() {
 
     // 计算程序标准库
     html = '';
-    for(let tmp of programData) {
+    for (let tmp of programData) {
         let tmpHtml = '<option value="' + tmp.id + '">' + tmp.displayName + '</option>';
         html += tmpHtml;
     }
@@ -715,14 +731,14 @@ function initCompilation() {
 
     //模板库
     html = '';
-    for(let tmp of billTemplateData) {
+    for (let tmp of billTemplateData) {
         let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + '</option>';
         html += tmpHtml;
     }
     $("select[name='template_lib']").children("option").first().after(html);
     //列设置
     html = '';
-    for(let tmp of mainTreeColData) {
+    for (let tmp of mainTreeColData) {
         let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + '</option>';
         html += tmpHtml;
     }
@@ -730,7 +746,7 @@ function initCompilation() {
 
     // 费率标准库
     html = '';
-    for(let tmp of feeLibData) {
+    for (let tmp of feeLibData) {
         let tmpHtml = '<option value="' + tmp.id + '">' + tmp.name + '</option>';
         html += tmpHtml;
     }
@@ -738,7 +754,7 @@ function initCompilation() {
 
     //工程特征库
     html = '';
-    for(let tmp of featureData){
+    for (let tmp of featureData) {
         let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + '</option>';
         html += tmpHtml;
     }
@@ -746,15 +762,15 @@ function initCompilation() {
 
     //基本信息库
     html = '';
-    for(let tmp of infoData){
+    for (let tmp of infoData) {
         let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + '</option>';
         html += tmpHtml;
     }
     $("select[name='info_lib']").children("option").first().after(html);
-    
+
     //累进区间库
     html = '';
-    for(let tmp of progressiveData){
+    for (let tmp of progressiveData) {
         let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + '</option>';
         html += tmpHtml;
     }
@@ -762,19 +778,19 @@ function initCompilation() {
 
     //车船税文件
     html = '';
-    for(let tmp of vvTaxData){
+    for (let tmp of vvTaxData) {
         let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + '</option>';
         html += tmpHtml;
     }
     $("select[name='vvTax_lib']").children("option").first().after(html);
 
-     //递延清单库文件
-     html = '';
-     for(let tmp of billCodeData){
-         let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + '</option>';
-         html += tmpHtml;
-     }
-     $("select[name='billCode_lib']").children("option").first().after(html);
+    //递延清单库文件
+    html = '';
+    for (let tmp of billCodeData) {
+        let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + '</option>';
+        html += tmpHtml;
+    }
+    $("select[name='billCode_lib']").children("option").first().after(html);
 }
 
 /**
@@ -788,7 +804,7 @@ function getAndValidData(model) {
     let standardBill = $("select[name='standard_bill']").children("option:selected").val();
     let rationLib = $("select[name='ration_lib']").children("option:selected").val();
     let gljLib = $("select[name='glj_lib']").children("option:selected").val();
-   // let feeLib = $("select[name='fee_lib']").children("option:selected").val();
+    // let feeLib = $("select[name='fee_lib']").children("option:selected").val();
     let artificialLib = $("select[name='artificial_lib']").children("option:selected").val();
     let programLib = $("select[name='program_lib']").children("option:selected").val();
     let billsGuidanceLib = $("select[name='billsGuidance_lib']").children("option:selected").val();
@@ -803,7 +819,7 @@ function getAndValidData(model) {
         throw '编办名字不能为空';
     }
 
-    if ( model === 'bill' && (standardBill === '' || standardBill === undefined)) {
+    if (model === 'bill' && (standardBill === '' || standardBill === undefined)) {
         throw '请选择标准清单库';
     }
 
@@ -843,7 +859,7 @@ function getAndValidData(model) {
     let standardBillString = $("select[name='standard_bill']").children("option:selected").text();
     let rationLibString = $("select[name='ration_lib']").children("option:selected").text();
     let gljLibString = $("select[name='glj_lib']").children("option:selected").text();
-  //  let feeLibString = $("select[name='fee_lib']").children("option:selected").text();
+    //  let feeLibString = $("select[name='fee_lib']").children("option:selected").text();
     let artificialString = $("select[name='artificial_lib']").children("option:selected").text();
     let programString = $("select[name='program_lib']").children("option:selected").text();
     let billsGuidanceString = $("select[name='billsGuidance_lib']").children("option:selected").text();
@@ -868,10 +884,10 @@ function getAndValidData(model) {
             id: gljLib,
             name: gljLibString
         },
-      /*  fee: {
-            id: feeLib,
-            name: feeLibString
-        },*/
+        /*  fee: {
+              id: feeLib,
+              name: feeLibString
+          },*/
         artificial: {
             id: artificialLib,
             name: artificialString
@@ -884,17 +900,17 @@ function getAndValidData(model) {
             id: billsGuidanceLib,
             name: billsGuidanceString
         },
-        feature:{
-            id:featureLib,
-            name:featrueString
+        feature: {
+            id: featureLib,
+            name: featrueString
         },
         info: {
             id: infoLib,
             name: infoString
         },
-        progressive:{
-            id:progressiveLib,
-            name:progressiveString
+        progressive: {
+            id: progressiveLib,
+            name: progressiveString
         },
         vvTax: {
             id: vvTaxLib,
@@ -927,33 +943,33 @@ function validLib() {
             throw '请选择工程专业';
         }
         //按新需求,清单库、定额库等不做非空验证
-      /*  if ($("input:hidden[name='bill_lib']").length <= 0) {
-            throw '请添加标准清单';
-        }
-
-        if ($("input:hidden[name='ration_lib']").length <= 0) {
-            throw '请添加定额库';
-        }
-
-        if ($("input:hidden[name='glj_lib']").length <= 0) {
-            throw '请添加人材机库';
-        }
-
-        if ($("input:hidden[name='fee_lib']").length <= 0) {
-            throw '请添加费率标准';
-        }
-
-        if ($("input:hidden[name='artificial_lib']").length <= 0) {
-            throw '请添加人工系数';
-        }
-
-        if ($("input:hidden[name='program_lib']").length <= 0) {
-            throw '请添加计算程序';
-        }
-
-        if ($("input:hidden[name='billsGuidance_lib']").length <= 0) {
-            throw '请添加清单指引库';
-        }*/
+        /*  if ($("input:hidden[name='bill_lib']").length <= 0) {
+              throw '请添加标准清单';
+          }
+  
+          if ($("input:hidden[name='ration_lib']").length <= 0) {
+              throw '请添加定额库';
+          }
+  
+          if ($("input:hidden[name='glj_lib']").length <= 0) {
+              throw '请添加人材机库';
+          }
+  
+          if ($("input:hidden[name='fee_lib']").length <= 0) {
+              throw '请添加费率标准';
+          }
+  
+          if ($("input:hidden[name='artificial_lib']").length <= 0) {
+              throw '请添加人工系数';
+          }
+  
+          if ($("input:hidden[name='program_lib']").length <= 0) {
+              throw '请添加计算程序';
+          }
+  
+          if ($("input:hidden[name='billsGuidance_lib']").length <= 0) {
+              throw '请添加清单指引库';
+          }*/
 
         result = true;
     } catch (error) {
@@ -993,54 +1009,54 @@ function switchChange(element) {
 }
 
 function editEngineer(selector) {
-    let engineerName =  $(selector).prev("span").text();
+    let engineerName = $(selector).prev("span").text();
     let parentDiv = $(selector).parent("div");
     parentDiv.next("div").find("input").val(engineerName);
     parentDiv.hide();
     parentDiv.next("div").show();
 }
 
-function confirmUpdate(selector,engineerID) {
+function confirmUpdate(selector, engineerID) {
     let inputDiv = $(selector).parents(".input_group_div");
     let input = $(selector).parent(".input-group-btn").prev("input");
     let oldValue = inputDiv.prev("div").find("span").text();
     let newValue = input.val();
     let key = input.attr("name");
-    if(newValue == "" || newValue==oldValue || !engineerID){
+    if (newValue == "" || newValue == oldValue || !engineerID) {
         inputDiv.prev("div").show();
         inputDiv.hide();
         return;
     }
-     let updateData = {};
-     updateData[key] = newValue;
-     updateEngineer(engineerID,updateData,function () {
+    let updateData = {};
+    updateData[key] = newValue;
+    updateEngineer(engineerID, updateData, function () {
         inputDiv.prev("div").find("span").text(newValue);
-     });
-     inputDiv.prev("div").show();
-     inputDiv.hide();
+    });
+    inputDiv.prev("div").show();
+    inputDiv.hide();
 }
 
-function deleteEngineerClick(engineerID,element) {
+function deleteEngineerClick(engineerID, element) {
     hintBox.infoBox('操作确认', '是否删除所选工程专业?', 2, async function () {
         try {
-            let result  = await ajaxPost('/compilation/delete-engineer',{id:engineerID});
+            let result = await ajaxPost('/compilation/delete-engineer', { id: engineerID });
             $(element).parent("td").parent("tr").remove();
-        }catch (err){
+        } catch (err) {
             console.log(err);
         }
-    }, null,['确定','取消'],false);
+    }, null, ['确定', '取消'], false);
 }
 
 
-function engineerVisibleChange(checkBox,engineerID) {
-    if(engineerID){
-        updateEngineer(engineerID,{visible:checkBox.checked});
+function engineerVisibleChange(checkBox, engineerID) {
+    if (engineerID) {
+        updateEngineer(engineerID, { visible: checkBox.checked });
     }
 }
 
-function updateEngineer(engineerID,data,callback) {
-    CommonAjax.post('/compilation/update-engineer',{id:engineerID,updateData:data},function (data) {
-        if(callback){
+function updateEngineer(engineerID, data, callback) {
+    CommonAjax.post('/compilation/update-engineer', { id: engineerID, updateData: data }, function (data) {
+        if (callback) {
             callback();
         }
     })
@@ -1050,13 +1066,13 @@ function editTaxGroup(ele) {
     $('#groupEditType').val("modify");
     let groupData = $(ele).nextAll("input[name = 'tax_group']").val();
     groupData = JSON.parse(groupData);
-    if(!_.isEmpty(groupData)){
-        $("#taxType").val(groupData.taxType?groupData.taxType:"");
-        $("#program_lib").val(groupData.program_lib?groupData.program_lib.id:"");
-        $("#template_lib").val(groupData.template_lib?groupData.template_lib.id:"");
-        $("#col_lib").val(groupData.col_lib?groupData.col_lib.id:"");
-        $("#fee_lib").val(groupData.fee_lib?groupData.fee_lib.id:"");
-    }else {
+    if (!_.isEmpty(groupData)) {
+        $("#taxType").val(groupData.taxType ? groupData.taxType : "");
+        $("#program_lib").val(groupData.program_lib ? groupData.program_lib.id : "");
+        $("#template_lib").val(groupData.template_lib ? groupData.template_lib.id : "");
+        $("#col_lib").val(groupData.col_lib ? groupData.col_lib.id : "");
+        $("#fee_lib").val(groupData.fee_lib ? groupData.fee_lib.id : "");
+    } else {
         $("#taxType").val("");
         $("#program_lib").val("");
         $("#template_lib").val("");
@@ -1064,68 +1080,68 @@ function editTaxGroup(ele) {
         $("#fee_lib").val("");
     }
     $("#groupIndex").val(getGroupIndex(groupData));
-    $("#addTaxGroup").modal({show:true});
+    $("#addTaxGroup").modal({ show: true });
 }
 
-function deleteTableTr(ele,classString) {
+function deleteTableTr(ele, classString) {
     let parentTr = $(ele).parents(`.${classString}`);
     parentTr.remove();
 }
 
 function getGroupIndex(groupData) {//用来做唯一标识
     let index = "";
-    if(groupData){
-        if(groupData.taxType) index = index + groupData.taxType;
-        if(groupData.program_lib) index = index + groupData.program_lib.id;
-        if(groupData.template_lib) index = index + groupData.template_lib.id;
-        if(groupData.col_lib) index = index + groupData.col_lib.id;
-        if(groupData.fee_lib) index = index + groupData.fee_lib.id;
+    if (groupData) {
+        if (groupData.taxType) index = index + groupData.taxType;
+        if (groupData.program_lib) index = index + groupData.program_lib.id;
+        if (groupData.template_lib) index = index + groupData.template_lib.id;
+        if (groupData.col_lib) index = index + groupData.col_lib.id;
+        if (groupData.fee_lib) index = index + groupData.fee_lib.id;
     }
     return index;
 }
 function getTaxGroupData() {
     let programData = programList === undefined ? [] : _.indexBy(JSON.parse(programList), 'id');
-    let billTemplateData = billTemplateList == undefined ? [] : _.indexBy(JSON.parse(billTemplateList),'ID');
-    let mainTreeColData= mainTreeColList == undefined ? [] :  _.indexBy(JSON.parse(mainTreeColList),'ID');
-    let feeLibData = feeRateList === undefined ? [] : _.indexBy(JSON.parse(feeRateList),'id');
+    let billTemplateData = billTemplateList == undefined ? [] : _.indexBy(JSON.parse(billTemplateList), 'ID');
+    let mainTreeColData = mainTreeColList == undefined ? [] : _.indexBy(JSON.parse(mainTreeColList), 'ID');
+    let feeLibData = feeRateList === undefined ? [] : _.indexBy(JSON.parse(feeRateList), 'id');
     let groupData = {};
-    if($("#taxType").val() !==""){
+    if ($("#taxType").val() !== "") {
         groupData.taxType = $("#taxType").val();
     }
-    if($("#program_lib").val() !==""){
-        let program =  programData[$("#program_lib").val()];
-        if(program){
+    if ($("#program_lib").val() !== "") {
+        let program = programData[$("#program_lib").val()];
+        if (program) {
             groupData.program_lib = {
-                id:program.id,
-                name:program.name,
-                displayName:program.displayName
+                id: program.id,
+                name: program.name,
+                displayName: program.displayName
             }
         }
     }
-    if($("#template_lib").val() !==""){
-        let template =  billTemplateData[$("#template_lib").val()];
-        if(template){
+    if ($("#template_lib").val() !== "") {
+        let template = billTemplateData[$("#template_lib").val()];
+        if (template) {
             groupData.template_lib = {
-                id:template.ID,
-                name:template.name
+                id: template.ID,
+                name: template.name
             }
         }
     }
-    if($("#col_lib").val() !==""){
-        let col =  mainTreeColData[$("#col_lib").val()];
-        if(col){
+    if ($("#col_lib").val() !== "") {
+        let col = mainTreeColData[$("#col_lib").val()];
+        if (col) {
             groupData.col_lib = {
-                id:col.ID,
-                name:col.name
+                id: col.ID,
+                name: col.name
             }
         }
     }
-    if($("#fee_lib").val() !==""){
-        let feeRate =  feeLibData[$("#fee_lib").val()];
-        if(feeRate){
+    if ($("#fee_lib").val() !== "") {
+        let feeRate = feeLibData[$("#fee_lib").val()];
+        if (feeRate) {
             groupData.fee_lib = {
-                id:feeRate.id,
-                name:feeRate.name
+                id: feeRate.id,
+                name: feeRate.name
             }
         }
     }
@@ -1133,12 +1149,12 @@ function getTaxGroupData() {
 }
 
 
-function intChecking(e,elemt) {//限制输入正整数
+function intChecking(e, elemt) {//限制输入正整数
     let code = e.which || e.keyCode;
-    if(code == 46 || code == 45){//不能输入小数点和-号
+    if (code == 46 || code == 45) {//不能输入小数点和-号
         e.preventDefault();
     }
-    if( elemt.value == ""&&code == 48){//当输入框为空时不能输入0
+    if (elemt.value == "" && code == 48) {//当输入框为空时不能输入0
         e.preventDefault();
     }
 

+ 5 - 0
web/users/views/compilation/index.html

@@ -306,6 +306,11 @@
                     </td>
                 </tr>
                 <tr><td><span>版本号:</span><input class="form-control" type="text" id="edition" value="<%= selectedCompilation.edition%>"></td></tr>
+                <tr>
+                    <td><span>序号:</span><input class="form-control" type="number" id="serialNumber"
+                            value="<%= selectedCompilation.serialNumber%>">
+                    </td>
+                </tr>
             </table>
         </div>
         <input type="hidden" name="id" value="<%= selectedCompilation._id %>" id="compilation-id">