diff --git a/apps/web-antd/src/api/infra/codegen/index.ts b/apps/web-antd/src/api/infra/codegen/index.ts index e621a2460..6f3969fb0 100644 --- a/apps/web-antd/src/api/infra/codegen/index.ts +++ b/apps/web-antd/src/api/infra/codegen/index.ts @@ -65,13 +65,13 @@ export namespace InfraCodegenApi { } /** 更新代码生成请求 */ - export interface CodegenUpdateReq { + export interface CodegenUpdateReqVO { table: any | CodegenTable; columns: CodegenColumn[]; } /** 创建代码生成请求 */ - export interface CodegenCreateListReq { + export interface CodegenCreateListReqVO { dataSourceConfigId?: number; tableNames: string[]; } @@ -79,7 +79,7 @@ export namespace InfraCodegenApi { /** 查询列表代码生成表定义 */ export function getCodegenTableList(dataSourceConfigId: number) { - return requestClient.get('/infra/codegen/table/list', { + return requestClient.get('/infra/codegen/table/list?', { params: { dataSourceConfigId }, }); } @@ -90,40 +90,35 @@ export function getCodegenTablePage(params: PageParam) { } /** 查询详情代码生成表定义 */ -export function getCodegenTable(id: number) { +export function getCodegenTable(tableId: number) { return requestClient.get('/infra/codegen/detail', { - params: { tableId: id }, + params: { tableId }, }); } -/** 新增代码生成表定义 */ -export function createCodegenTable(data: InfraCodegenApi.CodegenCreateListReq) { - return requestClient.post('/infra/codegen/create', data); -} - /** 修改代码生成表定义 */ -export function updateCodegenTable(data: InfraCodegenApi.CodegenUpdateReq) { +export function updateCodegenTable(data: InfraCodegenApi.CodegenUpdateReqVO) { return requestClient.put('/infra/codegen/update', data); } /** 基于数据库的表结构,同步数据库的表和字段定义 */ -export function syncCodegenFromDB(id: number) { +export function syncCodegenFromDB(tableId: number) { return requestClient.put('/infra/codegen/sync-from-db', { - params: { tableId: id }, + params: { tableId }, }); } /** 预览生成代码 */ -export function previewCodegen(id: number) { +export function previewCodegen(tableId: number) { return requestClient.get('/infra/codegen/preview', { - params: { tableId: id }, + params: { tableId }, }); } /** 下载生成代码 */ -export function downloadCodegen(id: number) { +export function downloadCodegen(tableId: number) { return requestClient.download('/infra/codegen/download', { - params: { tableId: id }, + params: { tableId }, }); } @@ -133,13 +128,13 @@ export function getSchemaTableList(params: any) { } /** 基于数据库的表结构,创建代码生成器的表定义 */ -export function createCodegenList(data: InfraCodegenApi.CodegenCreateListReq) { +export function createCodegenList(data: InfraCodegenApi.CodegenCreateListReqVO) { return requestClient.post('/infra/codegen/create-list', data); } /** 删除代码生成表定义 */ -export function deleteCodegenTable(id: number) { +export function deleteCodegenTable(tableId: number) { return requestClient.delete('/infra/codegen/delete', { - params: { tableId: id }, + params: { tableId }, }); } diff --git a/apps/web-antd/src/utils/date.ts b/apps/web-antd/src/utils/date.ts index d0230319c..9c8be81b4 100644 --- a/apps/web-antd/src/utils/date.ts +++ b/apps/web-antd/src/utils/date.ts @@ -7,24 +7,20 @@ export function getRangePickerDefaultProps() { return { showTime: { format: 'HH:mm:ss', - defaultValue: [ - dayjs('00:00:00', 'HH:mm:ss'), - dayjs('23:59:59', 'HH:mm:ss'), - ], + defaultValue: [dayjs('00:00:00', 'HH:mm:ss'), dayjs('23:59:59', 'HH:mm:ss')], }, valueFormat: 'YYYY-MM-DD HH:mm:ss', format: 'YYYY-MM-DD HH:mm:ss', placeholder: ['开始时间', '结束时间'], // prettier-ignore ranges: { - '今天': [dayjs().startOf('day'), dayjs().endOf('day')], - '昨天': [dayjs().subtract(1, 'day').startOf('day'), - dayjs().subtract(1, 'day').endOf('day')], - '本周': [dayjs().startOf('week'), dayjs().endOf('day')], - '本月': [dayjs().startOf('month'), dayjs().endOf('day')], - '最近 7 天': [dayjs().subtract(7, 'day').startOf('day'), dayjs().endOf('day')], - '最近 30 天': [dayjs().subtract(30, 'day').startOf('day'), dayjs().endOf('day')], - }, + '今天': [dayjs().startOf('day'), dayjs().endOf('day')], + '昨天': [dayjs().subtract(1, 'day').startOf('day'), dayjs().subtract(1, 'day').endOf('day')], + '本周': [dayjs().startOf('week'), dayjs().endOf('day')], + '本月': [dayjs().startOf('month'), dayjs().endOf('day')], + '最近 7 天': [dayjs().subtract(7, 'day').startOf('day'), dayjs().endOf('day')], + '最近 30 天': [dayjs().subtract(30, 'day').startOf('day'), dayjs().endOf('day')], + }, transformDateFunc: (dates: any) => { if (dates && dates.length === 2) { return [dates.createTime[0], dates.createTime[1]].join(','); // 格式化为后台支持的时间格式 diff --git a/apps/web-antd/src/utils/validator.ts b/apps/web-antd/src/utils/validator.ts new file mode 100644 index 000000000..b9cbf2989 --- /dev/null +++ b/apps/web-antd/src/utils/validator.ts @@ -0,0 +1,18 @@ +// 参数校验,对标 Hutool 的 Validator 工具类 + +/** 手机号正则表达式(中国) */ +const MOBILE_REGEX = /(?:0|86|\+86)?1[3-9]\d{9}/; + +/** + * 验证是否为手机号码(中国) + * + * @param value 值 + * @returns 是否为手机号码(中国) + */ +export function isMobile(value?: string | null): boolean { + if (!value) { + return false; + } + return MOBILE_REGEX.test(value); +} + diff --git a/apps/web-antd/src/views/infra/codegen/data.ts b/apps/web-antd/src/views/infra/codegen/data.ts index 2f8536898..3952aee81 100644 --- a/apps/web-antd/src/views/infra/codegen/data.ts +++ b/apps/web-antd/src/views/infra/codegen/data.ts @@ -27,6 +27,7 @@ export function useImportTableFormSchema( { fieldName: 'dataSourceConfigId', label: '数据源', + // TODO @puhui999:不确定使用 ApiSelect 的话,使用 afterEach,可以设置默认 defaultValue 不 component: 'Select', componentProps: { options: dataSourceConfigList.map((item) => ({ @@ -76,7 +77,7 @@ export function useBasicInfoFormSchema(): VbenFormSchema[] { label: '表描述', component: 'Input', componentProps: { - placeholder: '请输入', + placeholder: '请输入表描述', }, rules: 'required', }, @@ -85,7 +86,7 @@ export function useBasicInfoFormSchema(): VbenFormSchema[] { label: '实体类名称', component: 'Input', componentProps: { - placeholder: '请输入', + placeholder: '请输入实体类名称', }, rules: 'required', help: '默认去除表名的前缀。如果存在重复,则需要手动添加前缀,避免 MyBatis 报 Alias 重复的问题。', @@ -95,7 +96,7 @@ export function useBasicInfoFormSchema(): VbenFormSchema[] { label: '作者', component: 'Input', componentProps: { - placeholder: '请输入', + placeholder: '请输入作者', }, rules: 'required', }, @@ -105,8 +106,8 @@ export function useBasicInfoFormSchema(): VbenFormSchema[] { component: 'Textarea', componentProps: { rows: 3, + placeholder: '请输入备注', }, - // 使用 Tailwind 的 col-span-2 让元素跨越两列 formItemClass: 'md:col-span-2', }, ]; @@ -120,8 +121,8 @@ export function useGenerationInfoBaseFormSchema(): VbenFormSchema[] { fieldName: 'templateType', label: '生成模板', componentProps: { - class: 'w-full', options: getDictOptions(DICT_TYPE.INFRA_CODEGEN_TEMPLATE_TYPE, 'number'), + class: 'w-full', }, rules: z.number().min(1, { message: '生成模板不能为空' }), }, @@ -130,9 +131,10 @@ export function useGenerationInfoBaseFormSchema(): VbenFormSchema[] { fieldName: 'frontType', label: '前端类型', componentProps: { - class: 'w-full', options: getDictOptions(DICT_TYPE.INFRA_CODEGEN_FRONT_TYPE, 'number'), + class: 'w-full', }, + // todo @puhui999:1 可以是枚举么 rules: z.number().min(1, { message: '前端类型不能为空' }), }, { @@ -140,9 +142,10 @@ export function useGenerationInfoBaseFormSchema(): VbenFormSchema[] { fieldName: 'scene', label: '生成场景', componentProps: { - class: 'w-full', options: getDictOptions(DICT_TYPE.INFRA_CODEGEN_SCENE, 'number'), + class: 'w-full', }, + // todo @puhui999:1 可以是枚举么 rules: z.number().min(1, { message: '生成场景不能为空' }), }, { @@ -196,6 +199,7 @@ export function useGenerationInfoBaseFormSchema(): VbenFormSchema[] { fieldName: 'moduleName', label: '模块名', help: '模块名,即一级目录,例如 system、infra、tool 等等', + // TODO @puhui999:这种 rules,可以使用 required rules: z.string().min(1, { message: '模块名不能为空' }), }, { @@ -222,6 +226,7 @@ export function useGenerationInfoBaseFormSchema(): VbenFormSchema[] { ]; } +// TODO @puhui999:是不是使用 useGenerationInfoTreeFormSchema,主要考虑对称 /** 树表信息 schema */ export function useTreeTableFormSchema(columns: InfraCodegenApi.CodegenColumn[] = []): VbenFormSchema[] { return [ @@ -240,7 +245,7 @@ export function useTreeTableFormSchema(columns: InfraCodegenApi.CodegenColumn[] component: 'Select', fieldName: 'treeParentColumnId', label: '父编号字段', - help: '树显示的父编码字段名, 如:parent_Id', + help: '树显示的父编码字段名,例如 parent_Id', componentProps: { class: 'w-full', allowClear: true, @@ -256,11 +261,11 @@ export function useTreeTableFormSchema(columns: InfraCodegenApi.CodegenColumn[] component: 'Select', fieldName: 'treeNameColumnId', label: '名称字段', - help: '树节点显示的名称字段,一般是name', + help: '树节点显示的名称字段,一般是 name', componentProps: { class: 'w-full', allowClear: true, - placeholder: '请选择', + placeholder: '请选择名称字段', options: columns.map((column) => ({ label: column.columnName, value: column.id, @@ -271,6 +276,7 @@ export function useTreeTableFormSchema(columns: InfraCodegenApi.CodegenColumn[] ]; } +// TODO @puhui999:【类似】是不是使用 useGenerationInfoTreeFormSchema,主要考虑对称 /** 主子表信息 schema */ export function useSubTableFormSchema( columns: InfraCodegenApi.CodegenColumn[] = [], @@ -476,8 +482,8 @@ export function useCodegenColumnTableColumns(): VxeTableGridOptions['columns'] { { field: 'dataType', title: '物理类型', minWidth: 100 }, { field: 'javaType', - title: 'Java类型', - minWidth: 100, + title: 'Java 类型', + minWidth: 130, slots: { default: 'javaType' }, params: { options: [ @@ -493,7 +499,7 @@ export function useCodegenColumnTableColumns(): VxeTableGridOptions['columns'] { }, { field: 'javaField', - title: 'java属性', + title: 'Java 属性', minWidth: 100, slots: { default: 'javaField' }, }, @@ -542,13 +548,13 @@ export function useCodegenColumnTableColumns(): VxeTableGridOptions['columns'] { { field: 'nullable', title: '允许空', - width: 50, + width: 60, slots: { default: 'nullable' }, }, { field: 'htmlType', title: '显示类型', - width: 120, + width: 130, slots: { default: 'htmlType' }, params: { options: [ diff --git a/apps/web-antd/src/views/infra/codegen/edit.vue b/apps/web-antd/src/views/infra/codegen/edit.vue index 63348133e..1f268e3b7 100644 --- a/apps/web-antd/src/views/infra/codegen/edit.vue +++ b/apps/web-antd/src/views/infra/codegen/edit.vue @@ -1,4 +1,5 @@ - + - - + @@ -96,17 +85,14 @@ loadDictTypeOptions(); - - -