feat: [路由策略]随[任务类型]联动

This commit is contained in:
dhb52 2024-05-12 19:18:15 +08:00
parent bb3d1d7e9a
commit df06186a72
2 changed files with 25 additions and 9 deletions

View File

@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref } from 'vue';
import { computed } from 'vue';
import { $t } from '@/locales';
import { translateOptions } from '@/utils/common';
import { routeKeyRecordOptions } from '@/constants/business';
@ -8,25 +8,41 @@ defineOptions({
name: 'RouterKey'
});
interface Props {
taskType?: Api.Common.TaskType;
}
const props = withDefaults(defineProps<Props>(), {
taskType: 1
});
interface Emits {
(e: 'update:value', value: Api.Common.RouteKey): void;
}
const emit = defineEmits<Emits>();
const routeKeyRef = ref<Api.Common.RouteKey>();
const modelValue = defineModel<Api.Common.RouteKey>('value');
const handleUpdate = (routeKey: Api.Common.RouteKey) => {
emit('update:value', routeKey);
};
/** select 下拉选项 */
const selectOptions = computed(() => {
//
emit('update:value', 4);
// 1:, 3:
if (props.taskType === 1 || props.taskType === 3) {
return translateOptions(routeKeyRecordOptions.filter(o => o.value === 4));
}
// 2:广
return translateOptions(routeKeyRecordOptions);
});
</script>
<template>
<NSelect
v-model:value="routeKeyRef"
v-model:value="modelValue"
:placeholder="$t('common.routeKey.routeForm')"
:options="translateOptions(routeKeyRecordOptions)"
:options="selectOptions"
clearable
@update:value="handleUpdate"
/>
</template>

View File

@ -337,7 +337,7 @@ watch(visible, () => {
<CodeMirror v-else v-model="model.argsStr" lang="json" :placeholder="$t('page.jobTask.form.argsStr')" />
</NFormItem>
<NFormItem :label="$t('page.jobTask.routeKey')" path="routeKey">
<RouteKey v-model:value="model.routeKey" />
<RouteKey v-model:value="model.routeKey" :task-type="model.taskType" />
</NFormItem>
<NFormItem :label="$t('page.jobTask.blockStrategy')" path="blockStrategy">
<BlockStrategy v-model:value="model.blockStrategy" />