feat(sj_1.0.0): 完成通知配置
This commit is contained in:
parent
33e8ec8ae6
commit
283153b0ac
@ -666,6 +666,9 @@ const local: App.I18n.Schema = {
|
||||
notifyThreshold: 'Notify threshold',
|
||||
description: 'Describe',
|
||||
notifyAttribute: 'Notify Attribute',
|
||||
retryScene: 'Retry Scene',
|
||||
job: 'Job',
|
||||
workflow: 'Workflow',
|
||||
form: {
|
||||
businessId: 'Please select Business ID',
|
||||
description: 'Please enter Describe',
|
||||
|
@ -662,6 +662,9 @@ const local: App.I18n.Schema = {
|
||||
notifyThreshold: '通知阈值',
|
||||
description: '描述',
|
||||
notifyAttribute: '通知属性',
|
||||
retryScene: '重试场景',
|
||||
job: '定时任务',
|
||||
workflow: '工作流',
|
||||
form: {
|
||||
businessId: '请选择业务ID',
|
||||
description: '请输入描述',
|
||||
|
@ -9,6 +9,15 @@ export function fetchGetJobPage(params?: Api.Job.JobSearchParams) {
|
||||
});
|
||||
}
|
||||
|
||||
/** get Job list */
|
||||
export function fetchGetJobList(params?: Api.Job.JobSearchParams) {
|
||||
return request<Api.Job.Job[]>({
|
||||
url: '/job/list',
|
||||
method: 'get',
|
||||
params
|
||||
});
|
||||
}
|
||||
|
||||
/** add Job */
|
||||
export function fetchAddJob(data: Api.Job.Job) {
|
||||
return request<boolean>({
|
||||
|
@ -27,6 +27,14 @@ export function fetchEditNotify(data: Api.NotifyConfig.NotifyConfig) {
|
||||
});
|
||||
}
|
||||
|
||||
/** edit notify status */
|
||||
export function fetchUpdateNotifyStatus(id: string, status: Api.Common.EnableStatusNumber) {
|
||||
return request<boolean>({
|
||||
url: `/notify-config/${id}/status/${status}`,
|
||||
method: 'put'
|
||||
});
|
||||
}
|
||||
|
||||
/** get notify recipient list */
|
||||
export function fetchGetNotifyRecipientPageList(params?: Api.NotifyRecipient.NotifyRecipientParams) {
|
||||
return request<Api.NotifyRecipient.NotifyRecipientList>({
|
||||
|
2
src/typings/api.d.ts
vendored
2
src/typings/api.d.ts
vendored
@ -565,7 +565,7 @@ declare namespace Api {
|
||||
/** 状态 */
|
||||
notifyStatus: Api.Common.EnableStatusNumber;
|
||||
/** 通知场景 */
|
||||
notifyScene: string;
|
||||
notifyScene: number;
|
||||
/** 通知阈值 */
|
||||
notifyThreshold: number;
|
||||
/** 限流开关 */
|
||||
|
3
src/typings/app.d.ts
vendored
3
src/typings/app.d.ts
vendored
@ -814,6 +814,9 @@ declare namespace App {
|
||||
notifyThreshold: string;
|
||||
description: string;
|
||||
notifyAttribute: string;
|
||||
retryScene: string;
|
||||
job: string;
|
||||
workflow: string;
|
||||
form: {
|
||||
businessId: string;
|
||||
description: string;
|
||||
|
@ -1,11 +1,13 @@
|
||||
<script setup lang="tsx">
|
||||
import { NButton, NPopconfirm } from 'naive-ui';
|
||||
import { fetchGetNotifyConfigList } from '@/service/api';
|
||||
import { NButton, NPopconfirm, NTag } from 'naive-ui';
|
||||
import { fetchGetNotifyConfigList, fetchUpdateNotifyStatus } from '@/service/api';
|
||||
import { $t } from '@/locales';
|
||||
import { useAppStore } from '@/store/modules/app';
|
||||
import { useTable, useTableOperate } from '@/hooks/common/table';
|
||||
import NotifyConfigOperateDrawer from '@/views/notify/scene/modules/notify-config-operate-drawer.vue';
|
||||
import NotifyConfigSearch from '@/views/notify/scene/modules/notify-config-search.vue';
|
||||
import StatusSwitch from '@/components/common/status-switch.vue';
|
||||
import { jobNotifyScene, retryNotifyScene } from '@/constants/business';
|
||||
|
||||
const appStore = useAppStore();
|
||||
|
||||
@ -48,13 +50,52 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
|
||||
key: 'notifyStatus',
|
||||
title: $t('page.notifyConfig.notifyStatus'),
|
||||
align: 'left',
|
||||
width: 120
|
||||
width: 120,
|
||||
render: row => {
|
||||
const fetchFn = async (notifyStatus: Api.Common.EnableStatusNumber, callback: () => void) => {
|
||||
const { error } = await fetchUpdateNotifyStatus(row.id!, notifyStatus);
|
||||
if (!error) {
|
||||
row.notifyStatus = notifyStatus;
|
||||
window.$message?.success($t('common.updateSuccess'));
|
||||
}
|
||||
callback();
|
||||
};
|
||||
|
||||
return <StatusSwitch v-model:value={row.notifyStatus} onFetch={fetchFn} />;
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'notifyScene',
|
||||
title: $t('page.notifyConfig.notifyScene'),
|
||||
align: 'left',
|
||||
width: 120
|
||||
width: 120,
|
||||
render: row => {
|
||||
if (row.notifyScene === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const tagMap: Record<number, NaiveUI.ThemeColor> = {
|
||||
1: 'warning',
|
||||
2: 'info',
|
||||
3: 'warning',
|
||||
4: 'success'
|
||||
};
|
||||
|
||||
const index = row.notifyScene! % 4;
|
||||
|
||||
if (row.systemTaskType === 1) {
|
||||
const label = $t(retryNotifyScene[row.notifyScene! as Api.NotifyConfig.RetryNotifyScene]);
|
||||
const type = tagMap[index as Api.NotifyConfig.RetryNotifyScene];
|
||||
return <NTag type={type}>{label}</NTag>;
|
||||
}
|
||||
|
||||
if (row.systemTaskType === 3) {
|
||||
const label = $t(jobNotifyScene[row.notifyScene! as Api.NotifyConfig.JobNotifyScene]);
|
||||
return <NTag type={tagMap[row.notifyScene!]}>{label}</NTag>;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'notifyThreshold',
|
||||
@ -107,9 +148,6 @@ const {
|
||||
} = useTableOperate(data, getData);
|
||||
|
||||
async function handleBatchDelete() {
|
||||
// request
|
||||
console.log(checkedRowKeys.value);
|
||||
|
||||
onBatchDeleted();
|
||||
}
|
||||
|
||||
|
@ -3,14 +3,21 @@ 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, fetchGetNotifyRecipientList } from '@/service/api';
|
||||
import {
|
||||
fetchAddNotify,
|
||||
fetchEditNotify,
|
||||
fetchGetJobList,
|
||||
fetchGetNotifyRecipientList,
|
||||
fetchGetRetrySceneList
|
||||
} from '@/service/api';
|
||||
import {
|
||||
enableStatusNumberOptions,
|
||||
jobNotifySceneOptions,
|
||||
retryNotifySceneOptions,
|
||||
systemTaskTypeOptions
|
||||
} from '@/constants/business';
|
||||
import { translateOptions, translateOptions2 } from '@/utils/common';
|
||||
import { translateOptions } from '@/utils/common';
|
||||
import SelectGroup from '@/components/common/select-group.vue';
|
||||
|
||||
defineOptions({
|
||||
name: 'NotifyConfigOperateDrawer'
|
||||
@ -23,8 +30,10 @@ interface Props {
|
||||
rowData?: Api.NotifyConfig.NotifyConfig | null;
|
||||
}
|
||||
|
||||
const groupNameList = ref<string[]>([]);
|
||||
const notifyRecipientList = ref<CommonType.Option<number>[]>([]);
|
||||
const retryScenes = ref<Api.RetryScene.Scene[]>([]);
|
||||
const jobs = ref<Api.Job.Job[]>([]);
|
||||
|
||||
const props = defineProps<Props>();
|
||||
|
||||
interface Emits {
|
||||
@ -69,16 +78,10 @@ type Model = Pick<
|
||||
|
||||
onMounted(() => {
|
||||
nextTick(() => {
|
||||
getGroupNameList();
|
||||
getNotifyRecipientList();
|
||||
});
|
||||
});
|
||||
|
||||
async function getGroupNameList() {
|
||||
const res = await fetchGetAllGroupNameList();
|
||||
groupNameList.value = res.data as string[];
|
||||
}
|
||||
|
||||
async function getNotifyRecipientList() {
|
||||
const res = await fetchGetNotifyRecipientList();
|
||||
notifyRecipientList.value = res.data as CommonType.Option<number>[];
|
||||
@ -93,7 +96,7 @@ function createDefaultModel(): Model {
|
||||
notifyRecipientIds: 0,
|
||||
systemTaskType: 1,
|
||||
notifyStatus: 1,
|
||||
notifyScene: '',
|
||||
notifyScene: 1,
|
||||
notifyThreshold: 0,
|
||||
rateLimiterStatus: 0,
|
||||
rateLimiterThreshold: 0,
|
||||
@ -202,14 +205,25 @@ async function handleSubmit() {
|
||||
emit('submitted');
|
||||
}
|
||||
|
||||
function systemTaskTypeChange(value: string) {
|
||||
if (value === '1') {
|
||||
async function systemTaskTypeChange(value: number) {
|
||||
if (value === 1) {
|
||||
const res = await fetchGetRetrySceneList({ groupName: model.groupName });
|
||||
retryScenes.value = res.data as Api.RetryScene.Scene[];
|
||||
options.value = translateOptions(retryNotifySceneOptions);
|
||||
} else if (value === '3') {
|
||||
} else if (value === 3) {
|
||||
const res = await fetchGetJobList({ groupName: model.groupName });
|
||||
jobs.value = res.data as Api.Job.Job[];
|
||||
options.value = translateOptions(jobNotifySceneOptions);
|
||||
}
|
||||
|
||||
model.notifyScene = '';
|
||||
model.businessId = '';
|
||||
model.notifyScene = 1;
|
||||
}
|
||||
|
||||
function groupNameUpdate(groupName: string) {
|
||||
handleUpdateModelWhenEdit();
|
||||
model.groupName = groupName;
|
||||
systemTaskTypeChange(1);
|
||||
}
|
||||
|
||||
watch(visible, () => {
|
||||
@ -224,12 +238,7 @@ watch(visible, () => {
|
||||
<OperateDrawer v-model="visible" :title="title" @handle-submit="handleSubmit">
|
||||
<NForm ref="formRef" :model="model" :rules="rules">
|
||||
<NFormItem :label="$t('page.notifyConfig.groupName')" path="groupName">
|
||||
<NSelect
|
||||
v-model:value="model.groupName"
|
||||
:placeholder="$t('page.notifyConfig.form.groupName')"
|
||||
:options="translateOptions2(groupNameList)"
|
||||
clearable
|
||||
/>
|
||||
<SelectGroup v-model:modelValue="model.groupName" @update:model-value="groupNameUpdate" />
|
||||
</NFormItem>
|
||||
<NFormItem :label="$t('page.notifyConfig.notifyStatus')" path="notifyStatus">
|
||||
<NRadioGroup v-model:value="model.notifyStatus" name="notifyStatus">
|
||||
@ -252,6 +261,29 @@ watch(visible, () => {
|
||||
@update:value="systemTaskTypeChange"
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem v-if="model.systemTaskType === 1" :label="$t('page.notifyConfig.retryScene')" path="businessId">
|
||||
<NSelect
|
||||
v-model:value="model.businessId"
|
||||
:placeholder="$t('page.notifyConfig.form.groupName')"
|
||||
:options="retryScenes"
|
||||
label-field="sceneName"
|
||||
value-field="sceneName"
|
||||
clearable
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem v-if="model.systemTaskType === 3" :label="$t('page.notifyConfig.job')" path="businessId">
|
||||
<NSelect
|
||||
v-model:value="model.businessId"
|
||||
:placeholder="$t('page.notifyConfig.form.groupName')"
|
||||
:options="jobs"
|
||||
label-field="jobName"
|
||||
value-field="id"
|
||||
clearable
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem v-if="model.systemTaskType === 4" :label="$t('page.notifyConfig.workflow')" path="businessId">
|
||||
<NSelect v-model:value="model.businessId" :placeholder="$t('page.notifyConfig.form.groupName')" clearable />
|
||||
</NFormItem>
|
||||
<NFormItem :label="$t('page.notifyConfig.notifyScene')" path="notifyScene">
|
||||
<NSelect
|
||||
v-model:value="model.notifyScene"
|
||||
|
@ -6,6 +6,7 @@ import OperateDrawer from '@/components/common/operate-drawer.vue';
|
||||
import { $t } from '@/locales';
|
||||
import { fetchAddUser, fetchEditUser, fetchGetAllGroupConfigList } from '@/service/api';
|
||||
import { groupConfigYesOrNoOptions, roleRecordOptions } from '@/constants/business';
|
||||
import Permission = Api.UserManager.Permission;
|
||||
|
||||
defineOptions({
|
||||
name: 'UserManagerOperateDrawer'
|
||||
@ -135,15 +136,25 @@ watch(visible, () => {
|
||||
}
|
||||
});
|
||||
|
||||
function updatePermissions(p: OptionValue[]) {
|
||||
// ['snail_job_demo_group@764d604ec6fc45f68cd92514c40e9e1a']
|
||||
model.permissions = p?.map(value => {
|
||||
const [groupName, namespaceId] = (value as string).split('@'); // 将字符串分割成数组
|
||||
type PermissionModel = Pick<Permission, 'groupName' | 'namespaceId'>;
|
||||
|
||||
function getPermission(str: string): PermissionModel {
|
||||
const permissionModelComputedRef = computed<PermissionModel>(() => {
|
||||
const [groupName, namespaceId] = str.split('@'); // 将字符串分割成数组
|
||||
return {
|
||||
groupName,
|
||||
namespaceId
|
||||
};
|
||||
});
|
||||
|
||||
return permissionModelComputedRef.value;
|
||||
}
|
||||
|
||||
function updatePermissions(p: OptionValue[]) {
|
||||
// ['snail_job_demo_group@764d604ec6fc45f68cd92514c40e9e1a']
|
||||
model.permissions = p?.map(value => {
|
||||
return getPermission(value as string);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user