zhangweicheng пре 6 година
родитељ
комит
fe224a3eae

+ 1 - 1
modules/all_models/stdRation_ration.js

@@ -40,7 +40,7 @@ const rationItemSchema = new Schema({
     labourPrice: Number,
     materialPrice: Number,
     machinePrice: Number,
-    sectionId: Number,
+    sectionId: {type: Number,index: true},
     rationRepId: Number,
     caption: String,
     feeType: Number,

+ 1 - 22
modules/complementary_ration_lib/models/compleRationModel.js

@@ -165,20 +165,10 @@ class CompleRatoinDao {
                 comGljs = await complementaryGljModel.find({userId: userId, ID: {$in: comGljIds}});
             }
             let gljDatas = gljUtil.sortRationGLJ(stdGljs.concat(comGljs),true);
-          /*  gljDatas.sort(function (a, b) {
-                let aV = a.gljType + a.code,
-                    bV = b.gljType + b.code;
-                if(aV > bV) {
-                    return 1;
-                } else if (aV < bV) {
-                    return -1;
-                }
-                return 0;
-            });*/
             if(ration.jobContent && ration.jobContent.toString().trim() !== ''){
                 hintsArr.push(`<label class="nomargin font_blue">工作内容:`);
                 hintsArr = hintsArr.concat(ration.jobContent.split('\n'));
-                hintsArr.push("</label>")
+                hintsArr.push("</label>");
                 hintsArr.push("");
             }
             for(let glj of gljDatas){
@@ -253,17 +243,6 @@ class CompleRatoinDao {
                 stdGljs = await stdGljModel.find({ID: {$in: stdGljIds}});
             }
             let gljDatas =  gljUtil.sortRationGLJ(stdGljs,true);
-        /*    gljDatas.sort(function (a, b) {
-                let aV = a.gljType + a.code,
-                    bV = b.gljType + b.code;
-                if(aV > bV) {
-                    return 1;
-                } else if (aV < bV) {
-                    return -1;
-                }
-                return 0;
-            });*/
-            gljDatas = gljUtil.sortRationGLJ(gljDatas,true);
             if(ration.jobContent && ration.jobContent.toString().trim() !== ''){
                 hintsArr.push(`<label class="nomargin font_blue">工作内容:`);
                 hintsArr = hintsArr.concat(ration.jobContent.split('\n'));

+ 7 - 7
modules/complementary_ration_lib/models/searchModel.js

@@ -15,13 +15,13 @@ const compleRationLib = 'compleRationLib';
 class SearchDao{
     async getRationItem(userId, compilationId, rationRepIds, code, ID, callback){
         let ration = null;
+        let otherLibs=[];
         try{
-            let firstLib = rationRepIds.shift();//优先取第一个
-            if(rationRepIds.includes(firstLib)) {//去掉重复的库ID
-                rationRepIds.splice(rationRepIds.indexOf(firstLib), 1);
-            }
-            if(rationRepIds.includes(compleRationLib)) {
-                rationRepIds.splice(rationRepIds.indexOf(compleRationLib), 1);
+            let firstLib = rationRepIds[0];//优先取第一个
+            for (let l of rationRepIds){
+                if(l != firstLib && l != compleRationLib){
+                    otherLibs.push(l);
+                }
             }
             if(firstLib == compleRationLib){//说明选中的是补充定额库
                 ration = await this.getCompleRation(userId,compilationId,code,ID);
@@ -34,7 +34,7 @@ class SearchDao{
                 ration = await this.getStdRation(firstQuery);
             }
             if(ration == null){//选中的定额库或者默认的定额库中没有找到定额,才走常规的流程查找其它定额库
-                let stdQuery = {rationRepId: {$in: rationRepIds}, code: code, $or: [{isDeleted: null}, {isDeleted: false}]};
+                let stdQuery = {rationRepId: {$in: otherLibs}, code: code, $or: [{isDeleted: null}, {isDeleted: false}]};
                 if(ID){
                     stdQuery = {ID: ID, $or: [{isDeleted: null}, {isDeleted: false}]};
                 }