fix: 搭建代码生成页面
Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CI / CI OK (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Element Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Deploy Website on push / Rerun on failure (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Issue Close Require / close-issues (push) Has been cancelled
Close stale issues / stale (push) Has been cancelled

This commit is contained in:
2025-05-12 17:04:27 +08:00
parent bc3b9e1129
commit eb893e44a3
11 changed files with 765 additions and 115 deletions

View File

@@ -0,0 +1,66 @@
import type { VbenFormProps } from '#/adapter/form';
import { getMenuTreeOption } from '#/views/system/menu/api';
export const codeGenerationForm: VbenFormProps = {
wrapperClass: 'grid-cols-12', // 24栅格,
commonConfig: {
formItemClass: 'col-span-12',
// 所有表单项
componentProps: {
class: 'w-full',
},
},
// handleSubmit: onSubmit,
layout: 'horizontal',
schema: [
{
component: 'VbenInput',
componentProps: {
placeholder: '请输入类名',
},
fieldName: 'class_name',
label: '类名',
rules: 'required',
formItemClass: 'col-span-6',
},
{
component: 'VbenInput',
componentProps: {
placeholder: '请输入中文名称',
},
fieldName: 'class_comment',
label: '中文名称',
rules: 'required',
formItemClass: 'col-span-6',
},
{
component: 'InputNumber',
componentProps: {
placeholder: '请输入排序',
},
fieldName: 'sort',
label: '排序',
defaultValue: 9999,
rules: 'required',
formItemClass: 'col-span-6',
},
{
component: 'ApiTreeSelect',
// 对应组件的参数
componentProps: {
childrenField: 'children',
labelField: 'title',
valueField: 'id',
// 菜单接口
api: getMenuTreeOption,
},
defaultValue: 0,
fieldName: 'pid',
label: '父级菜单',
formItemClass: 'col-span-6',
rules: 'required',
},
],
showDefaultActions: false,
};

View File

@@ -0,0 +1,56 @@
import type { VbenFormProps } from '#/adapter/form';
import { getRoleOption } from '#/views/system/role/api';
export const formOptions: VbenFormProps = {
// 默认展开
collapsed: false,
schema: [
{
component: 'VbenInput',
componentProps: {
placeholder: '输入名称',
},
defaultValue: '',
fieldName: 'nick_name',
label: '管理员名称',
},
{
component: 'VbenInput',
componentProps: {
placeholder: '输入手机号码',
},
defaultValue: '',
fieldName: 'phone',
label: '手机号码',
},
{
component: 'ApiSelect',
componentProps: {
allowClear: true,
filterOption: true,
showSearch: true,
// 菜单接口转options格式
afterFetch: (data: { id: number; name: string }[]) => {
return data.map((item: any) => ({
label: item.name,
value: item.id,
}));
},
api: getRoleOption,
placeholder: '请选择',
},
fieldName: 'role_id',
label: '角色',
},
],
// 控制表单是否显示折叠按钮
showCollapseButton: true,
submitButtonOptions: {
content: '查询',
},
// 是否在字段值改变时提交表单
submitOnChange: true,
// 按下回车时是否提交表单
submitOnEnter: false,
};

View File

@@ -0,0 +1,342 @@
import type { VxeGridProps } from '#/adapter/vxe-table';
import filedType from '#/util/json/filedType.json';
import formType from '#/util/json/formType.json';
import { getAdminList } from '#/views/system/admin/api';
interface RowType {
id: string;
nick_name: string;
email: string;
avatar: string;
roles: { name: string }[];
open_id: string;
code: string;
platform_id: string;
phone: string;
desc: string;
created_at: string;
}
export const gridOptions: VxeGridProps<RowType> = {
title: '时间字段由系统生成',
titleHelpMessage:
'创建时间:created_at 编辑时间:updated_at 删除时间:deleted_at',
checkboxConfig: {
highlight: true,
labelField: '',
},
columnConfig: {
useKey: true,
},
rowConfig: {
useKey: true,
},
columns: [
{
title: '字段名称',
tableTitleHelp: '表中字段名称,为英文开头,纯小写 多个单词下划线隔开',
dataIndex: 'name',
editRow: true,
},
{
title: '字段类型',
tableTitleHelp: '表中字段储存类型',
dataIndex: 'type',
editRow: true,
editComponent: 'Select',
editComponentProps: {
options: filedType,
showSearch: true,
},
},
{
title: '字段长度',
tableTitleHelp: '表中字段储存类型长度',
dataIndex: 'type_number',
editRow: true,
width: 100,
},
{
title: '默认值',
tableTitleHelp: '表中字段的默认值',
dataIndex: 'default',
editRow: true,
width: 100,
},
{
title: '备注',
tableTitleHelp: '表中字段备注',
dataIndex: 'comment',
editRow: true,
},
// {
// title: '主键',
// tableTitleHelp: '表中该字段是否为主键',
// dataIndex: 'isKey',
// width: 80,
// editRow: true,
// editComponent: 'Switch',
// editComponentProps: {
// checkedChildren: '是',
// unCheckedChildren: '否',
// size: 'default',
// },
// },
{
title: '非空',
tableTitleHelp: '表中字段是否为必填',
dataIndex: 'null',
width: 80,
editRow: true,
editComponent: 'Switch',
editComponentProps: {
checkedChildren: '是',
unCheckedChildren: '否',
size: 'default',
},
},
{
title: '表单',
tableTitleHelp: '是否在表单中展示该字段',
dataIndex: 'formShow',
width: 80,
editRow: true,
editComponent: 'Switch',
editComponentProps: {
checkedChildren: '是',
unCheckedChildren: '否',
size: 'default',
},
},
{
title: '表格',
tableTitleHelp: '是否在表格中展示该字段',
dataIndex: 'tableShow',
width: 80,
editRow: true,
editComponent: 'Switch',
editComponentProps: {
checkedChildren: '是',
unCheckedChildren: '否',
size: 'default',
},
},
{
title: '搜索',
tableTitleHelp: '是否在表格中搜索该字段',
dataIndex: 'search',
width: 80,
editRow: true,
editComponent: 'Switch',
editComponentProps: {
checkedChildren: '是',
unCheckedChildren: '否',
size: 'default',
},
},
{
title: '搜索方式',
tableTitleHelp: '是否在表格中搜索该字段',
dataIndex: 'searchValue',
editRow: true,
editComponent: 'Select',
editComponentProps: {
options: [
{
label: '绝对查询',
value: '=',
},
{
label: '模糊查询',
value: 'like',
},
],
size: 'default',
},
},
{
title: '表单类型',
tableTitleHelp: '在表单中展示该字段的组件类型 如不在表单中展示则不填',
dataIndex: 'formType',
width: 250,
editRow: true,
editComponent: 'Select',
editComponentProps: {
options: formType,
showSearch: true,
},
},
],
keepSource: true,
pagerConfig: {},
proxyConfig: {
ajax: {
// 请求后端接口方法
query: async ({ page }, formValues) => {
return await getAdminList({
page: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
height: 'auto',
border: false,
toolbarConfig: {
// 是否显示搜索表单控制按钮
// @ts-ignore 正式环境时有完整的类型声明
search: true,
refresh: true, // 刷新
print: false, // 打印
export: false, // 导出
// custom: true, // 自定义列
zoom: true, // 最大化最小化
slots: {
buttons: 'toolbar-buttons',
},
custom: {
// 自定义列-图标
icon: 'vxe-icon-menu',
},
},
showOverflow: false,
};
// const columns: BasicColumn[] = [
// {
// title: '字段名称',
// tableTitleHelp: '表中字段名称,为英文开头,纯小写 多个单词下划线隔开',
// dataIndex: 'name',
// editRow: true,
// },
// {
// title: '字段类型',
// tableTitleHelp: '表中字段储存类型',
// dataIndex: 'type',
// editRow: true,
// editComponent: 'Select',
// editComponentProps: {
// options: filedType,
// showSearch: true,
// },
// },
// {
// title: '字段长度',
// tableTitleHelp: '表中字段储存类型长度',
// dataIndex: 'type_number',
// editRow: true,
// width: 100,
// },
// {
// title: '默认值',
// tableTitleHelp: '表中字段的默认值',
// dataIndex: 'default',
// editRow: true,
// width: 100,
// },
// {
// title: '备注',
// tableTitleHelp: '表中字段备注',
// dataIndex: 'comment',
// editRow: true,
// },
// // {
// // title: '主键',
// // tableTitleHelp: '表中该字段是否为主键',
// // dataIndex: 'isKey',
// // width: 80,
// // editRow: true,
// // editComponent: 'Switch',
// // editComponentProps: {
// // checkedChildren: '是',
// // unCheckedChildren: '否',
// // size: 'default',
// // },
// // },
// {
// title: '非空',
// tableTitleHelp: '表中字段是否为必填',
// dataIndex: 'null',
// width: 80,
// editRow: true,
// editComponent: 'Switch',
// editComponentProps: {
// checkedChildren: '是',
// unCheckedChildren: '否',
// size: 'default',
// },
// },
// {
// title: '表单',
// tableTitleHelp: '是否在表单中展示该字段',
// dataIndex: 'formShow',
// width: 80,
// editRow: true,
// editComponent: 'Switch',
// editComponentProps: {
// checkedChildren: '是',
// unCheckedChildren: '否',
// size: 'default',
// },
// },
// {
// title: '表格',
// tableTitleHelp: '是否在表格中展示该字段',
// dataIndex: 'tableShow',
// width: 80,
// editRow: true,
// editComponent: 'Switch',
// editComponentProps: {
// checkedChildren: '是',
// unCheckedChildren: '否',
// size: 'default',
// },
// },
// {
// title: '搜索',
// tableTitleHelp: '是否在表格中搜索该字段',
// dataIndex: 'search',
// width: 80,
// editRow: true,
// editComponent: 'Switch',
// editComponentProps: {
// checkedChildren: '是',
// unCheckedChildren: '否',
// size: 'default',
// },
// },
// {
// title: '搜索方式',
// tableTitleHelp: '是否在表格中搜索该字段',
// dataIndex: 'searchValue',
// editRow: true,
// editComponent: 'Select',
// editComponentProps: {
// options: [
// {
// label: '绝对查询',
// value: '=',
// },
// {
// label: '模糊查询',
// value: 'like',
// },
// ],
// size: 'default',
// },
// },
// {
// title: '表单类型',
// tableTitleHelp: '在表单中展示该字段的组件类型 如不在表单中展示则不填',
// dataIndex: 'formType',
// width: 250,
// editRow: true,
// editComponent: 'Select',
// editComponentProps: {
// options: formType,
// showSearch: true,
// },
// },
// ];