Commit a4341e8d92a08dc32fc7365cc7bc8ffcfc6f7bc2
Merge branch 'fix/DEFECT-1443' into 'main_dev'
perf: 告警记录新增批量处理功能 See merge request yunteng/thingskit-front!881
Showing
2 changed files
with
42 additions
and
3 deletions
... | ... | @@ -28,6 +28,8 @@ enum DeviceManagerApi { |
28 | 28 | |
29 | 29 | DEVICE_ALARM_URL = '/alarm', |
30 | 30 | |
31 | + ALARM_BATCH_ACK = '/alarm/batch/ack', | |
32 | + | |
31 | 33 | DEVICE_CREDENTIALS = '/device/credentials', |
32 | 34 | |
33 | 35 | COMMAND_ISSUANCE = '/rpc', |
... | ... | @@ -346,3 +348,13 @@ export const getDevicesByDeviceIds = (ids: string[]) => { |
346 | 348 | data: ids, |
347 | 349 | }); |
348 | 350 | }; |
351 | + | |
352 | +export const doBatchAckAlarm = (ids: string[]) => { | |
353 | + return defHttp.post( | |
354 | + { | |
355 | + url: DeviceManagerApi.ALARM_BATCH_ACK, | |
356 | + data: { alarmIds: ids }, | |
357 | + }, | |
358 | + { joinPrefix: false } | |
359 | + ); | |
360 | +}; | ... | ... |
... | ... | @@ -18,6 +18,9 @@ |
18 | 18 | 查看告警详情 |
19 | 19 | </a-button> |
20 | 20 | </template> |
21 | + <template #toolbar> | |
22 | + <Button @click="handleBatchAck" type="primary">批量处理</Button> | |
23 | + </template> | |
21 | 24 | </BasicTable> |
22 | 25 | <AlarmDetailDrawer @register="registerDetailDrawer" @success="handleSuccess" /> |
23 | 26 | </div> |
... | ... | @@ -26,10 +29,10 @@ |
26 | 29 | import { defineComponent, nextTick, h } from 'vue'; |
27 | 30 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
28 | 31 | import { alarmColumns, alarmSearchSchemas } from './config/detail.config'; |
29 | - import { getDeviceAlarm } from '/@/api/device/deviceManager'; | |
32 | + import { doBatchAckAlarm, getDeviceAlarm } from '/@/api/device/deviceManager'; | |
30 | 33 | import { useDrawer } from '/@/components/Drawer'; |
31 | 34 | import AlarmDetailDrawer from './cpns/AlarmDetailDrawer.vue'; |
32 | - import { Modal } from 'ant-design-vue'; | |
35 | + import { Modal, Button } from 'ant-design-vue'; | |
33 | 36 | import { JsonPreview } from '/@/components/CodeEditor'; |
34 | 37 | import { getDeviceDetail } from '/@/api/device/deviceManager'; |
35 | 38 | import { getAttribute } from '/@/api/ruleengine/ruleengineApi'; |
... | ... | @@ -38,17 +41,21 @@ |
38 | 41 | operationString, |
39 | 42 | operationBoolean, |
40 | 43 | } from '/@/views/rule/linkedge/config/formatData'; |
44 | + import { AlarmLogItem } from '/@/api/device/model/deviceConfigModel'; | |
45 | + import { AlarmStatus } from '/@/enums/alarmEnum'; | |
46 | + import { useMessage } from '/@/hooks/web/useMessage'; | |
41 | 47 | |
42 | 48 | export default defineComponent({ |
43 | 49 | name: 'AlarmCenter', |
44 | 50 | components: { |
51 | + Button, | |
45 | 52 | BasicTable, |
46 | 53 | TableAction, |
47 | 54 | AlarmDetailDrawer, |
48 | 55 | }, |
49 | 56 | |
50 | 57 | setup() { |
51 | - const [registerTable, { reload }] = useTable({ | |
58 | + const [registerTable, { reload, getSelectRows, clearSelectedRowKeys }] = useTable({ | |
52 | 59 | title: '告警记录列表', |
53 | 60 | api: getDeviceAlarm, |
54 | 61 | columns: alarmColumns, |
... | ... | @@ -61,6 +68,14 @@ |
61 | 68 | bordered: true, |
62 | 69 | showIndexColumn: false, |
63 | 70 | showTableSetting: true, |
71 | + rowSelection: { | |
72 | + type: 'checkbox', | |
73 | + getCheckboxProps: (record: AlarmLogItem) => { | |
74 | + return { | |
75 | + disabled: record.status === AlarmStatus.CLEARED_ACK, | |
76 | + }; | |
77 | + }, | |
78 | + }, | |
64 | 79 | actionColumn: { |
65 | 80 | width: 200, |
66 | 81 | title: '操作', |
... | ... | @@ -148,12 +163,24 @@ |
148 | 163 | attribute, |
149 | 164 | }; |
150 | 165 | }; |
166 | + | |
167 | + const { createMessage } = useMessage(); | |
168 | + const handleBatchAck = async () => { | |
169 | + const ids = getSelectRows<AlarmLogItem>().map((item) => item.id); | |
170 | + | |
171 | + await doBatchAckAlarm(ids); | |
172 | + createMessage.success('操作成功'); | |
173 | + clearSelectedRowKeys(); | |
174 | + reload(); | |
175 | + }; | |
176 | + | |
151 | 177 | return { |
152 | 178 | registerTable, |
153 | 179 | registerDetailDrawer, |
154 | 180 | handleDetail, |
155 | 181 | handleSuccess, |
156 | 182 | handleViewAlarmDetails, |
183 | + handleBatchAck, | |
157 | 184 | }; |
158 | 185 | }, |
159 | 186 | }); | ... | ... |