Pārlūkot izejas kodu

各库重命名,更新工程专业引用

zhongzewei 7 gadi atpakaļ
vecāks
revīzija
87e98f5402

+ 13 - 24
modules/bills_lib/models/bills_lib_interfaces.js

@@ -10,6 +10,7 @@ let JobContent = mongoose.model('std_bills_lib_jobContent');
 let ItemCharacter = mongoose.model('std_bills_lib_itemCharacter');
 let moment = require("moment");
 let billsGuidanceLib = mongoose.model('std_billsGuidance_lib');
+const engLibModel = mongoose.model('engineering_lib');
 let billsLibDao = function(){};
 
 
@@ -177,36 +178,24 @@ billsLibDao.prototype.deleteStdBillsLib = function(data, callback){
     });
 };
 
-billsLibDao.prototype.renameStdBillsLib = function(renameData, callback){
+billsLibDao.prototype.renameStdBillsLib = async function(renameData, callback){
     let billsLibId = renameData.id;
     let renameVal = renameData.value;
     let lastOperator = renameData.lastOperator;
     let lastOperateDate = moment(Date.now()).format('YYYY-MM-DD HH:mm:ss');
-    StdBillsLib.find({billsLibId: billsLibId}, function (err, result) {
-        if(err){
+    try{
+        let billsLib = await StdBillsLib.findOne({billsLibId: billsLibId});
+        if(billsLib){
+            let newRecentOpr = getNewOprArr(billsLib.recentOpr, lastOperator, lastOperateDate);
+            await StdBillsLib.update({billsLibId: billsLibId}, {$set:{billsLibName: renameVal, recentOpr: newRecentOpr}});
+            await billsGuidanceLib.update({billsLibId: billsLibId}, {$set: {billsLibName: renameVal}}, {multi: true});
+            await engLibModel.update({'bill_lib.id': billsLibId}, {$set: {'bill_lib.$.name': renameVal}}, {multi: true});
             callback(0, '');
         }
-        else{
-            if(result.length > 0){
-                let newRecentOpr = getNewOprArr(result[0].recentOpr, lastOperator, lastOperateDate);
-                StdBillsLib.update({billsLibId: billsLibId}, {$set:{billsLibName: renameVal, recentOpr: newRecentOpr}}, function(err){
-                    if(err){
-                        callback(1, "Error");
-                    }
-                    else{
-                        billsGuidanceLib.update({billsLibId: billsLibId}, {$set: {billsLibName: renameVal}}, {multi: true}, function (err) {
-                            if(err){
-                                callback(1, "Error");
-                            }
-                            else {
-                                callback(0, "");
-                            }
-                        });
-                    }
-                });
-            }
-        }
-    })
+    }
+    catch (err){
+        callback(1, err);
+    }
 };
 
 billsLibDao.prototype.getStdBillsLibName = function(billsLibId, callback){

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

@@ -13,6 +13,7 @@ const rationItemModel = mongoose.model('std_ration_lib_ration_items');
 const rationCoeModel = mongoose.model('std_ration_lib_coe_list');
 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){
     var rst = {};
@@ -192,7 +193,14 @@ rationRepositoryDao.prototype.updateName = function(oprtor, renameObj, callback)
                     callback(err, '更新最近操作者失败!');
                 }
                 else{
-                    callback(null, '成功!');
+                    engLibModel.update({'ration_lib.id': renameObj.ID}, {$set: {'ration_lib.$.name': renameObj.newName}}, {multi: true}, function (err) {
+                        if(err){
+                            callback(err, '更新工程专业引用失败!');
+                        }
+                        else {
+                            callback(null, '成功!');
+                        }
+                    });
                 }
             });
         }

+ 0 - 11
modules/std_billsGuidance_lib/controllers/libController.js

@@ -8,18 +8,7 @@
  * @version
  */
 import BaseController from '../../common/base/base_controller';
-import mongoose from 'mongoose';
-import CompilationModel from "../../users/models/compilation_model";
 import moment from 'moment';
-const uuidV1 = require('uuid/v1');
-const billsLibModel = mongoose.model('std_bills_lib_list');
-const billsGuideLibModel = mongoose.model('std_billsGuidance_lib');
-const billsGuideItemsModel = mongoose.model('std_billsGuidance_items');
-const stdBillsLibModel = mongoose.model('std_bills_lib_list');
-const stdBillsModel = mongoose.model('std_bills_lib_bills');
-const stdBillsJobsModel = mongoose.model('std_bills_lib_jobContent');
-const stdRationModel = mongoose.model('std_ration_lib_ration_items');
-const _ = require('lodash');
 const billsGuidanceFacade = require('../facade/facades');
 let callback = function (req, res, err, msg, data) {
     res.json({error: err, message: msg, data: data});

+ 2 - 0
modules/std_billsGuidance_lib/facade/facades.js

@@ -18,6 +18,7 @@ const stdBillsLibModel = mongoose.model('std_bills_lib_list');
 const stdBillsModel = mongoose.model('std_bills_lib_bills');
 const stdBillsJobsModel = mongoose.model('std_bills_lib_jobContent');
 const stdRationModel = mongoose.model('std_ration_lib_ration_items');
+const engLibModel = mongoose.model('engineering_lib');
 const _ = require('lodash');
 
 module.exports = {
@@ -112,6 +113,7 @@ async function updateBillsGuideLib(data) {
     }
     else {
         await billsGuideLibModel.update(data.findData, {$set: data.updateData});
+        await engLibModel.update({'billsGuidance_lib.id': data.findData.ID}, {$set: {'billsGuidance_lib.$.name': data.updateData.name}}, {multi: true});
     }
 }
 

+ 9 - 1
modules/std_glj_lib/models/gljMapModel.js

@@ -7,6 +7,7 @@ const gljModel = mongoose.model('std_glj_lib_gljList');
 const gljClassModel = mongoose.model('std_glj_lib_gljClass');
 const gljClassTemplateModel = mongoose.model('std_glj_lib_gljClassTemplate');
 const rationRepository = mongoose.model('std_ration_lib_map');
+const engLibModel = mongoose.model('engineering_lib');
 import moment from "moment";
 import counter from "../../../public/counter/counter";
 import async from "async";
@@ -164,7 +165,14 @@ class GljMapDao extends OprDao{
                         callback(err, '更新最近操作者失败!');
                     }
                     else{
-                        callback(null, '成功!');
+                        engLibModel.update({'glj_lib.id': renameObj.ID}, {$set: {'glj_lib.$.name': renameObj.newName}}, {multi: true}, function (err) {
+                            if(err){
+                                callback(err, '更新工程专业引用失败!');
+                            }
+                            else {
+                                callback(null, '成功!');
+                            }
+                        });
                     }
                 });
             }

+ 17 - 0
web/maintain/bills_lib/html/main.html

@@ -195,10 +195,27 @@
 
        $("#showArea").on("click", "[data-target = '#edit']", function(){
            let renameId = $(this).parent().parent().attr("id");
+           $('#renameText').val($(this).parent().parent().find('td:first-child').text());
            $("#renameA").attr("renameId", renameId);
 
        });
 
+       $('#edit').on('shown.bs.modal', function () {
+           setTimeout(function () {
+                $('#renameText').focus();
+           }, 100);
+       });
+
+       $('#add').on('shown.bs.modal', function () {
+           setTimeout(function () {
+                $('#createText').focus();
+           }, 100);
+       });
+
+       $('#add').on('hidden.bs.modal', function () {
+           $('#createText').val('');
+       });
+
         $("#renameA").click(function(){
             let newName = $("#renameText").val();
             let renameId = $(this).attr("renameId");

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

@@ -47,6 +47,7 @@ $(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());
             $("#renameA").attr("renameId", renameId);
         });
         $("#renameA").click(function(){
@@ -66,6 +67,20 @@ $(function () {
                 renameRationLib({ID: libId, newName: newName, orgName: orgName}, dispNameArr);
             }
         });
+        $('#edit').on('shown.bs.modal', function () {
+            setTimeout(function () {
+                $('#renameText').focus();
+            }, 100);
+        });
+
+        $('#add').on('shown.bs.modal', function () {
+            setTimeout(function () {
+                $('#libNameTxt').focus();
+            }, 100);
+        });
+        $('#add').on('hidden.bs.modal', function () {
+            $('#libNameTxt').val('');
+        });
         //删除
         $("#showArea").on("click", "[data-target = '#del']", function(){
             let deleteId = $(this).parent().parent().attr("id");

+ 18 - 0
web/maintain/std_glj_lib/js/main.js

@@ -46,11 +46,29 @@ $(function () {
                     createGljLib(newGljLib, dispNameArr, usedCom);
                 }
             });
+
+            $('#edit').on('shown.bs.modal', function () {
+                setTimeout(function () {
+                    $('#renameText').focus();
+                }, 100);
+            });
+
+            $('#add').on('shown.bs.modal', function () {
+                setTimeout(function () {
+                    $('#libNameTxt').focus();
+                }, 100);
+            });
+
+            $('#add').on('hidden.bs.modal', function () {
+                $('#libNameTxt').val('');
+            });
+
             //重命名
             $("#showArea").on("click", "[data-target = '#edit']", function(){
                 let renameId = $(this).parent().parent().attr("id");
                 let compilationName = $(this).parent().parent().children()[1].textContent;
                 $('#compilationEdit option').text(compilationName);
+                $('#renameText').val($(this).parent().parent().find('td:first-child').text());
                 $("#renameA").attr("renameId", renameId);
             });
             $("#renameA").click(function(){