dedsudiyu 1 year ago
parent
commit
4262626696

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

@@ -25,6 +25,14 @@ export function iotTypeGetParamByTypeId(query) {
     params: query
   })
 }
+//通过设备类型查询设备属性
+export function iotAttributeGetByTypeId(query) {
+  return request({
+    url: '/iot/attribute/getByTypeId',
+    method: 'get',
+    params: query
+  })
+}
 
 //新增设备
 export function iotDeviceAdd(data) {

+ 3 - 3
src/views/iotDevice/intelligenceIot/iotClassification/infoPage.vue

@@ -154,12 +154,12 @@
               </el-select>
             </el-form-item>
             <el-form-item>
-              <p class="inquire-button-one" @click="handleQuery" style="margin-right:10px;">查询</p>
-              <p class="reset-button-one" @click="resetQuery">重置</p>
+              <p class="page-inquire-common-style-button" @click="handleQuery" style="margin-right:10px;">查询</p>
+              <p class="page-reset-common-style-button" @click="resetQuery">重置</p>
             </el-form-item>
             <el-form-item label="" prop="title" style="float: right">
               <el-col :span="1.5" style="margin-right:10px;">
-                <p class="add-button-one-90"
+                <p class="page-add-common-style-button"
                    @click="dialogOpen"
                 >新增</p>
               </el-col>

+ 43 - 1
src/views/iotDevice/intelligenceIot/iotHardware/addPage.vue

@@ -24,6 +24,15 @@
                   :value="dict.typeId"/>
               </el-select>
             </el-form-item>
+            <el-form-item label="设备属性:" prop="attributeId">
+              <el-select v-model="newData.attributeId " @change="selectChangeStats" placeholder="请选择类型" style="width: 500px">
+                <el-option
+                  v-for="dict in optionsStats"
+                  :key="dict.id"
+                  :label="dict.name"
+                  :value="dict.id"/>
+              </el-select>
+            </el-form-item>
             <el-form-item label="状态:" prop="state">
               <el-radio-group v-model="newData.state">
                 <el-radio :label="true">启用</el-radio>
@@ -67,7 +76,7 @@
 
 <script>
   import { systemBuildingGetTreeList,} from "@/api/commonality/permission";
-  import { iotTypeGetAllTypes,iotTypeGetParamByTypeId,iotDeviceAdd,iotDeviceUpdate,iotDeviceDelete } from "@/api/iotDevice/index";
+  import { iotTypeGetAllTypes,iotTypeGetParamByTypeId,iotAttributeGetByTypeId,iotDeviceAdd,iotDeviceUpdate,iotDeviceDelete } from "@/api/iotDevice/index";
   import forElFormItem from "./forElFormItem.vue";
   export default {
     name: 'addPage',
@@ -80,6 +89,7 @@
     data(){
       return{
         options:[],
+        optionsStats:[],
         subOptions:[{id:'1',name:'实验室-1',room:'11'},{id:'2',name:'实验室-2',room:'22'}],
         treeOptions:[],
         newData:{},
@@ -95,6 +105,9 @@
           typeId: [
             { required: true, message: "请选择设备类型", trigger: "blur" },
           ],
+          attributeId: [
+            { required: true, message: "请选择设备属性", trigger: "blur" },
+          ],
           state: [
             { required: true, message: "请选择状态", trigger: "blur" },
           ],
@@ -118,8 +131,25 @@
 
     },
     methods:{
+      //设备属性选中
+      selectChangeStats(val){
+        let self = this;
+        for(let i=0;i<self.optionsStats.length;i++){
+          if(val == self.optionsStats[i].id){
+            self.$set(self.newData,'code',self.optionsStats[i].code);
+          }
+        }
+      },
       //设备类型选中
       selectChange(val){
+        let self = this;
+        for(let i=0;i<self.options.length;i++){
+          if(val == self.options[i].typeId){
+            self.$set(self.newData,'typekey',self.options[i].typekey);
+          }
+        }
+        this.$set(this.newData,'attributeId','');
+        this.$set(this.newData,'code','');
         iotTypeGetParamByTypeId({typeId:val}).then(response => {
           //处理返回数据
           let formData = {};
@@ -164,6 +194,9 @@
             this.$refs.forElFormItem.$refs["form"].resetFields();
           }
         });
+        iotAttributeGetByTypeId({typeId:val}).then(response => {
+          this.$set(this,'optionsStats',response.data);
+        });
       },
       //初始化
       initialize(){
@@ -197,6 +230,9 @@
             deviceName:this.propsData.deviceName,
             deviceNo:this.propsData.deviceNo,
             typeId:this.propsData.typeId,
+            typekey:this.propsData.typekey,
+            attributeId:this.propsData.attributeId,
+            code:this.propsData.code,
             state:this.propsData.state,
             address:[this.propsData.schoolId,this.propsData.buildId,this.propsData.floorId],
             subId:this.propsData.subjectId,
@@ -239,11 +275,17 @@
               this.$refs.forElFormItem.$refs["form"].resetFields();
             }
           })
+          iotAttributeGetByTypeId({typeId:this.propsData.typeId}).then(response => {
+            this.$set(this,'optionsStats',response.data);
+          });
         }else{
           this.$set(this,'newData',{
             deviceName:'',
             deviceNo:'',
             typeId:'',
+            typekey:'',
+            attributeId:'',
+            code:'',
             state:true,
             address:[],
             subId:'',