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">
|
<script setup lang="ts">
|
||||||
import { ref, watch } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { $t } from '@/locales';
|
import { $t } from '@/locales';
|
||||||
import { translateOptions2 } from '@/utils/common';
|
import { translateOptions2 } from '@/utils/common';
|
||||||
import { fetchGetAllGroupNameList } from '@/service/api';
|
import { fetchGetAllGroupNameList } from '@/service/api';
|
||||||
@ -8,16 +8,22 @@ defineOptions({
|
|||||||
name: 'SelectGroup'
|
name: 'SelectGroup'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
disabled?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
|
disabled: false
|
||||||
|
});
|
||||||
|
|
||||||
const model = defineModel<string | null>();
|
const model = defineModel<string | null>();
|
||||||
interface Emits {
|
interface Emits {
|
||||||
(e: 'update:modelValue', value: string): void;
|
(e: 'update:modelValue', value: string): void;
|
||||||
}
|
}
|
||||||
const emit = defineEmits<Emits>();
|
const emit = defineEmits<Emits>();
|
||||||
|
|
||||||
/** 组列表 */
|
/** 可选组列表 */
|
||||||
const groupNameList = ref<string[]>([]);
|
const groupNameList = ref<string[]>([]);
|
||||||
/** 组列表 */
|
|
||||||
const groupName = ref<string>();
|
|
||||||
|
|
||||||
async function getGroupNameList() {
|
async function getGroupNameList() {
|
||||||
const { data, error } = await fetchGetAllGroupNameList();
|
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) => {
|
const handleUpdate = (value: string) => {
|
||||||
emit('update:modelValue', value);
|
emit('update:modelValue', value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
getGroupNameList();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<NSelect
|
<NSelect
|
||||||
v-model:value="groupName"
|
v-model:value="model"
|
||||||
:placeholder="$t('page.retryTask.form.groupName')"
|
:placeholder="$t('page.retryTask.form.groupName')"
|
||||||
:options="translateOptions2(groupNameList)"
|
:options="translateOptions2(groupNameList)"
|
||||||
|
:disabled="props.disabled"
|
||||||
clearable
|
clearable
|
||||||
filterable
|
filterable
|
||||||
@update:value="handleUpdate"
|
@update:value="handleUpdate"
|
||||||
|
Loading…
Reference in New Issue
Block a user