mirror of
https://gitee.com/nicefold/seewis-soybean-plus.git
synced 2026-10-14 03:52:28 +08:00
51 lines
1.1 KiB
Vue
51 lines
1.1 KiB
Vue
<script setup lang="ts">
|
|
import { ref } from 'vue';
|
|
import { useLoading } from '@sa/hooks';
|
|
import { fetchGetUserSelect } from '@/service/api/system';
|
|
|
|
defineOptions({
|
|
name: 'UserSelect',
|
|
inheritAttrs: false
|
|
});
|
|
|
|
interface Props {
|
|
[key: string]: any;
|
|
}
|
|
|
|
defineProps<Props>();
|
|
|
|
const value = defineModel<CommonType.IdType | null>('value', { required: false });
|
|
|
|
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"
|
|
v-bind="$attrs"
|
|
placeholder="请选择用户"
|
|
/>
|
|
</template>
|
|
|
|
<style scoped></style>
|