feat: 新增测试单表页面

This commit is contained in:
xlsea
2025-05-10 17:58:33 +08:00
parent 1a351c1c88
commit 4a4febeeab
18 changed files with 740 additions and 2 deletions

View File

@ -0,0 +1,46 @@
<script setup lang="tsx">
import { useAttrs } from 'vue';
import type { TreeSelectProps } from 'naive-ui';
import { useLoading } from '@sa/hooks';
import { fetchGetDeptSelect } from '@/service/api/system';
defineOptions({ name: 'DeptTreeSelect' });
interface Props {
[key: string]: any;
}
defineProps<Props>();
const value = defineModel<CommonType.IdType | null>('value', { required: false });
const options = defineModel<Api.System.Dept[]>('options', { required: false, default: [] });
const attrs: TreeSelectProps = useAttrs();
const { loading, startLoading, endLoading } = useLoading();
async function getDeptList() {
startLoading();
const { error, data } = await fetchGetDeptSelect();
if (error) return;
options.value = data;
endLoading();
}
getDeptList();
</script>
<template>
<NTreeSelect
v-model:value="value"
filterable
class="h-full"
:loading="loading"
key-field="deptId"
label-field="deptName"
:options="options"
:default-expanded-keys="[0]"
v-bind="attrs"
/>
</template>
<style scoped></style>

View 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>