feat(sj_1.0.0_beta3): 通知人支持导出导入

This commit is contained in:
opensnail 2024-05-30 23:12:32 +08:00
parent 5b6cd8a47c
commit 2daa6353b6
2 changed files with 42 additions and 4 deletions

View File

@ -649,8 +649,7 @@ declare namespace Api {
/** notifyRecipient search params */ /** notifyRecipient search params */
type NotifyRecipientParams = CommonType.RecordNullable< type NotifyRecipientParams = CommonType.RecordNullable<
Pick<Api.NotifyRecipient.NotifyRecipient, 'recipientName' | 'notifyType' | 'notifyAttribute' | 'description'> & Pick<Api.NotifyRecipient.NotifyRecipient, 'recipientName' | 'notifyType'> & CommonSearchParams
CommonSearchParams
>; >;
/** notifyRecipient list */ /** notifyRecipient list */
@ -659,6 +658,11 @@ declare namespace Api {
/** 1: 钉钉通知 2: 邮件通知 3: 企业通知 4: 飞书 5: Webhook */ /** 1: 钉钉通知 2: 邮件通知 3: 企业通知 4: 飞书 5: Webhook */
type AlarmType = 1 | 2 | 3 | 4 | 5; type AlarmType = 1 | 2 | 3 | 4 | 5;
type ExportNotifyRecipient = Common.CommonRecord<{
notifyRecipientIds: string[];
}> &
NotifyRecipientParams;
/* 1: application/json 2application/x-www-form-urlencoded */ /* 1: application/json 2application/x-www-form-urlencoded */
type AlarmTypeWebhook = 1 | 2; type AlarmTypeWebhook = 1 | 2;
} }

View File

@ -9,6 +9,7 @@ import { useTable, useTableOperate } from '@/hooks/common/table';
import { alarmTypeRecord } from '@/constants/business'; import { alarmTypeRecord } from '@/constants/business';
import { tagColor } from '@/utils/common'; import { tagColor } from '@/utils/common';
import { useAuth } from '@/hooks/business/auth'; import { useAuth } from '@/hooks/business/auth';
import { downloadFetch } from '@/utils/download';
import NotifyRecipientOperateDrawer from './modules/notify-recipient-operate-drawer.vue'; import NotifyRecipientOperateDrawer from './modules/notify-recipient-operate-drawer.vue';
import NotifyRecipientSearch from './modules/notify-recipient-search.vue'; import NotifyRecipientSearch from './modules/notify-recipient-search.vue';
import NotifyRecipientDetailDrawer from './modules/notify-recipient-detail-drawer.vue'; import NotifyRecipientDetailDrawer from './modules/notify-recipient-detail-drawer.vue';
@ -28,7 +29,7 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
size: 10, size: 10,
// if you want to use the searchParams in Form, you need to define the following properties, and the value is null // if you want to use the searchParams in Form, you need to define the following properties, and the value is null
// the value can not be undefined, otherwise the property in Form will not be reactive // the value can not be undefined, otherwise the property in Form will not be reactive
recipientName: '', recipientName: null,
notifyType: null notifyType: null
}, },
columns: () => [ columns: () => [
@ -137,6 +138,18 @@ async function handleDelete(id: string) {
function edit(id: string) { function edit(id: string) {
handleEdit(id); handleEdit(id);
} }
function body(): Api.NotifyRecipient.ExportNotifyRecipient {
return {
notifyRecipientIds: checkedRowKeys.value,
notifyType: searchParams.notifyType,
recipientName: searchParams.recipientName
};
}
function handleExport() {
downloadFetch('/notify-recipient/export', body(), $t('page.notifyRecipient.title'));
}
</script> </script>
<template> <template>
@ -157,7 +170,28 @@ function edit(id: string) {
@add="handleAdd" @add="handleAdd"
@delete="handleBatchDelete" @delete="handleBatchDelete"
@refresh="getData" @refresh="getData"
/> >
<template #addAfter>
<FileUpload action="/job/import" accept="application/json" @refresh="getData" />
<NPopconfirm @positive-click="handleExport">
<template #trigger>
<NButton size="small" ghost type="primary" :disabled="checkedRowKeys.length === 0 && hasAuth('R_USER')">
<template #icon>
<IconPajamasExport class="text-icon" />
</template>
{{ $t('common.export') }}
</NButton>
</template>
<template #default>
{{
checkedRowKeys.length === 0
? $t('common.exportAll')
: $t('common.exportPar', { num: checkedRowKeys.length })
}}
</template>
</NPopconfirm>
</template>
</TableHeaderOperation>
</template> </template>
<NDataTable <NDataTable
v-model:checked-row-keys="checkedRowKeys" v-model:checked-row-keys="checkedRowKeys"