Commit 6abc3a90 authored by wends's avatar wends

update 设备详情

parent 24c15e14
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
v-for="(property, index) in propertyList" v-for="(property, index) in propertyList"
:key="index" :key="index"
:label="property.propertyName" :label="property.propertyName"
:value="`${property.propertyValue} ${property.propertyUnit}`" :value="formatProperty(property)"
/> />
</descriptions> </descriptions>
</el-tab-pane> </el-tab-pane>
...@@ -135,17 +135,37 @@ export default { ...@@ -135,17 +135,37 @@ export default {
}, },
created() { created() {
const { deviceTypeId, deviceInstanceId } = this.$route.query const { deviceTypeId, deviceInstanceId } = this.$route.query
getAllDeviceModel() // getAllDeviceModel()
.then(res => { // .then(res => {
this.deviceTypeList = res.data // this.deviceTypeList = res.data
this.form.deviceType = deviceTypeId || (this.deviceTypeList.length ? this.deviceTypeList[0].id : null) // this.form.deviceType = deviceTypeId || (this.deviceTypeList.length ? this.deviceTypeList[0].id : null)
this.getAllInstanceByDeviceTypeId(this.form.deviceType, deviceInstanceId) // this.getAllInstanceByDeviceTypeId(this.form.deviceType, deviceInstanceId)
this.getDataModelByDeviceTypeId(this.form.deviceType) // this.getDataModelByDeviceTypeId(this.form.deviceType)
this.getDeviceInstanceDetail(this.form.deviceType) // this.getDeviceInstanceDetail(this.form.deviceType)
}) // })
.catch(_ => {}) // .catch(_ => {})
this.init(deviceTypeId, deviceInstanceId)
}, },
methods: { 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() { onTabClick() {
const dataModel = this.dataModelList.find(v => v.name === this.activeDataModel) const dataModel = this.dataModelList.find(v => v.name === this.activeDataModel)
this.getPropertyDetail(dataModel.id, this.form.deviceInstance) this.getPropertyDetail(dataModel.id, this.form.deviceInstance)
...@@ -187,7 +207,6 @@ export default { ...@@ -187,7 +207,6 @@ export default {
this.dataModelList = res.data this.dataModelList = res.data
if (this.dataModelList.length) { if (this.dataModelList.length) {
this.activeDataModel = this.dataModelList[0].name this.activeDataModel = this.dataModelList[0].name
this.getPropertyDetail(this.dataModelList[0].id, this.form.deviceInstance)
} }
}) })
.catch(_ => {}) .catch(_ => {})
...@@ -195,13 +214,14 @@ export default { ...@@ -195,13 +214,14 @@ export default {
getPropertyDetail(dataModelId, deviceId) { getPropertyDetail(dataModelId, deviceId) {
getPropertyDetail({ dataModelId, deviceId }) getPropertyDetail({ dataModelId, deviceId })
.then(res => { .then(res => {
this.propertyList = res.data.propertyList this.propertyList = res.data.propertyList.length ? res.data.propertyList : []
}) })
.catch(_ => {}) .catch(_ => {})
}, },
queryData() { queryData() {
this.getDataModelByDeviceTypeId(this.form.deviceType) this.getDataModelByDeviceTypeId(this.form.deviceType)
this.getDeviceInstanceDetail(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