|
@@ -727,7 +727,10 @@ export default {
|
|
|
// 楼控设备相关 - 新增
|
|
// 楼控设备相关 - 新增
|
|
|
baDeviceModels: [
|
|
baDeviceModels: [
|
|
|
{ modelCode: 'M_Z020_DEV_BA_XF', modelName: 'BA新风设备' },
|
|
{ modelCode: 'M_Z020_DEV_BA_XF', modelName: 'BA新风设备' },
|
|
|
- { modelCode: 'M_Z020_DEV_BA_AHU', modelName: 'BA空调设备' }
|
|
|
|
|
|
|
+ { modelCode: 'M_Z020_DEV_BA_AHU', modelName: 'BA空调设备' },
|
|
|
|
|
+ { modelCode: 'M_Z020_DEV_BA_WT', modelName: 'BA水箱监测' },
|
|
|
|
|
+ { modelCode: 'M_Z020_DEV_BA_WP', modelName: 'BA水泵监测' },
|
|
|
|
|
+ { modelCode: 'M_Z020_DEV_BA_LIGHT', modelName: 'BA照明监测' },
|
|
|
],
|
|
],
|
|
|
selectedBaDeviceModel: 'M_Z020_DEV_BA_XF',
|
|
selectedBaDeviceModel: 'M_Z020_DEV_BA_XF',
|
|
|
baDeviceList: [],
|
|
baDeviceList: [],
|
|
@@ -1453,7 +1456,14 @@ export default {
|
|
|
|
|
|
|
|
this.baDeviceLoading = true
|
|
this.baDeviceLoading = true
|
|
|
try {
|
|
try {
|
|
|
- // 查询指定模型的设备
|
|
|
|
|
|
|
+ // 1. 先查询设备物模型,获取属性定义
|
|
|
|
|
+ const modelRes = await getModelByCode(this.selectedBaDeviceModel)
|
|
|
|
|
+ const modelData = modelRes.data
|
|
|
|
|
+
|
|
|
|
|
+ // 缓存当前模型的属性定义
|
|
|
|
|
+ this.$set(this.baDeviceAttrs, '_model_' + this.selectedBaDeviceModel, modelData)
|
|
|
|
|
+
|
|
|
|
|
+ // 2. 查询指定模型的设备列表
|
|
|
const res = await getByCondition({
|
|
const res = await getByCondition({
|
|
|
subsystemCode: this.systemCode,
|
|
subsystemCode: this.systemCode,
|
|
|
deviceModel: this.selectedBaDeviceModel
|
|
deviceModel: this.selectedBaDeviceModel
|
|
@@ -1466,7 +1476,7 @@ export default {
|
|
|
detailTab: 'base'
|
|
detailTab: 'base'
|
|
|
}))
|
|
}))
|
|
|
|
|
|
|
|
- // 批量加载设备属性
|
|
|
|
|
|
|
+ // 3. 批量加载设备属性值
|
|
|
if (this.baDeviceList.length > 0) {
|
|
if (this.baDeviceList.length > 0) {
|
|
|
await this.loadBaDeviceAttrsBatch(this.selectedBaDeviceModel)
|
|
await this.loadBaDeviceAttrsBatch(this.selectedBaDeviceModel)
|
|
|
}
|
|
}
|
|
@@ -1494,13 +1504,53 @@ export default {
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- // 获取楼控设备的属性(按组)
|
|
|
|
|
|
|
+ // 获取楼控设备的属性(按组) - 修改:合并模型定义和实际值
|
|
|
getBaDeviceAttrs(deviceCode, attrGroup) {
|
|
getBaDeviceAttrs(deviceCode, attrGroup) {
|
|
|
- const attrData = this.baDeviceAttrs[deviceCode]
|
|
|
|
|
- if (!attrData || !attrData[attrGroup]) {
|
|
|
|
|
- return []
|
|
|
|
|
- }
|
|
|
|
|
- return attrData[attrGroup]
|
|
|
|
|
|
|
+ // 获取设备所属的模型
|
|
|
|
|
+ const device = this.baDeviceList.find(d => d.deviceCode === deviceCode)
|
|
|
|
|
+ if (!device) return []
|
|
|
|
|
+
|
|
|
|
|
+ // 获取模型定义
|
|
|
|
|
+ const modelData = this.baDeviceAttrs['_model_' + device.deviceModel]
|
|
|
|
|
+ if (!modelData || !modelData.attrList) return []
|
|
|
|
|
+
|
|
|
|
|
+ // 筛选出当前分组的属性定义
|
|
|
|
|
+ const modelAttrs = modelData.attrList.filter(attr => attr.attrGroup === attrGroup)
|
|
|
|
|
+
|
|
|
|
|
+ // 获取设备的实际属性值
|
|
|
|
|
+ const deviceAttrData = this.baDeviceAttrs[deviceCode]
|
|
|
|
|
+ const deviceAttrs = deviceAttrData && deviceAttrData[attrGroup] ? deviceAttrData[attrGroup] : []
|
|
|
|
|
+
|
|
|
|
|
+ // 将实际值映射到字典
|
|
|
|
|
+ const attrValueMap = {}
|
|
|
|
|
+ deviceAttrs.forEach(attr => {
|
|
|
|
|
+ attrValueMap[attr.attrKey] = attr
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ // 合并模型定义和实际值
|
|
|
|
|
+ const mergedAttrs = modelAttrs.map(modelAttr => {
|
|
|
|
|
+ const actualAttr = attrValueMap[modelAttr.attrKey]
|
|
|
|
|
+
|
|
|
|
|
+ if (actualAttr) {
|
|
|
|
|
+ // 有实际值,返回实际值
|
|
|
|
|
+ return actualAttr
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 没有实际值,返回模型定义的空属性
|
|
|
|
|
+ return {
|
|
|
|
|
+ objCode: deviceCode,
|
|
|
|
|
+ attrGroup: modelAttr.attrGroup,
|
|
|
|
|
+ attrKey: modelAttr.attrKey,
|
|
|
|
|
+ attrName: modelAttr.attrName,
|
|
|
|
|
+ attrValue: null,
|
|
|
|
|
+ attrValueName: null,
|
|
|
|
|
+ attrValueType: modelAttr.attrValueType,
|
|
|
|
|
+ attrUnit: modelAttr.attrUnit,
|
|
|
|
|
+ updateTime: null
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ return mergedAttrs
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
// 格式化楼控设备属性值
|
|
// 格式化楼控设备属性值
|