feat(sj_1.0.0): 工作流接入告警

This commit is contained in:
opensnail 2024-05-05 23:22:53 +08:00
parent 4b738d4907
commit f30827f01f
6 changed files with 57 additions and 9 deletions

View File

@ -76,6 +76,13 @@ export const jobNotifyScene: Record<Api.NotifyConfig.JobNotifyScene, App.I18n.I1
}; };
export const jobNotifySceneOptions = transformRecordToOption(jobNotifyScene); export const jobNotifySceneOptions = transformRecordToOption(jobNotifyScene);
export const workflowNotifyScene: Record<Api.NotifyConfig.WorkflowNotifyScene, App.I18n.I18nKey> = {
100: 'page.notifyConfig.workflowNotifyScene.workTaskError',
101: 'page.notifyConfig.workflowNotifyScene.workflowTaskCallbackError',
102: 'page.notifyConfig.workflowNotifyScene.workflowTaskDecisionError'
};
export const workflowNotifySceneOptions = transformRecordToOption(workflowNotifyScene);
export const groupConfigStatusRecord: Record<Api.GroupConfig.GroupStatusType, App.I18n.I18nKey> = { export const groupConfigStatusRecord: Record<Api.GroupConfig.GroupStatusType, App.I18n.I18nKey> = {
0: 'page.manage.common.status.disable', 0: 'page.manage.common.status.disable',
1: 'page.manage.common.status.enable' 1: 'page.manage.common.status.enable'

View File

@ -693,7 +693,10 @@ const local: App.I18n.Schema = {
notifyStatus: 'Please select State', notifyStatus: 'Please select State',
systemTaskType: '请选择任务类型', systemTaskType: '请选择任务类型',
notifyRecipient: '请选择通知人', notifyRecipient: '请选择通知人',
rateLimiterThreshold: '请选择阈值' rateLimiterThreshold: '请选择阈值',
sceneName: '请选择重试场景',
jobName: '请选择定时任务',
workflowName: '请选择工作流'
}, },
addNotifyConfig: 'Add Alarm notification', addNotifyConfig: 'Add Alarm notification',
editNotifyConfig: 'Add Alarm notification', editNotifyConfig: 'Add Alarm notification',
@ -709,6 +712,11 @@ const local: App.I18n.Schema = {
jobNotifyScene: { jobNotifyScene: {
jobTaskError: '任务执行失败' jobTaskError: '任务执行失败'
}, },
workflowNotifyScene: {
workTaskError: '任务执行失败',
workflowTaskCallbackError: '回调任务执行失败',
workflowTaskDecisionError: '判定节点执行失败'
},
notifyRecipient: '通知人信息', notifyRecipient: '通知人信息',
rateLimiterStatus: '限流开关', rateLimiterStatus: '限流开关',
rateLimiterThreshold: '每秒限流阈值' rateLimiterThreshold: '每秒限流阈值'

View File

@ -689,7 +689,10 @@ const local: App.I18n.Schema = {
notifyStatus: '请选择状态', notifyStatus: '请选择状态',
systemTaskType: '请选择任务类型', systemTaskType: '请选择任务类型',
notifyRecipient: '请选择通知人', notifyRecipient: '请选择通知人',
rateLimiterThreshold: '请选择阈值' rateLimiterThreshold: '请选择阈值',
sceneName: '请选择重试场景',
jobName: '请选择定时任务',
workflowName: '请选择工作流'
}, },
addNotifyConfig: '新增告警通知', addNotifyConfig: '新增告警通知',
editNotifyConfig: '编辑告警通知', editNotifyConfig: '编辑告警通知',
@ -705,6 +708,11 @@ const local: App.I18n.Schema = {
jobNotifyScene: { jobNotifyScene: {
jobTaskError: '任务执行失败' jobTaskError: '任务执行失败'
}, },
workflowNotifyScene: {
workTaskError: '工作流任务执行失败',
workflowTaskCallbackError: '工作流回调任务执行失败',
workflowTaskDecisionError: '工作流判定节点执行失败'
},
notifyRecipient: '通知人信息', notifyRecipient: '通知人信息',
rateLimiterStatus: '限流开关', rateLimiterStatus: '限流开关',
rateLimiterThreshold: '每秒限流阈值' rateLimiterThreshold: '每秒限流阈值'

View File

@ -565,7 +565,7 @@ declare namespace Api {
/** 状态 */ /** 状态 */
notifyStatus: Api.Common.EnableStatusNumber; notifyStatus: Api.Common.EnableStatusNumber;
/** 通知场景 */ /** 通知场景 */
notifyScene: JobNotifyScene | RetryNotifyScene; notifyScene: JobNotifyScene | RetryNotifyScene | WorkflowNotifyScene | null;
/** 通知阈值 */ /** 通知阈值 */
notifyThreshold: number; notifyThreshold: number;
/** 限流开关 */ /** 限流开关 */
@ -596,6 +596,9 @@ declare namespace Api {
/** 1、任务执行失败 */ /** 1、任务执行失败 */
type JobNotifyScene = 1; type JobNotifyScene = 1;
/** 100、工作流任务执行失败 101、回调节点执行失败 102、判定节点执行失败 */
type WorkflowNotifyScene = 100 | 101 | 102;
} }
/** /**

View File

@ -837,6 +837,9 @@ declare namespace App {
systemTaskType: string; systemTaskType: string;
notifyRecipient: string; notifyRecipient: string;
rateLimiterThreshold: string; rateLimiterThreshold: string;
sceneName: string;
jobName: string;
workflowName: string;
}; };
addNotifyConfig: string; addNotifyConfig: string;
editNotifyConfig: string; editNotifyConfig: string;
@ -852,6 +855,11 @@ declare namespace App {
jobNotifyScene: { jobNotifyScene: {
jobTaskError: string; jobTaskError: string;
}; };
workflowNotifyScene: {
workTaskError: string;
workflowTaskCallbackError: string;
workflowTaskDecisionError: string;
};
notifyRecipient: string; notifyRecipient: string;
rateLimiterStatus: string; rateLimiterStatus: string;
rateLimiterThreshold: string; rateLimiterThreshold: string;

View File

@ -8,13 +8,15 @@ import {
fetchEditNotify, fetchEditNotify,
fetchGetJobList, fetchGetJobList,
fetchGetNotifyRecipientList, fetchGetNotifyRecipientList,
fetchGetRetrySceneList fetchGetRetrySceneList,
fetchGetWorkflowNameList
} from '@/service/api'; } from '@/service/api';
import { import {
enableStatusNumberOptions, enableStatusNumberOptions,
jobNotifySceneOptions, jobNotifySceneOptions,
retryNotifySceneOptions, retryNotifySceneOptions,
systemTaskTypeOptions systemTaskTypeOptions,
workflowNotifySceneOptions
} from '@/constants/business'; } from '@/constants/business';
import { translateOptions } from '@/utils/common'; import { translateOptions } from '@/utils/common';
import SelectGroup from '@/components/common/select-group.vue'; import SelectGroup from '@/components/common/select-group.vue';
@ -33,6 +35,7 @@ interface Props {
const notifyRecipientList = ref<CommonType.Option<number>[]>([]); const notifyRecipientList = ref<CommonType.Option<number>[]>([]);
const retryScenes = ref<Api.RetryScene.Scene[]>([]); const retryScenes = ref<Api.RetryScene.Scene[]>([]);
const jobs = ref<Api.Job.Job[]>([]); const jobs = ref<Api.Job.Job[]>([]);
const workflows = ref<Api.Workflow.Workflow[]>([]);
const props = defineProps<Props>(); const props = defineProps<Props>();
@ -212,10 +215,14 @@ async function systemTaskTypeChange(value: number) {
const res = await fetchGetJobList({ groupName: model.groupName }); const res = await fetchGetJobList({ groupName: model.groupName });
jobs.value = res.data as Api.Job.Job[]; jobs.value = res.data as Api.Job.Job[];
notifySceneOptions.value = translateOptions(jobNotifySceneOptions); notifySceneOptions.value = translateOptions(jobNotifySceneOptions);
} else if (value === 4) {
const res = await fetchGetWorkflowNameList({ groupName: model.groupName });
workflows.value = res.data as Api.Workflow.Workflow[];
notifySceneOptions.value = translateOptions(workflowNotifySceneOptions);
} }
model.businessId = ''; model.businessId = '';
model.notifyScene = 1; model.notifyScene = null;
} }
function groupNameUpdate(groupName: string) { function groupNameUpdate(groupName: string) {
@ -262,7 +269,7 @@ watch(visible, () => {
<NFormItem v-if="model.systemTaskType === 1" :label="$t('page.notifyConfig.retryScene')" path="businessId"> <NFormItem v-if="model.systemTaskType === 1" :label="$t('page.notifyConfig.retryScene')" path="businessId">
<NSelect <NSelect
v-model:value="model.businessId" v-model:value="model.businessId"
:placeholder="$t('page.notifyConfig.form.groupName')" :placeholder="$t('page.notifyConfig.form.sceneName')"
:options="retryScenes" :options="retryScenes"
label-field="sceneName" label-field="sceneName"
value-field="sceneName" value-field="sceneName"
@ -272,7 +279,7 @@ watch(visible, () => {
<NFormItem v-if="model.systemTaskType === 3" :label="$t('page.notifyConfig.job')" path="businessId"> <NFormItem v-if="model.systemTaskType === 3" :label="$t('page.notifyConfig.job')" path="businessId">
<NSelect <NSelect
v-model:value="model.businessId" v-model:value="model.businessId"
:placeholder="$t('page.notifyConfig.form.groupName')" :placeholder="$t('page.notifyConfig.form.jobName')"
:options="jobs" :options="jobs"
label-field="jobName" label-field="jobName"
value-field="id" value-field="id"
@ -280,7 +287,14 @@ watch(visible, () => {
/> />
</NFormItem> </NFormItem>
<NFormItem v-if="model.systemTaskType === 4" :label="$t('page.notifyConfig.workflow')" path="businessId"> <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 /> <NSelect
v-model:value="model.businessId"
:placeholder="$t('page.notifyConfig.form.workflowName')"
:options="workflows"
label-field="workflowName"
value-field="id"
clearable
/>
</NFormItem> </NFormItem>
<NFormItem :label="$t('page.notifyConfig.notifyScene')" path="notifyScene"> <NFormItem :label="$t('page.notifyConfig.notifyScene')" path="notifyScene">
<NSelect <NSelect