feat(sj_1.0.0): 优化任务类型与通知场景联动

This commit is contained in:
opensnail 2024-04-19 23:06:48 +08:00
parent d7eae71827
commit 04d2472a91

View File

@ -4,7 +4,12 @@ import { useFormRules, useNaiveForm } from '@/hooks/common/form';
import OperateDrawer from '@/components/common/operate-drawer.vue'; import OperateDrawer from '@/components/common/operate-drawer.vue';
import { $t } from '@/locales'; import { $t } from '@/locales';
import { fetchAddNotify, fetchEditNotify } from '@/service/api'; 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'; import { translateOptions } from '@/utils/common';
defineOptions({ defineOptions({
@ -30,6 +35,10 @@ const visible = defineModel<boolean>('visible', {
default: false default: false
}); });
const options = defineModel<CommonType.Option<string | number>[]>('options', {
default: translateOptions(retryNotifySceneOptions)
});
const { formRef, validate, restoreValidation } = useNaiveForm(); const { formRef, validate, restoreValidation } = useNaiveForm();
const { defaultRequiredRule } = useFormRules(); const { defaultRequiredRule } = useFormRules();
@ -95,15 +104,7 @@ async function handleSubmit() {
await validate(); await validate();
// request // request
if (props.operateType === 'add') { if (props.operateType === 'add') {
const { const { groupName, businessId, systemTaskType, notifyStatus, notifyScene, notifyThreshold, description } = model;
groupName,
businessId,
systemTaskType,
notifyStatus,
notifyScene,
notifyThreshold,
description
} = model;
const { error } = await fetchAddNotify({ const { error } = await fetchAddNotify({
groupName, groupName,
businessId, businessId,
@ -117,16 +118,8 @@ async function handleSubmit() {
} }
if (props.operateType === 'edit') { if (props.operateType === 'edit') {
const { const { id, groupName, businessId, notifyStatus, systemTaskType, notifyScene, notifyThreshold, description } =
id, model;
groupName,
businessId,
notifyStatus,
systemTaskType,
notifyScene,
notifyThreshold,
description
} = model;
const { error } = await fetchEditNotify({ const { error } = await fetchEditNotify({
id, id,
groupName, groupName,
@ -144,6 +137,16 @@ async function handleSubmit() {
emit('submitted'); 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, () => { watch(visible, () => {
if (visible.value) { if (visible.value) {
handleUpdateModelWhenEdit(); handleUpdateModelWhenEdit();
@ -176,13 +179,14 @@ watch(visible, () => {
:placeholder="$t('page.notifyConfig.form.systemTaskType')" :placeholder="$t('page.notifyConfig.form.systemTaskType')"
:options="translateOptions(systemTaskTypeOptions)" :options="translateOptions(systemTaskTypeOptions)"
clearable clearable
@update:value="systemTaskTypeChange"
/> />
</NFormItem> </NFormItem>
<NFormItem :label="$t('page.notifyConfig.notifyScene')" path="notifyScene"> <NFormItem :label="$t('page.notifyConfig.notifyScene')" path="notifyScene">
<NSelect <NSelect
v-model:value="model.notifyScene" v-model:value="model.notifyScene"
:placeholder="$t('page.notifyConfig.form.notifyScene')" :placeholder="$t('page.notifyConfig.form.notifyScene')"
:options="translateOptions(retryNotifySceneOptions)" :options="options"
clearable clearable
/> />
</NFormItem> </NFormItem>