feat: add CodegenOptionsModal for editing code generation configurations
- Introduced a new modal component for modifying code generation settings. - Updated codegen.data.ts to include form schema for the new modal.pull/54/head
parent
3e0c0af119
commit
2b04e1e4ef
|
@ -1,10 +1,11 @@
|
|||
import type { VbenFormProps } from '@vben/common-ui';
|
||||
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { CodegenApi } from '#/api/infra/codegen';
|
||||
|
||||
import { type VbenFormProps, z } from '@vben/common-ui';
|
||||
|
||||
import { getDataSourceConfigList } from '#/api/infra/data-source-config';
|
||||
import { $t } from '#/locales';
|
||||
import { DICT_TYPE } from '#/utils/dict';
|
||||
|
||||
export namespace CodegenDefaultData {
|
||||
/**
|
||||
|
@ -114,3 +115,131 @@ export namespace CodegenImportTableModalData {
|
|||
},
|
||||
];
|
||||
}
|
||||
|
||||
//* ****************************** CodegenOptionsModal.vue *******************************//
|
||||
export namespace CodegenOptionsModalData {
|
||||
export const formSchema: VbenFormProps['schema'] = [
|
||||
{
|
||||
label: '表名称',
|
||||
fieldName: 'tableName',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入表名称',
|
||||
},
|
||||
rules: z.string().min(1, { message: '表名称不能为空' }),
|
||||
},
|
||||
{
|
||||
label: '表描述',
|
||||
fieldName: 'tableComment',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入表描述',
|
||||
},
|
||||
rules: z.string().min(1, { message: '表描述不能为空' }),
|
||||
},
|
||||
{
|
||||
label: '实体类名',
|
||||
fieldName: 'className',
|
||||
component: 'Input',
|
||||
rules: z.string().min(1, { message: '实体类名不能为空' }),
|
||||
componentProps: {
|
||||
tooltip:
|
||||
'默认去除表名的前缀。如果存在重复,则需要手动添加前缀,避免 MyBatis 报 Alias 重复的问题。',
|
||||
placeholder: '请输入实体类名',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '作者',
|
||||
fieldName: 'author',
|
||||
component: 'Input',
|
||||
rules: z.string().min(1, { message: '作者不能为空' }),
|
||||
componentProps: {
|
||||
placeholder: '请输入作者',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '备注',
|
||||
fieldName: 'remark',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入备注',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '生成模版',
|
||||
fieldName: 'template',
|
||||
component: 'ApiDict',
|
||||
componentProps: {
|
||||
code: DICT_TYPE.INFRA_CODEGEN_TEMPLATE_TYPE,
|
||||
class: 'w-full',
|
||||
placeholder: '请选择生成模版',
|
||||
},
|
||||
rules: z.string().min(1, { message: '生成模版不能为空' }),
|
||||
defaultValue: '1',
|
||||
},
|
||||
{
|
||||
label: '前端类型',
|
||||
fieldName: 'frontType',
|
||||
component: 'ApiDict',
|
||||
componentProps: {
|
||||
code: DICT_TYPE.INFRA_CODEGEN_FRONT_TYPE,
|
||||
class: 'w-full',
|
||||
placeholder: '请选择前端类型',
|
||||
},
|
||||
rules: z.string().min(1, { message: '前端类型不能为空' }),
|
||||
defaultValue: '31',
|
||||
},
|
||||
{
|
||||
label: '生成场景',
|
||||
fieldName: 'scene',
|
||||
component: 'ApiDict',
|
||||
componentProps: {
|
||||
code: DICT_TYPE.INFRA_CODEGEN_SCENE,
|
||||
class: 'w-full',
|
||||
placeholder: '请选择生成场景',
|
||||
},
|
||||
rules: z.string().min(1, { message: '生成场景不能为空' }),
|
||||
defaultValue: '1',
|
||||
},
|
||||
{
|
||||
label: '上级菜单',
|
||||
fieldName: 'parentMenuId',
|
||||
component: 'ApiTreeSelect',
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
placeholder: '请选择上级菜单',
|
||||
},
|
||||
rules: z.string().min(1, { message: '上级菜单不能为空' }),
|
||||
},
|
||||
{
|
||||
label: '模块名',
|
||||
fieldName: 'moduleName',
|
||||
component: 'Input',
|
||||
rules: z.string().min(1, { message: '模块名不能为空' }),
|
||||
componentProps: {
|
||||
placeholder: '请输入模块名',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '业务名',
|
||||
fieldName: 'businessName',
|
||||
component: 'Input',
|
||||
rules: z.string().min(1, { message: '业务名不能为空' }),
|
||||
componentProps: {
|
||||
placeholder: '请输入业务名',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '类名',
|
||||
fieldName: 'className',
|
||||
component: 'Input',
|
||||
rules: z.string().min(1, { message: '类名不能为空' }),
|
||||
},
|
||||
{
|
||||
label: '类描述',
|
||||
fieldName: 'classComment',
|
||||
component: 'Input',
|
||||
rules: z.string().min(1, { message: '类描述不能为空' }),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<script setup lang="ts">
|
||||
import { useVbenForm, useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { CodegenOptionsModalData } from '../codegen.data';
|
||||
|
||||
defineOptions({
|
||||
name: 'CodegenOptionsModal',
|
||||
});
|
||||
|
||||
// 使用表单组件
|
||||
const [Form] = useVbenForm({
|
||||
commonConfig: {
|
||||
labelWidth: 120,
|
||||
wrapperClass: 'w-full',
|
||||
},
|
||||
schema: CodegenOptionsModalData.formSchema,
|
||||
// 大屏一行显示3个,中屏一行显示2个,小屏一行显示1个
|
||||
wrapperClass: 'grid-cols-1 md:grid-cols-2',
|
||||
});
|
||||
|
||||
// 使用弹窗组件
|
||||
const [Modal] = useVbenModal({
|
||||
title: '修改代码生成配置',
|
||||
class: 'w-[90%] h-[90%]',
|
||||
onOpenChange(isOpen) {
|
||||
if (isOpen) {
|
||||
// TODO: 打开弹窗
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal>
|
||||
<Form />
|
||||
</Modal>
|
||||
</template>
|
|
@ -16,13 +16,6 @@ import { CodegenDefaultData } from './codegen.data';
|
|||
// checked
|
||||
const checkedStatus = ref<boolean>(false);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
const handleEdit = (_row: CodegenApi.CodegenTableRespVO) => {
|
||||
// console.log('编辑', row);
|
||||
};
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
|
@ -145,6 +138,13 @@ const [PreviewCodeModal, previewCodeModalApi] = useVbenModal({
|
|||
),
|
||||
});
|
||||
|
||||
// 使用修改代码生成配置弹窗组件
|
||||
const [CodegenOptionsModal, codegenOptionsModalApi] = useVbenModal({
|
||||
connectedComponent: defineAsyncComponent(
|
||||
() => import('./components/codegen-options-modal.vue'),
|
||||
),
|
||||
});
|
||||
|
||||
/**
|
||||
* 打开导入表弹窗
|
||||
*/
|
||||
|
@ -159,6 +159,14 @@ const handleOpenPreviewCodeModal = (row: CodegenApi.CodegenTableRespVO) => {
|
|||
previewCodeModalApi.setData(row);
|
||||
previewCodeModalApi.open();
|
||||
};
|
||||
|
||||
/**
|
||||
* 打开修改代码生成配置弹窗
|
||||
*/
|
||||
const handleOpenCodegenOptionsModal = (row: CodegenApi.CodegenTableRespVO) => {
|
||||
codegenOptionsModalApi.setData(row);
|
||||
codegenOptionsModalApi.open();
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -214,7 +222,7 @@ const handleOpenPreviewCodeModal = (row: CodegenApi.CodegenTableRespVO) => {
|
|||
type: 'link',
|
||||
label: '编辑',
|
||||
icon: 'ant-design:edit-outlined',
|
||||
onClick: handleEdit.bind(null, row),
|
||||
onClick: handleOpenCodegenOptionsModal.bind(null, row),
|
||||
},
|
||||
{
|
||||
type: 'link',
|
||||
|
@ -241,5 +249,6 @@ const handleOpenPreviewCodeModal = (row: CodegenApi.CodegenTableRespVO) => {
|
|||
</Grid>
|
||||
<ImportTableModal />
|
||||
<PreviewCodeModal />
|
||||
<CodegenOptionsModal />
|
||||
</Page>
|
||||
</template>
|
||||
|
|
Loading…
Reference in New Issue