zhangweicheng 7 years ago
parent
commit
a8e6d171da

+ 2 - 1
modules/all_models/compilation.js

@@ -20,6 +20,7 @@ let engineeringListSchema = new Schema({
     }
     }
 }, {_id: false});
 }, {_id: false});
 let childrenSchema = new Schema({
 let childrenSchema = new Schema({
+    id:String,
     // 计价名称
     // 计价名称
     name: String,
     name: String,
     // 工程专业列表
     // 工程专业列表
@@ -36,7 +37,7 @@ let childrenSchema = new Schema({
     type: {
     type: {
         type: Number
         type: Number
     }
     }
-});
+},{_id: false});
 let modelSchema = {
 let modelSchema = {
     // 是否发布
     // 是否发布
     is_release: {
     is_release: {

+ 8 - 6
modules/users/models/compilation_model.js

@@ -35,8 +35,8 @@ class CompilationModel extends BaseModel {
      */
      */
     async getCompilationList() {
     async getCompilationList() {
         // 筛选字段
         // 筛选字段
-        let field = {_id: 1, name: 1, is_release: 1, description: 1, "ration_valuation._id": 1, "ration_valuation.name": 1, "ration_valuation.enable": 1,
-            "bill_valuation._id": 1, "bill_valuation.name": 1, "bill_valuation.enable": 1};
+        let field = {_id: 1, name: 1, is_release: 1, description: 1, "ration_valuation.id": 1, "ration_valuation.name": 1, "ration_valuation.enable": 1,
+            "bill_valuation.id": 1, "bill_valuation.name": 1, "bill_valuation.enable": 1};
         let compilationData = await this.findDataByCondition({name: {$ne: ''}}, field, false);
         let compilationData = await this.findDataByCondition({name: {$ne: ''}}, field, false);
 
 
         return compilationData === null ? [] : compilationData;
         return compilationData === null ? [] : compilationData;
@@ -113,8 +113,10 @@ class CompilationModel extends BaseModel {
         }
         }
 
 
         let insertData = {};
         let insertData = {};
+        data.id = "12580";
         insertData[section + '_valuation'] = data;
         insertData[section + '_valuation'] = data;
         let result = await this.db.addToSet(condition, insertData);
         let result = await this.db.addToSet(condition, insertData);
+        console.log(result);
 
 
         return result.ok === undefined ? false : result.ok;
         return result.ok === undefined ? false : result.ok;
     }
     }
@@ -205,7 +207,7 @@ class CompilationModel extends BaseModel {
         let sectionString = section + '_valuation';
         let sectionString = section + '_valuation';
 
 
         for(let valuation of compilationData[sectionString]) {
         for(let valuation of compilationData[sectionString]) {
-            if (valuation._id.toString() === id) {
+            if (valuation.id.toString() === id) {
                 result = valuation;
                 result = valuation;
                 break;
                 break;
             }
             }
@@ -292,7 +294,7 @@ class CompilationModel extends BaseModel {
     async getEngineeringLib(valuationId, section, engineering) {
     async getEngineeringLib(valuationId, section, engineering) {
         let sectionString = section + "_valuation";
         let sectionString = section + "_valuation";
         let condition = {};
         let condition = {};
-        condition[sectionString + "._id"] = valuationId;
+        condition[sectionString + ".id"] = valuationId;
 
 
         let compilationData = await this.findDataByCondition(condition);
         let compilationData = await this.findDataByCondition(condition);
         if (compilationData === null) {
         if (compilationData === null) {
@@ -300,7 +302,7 @@ class CompilationModel extends BaseModel {
         }
         }
         let valuationData = null;
         let valuationData = null;
         for(let valuation of compilationData[sectionString]) {
         for(let valuation of compilationData[sectionString]) {
-            if(valuation._id.toString() === valuationId) {
+            if(valuation.id === valuationId) {
                 valuationData = valuation;
                 valuationData = valuation;
             }
             }
         }
         }
@@ -333,7 +335,7 @@ class CompilationModel extends BaseModel {
     async addEngineeringLib(valuationId, section, data) {
     async addEngineeringLib(valuationId, section, data) {
         let sectionString = section + "_valuation";
         let sectionString = section + "_valuation";
         let condition = {};
         let condition = {};
-        condition[sectionString + "._id"] = valuationId;
+        condition[sectionString + ".id"] = valuationId;
 
 
         let insertData = {};
         let insertData = {};
         insertData[sectionString + ".$.engineering_list"] = data;
         insertData[sectionString + ".$.engineering_list"] = data;

+ 1 - 1
modules/users/models/engineering_lib_model.js

@@ -77,10 +77,10 @@ class EngineeringLibModel extends BaseModel {
             // 查找计价规则表中是否有对应工程专业标准库的数据
             // 查找计价规则表中是否有对应工程专业标准库的数据
             let compilationModel = new CompilationModel();
             let compilationModel = new CompilationModel();
             let engineeringLib = await compilationModel.getEngineeringLib(valuationId, data.section, data.engineering);
             let engineeringLib = await compilationModel.getEngineeringLib(valuationId, data.section, data.engineering);
-
             if (engineeringLib === null) {
             if (engineeringLib === null) {
                 // 不存在则插入
                 // 不存在则插入
                 result = await this.db.create(data);
                 result = await this.db.create(data);
+                console.log(data);
             } else {
             } else {
                 delete data.id;
                 delete data.id;
                 delete data.section;
                 delete data.section;

+ 2 - 1
package.json

@@ -19,7 +19,8 @@
     "moment": "^2.18.1",
     "moment": "^2.18.1",
     "mongoose": "~4.13.12",
     "mongoose": "~4.13.12",
     "request": "^2.79.0",
     "request": "^2.79.0",
-    "tape": "^4.6.3"
+    "tape": "^4.6.3",
+    "uuid": "^3.1.0"
   },
   },
   "dependencies": {
   "dependencies": {
     "babel-core": "^6.26.0",
     "babel-core": "^6.26.0",

+ 1 - 1
web/users/views/compilation/add.html

@@ -12,7 +12,7 @@
         <div class="c-header" style="padding:0">
         <div class="c-header" style="padding:0">
             <ul class="nav nav-tabs">
             <ul class="nav nav-tabs">
                 <% valuationList.forEach(function(valuation) { %>
                 <% valuationList.forEach(function(valuation) { %>
-                <li role="presentation" <% if (valuation._id.toString() === valuationId) { %>class="active"<% } %>><a href="/compilation/valuation/<%= section %>/<%= valuation._id %>"><%= valuation.name %></a></li>
+                <li role="presentation" <% if (valuation.id.toString() === valuationId) { %>class="active"<% } %>><a href="/compilation/valuation/<%= section %>/<%= valuation.id %>"><%= valuation.name %></a></li>
                 <% }) %>
                 <% }) %>
             </ul>
             </ul>
         </div>
         </div>

+ 1 - 1
web/users/views/compilation/template.html

@@ -18,7 +18,7 @@
         <div class="c-header" style="padding:0">
         <div class="c-header" style="padding:0">
             <ul class="nav nav-tabs">
             <ul class="nav nav-tabs">
                 <% valuationList.forEach(function(valuation) { %>
                 <% valuationList.forEach(function(valuation) { %>
-                <li role="presentation" <% if (valuation._id.toString() === valuationId) { %>class="active"<% } %>><a href="/compilation/valuation/<%= section %>/<%= valuation._id %>"><%= valuation.name %></a></li>
+                <li role="presentation" <% if (valuation.id.toString() === valuationId) { %>class="active"<% } %>><a href="/compilation/valuation/<%= section %>/<%= valuation.id %>"><%= valuation.name %></a></li>
                 <% }) %>
                 <% }) %>
             </ul>
             </ul>
         </div>
         </div>