dedsudiyu 1 年之前
父節點
當前提交
80adad9de5
共有 2 個文件被更改,包括 60 次插入2 次删除
  1. 9 0
      src/api/iotDevice/index.js
  2. 51 2
      src/views/iotDevice/intelligenceIot/iotClassification/attributePage.vue

+ 9 - 0
src/api/iotDevice/index.js

@@ -130,6 +130,7 @@ export function iotDeviceAddBatch(data) {
     data: data
   })
 }
+
 /************物联分类************/
 //物联分类列表
 export function iotTypeList(data) {
@@ -246,6 +247,14 @@ export function iotAttributeMoveDown(data) {
   })
 }
 
+//物联分类-配置-属性类别(分类下的子标识)列表
+export function iotAttributeAttrType(query) {
+  return request({
+    url: '/iot/attribute/attrType',
+    method: 'get',
+    params: query
+  })
+}
 //物联分类-配置-模块列表
 export function iotTypeTypeModelAndAttr(query) {
   return request({

+ 51 - 2
src/views/iotDevice/intelligenceIot/iotClassification/attributePage.vue

@@ -116,7 +116,17 @@
           <el-form-item label="名称" prop="name">
             <el-input v-model="dialogForm.name" placeholder="请输入名称" maxLength="10" style="width:320px;"/>
           </el-form-item>
-          <el-form-item label="标识" prop="code">
+          <el-form-item label="标识" prop="code" v-if="dialogAttrType">
+            <el-select v-model="dialogForm.code" clearable placeholder="请选择" style="width: 320px">
+              <el-option
+                v-for="dict in attrTypeOptions"
+                :key="dict.code"
+                :label="dict.name"
+                :value="dict.code"
+              />
+            </el-select>
+          </el-form-item>
+          <el-form-item label="标识" prop="code" v-if="!dialogAttrType">
             <el-input v-model="dialogForm.code" placeholder="请输入标识" maxLength="20" style="width:320px;"/>
           </el-form-item>
           <el-form-item label="属性" prop="attrName">
@@ -209,7 +219,7 @@
   import { getToken } from "@/utils/auth";
   import { iotAttributeList,iotAttributeAdd,iotNetworkInfo,
     iotAttributeUpdate,iotAttributeDelete,iotAttributeDetail,
-    iotAttributeMoveUp,iotAttributeMoveDown  } from "@/api/iotDevice/index";
+    iotAttributeMoveUp,iotAttributeMoveDown,iotAttributeAttrType  } from "@/api/iotDevice/index";
   export default {
     name: 'attributePage',
     data(){
@@ -222,6 +232,10 @@
         loading:false,
         options:[{label:'启用',value:true},{label:'停用',value:false}],
         networkOptions:[],
+        //子标识列表
+        attrTypeOptions:[],
+        //原始数据
+        attrTypeOptionsList:[],
         queryParams:{
           typeId:this.$parent.propsData.typeId,
           page:1,
@@ -234,6 +248,8 @@
         //弹层
         dialogTitle:null,
         dialogType:false,
+        //标识状态(列表或者输入)
+        dialogAttrType:true,
         dialogForm:{
           name:"",
           code:"",
@@ -274,6 +290,7 @@
     mounted(){
       this.getList();
       this.iotNetworkInfo();
+      this.iotAttributeAttrType();
     },
     methods:{
       //获取网络组件列表
@@ -282,6 +299,11 @@
           this.$set(this,'networkOptions',response.data);
         });
       },
+      iotAttributeAttrType(){
+        iotAttributeAttrType({typeKey:this.$parent.propsData.typeKey}).then(response => {
+          this.$set(this,'attrTypeOptionsList',response.data);
+        });
+      },
       //属性
       getList(){
         let obj = JSON.parse(JSON.stringify(this.queryParams))
@@ -313,6 +335,11 @@
       //弹层开启
       dialogOpen(){
         this.dialogFormReset();
+        if(this.attrTypeOptionsList[0]){
+          this.$set(this,'attrTypeOptions',JSON.parse(JSON.stringify(this.attrTypeOptionsList)));
+        }else{
+          this.$set(this,'dialogAttrType',false);
+        }
         this.$set(this,'dialogTitle','新增');
         this.$set(this,'dialogType',true);
       },
@@ -389,6 +416,28 @@
             exceptionIcon:row.exceptionIcon,
             state:row.state,
           }
+          //子标识判定
+          if(this.attrTypeOptionsList[0]){
+            if(obj.code[0]){
+              let num = 0;
+              for(let i=0;i<self.attrTypeOptionsList.length;i++){
+                if(obj.code == self.attrTypeOptionsList[i].code){
+                  num++
+                }
+              }
+              if(num == 0){
+                obj.code = '';
+              }
+              this.$set(this,'dialogAttrType',true);
+              this.$set(this,'attrTypeOptions',JSON.parse(JSON.stringify(this.attrTypeOptionsList)));
+            }else{
+              this.$set(this,'dialogAttrType',true);
+              this.$set(this,'attrTypeOptions',JSON.parse(JSON.stringify(this.attrTypeOptionsList)));
+            }
+          }else{
+            this.$set(this,'dialogAttrType',false);
+            this.$set(this,'attrTypeOptions',[]);
+          }
           this.$set(this,'dialogForm',obj);
           this.$set(this,'dialogTitle','编辑');
           this.$set(this,'dialogType',true);