2025-05-10 17:58:33 +08:00
|
|
|
<script setup lang="ts">
|
2026-03-31 14:26:51 +08:00
|
|
|
import { ref } from 'vue';
|
2025-05-10 17:58:33 +08:00
|
|
|
import { useLoading } from '@sa/hooks';
|
|
|
|
|
import { fetchGetUserSelect } from '@/service/api/system';
|
|
|
|
|
|
|
|
|
|
defineOptions({
|
2026-03-31 14:26:51 +08:00
|
|
|
name: 'UserSelect',
|
|
|
|
|
inheritAttrs: false
|
2025-05-10 17:58:33 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
|
[key: string]: any;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
defineProps<Props>();
|
|
|
|
|
|
2025-05-10 19:32:20 +08:00
|
|
|
const value = defineModel<CommonType.IdType | null>('value', { required: false });
|
2025-05-10 17:58:33 +08:00
|
|
|
|
|
|
|
|
const { loading: userLoading, startLoading: startUserLoading, endLoading: endUserLoading } = useLoading();
|
|
|
|
|
|
|
|
|
|
/** the enabled role options */
|
|
|
|
|
const userOptions = ref<CommonType.Option<CommonType.IdType>[]>([]);
|
|
|
|
|
|
|
|
|
|
async function getUserOptions() {
|
|
|
|
|
startUserLoading();
|
|
|
|
|
const { error, data } = await fetchGetUserSelect();
|
|
|
|
|
|
|
|
|
|
if (!error) {
|
|
|
|
|
userOptions.value = data.map(item => ({
|
|
|
|
|
label: `${item.nickName} ( ${item.userName} )`,
|
|
|
|
|
value: item.userId
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
endUserLoading();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getUserOptions();
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<NSelect
|
|
|
|
|
v-model:value="value"
|
|
|
|
|
:loading="userLoading"
|
|
|
|
|
:options="userOptions"
|
2026-03-31 14:26:51 +08:00
|
|
|
v-bind="$attrs"
|
2025-05-10 17:58:33 +08:00
|
|
|
placeholder="请选择用户"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped></style>
|