浏览代码

feat: 选择工料机库可以跨编办

zhangweicheng 3 周之前
父节点
当前提交
1632b1d211
共有 2 个文件被更改,包括 75 次插入40 次删除
  1. 74 39
      modules/common/std/std_glj_lib_map_model.js
  2. 1 1
      modules/users/controllers/compilation_controller.js

+ 74 - 39
modules/common/std/std_glj_lib_map_model.js

@@ -6,51 +6,86 @@
  * @version
  */
 import BaseModel from "../../common/base/base_model";
-import mongoose from 'mongoose';
-const STDGLJLibMapSchema = mongoose.model('std_glj_lib_map');
+import mongoose from "mongoose";
+const STDGLJLibMapSchema = mongoose.model("std_glj_lib_map");
 
 class STDGLJLibMapModel extends BaseModel {
+  /**
+   * 构造函数
+   *
+   * @return {void}
+   */
+  constructor() {
+    let parent = super();
+    parent.model = STDGLJLibMapSchema;
+    parent.init();
+  }
 
-    /**
-     * 构造函数
-     *
-     * @return {void}
-     */
-    constructor() {
-        let parent = super();
-        parent.model = STDGLJLibMapSchema;
-        parent.init();
+  /**
+   * 获取对应的工料机库
+   *
+   * @param {String} compilationId
+   * @return {Promise}
+   */
+  async getGLJLibList(compilationId) {
+    let result = [];
+    let gliLib = await this.findDataByCondition(
+      { deleted: false, compilationId: compilationId.toString() },
+      null,
+      false
+    );
+
+    if (gliLib.length <= 0) {
+      return result;
+    }
+
+    // 整理数据
+    let gljList = [];
+    for (let tmp of gliLib) {
+      let tmpRation = { id: tmp.ID, name: tmp.dispName };
+      if (gljList.length <= 0) {
+        gljList = [tmpRation];
+      } else {
+        gljList.push(tmpRation);
+      }
+    }
+
+    result = gljList;
+    return result;
+  }
+
+  /**
+   * 获取所有未删除的的工料机库
+   *
+   * @param {String} compilationId
+   * @return {Promise}
+   */
+  async getAllGLJLibList() {
+    let result = [];
+    let gliLib = await this.findDataByCondition(
+      { deleted: false },
+      null,
+      false
+    );
+
+    if (gliLib.length <= 0) {
+      return result;
     }
 
-    /**
-     * 获取对应的工料机库
-     *
-     * @param {String} compilationId
-     * @return {Promise}
-     */
-    async getGLJLibList(compilationId) {
-        let result = [];
-        let gliLib = await this.findDataByCondition({deleted: false, compilationId: compilationId.toString()}, null, false);
-
-        if (gliLib.length <= 0) {
-            return result;
-        }
-
-        // 整理数据
-        let gljList = [];
-        for(let tmp of gliLib) {
-            let tmpRation = {id: tmp.ID, name: tmp.dispName};
-            if (gljList.length <= 0) {
-                gljList = [tmpRation];
-            } else {
-                gljList.push(tmpRation);
-            }
-        }
-
-        result = gljList;
-        return result;
+    // 整理数据
+    let gljList = [];
+    for (let tmp of gliLib) {
+      let tmpRation = { id: tmp.ID, name: tmp.dispName };
+      if (gljList.length <= 0) {
+        gljList = [tmpRation];
+      } else {
+        gljList.push(tmpRation);
+      }
     }
 
+    result = gljList;
+    return result;
+  }
 }
 
-export default STDGLJLibMapModel;
+export default STDGLJLibMapModel;

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

@@ -256,7 +256,7 @@ class CompilationController extends BaseController {
 
       // 获取工料机库
       let stdGLJLibMapModel = new STDGLJLibMapModel();
-      gljList = await stdGLJLibMapModel.getGLJLibList(selectedCompilation._id);
+      gljList = await stdGLJLibMapModel.getAllGLJLibList();
 
       // 获取费率标准库
       let stdFeeRateLibsModel = new STDFeeRateLibsModel();