feat: 代码生成编辑

pull/69/head
puhui999 2025-04-08 18:30:12 +08:00
parent ffd645c666
commit ff166fb6c3
6 changed files with 272 additions and 288 deletions

View File

@ -1,28 +1,6 @@
import type { RouteRecordRaw } from 'vue-router'; import type { RouteRecordRaw } from 'vue-router';
import { $t } from '#/locales';
const routes: RouteRecordRaw[] = [ const routes: RouteRecordRaw[] = [
{
meta: {
icon: 'ic:baseline-view-in-ar',
keepAlive: true,
order: 1000,
title: $t('demos.title'),
},
name: 'Demos',
path: '/demos',
children: [
{
meta: {
title: $t('demos.antd'),
},
name: 'AntDesignDemos',
path: '/demos/ant-design',
component: () => import('#/views/demos/antd/index.vue'),
},
],
},
{ {
path: '/codegen', path: '/codegen',
name: 'CodegenEdit', name: 'CodegenEdit',
@ -30,18 +8,19 @@ const routes: RouteRecordRaw[] = [
icon: 'ic:baseline-view-in-ar', icon: 'ic:baseline-view-in-ar',
keepAlive: true, keepAlive: true,
order: 1000, order: 1000,
title: $t('demos.title'), title: '代码生成',
hideInMenu: true,
}, },
children: [ children: [
// { {
// path: 'codegen/edit', path: '/codegen/edit',
// name: 'InfraCodegenEdit', name: 'InfraCodegenEdit',
// component: () => import('#/views/infra/codegen/edit.vue'), component: () => import('#/views/infra/codegen/edit.vue'),
// meta: { meta: {
// title: '修改生成配置', title: '修改生成配置',
// activeMenu: '/infra/codegen', activeMenu: '/infra/codegen',
// }, },
// }, },
], ],
}, },
]; ];

View File

@ -1,7 +1,8 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { InfraCodegenApi } from '#/api/infra/codegen'; import type { InfraCodegenApi } from '#/api/infra/codegen';
import { QuestionCircleFilled } from '@vben/icons'; import { CircleHelp } from '@vben/icons';
import { Col, Form, FormItem, Input, Row, Textarea, Tooltip } from 'ant-design-vue';
import { ref, unref, watch } from 'vue'; import { ref, unref, watch } from 'vue';
@ -52,44 +53,44 @@ defineExpose({
}); });
</script> </script>
<template> <template>
<a-form ref="formRef" :model="formData" :rules="rules" :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }"> <Form ref="formRef" :model="formData" :rules="rules" :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }">
<a-row :gutter="16"> <Row :gutter="16">
<a-col :span="12"> <Col :span="12">
<a-form-item label="表名称" name="tableName"> <FormItem label="表名称" name="tableName">
<a-input v-model:value="formData.tableName" placeholder="请输入仓库名称" /> <Input v-model:value="formData.tableName" placeholder="请输入仓库名称" />
</a-form-item> </FormItem>
</a-col> </Col>
<a-col :span="12"> <Col :span="12">
<a-form-item label="表描述" name="tableComment"> <FormItem label="表描述" name="tableComment">
<a-input v-model:value="formData.tableComment" placeholder="请输入" /> <Input v-model:value="formData.tableComment" placeholder="请输入" />
</a-form-item> </FormItem>
</a-col> </Col>
<a-col :span="12"> <Col :span="12">
<a-form-item name="className"> <FormItem name="className">
<template #label> <template #label>
<span> <span>
实体类名称 实体类名称
<a-tooltip <Tooltip
title="默认去除表名的前缀。如果存在重复,则需要手动添加前缀,避免 MyBatis 报 Alias 重复的问题。" title="默认去除表名的前缀。如果存在重复,则需要手动添加前缀,避免 MyBatis 报 Alias 重复的问题。"
placement="top" placement="top"
> >
<QuestionCircleFilled /> <CircleHelp />
</a-tooltip> </Tooltip>
</span> </span>
</template> </template>
<a-input v-model:value="formData.className" placeholder="请输入" /> <Input v-model:value="formData.className" placeholder="请输入" />
</a-form-item> </FormItem>
</a-col> </Col>
<a-col :span="12"> <Col :span="12">
<a-form-item label="作者" name="author"> <FormItem label="作者" name="author">
<a-input v-model:value="formData.author" placeholder="请输入" /> <Input v-model:value="formData.author" placeholder="请输入" />
</a-form-item> </FormItem>
</a-col> </Col>
<a-col :span="24"> <Col :span="24">
<a-form-item label="备注" name="remark"> <FormItem label="备注" name="remark">
<a-textarea v-model:value="formData.remark" :rows="3" /> <Textarea v-model:value="formData.remark" :rows="3" />
</a-form-item> </FormItem>
</a-col> </Col>
</a-row> </Row>
</a-form> </Form>
</template> </template>

View File

@ -2,23 +2,25 @@
import type { InfraCodegenApi } from '#/api/infra/codegen'; import type { InfraCodegenApi } from '#/api/infra/codegen';
import type { SystemDictTypeApi } from '#/api/system/dict/type'; import type { SystemDictTypeApi } from '#/api/system/dict/type';
import { Checkbox, Input, Select, SelectOption, Table } from 'ant-design-vue';
import { getSimpleDictTypeList } from '#/api/system/dict/type'; import { getSimpleDictTypeList } from '#/api/system/dict/type';
import { computed, onMounted, ref, watch } from 'vue'; import { computed, onMounted, ref, watch } from 'vue';
defineOptions({ name: 'InfraCodegenColumInfoForm' }); defineOptions({ name: 'InfraCodegenColumInfoForm' });
const props = defineProps<Props>();
interface Props { interface Props {
columns?: InfraCodegenApi.CodegenColumn[]; columns?: InfraCodegenApi.CodegenColumn[];
} }
const props = defineProps<Props>();
const formData = ref<InfraCodegenApi.CodegenColumn[]>([]); const formData = ref<InfraCodegenApi.CodegenColumn[]>([]);
const tableHeight = computed(() => document.documentElement.scrollHeight - 350); const tableHeight = computed(() => document.documentElement.scrollHeight - 350);
const dictOptions = ref<SystemDictTypeApi.SystemDictType[]>([]); const dictOptions = ref<SystemDictTypeApi.SystemDictType[]>([]);
// //
const columns = [ const tableColumns = [
{ title: '字段列名', dataIndex: 'columnName', width: 100 }, { title: '字段列名', dataIndex: 'columnName', width: 100 },
{ title: '字段描述', dataIndex: 'columnComment', width: 100 }, { title: '字段描述', dataIndex: 'columnComment', width: 100 },
{ title: '物理类型', dataIndex: 'dataType', width: 100 }, { title: '物理类型', dataIndex: 'dataType', width: 100 },
@ -62,74 +64,73 @@ onMounted(async () => {
}); });
</script> </script>
<template> <template>
<a-table <Table
ref="tableRef"
:data-source="formData" :data-source="formData"
:columns="columns" :columns="tableColumns"
:scroll="{ y: tableHeight }" :scroll="{ y: tableHeight }"
:pagination="false" :pagination="false"
row-key="columnId" row-key="columnId"
> >
<template #bodyCell="{ column, text, record }"> <template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'columnComment'"> <template v-if="column.dataIndex === 'columnComment'">
<a-input v-model:value="record.columnComment" /> <Input v-model:value="record.columnComment" />
</template> </template>
<template v-else-if="column.dataIndex === 'javaType'"> <template v-else-if="column.dataIndex === 'javaType'">
<a-select v-model:value="record.javaType" style="width: 100%"> <Select v-model:value="record.javaType" style="width: 100%">
<a-select-option value="Long">Long</a-select-option> <SelectOption value="Long">Long</SelectOption>
<a-select-option value="String">String</a-select-option> <SelectOption value="String">String</SelectOption>
<a-select-option value="Integer">Integer</a-select-option> <SelectOption value="Integer">Integer</SelectOption>
<a-select-option value="Double">Double</a-select-option> <SelectOption value="Double">Double</SelectOption>
<a-select-option value="BigDecimal">BigDecimal</a-select-option> <SelectOption value="BigDecimal">BigDecimal</SelectOption>
<a-select-option value="LocalDateTime">LocalDateTime</a-select-option> <SelectOption value="LocalDateTime">LocalDateTime</SelectOption>
<a-select-option value="Boolean">Boolean</a-select-option> <SelectOption value="Boolean">Boolean</SelectOption>
</a-select> </Select>
</template> </template>
<template v-else-if="column.dataIndex === 'javaField'"> <template v-else-if="column.dataIndex === 'javaField'">
<a-input v-model:value="record.javaField" /> <Input v-model:value="record.javaField" />
</template> </template>
<template v-else-if="column.dataIndex === 'createOperation'"> <template v-else-if="column.dataIndex === 'createOperation'">
<a-checkbox v-model:checked="record.createOperation" /> <Checkbox v-model:checked="record.createOperation" />
</template> </template>
<template v-else-if="column.dataIndex === 'updateOperation'"> <template v-else-if="column.dataIndex === 'updateOperation'">
<a-checkbox v-model:checked="record.updateOperation" /> <Checkbox v-model:checked="record.updateOperation" />
</template> </template>
<template v-else-if="column.dataIndex === 'listOperationResult'"> <template v-else-if="column.dataIndex === 'listOperationResult'">
<a-checkbox v-model:checked="record.listOperationResult" /> <Checkbox v-model:checked="record.listOperationResult" />
</template> </template>
<template v-else-if="column.dataIndex === 'listOperation'"> <template v-else-if="column.dataIndex === 'listOperation'">
<a-checkbox v-model:checked="record.listOperation" /> <Checkbox v-model:checked="record.listOperation" />
</template> </template>
<template v-else-if="column.dataIndex === 'listOperationCondition'"> <template v-else-if="column.dataIndex === 'listOperationCondition'">
<a-select v-model:value="record.listOperationCondition" style="width: 100%"> <Select v-model:value="record.listOperationCondition" style="width: 100%">
<a-select-option value="=">=</a-select-option> <SelectOption value="=">=</SelectOption>
<a-select-option value="!=">!=</a-select-option> <SelectOption value="!=">!=</SelectOption>
<a-select-option value=">">></a-select-option> <SelectOption value=">">&gt;</SelectOption>
<a-select-option value=">=">>=</a-select-option> <SelectOption value=">=">&gt;=</SelectOption>
<a-select-option value="<"><</a-select-option> <SelectOption value="<">&lt;</SelectOption>
<a-select-option value="<="><=</a-select-option> <SelectOption value="<=">&lt;=</SelectOption>
<a-select-option value="LIKE">LIKE</a-select-option> <SelectOption value="LIKE">LIKE</SelectOption>
<a-select-option value="BETWEEN">BETWEEN</a-select-option> <SelectOption value="BETWEEN">BETWEEN</SelectOption>
</a-select> </Select>
</template> </template>
<template v-else-if="column.dataIndex === 'nullable'"> <template v-else-if="column.dataIndex === 'nullable'">
<a-checkbox v-model:checked="record.nullable" /> <Checkbox v-model:checked="record.nullable" />
</template> </template>
<template v-else-if="column.dataIndex === 'htmlType'"> <template v-else-if="column.dataIndex === 'htmlType'">
<a-select v-model:value="record.htmlType" style="width: 100%"> <Select v-model:value="record.htmlType" style="width: 100%">
<a-select-option value="input">文本框</a-select-option> <SelectOption value="input">文本框</SelectOption>
<a-select-option value="textarea">文本域</a-select-option> <SelectOption value="textarea">文本域</SelectOption>
<a-select-option value="select">下拉框</a-select-option> <SelectOption value="select">下拉框</SelectOption>
<a-select-option value="radio">单选框</a-select-option> <SelectOption value="radio">单选框</SelectOption>
<a-select-option value="checkbox">复选框</a-select-option> <SelectOption value="checkbox">复选框</SelectOption>
<a-select-option value="datetime">日期控件</a-select-option> <SelectOption value="datetime">日期控件</SelectOption>
<a-select-option value="imageUpload">图片上传</a-select-option> <SelectOption value="imageUpload">图片上传</SelectOption>
<a-select-option value="fileUpload">文件上传</a-select-option> <SelectOption value="fileUpload">文件上传</SelectOption>
<a-select-option value="editor">富文本控件</a-select-option> <SelectOption value="editor">富文本控件</SelectOption>
</a-select> </Select>
</template> </template>
<template v-else-if="column.dataIndex === 'dictType'"> <template v-else-if="column.dataIndex === 'dictType'">
<a-select <Select
v-model:value="record.dictType" v-model:value="record.dictType"
allow-clear allow-clear
show-search show-search
@ -137,14 +138,14 @@ onMounted(async () => {
style="width: 100%" style="width: 100%"
:filter-option="filterOption" :filter-option="filterOption"
> >
<a-select-option v-for="dict in dictOptions" :key="dict.id" :value="dict.type"> <SelectOption v-for="dict in dictOptions" :key="dict.id" :value="dict.type">
{{ dict.name }} {{ dict.name }}
</a-select-option> </SelectOption>
</a-select> </Select>
</template> </template>
<template v-else-if="column.dataIndex === 'example'"> <template v-else-if="column.dataIndex === 'example'">
<a-input v-model:value="record.example" /> <Input v-model:value="record.example" />
</template> </template>
</template> </template>
</a-table> </Table>
</template> </template>

View File

@ -2,7 +2,9 @@
import type { InfraCodegenApi } from '#/api/infra/codegen'; import type { InfraCodegenApi } from '#/api/infra/codegen';
import type { SystemMenuApi } from '#/api/system/menu'; import type { SystemMenuApi } from '#/api/system/menu';
import { QuestionCircleFilled } from '@vben/icons'; import { CircleHelp } from '@vben/icons';
import { Col, Divider, Form, FormItem, Input, Row, Select, SelectOption, Tooltip, TreeSelect } from 'ant-design-vue';
import { getCodegenTableList } from '#/api/infra/codegen'; import { getCodegenTableList } from '#/api/infra/codegen';
import { getSimpleMenusList } from '#/api/system/menu'; import { getSimpleMenusList } from '#/api/system/menu';
import { DICT_TYPE, getDictOptions } from '#/utils/dict'; import { DICT_TYPE, getDictOptions } from '#/utils/dict';
@ -10,13 +12,13 @@ import { onMounted, ref, unref, watch } from 'vue';
defineOptions({ name: 'InfraCodegenGenerateInfoForm' }); defineOptions({ name: 'InfraCodegenGenerateInfoForm' });
const props = defineProps<Props>();
interface Props { interface Props {
columns?: InfraCodegenApi.CodegenColumn[]; columns?: InfraCodegenApi.CodegenColumn[];
table?: InfraCodegenApi.CodegenTable; table?: InfraCodegenApi.CodegenTable;
} }
const props = defineProps<Props>();
const formRef = ref(); const formRef = ref();
const formData = ref<InfraCodegenApi.CodegenTable>({} as InfraCodegenApi.CodegenTable); const formData = ref<InfraCodegenApi.CodegenTable>({} as InfraCodegenApi.CodegenTable);
const subColumns = ref<InfraCodegenApi.CodegenColumn[]>([]); const subColumns = ref<InfraCodegenApi.CodegenColumn[]>([]);
@ -97,54 +99,54 @@ defineExpose({
</script> </script>
<template> <template>
<a-form ref="formRef" :model="formData" :rules="rules" :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }"> <Form ref="formRef" :model="formData" :rules="rules" :label-col="{ span: 4 }" :wrapper-col="{ span: 20 }">
<a-row :gutter="16"> <Row :gutter="16">
<a-col :span="12"> <Col :span="12">
<a-form-item label="生成模板" name="templateType"> <FormItem label="生成模板" name="templateType">
<a-select v-model:value="formData.templateType"> <Select v-model:value="formData.templateType">
<a-select-option <SelectOption
v-for="dict in getDictOptions(DICT_TYPE.INFRA_CODEGEN_TEMPLATE_TYPE, 'number')" v-for="dict in getDictOptions(DICT_TYPE.INFRA_CODEGEN_TEMPLATE_TYPE, 'number')"
:key="dict.value" :key="dict.value"
:value="dict.value" :value="dict.value"
> >
{{ dict.label }} {{ dict.label }}
</a-select-option> </SelectOption>
</a-select> </Select>
</a-form-item> </FormItem>
</a-col> </Col>
<a-col :span="12"> <Col :span="12">
<a-form-item label="前端类型" name="frontType"> <FormItem label="前端类型" name="frontType">
<a-select v-model:value="formData.frontType"> <Select v-model:value="formData.frontType">
<a-select-option <SelectOption
v-for="dict in getDictOptions(DICT_TYPE.INFRA_CODEGEN_FRONT_TYPE, 'number')" v-for="dict in getDictOptions(DICT_TYPE.INFRA_CODEGEN_FRONT_TYPE, 'number')"
:key="dict.value" :key="dict.value"
:value="dict.value" :value="dict.value"
> >
{{ dict.label }} {{ dict.label }}
</a-select-option> </SelectOption>
</a-select> </Select>
</a-form-item> </FormItem>
</a-col> </Col>
<a-col :span="12"> <Col :span="12">
<a-form-item label="生成场景" name="scene"> <FormItem label="生成场景" name="scene">
<a-select v-model:value="formData.scene"> <Select v-model:value="formData.scene">
<a-select-option <SelectOption
v-for="dict in getDictOptions(DICT_TYPE.INFRA_CODEGEN_SCENE, 'number')" v-for="dict in getDictOptions(DICT_TYPE.INFRA_CODEGEN_SCENE, 'number')"
:key="dict.value" :key="dict.value"
:value="dict.value" :value="dict.value"
> >
{{ dict.label }} {{ dict.label }}
</a-select-option> </SelectOption>
</a-select> </Select>
</a-form-item> </FormItem>
</a-col> </Col>
<a-col :span="12"> <Col :span="12">
<a-form-item label="上级菜单"> <FormItem label="上级菜单">
<a-tooltip placement="top"> <Tooltip placement="top">
<template #title>分配到指定菜单下例如 系统管理</template> <template #title>分配到指定菜单下例如 系统管理</template>
<template #default> <template #default>
<a-tree-select <TreeSelect
v-model:value="formData.parentMenuId" v-model:value="formData.parentMenuId"
:tree-data="menus" :tree-data="menus"
:field-names="menuTreeProps" :field-names="menuTreeProps"
@ -156,193 +158,193 @@ defineExpose({
style="width: 100%" style="width: 100%"
/> />
</template> </template>
</a-tooltip> </Tooltip>
</a-form-item> </FormItem>
</a-col> </Col>
<a-col :span="12"> <Col :span="12">
<a-form-item label="模块名" name="moduleName"> <FormItem label="模块名" name="moduleName">
<a-tooltip placement="top"> <Tooltip placement="top">
<template #title>模块名即一级目录例如 systeminfratool 等等</template> <template #title>模块名即一级目录例如 systeminfratool 等等</template>
<template #default> <template #default>
<a-input v-model:value="formData.moduleName" /> <Input v-model:value="formData.moduleName" />
</template> </template>
</a-tooltip> </Tooltip>
</a-form-item> </FormItem>
</a-col> </Col>
<a-col :span="12"> <Col :span="12">
<a-form-item label="业务名" name="businessName"> <FormItem label="业务名" name="businessName">
<a-tooltip placement="top"> <Tooltip placement="top">
<template #title>业务名即二级目录例如 userpermissiondict 等等</template> <template #title>业务名即二级目录例如 userpermissiondict 等等</template>
<template #default> <template #default>
<a-input v-model:value="formData.businessName" /> <Input v-model:value="formData.businessName" />
</template> </template>
</a-tooltip> </Tooltip>
</a-form-item> </FormItem>
</a-col> </Col>
<a-col :span="12"> <Col :span="12">
<a-form-item label="类名称" name="className"> <FormItem label="类名称" name="className">
<a-tooltip placement="top"> <Tooltip placement="top">
<template #title>类名称首字母大写例如SysUserSysMenuSysDictData 等等</template> <template #title>类名称首字母大写例如SysUserSysMenuSysDictData 等等</template>
<template #default> <template #default>
<a-input v-model:value="formData.className" /> <Input v-model:value="formData.className" />
</template> </template>
</a-tooltip> </Tooltip>
</a-form-item> </FormItem>
</a-col> </Col>
<a-col :span="12"> <Col :span="12">
<a-form-item label="类描述" name="classComment"> <FormItem label="类描述" name="classComment">
<a-tooltip placement="top"> <Tooltip placement="top">
<template #title>用作类描述例如 用户</template> <template #title>用作类描述例如 用户</template>
<template #default> <template #default>
<a-input v-model:value="formData.classComment" /> <Input v-model:value="formData.classComment" />
</template> </template>
</a-tooltip> </Tooltip>
</a-form-item> </FormItem>
</a-col> </Col>
</a-row> </Row>
<!-- 树表信息 --> <!-- 树表信息 -->
<template v-if="formData.templateType == 2"> <template v-if="formData.templateType === 2">
<a-divider>树表信息</a-divider> <Divider>树表信息</Divider>
<a-row :gutter="16"> <Row :gutter="16">
<a-col :span="12"> <Col :span="12">
<a-form-item label="父编号字段" name="treeParentColumnId"> <FormItem label="父编号字段" name="treeParentColumnId">
<a-tooltip placement="top"> <Tooltip placement="top">
<template #title>树显示的父编码字段名 parent_Id</template> <template #title>树显示的父编码字段名 parent_Id</template>
<template #icon><QuestionCircleFilled /></template> <template #icon><CircleHelp /></template>
<template #default> <template #default>
<a-select v-model:value="formData.treeParentColumnId" placeholder="请选择" allow-clear> <Select v-model:value="formData.treeParentColumnId" placeholder="请选择" allow-clear>
<a-select-option v-for="column in columns" :key="column.id" :value="column.id"> <SelectOption v-for="column in columns" :key="column.id" :value="column.id">
{{ column.columnName }} {{ column.columnName }}
</a-select-option> </SelectOption>
</a-select> </Select>
</template> </template>
</a-tooltip> </Tooltip>
</a-form-item> </FormItem>
</a-col> </Col>
<a-col :span="12"> <Col :span="12">
<a-form-item label="名称字段" name="treeNameColumnId"> <FormItem label="名称字段" name="treeNameColumnId">
<a-tooltip placement="top"> <Tooltip placement="top">
<template #title>树节点显示的名称字段一般是name</template> <template #title>树节点显示的名称字段一般是name</template>
<template #icon><QuestionCircleFilled /></template> <template #icon><CircleHelp /></template>
<template #default> <template #default>
<a-select v-model:value="formData.treeNameColumnId" placeholder="请选择" allow-clear> <Select v-model:value="formData.treeNameColumnId" placeholder="请选择" allow-clear>
<a-select-option v-for="column in columns" :key="column.id" :value="column.id"> <SelectOption v-for="column in columns" :key="column.id" :value="column.id">
{{ column.columnName }} {{ column.columnName }}
</a-select-option> </SelectOption>
</a-select> </Select>
</template> </template>
</a-tooltip> </Tooltip>
</a-form-item> </FormItem>
</a-col> </Col>
</a-row> </Row>
</template> </template>
<!-- 主子表信息 --> <!-- 主子表信息 -->
<template v-if="formData.templateType == 3"> <template v-if="formData.templateType === 3">
<a-divider>主子表信息</a-divider> <Divider>主子表信息</Divider>
<a-row :gutter="16"> <Row :gutter="16">
<a-col :span="24"> <Col :span="24">
<a-form-item label="关联子表的成员变量名" name="subJoinColumnId"> <FormItem label="关联子表的成员变量名" name="subJoinColumnId">
<a-tooltip placement="top"> <Tooltip placement="top">
<template #title>子表的成员变量名默认为子表的名称</template> <template #title>子表的成员变量名默认为子表的名称</template>
<template #icon><QuestionCircleFilled /></template> <template #icon><CircleHelp /></template>
<template #default> <template #default>
<a-input v-model:value="formData.subJoinColumnId" placeholder="请输入" /> <Input v-model:value="formData.subJoinColumnId" placeholder="请输入" />
</template> </template>
</a-tooltip> </Tooltip>
</a-form-item> </FormItem>
</a-col> </Col>
<a-col :span="12"> <Col :span="12">
<a-form-item label="子表的表名" name="subTableName"> <FormItem label="子表的表名" name="subTableName">
<a-tooltip placement="top"> <Tooltip placement="top">
<template #title>关联的子表的表名 sys_user_post</template> <template #title>关联的子表的表名 sys_user_post</template>
<template #icon><QuestionCircleFilled /></template> <template #icon><CircleHelp /></template>
<template #default> <template #default>
<a-select <Select
v-model:value="formData.subTableName" v-model:value="formData.subTableName"
placeholder="请选择" placeholder="请选择"
allow-clear allow-clear
@change="subTableNameSelected" @change="subTableNameSelected"
> >
<a-select-option v-for="table in tables" :key="table.tableName" :value="table.tableName"> <SelectOption v-for="table in tables" :key="table.tableName" :value="table.tableName">
{{ `${table.tableName}${table.tableComment}` }} {{ `${table.tableName}${table.tableComment}` }}
</a-select-option> </SelectOption>
</a-select> </Select>
</template> </template>
</a-tooltip> </Tooltip>
</a-form-item> </FormItem>
</a-col> </Col>
<a-col :span="12"> <Col :span="12">
<a-form-item label="子表的类名" name="subTableClassName"> <FormItem label="子表的类名" name="subTableClassName">
<a-tooltip placement="top"> <Tooltip placement="top">
<template #title>子表的类名 SysUserPost</template> <template #title>子表的类名 SysUserPost</template>
<template #icon><QuestionCircleFilled /></template> <template #icon><CircleHelp /></template>
<template #default> <template #default>
<a-input v-model:value="formData.subTableClassName" placeholder="请输入" /> <Input v-model:value="formData.subTableClassName" placeholder="请输入" />
</template> </template>
</a-tooltip> </Tooltip>
</a-form-item> </FormItem>
</a-col> </Col>
<a-col :span="12"> <Col :span="12">
<a-form-item label="子表的外键字段" name="subTableFkColumnId"> <FormItem label="子表的外键字段" name="subTableFkColumnId">
<a-tooltip placement="top"> <Tooltip placement="top">
<template #title>子表的外键字段的编号对应主表的主键</template> <template #title>子表的外键字段的编号对应主表的主键</template>
<template #icon><QuestionCircleFilled /></template> <template #icon><CircleHelp /></template>
<template #default> <template #default>
<a-select v-model:value="formData.subTableFkColumnId" placeholder="请选择" allow-clear> <Select v-model:value="formData.subTableFkColumnId" placeholder="请选择" allow-clear>
<a-select-option v-for="column in subColumns" :key="column.id" :value="column.id"> <SelectOption v-for="column in subColumns" :key="column.id" :value="column.id">
{{ column.columnName }} {{ column.columnName }}
</a-select-option> </SelectOption>
</a-select> </Select>
</template> </template>
</a-tooltip> </Tooltip>
</a-form-item> </FormItem>
</a-col> </Col>
<a-col :span="12"> <Col :span="12">
<a-form-item label="主表的类名" name="mainTableClassName"> <FormItem label="主表的类名" name="mainTableClassName">
<a-tooltip placement="top"> <Tooltip placement="top">
<template #title>主表的类名 SysUser</template> <template #title>主表的类名 SysUser</template>
<template #icon><QuestionCircleFilled /></template> <template #icon><CircleHelp /></template>
<template #default> <template #default>
<a-input v-model:value="formData.mainTableClassName" placeholder="请输入" /> <Input v-model:value="formData.mainTableClassName" placeholder="请输入" />
</template> </template>
</a-tooltip> </Tooltip>
</a-form-item> </FormItem>
</a-col> </Col>
<a-col :span="12"> <Col :span="12">
<a-form-item label="主表的外键字段" name="mainTableFKColumnId"> <FormItem label="主表的外键字段" name="mainTableFKColumnId">
<a-tooltip placement="top"> <Tooltip placement="top">
<template #title>子表的外键关联到主表的主键字段编号</template> <template #title>子表的外键关联到主表的主键字段编号</template>
<template #icon><QuestionCircleFilled /></template> <template #icon><CircleHelp /></template>
<template #default> <template #default>
<a-select v-model:value="formData.mainTableFKColumnId" placeholder="请选择" allow-clear> <Select v-model:value="formData.mainTableFKColumnId" placeholder="请选择" allow-clear>
<a-select-option v-for="column in columns" :key="column.id" :value="column.id"> <SelectOption v-for="column in columns" :key="column.id" :value="column.id">
{{ column.columnName }} {{ column.columnName }}
</a-select-option> </SelectOption>
</a-select> </Select>
</template> </template>
</a-tooltip> </Tooltip>
</a-form-item> </FormItem>
</a-col> </Col>
<a-col :span="12"> <Col :span="12">
<a-form-item label="子表的类描述" name="subTableClassComment"> <FormItem label="子表的类描述" name="subTableClassComment">
<a-tooltip placement="top"> <Tooltip placement="top">
<template #title>子表的描述例如 用户岗位</template> <template #title>子表的描述例如 用户岗位</template>
<template #icon><QuestionCircleFilled /></template> <template #icon><CircleHelp /></template>
<template #default> <template #default>
<a-input v-model:value="formData.subTableClassComment" placeholder="请输入" /> <Input v-model:value="formData.subTableClassComment" placeholder="请输入" />
</template> </template>
</a-tooltip> </Tooltip>
</a-form-item> </FormItem>
</a-col> </Col>
</a-row> </Row>
</template> </template>
</a-form> </Form>
</template> </template>
<style scoped> <style scoped>

View File

@ -1,17 +1,18 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { InfraCodegenApi } from '#/api/infra/codegen'; import type { InfraCodegenApi } from '#/api/infra/codegen';
import { Page } from '@vben/common-ui';
import { Button, message, Tabs } from 'ant-design-vue';
import { ArrowLeftOutlined } from '@vben/icons';
import { ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { $t } from '#/locales';
import { getCodegenTable, updateCodegenTable } from '#/api/infra/codegen';
import BasicInfo from './components/BasicInfoForm.vue'; import BasicInfo from './components/BasicInfoForm.vue';
import ColumnInfo from './components/ColumInfoForm.vue'; import ColumnInfo from './components/ColumInfoForm.vue';
import GenerateInfo from './components/GenerateInfoForm.vue'; import GenerateInfo from './components/GenerateInfoForm.vue';
import { Page } from '@vben/common-ui';
import { ChevronsLeft } from '@vben/icons';
import { Button, message, Tabs } from 'ant-design-vue';
import { getCodegenTable, updateCodegenTable } from '#/api/infra/codegen';
import { $t } from '#/locales';
import { ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
@ -80,7 +81,7 @@ getDetail();
<template> <template>
<Page auto-content-height> <Page auto-content-height>
<div v-loading="loading"> <div v-loading="loading">
<Tabs v-model:activeKey="activeKey"> <Tabs v-model:active-key="activeKey">
<Tabs.TabPane key="basicInfo" tab="基本信息"> <Tabs.TabPane key="basicInfo" tab="基本信息">
<BasicInfo ref="basicInfoRef" :table="formData.table" /> <BasicInfo ref="basicInfoRef" :table="formData.table" />
</Tabs.TabPane> </Tabs.TabPane>
@ -92,10 +93,10 @@ getDetail();
</Tabs.TabPane> </Tabs.TabPane>
</Tabs> </Tabs>
<div class="flex justify-end mt-4"> <div class="mt-4 flex justify-end">
<Button type="primary" :loading="loading" @click="submitForm"></Button> <Button type="primary" :loading="loading" @click="submitForm"></Button>
<Button class="ml-2" @click="close"> <Button class="ml-2" @click="close">
<ArrowLeftOutlined class="mr-1" /> <ChevronsLeft class="mr-1" />
返回 返回
</Button> </Button>
</div> </div>

View File

@ -50,7 +50,7 @@ function onPreview(row: InfraCodegenApi.CodegenTable) {
/** 编辑表格 */ /** 编辑表格 */
function onEdit(row: InfraCodegenApi.CodegenTable) { function onEdit(row: InfraCodegenApi.CodegenTable) {
router.push(`/infra/codegen/edit?id=${row.id}`); router.push(`/codegen/edit?id=${row.id}`);
} }
/** 删除代码生成配置 */ /** 删除代码生成配置 */