zhongzewei 7 年之前
父节点
当前提交
ffee27b631
共有 1 个文件被更改,包括 18 次插入8 次删除
  1. 18 8
      modules/std_glj_lib/models/gljMapModel.js

+ 18 - 8
modules/std_glj_lib/models/gljMapModel.js

@@ -3,6 +3,7 @@
  */
 import gljMapModel from "./schemas";
 import {gljModel, gljClassModel} from "./schemas";
+import {rationRepository} from "../../ration_repository/models/schemas";
 import moment from "moment";
 import counter from "../../../public/counter/counter";
 import async from "async";
@@ -84,15 +85,24 @@ class GljMapDao extends OprDao{
             }
         })
     }
-    getAllGljLib(callback){
-        gljMapModel.find({deleted: false}, function (err, result) {
-            if(err){
-                callback(err, '没有定额库数据!', null);
-            }
-            else{
-                callback(null, '成功', result);
+    async getAllGljLib(callback){
+        try{
+            let gljLibs = await gljMapModel.find({deleted: false});
+            for(let gljLib of gljLibs){
+                let tempRationLibs = [];
+                for(let rationLib of gljLib.rationLibs){
+                    let rLib = await rationRepository.findOne({ID: rationLib.ID, deleted: false});
+                    if(rLib !== undefined && rLib !== null){
+                        tempRationLibs.push({ID: rationLib.ID, dispName: rLib.dispName});
+                    }
+                }
+                gljLib._doc.rationLibs = tempRationLibs;
             }
-        })
+            callback(null, '成功', gljLibs);
+        }
+        catch(err){
+            callback(err, '没有定额库数据!', null);
+        }
     }
     createGljLib(gljLibObj, callback){
         counter.counterDAO.getIDAfterCount(counter.moduleName.stdGljLib, 1, function (err, result) {