diff --git a/src/service/api/notify.ts b/src/service/api/notify.ts index 2e7f4df..1d36190 100644 --- a/src/service/api/notify.ts +++ b/src/service/api/notify.ts @@ -27,6 +27,15 @@ export function fetchEditNotify(data: Api.NotifyConfig.NotifyConfig) { }); } +/** delete notify */ +export function fetchBatchDeleteNotify(data: string[]) { + return request({ + url: '/notify-config/ids', + method: 'delete', + data + }); +} + /** edit notify status */ export function fetchUpdateNotifyStatus(id: string, status: Api.Common.EnableStatusNumber) { return request({ @@ -69,3 +78,12 @@ export function fetchEditNotifyRecipient(data: Api.NotifyRecipient.NotifyRecipie data }); } + +/** delete notify recipient */ +export function fetchDeleteNotifyRecipient(data: string[]) { + return request({ + url: '/notify-recipient/ids', + method: 'delete', + data + }); +} diff --git a/src/views/notify/recipient/index.vue b/src/views/notify/recipient/index.vue index 9c28068..e530722 100644 --- a/src/views/notify/recipient/index.vue +++ b/src/views/notify/recipient/index.vue @@ -2,11 +2,12 @@ import { NButton, NPopconfirm, NTag } from 'naive-ui'; import { ref } from 'vue'; import { useBoolean } from '@sa/hooks'; -import { fetchGetNotifyRecipientPageList } from '@/service/api'; +import { fetchDeleteNotifyRecipient, fetchGetNotifyRecipientPageList } from '@/service/api'; import { $t } from '@/locales'; import { useAppStore } from '@/store/modules/app'; import { useTable, useTableOperate } from '@/hooks/common/table'; import { alarmTypeRecord } from '@/constants/business'; +import { tagColor } from '@/utils/common'; import NotifyRecipientOperateDrawer from './modules/notify-recipient-operate-drawer.vue'; import NotifyRecipientSearch from './modules/notify-recipient-search.vue'; import NotifyRecipientDetailDrawer from './modules/notify-recipient-detail-drawer.vue'; @@ -65,7 +66,7 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP minWidth: 120, render: row => { const label = $t(alarmTypeRecord[row.notifyType!]); - return {label}; + return {label}; } }, { @@ -106,24 +107,25 @@ const { editingData, handleAdd, handleEdit, - checkedRowKeys, - onBatchDeleted, - onDeleted + checkedRowKeys // closeDrawer } = useTableOperate(data, getData); async function handleBatchDelete() { - // request - console.log(checkedRowKeys.value); - - onBatchDeleted(); + const { error } = await fetchDeleteNotifyRecipient(checkedRowKeys.value); + if (!error) { + window.$message?.success($t('common.deleteSuccess')); + getData(); + } } -function handleDelete(id: string) { +async function handleDelete(id: string) { // request - console.log(id); - - onDeleted(); + const { error } = await fetchDeleteNotifyRecipient([id]); + if (!error) { + window.$message?.success($t('common.deleteSuccess')); + getData(); + } } function edit(id: string) { diff --git a/src/views/notify/recipient/modules/dingding-form.vue b/src/views/notify/recipient/modules/dingding-form.vue index 3338b63..8e9c989 100644 --- a/src/views/notify/recipient/modules/dingding-form.vue +++ b/src/views/notify/recipient/modules/dingding-form.vue @@ -36,7 +36,7 @@ function createDefaultModel(): Model { notifyType: 1, webhookUrl, ats, - description: '' + description: props.value.description }; } diff --git a/src/views/notify/recipient/modules/email-form.vue b/src/views/notify/recipient/modules/email-form.vue index 620a278..40bb39b 100644 --- a/src/views/notify/recipient/modules/email-form.vue +++ b/src/views/notify/recipient/modules/email-form.vue @@ -11,7 +11,7 @@ interface Props { value: Api.NotifyRecipient.NotifyRecipient; } -defineProps(); +const props = defineProps(); interface Emits { (e: 'update:value', value: Api.NotifyRecipient.NotifyRecipient): void; @@ -26,12 +26,13 @@ type Model = Pick(); +const props = defineProps(); interface Emits { (e: 'update:value', value: Api.NotifyRecipient.NotifyRecipient): void; @@ -29,13 +29,15 @@ type Model = Pick< const model: Model = reactive(createDefaultModel()); function createDefaultModel(): Model { + const { webhookUrl, ats } = JSON.parse(props.value.notifyAttribute!) as { webhookUrl: string; ats: string[] }; + return { - id: '', - recipientName: '', + id: props.value.id, + recipientName: props.value.recipientName, notifyType: 4, - webhookUrl: '', - ats: [], - description: '' + webhookUrl, + ats, + description: props.value.description }; } diff --git a/src/views/notify/recipient/modules/notify-recipient-operate-drawer.vue b/src/views/notify/recipient/modules/notify-recipient-operate-drawer.vue index adf070d..a86e26a 100644 --- a/src/views/notify/recipient/modules/notify-recipient-operate-drawer.vue +++ b/src/views/notify/recipient/modules/notify-recipient-operate-drawer.vue @@ -64,11 +64,13 @@ function createDefaultModel(): Model { function handleUpdateModelWhenEdit() { if (props.operateType === 'add') { model.value = createDefaultModel(); + notifyTabPane.value = 1; return; } if (props.operateType === 'edit' && props.rowData) { model.value = props.rowData; + notifyTabPane.value = props.rowData.notifyType; } } diff --git a/src/views/notify/recipient/modules/wecom-form.vue b/src/views/notify/recipient/modules/wecom-form.vue index 7137997..1f1f3be 100644 --- a/src/views/notify/recipient/modules/wecom-form.vue +++ b/src/views/notify/recipient/modules/wecom-form.vue @@ -4,14 +4,14 @@ import { useFormRules, useNaiveForm } from '@/hooks/common/form'; import { $t } from '@/locales'; defineOptions({ - name: 'WecomForm' + name: 'WeComForm' }); interface Props { value: Api.NotifyRecipient.NotifyRecipient; } -defineProps(); +const props = defineProps(); interface Emits { (e: 'update:value', value: Api.NotifyRecipient.NotifyRecipient): void; @@ -29,13 +29,14 @@ type Model = Pick< const model: Model = reactive(createDefaultModel()); function createDefaultModel(): Model { + const { webhookUrl, ats } = JSON.parse(props.value.notifyAttribute!) as { webhookUrl: string; ats: string[] }; return { - id: '', - recipientName: '', + id: props.value.id, + recipientName: props.value.recipientName, notifyType: 3, - webhookUrl: '', - ats: [], - description: '' + webhookUrl, + ats, + description: props.value.description }; } diff --git a/src/views/notify/scene/index.vue b/src/views/notify/scene/index.vue index b2e06a9..080ae74 100644 --- a/src/views/notify/scene/index.vue +++ b/src/views/notify/scene/index.vue @@ -2,7 +2,7 @@ import { NButton, NPopconfirm, NTag } from 'naive-ui'; import { ref } from 'vue'; import { useBoolean } from '@sa/hooks'; -import { fetchGetNotifyConfigList, fetchUpdateNotifyStatus } from '@/service/api'; +import { fetchBatchDeleteNotify, fetchGetNotifyConfigList, fetchUpdateNotifyStatus } from '@/service/api'; import { $t } from '@/locales'; import { useAppStore } from '@/store/modules/app'; import { useTable, useTableOperate } from '@/hooks/common/table'; @@ -173,21 +173,25 @@ const { editingData, handleAdd, handleEdit, - checkedRowKeys, - onBatchDeleted, - onDeleted + checkedRowKeys // closeDrawer } = useTableOperate(data, getData); async function handleBatchDelete() { - onBatchDeleted(); + const { error } = await fetchBatchDeleteNotify(checkedRowKeys.value); + if (!error) { + window.$message?.success($t('common.deleteSuccess')); + getData(); + } } -function handleDelete(id: string) { +async function handleDelete(id: string) { // request - console.log(id); - - onDeleted(); + const { error } = await fetchBatchDeleteNotify([id]); + if (!error) { + window.$message?.success($t('common.deleteSuccess')); + getData(); + } } function edit(id: string) {