Browse Source

子目换算 - 替换人材机修改

zhangweicheng 7 years ago
parent
commit
1e90990e2a
2 changed files with 18 additions and 3 deletions
  1. 1 0
      modules/all_models/stdRation_coe.js
  2. 17 3
      web/maintain/ration_repository/js/coe.js

+ 1 - 0
modules/all_models/stdRation_coe.js

@@ -25,6 +25,7 @@ const coeListSchema = new Schema({
     content: String,                    // 说明
     original_code:String,               //原人材机编码
     option_codes:String,                //可选人材机编码
+    option_list:[Schema.Types.Mixed],//下拉列表选项
     coes: [coeSchema]
 }, {versionKey: false});
 

+ 17 - 3
web/maintain/ration_repository/js/coe.js

@@ -293,6 +293,7 @@ let coeOprObj = {
                     }
                     else {
                         updateObj[dataCode] = inputT;
+                        me.setOptionList(dataCode,inputT,updateObj);
                         updateArr.push(updateObj);
                         me.save([], updateArr, [], true);
                     }
@@ -323,6 +324,7 @@ let coeOprObj = {
                 else{
                     newCoe.serialNo = ++me.currentMaxNo;
                     newCoe[dataCode] = inputT;
+                    me.setOptionList(dataCode,inputT,newCoe);
                     addArr.push(newCoe);
                     me.save(addArr, [], [], true, function (result) {
                         me.updateCurrentCoeList(result);
@@ -331,6 +333,18 @@ let coeOprObj = {
             }
         }
     },
+    setOptionList:function (dataCode,inputT,obj) {
+        if(dataCode == "option_codes"){//所选人材的情况,要获取人材机下拉列表
+            inputT = inputT.replace(/[\s\r\n]/g, "")//去掉空格换行等字符
+            let optionList = [];
+            let options = inputT.split("|");
+            for(let code of options){
+                let name = gljAdjOprObj.getGljName(code,gljAdjOprObj.gljList,true);
+                if(name) optionList.push({text:name,value:code});
+            }
+            obj.option_list = optionList;
+        }
+    },
     onClipboardPasting: function (sender, info) {
         let me = coeOprObj, maxCol = info.cellRange.col + info.cellRange.colCount - 1;
         if(maxCol > me.setting.header.length){
@@ -798,11 +812,11 @@ let gljAdjOprObj = {
         workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
         workBook.commandManager().setShortcutKey('gljAdjDel', GC.Spread.Commands.Key.del, false, false, false, false);
     },
-    getGljName: function (gljCode, gljList) {
+    getGljName: function (gljCode, gljList,withSpecs) {//withSpecs 是否带上规格型号
         let rst = null;
         for(let i = 0, len = gljList.length; i < len; i++){
             if(gljCode === gljList[i].code){
-                rst = gljList[i].name;
+                rst = withSpecs == true ?gljList[i].name +" - "+gljList[i].specs :gljList[i].name;
                 break;
             }
         }
@@ -817,7 +831,7 @@ let gljAdjOprObj = {
         $.ajax({
             type: 'post',
             url: '/stdGljRepository/api/getGljItemsOccupied',
-            data: {repId: pageObj.gljLibID, occupation: '-_id code name'},
+            data: {repId: pageObj.gljLibID, occupation: '-_id code name specs'},
             dataType: 'json',
             timeout: 5000,
             success:function(result){