Commit 2b2a1c3bdbcf25a06dd767d795143addaaa283c5
1 parent
56943d39
fix: DEFECT-1741 修改报表导出点击报表查看趋势图里属性映射成物模型的标识符名
Showing
1 changed file
with
59 additions
and
6 deletions
| ... | ... | @@ -34,7 +34,12 @@ |
| 34 | 34 | @change="(value) => handleChangeChars(value, item.device, item)" |
| 35 | 35 | v-bind="createPickerSearch()" |
| 36 | 36 | placeholder="请选择设备属性" |
| 37 | - :options="item?.attributes?.map((item1) => ({ label: item1, value: item1 }))" | |
| 37 | + :options=" | |
| 38 | + item?.attributes?.map((attrItem: any) => ({ | |
| 39 | + label: attrItem.label, | |
| 40 | + value: attrItem.value, | |
| 41 | + })) | |
| 42 | + " | |
| 38 | 43 | /> |
| 39 | 44 | </div> |
| 40 | 45 | <div class="w-full h-full flex justify-center items-center"> |
| ... | ... | @@ -64,6 +69,8 @@ |
| 64 | 69 | import { ExecuteReportRecord } from '/@/api/export/model/exportModel'; |
| 65 | 70 | import { Select, Spin, Empty } from 'ant-design-vue'; |
| 66 | 71 | import { createPickerSearch } from '/@/utils/pickerSearch'; |
| 72 | + import { getDeviceDetail } from '/@/api/device/deviceManager'; | |
| 73 | + import { getAttribute } from '/@/api/ruleengine/ruleengineApi'; | |
| 67 | 74 | |
| 68 | 75 | interface ResponsData { |
| 69 | 76 | attr: string; |
| ... | ... | @@ -141,20 +148,66 @@ |
| 141 | 148 | return chartOption; |
| 142 | 149 | }; |
| 143 | 150 | |
| 151 | + const handleDeviceProfileAttributes = async (entityId: string) => { | |
| 152 | + const deviceDetailRes = await getDeviceDetail(entityId); | |
| 153 | + const { deviceProfileId } = deviceDetailRes; | |
| 154 | + if (!deviceProfileId) return; | |
| 155 | + const attributeRes = await getAttribute(deviceProfileId); | |
| 156 | + return handleDataFormat(deviceDetailRes, attributeRes); | |
| 157 | + }; | |
| 158 | + | |
| 159 | + const handleDataFormat = (deviceDetail: any, attributes: any) => { | |
| 160 | + const { name, tbDeviceId } = deviceDetail; | |
| 161 | + const attribute = attributes.map((item: any) => ({ | |
| 162 | + identifier: item.identifier, | |
| 163 | + name: item.name, | |
| 164 | + detail: item.detail, | |
| 165 | + })); | |
| 166 | + return { | |
| 167 | + name, | |
| 168 | + tbDeviceId, | |
| 169 | + attribute, | |
| 170 | + }; | |
| 171 | + }; | |
| 172 | + | |
| 144 | 173 | const [register, { setModalProps }] = useModalInner( |
| 145 | 174 | async (data: { record: ExecuteReportRecord }) => { |
| 146 | 175 | setModalProps({ loading: true }); |
| 147 | 176 | try { |
| 148 | 177 | currentRecord = data.record; |
| 149 | 178 | const deviceInfo = data.record.executeCondition.executeAttributes || []; |
| 150 | - chartInstance.value = deviceInfo.map((item) => ({ | |
| 151 | - ...item, | |
| 152 | - active: item.attributes.at(0), | |
| 153 | - })); | |
| 179 | + let attributesList: Recordable[] = []; | |
| 180 | + // 处理为物模型里的标识符名 | |
| 181 | + const reflectDeviceList = deviceInfo.map(async (item) => { | |
| 182 | + const { device, attributes } = item as Recordable; | |
| 183 | + if (!device) return; | |
| 184 | + const thingsModel = (await handleDeviceProfileAttributes(item.device)) as Recordable; | |
| 185 | + const { tbDeviceId, attribute } = thingsModel as Recordable; | |
| 186 | + if (!tbDeviceId) return; | |
| 187 | + if (device === tbDeviceId) { | |
| 188 | + attributesList = attributes.reduce((acc, curr) => { | |
| 189 | + attribute.forEach((item: Recordable) => { | |
| 190 | + if (item.identifier === curr) { | |
| 191 | + acc.push({ | |
| 192 | + label: item.name, | |
| 193 | + value: item.identifier, | |
| 194 | + }); | |
| 195 | + } | |
| 196 | + }); | |
| 197 | + return [...acc]; | |
| 198 | + }, []); | |
| 199 | + } | |
| 200 | + return { | |
| 201 | + ...item, | |
| 202 | + active: attributes.at(0), | |
| 203 | + attributes: attributesList, | |
| 204 | + }; | |
| 205 | + }); | |
| 206 | + chartInstance.value = (await Promise.all(reflectDeviceList)) as any as ChartInstance[]; | |
| 154 | 207 | for (const item of unref(chartInstance)) { |
| 155 | 208 | const { attributes, device } = item; |
| 156 | 209 | |
| 157 | - const keys = attributes.length ? attributes.at(0) : ''; | |
| 210 | + const keys = attributes.length ? (attributes as any[]).at(0)?.value : ''; | |
| 158 | 211 | |
| 159 | 212 | const sendParams = { |
| 160 | 213 | ...data.record.executeCondition.executeCondition, | ... | ... |