表单优化

This commit is contained in:
Xubx 2025-03-04 14:32:56 +08:00
parent 34f7309717
commit 0e890d96c5
5 changed files with 411 additions and 363 deletions

View File

@ -5,27 +5,17 @@ import { render } from '/@/utils/common/renderUtils';
//列表数据 //列表数据
export const columns: BasicColumn[] = [ export const columns: BasicColumn[] = [
{ {
title: '用户id', title: '姓名',
align: 'center',
dataIndex: 'userId',
},
{
title: '用户名',
align: 'center', align: 'center',
dataIndex: 'userName', dataIndex: 'userName',
}, },
{ {
title: '专业id,0表示未选择', title: '用户ID',
align: 'center', align: 'center',
dataIndex: 'majorId', dataIndex: 'userId',
}, },
{ {
title: '用户专业id', title: '工号',
align: 'center',
dataIndex: 'userMajorId',
},
{
title: '用户专业id',
align: 'center', align: 'center',
dataIndex: 'teacherId', dataIndex: 'teacherId',
}, },
@ -35,20 +25,33 @@ export const columns: BasicColumn[] = [
dataIndex: 'phone', dataIndex: 'phone',
}, },
{ {
title: '组id', title: '学科',
align: 'center',
dataIndex: 'majorId',
},
{
title: '所属分组',
align: 'center', align: 'center',
dataIndex: 'groupId', dataIndex: 'groupId',
}, },
{ {
title: '使用次数', title: '是否第一次阅卷',
align: 'center',
dataIndex: 'numberuse',
},
{
title: '状态',
align: 'center', align: 'center',
dataIndex: 'status', dataIndex: 'status',
}, },
//{
// title: '用户专业id',
// align: 'center',
// dataIndex: 'userMajorId',
//},
//{
// title: '使用次数',
// align: 'center',
// dataIndex: 'numberuse',
//},
]; ];
//查询数据 //查询数据
export const searchFormSchema: FormSchema[] = [ export const searchFormSchema: FormSchema[] = [
@ -78,11 +81,11 @@ export const formSchema: FormSchema[] = [
}, },
}, },
{ {
label: '专业id,0表示未选择', label: '学科',
field: 'majorId', field: 'majorId',
component: 'InputNumber', component: 'InputNumber',
dynamicRules: ({ model, schema }) => { dynamicRules: ({ model, schema }) => {
return [{ required: true, message: '请输入专业id,0表示未选择!' }]; return [{ required: true, message: '请输入学科!' }];
}, },
}, },
{ {
@ -94,11 +97,11 @@ export const formSchema: FormSchema[] = [
}, },
}, },
{ {
label: '用户专业id', label: '工号',
field: 'teacherId', field: 'teacherId',
component: 'Input', component: 'Input',
dynamicRules: ({ model, schema }) => { dynamicRules: ({ model, schema }) => {
return [{ required: true, message: '请输入用户专业id!' }]; return [{ required: true, message: '请输入工号!' }];
}, },
}, },
{ {
@ -110,11 +113,11 @@ export const formSchema: FormSchema[] = [
}, },
}, },
{ {
label: 'id', label: '所属分组',
field: 'groupId', field: 'groupId',
component: 'InputNumber', component: 'InputNumber',
dynamicRules: ({ model, schema }) => { dynamicRules: ({ model, schema }) => {
return [{ required: true, message: '请输入id!' }]; return [{ required: true, message: '请输入所属分组!' }];
}, },
}, },
{ {
@ -126,17 +129,17 @@ export const formSchema: FormSchema[] = [
}, },
}, },
{ {
label: '状态', label: '是否第一次阅卷',
field: 'status', field: 'status',
component: 'RadioGroup', component: 'RadioGroup',
componentProps: { componentProps: {
options: [ options: [
{ label: '正常', value: 0 }, { label: '', value: 0 },
{ label: '禁用', value: 1 }, { label: '', value: 1 },
], ],
}, },
dynamicRules: ({ model, schema }) => { dynamicRules: ({ model, schema }) => {
return [{ required: true, message: '请选择状态' }]; return [{ required: true, message: '请选择是否第一次阅卷' }];
}, },
}, },
// TODO 主键隐藏字段目前写死为ID // TODO 主键隐藏字段目前写死为ID
@ -152,11 +155,11 @@ export const formSchema: FormSchema[] = [
export const superQuerySchema = { export const superQuerySchema = {
userId: { title: '用户id', order: 0, view: 'text', type: 'string' }, userId: { title: '用户id', order: 0, view: 'text', type: 'string' },
userName: { title: '用户名', order: 1, view: 'text', type: 'string' }, userName: { title: '用户名', order: 1, view: 'text', type: 'string' },
majorId: { title: '专业id,0表示未选择', order: 2, view: 'number', type: 'number' }, majorId: { title: '学科', order: 2, view: 'number', type: 'number' },
userMajorId: { title: '用户专业id', order: 3, view: 'text', type: 'string' }, userMajorId: { title: '用户专业id', order: 3, view: 'text', type: 'string' },
teacherId: { title: '用户专业id', order: 4, view: 'text', type: 'string' }, teacherId: { title: '用户专业id', order: 4, view: 'text', type: 'string' },
phone: { title: '手机号', order: 5, view: 'text', type: 'string' }, phone: { title: '手机号', order: 5, view: 'text', type: 'string' },
groupId: { title: 'id', order: 6, view: 'number', type: 'number' }, groupId: { title: '所属分组', order: 6, view: 'number', type: 'number' },
numberuse: { title: '使用次数', order: 7, view: 'number', type: 'number' }, numberuse: { title: '使用次数', order: 7, view: 'number', type: 'number' },
status: { title: '状态0正常 1禁用', order: 8, view: 'number', type: 'number' }, status: { title: '状态0正常 1禁用', order: 8, view: 'number', type: 'number' },
}; };

View File

@ -16,8 +16,7 @@
</a-menu-item> </a-menu-item>
</a-menu> </a-menu>
</template> </template>
<a-button <a-button>批量操作
>批量操作
<Icon icon="mdi:chevron-down" /> <Icon icon="mdi:chevron-down" />
</a-button> </a-button>
</a-dropdown> </a-dropdown>
@ -31,8 +30,8 @@
<!--字段回显插槽--> <!--字段回显插槽-->
<template #bodyCell="{ column, record, index, text }"> <template #bodyCell="{ column, record, index, text }">
<span v-if="column.dataIndex === 'status'"> <span v-if="column.dataIndex === 'status'">
<a-tag v-if="record.status === 0" color="green">正常</a-tag> <a-tag v-if="record.status === 0" color="green"></a-tag>
<a-tag v-else-if="record.status !== 0" color="red">禁用</a-tag> <a-tag v-else-if="record.status !== 0" color="red"></a-tag>
</span> </span>
</template> </template>
</BasicTable> </BasicTable>

View File

@ -5,25 +5,30 @@ import { render } from '/@/utils/common/renderUtils';
//列表数据 //列表数据
export const columns: BasicColumn[] = [ export const columns: BasicColumn[] = [
{ {
title: '用户id', title: '姓名',
align: 'center',
dataIndex: 'userName',
},
{
title: '用户ID',
align: 'center', align: 'center',
dataIndex: 'userId', dataIndex: 'userId',
}, },
{ {
title: '专业id', title: '年龄',
align: 'center',
dataIndex: 'age',
},
{
title: '性别',
align: 'center',
dataIndex: 'sex',
},
{
title: '学科',
align: 'center', align: 'center',
dataIndex: 'majorId', dataIndex: 'majorId',
}, },
{
title: '用户专业id',
align: 'center',
dataIndex: 'userMajorId',
},
{
title: '用户名',
align: 'center',
dataIndex: 'userName',
},
{ {
title: '手机号', title: '手机号',
align: 'center', align: 'center',
@ -34,6 +39,27 @@ export const columns: BasicColumn[] = [
align: 'center', align: 'center',
dataIndex: 'jobTitle', dataIndex: 'jobTitle',
}, },
{
title: '职务',
align: 'center',
dataIndex: 'office',
},
{
title: '所属分组',
align: 'center',
dataIndex: 'groupId',
},
{
title: '住宿信息',
align: 'center',
dataIndex: 'dormitory',
},
{
title: '用户专业id',
align: 'center',
dataIndex: 'userMajorId',
},
{ {
title: '银行卡号', title: '银行卡号',
align: 'center', align: 'center',
@ -44,11 +70,7 @@ export const columns: BasicColumn[] = [
align: 'center', align: 'center',
dataIndex: 'mealCard', dataIndex: 'mealCard',
}, },
{
title: '办公位',
align: 'center',
dataIndex: 'office',
},
{ {
title: '工作名称', title: '工作名称',
align: 'center', align: 'center',
@ -69,26 +91,11 @@ export const columns: BasicColumn[] = [
align: 'center', align: 'center',
dataIndex: 'carNumber', dataIndex: 'carNumber',
}, },
{
title: '性别',
align: 'center',
dataIndex: 'sex',
},
{
title: '年龄',
align: 'center',
dataIndex: 'age',
},
{ {
title: '车辆是否入校', title: '车辆是否入校',
align: 'center', align: 'center',
dataIndex: 'carStatus', dataIndex: 'carStatus',
}, },
{
title: '宿舍信息',
align: 'center',
dataIndex: 'dormitory',
},
{ {
title: '是否住宿', title: '是否住宿',
align: 'center', align: 'center',
@ -104,11 +111,6 @@ export const columns: BasicColumn[] = [
align: 'center', align: 'center',
dataIndex: 'bankName', dataIndex: 'bankName',
}, },
{
title: '组id',
align: 'center',
dataIndex: 'groupId',
},
{ {
title: '使用次数', title: '使用次数',
align: 'center', align: 'center',
@ -123,13 +125,13 @@ export const columns: BasicColumn[] = [
//查询数据 //查询数据
export const searchFormSchema: FormSchema[] = [ export const searchFormSchema: FormSchema[] = [
{ {
label: '专业id', label: '学科',
field: 'majorId', field: 'majorId',
component: 'JRangeNumber', component: 'JRangeNumber',
//colProps: {span: 6}, //colProps: {span: 6},
}, },
{ {
label: '用户名', label: '名',
field: 'userName', field: 'userName',
component: 'Input', component: 'Input',
//colProps: {span: 6}, //colProps: {span: 6},
@ -138,15 +140,15 @@ export const searchFormSchema: FormSchema[] = [
//表单数据 //表单数据
export const formSchema: FormSchema[] = [ export const formSchema: FormSchema[] = [
{ {
label: '用户id', label: '用户ID',
field: 'userId', field: 'userId',
component: 'Input', component: 'Input',
dynamicRules: ({ model, schema }) => { dynamicRules: ({ model, schema }) => {
return [{ required: true, message: '请输入用户id!' }]; return [{ required: true, message: '请输入用户ID!' }];
}, },
}, },
{ {
label: '专业id', label: '学科',
field: 'majorId', field: 'majorId',
component: 'InputNumber', component: 'InputNumber',
dynamicRules: ({ model, schema }) => { dynamicRules: ({ model, schema }) => {
@ -162,11 +164,11 @@ export const formSchema: FormSchema[] = [
}, },
}, },
{ {
label: '用户名', label: '名',
field: 'userName', field: 'userName',
component: 'Input', component: 'Input',
dynamicRules: ({ model, schema }) => { dynamicRules: ({ model, schema }) => {
return [{ required: true, message: '请输入用户名!' }]; return [{ required: true, message: '请输入名!' }];
}, },
}, },
{ {
@ -202,7 +204,7 @@ export const formSchema: FormSchema[] = [
}, },
}, },
{ {
label: '办公位', label: '职务',
field: 'office', field: 'office',
component: 'Input', component: 'Input',
dynamicRules: ({ model, schema }) => { dynamicRules: ({ model, schema }) => {
@ -272,7 +274,7 @@ export const formSchema: FormSchema[] = [
}, },
}, },
{ {
label: '宿信息', label: '宿信息',
field: 'dormitory', field: 'dormitory',
component: 'Input', component: 'Input',
dynamicRules: ({ model, schema }) => { dynamicRules: ({ model, schema }) => {
@ -310,7 +312,7 @@ export const formSchema: FormSchema[] = [
}, },
}, },
{ {
label: 'id', label: '所属分组',
field: 'groupId', field: 'groupId',
component: 'InputNumber', component: 'InputNumber',
dynamicRules: ({ model, schema }) => { dynamicRules: ({ model, schema }) => {
@ -350,15 +352,15 @@ export const formSchema: FormSchema[] = [
// 高级查询数据 // 高级查询数据
export const superQuerySchema = { export const superQuerySchema = {
userId: { title: '用户id', order: 0, view: 'text', type: 'string' }, userId: { title: '用户ID', order: 0, view: 'text', type: 'string' },
majorId: { title: '专业id', order: 1, view: 'number', type: 'number' }, majorId: { title: '学科', order: 1, view: 'number', type: 'number' },
userMajorId: { title: '用户专业id', order: 2, view: 'text', type: 'string' }, userMajorId: { title: '用户专业id', order: 2, view: 'text', type: 'string' },
userName: { title: '用户名', order: 3, view: 'text', type: 'string' }, userName: { title: '名', order: 3, view: 'text', type: 'string' },
phone: { title: '手机号', order: 4, view: 'text', type: 'string' }, phone: { title: '手机号', order: 4, view: 'text', type: 'string' },
jobTitle: { title: '职称', order: 5, view: 'text', type: 'string' }, jobTitle: { title: '职称', order: 5, view: 'text', type: 'string' },
pyCard: { title: '银行卡号', order: 6, view: 'text', type: 'string' }, pyCard: { title: '银行卡号', order: 6, view: 'text', type: 'string' },
mealCard: { title: '饭卡', order: 7, view: 'text', type: 'string' }, mealCard: { title: '饭卡', order: 7, view: 'text', type: 'string' },
office: { title: '办公位', order: 8, view: 'text', type: 'string' }, office: { title: '职务', order: 8, view: 'text', type: 'string' },
workName: { title: '工作名称', order: 9, view: 'text', type: 'string' }, workName: { title: '工作名称', order: 9, view: 'text', type: 'string' },
workPhone: { title: '固定电话', order: 10, view: 'text', type: 'string' }, workPhone: { title: '固定电话', order: 10, view: 'text', type: 'string' },
identityId: { title: '身份证', order: 11, view: 'text', type: 'string' }, identityId: { title: '身份证', order: 11, view: 'text', type: 'string' },
@ -366,11 +368,11 @@ export const superQuerySchema = {
sex: { title: '性别', order: 13, view: 'text', type: 'string' }, sex: { title: '性别', order: 13, view: 'text', type: 'string' },
age: { title: '年龄', order: 14, view: 'number', type: 'number' }, age: { title: '年龄', order: 14, view: 'number', type: 'number' },
carStatus: { title: '车辆是否入校', order: 15, view: 'number', type: 'number' }, carStatus: { title: '车辆是否入校', order: 15, view: 'number', type: 'number' },
dormitory: { title: '宿信息', order: 16, view: 'text', type: 'string' }, dormitory: { title: '宿信息', order: 16, view: 'text', type: 'string' },
dormitoryStatus: { title: '是否住宿', order: 17, view: 'text', type: 'string' }, dormitoryStatus: { title: '是否住宿', order: 17, view: 'text', type: 'string' },
bankAddress: { title: '开户所在地', order: 18, view: 'text', type: 'string' }, bankAddress: { title: '开户所在地', order: 18, view: 'text', type: 'string' },
bankName: { title: '开户行', order: 19, view: 'text', type: 'string' }, bankName: { title: '开户行', order: 19, view: 'text', type: 'string' },
groupId: { title: 'id', order: 20, view: 'number', type: 'number' }, groupId: { title: '所属分组', order: 20, view: 'number', type: 'number' },
numberuse: { title: '使用次数', order: 21, view: 'number', type: 'number' }, numberuse: { title: '使用次数', order: 21, view: 'number', type: 'number' },
status: { title: '状态0已报道 1未报到', order: 22, view: 'number', type: 'number' }, status: { title: '状态0已报道 1未报到', order: 22, view: 'number', type: 'number' },
}; };

View File

@ -1,7 +1,8 @@
<template> <template>
<div> <div>
<!--引用表格--> <!--引用表格-->
<BasicTable @register="registerTable" :rowSelection="rowSelection"> <BasicTable @register="registerTable" :rowSelection="rowSelection" :expanded-row-keys="expandedRowKeys"
:expandable="expandable" @expanded-rows-change="handleExpand">
<!--插槽:table标题--> <!--插槽:table标题-->
<template #tableTitle> <template #tableTitle>
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button> <a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
@ -16,14 +17,41 @@
</a-menu-item> </a-menu-item>
</a-menu> </a-menu>
</template> </template>
<a-button <a-button>批量操作
>批量操作
<Icon icon="mdi:chevron-down" /> <Icon icon="mdi:chevron-down" />
</a-button> </a-button>
</a-dropdown> </a-dropdown>
<!-- 高级查询 --> <!-- 高级查询 -->
<super-query :config="superQueryConfig" @search="handleSuperQuery" /> <super-query :config="superQueryConfig" @search="handleSuperQuery" />
</template> </template>
<template #expand="{ record }">
<a-descriptions bordered :column="2">
<a-descriptions-item label="身份证号">
{{ record.identityId }}
</a-descriptions-item>
<a-descriptions-item label="银行卡号">
{{ record.pyCard }}
</a-descriptions-item>
<a-descriptions-item label="工作单位">
{{ record.workName }}
</a-descriptions-item>
<a-descriptions-item label="开户所在地">
{{ record.bankAddress }}
</a-descriptions-item>
<a-descriptions-item label="单位电话">
{{ record.workPhone }}
</a-descriptions-item>
<a-descriptions-item label="开户行">
{{ record.bankName }}
</a-descriptions-item>
<a-descriptions-item label="车牌号">
{{ record.carNumber }}
</a-descriptions-item>
<a-descriptions-item label="饭卡号">
{{ record.mealCard }}
</a-descriptions-item>
</a-descriptions>
</template>
<!--操作栏--> <!--操作栏-->
<template #action="{ record }"> <template #action="{ record }">
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" /> <TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
@ -101,7 +129,23 @@
success: handleSuccess, success: handleSuccess,
}, },
}); });
//
const expandedRowKeys = ref<string[]>(["0"]);
const expandable = {
expandedRowKeys,
expandedRowRender: (record) => (
1111
),
};
//
const handleExpand = (expanded, record) => {
console.log(expanded, record, 'expand');
if (expanded) {
expandedRowKeys.value = [record.id]; //
} else {
expandedRowKeys.value = []; //
}
};
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext; const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
// //