Browse Source

补充工料机的组成物增加字段isStd: Boolean,和相关操作

zhongzewei 7 năm trước cách đây
mục cha
commit
ba36e5b1fd

+ 14 - 4
modules/complementary_glj_lib/models/schemas.js

@@ -4,9 +4,19 @@
 import mongoose from "mongoose";
 
 let Schema = mongoose.Schema;
-let gjlComponentSchema = mongoose.Schema(
+//补充工料机的组成物可能来自标准工料机和补充工料机
+let comGjlComponentSchema = new Schema(
+    {
+        isStd: Boolean, //组成物里的工料机是否是标准的,否则是补充的
+        ID: Number,
+        consumeAmt: Number
+    },
+    {_id: false},
+    {versionKey: false}
+);
+//标准工料机的组成物只来自标准工料机
+let stdGjlComponentSchema = new Schema(
     {
-       // module: String, //"stdGlj"标准工料机 "complementaryGlj"
         ID: Number,
         consumeAmt: Number
     },
@@ -26,7 +36,7 @@ let complementaryGljSchema = new Schema({
     gljClass: Number,
     gljType: Number,
     shortName: String,
-    component: [gjlComponentSchema]
+    component: [comGjlComponentSchema]
 }, {versionKey: false});
 
 //标准工料机
@@ -42,7 +52,7 @@ let stdGljSchema = new Schema({
     gljType: Number,
     shortName: String,
     unit: String,
-    component: [gjlComponentSchema]
+    component: [stdGjlComponentSchema]
 },{versionKey: false});
 
 //标准工料机分类树

+ 3 - 2
web/building_saas/complementary_glj_lib/js/components.js

@@ -217,13 +217,14 @@ let componentOprObj = {
                 let isExist = false;
                 for(let j = 0, jLen = re.currentGlj.component.length; j < jLen; j++){
                     if(me.selectedList[i].ID === re.currentGlj.component[j].ID){
-                        newComponent.push({ID: me.selectedList[i].ID, consumeAmt: re.currentGlj.component[j].consumeAmt});
+                        newComponent.push({isStd: typeof me.selectedList[i].isStd !== 'undefined' ? me.selectedList[i].isStd : false
+                            , ID: me.selectedList[i].ID, consumeAmt: re.currentGlj.component[j].consumeAmt});
                         isExist = true;
                         break;
                     }
                 }
                 if(!isExist){
-                    newComponent.push({ID: me.selectedList[i].ID, consumeAmt: 0});
+                    newComponent.push({isStd: typeof me.selectedList[i].isStd !== 'undefined' ? me.selectedList[i].isStd : false, ID: me.selectedList[i].ID, consumeAmt: 0});
                 }
                 //re.currentGlj.component.push({ID: me.selectedList[i].ID, consumeAmt: 0});
             }

+ 9 - 0
web/building_saas/complementary_glj_lib/js/glj.js

@@ -147,6 +147,7 @@ let repositoryGljObj = {
                     me.complementaryGljList = result.data.complementaryGljs;
                     me.workBook.getSheet(0).setRowCount(me.stdGljList.length);
                     me.sortGlj(me.stdGljList);
+                    me.setProp('isStd', true, me.stdGljList);
                     me.sortGlj(me.complementaryGljList);
                     let rootNode = me.treeObj.getNodes()[0];
                     if(rootNode && rootNode.isParent && rootNode.isFirstNode){
@@ -199,6 +200,7 @@ let repositoryGljObj = {
             let obj = {};
             for(let j = 0; j < me.complementaryGljList.length; j++){
                 if(gljComponent[i].ID == me.complementaryGljList[j].ID){
+                    obj.isStd = false;
                     obj.ID = me.complementaryGljList[j].ID;
                     obj.code = me.complementaryGljList[j].code;
                     obj.name = me.complementaryGljList[j].name;
@@ -210,6 +212,7 @@ let repositoryGljObj = {
             }
             for(let j = 0; j < me.stdGljList.length; j++){
                 if(gljComponent[i].ID == me.stdGljList[j].ID){
+                    obj.isStd = true;
                     obj.ID = me.stdGljList[j].ID;
                     obj.code = me.stdGljList[j].code;
                     obj.name = me.stdGljList[j].name;
@@ -1043,6 +1046,12 @@ let repositoryGljObj = {
         }
         //allgljs
     },
+    setProp: function (prop, value, gljList) {
+        let me = this;
+        for(let i = 0, len = gljList.length; i < len; i++){
+            gljList[i][prop] = value;
+        }
+    },
     sortGlj: function(gljList) {
         let me = this;
         gljList.sort(function(a, b){