|
|
|
|
@ -65,17 +65,27 @@
|
|
|
|
|
:key="index"
|
|
|
|
|
class="w-full flex items-center gap-8px"
|
|
|
|
|
>
|
|
|
|
|
<el-cascader
|
|
|
|
|
v-model='rule.pointValue'
|
|
|
|
|
:options='devicePointOptions'
|
|
|
|
|
:props='devicePointCascaderProps'
|
|
|
|
|
filterable
|
|
|
|
|
clearable
|
|
|
|
|
class="!w-full"
|
|
|
|
|
:placeholder="t('EnergyManagement.EnergyDevice.dialogRulesPointPlaceholder')"
|
|
|
|
|
:show-all-levels='false'
|
|
|
|
|
@change='(val) => handlePointSelected(index, val)'
|
|
|
|
|
/>
|
|
|
|
|
<div class="flex-1 min-w-0">
|
|
|
|
|
<el-tooltip
|
|
|
|
|
:content="getRuleRatioTooltip(rule)"
|
|
|
|
|
:disabled="!getRuleRatioTooltip(rule)"
|
|
|
|
|
placement="top"
|
|
|
|
|
>
|
|
|
|
|
<div class="w-full">
|
|
|
|
|
<el-cascader
|
|
|
|
|
v-model='rule.pointValue'
|
|
|
|
|
:options='devicePointOptions'
|
|
|
|
|
:props='devicePointCascaderProps'
|
|
|
|
|
filterable
|
|
|
|
|
clearable
|
|
|
|
|
class="!w-full"
|
|
|
|
|
:placeholder="t('EnergyManagement.EnergyDevice.dialogRulesPointPlaceholder')"
|
|
|
|
|
:show-all-levels='false'
|
|
|
|
|
@change='(val) => handlePointSelected(index, val)'
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</el-tooltip>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<template v-if="index < formData.operationRulesVOList.length - 1">
|
|
|
|
|
<el-select
|
|
|
|
|
@ -227,6 +237,7 @@ type DevicePointOption = {
|
|
|
|
|
label: string
|
|
|
|
|
leaf?: boolean
|
|
|
|
|
dataType?: string | null
|
|
|
|
|
ratio?: number | string | null
|
|
|
|
|
children?: DevicePointOption[]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -300,6 +311,16 @@ const findPointDataType = (deviceId: any, pointId: any): string | undefined => {
|
|
|
|
|
return devicePointCache.get(String(deviceId))?.find((point) => isSameId(point.value, pointId))?.dataType as string | undefined
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getRuleRatioTooltip = (rule: any) => {
|
|
|
|
|
const [deviceId, pointId] = Array.isArray(rule?.pointValue)
|
|
|
|
|
? rule.pointValue
|
|
|
|
|
: [rule?.deviceId, rule?.pointId]
|
|
|
|
|
const ratio = devicePointCache.get(String(deviceId))
|
|
|
|
|
?.find((point) => isSameId(point.value, pointId))?.ratio
|
|
|
|
|
if (ratio === undefined || ratio === null || ratio === '') return ''
|
|
|
|
|
return t('EnergyManagement.EnergyDevice.dialogRulesRatioTooltip', { ratio })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const open = async (type: string, id?: number) => {
|
|
|
|
|
dialogVisible.value = true
|
|
|
|
|
dialogTitle.value = t('action.' + type)
|
|
|
|
|
@ -417,7 +438,13 @@ const loadDevicePoints = async (deviceId: number | string): Promise<DevicePointO
|
|
|
|
|
const cached = devicePointCache.get(cacheKey)
|
|
|
|
|
if (cached) return cached
|
|
|
|
|
const data = await DeviceApi.getDeviceAttributePage({ pageNo: 1, pageSize: 100, deviceId })
|
|
|
|
|
const points = (data?.list ?? []).map((point: any) => ({ value: point.id, label: String(point.attributeName ?? point.attributeCode ?? point.id), leaf: true, dataType: point.dataType ?? point.type ?? undefined }))
|
|
|
|
|
const points = (data?.list ?? []).map((point: any) => ({
|
|
|
|
|
value: point.id,
|
|
|
|
|
label: String(point.attributeName ?? point.attributeCode ?? point.id),
|
|
|
|
|
leaf: true,
|
|
|
|
|
dataType: point.dataType ?? point.type ?? undefined,
|
|
|
|
|
ratio: point.ratio
|
|
|
|
|
}))
|
|
|
|
|
devicePointCache.set(cacheKey, points)
|
|
|
|
|
const device = devicePointOptions.value.find((item) => isSameId(item.value, deviceId))
|
|
|
|
|
if (device) device.children = points
|
|
|
|
|
|