feat(sj_1.0.0): 优化任务类型与通知场景联动
This commit is contained in:
parent
d7eae71827
commit
04d2472a91
@ -4,7 +4,12 @@ import { useFormRules, useNaiveForm } from '@/hooks/common/form';
|
||||
import OperateDrawer from '@/components/common/operate-drawer.vue';
|
||||
import { $t } from '@/locales';
|
||||
import { fetchAddNotify, fetchEditNotify } from '@/service/api';
|
||||
import { enableStatus01Options, retryNotifySceneOptions, systemTaskTypeOptions } from '@/constants/business';
|
||||
import {
|
||||
enableStatus01Options,
|
||||
jobNotifySceneOptions,
|
||||
retryNotifySceneOptions,
|
||||
systemTaskTypeOptions
|
||||
} from '@/constants/business';
|
||||
import { translateOptions } from '@/utils/common';
|
||||
|
||||
defineOptions({
|
||||
@ -30,6 +35,10 @@ const visible = defineModel<boolean>('visible', {
|
||||
default: false
|
||||
});
|
||||
|
||||
const options = defineModel<CommonType.Option<string | number>[]>('options', {
|
||||
default: translateOptions(retryNotifySceneOptions)
|
||||
});
|
||||
|
||||
const { formRef, validate, restoreValidation } = useNaiveForm();
|
||||
const { defaultRequiredRule } = useFormRules();
|
||||
|
||||
@ -95,15 +104,7 @@ async function handleSubmit() {
|
||||
await validate();
|
||||
// request
|
||||
if (props.operateType === 'add') {
|
||||
const {
|
||||
groupName,
|
||||
businessId,
|
||||
systemTaskType,
|
||||
notifyStatus,
|
||||
notifyScene,
|
||||
notifyThreshold,
|
||||
description
|
||||
} = model;
|
||||
const { groupName, businessId, systemTaskType, notifyStatus, notifyScene, notifyThreshold, description } = model;
|
||||
const { error } = await fetchAddNotify({
|
||||
groupName,
|
||||
businessId,
|
||||
@ -117,16 +118,8 @@ async function handleSubmit() {
|
||||
}
|
||||
|
||||
if (props.operateType === 'edit') {
|
||||
const {
|
||||
id,
|
||||
groupName,
|
||||
businessId,
|
||||
notifyStatus,
|
||||
systemTaskType,
|
||||
notifyScene,
|
||||
notifyThreshold,
|
||||
description
|
||||
} = model;
|
||||
const { id, groupName, businessId, notifyStatus, systemTaskType, notifyScene, notifyThreshold, description } =
|
||||
model;
|
||||
const { error } = await fetchEditNotify({
|
||||
id,
|
||||
groupName,
|
||||
@ -144,6 +137,16 @@ async function handleSubmit() {
|
||||
emit('submitted');
|
||||
}
|
||||
|
||||
function systemTaskTypeChange(value: string) {
|
||||
if (value === '1') {
|
||||
options.value = translateOptions(retryNotifySceneOptions);
|
||||
} else if (value === '3') {
|
||||
options.value = translateOptions(jobNotifySceneOptions);
|
||||
}
|
||||
|
||||
model.notifyScene = '';
|
||||
}
|
||||
|
||||
watch(visible, () => {
|
||||
if (visible.value) {
|
||||
handleUpdateModelWhenEdit();
|
||||
@ -176,13 +179,14 @@ watch(visible, () => {
|
||||
:placeholder="$t('page.notifyConfig.form.systemTaskType')"
|
||||
:options="translateOptions(systemTaskTypeOptions)"
|
||||
clearable
|
||||
@update:value="systemTaskTypeChange"
|
||||
/>
|
||||
</NFormItem>
|
||||
<NFormItem :label="$t('page.notifyConfig.notifyScene')" path="notifyScene">
|
||||
<NSelect
|
||||
v-model:value="model.notifyScene"
|
||||
:placeholder="$t('page.notifyConfig.form.notifyScene')"
|
||||
:options="translateOptions(retryNotifySceneOptions)"
|
||||
:options="options"
|
||||
clearable
|
||||
/>
|
||||
</NFormItem>
|
||||
|
Loading…
Reference in New Issue
Block a user