瀏覽代碼

feat: 定额库编辑器增加序号

vian 10 月之前
父節點
當前提交
6b61253d11

文件差異過大導致無法顯示
+ 78 - 72
config/config.js


+ 5 - 4
modules/all_models/stdRation_lib.js

@@ -7,18 +7,19 @@ const Schema = mongoose.Schema;
 const oprSchema = require('../all_schemas/opr_schema');
 const RepositoryMapSchema = new Schema({
     "ID": Number,
-    "dispName" : String,
+    "dispName": String,
     "libCode": String, //定额库编码
-    "appType" : String, //如:"建筑" / "公路"
+    "appType": String, //如:"建筑" / "公路"
     "localeType": String, //如 各个省份 / 部颁
-    "descr" : String,
+    "descr": String,
     "deleted": Boolean,
     compilationId: String,
     compilationName: String,
     gljLib: Number,
     creator: String,
     createDate: String,
-    recentOpr: [oprSchema]
+    recentOpr: [oprSchema],
+    serialNo: Number, // 序号
 
 });
 

文件差異過大導致無法顯示
+ 919 - 0
modules/common/helper/pinyin.js


+ 18 - 0
modules/ration_repository/controllers/repository_views_controller.js

@@ -9,6 +9,11 @@ import mongoose from 'mongoose';
 const compilationModel = mongoose.model('compilation');
 const rationLibModel = mongoose.model('std_ration_lib_map');
 const fs = require('fs');
+import Pinyin from "../../common/helper/pinyin.js";
+
+const pinyin = new Pinyin();
+pinyin.initialize({});
+
 class ViewsController extends BaseController {
 
     async redirectMain(req, res) {
@@ -21,6 +26,19 @@ class ViewsController extends BaseController {
             rationLibs = allLibs.filter(lib => filter && lib.compilationId === filter.compilationId || !filter),
             allNames = allLibs.map(lib => lib.dispName);
         rationLibs = rationLibs.filter(lib => compilationPermission.includes(lib.compilationId))
+
+        // 这个node版本的中文localeCompare不靠谱,因此用拼音排序
+        rationLibs.forEach(lib => {
+            lib.pinyin = lib.dispName ? pinyin.getCamelCharsStr(lib.dispName) : '';
+        });
+        rationLibs.sort((a, b) => {
+            return (a.pinyin || '').localeCompare(b.pinyin || '');
+        });
+        rationLibs.forEach((lib, index) => {
+            // 空编码排后面
+            lib.weight = (lib.serialNo || 1000) * 1000 + index;
+        });
+        rationLibs.sort((a, b) => a.weight - b.weight);
         let compilationModel = new CompilationModel();
         let compilationList = await compilationModel.getPermissionCompilationList(req, { _id: 1, name: 1 });
         compilationList.unshift({ _id: 'all', name: '所有' });

+ 131 - 125
modules/ration_repository/models/repository_map.js

@@ -15,89 +15,92 @@ const rationInstallFeeItem = mongoose.model('std_ration_lib_installation');
 const rationInstallSection = mongoose.model('std_ration_lib_installationSection');
 const engLibModel = mongoose.model('engineering_lib');
 
-function createNewLibModel(rationLibObj){
+function createNewLibModel(rationLibObj) {
     var rst = {};
+    if (rationLibObj.serialNo) {
+        rst.serialNo = rationLibObj.serialNo;
+    }
     rst.dispName = rationLibObj.dispName;
     rst.libCode = rationLibObj.libCode;
-    rst.appType = rationLibObj.appType?rationLibObj.appType:'construct';
+    rst.appType = rationLibObj.appType ? rationLibObj.appType : 'construct';
     rst.compilationId = rationLibObj.compilationId;
     rst.compilationName = rationLibObj.compilationName;
     rst.gljLib = rationLibObj.gljLib;
     rst.creator = rationLibObj.creator;
     rst.createDate = moment(Date.now()).format('YYYY-MM-DD HH:mm:ss');
-    rst.recentOpr = [{operator: rationLibObj.creator, operateDate: rst.createDate}],
-    rst.deleted = false;
+    rst.recentOpr = [{ operator: rationLibObj.creator, operateDate: rst.createDate }],
+        rst.deleted = false;
     return rst;
 }
 
-var rationRepositoryDao = function(){};
+var rationRepositoryDao = function () { };
 
 rationRepositoryDao.prototype.getRationLibsByCompilation = async function (compilationId) {
-    return await rationRepository.find({compilationId: compilationId, deleted: false});
+    return await rationRepository.find({ compilationId: compilationId, deleted: false });
 };
 
 rationRepositoryDao.prototype.updateGljLib = function (gljLibId, callback) {
-    rationRepository.update({gljLib: gljLibId}, {$set: {gljLib: -1}}, {multi: true}, function (err) {
-        if(err){
+    rationRepository.update({ gljLib: gljLibId }, { $set: { gljLib: -1 } }, { multi: true }, function (err) {
+        if (err) {
             callback(err);
         }
-        else{
+        else {
             callback(null);
         }
     })
 };
 
-rationRepositoryDao.prototype.updateOprArr= function(findSet, oprtor, oprDate, cb){
+rationRepositoryDao.prototype.updateOprArr = function (findSet, oprtor, oprDate, cb) {
     rationRepository.find(findSet, function (err, result) {
-        if(err){
+        if (err) {
             cb(err);
         }
-        else{
-            if(result.length === 1){
+        else {
+            if (result.length === 1) {
                 let recentOprArr = result[0].recentOpr;
                 let isExist = false;
-                for(let i =0 ; i<recentOprArr.length; i++){
-                    if(recentOprArr[i].operator === oprtor){
+                for (let i = 0; i < recentOprArr.length; i++) {
+                    if (recentOprArr[i].operator === oprtor) {
                         recentOprArr[i].operateDate = oprDate;
                         isExist = true;
                     }
                 }
-                if(!isExist){
-                    if(recentOprArr.length < 5){
-                        recentOprArr.push({operator: oprtor, operateDate: oprDate});
+                if (!isExist) {
+                    if (recentOprArr.length < 5) {
+                        recentOprArr.push({ operator: oprtor, operateDate: oprDate });
                     }
-                    else if(recentOprArr.length === 5){
+                    else if (recentOprArr.length === 5) {
                         recentOprArr.sort(function (a, b) {
-                            if(a.operateDate > b.operateDate){
+                            if (a.operateDate > b.operateDate) {
                                 return -1;
-                            }else {
+                            } else {
                                 return 1;
                             }
                             return 0;
                         });
-                        recentOprArr.splice(recentOprArr.length -1, 1);
-                        recentOprArr.splice(0, 1, {operator: oprtor, operateDate: oprDate});
+                        recentOprArr.splice(recentOprArr.length - 1, 1);
+                        recentOprArr.splice(0, 1, { operator: oprtor, operateDate: oprDate });
                     }
                 }
-                rationRepository.update(findSet, {$set: {recentOpr: recentOprArr}}, function (err) {
-                    if(err){
+                rationRepository.update(findSet, { $set: { recentOpr: recentOprArr } }, function (err) {
+                    if (err) {
                         cb(err);
                     }
-                    else{
+                    else {
                         cb(null);
                     }
                 });
             }
-            else{
+            else {
                 cb(err);
             }
         }
     })
 };
 
-rationRepositoryDao.prototype.getRealLibName = function(dispName,callback){
+rationRepositoryDao.prototype.getRealLibName = function (dispName, callback) {
     if (callback) {
-        rationRepository.find({"dispName": dispName}, function(err,data){
+        rationRepository.find({ "dispName": dispName }, function (err, data) {
             if (err) {
                 callback('Error', null);
             } else {
@@ -105,13 +108,13 @@ rationRepositoryDao.prototype.getRealLibName = function(dispName,callback){
             }
         });
     } else {
-        var rst = rationRepository.find({"dispName": dispName}).exec();
+        var rst = rationRepository.find({ "dispName": dispName }).exec();
         return rst;
     }
 };
 
-rationRepositoryDao.prototype.getLibIDByName = function(dispName, callback){
-    rationRepository.findOne({"dispName": dispName}, function(err,data){
+rationRepositoryDao.prototype.getLibIDByName = function (dispName, callback) {
+    rationRepository.findOne({ "dispName": dispName }, function (err, data) {
         if (err) {
             callback('Error', null);
         } else {
@@ -120,9 +123,9 @@ rationRepositoryDao.prototype.getLibIDByName = function(dispName, callback){
     });
 };
 
-rationRepositoryDao.prototype.getRepositoryById = function(repId,callback = null){
+rationRepositoryDao.prototype.getRepositoryById = function (repId, callback = null) {
     if (callback) {
-        rationRepository.find({"ID": repId}, function(err,data){
+        rationRepository.find({ "ID": repId }, function (err, data) {
             if (err) {
                 callback('Error', null);
             } else {
@@ -130,34 +133,34 @@ rationRepositoryDao.prototype.getRepositoryById = function(repId,callback = null
             }
         });
     } else {
-        var rst = rationRepository.find({"ID": repId}).exec();
+        var rst = rationRepository.find({ "ID": repId }).exec();
         return rst;
     }
 };
 
-rationRepositoryDao.prototype.addRationRepository = function( rationLibObj,callback){
-    counter.counterDAO.getIDAfterCount(counter.moduleName.rationMap, 1, function(err, result){
+rationRepositoryDao.prototype.addRationRepository = function (rationLibObj, callback) {
+    counter.counterDAO.getIDAfterCount(counter.moduleName.rationMap, 1, function (err, result) {
         if (!result) {
             callback('获取不到新的库ID,创建失败', null);
         }
         var rMap = createNewLibModel(rationLibObj);
         rMap.ID = result.sequence_value;
-        new rationRepository(rMap).save(function(err, result) {
+        new rationRepository(rMap).save(function (err, result) {
             if (err) callback("Error", null);
-            else{
+            else {
                 //向引用工料机库的添加标记
-                gljMapModel.update({ID: rMap.gljLib, deleted: false}, {$addToSet: {rationLibs: {ID: rMap.ID, dispName: rMap.dispName}}}, function (err, data) {
-                    if(err){
-                        rationRepository.remove({ID: rMap.ID}, function (err) {
-                            if(err){
+                gljMapModel.update({ ID: rMap.gljLib, deleted: false }, { $addToSet: { rationLibs: { ID: rMap.ID, dispName: rMap.dispName } } }, function (err, data) {
+                    if (err) {
+                        rationRepository.remove({ ID: rMap.ID }, function (err) {
+                            if (err) {
                                 callback("创建失败且回滚失败!", null);
                             }
-                            else{
+                            else {
                                 callback("创建失败,已回滚!", null);
                             }
                         });
                     }
-                    else{
+                    else {
                         callback(false, result);
                     }
                 });
@@ -166,39 +169,42 @@ rationRepositoryDao.prototype.addRationRepository = function( rationLibObj,callb
     });
 };
 
-rationRepositoryDao.prototype.getRationLib = function(libId, callback) {
-    rationRepository.find({ID: libId, "deleted": false}, function(err, data){
+rationRepositoryDao.prototype.getRationLib = function (libId, callback) {
+    rationRepository.find({ ID: libId, "deleted": false }, function (err, data) {
         if (err) {
-            callback( 'Error', null);
+            callback('Error', null);
         } else {
             callback(0, data);
         }
     });
 };
 
-rationRepositoryDao.prototype.getDisplayRationLibs = function(callback) {
-    rationRepository.find(filter, function(err, data){
+rationRepositoryDao.prototype.getDisplayRationLibs = function (callback) {
+    rationRepository.find(filter, function (err, data) {
         if (err) {
-            callback( 'Error', null);
+            callback('Error', null);
         } else {
-            callback( false, data);
+            callback(false, data);
         }
     });
 };
 
-rationRepositoryDao.prototype.updateName = function(oprtor, renameObj, callback){
-    rationRepository.update({ID: renameObj.ID, deleted: false}, {$set: {dispName: renameObj.newName, libCode: renameObj.newLibCode}}, function (err) {
-        if(err){
+rationRepositoryDao.prototype.updateName = function (oprtor, renameObj, callback) {
+    if (!renameObj.newSerialNo) {
+        delete renameObj.newSerialNo;
+    }
+    rationRepository.update({ ID: renameObj.ID, deleted: false }, { $set: { dispName: renameObj.newName, libCode: renameObj.newLibCode, serialNo: renameObj.newSerialNo } }, function (err) {
+        if (err) {
             callback(err, '重命名失败!');
         }
-        else{
-            new rationRepositoryDao().updateOprArr({ID: renameObj.ID, deleted: false}, oprtor, moment(Date.now()).format('YYYY-MM-DD HH:mm:ss'), function (err) {
-                if(err){
+        else {
+            new rationRepositoryDao().updateOprArr({ ID: renameObj.ID, deleted: false }, oprtor, moment(Date.now()).format('YYYY-MM-DD HH:mm:ss'), function (err) {
+                if (err) {
                     callback(err, '更新最近操作者失败!');
                 }
-                else{
-                    engLibModel.update({'ration_lib.id': {$in: [String(renameObj.ID), +renameObj.ID]}}, {$set: {'ration_lib.$.name': renameObj.newName}}, {multi: true}, function (err) {
-                        if(err){
+                else {
+                    engLibModel.update({ 'ration_lib.id': { $in: [String(renameObj.ID), +renameObj.ID] } }, { $set: { 'ration_lib.$.name': renameObj.newName } }, { multi: true }, function (err) {
+                        if (err) {
                             callback(err, '更新工程专业引用失败!');
                         }
                         else {
@@ -211,80 +217,80 @@ rationRepositoryDao.prototype.updateName = function(oprtor, renameObj, callback)
     });
 }
 
-rationRepositoryDao.prototype.deleteRationLib = function(oprtor, libId, callback){
-    new rationRepositoryDao().updateOprArr({ID: libId, deleted: false}, oprtor, moment(Date.now()).format('YYYY-MM-DD HH:mm:ss'), function (err) {
-        if(err){
+rationRepositoryDao.prototype.deleteRationLib = function (oprtor, libId, callback) {
+    new rationRepositoryDao().updateOprArr({ ID: libId, deleted: false }, oprtor, moment(Date.now()).format('YYYY-MM-DD HH:mm:ss'), function (err) {
+        if (err) {
             callback(err, '失败!')
         }
-        else{
-            rationRepository.find({ID: libId, deleted: false}, function (err, result) {
-               if(err){
-                   callback(err, "没有数据!");
-               }
-                else{
-                   rationRepository.remove({ID: libId}, function (err) {
-                       if(err){
-                           callback(err, '移除定额库失败!');
-                       }
-                       else{
-                           async.parallel([
-                               function (cb) {
-                                   //移除工料机库内被引用标记
-                                   gljMapModel.update({ID: result[0].gljLib, deleted: false}, {$pull: {rationLibs: {ID: libId}}}, function (err) {
-                                       if(err){
-                                           cb(err);
-                                       }
-                                       else{
-                                           cb(null);
-                                       }
-                                   });
-                               },
-                               //删除库下定额
-                               function (cb) {
-                                   rationItemModel.remove({rationRepId: libId}, function (err) {
-                                       if(err)cb(err);
-                                       else cb(null);
-                                   });
-                               },
-                               //删除库下章节树
-                               function (cb) {
-                                   rationChapterTreeModel.remove({rationRepId: libId}, function (err) {
-                                       if(err)cb(err);
-                                       else cb(null);
-                                   })
-                               },
-                               //删除子目换算
-                               function (cb) {
-                                   rationCoeModel.remove({libID: libId}, function (err) {
-                                       if(err)cb(err);
-                                       else cb(null);
-                                   });
-                               },
-                               //删除安装
-                               async function (cb) {
-                                    try{
-                                        let feeItems = await rationInstallFeeItem.find({rationRepId: libId});
+        else {
+            rationRepository.find({ ID: libId, deleted: false }, function (err, result) {
+                if (err) {
+                    callback(err, "没有数据!");
+                }
+                else {
+                    rationRepository.remove({ ID: libId }, function (err) {
+                        if (err) {
+                            callback(err, '移除定额库失败!');
+                        }
+                        else {
+                            async.parallel([
+                                function (cb) {
+                                    //移除工料机库内被引用标记
+                                    gljMapModel.update({ ID: result[0].gljLib, deleted: false }, { $pull: { rationLibs: { ID: libId } } }, function (err) {
+                                        if (err) {
+                                            cb(err);
+                                        }
+                                        else {
+                                            cb(null);
+                                        }
+                                    });
+                                },
+                                //删除库下定额
+                                function (cb) {
+                                    rationItemModel.remove({ rationRepId: libId }, function (err) {
+                                        if (err) cb(err);
+                                        else cb(null);
+                                    });
+                                },
+                                //删除库下章节树
+                                function (cb) {
+                                    rationChapterTreeModel.remove({ rationRepId: libId }, function (err) {
+                                        if (err) cb(err);
+                                        else cb(null);
+                                    })
+                                },
+                                //删除子目换算
+                                function (cb) {
+                                    rationCoeModel.remove({ libID: libId }, function (err) {
+                                        if (err) cb(err);
+                                        else cb(null);
+                                    });
+                                },
+                                //删除安装
+                                async function (cb) {
+                                    try {
+                                        let feeItems = await rationInstallFeeItem.find({ rationRepId: libId });
                                         let sectionIDs = [];
-                                        for(let item of feeItems){
-                                            for(let section of item.section){
+                                        for (let item of feeItems) {
+                                            for (let section of item.section) {
                                                 sectionIDs.push(section.ID);
                                             }
                                         }
-                                        await rationInstallFeeItem.remove({rationRepId: libId});
-                                        await rationInstallSection.remove({ID: {$in: sectionIDs}});
+                                        await rationInstallFeeItem.remove({ rationRepId: libId });
+                                        await rationInstallSection.remove({ ID: { $in: sectionIDs } });
                                         cb(null);
                                     }
-                                    catch (err){
+                                    catch (err) {
                                         cb(err);
                                     }
-                               }
-                           ], function (err) {
-                               if(err) callback(err, 'fail');
-                               else callback(null, 'sc')
-                           });
-                       }
-                   });
-               }
+                                }
+                            ], function (err) {
+                                if (err) callback(err, 'fail');
+                                else callback(null, 'sc')
+                            });
+                        }
+                    });
+                }
             });
         }
     });

+ 61 - 55
web/maintain/ration_repository/js/main.js

@@ -18,20 +18,21 @@ $(function () {
         let gljLibId = $('#gljLibSels option:selected').val();
         let libName = $('#libNameTxt').val();
         let libCode = $('#libCode').val().trim();
-        if(libName.trim().length === 0){
+        const serialNo = +$('#serialNo').val();
+        if (libName.trim().length === 0) {
             alert('名称不可为空!');
             $('#libNameTxt').val('')
         } else if (!libCode) {
             alert('定额库编码不可为空');
             $('#libCode').val('');
-        } else if(allNames.indexOf(libName) !== -1){
+        } else if (allNames.indexOf(libName) !== -1) {
             alert('此定额库已存在!');
             $('#libNameTxt').val('')
-        } else if(compilationName.trim().length === 0){
+        } else if (compilationName.trim().length === 0) {
             alert('编办不可为空!');
-        } else if(gljLibName.trim().length === 0){
+        } else if (gljLibName.trim().length === 0) {
             alert("请选择工料机库!");
-        } else{
+        } else {
             let newRationLib = {};
             newRationLib.dispName = libName;
             newRationLib.libCode = libCode; //定额编号,标准数据导出xml需要
@@ -40,37 +41,40 @@ $(function () {
             newRationLib.gljLib = gljLibId;
             newRationLib.creator = userAccount;
             newRationLib.appType = "建筑";
+            newRationLib.serialNo = serialNo;
             $('#libNameTxt').val('');
             createRationLib(newRationLib);
         }
     });
     //重命名
-    $("#showArea").on("click", "[data-target = '#edit']", function(){
+    $("#showArea").on("click", "[data-target = '#edit']", function () {
         let renameId = $(this).parent().parent().attr("id");
         $('#renameText').val($(this).parent().parent().find('td:first-child').text());
-        $('#renameCode').val($(this).parent().parent().find('td:eq(1)').text());
+        $('#renameSerialNo').val($(this).parent().parent().find('td:eq(1)').text());
+        $('#renameCode').val($(this).parent().parent().find('td:eq(2)').text());
         $("#renameA").attr("renameId", renameId);
     });
-    $("#renameA").click(function(){
+    $("#renameA").click(function () {
         let newName = $("#renameText").val();
         let newLibCode = $('#renameCode').val().trim();
+        let newSerialNo = +$('#renameSerialNo').val();
         let libId = $(this).attr("renameId");
         let jqSel = "#" + libId + " td:first" + " a";
         let orgName = $(jqSel).text();
         let filterName = allNames.filter(function (v) {
             return v === newName;
         });
-        if(newName.trim().length === 0){
+        if (newName.trim().length === 0) {
             alert("名称不可为空!");
             $("#renameText").val('');
         } else if (!newLibCode) {
             alert('定额库编码不可为空!');
             $('#renameCode').val('');
-        } else if(filterName.length > 0 && newName !== orgName){
+        } else if (filterName.length > 0 && newName !== orgName) {
             alert("该定额库已存在!");
             $("#renameText").val('');
-        } else{
-            renameRationLib({ID: libId, newName: newName, orgName: orgName, newLibCode: newLibCode});
+        } else {
+            renameRationLib({ ID: libId, newName: newName, orgName: orgName, newLibCode: newLibCode, newSerialNo });
         }
     });
     $('#edit').on('shown.bs.modal', function () {
@@ -88,37 +92,37 @@ $(function () {
         $('#libNameTxt').val('');
     });
     //删除
-    $("#showArea").on("click", "[data-target = '#del']", function(){
+    $("#showArea").on("click", "[data-target = '#del']", function () {
         let deleteId = $(this).parent().parent().attr("id");
         $("#deleteA").attr("deleteId", deleteId);
         let delLibName = $(`#${deleteId}`).find('td:first').text();
         $('#del').find('.modal-body h5').text(`准备删除 “${delLibName}”,会导致已引用此库的地方出错,确定要删除吗?`);
     });
-    $("#deleteA").click(function(){
+    $("#deleteA").click(function () {
         let deleteId = $(this).attr("deleteId");
-        if(preDeleteId && preDeleteId !== deleteId){
+        if (preDeleteId && preDeleteId !== deleteId) {
             deleteCount = 0;
         }
         preDeleteId = deleteId;
         deleteCount++;
         let jqSel = "#" + deleteId + " td:first" + " a";
         let libName = $(jqSel).text();
-        if(deleteCount === 3){
+        if (deleteCount === 3) {
             deleteCount = 0;
-            removeRationLib({libId: deleteId, libName: libName});
+            removeRationLib({ libId: deleteId, libName: libName });
             $('#del').modal('hide');
         }
     });
     //全部计算
-    $("#showArea").on("click", "[data-target = '#reCalcAll']", function(){
+    $("#showArea").on("click", "[data-target = '#reCalcAll']", function () {
         let recalcId = $(this).parent().parent().attr("id");
         $("#reCalcConfirm").attr("recalcId", recalcId);
     });
-    $("#reCalcConfirm").click(function(){
+    $("#reCalcConfirm").click(function () {
         $('#reCalcConfirm').addClass('disabled');
         $.bootstrapLoading.start();
         let recalcId = $(this).attr("recalcId");
-        CommonAjax.post('/rationRepository/api/reCalcAll', {rationRepId: recalcId}, function (rstData) {
+        CommonAjax.post('/rationRepository/api/reCalcAll', { rationRepId: recalcId }, function (rstData) {
             $.bootstrapLoading.end();
             $('#reCalcAll').modal('hide');
             $('#reCalcConfirm').removeClass('disabled');
@@ -168,14 +172,14 @@ $(function () {
     });
 
     // 导入原始数据确认
-    $("#source-import,#data-import").click(function() {
+    $("#source-import,#data-import").click(function () {
         $.bootstrapLoading.start();
         const self = $(this);
         const type = self.is("#source-import") ? 'source_file' : 'import_data';
         const dialog = type === 'source_file' ? $("#import") : $("#import2");
         try {
             let formData = new FormData();
-            let file = $("input[name='"+ type +"']")[0];
+            let file = $("input[name='" + type + "']")[0];
             if (file.files.length <= 0) {
                 throw '请选择文件!';
             }
@@ -193,11 +197,11 @@ $(function () {
                 cache: false,
                 contentType: false,
                 processData: false,
-                beforeSend: function() {
+                beforeSend: function () {
                     self.attr('disabled', 'disabled');
                     self.text('上传中...');
                 },
-                success: function(response){
+                success: function (response) {
                     self.removeAttr('disabled');
                     self.text('确定导入');
                     if (response.err === 0) {
@@ -214,19 +218,19 @@ $(function () {
                         alert(message);
                     }
                 },
-                error: function(){
+                error: function () {
                     $.bootstrapLoading.end();
                     alert("与服务器通信发生错误");
                     self.removeAttr('disabled');
                     self.text('确定导入');
                 }
             });
-        } catch(error) {
+        } catch (error) {
             alert(error);
         }
     });
     // 导入章节数据确认
-    $('#import-section-confirm').click(function() {
+    $('#import-section-confirm').click(function () {
         $.bootstrapLoading.start();
         const self = $(this);
         const dialog = $('#section');
@@ -250,11 +254,11 @@ $(function () {
                 cache: false,
                 contentType: false,
                 processData: false,
-                beforeSend: function() {
+                beforeSend: function () {
                     self.attr('disabled', 'disabled');
                     self.text('上传中...');
                 },
-                success: function(response){
+                success: function (response) {
                     self.removeAttr('disabled');
                     self.text('确定导入');
                     if (response.err === 0) {
@@ -271,14 +275,14 @@ $(function () {
                         alert(message);
                     }
                 },
-                error: function(){
+                error: function () {
                     $.bootstrapLoading.end();
                     alert("与服务器通信发生错误");
                     self.removeAttr('disabled');
                     self.text('确定导入');
                 }
             });
-        } catch(error) {
+        } catch (error) {
             alert(error);
         }
     });
@@ -323,7 +327,7 @@ $(function () {
             return false;
         }
         $.bootstrapLoading.start();
-        CommonAjax.post('/rationRepository/api/initSectionTemplate', {rationLibId: rationRepId, compilationId: selCompilationId}, function () {
+        CommonAjax.post('/rationRepository/api/initSectionTemplate', { rationLibId: rationRepId, compilationId: selCompilationId }, function () {
             $.bootstrapLoading.end();
             $('#template').modal('hide');
         }, function () {
@@ -333,25 +337,25 @@ $(function () {
     });
 });
 
-function getCompilationList(callback){
+function getCompilationList(callback) {
     $.ajax({
         type: 'post',
         url: '/rationRepository/api/getCompilationList',
         dataType: 'json',
         success: function (result) {
             //addoptions
-            for(let i = 0; i < result.data.compilation.length; i++){
-                let $option =  $("<option >"+ result.data.compilation[i].name +"</option>");
-                $option.val( result.data.compilation[i]._id);
+            for (let i = 0; i < result.data.compilation.length; i++) {
+                let $option = $("<option >" + result.data.compilation[i].name + "</option>");
+                $option.val(result.data.compilation[i]._id);
                 $('#compilationSels').append($option);
             }
             //初始工料机库选项
-            if(result.data.compilation.length > 0 && result.data.gljLibs.length > 0){
+            if (result.data.compilation.length > 0 && result.data.gljLibs.length > 0) {
                 let compilationId = result.data.compilation[0]._id;
                 //console.log(compilationId);
                 let gljLibOps = getGljLibOps(compilationId, result.data.gljLibs);
-                for(let i = 0; i < gljLibOps.length; i++){
-                    let $option =  $("<option >"+ gljLibOps[i].dispName +"</option>");
+                for (let i = 0; i < gljLibOps.length; i++) {
+                    let $option = $("<option >" + gljLibOps[i].dispName + "</option>");
                     $option.val(gljLibOps[i].ID);
                     $('#gljLibSels').append($option);
                 }
@@ -361,8 +365,8 @@ function getCompilationList(callback){
                 //刷新工料机库选项
                 $('#gljLibSels').children().remove();
                 let newGljLibOps = getGljLibOps(this.selectedOptions[0].value, result.data.gljLibs);
-                for(let i = 0; i < newGljLibOps.length; i++){
-                    let $option =  $("<option >"+ newGljLibOps[i].dispName +"</option>");
+                for (let i = 0; i < newGljLibOps.length; i++) {
+                    let $option = $("<option >" + newGljLibOps[i].dispName + "</option>");
                     $option.val(newGljLibOps[i].ID);
                     $('#gljLibSels').append($option);
                 }
@@ -371,11 +375,11 @@ function getCompilationList(callback){
         }
     });
 }
-function getGljLibOps(compilationId, gljLibs){
+function getGljLibOps(compilationId, gljLibs) {
     let rst = [];
-    for(let i = 0; i < gljLibs.length; i++){
-        if(gljLibs[i]){
-            if(compilationId === gljLibs[i].compilationId){
+    for (let i = 0; i < gljLibs.length; i++) {
+        if (gljLibs[i]) {
+            if (compilationId === gljLibs[i].compilationId) {
                 rst.push(gljLibs[i]);
             }
         }
@@ -383,11 +387,11 @@ function getGljLibOps(compilationId, gljLibs){
     return rst;
 }
 
-function createRationLib(rationObj){
+function createRationLib(rationObj) {
     $.ajax({
         type: 'post',
         url: '/rationRepository/api/addRationRepository',
-        data: {rationRepObj: JSON.stringify(rationObj)},
+        data: { rationRepObj: JSON.stringify(rationObj) },
         dataType: 'json',
         success: function (result) {
             window.location.href = location.href;
@@ -395,17 +399,18 @@ function createRationLib(rationObj){
         }
     })
 }
-function renameRationLib(renameObj){
+function renameRationLib(renameObj) {
     $.ajax({
         type: 'post',
         url: '/rationRepository/api/editRationLibs',
-        data: {oprtor: userAccount, renameObj: JSON.stringify(renameObj)},
+        data: { oprtor: userAccount, renameObj: JSON.stringify(renameObj) },
         dataType: 'json',
         success: function (result) {
-            if(!result.error){
+            if (!result.error) {
                 let jqSel = "#" + renameObj.ID + " td:first" + " a";
                 $(jqSel).text(renameObj.newName);
-                $(`#${renameObj.ID} td:eq(1)`).text(renameObj.newLibCode);
+                $(`#${renameObj.ID} td:eq(1)`).text(renameObj.newSerialNo);
+                $(`#${renameObj.ID} td:eq(2)`).text(renameObj.newLibCode);
                 let index = allNames.indexOf(renameObj.orgName);
                 allNames.splice(index, 1);
                 allNames.splice(index, 0, renameObj.newName);
@@ -413,19 +418,20 @@ function renameRationLib(renameObj){
             $('#editCancelBtn').click();
             $('#renameText').val('');
             $('#renameCode').val('');
+            $('#renameSerialNo').val('');
         }
     })
 }
-function removeRationLib(delObj){
+function removeRationLib(delObj) {
     $.bootstrapLoading.start();
     $.ajax({
         type: 'post',
         url: '/rationRepository/api/deleteRationLibs',
-        data: {oprtor: userAccount, libId: delObj.libId},
+        data: { oprtor: userAccount, libId: delObj.libId },
         dataType: 'json',
         success: function (result) {
-            if(!result.error){
-                var jqSel = "#"+ delObj.libId;
+            if (!result.error) {
+                var jqSel = "#" + delObj.libId;
                 $(jqSel).remove();
                 let index = allNames.indexOf(delObj.libName);
                 allNames.splice(index, 1);

+ 10 - 0
web/maintain/ration_repository/main.html

@@ -52,6 +52,7 @@
                         <thead>
                             <tr>
                                 <th>定额库名称</th>
+                                <th width="60">序号</th>
                                 <th width="100">定额库编码</th>
                                 <th width="160">费用定额</th>
                                 <th width="120">添加时间</th>
@@ -66,6 +67,7 @@
                         <% for(let lib of rationLibs){ %>
                         <tr id="<%= lib.ID %>">
                             <td><a href="/rationRepository/ration?repository=<%= lib.ID%>&locked=true"><%= lib.dispName%></a></td>
+                            <td><%= lib.serialNo%></td>
                             <td><%= lib.libCode%></td>
                             <td><%= lib.compilationName%></td>
                             <td><%= moment(lib.createDate).format('YYYY-MM-DD')%></td>
@@ -139,6 +141,10 @@
                             <input id="libNameTxt" class="form-control" placeholder="输入定额库名称" type="text">
                         </div>
                         <div class="form-group">
+                            <label>序号</label>
+                            <input id="serialNo" class="form-control" placeholder="输入序号" type="number">
+                        </div>
+                        <div class="form-group">
                             <label>定额库编码</label>
                             <input id="libCode" class="form-control" placeholder="输入定额库编码" type="text">
                         </div>
@@ -175,6 +181,10 @@
                       <label>定额库名称</label>
                       <input class="form-control" id="renameText" placeholder="输入定额库名称" type="text" value="">
                     </div>
+                    <div class="form-group">
+                      <label>序号</label>
+                      <input class="form-control" id="renameSerialNo" placeholder="输入序号" type="number" value="">
+                    </div>
                       <div class="form-group">
                           <label>定额库编码</label>
                           <input class="form-control" id="renameCode" placeholder="输入定额库编码" type="text" value="">