2024-04-22 17:12:45 +08:00
|
|
|
<script setup lang="ts">
|
2024-04-23 09:23:11 +08:00
|
|
|
import { ref, watch } from 'vue';
|
2024-04-22 17:12:45 +08:00
|
|
|
import { $t } from '@/locales';
|
|
|
|
import { translateOptions2 } from '@/utils/common';
|
|
|
|
import { fetchGetAllGroupNameList } from '@/service/api';
|
|
|
|
|
2024-04-23 09:23:11 +08:00
|
|
|
defineOptions({
|
|
|
|
name: 'SelectGroup'
|
|
|
|
});
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
modelValue?: string | null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const props = defineProps<Props>();
|
|
|
|
|
2024-04-22 17:12:45 +08:00
|
|
|
const emit = defineEmits<Emits>();
|
|
|
|
|
|
|
|
interface Emits {
|
2024-04-23 09:23:11 +08:00
|
|
|
(e: 'update:modelValue', value: string): void;
|
2024-04-22 17:12:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/** 组列表 */
|
|
|
|
const groupNameList = ref<string[]>([]);
|
|
|
|
/** 组列表 */
|
2024-04-23 09:23:11 +08:00
|
|
|
const groupName = ref<string>();
|
2024-04-22 17:12:45 +08:00
|
|
|
|
|
|
|
async function getGroupNameList() {
|
2024-04-23 09:23:11 +08:00
|
|
|
const { data, error } = await fetchGetAllGroupNameList();
|
|
|
|
if (!error) {
|
|
|
|
groupNameList.value = data;
|
|
|
|
}
|
2024-04-22 17:12:45 +08:00
|
|
|
}
|
|
|
|
|
2024-04-23 09:23:11 +08:00
|
|
|
getGroupNameList();
|
2024-04-22 17:12:45 +08:00
|
|
|
|
|
|
|
watch(
|
2024-04-23 09:23:11 +08:00
|
|
|
() => props.modelValue,
|
2024-04-22 17:12:45 +08:00
|
|
|
() => {
|
2024-04-23 09:23:11 +08:00
|
|
|
groupName.value = props.modelValue!;
|
|
|
|
},
|
|
|
|
{ immediate: true }
|
2024-04-22 17:12:45 +08:00
|
|
|
);
|
2024-04-23 09:23:11 +08:00
|
|
|
|
|
|
|
const handleUpdate = (value: string) => {
|
|
|
|
emit('update:modelValue', value);
|
|
|
|
};
|
2024-04-22 17:12:45 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<NSelect
|
2024-04-23 09:23:11 +08:00
|
|
|
v-model:value="groupName"
|
2024-04-22 17:12:45 +08:00
|
|
|
:placeholder="$t('page.retryTask.form.groupName')"
|
|
|
|
:options="translateOptions2(groupNameList)"
|
|
|
|
clearable
|
|
|
|
filterable
|
2024-04-23 09:23:11 +08:00
|
|
|
@update:value="handleUpdate"
|
2024-04-22 17:12:45 +08:00
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<style scoped></style>
|