feat: [路由策略]随[任务类型]联动
This commit is contained in:
parent
bb3d1d7e9a
commit
df06186a72
@ -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>
|
||||
|
||||
|
@ -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" />
|
||||
|
Loading…
Reference in New Issue
Block a user