From 6e27639bb949227f3faae514ad2fb42f5f16cf30 Mon Sep 17 00:00:00 2001 From: xingyu Date: Thu, 23 Mar 2023 22:31:00 +0800 Subject: [PATCH] feat: editTable init --- src/router/routes/index.ts | 26 +++- src/views/infra/codegen/EditTable.vue | 57 ++++++++- .../codegen/components/BasicInfoForm.vue | 78 +++++++++++ .../codegen/components/CloumInfoForm.vue | 78 +++++++++++ .../infra/codegen/components/GenInfoForm.vue | 78 +++++++++++ src/views/infra/codegen/components/data.ts | 121 ++++++++++++++++++ src/views/infra/codegen/index.vue | 10 +- 7 files changed, 441 insertions(+), 7 deletions(-) create mode 100644 src/views/infra/codegen/components/BasicInfoForm.vue create mode 100644 src/views/infra/codegen/components/CloumInfoForm.vue create mode 100644 src/views/infra/codegen/components/GenInfoForm.vue create mode 100644 src/views/infra/codegen/components/data.ts diff --git a/src/router/routes/index.ts b/src/router/routes/index.ts index 2633c127..a053c12f 100644 --- a/src/router/routes/index.ts +++ b/src/router/routes/index.ts @@ -74,6 +74,30 @@ export const ProfileRoute: AppRouteRecordRaw = { ] } +export const CodegenRoute: AppRouteRecordRaw = { + path: '/codegen', + component: LAYOUT, + name: 'CodegenEdit', + meta: { + title: '修改生成配置', + hidden: true + }, + children: [ + { + path: 'editTable', + component: () => import('@/views/infra/codegen/EditTable.vue'), + name: 'EditTable', + meta: { + canTo: true, + hidden: true, + noTagsView: false, + icon: 'ep:edit', + title: '修改生成配置' + } + } + ] +} + // Basic routing without permission // 未经许可的基本路由 -export const basicRoutes = [LoginRoute, RootRoute, ProfileRoute, REDIRECT_ROUTE, PAGE_NOT_FOUND_ROUTE] +export const basicRoutes = [LoginRoute, RootRoute, ProfileRoute, CodegenRoute, REDIRECT_ROUTE, PAGE_NOT_FOUND_ROUTE] diff --git a/src/views/infra/codegen/EditTable.vue b/src/views/infra/codegen/EditTable.vue index dad38a65..0ed50a90 100644 --- a/src/views/infra/codegen/EditTable.vue +++ b/src/views/infra/codegen/EditTable.vue @@ -1 +1,56 @@ - + + diff --git a/src/views/infra/codegen/components/BasicInfoForm.vue b/src/views/infra/codegen/components/BasicInfoForm.vue new file mode 100644 index 00000000..7e2c62ac --- /dev/null +++ b/src/views/infra/codegen/components/BasicInfoForm.vue @@ -0,0 +1,78 @@ + + + diff --git a/src/views/infra/codegen/components/CloumInfoForm.vue b/src/views/infra/codegen/components/CloumInfoForm.vue new file mode 100644 index 00000000..0a717ab6 --- /dev/null +++ b/src/views/infra/codegen/components/CloumInfoForm.vue @@ -0,0 +1,78 @@ + + + diff --git a/src/views/infra/codegen/components/GenInfoForm.vue b/src/views/infra/codegen/components/GenInfoForm.vue new file mode 100644 index 00000000..fa1718d1 --- /dev/null +++ b/src/views/infra/codegen/components/GenInfoForm.vue @@ -0,0 +1,78 @@ + + + diff --git a/src/views/infra/codegen/components/data.ts b/src/views/infra/codegen/components/data.ts new file mode 100644 index 00000000..4b0be0e0 --- /dev/null +++ b/src/views/infra/codegen/components/data.ts @@ -0,0 +1,121 @@ +import { listSimpleMenus } from '@/api/system/menu' +import { FormSchema } from '@/components/Form' +import { getIntDictOptions, DICT_TYPE } from '@/utils/dict' + +export const basicInfoSchemas: FormSchema[] = [ + { + label: '表名称', + field: 'tableName', + required: true, + component: 'Input', + colProps: { span: 24 } + }, + { + label: '表描述', + field: 'tableComment', + required: true, + component: 'Input', + colProps: { span: 24 } + }, + { + label: '实体类名称', + field: 'className', + required: true, + helpMessage: '默认去除表名的前缀。如果存在重复,则需要手动添加前缀,避免 MyBatis 报 Alias 重复的问题。', + component: 'Input', + colProps: { span: 24 } + }, + { + label: '作者', + field: 'author', + required: true, + component: 'Input', + colProps: { span: 24 } + }, + { + label: '备注', + field: 'remark', + component: 'InputTextArea', + colProps: { span: 24 } + } +] + +export const genInfoSchemas: FormSchema[] = [ + { + label: '生成模板', + field: 'templateType', + required: true, + component: 'Select', + componentProps: { + options: getIntDictOptions(DICT_TYPE.INFRA_CODEGEN_TEMPLATE_TYPE) + }, + colProps: { span: 24 } + }, + { + label: '生成场景', + field: 'scene', + required: true, + component: 'Select', + componentProps: { + options: getIntDictOptions(DICT_TYPE.INFRA_CODEGEN_SCENE) + }, + colProps: { span: 24 } + }, + { + label: '模块名', + field: 'moduleName', + required: true, + helpMessage: '模块名,即一级目录,例如 system、infra、tool 等等', + component: 'Input', + colProps: { span: 24 } + }, + { + label: '业务名', + field: 'businessName', + required: true, + component: 'Input', + helpMessage: '业务名,即二级目录,例如 user、permission、dict 等等', + colProps: { span: 24 } + }, + { + label: '类名称', + field: 'className', + required: true, + component: 'Input', + helpMessage: '类名称(首字母大写),例如SysUser、SysMenu、SysDictData 等等', + colProps: { span: 24 } + }, + { + label: '类描述', + field: 'classComment', + required: true, + component: 'Input', + helpMessage: '用作类描述,例如 用户', + colProps: { span: 24 } + }, + { + label: '上级菜单', + field: 'parentMenuId', + required: true, + component: 'ApiTreeSelect', + componentProps: { + api: () => listSimpleMenus(), + fieldNames: { + label: 'name', + key: 'id', + value: 'id' + }, + handleTree: 'id' + }, + colProps: { span: 24 } + }, + { + label: '自定义路径', + field: 'genPath', + component: 'Input', + helpMessage: '填写磁盘绝对路径,若不填写,则生成到当前Web项目下', + defaultValue: '/', + ifShow: ({ values }) => values.genType === '1', + colProps: { span: 24 } + } +] diff --git a/src/views/infra/codegen/index.vue b/src/views/infra/codegen/index.vue index f0f4531f..0825abbf 100644 --- a/src/views/infra/codegen/index.vue +++ b/src/views/infra/codegen/index.vue @@ -9,7 +9,7 @@ +import { useGo } from '@/hooks/web/usePage' import { useI18n } from '@/hooks/web/useI18n' import { useMessage } from '@/hooks/web/useMessage' import { useModal } from '@/components/Modal' @@ -50,6 +51,7 @@ import { BasicTable, useTable, TableAction } from '@/components/Table' import { deleteCodegenTable, downloadCodegen, getCodegenTablePage, syncCodegenFromDB } from '@/api/infra/codegen' import { columns, searchFormSchema } from './codegen.data' +const go = useGo() const { t } = useI18n() const { createMessage } = useMessage() const [registerPreviewModal, { openModal: openPreviewModal }] = useModal() @@ -80,10 +82,8 @@ function handlePreview(record: Recordable) { }) } -function handleEdit(record: Recordable) { - openPreviewModal(true, { - record - }) +function handleEdit() { + go('/codegen/editTable') } async function handleGenTable(record: Recordable) {