Commit 6abc3a90 authored by wends's avatar wends

update 设备详情

parent 24c15e14
......@@ -73,7 +73,7 @@
v-for="(property, index) in propertyList"
:key="index"
:label="property.propertyName"
:value="`${property.propertyValue} ${property.propertyUnit}`"
:value="formatProperty(property)"
/>
</descriptions>
</el-tab-pane>
......@@ -135,17 +135,37 @@ export default {
},
created() {
const { deviceTypeId, deviceInstanceId } = this.$route.query
getAllDeviceModel()
.then(res => {
this.deviceTypeList = res.data
this.form.deviceType = deviceTypeId || (this.deviceTypeList.length ? this.deviceTypeList[0].id : null)
this.getAllInstanceByDeviceTypeId(this.form.deviceType, deviceInstanceId)
this.getDataModelByDeviceTypeId(this.form.deviceType)
this.getDeviceInstanceDetail(this.form.deviceType)
})
.catch(_ => {})
// getAllDeviceModel()
// .then(res => {
// this.deviceTypeList = res.data
// this.form.deviceType = deviceTypeId || (this.deviceTypeList.length ? this.deviceTypeList[0].id : null)
// this.getAllInstanceByDeviceTypeId(this.form.deviceType, deviceInstanceId)
// this.getDataModelByDeviceTypeId(this.form.deviceType)
// this.getDeviceInstanceDetail(this.form.deviceType)
// })
// .catch(_ => {})
this.init(deviceTypeId, deviceInstanceId)
},
methods: {
async init(deviceTypeId, deviceInstanceId) {
const deviceTypeList = await getAllDeviceModel()
this.deviceTypeList = deviceTypeList.data
this.form.deviceType = deviceTypeId || (this.deviceTypeList.length ? this.deviceTypeList[0].id : null)
const deviceInstanceList = await getAllInstanceByDeviceTypeId({ deviceTypeId: this.form.deviceType })
this.deviceInstanceList = deviceInstanceList.data
this.form.deviceInstance = deviceInstanceId || this.deviceInstanceList.length ? this.deviceInstanceList[0].id : null
const dataModelList = await getDataModelByDeviceTypeId({ id: this.form.deviceType })
this.dataModelList = dataModelList.data
this.activeDataModel = this.dataModelList.length ? this.dataModelList[0].name : null
await this.getDeviceInstanceDetail(this.form.deviceType)
await this.getPropertyDetail(this.dataModelList[0].id, this.form.deviceInstance)
return {}
},
formatProperty(property) {
return property.propertyValue ? `${property.propertyValue} ${property.propertyUnit}` : ''
},
onTabClick() {
const dataModel = this.dataModelList.find(v => v.name === this.activeDataModel)
this.getPropertyDetail(dataModel.id, this.form.deviceInstance)
......@@ -187,7 +207,6 @@ export default {
this.dataModelList = res.data
if (this.dataModelList.length) {
this.activeDataModel = this.dataModelList[0].name
this.getPropertyDetail(this.dataModelList[0].id, this.form.deviceInstance)
}
})
.catch(_ => {})
......@@ -195,13 +214,14 @@ export default {
getPropertyDetail(dataModelId, deviceId) {
getPropertyDetail({ dataModelId, deviceId })
.then(res => {
this.propertyList = res.data.propertyList
this.propertyList = res.data.propertyList.length ? res.data.propertyList : []
})
.catch(_ => {})
},
queryData() {
this.getDataModelByDeviceTypeId(this.form.deviceType)
this.getDeviceInstanceDetail(this.form.deviceType)
this.getPropertyDetail(this.dataModelList[0].id, this.form.deviceInstance)
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment