2024-04-24 21:44:33 +08:00
|
|
|
<script setup lang="ts">
|
2024-05-12 19:18:15 +08:00
|
|
|
import { computed } from 'vue';
|
2024-04-24 21:44:33 +08:00
|
|
|
import { $t } from '@/locales';
|
|
|
|
import { translateOptions } from '@/utils/common';
|
|
|
|
import { routeKeyRecordOptions } from '@/constants/business';
|
|
|
|
|
2024-04-25 02:01:38 +08:00
|
|
|
defineOptions({
|
|
|
|
name: 'RouterKey'
|
|
|
|
});
|
|
|
|
|
2024-05-12 19:18:15 +08:00
|
|
|
interface Props {
|
|
|
|
taskType?: Api.Common.TaskType;
|
|
|
|
}
|
|
|
|
|
|
|
|
const props = withDefaults(defineProps<Props>(), {
|
2024-05-12 19:21:00 +08:00
|
|
|
// HACK: 默认值为`集群`, 选项不受限制
|
|
|
|
taskType: 2
|
2024-05-12 19:18:15 +08:00
|
|
|
});
|
|
|
|
|
2024-04-24 21:44:33 +08:00
|
|
|
interface Emits {
|
|
|
|
(e: 'update:value', value: Api.Common.RouteKey): void;
|
|
|
|
}
|
2024-05-05 01:22:46 +08:00
|
|
|
const emit = defineEmits<Emits>();
|
|
|
|
|
2024-05-12 19:18:15 +08:00
|
|
|
const modelValue = defineModel<Api.Common.RouteKey>('value');
|
|
|
|
|
|
|
|
/** select 下拉选项 */
|
|
|
|
const selectOptions = computed(() => {
|
|
|
|
// 默认选中轮询
|
|
|
|
emit('update:value', 4);
|
2024-04-24 21:44:33 +08:00
|
|
|
|
2024-05-12 19:18:15 +08:00
|
|
|
// 1:集群, 3:切片
|
|
|
|
if (props.taskType === 1 || props.taskType === 3) {
|
|
|
|
return translateOptions(routeKeyRecordOptions.filter(o => o.value === 4));
|
|
|
|
}
|
|
|
|
// 2:广播
|
|
|
|
return translateOptions(routeKeyRecordOptions);
|
|
|
|
});
|
2024-04-24 21:44:33 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<NSelect
|
2024-05-12 19:18:15 +08:00
|
|
|
v-model:value="modelValue"
|
2024-04-24 21:44:33 +08:00
|
|
|
:placeholder="$t('common.routeKey.routeForm')"
|
2024-05-12 19:18:15 +08:00
|
|
|
:options="selectOptions"
|
2024-04-24 21:44:33 +08:00
|
|
|
clearable
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<style scoped></style>
|