Commit 685d608a566ab5e7769c4e1e253d835c6e35b60d
Merge branch 'fix/DEFECT-1604' into 'main_dev'
fix: 告警处理新增批量清除按钮 See merge request yunteng/thingskit-front!893
Showing
2 changed files
with
75 additions
and
4 deletions
@@ -30,6 +30,8 @@ enum DeviceManagerApi { | @@ -30,6 +30,8 @@ enum DeviceManagerApi { | ||
30 | 30 | ||
31 | ALARM_BATCH_ACK = '/alarm/batch/ack', | 31 | ALARM_BATCH_ACK = '/alarm/batch/ack', |
32 | 32 | ||
33 | + ALARM_BATCH_CLEAR = '/alarm/batch/clear', | ||
34 | + | ||
33 | DEVICE_CREDENTIALS = '/device/credentials', | 35 | DEVICE_CREDENTIALS = '/device/credentials', |
34 | 36 | ||
35 | COMMAND_ISSUANCE = '/rpc', | 37 | COMMAND_ISSUANCE = '/rpc', |
@@ -358,3 +360,13 @@ export const doBatchAckAlarm = (ids: string[]) => { | @@ -358,3 +360,13 @@ export const doBatchAckAlarm = (ids: string[]) => { | ||
358 | { joinPrefix: false } | 360 | { joinPrefix: false } |
359 | ); | 361 | ); |
360 | }; | 362 | }; |
363 | + | ||
364 | +export const doBatchClearAlarm = (ids: string[]) => { | ||
365 | + return defHttp.post( | ||
366 | + { | ||
367 | + url: DeviceManagerApi.ALARM_BATCH_CLEAR, | ||
368 | + data: { alarmIds: ids }, | ||
369 | + }, | ||
370 | + { joinPrefix: false } | ||
371 | + ); | ||
372 | +}; |
@@ -19,7 +19,30 @@ | @@ -19,7 +19,30 @@ | ||
19 | </a-button> | 19 | </a-button> |
20 | </template> | 20 | </template> |
21 | <template #toolbar> | 21 | <template #toolbar> |
22 | - <Button @click="handleBatchAck" type="primary" :disabled="getCanBatchAck">批量处理</Button> | 22 | + <Tooltip> |
23 | + <template #title> | ||
24 | + <div>激活未确认: 可以处理,清除</div> | ||
25 | + <div>激活已确认: 只可清除,已经处理</div> | ||
26 | + <div>清除未确认: 只可处理,已经清除</div> | ||
27 | + <div>清除已确认: 不需要做处理和清除</div> | ||
28 | + </template> | ||
29 | + <Button @click="handleBatchClear" type="primary" :disabled="getCanBatchClear"> | ||
30 | + <QuestionCircleOutlined class="cursor-pointer" /> | ||
31 | + <span>批量清除</span> | ||
32 | + </Button> | ||
33 | + </Tooltip> | ||
34 | + <Tooltip> | ||
35 | + <template #title> | ||
36 | + <div>激活未确认: 可以处理,清除</div> | ||
37 | + <div>激活已确认: 只可清除,已经处理</div> | ||
38 | + <div>清除未确认: 只可处理,已经清除</div> | ||
39 | + <div>清除已确认: 不需要做处理和清除</div> | ||
40 | + </template> | ||
41 | + <Button @click="handleBatchAck" type="primary" :disabled="getCanBatchAck"> | ||
42 | + <QuestionCircleOutlined class="cursor-pointer" /> | ||
43 | + <span>批量处理</span> | ||
44 | + </Button> | ||
45 | + </Tooltip> | ||
23 | </template> | 46 | </template> |
24 | </BasicTable> | 47 | </BasicTable> |
25 | <AlarmDetailDrawer @register="registerDetailDrawer" @success="handleSuccess" /> | 48 | <AlarmDetailDrawer @register="registerDetailDrawer" @success="handleSuccess" /> |
@@ -29,10 +52,10 @@ | @@ -29,10 +52,10 @@ | ||
29 | import { defineComponent, nextTick, h, computed } from 'vue'; | 52 | import { defineComponent, nextTick, h, computed } from 'vue'; |
30 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; | 53 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
31 | import { alarmColumns, alarmSearchSchemas } from './config/detail.config'; | 54 | import { alarmColumns, alarmSearchSchemas } from './config/detail.config'; |
32 | - import { doBatchAckAlarm, getDeviceAlarm } from '/@/api/device/deviceManager'; | 55 | + import { doBatchAckAlarm, doBatchClearAlarm, getDeviceAlarm } from '/@/api/device/deviceManager'; |
33 | import { useDrawer } from '/@/components/Drawer'; | 56 | import { useDrawer } from '/@/components/Drawer'; |
34 | import AlarmDetailDrawer from './cpns/AlarmDetailDrawer.vue'; | 57 | import AlarmDetailDrawer from './cpns/AlarmDetailDrawer.vue'; |
35 | - import { Modal, Button } from 'ant-design-vue'; | 58 | + import { Modal, Button, Tooltip } from 'ant-design-vue'; |
36 | import { JsonPreview } from '/@/components/CodeEditor'; | 59 | import { JsonPreview } from '/@/components/CodeEditor'; |
37 | import { getDeviceDetail } from '/@/api/device/deviceManager'; | 60 | import { getDeviceDetail } from '/@/api/device/deviceManager'; |
38 | import { getAttribute } from '/@/api/ruleengine/ruleengineApi'; | 61 | import { getAttribute } from '/@/api/ruleengine/ruleengineApi'; |
@@ -44,6 +67,7 @@ | @@ -44,6 +67,7 @@ | ||
44 | import { AlarmLogItem } from '/@/api/device/model/deviceConfigModel'; | 67 | import { AlarmLogItem } from '/@/api/device/model/deviceConfigModel'; |
45 | import { AlarmStatus } from '/@/enums/alarmEnum'; | 68 | import { AlarmStatus } from '/@/enums/alarmEnum'; |
46 | import { useMessage } from '/@/hooks/web/useMessage'; | 69 | import { useMessage } from '/@/hooks/web/useMessage'; |
70 | + import { QuestionCircleOutlined } from '@ant-design/icons-vue'; | ||
47 | 71 | ||
48 | export default defineComponent({ | 72 | export default defineComponent({ |
49 | name: 'AlarmCenter', | 73 | name: 'AlarmCenter', |
@@ -52,6 +76,8 @@ | @@ -52,6 +76,8 @@ | ||
52 | BasicTable, | 76 | BasicTable, |
53 | TableAction, | 77 | TableAction, |
54 | AlarmDetailDrawer, | 78 | AlarmDetailDrawer, |
79 | + QuestionCircleOutlined, | ||
80 | + Tooltip, | ||
55 | }, | 81 | }, |
56 | 82 | ||
57 | setup() { | 83 | setup() { |
@@ -60,6 +86,7 @@ | @@ -60,6 +86,7 @@ | ||
60 | title: '告警记录列表', | 86 | title: '告警记录列表', |
61 | api: getDeviceAlarm, | 87 | api: getDeviceAlarm, |
62 | columns: alarmColumns, | 88 | columns: alarmColumns, |
89 | + rowKey: 'id', | ||
63 | useSearchForm: true, | 90 | useSearchForm: true, |
64 | formConfig: { | 91 | formConfig: { |
65 | labelWidth: 120, | 92 | labelWidth: 120, |
@@ -168,9 +195,30 @@ | @@ -168,9 +195,30 @@ | ||
168 | }; | 195 | }; |
169 | }; | 196 | }; |
170 | 197 | ||
198 | + const getCanBatchClear = computed(() => { | ||
199 | + const rowSelection = getRowSelection(); | ||
200 | + const getRows: AlarmLogItem[] = getSelectRows(); | ||
201 | + | ||
202 | + return ( | ||
203 | + !rowSelection.selectedRowKeys?.length || | ||
204 | + getRows.some( | ||
205 | + (item) => | ||
206 | + item.status === AlarmStatus.CLEARED_ACK || item.status === AlarmStatus.CLEARED_UN_ACK | ||
207 | + ) | ||
208 | + ); | ||
209 | + }); | ||
210 | + | ||
171 | const getCanBatchAck = computed(() => { | 211 | const getCanBatchAck = computed(() => { |
172 | const rowSelection = getRowSelection(); | 212 | const rowSelection = getRowSelection(); |
173 | - return !rowSelection.selectedRowKeys?.length; | 213 | + const getRows: AlarmLogItem[] = getSelectRows(); |
214 | + | ||
215 | + return ( | ||
216 | + !rowSelection.selectedRowKeys?.length || | ||
217 | + getRows.some( | ||
218 | + (item) => | ||
219 | + item.status === AlarmStatus.CLEARED_ACK || item.status === AlarmStatus.ACTIVE_ACK | ||
220 | + ) | ||
221 | + ); | ||
174 | }); | 222 | }); |
175 | 223 | ||
176 | const { createMessage } = useMessage(); | 224 | const { createMessage } = useMessage(); |
@@ -183,6 +231,15 @@ | @@ -183,6 +231,15 @@ | ||
183 | reload(); | 231 | reload(); |
184 | }; | 232 | }; |
185 | 233 | ||
234 | + const handleBatchClear = async () => { | ||
235 | + const ids = getSelectRows<AlarmLogItem>().map((item) => item.id); | ||
236 | + if (!ids.length) return; | ||
237 | + await doBatchClearAlarm(ids); | ||
238 | + createMessage.success('操作成功'); | ||
239 | + clearSelectedRowKeys(); | ||
240 | + reload(); | ||
241 | + }; | ||
242 | + | ||
186 | return { | 243 | return { |
187 | registerTable, | 244 | registerTable, |
188 | registerDetailDrawer, | 245 | registerDetailDrawer, |
@@ -190,7 +247,9 @@ | @@ -190,7 +247,9 @@ | ||
190 | handleSuccess, | 247 | handleSuccess, |
191 | handleViewAlarmDetails, | 248 | handleViewAlarmDetails, |
192 | handleBatchAck, | 249 | handleBatchAck, |
250 | + handleBatchClear, | ||
193 | getCanBatchAck, | 251 | getCanBatchAck, |
252 | + getCanBatchClear, | ||
194 | }; | 253 | }; |
195 | }, | 254 | }, |
196 | }); | 255 | }); |