mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
feat: 新增测试单表页面
This commit is contained in:
52
src/components/custom/user-select.vue
Normal file
52
src/components/custom/user-select.vue
Normal file
@ -0,0 +1,52 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, useAttrs } from 'vue';
|
||||
import type { SelectProps } from 'naive-ui';
|
||||
import { useLoading } from '@sa/hooks';
|
||||
import { fetchGetUserSelect } from '@/service/api/system';
|
||||
|
||||
defineOptions({
|
||||
name: 'UserSelect'
|
||||
});
|
||||
|
||||
interface Props {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
defineProps<Props>();
|
||||
|
||||
const value = defineModel<CommonType.IdType[] | null>('value', { required: false });
|
||||
|
||||
const attrs: SelectProps = useAttrs();
|
||||
|
||||
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>
|
Reference in New Issue
Block a user