Bläddra i källkod

工程专业数据排序

zhangweicheng 6 år sedan
förälder
incheckning
4c57ab2408

+ 1 - 1
config/config.js

@@ -11,7 +11,7 @@ module.exports = {
             auth: {
                 "authdb": "admin"
             },
-            connectTimeoutMS: 20000,
+            connectTimeoutMS: 100000,
             useMongoClient: true
         }
     },

+ 2 - 2
config/db/db_manager.js

@@ -50,11 +50,11 @@ module.exports = {
         var config = require("../config.js");
         var dbURL = 'mongodb://' + config[env].server + ":" + config[env].port + '/scConstruct';
         if(config[env].dbURL){
-            mg.connect(config[env].dbURL,{connectTimeoutMS: 20000,useMongoClient: true});
+            mg.connect(config[env].dbURL,{connectTimeoutMS: 100000,useMongoClient: true});
         } else if(config[env].options){
             mg.connect(dbURL,config[env].options);
         }else {
-            mg.connect(dbURL,{connectTimeoutMS: 20000,useMongoClient: true});//useMongoClient': true*! //报 DeprecationWarning: `open()` is deprecated in mongoose这个错
+            mg.connect(dbURL,{connectTimeoutMS:100000,useMongoClient: true});//useMongoClient': true*! //报 DeprecationWarning: `open()` is deprecated in mongoose这个错
         }
         var db = mg.connection;
         db.on("error",function (err) {

+ 2 - 1
modules/all_models/engineering_lib.js

@@ -79,7 +79,8 @@ let modelSchema = {
     //单位工程取费专业
     projectEngineering:Number,
     //是否计算安装增加费
-    isInstall:{type: Boolean, default: false}
+    isInstall:{type: Boolean, default: false},
+    seq:Number//序列号
 };
 mongoose.model(collectionName, new Schema(modelSchema, {versionKey: false, collection: collectionName}));
 

+ 2 - 1
modules/users/controllers/compilation_controller.js

@@ -26,6 +26,7 @@ import basicInfoFacade from "../../basic_info_lib/facade/basic_info_facade";
 import {default as category, List as categoryList} from "../../common/const/category_const.js";
 let config = require("../../../config/config.js");
 const fs = require('fs');
+let _ = require('lodash');
 
 class CompilationController extends BaseController {
 
@@ -149,7 +150,7 @@ class CompilationController extends BaseController {
             // 获取计价规则中对应的标准库数据
             let engineeringLibModel = new EngineeringLibModel();
             engineeringList = await engineeringLibModel.getLibsByValuationID(valuationId);
-
+            engineeringList = _.sortBy(engineeringList,['seq'])
         } catch (error) {
             console.log(error);
         }

+ 10 - 4
web/users/js/compilation.js

@@ -747,10 +747,12 @@ function switchChange(element) {
     return !currentStatus;
 }
 
-function editEngineer(selector) {
-    let engineerName =  $(selector).prev("span").text();
+function editEngineer(selector,key) {
+    let editText =  $(selector).prev("span").text();
     let parentDiv = $(selector).parent("div");
-    parentDiv.next("div").find("input").val(engineerName);
+    let width =  key == 'seq'?70:200;
+    parentDiv.next("div").css('width',width);
+    parentDiv.next("div").find("input").val(editText);
     parentDiv.hide();
     parentDiv.next("div").show();
 }
@@ -769,7 +771,11 @@ function confirmUpdate(selector,engineerID) {
      let updateData = {};
      updateData[key] = newValue;
      updateEngineer(engineerID,updateData,function () {
-        inputDiv.prev("div").find("span").text(newValue);
+         if(key == 'seq'){
+             window.location.reload();
+         } else {
+             inputDiv.prev("div").find("span").text(newValue);
+         }
      });
      inputDiv.prev("div").show();
      inputDiv.hide();

+ 11 - 0
web/users/views/compilation/add.html

@@ -34,6 +34,7 @@
                         <table class="table engineer_table">
                             <thead>
                             <tr>
+                                <th>序号</th>
                                 <th>工程专业</th>
                                 <th>费用标准</th>
                                 <th>定额取费专业</th>
@@ -49,6 +50,16 @@
                                 <% engineeringList.forEach(function(engineering) {%>
                                 <tr >
                                     <td>
+                                        <div><span><%= engineering.seq %></span> <a onclick='editEngineer(this,"seq")'><i class="glyphicon glyphicon-pencil"></i></a></div>
+                                        <div class="input-group input-group-sm input_group_div" style="width:200px;display: none">
+                                            <input class="form-control" name="seq">
+                                            <div class="input-group-btn">
+                                                <button type="button" class="btn btn-success" onclick='confirmUpdate(this,"<%= engineering._id.toString()%>")'>
+                                                    <span class="glyphicon glyphicon-ok"></span></button>
+                                            </div>
+                                        </div>
+                                    </td>
+                                    <td>
                                         <div><span><%= engineering.name %></span> <a onclick='editEngineer(this)'><i class="glyphicon glyphicon-pencil"></i></a></div>
                                         <div class="input-group input-group-sm input_group_div" style="width:200px;display: none">
                                             <input class="form-control" name="name">