fix: 修复组名称查询组件

This commit is contained in:
xlsea 2024-04-23 09:23:11 +08:00
parent dffa22e4a1
commit 8ac203b885
3 changed files with 30 additions and 14 deletions

View File

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

View File

@ -61,7 +61,7 @@ function search() {
<!-- @update:value="handleGroupNameUpdate"-->
<!-- />-->
<SelectGroup v-model:value="model.groupName" />
<SelectGroup v-model="model.groupName" />
</NFormItemGi>
<NFormItemGi span="24 s:12 m:6" :label="$t('page.retryScene.sceneName')" path="userName" class="pr-24px">
<!-- <NSelect-->

View File

@ -29,7 +29,7 @@ function search() {
<template>
<SearchForm :model="model" @search="search" @reset="reset">
<NFormItemGi span="24 s:12 m:6" :label="$t('page.workflow.groupName')" path="groupName" class="pr-24px">
<SelectGroup v-model:value="model.groupName" />
<SelectGroup v-model="model.groupName" />
</NFormItemGi>
<NFormItemGi span="24 s:12 m:6" :label="$t('page.workflow.workflowName')" path="workflowName" class="pr-24px">
<NInput v-model:value="model.workflowName" :placeholder="$t('page.workflow.form.workflowName')" />