feat(sj_1.3.0-beta1): 重试任务、工作流任务新增告警通知场景
This commit is contained in:
		
							parent
							
								
									a4c8916000
								
							
						
					
					
						commit
						044f731aa2
					
				@ -1,5 +1,5 @@
 | 
			
		||||
<script setup lang="ts">
 | 
			
		||||
import { ref, watch } from 'vue';
 | 
			
		||||
import { nextTick, onMounted, ref, watch } from 'vue';
 | 
			
		||||
import CronInput from '@sa/cron-input';
 | 
			
		||||
import { type FormInst, type FormItemRule } from 'naive-ui';
 | 
			
		||||
import {
 | 
			
		||||
@ -8,7 +8,7 @@ import {
 | 
			
		||||
  workFlowNodeStatusOptions
 | 
			
		||||
} from '@/constants/business';
 | 
			
		||||
import { $t } from '@/locales';
 | 
			
		||||
import { fetchGetAllGroupNameList } from '@/service/api';
 | 
			
		||||
import { fetchGetAllGroupNameList, fetchGetNotifyConfigSystemTaskTypeList } from '@/service/api';
 | 
			
		||||
import { isNotNull, parseContent, stringToContent } from '@/utils/common';
 | 
			
		||||
import { useWorkflowStore } from '@/store/modules/workflow';
 | 
			
		||||
import EditableInput from '@/components/common/editable-input.vue';
 | 
			
		||||
@ -22,6 +22,7 @@ interface Props {
 | 
			
		||||
  open?: boolean;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const notifyNameList = ref<CommonType.Option<number>[]>([]);
 | 
			
		||||
const props = withDefaults(defineProps<Props>(), {
 | 
			
		||||
  open: false,
 | 
			
		||||
  modelValue: () => ({
 | 
			
		||||
@ -34,6 +35,16 @@ interface Emits {
 | 
			
		||||
  (e: 'save', form: Workflow.NodeDataType): void;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
onMounted(() => {
 | 
			
		||||
  nextTick(() => {
 | 
			
		||||
    getNotifyConfigSystemTaskTypeList();
 | 
			
		||||
  });
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
async function getNotifyConfigSystemTaskTypeList() {
 | 
			
		||||
  const res = await fetchGetNotifyConfigSystemTaskTypeList(4);
 | 
			
		||||
  notifyNameList.value = res.data as CommonType.Option<number>[];
 | 
			
		||||
}
 | 
			
		||||
const emit = defineEmits<Emits>();
 | 
			
		||||
 | 
			
		||||
const store = useWorkflowStore();
 | 
			
		||||
@ -225,6 +236,17 @@ const rules: Record<RuleKey, FormItemRule> = {
 | 
			
		||||
            </NSpace>
 | 
			
		||||
          </NRadioGroup>
 | 
			
		||||
        </NFormItem>
 | 
			
		||||
        <NFormItem path="notifyIds" label="通知场景名称">
 | 
			
		||||
          <NSelect
 | 
			
		||||
            v-model:value="form.notifyIds"
 | 
			
		||||
            value-field="id"
 | 
			
		||||
            label-field="notifyName"
 | 
			
		||||
            placeholder="请选择告警通知名称"
 | 
			
		||||
            :options="notifyNameList"
 | 
			
		||||
            clearable
 | 
			
		||||
            multiple
 | 
			
		||||
          />
 | 
			
		||||
        </NFormItem>
 | 
			
		||||
        <NFormItem path="description" label="描述">
 | 
			
		||||
          <NInput
 | 
			
		||||
            v-model:value="form.description"
 | 
			
		||||
 | 
			
		||||
@ -686,6 +686,7 @@ const local: App.I18n.Schema = {
 | 
			
		||||
      detail: 'Scene Detail',
 | 
			
		||||
      groupName: 'Group name',
 | 
			
		||||
      sceneName: 'Scene name',
 | 
			
		||||
      notifyName: 'Notify name',
 | 
			
		||||
      sceneStatus: 'State',
 | 
			
		||||
      backOff: 'Backoff strategy',
 | 
			
		||||
      maxRetryCount: 'Maximum number of retries',
 | 
			
		||||
@ -698,6 +699,7 @@ const local: App.I18n.Schema = {
 | 
			
		||||
      routeKey: 'Routing strategy',
 | 
			
		||||
      form: {
 | 
			
		||||
        maxRetryCount: 'Please enter Maximum number of retries',
 | 
			
		||||
        notifyName: 'Plase enter Notify name',
 | 
			
		||||
        triggerInterval: 'Please enter Intervals(s)',
 | 
			
		||||
        groupName: 'Please enter Group name',
 | 
			
		||||
        description: 'Please enter Describe',
 | 
			
		||||
 | 
			
		||||
@ -694,6 +694,7 @@ const local: App.I18n.Schema = {
 | 
			
		||||
      detail: '场景详情',
 | 
			
		||||
      groupName: '组名',
 | 
			
		||||
      sceneName: '场景名',
 | 
			
		||||
      notifyName: '告警通知名称',
 | 
			
		||||
      sceneStatus: '状态',
 | 
			
		||||
      backOff: '退避策略',
 | 
			
		||||
      maxRetryCount: '最大重试次数',
 | 
			
		||||
@ -705,6 +706,7 @@ const local: App.I18n.Schema = {
 | 
			
		||||
      description: '描述',
 | 
			
		||||
      routeKey: '路由策略',
 | 
			
		||||
      form: {
 | 
			
		||||
        notifyName: '请选择告警通知名称',
 | 
			
		||||
        maxRetryCount: '请输入最大重试次数',
 | 
			
		||||
        triggerInterval: '请输入间隔时间(秒)',
 | 
			
		||||
        groupName: '请输入组名',
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										4
									
								
								src/typings/api.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								src/typings/api.d.ts
									
									
									
									
										vendored
									
									
								
							@ -838,6 +838,8 @@ declare namespace Api {
 | 
			
		||||
      groupName: string;
 | 
			
		||||
      /** 场景名 */
 | 
			
		||||
      sceneName: string;
 | 
			
		||||
      /** 通知场景ids */
 | 
			
		||||
      notifyIds: number[];
 | 
			
		||||
      /** 状态 */
 | 
			
		||||
      sceneStatus: EnableStatusNumber;
 | 
			
		||||
      /** 退避策略 */
 | 
			
		||||
@ -903,6 +905,8 @@ declare namespace Api {
 | 
			
		||||
      groupName: string;
 | 
			
		||||
      /** 触发时间 */
 | 
			
		||||
      nextTriggerAt: string;
 | 
			
		||||
      /** 告警通知场景ids */
 | 
			
		||||
      notifyIds: number[];
 | 
			
		||||
      /** 状态 */
 | 
			
		||||
      workflowStatus: EnableStatusNumber;
 | 
			
		||||
      /** 触发类型 */
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								src/typings/app.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								src/typings/app.d.ts
									
									
									
									
										vendored
									
									
								
							@ -894,6 +894,7 @@ declare namespace App {
 | 
			
		||||
          detail: string;
 | 
			
		||||
          groupName: string;
 | 
			
		||||
          sceneName: string;
 | 
			
		||||
          notifyName: string;
 | 
			
		||||
          sceneStatus: string;
 | 
			
		||||
          backOff: string;
 | 
			
		||||
          maxRetryCount: string;
 | 
			
		||||
@ -905,6 +906,7 @@ declare namespace App {
 | 
			
		||||
          description: string;
 | 
			
		||||
          routeKey: string;
 | 
			
		||||
          form: {
 | 
			
		||||
            notifyName: string;
 | 
			
		||||
            maxRetryCount: string;
 | 
			
		||||
            triggerInterval: string;
 | 
			
		||||
            groupName: string;
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										8
									
								
								src/typings/workflow.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								src/typings/workflow.d.ts
									
									
									
									
										vendored
									
									
								
							@ -7,6 +7,8 @@ declare namespace Workflow {
 | 
			
		||||
    workflowName?: string;
 | 
			
		||||
    /** 组名称 */
 | 
			
		||||
    groupName?: string;
 | 
			
		||||
    /** 告警通知场景ids */
 | 
			
		||||
    notifyIds?: number[];
 | 
			
		||||
    /** 触发类型 */
 | 
			
		||||
    triggerType?: Api.Common.TriggerType;
 | 
			
		||||
    /** 触发间隔 */
 | 
			
		||||
@ -179,13 +181,13 @@ declare namespace Workflow {
 | 
			
		||||
    taskStatus?: Api.Common.TaskBatchStatus;
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  export type JobBatchPage = {
 | 
			
		||||
  /* export type JobBatchPage = {
 | 
			
		||||
    total: number;
 | 
			
		||||
    data: JobTaskType[];
 | 
			
		||||
  };
 | 
			
		||||
  }; */
 | 
			
		||||
 | 
			
		||||
  /** 任务日志 */
 | 
			
		||||
  export type JobLogType = {};
 | 
			
		||||
  /* export type JobLogType = {}; */
 | 
			
		||||
 | 
			
		||||
  /** Tag */
 | 
			
		||||
  export type JobTagType = {
 | 
			
		||||
 | 
			
		||||
@ -1,10 +1,10 @@
 | 
			
		||||
<script setup lang="ts">
 | 
			
		||||
import { computed, reactive, ref, watch } from 'vue';
 | 
			
		||||
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 RouteKey from '@/components/common/route-key.vue';
 | 
			
		||||
import { $t } from '@/locales';
 | 
			
		||||
import { fetchAddRetryScene, fetchEditRetryScene } from '@/service/api';
 | 
			
		||||
import { fetchAddRetryScene, fetchEditRetryScene, fetchGetNotifyConfigSystemTaskTypeList } from '@/service/api';
 | 
			
		||||
import { DelayLevel, backOffRecordOptions, enableStatusNumberOptions } from '@/constants/business';
 | 
			
		||||
import { isNotNull, translateOptions } from '@/utils/common';
 | 
			
		||||
 | 
			
		||||
@ -21,6 +21,7 @@ interface Props {
 | 
			
		||||
 | 
			
		||||
const delayLevelDesc = ref<string>('10s');
 | 
			
		||||
 | 
			
		||||
const notifyNameList = ref<CommonType.Option<number>[]>([]);
 | 
			
		||||
const props = defineProps<Props>();
 | 
			
		||||
 | 
			
		||||
interface Emits {
 | 
			
		||||
@ -48,6 +49,7 @@ type Model = Pick<
 | 
			
		||||
  Api.RetryScene.Scene,
 | 
			
		||||
  | 'id'
 | 
			
		||||
  | 'groupName'
 | 
			
		||||
  | 'notifyIds'
 | 
			
		||||
  | 'sceneName'
 | 
			
		||||
  | 'sceneStatus'
 | 
			
		||||
  | 'backOff'
 | 
			
		||||
@ -59,12 +61,24 @@ type Model = Pick<
 | 
			
		||||
  | 'routeKey'
 | 
			
		||||
>;
 | 
			
		||||
 | 
			
		||||
onMounted(() => {
 | 
			
		||||
  nextTick(() => {
 | 
			
		||||
    getNotifyConfigSystemTaskTypeList();
 | 
			
		||||
  });
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
async function getNotifyConfigSystemTaskTypeList() {
 | 
			
		||||
  const res = await fetchGetNotifyConfigSystemTaskTypeList(1);
 | 
			
		||||
  notifyNameList.value = res.data as CommonType.Option<number>[];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const model: Model = reactive(createDefaultModel());
 | 
			
		||||
 | 
			
		||||
function createDefaultModel(): Model {
 | 
			
		||||
  return {
 | 
			
		||||
    groupName: '',
 | 
			
		||||
    sceneName: '',
 | 
			
		||||
    notifyIds: [],
 | 
			
		||||
    sceneStatus: 1,
 | 
			
		||||
    backOff: 2,
 | 
			
		||||
    maxRetryCount: 1,
 | 
			
		||||
@ -133,6 +147,7 @@ async function handleSubmit() {
 | 
			
		||||
    const {
 | 
			
		||||
      groupName,
 | 
			
		||||
      sceneName,
 | 
			
		||||
      notifyIds,
 | 
			
		||||
      sceneStatus,
 | 
			
		||||
      backOff,
 | 
			
		||||
      maxRetryCount,
 | 
			
		||||
@ -145,6 +160,7 @@ async function handleSubmit() {
 | 
			
		||||
    const { error } = await fetchAddRetryScene({
 | 
			
		||||
      groupName,
 | 
			
		||||
      sceneName,
 | 
			
		||||
      notifyIds,
 | 
			
		||||
      sceneStatus,
 | 
			
		||||
      backOff,
 | 
			
		||||
      maxRetryCount,
 | 
			
		||||
@ -163,6 +179,7 @@ async function handleSubmit() {
 | 
			
		||||
      id,
 | 
			
		||||
      groupName,
 | 
			
		||||
      sceneName,
 | 
			
		||||
      notifyIds,
 | 
			
		||||
      sceneStatus,
 | 
			
		||||
      backOff,
 | 
			
		||||
      maxRetryCount,
 | 
			
		||||
@ -176,6 +193,7 @@ async function handleSubmit() {
 | 
			
		||||
      id,
 | 
			
		||||
      groupName,
 | 
			
		||||
      sceneName,
 | 
			
		||||
      notifyIds,
 | 
			
		||||
      sceneStatus,
 | 
			
		||||
      backOff,
 | 
			
		||||
      maxRetryCount,
 | 
			
		||||
@ -342,6 +360,17 @@ watch(
 | 
			
		||||
          </NFormItem>
 | 
			
		||||
        </NGi>
 | 
			
		||||
      </NGrid>
 | 
			
		||||
      <NFormItem :label="$t('page.retryScene.notifyName')" path="notifyIds">
 | 
			
		||||
        <NSelect
 | 
			
		||||
          v-model:value="model.notifyIds"
 | 
			
		||||
          value-field="id"
 | 
			
		||||
          label-field="notifyName"
 | 
			
		||||
          :placeholder="$t('page.retryScene.form.notifyName')"
 | 
			
		||||
          :options="notifyNameList"
 | 
			
		||||
          clearable
 | 
			
		||||
          multiple
 | 
			
		||||
        />
 | 
			
		||||
      </NFormItem>
 | 
			
		||||
      <NFormItem :label="$t('page.retryScene.description')" path="description">
 | 
			
		||||
        <NInput
 | 
			
		||||
          v-model:value="model.description"
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user