|  | @@ -85,6 +85,16 @@ |  | @@ -85,6 +85,16 @@ | 
| 85 | useTable({ | 85 | useTable({ | 
| 86 | title: '告警记录列表', | 86 | title: '告警记录列表', | 
| 87 | api: getDeviceAlarm, | 87 | api: getDeviceAlarm, | 
|  |  | 88 | +          beforeFetch: (params) => { | 
|  |  | 89 | +            const { status } = params; | 
|  |  | 90 | +            const obj = { | 
|  |  | 91 | +              ...params, | 
|  |  | 92 | +              ...{ | 
|  |  | 93 | +                status: status ? status.at(-1) : null, | 
|  |  | 94 | +              }, | 
|  |  | 95 | +            }; | 
|  |  | 96 | +            return obj; | 
|  |  | 97 | +          }, | 
| 88 | columns: alarmColumns, | 98 | columns: alarmColumns, | 
| 89 | rowKey: 'id', | 99 | rowKey: 'id', | 
| 90 | useSearchForm: true, | 100 | useSearchForm: true, | 
|  | @@ -120,25 +130,25 @@ |  | @@ -120,25 +130,25 @@ | 
| 120 | reload(); | 130 | reload(); | 
| 121 | }; | 131 | }; | 
| 122 |  | 132 |  | 
| 123 | -      const findName = (item: any, curr: any) => { |  |  | 
| 124 | -        return item.attribute.find((item) => item.identifier === curr.key)?.name; | 133 | +      const findName = (item: Recordable, curr: Recordable) => { | 
|  |  | 134 | +        return item.attribute.find((item) => item.identifier === curr?.key)?.name; | 
| 125 | }; | 135 | }; | 
| 126 |  | 136 |  | 
| 127 | -      const findLogin = (curr: any) => { | 137 | +      const findLogin = (curr: Recordable) => { | 
| 128 | return [...operationNumber_OR_TIME, ...operationString, ...operationBoolean].find( | 138 | return [...operationNumber_OR_TIME, ...operationString, ...operationBoolean].find( | 
| 129 | -          (item) => item.value === curr.logic | 139 | +          (item) => item.value === curr?.logic | 
| 130 | )?.symbol; | 140 | )?.symbol; | 
| 131 | }; | 141 | }; | 
| 132 |  | 142 |  | 
| 133 | -      const findAttribute = (item: any, curr: any) => { |  |  | 
| 134 | -        item.attribute.find((findItem) => findItem.identifier === curr.key); | 143 | +      const findAttribute = (item: Recordable, curr: Recordable) => { | 
|  |  | 144 | +        item.attribute.find((findItem) => findItem.identifier === curr?.key); | 
| 135 | }; | 145 | }; | 
| 136 |  | 146 |  | 
| 137 | -      const findValue = (item: any, curr: any) => { | 147 | +      const findValue = (item: Recordable, curr: Recordable) => { | 
| 138 | return { | 148 | return { | 
| 139 | ['触发属性']: findName(item, curr), | 149 | ['触发属性']: findName(item, curr), | 
| 140 | -          ['触发条件']: `${findLogin(curr)}${curr.logicValue}`, |  |  | 
| 141 | -          ['触发值']: `${curr.realValue}${ | 150 | +          ['触发条件']: `${findLogin(curr)}${curr?.logicValue}`, | 
|  |  | 151 | +          ['触发值']: `${curr?.realValue}${ | 
| 142 | findAttribute(item, curr)?.detail?.dataType?.specs?.unit?.key ?? '' | 152 | findAttribute(item, curr)?.detail?.dataType?.specs?.unit?.key ?? '' | 
| 143 | }`, | 153 | }`, | 
| 144 | }; | 154 | }; | 
|  | @@ -151,56 +161,62 @@ |  | @@ -151,56 +161,62 @@ | 
| 151 | const { details } = record; | 161 | const { details } = record; | 
| 152 | if (!details) return; | 162 | if (!details) return; | 
| 153 | const deviceIdKeys = Object.keys(details); | 163 | const deviceIdKeys = Object.keys(details); | 
| 154 | -        const detailObject = deviceIdKeys.map((key) => ({ label: key, value: details[key] })); |  |  | 
| 155 | const dataFormat = await handleAlarmDetailFormat(deviceIdKeys); | 164 | const dataFormat = await handleAlarmDetailFormat(deviceIdKeys); | 
| 156 | -        const dataFormats = detailObject.reduce((acc: Recordable[], curr: Recordable) => { |  |  | 
| 157 | -          let currentObj: Recordable = {}; |  |  | 
| 158 | -          dataFormat.forEach((item) => { |  |  | 
| 159 | -            if (item.tbDeviceId === curr.label) { |  |  | 
| 160 | -              const { triggerData, conditionData } = curr.value; |  |  | 
| 161 | -              if (triggerData || conditionData) { |  |  | 
| 162 | -                for (let currItem in curr.value) { |  |  | 
| 163 | -                  const value = findValue(item, curr.value[currItem]); |  |  | 
| 164 | -                  currentObj = { |  |  | 
| 165 | -                    [item.name]: { |  |  | 
| 166 | -                      [handleAlarmText(currItem)]: value, |  |  | 
| 167 | -                    }, |  |  | 
| 168 | -                  }; |  |  | 
| 169 | -                  acc.push(currentObj); |  |  | 
| 170 | -                } |  |  | 
| 171 | -              } else { |  |  | 
| 172 | -                const value = findValue(item, curr.value); |  |  | 
| 173 | -                currentObj = { |  |  | 
| 174 | -                  [item.name]: value, |  |  | 
| 175 | -                }; |  |  | 
| 176 | -                acc.push(currentObj); |  |  | 
| 177 | -              } | 165 | +        const mapDataFormat = deviceIdKeys.map((deviceKey: string) => { | 
|  |  | 166 | +          const findDataFormat = dataFormat.find( | 
|  |  | 167 | +            (dataItem: Recordable) => dataItem.tbDeviceId === deviceKey | 
|  |  | 168 | +          ); | 
|  |  | 169 | +          const dataKeys = Object.keys(details[deviceKey]); | 
|  |  | 170 | +          const data: any = dataKeys.map((dataItem: string) => { | 
|  |  | 171 | +            if (dataItem !== 'triggerData' && dataItem !== 'conditionData') { | 
|  |  | 172 | +              return findValue(findDataFormat, details[deviceKey]); | 
|  |  | 173 | +            } else { | 
|  |  | 174 | +              return { | 
|  |  | 175 | +                [handleAlarmText(dataItem)]: findValue( | 
|  |  | 176 | +                  findDataFormat, | 
|  |  | 177 | +                  details[deviceKey][dataItem] | 
|  |  | 178 | +                ), | 
|  |  | 179 | +              }; | 
| 178 | } | 180 | } | 
| 179 | }); | 181 | }); | 
| 180 | -          return [...acc]; |  |  | 
| 181 | -        }, []); | 182 | +          const objectDataFormat = data.reduce((acc: Recordable, curr: Recordable) => { | 
|  |  | 183 | +            return { | 
|  |  | 184 | +              ...acc, | 
|  |  | 185 | +              ...curr, | 
|  |  | 186 | +            }; | 
|  |  | 187 | +          }); | 
|  |  | 188 | +          return { | 
|  |  | 189 | +            [findDataFormat.name]: objectDataFormat, | 
|  |  | 190 | +          }; | 
|  |  | 191 | +        }); | 
|  |  | 192 | +        const objectDataFormats = mapDataFormat.reduce((acc: Recordable, curr: Recordable) => { | 
|  |  | 193 | +          return { | 
|  |  | 194 | +            ...acc, | 
|  |  | 195 | +            ...curr, | 
|  |  | 196 | +          }; | 
|  |  | 197 | +        }); | 
| 182 | Modal.info({ | 198 | Modal.info({ | 
| 183 | title: '告警详情', | 199 | title: '告警详情', | 
| 184 | width: 600, | 200 | width: 600, | 
| 185 | centered: true, | 201 | centered: true, | 
| 186 | maskClosable: true, | 202 | maskClosable: true, | 
| 187 | -          content: h(JsonPreview, { data: JSON.parse(JSON.stringify(dataFormats)), deep: 4 }), | 203 | +          content: h(JsonPreview, { data: JSON.parse(JSON.stringify(objectDataFormats)), deep: 4 }), | 
| 188 | }); | 204 | }); | 
| 189 | }; | 205 | }; | 
| 190 | const handleAlarmDetailFormat = async (keys: string[]) => { | 206 | const handleAlarmDetailFormat = async (keys: string[]) => { | 
| 191 | -        const temp: any = []; | 207 | +        const temp: Recordable = []; | 
| 192 | for (let item of keys) { | 208 | for (let item of keys) { | 
| 193 | if (item === 'key' || item === 'data') return []; //旧数据则终止 | 209 | if (item === 'key' || item === 'data') return []; //旧数据则终止 | 
| 194 | const deviceDetailRes = await getDeviceDetail(item); | 210 | const deviceDetailRes = await getDeviceDetail(item); | 
| 195 | const { deviceProfileId } = deviceDetailRes; | 211 | const { deviceProfileId } = deviceDetailRes; | 
| 196 | if (!deviceProfileId) return []; | 212 | if (!deviceProfileId) return []; | 
| 197 | const attributeRes = await getAttribute(deviceProfileId); | 213 | const attributeRes = await getAttribute(deviceProfileId); | 
| 198 | -          const dataFormat: any = handleDataFormat(deviceDetailRes, attributeRes); | 214 | +          const dataFormat: Recordable = handleDataFormat(deviceDetailRes, attributeRes); | 
| 199 | temp.push(dataFormat); | 215 | temp.push(dataFormat); | 
| 200 | } | 216 | } | 
| 201 | return temp; | 217 | return temp; | 
| 202 | }; | 218 | }; | 
| 203 | -      const handleDataFormat = (deviceDetail: any, attributes: any) => { | 219 | +      const handleDataFormat = (deviceDetail: Recordable, attributes: Recordable) => { | 
| 204 | const { name, tbDeviceId, alias } = deviceDetail; | 220 | const { name, tbDeviceId, alias } = deviceDetail; | 
| 205 | const attribute = attributes.map((item) => ({ | 221 | const attribute = attributes.map((item) => ({ | 
| 206 | identifier: item.identifier, | 222 | identifier: item.identifier, |