feat(sj_1.0.0_beta4): SelectGroup 支持 :disabled 属性, 删除多余代码
This commit is contained in:
parent
e1aef477cb
commit
0ff686e27d
@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue';
|
||||
import { ref } from 'vue';
|
||||
import { $t } from '@/locales';
|
||||
import { translateOptions2 } from '@/utils/common';
|
||||
import { fetchGetAllGroupNameList } from '@/service/api';
|
||||
@ -8,16 +8,22 @@ defineOptions({
|
||||
name: 'SelectGroup'
|
||||
});
|
||||
|
||||
interface Props {
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
disabled: false
|
||||
});
|
||||
|
||||
const model = defineModel<string | null>();
|
||||
interface Emits {
|
||||
(e: 'update:modelValue', value: string): void;
|
||||
}
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
/** 组列表 */
|
||||
/** 可选组列表 */
|
||||
const groupNameList = ref<string[]>([]);
|
||||
/** 组列表 */
|
||||
const groupName = ref<string>();
|
||||
|
||||
async function getGroupNameList() {
|
||||
const { data, error } = await fetchGetAllGroupNameList();
|
||||
@ -26,26 +32,19 @@ async function getGroupNameList() {
|
||||
}
|
||||
}
|
||||
|
||||
getGroupNameList();
|
||||
|
||||
watch(
|
||||
() => model,
|
||||
() => {
|
||||
groupName.value = model.value!;
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
const handleUpdate = (value: string) => {
|
||||
emit('update:modelValue', value);
|
||||
};
|
||||
|
||||
getGroupNameList();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NSelect
|
||||
v-model:value="groupName"
|
||||
v-model:value="model"
|
||||
:placeholder="$t('page.retryTask.form.groupName')"
|
||||
:options="translateOptions2(groupNameList)"
|
||||
:disabled="props.disabled"
|
||||
clearable
|
||||
filterable
|
||||
@update:value="handleUpdate"
|
||||
|
Loading…
Reference in New Issue
Block a user