|
@@ -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:'',
|