Browse Source

Merge branch 'apiupdate' of git.sagacloud.cn:web/ibms into apiupdate-zy

zhangyu 5 years ago
parent
commit
ef2b76e701

+ 32 - 5
src/components/config_point/dictionaryCascader.vue

@@ -1,6 +1,12 @@
 <template>
-  <el-cascader style='width: 100%;' :options='options' v-model='dict' @active-item-change='handleChange' :props='props' filterable
-    @change="changeSelect" ref="dictCas"></el-cascader>
+  <div>
+    <el-form ref="form" :rules='rules' :model="form">
+      <el-form-item prop="dict">
+        <el-cascader style='width: 100%;' :options='options' v-model='form.dict' @active-item-change='handleChange' :props='props' filterable
+          @change="changeSelect" ref="dictCas"></el-cascader>
+      </el-form-item>
+    </el-form>
+  </div>
 </template>
 <script>
 import {
@@ -49,12 +55,17 @@ export default {
           children: []
         },
       ],
-      dict: [],
+      form: {
+        dict: [],
+      },
       props: {
         value: 'Code',
         label: 'Name',
         children: 'children'
       },
+      rules: {
+        dict: [{ required: true, message: '请选择对应数据字典', trigger: 'blur' }]
+      }
     }
   },
   created() {
@@ -126,6 +137,11 @@ export default {
           }
         })
         this.pushPoints(this.options, tempArr, type);
+        this.pointDataSource = {}
+        res.Content.map(item => {
+          let code = item.InfoPointCode
+          this.pointDataSource[code] = item
+        })
       })
     },
     //根据返回数据拼接options
@@ -156,10 +172,21 @@ export default {
     },
     //设置值
     setCascaderVal(value) {
-      this.dict = tools.deepCopy(value)
+      this.form.dict = tools.deepCopy(value)
+      this.changeSelect(value)
       value.splice(value.length - 1, 1)
       this.handleChange(value)
-    }
+    },
+    //校验是否选择
+    validate(cb) {
+      this.$refs.form.validate(valid => {
+        if (valid) {
+          cb(true)
+        } else {
+          cb(false)
+        }
+      })
+    },
   }
 }
 </script>

File diff suppressed because it is too large
+ 580 - 611
src/components/config_point/step3_edit/index.vue


+ 45 - 67
src/components/config_point/step3_point/3_temps.vue

@@ -5,12 +5,10 @@
       <el-step title="步骤2" description="确定值得处理方式"></el-step>
       <el-step title="步骤3" description="确认并维护涉及到得原始点位对应得设备标识"></el-step>
     </el-steps>
-    <div class="collapse-item" v-if="activeName == 0">
+    <div class="collapse-item" v-show="activeName == 0">
       <el-form class="form" :rules="rules" ref="form" :model="form1" label-width="120px">
-        <el-form-item label="对应数据字典" prop="dict"
-          :rules="[{ required: true, message: '请输入对应数据字典', trigger: 'change' },{ validator: validateDict, trigger: ['blur', 'change'] }]">
-          <el-cascader style="width: 100%;" :options="options" v-model="form1.dict" @change="handleChange" :props="props" filterable
-            @active-item-change="handleItemChange"></el-cascader>
+        <el-form-item label="对应数据字典" prop="dict">
+          <dictionary-cas @change="changeDictionaryCas" ref="dictionaryCas"></dictionary-cas>
         </el-form-item>
       </el-form>
       <div class="flex-around">
@@ -20,7 +18,7 @@
         </div>
         <div class="point-despoint">
           <p class="center">数据字典值说明</p>
-          <p class="content-view p10">{{delDataSource(unitObj.dataSource)}}</p>
+          <p class="content-view p10">{{delDataSource(unitObj.DataSource)}}</p>
         </div>
       </div>
       <div class="center">
@@ -35,7 +33,7 @@
         </div>
         <div class="point-despoint">
           <p class="center">数据字典值说明</p>
-          <p class="content-view p10">{{delDataSource(unitObj.dataSource)}}</p>
+          <p class="content-view p10">{{delDataSource(unitObj.DataSource)}}</p>
         </div>
       </div>
       <el-form class="form" :rules="rules" ref="form2" :model="form2" label-width="140px">
@@ -78,6 +76,7 @@ import enumHandle from '@/components/config_point/step3_edit/enum_handle'
 import formulaHandle from '@/components/config_point/step3_edit/formula_handle'
 import splitHandle from '@/components/config_point/step3_edit/split_handle'
 import handsontableComponent from "@/components/common/handsontable"
+import dictionaryCas from '@/components/config_point/dictionaryCascader'
 import {
   mapGetters,
   mapActions
@@ -114,15 +113,10 @@ export default {
     return {
       activeName: 0,
       form1: {
-        dict: []
+        dict: 1
       },
       options: [],
       dataDict: {}, //数据字典
-      props: {
-        value: 'code',
-        label: 'name',
-        children: 'content'
-      },
       infoDict: {}, //信息点字典
       InfomationPoint: null, //信息点
       unitObj: {}, //传给自动单位转换的obj
@@ -157,7 +151,8 @@ export default {
           required: true,
           message: '请选择值处理方式',
           trigger: 'change'
-        }]
+        }],
+        dict: [{ required: true }]
       },
       pointDes: ""
     }
@@ -172,15 +167,17 @@ export default {
     enumHandle,
     formulaHandle,
     splitHandle,
-    handsontableComponent
+    handsontableComponent,
+    dictionaryCas
   },
   methods: {
     getMain(param) {
       this.activeName = 0
       this.dealType = {}
       this.form1 = {
-        dict: []
+        dict: 1
       }
+      this.$refs.dictionaryCas.setCascaderVal([])
       this.form2 = {
         ValueDescription: '',
         DataRuleType: '无需处理,直接使用'
@@ -264,29 +261,21 @@ export default {
     next() {
       var that = this;
       if (this.activeName == 0) {
-        this.$refs.form.validate((isOk, obj) => {
-          if (isOk) {
-            this.form2 = Object.assign(this.form2, this.form1)
+        this.$refs.dictionaryCas.validate(valid => {
+          if (valid) {
             this.activeName += 1
           } else {
             this.errMsg()
           }
         })
       } else if (this.activeName == 1) {
-        this.$refs['form2'].validate(valid => {
+        this.$refs.form2.validate(valid => {
           if (valid) {
             var flag = this.form2.DataRuleType
             var isNext = true;
             switch (flag) {
               case '无需处理,直接使用':
-                //     this.$refs.noHandle.getForm(noHandle => {
-                //         if (noHandle) {
                 this.saveForm(this.form2, {})
-                //     } else {
-                //         isNext = false
-                //         this.errMsg()
-                //     }
-                // })
                 break
               case '需自动单位转换':
                 this.$refs.autoHandle.getForm(autoHandle => {
@@ -369,17 +358,21 @@ export default {
     saveForm(basic, other) {
       let type = basic.DataRuleType
       let basicParams = {
-        SpecialtyCode: basic.dict[0],
-        SystemCode: basic.dict[1], //code
-        EquipmentTypeCode: basic.dict[2],
-        InfomationPointCode: basic.dict[3],
-        Specialty: this.dataDict[basic.dict[0]].name, //专业
-        System: this.dataDict[basic.dict[1]].name, //系统
-        EquipmentType: this.dataDict[basic.dict[2]].name, //设备
-        InfomationPoint: this.InfomationPoint, //信息点
+        InfomationPointCode: this.dictionaryData[this.dictionaryData.length - 1], //信息点code
+        InfomationPoint: this.dictionaryNames[this.dictionaryNames.length - 1], //信息点名称
         DataRuleType: basic.DataRuleType, //值处理方式
-        // DataSourceId: '4',
-        // PointId: this.editData.Point.Id //点位ID
+        Type: this.dictionaryNames[0], //一级分类名称
+        TypeCode: this.dictionaryData[0], //一级分类code
+      }
+      if (this.dictionaryData.length == 3) {
+        //设备-部件-空间
+        basicParams.EquipmentTypeCode = this.dictionaryData[1]
+        basicParams.EquipmentType = this.dictionaryNames[1]
+      } else if (this.dictionaryData.length == 4) { //专业系统
+        basicParams.SpecialtyCode = this.dictionaryData[1]
+        basicParams.Specialty = this.dictionaryNames[1]
+        basicParams.SystemCode = this.dictionaryNames[2]
+        basicParams.System = this.dictionaryNames[2]
       }
       let otherParams = {}
       switch (type) {
@@ -498,10 +491,6 @@ export default {
         cb()
       }
     },
-    handleChange(arr) {
-      this.unitObj = this.infoDict[arr[3]]
-      this.InfomationPoint = this.unitObj.infoPointName
-    },
     handleItemChange(val) {
       if (val.length == 3) {
         let params = {
@@ -512,7 +501,7 @@ export default {
             let data = res.Content
             let arr = data
               .filter(item => {
-                return item.inputMode == 'L'
+                return item.inputMode == 'L' || item.inputMode == 'M'
               })
               .map(item => {
                 return {
@@ -547,17 +536,6 @@ export default {
         }
       }
     },
-    //缓存数据字典
-    getDataDict(arr) {
-      for (var i = 0; i < arr.length; i++) {
-        // this.dataDict[arr[i].code] = arr[i]
-        if (arr[i].content && arr[i].content.length > 0) {
-          this.getDataDict(arr[i].content)
-        } else {
-          this.$set(arr[i], 'content', [])
-        }
-      }
-    },
     getEqAll() {
       let params = {
         format: true
@@ -586,23 +564,23 @@ export default {
     },
     //处理函数
     delDataSource(val) {
-
       if (!val) {
         return '--'
       }
-      if (typeof val == 'string') {
-        if (!!val) {
-          return val
-        } else {
-          return '无信息带你单位及值说明'
-        }
-      } else {
-        let str = ''
-        val.forEach(el => {
-          str += el.code + '.' + el.name + ' '
-        })
-        return str
-      }
+      val = JSON.parse(val)
+      let str = ''
+      val.forEach(el => {
+        str += el.Code + '.' + el.Name + ' '
+      })
+      return str
+    },
+    //对应数据字典变化
+    changeDictionaryCas({ val, labels }) {
+      this.dictionaryData = val;
+      this.dictionaryNames = labels
+      this.infoDict = this.$refs.dictionaryCas.pointDataSource
+      this.unitObj = this.infoDict[val[val.length - 1]]
+      this.InfomationPoint = this.unitObj.infoPointName || ''
     }
   }
 }