feat(sj_1.0.0): 优化通知人列表和查询

This commit is contained in:
opensnail 2024-04-20 11:40:29 +08:00
parent e83f20d14e
commit 19201310c9
8 changed files with 132 additions and 28 deletions

View File

@ -13,8 +13,8 @@ export const enableStatusRecord: Record<Api.Common.EnableStatus, App.I18n.I18nKe
export const enableStatusOptions = transformRecordToOption(enableStatusRecord);
export const enableStatus01Record: Record<Api.Common.EnableStatus01, App.I18n.I18nKey> = {
'0': 'page.manage.common.status.enable',
'1': 'page.manage.common.status.disable'
0: 'page.manage.common.status.enable',
1: 'page.manage.common.status.disable'
};
export const enableStatus01Options = transformRecordToOption(enableStatus01Record);

View File

@ -549,7 +549,9 @@ const local: App.I18n.Schema = {
groupName: 'Please select Group name',
notifyThreshold: 'Please enter Notification threshold',
notifyStatus: 'Please select State',
systemTaskType: '请选择任务类型'
systemTaskType: '请选择任务类型',
notifyRecipient: '请选择通知人',
rateLimiterThreshold: '请选择阈值'
},
addNotifyConfig: 'Add Alarm notification',
editNotifyConfig: 'Add Alarm notification',
@ -564,7 +566,10 @@ const local: App.I18n.Schema = {
},
jobNotifyScene: {
jobTaskError: '任务执行失败'
}
},
notifyRecipient: '通知人信息',
rateLimiterStatus: '限流开关',
rateLimiterThreshold: '每秒限流阈值'
},
notifyRecipient: {
title: 'Notify Recipient List',

View File

@ -545,7 +545,9 @@ const local: App.I18n.Schema = {
groupName: '请选择组名称',
notifyThreshold: '请输入通知阈值',
notifyStatus: '请选择状态',
systemTaskType: '请选择任务类型'
systemTaskType: '请选择任务类型',
notifyRecipient: '请选择通知人',
rateLimiterThreshold: '请选择阈值'
},
addNotifyConfig: '新增告警通知',
editNotifyConfig: '编辑告警通知',
@ -560,7 +562,10 @@ const local: App.I18n.Schema = {
},
jobNotifyScene: {
jobTaskError: '任务执行失败'
}
},
notifyRecipient: '通知人信息',
rateLimiterStatus: '限流开关',
rateLimiterThreshold: '每秒限流阈值'
},
notifyRecipient: {
title: '通知人列表',

View File

@ -28,7 +28,7 @@ export function fetchEditNotify(data: Api.NotifyConfig.NotifyConfig) {
}
/** get notify recipient list */
export function fetchGetNotifyRecipientList(params?: Api.NotifyRecipient.NotifyRecipientParams) {
export function fetchGetNotifyRecipientPageList(params?: Api.NotifyRecipient.NotifyRecipientParams) {
return request<Api.NotifyRecipient.NotifyRecipientList>({
url: '/notify-recipient/page/list',
method: 'get',
@ -36,6 +36,14 @@ export function fetchGetNotifyRecipientList(params?: Api.NotifyRecipient.NotifyR
});
}
/** get notify recipient list */
export function fetchGetNotifyRecipientList() {
return request<CommonType.Option<number>[]>({
url: '/notify-recipient/list',
method: 'get'
});
}
/** add notify recipient */
export function fetchAddNotifyRecipient(data: Api.NotifyRecipient.NotifyRecipient) {
return request<boolean>({

View File

@ -44,7 +44,7 @@ declare namespace Api {
* - "0": enabled
* - "1": disabled
*/
type EnableStatus01 = '0' | '1';
type EnableStatus01 = 0 | 1;
/**
* yes/no status
@ -516,6 +516,8 @@ declare namespace Api {
groupName: string;
/** 业务ID */
businessId: string;
/** 通知人id */
notifyRecipientIds: number;
/** 任务类型 1、重试任务 2、回调任务、3、JOB任务 4、WORKFLOW任务 */
systemTaskType: SystemTaskType;
/** 业务名称 */
@ -526,6 +528,10 @@ declare namespace Api {
notifyScene: string;
/** 通知阈值 */
notifyThreshold: number;
/** 限流开关 */
rateLimiterStatus: number;
/** 每秒限流阈值 */
rateLimiterThreshold: number;
/** 描述 */
description: string;
}>;

View File

@ -721,6 +721,8 @@ declare namespace App {
notifyThreshold: string;
notifyStatus: string;
systemTaskType: string;
notifyRecipient: string;
rateLimiterThreshold: string;
};
addNotifyConfig: string;
editNotifyConfig: string;
@ -736,6 +738,9 @@ declare namespace App {
jobNotifyScene: {
jobTaskError: string;
};
notifyRecipient: string;
rateLimiterStatus: string;
rateLimiterThreshold: string;
};
notifyRecipient: {
title: string;

View File

@ -1,6 +1,6 @@
<script setup lang="tsx">
import { NButton, NPopconfirm, NTag } from 'naive-ui';
import { fetchGetNotifyRecipientList } from '@/service/api';
import { fetchGetNotifyRecipientPageList } from '@/service/api';
import { $t } from '@/locales';
import { useAppStore } from '@/store/modules/app';
import { useTable, useTableOperate } from '@/hooks/common/table';
@ -11,7 +11,7 @@ import NotifyRecipientSearch from './modules/notify-recipient-search.vue';
const appStore = useAppStore();
const { columns, columnChecks, data, getData, loading, mobilePagination, searchParams, resetSearchParams } = useTable({
apiFn: fetchGetNotifyRecipientList,
apiFn: fetchGetNotifyRecipientPageList,
apiParams: {
page: 1,
size: 10,

View File

@ -3,7 +3,7 @@ import { computed, nextTick, onMounted, reactive, ref, watch } from 'vue';
import { useFormRules, useNaiveForm } from '@/hooks/common/form';
import OperateDrawer from '@/components/common/operate-drawer.vue';
import { $t } from '@/locales';
import { fetchAddNotify, fetchEditNotify, fetchGetAllGroupNameList } from '@/service/api';
import { fetchAddNotify, fetchEditNotify, fetchGetAllGroupNameList, fetchGetNotifyRecipientList } from '@/service/api';
import {
enableStatus01Options,
jobNotifySceneOptions,
@ -24,7 +24,9 @@ interface Props {
}
const groupNameList = ref<string[]>([]);
const notifyRecipientList = ref<CommonType.Option<number>[]>([]);
const props = defineProps<Props>();
const defaultChecked = ref<number>(0);
interface Emits {
(e: 'submitted'): void;
@ -56,46 +58,69 @@ type Model = Pick<
| 'id'
| 'groupName'
| 'businessId'
| 'notifyRecipientIds'
| 'systemTaskType'
| 'notifyStatus'
| 'notifyScene'
| 'notifyThreshold'
| 'rateLimiterStatus'
| 'rateLimiterThreshold'
| 'description'
>;
onMounted(() => {
nextTick(() => {
getGroupNameList();
getNotifyRecipientList();
});
});
async function getGroupNameList() {
const res = await fetchGetAllGroupNameList();
console.log(res.data);
groupNameList.value = res.data as string[];
}
async function getNotifyRecipientList() {
const res = await fetchGetNotifyRecipientList();
notifyRecipientList.value = res.data as CommonType.Option<number>[];
}
const model: Model = reactive(createDefaultModel());
function createDefaultModel(): Model {
return {
groupName: '',
businessId: '',
notifyRecipientIds: 0,
systemTaskType: '1',
notifyStatus: '',
notifyScene: '',
notifyThreshold: 0,
rateLimiterStatus: 0,
rateLimiterThreshold: 0,
description: ''
};
}
type RuleKey = Extract<keyof Model, 'groupName' | 'businessId' | 'notifyStatus' | 'notifyScene'>;
type RuleKey = Extract<
keyof Model,
| 'groupName'
| 'businessId'
| 'notifyRecipientIds'
| 'notifyStatus'
| 'notifyScene'
| 'rateLimiterStatus'
| 'notifyThreshold'
>;
const rules: Record<RuleKey, App.Global.FormRule> = {
groupName: defaultRequiredRule,
businessId: defaultRequiredRule,
notifyStatus: defaultRequiredRule,
notifyScene: defaultRequiredRule
notifyScene: defaultRequiredRule,
notifyRecipientIds: defaultRequiredRule,
rateLimiterStatus: defaultRequiredRule,
notifyThreshold: defaultRequiredRule
};
function handleUpdateModelWhenEdit() {
@ -117,30 +142,58 @@ async function handleSubmit() {
await validate();
// request
if (props.operateType === 'add') {
const { groupName, businessId, systemTaskType, notifyStatus, notifyScene, notifyThreshold, description } = model;
const { error } = await fetchAddNotify({
const {
groupName,
businessId,
notifyRecipientIds,
systemTaskType,
notifyStatus,
notifyScene,
notifyThreshold,
rateLimiterStatus,
rateLimiterThreshold,
description
} = model;
const { error } = await fetchAddNotify({
groupName,
businessId,
notifyRecipientIds,
systemTaskType,
notifyStatus,
notifyScene,
notifyThreshold,
rateLimiterStatus,
rateLimiterThreshold,
description
});
if (error) return;
}
if (props.operateType === 'edit') {
const { id, groupName, businessId, notifyStatus, systemTaskType, notifyScene, notifyThreshold, description } =
model;
const {
id,
groupName,
businessId,
notifyRecipientIds,
notifyStatus,
systemTaskType,
notifyScene,
notifyThreshold,
rateLimiterStatus,
rateLimiterThreshold,
description
} = model;
const { error } = await fetchEditNotify({
id,
groupName,
businessId,
notifyRecipientIds,
systemTaskType,
notifyStatus,
notifyScene,
notifyThreshold,
rateLimiterStatus,
rateLimiterThreshold,
description
});
if (error) return;
@ -208,17 +261,39 @@ watch(visible, () => {
clearable
/>
</NFormItem>
<NGrid x-gap="12" :cols="6" item-responsive responsive="screen">
<NGi span="m:6 l:6"></NGi>
<NGi span="m:6 l:2">
<NFormItem :label="$t('page.notifyConfig.notifyThreshold')" path="notifyThreshold">
<NInputNumber
v-model:value="model.notifyThreshold"
:placeholder="$t('page.notifyConfig.form.notifyThreshold')"
<NFormItem :label="$t('page.notifyConfig.notifyRecipient')" path="notifyRecipientIds">
<NSelect
v-model:value="model.notifyRecipientIds"
:placeholder="$t('page.notifyConfig.form.notifyRecipient')"
:options="notifyRecipientList"
clearable
multiple
/>
</NFormItem>
<NFormItem :label="$t('page.notifyConfig.rateLimiterStatus')" path="rateLimiterStatus">
<NRadioGroup v-model:value="model.rateLimiterStatus" :default-value="defaultChecked" name="rateLimiterStatus">
<NSpace>
<NRadio
v-for="item in enableStatus01Options"
:key="item.value"
:value="item.value"
:label="$t(item.label)"
/>
</NFormItem>
</NGi>
</NGrid>
</NSpace>
</NRadioGroup>
</NFormItem>
<NFormItem :label="$t('page.notifyConfig.rateLimiterThreshold')" path="rateLimiterThreshold">
<NInputNumber
v-model:value="model.rateLimiterThreshold"
:placeholder="$t('page.notifyConfig.form.rateLimiterThreshold')"
/>
</NFormItem>
<NFormItem :label="$t('page.notifyConfig.notifyThreshold')" path="notifyThreshold">
<NInputNumber
v-model:value="model.notifyThreshold"
:placeholder="$t('page.notifyConfig.form.notifyThreshold')"
/>
</NFormItem>
<NFormItem :label="$t('page.notifyConfig.description')" path="description">
<NInput
v-model:value="model.description"