Kaynağa Gözat

定额库编号

zhongzewei 6 yıl önce
ebeveyn
işleme
b9e1dd1a66

+ 1 - 0
modules/all_models/stdRation_lib.js

@@ -8,6 +8,7 @@ const oprSchema = require('../all_schemas/opr_schema');
 const RepositoryMapSchema = new Schema({
     "ID": Number,
     "dispName" : String,
+    "libCode": String, //定额编号
     "appType" : String, //如:"建筑" / "公路"
     "localeType": String, //如 各个省份 / 部颁
     "descr" : String,

+ 1 - 1
modules/ration_repository/controllers/ration_repository_controller.js

@@ -102,7 +102,7 @@ class RationRepositoryController extends baseController {
         });
     }
 
-    getDisPlayRationLibs(req, res) {
+    async getDisPlayRationLibs(req, res) {
         rationRepository.getDisplayRationLibs(function (err, data) {
             if (data) {
                 callback(req, res, err, "has data", data);

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

@@ -18,6 +18,7 @@ const engLibModel = mongoose.model('engineering_lib');
 function createNewLibModel(rationLibObj){
     var rst = {};
     rst.dispName = rationLibObj.dispName;
+    rst.libCode = rationLibObj.libCode;
     rst.appType = rationLibObj.appType?rationLibObj.appType:'construct';
     rst.compilationId = rationLibObj.compilationId;
     rst.compilationName = rationLibObj.compilationName;
@@ -186,7 +187,7 @@ rationRepositoryDao.prototype.getDisplayRationLibs = function(callback) {
 };
 
 rationRepositoryDao.prototype.updateName = function(oprtor, renameObj, callback){
-    rationRepository.update({ID: renameObj.ID, deleted: false}, {$set: {dispName: renameObj.newName}}, function (err) {
+    rationRepository.update({ID: renameObj.ID, deleted: false}, {$set: {dispName: renameObj.newName, libCode: renameObj.newLibCode}}, function (err) {
         if(err){
             callback(err, '重命名失败!');
         }

+ 26 - 13
web/maintain/ration_repository/js/main.js

@@ -20,23 +20,24 @@ $(function () {
             let gljLibName = $('#gljLibSels option:selected').text();
             let gljLibId = $('#gljLibSels option:selected').val();
             let libName = $('#libNameTxt').val();
+            let libCode = $('#libCode').val().trim();
             if(libName.trim().length === 0){
                 alert('名称不可为空!');
                 $('#libNameTxt').val('')
-            }
-            else if(dispNames.indexOf(libName) !== -1){
+            } else if (!libCode) {
+                alert('定额编号不可为空');
+                $('#libCode').val('');
+            } else if(dispNames.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需要
                 newRationLib.compilationId = compilationId;
                 newRationLib.compilationName = compilationName;
                 newRationLib.gljLib = gljLibId;
@@ -50,23 +51,29 @@ $(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());
             $("#renameA").attr("renameId", renameId);
         });
         $("#renameA").click(function(){
             let newName = $("#renameText").val();
+            let newLibCode = $('#renameCode').val().trim();
             let libId = $(this).attr("renameId");
             let jqSel = "#" + libId + " td:first" + " a";
             let orgName = $(jqSel).text();
+            let filterName = dispNameArr.filter(function (v) {
+                return v === newName;
+            });
             if(newName.trim().length === 0){
                 alert("名称不可为空!");
                 $("#renameText").val('');
-            }
-            else if(dispNameArr.indexOf(newName) !== -1){
+            } else if (!newLibCode) {
+                alert('定额编号不可为空!');
+                $('#renameCode').val('');
+            } else if(filterName.length > 0 && newName !== orgName){
                 alert("该定额库已存在!");
                 $("#renameText").val('');
-            }
-            else{
-                renameRationLib({ID: libId, newName: newName, orgName: orgName}, dispNameArr);
+            } else{
+                renameRationLib({ID: libId, newName: newName, orgName: orgName, newLibCode: newLibCode}, dispNameArr);
             }
         });
         $('#edit').on('shown.bs.modal', function () {
@@ -277,12 +284,14 @@ function getAllRationLib(callback){
                     }
                     let id = result.data[i].ID;
                     let libName = result.data[i].dispName;
+                    let libCode = result.data[i].libCode ? result.data[i].libCode : '';
                     let createDate = result.data[i].createDate.split(' ')[0];
                     let compilationName = result.data[i].compilationName;
                     dispNames.push(result.data[i].dispName);
                     $("#showArea").append(
                         "<tr id='"+id+"'>" +
                         "<td><a href='/rationRepository/ration?repository=" + id +"'>"+libName+"</a></td>" +
+                        "<td>"+libCode+"</td>" +
                         "<td>"+compilationName+" </td>" +
                         "<td>"+createDate+" </td>" +
                         "<td><a href='javascript:void(0);' data-toggle='modal' data-target='#edit' title='编辑'>" +
@@ -366,10 +375,12 @@ function createRationLib(rationObj, dispNamesArr){
                 let libName = result.data.dispName;
                 let createDate = result.data.createDate.split(' ')[0];
                 let compilationName = result.data.compilationName;
+                let libCode = result.data.libCode ? result.data.libCode : '';
                 dispNamesArr.push(libName);
                 $("#showArea").append(
                     "<tr id='"+id+"'>" +
                     "<td><a href='/rationRepository/ration?repository=" + id +"'>"+libName+"</a></td>" +
+                    "<td>"+libCode+" </td>" +
                     "<td>"+compilationName+" </td>" +
                     "<td>"+createDate+" </td>" +
                     "<td><a href='javascript:void(0);' data-toggle='modal' data-target='#edit' title='编辑'>" +
@@ -396,12 +407,14 @@ function renameRationLib(renameObj, dispNames){
             if(!result.error){
                 let jqSel = "#" + renameObj.ID + " td:first" + " a";
                 $(jqSel).text(renameObj.newName);
+                $(`#${renameObj.ID} td:eq(1)`).text(renameObj.newLibCode);
                 let index = dispNames.indexOf(renameObj.orgName);
                 dispNames.splice(index, 1);
                 dispNames.splice(index, 0, renameObj.newName);
             }
             $('#editCancelBtn').click();
             $('#renameText').val('');
+            $('#renameCode').val('');
         }
     })
 }

+ 9 - 1
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><th width="90">补充模板</th></tr></thead>
+                        <thead><tr><th>定额库名称</th><th>定额编号</th><th width="160">费用定额</th><th width="160">添加时间</th><th width="90">操作</th><th width="90">原始数据</th><th width="150">内部数据</th><th width="90">补充模板</th></tr></thead>
                         <tbody id="showArea">
                         </tbody>
                       </table>
@@ -86,6 +86,10 @@
                             <input id="libNameTxt" class="form-control" placeholder="输入定额库名称" type="text">
                         </div>
                         <div class="form-group">
+                            <label>定额编号</label>
+                            <input id="libCode" class="form-control" placeholder="输入定额编号" type="text">
+                        </div>
+                        <div class="form-group">
                             <label>费用定额名称</label>
                             <select id="compilationSels" class="form-control"></select>
                         </div>
@@ -118,6 +122,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="renameCode" placeholder="输入定额编号" type="text" value="">
+                      </div>
                   </form>
                 </div>
                 <div class="modal-footer">