Commit a57f79cf90e8fc70f646c1dd91fac79b0df6ce73
1 parent
9983590f
fix: vue2代码生成模板
Showing
10 changed files
with
42 additions
and
46 deletions
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/exportReqVO.vm
| @@ -15,9 +15,6 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | @@ -15,9 +15,6 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 15 | #end | 15 | #end |
| 16 | ## 字段模板 | 16 | ## 字段模板 |
| 17 | #macro(columnTpl $prefix $prefixStr) | 17 | #macro(columnTpl $prefix $prefixStr) |
| 18 | -#if (${column.javaType} == "Date")## 时间类型 | ||
| 19 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 20 | -#end | ||
| 21 | @ApiModelProperty(value = "${prefixStr}${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end) | 18 | @ApiModelProperty(value = "${prefixStr}${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end) |
| 22 | private ${column.javaType}#if ("$!prefix" != "") ${prefix}${JavaField}#else ${column.javaField}#end; | 19 | private ${column.javaType}#if ("$!prefix" != "") ${prefix}${JavaField}#else ${column.javaField}#end; |
| 23 | #end | 20 | #end |
| @@ -27,12 +24,11 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | @@ -27,12 +24,11 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 27 | public class ${sceneEnum.prefixClass}${table.className}ExportReqVO { | 24 | public class ${sceneEnum.prefixClass}${table.className}ExportReqVO { |
| 28 | 25 | ||
| 29 | #foreach ($column in $columns) | 26 | #foreach ($column in $columns) |
| 30 | -#set ($JavaField = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})##首字母大写 | ||
| 31 | #if (${column.listOperation})##查询操作 | 27 | #if (${column.listOperation})##查询操作 |
| 32 | #if (${column.listOperationCondition} == "BETWEEN")## 情况一,Between 的时候 | 28 | #if (${column.listOperationCondition} == "BETWEEN")## 情况一,Between 的时候 |
| 33 | - #columnTpl('begin', '开始') | ||
| 34 | - | ||
| 35 | - #columnTpl('end', '结束') | 29 | + @ApiModelProperty(value = "${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end) |
| 30 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 31 | + private ${column.javaType}[] ${column.javaField}; | ||
| 36 | #else##情况二,非 Between 的时间 | 32 | #else##情况二,非 Between 的时间 |
| 37 | #columnTpl('', '') | 33 | #columnTpl('', '') |
| 38 | #end | 34 | #end |
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/pageReqVO.vm
| @@ -15,9 +15,6 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | @@ -15,9 +15,6 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 15 | #end | 15 | #end |
| 16 | ## 字段模板 | 16 | ## 字段模板 |
| 17 | #macro(columnTpl $prefix $prefixStr) | 17 | #macro(columnTpl $prefix $prefixStr) |
| 18 | -#if (${column.javaType} == "Date")## 时间类型 | ||
| 19 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 20 | -#end | ||
| 21 | @ApiModelProperty(value = "${prefixStr}${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end) | 18 | @ApiModelProperty(value = "${prefixStr}${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end) |
| 22 | private ${column.javaType}#if ("$!prefix" != "") ${prefix}${JavaField}#else ${column.javaField}#end; | 19 | private ${column.javaType}#if ("$!prefix" != "") ${prefix}${JavaField}#else ${column.javaField}#end; |
| 23 | #end | 20 | #end |
| @@ -29,12 +26,11 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | @@ -29,12 +26,11 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 29 | public class ${sceneEnum.prefixClass}${table.className}PageReqVO extends PageParam { | 26 | public class ${sceneEnum.prefixClass}${table.className}PageReqVO extends PageParam { |
| 30 | 27 | ||
| 31 | #foreach ($column in $columns) | 28 | #foreach ($column in $columns) |
| 32 | -#set ($JavaField = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})##首字母大写 | ||
| 33 | #if (${column.listOperation})##查询操作 | 29 | #if (${column.listOperation})##查询操作 |
| 34 | #if (${column.listOperationCondition} == "BETWEEN")## 情况一,Between 的时候 | 30 | #if (${column.listOperationCondition} == "BETWEEN")## 情况一,Between 的时候 |
| 35 | - #columnTpl('begin', '开始') | ||
| 36 | - | ||
| 37 | - #columnTpl('end', '结束') | 31 | + @ApiModelProperty(value = "${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end) |
| 32 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 33 | + private ${column.javaType}[] ${column.javaField}; | ||
| 38 | #else##情况二,非 Between 的时间 | 34 | #else##情况二,非 Between 的时间 |
| 39 | #columnTpl('', '') | 35 | #columnTpl('', '') |
| 40 | #end | 36 | #end |
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/index.vue.vm
| @@ -219,22 +219,16 @@ export default { | @@ -219,22 +219,16 @@ export default { | ||
| 219 | title: "", | 219 | title: "", |
| 220 | // 是否显示弹出层 | 220 | // 是否显示弹出层 |
| 221 | open: false, | 221 | open: false, |
| 222 | - #foreach ($column in $columns)## 时间范围 | ||
| 223 | - #if ($column.listOperation) | ||
| 224 | - #if ($column.htmlType == "datetime" && $column.listOperationCondition == "BETWEEN") | ||
| 225 | - #set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) | ||
| 226 | - dateRange${AttrName}: [], | ||
| 227 | - #end | ||
| 228 | - #end | ||
| 229 | - #end | ||
| 230 | // 查询参数 | 222 | // 查询参数 |
| 231 | queryParams: { | 223 | queryParams: { |
| 232 | pageNo: 1, | 224 | pageNo: 1, |
| 233 | pageSize: 10, | 225 | pageSize: 10, |
| 234 | #foreach ($column in $columns) | 226 | #foreach ($column in $columns) |
| 235 | - #if ($column.listOperation && $column.listOperationCondition != 'BETWEEN') | 227 | + #if ($column.listOperation) |
| 228 | + #if ($column.listOperationCondition != 'BETWEEN') | ||
| 236 | $column.javaField: null, | 229 | $column.javaField: null, |
| 237 | - #else if ($column.htmlType == "datetime" && $column.listOperationCondition == "BETWEEN") | 230 | + #end |
| 231 | + #if ($column.htmlType == "datetime" || $column.listOperationCondition == "BETWEEN") | ||
| 238 | $column.javaField: [], | 232 | $column.javaField: [], |
| 239 | #end | 233 | #end |
| 240 | #end | 234 | #end |
yudao-ui-admin-vue3/src/router/modules/remaining.ts
| @@ -72,7 +72,7 @@ const remainingRouter: AppRouteRecordRaw[] = [ | @@ -72,7 +72,7 @@ const remainingRouter: AppRouteRecordRaw[] = [ | ||
| 72 | children: [ | 72 | children: [ |
| 73 | { | 73 | { |
| 74 | path: 'edit', | 74 | path: 'edit', |
| 75 | - component: () => import('@/views/infra/codegen/EditTable.vue'), | 75 | + component: () => import('@/views/infra/codegen/components/EditTable.vue'), |
| 76 | name: 'EditTable', | 76 | name: 'EditTable', |
| 77 | meta: { | 77 | meta: { |
| 78 | noCache: true, | 78 | noCache: true, |
yudao-ui-admin-vue3/src/views/infra/codegen/EditTable.vue renamed to yudao-ui-admin-vue3/src/views/infra/codegen/components/EditTable.vue
| 1 | <script setup lang="ts"> | 1 | <script setup lang="ts"> |
| 2 | import { ref, unref, onMounted } from 'vue' | 2 | import { ref, unref, onMounted } from 'vue' |
| 3 | import { ContentDetailWrap } from '@/components/ContentDetailWrap' | 3 | import { ContentDetailWrap } from '@/components/ContentDetailWrap' |
| 4 | -import BasicInfoForm from './components/BasicInfoForm.vue' | ||
| 5 | -import CloumInfoFormVue from './components/CloumInfoForm.vue' | ||
| 6 | -import GenInfoFormVue from './components/GenInfoForm.vue' | 4 | +import BasicInfoForm from './BasicInfoForm.vue' |
| 5 | +import CloumInfoFormVue from './CloumInfoForm.vue' | ||
| 6 | +import GenInfoFormVue from './GenInfoForm.vue' | ||
| 7 | import { ElTabs, ElTabPane, ElButton } from 'element-plus' | 7 | import { ElTabs, ElTabPane, ElButton } from 'element-plus' |
| 8 | import { getCodegenTableApi } from '@/api/infra/codegen' | 8 | import { getCodegenTableApi } from '@/api/infra/codegen' |
| 9 | import { useRouter, useRoute } from 'vue-router' | 9 | import { useRouter, useRoute } from 'vue-router' |
| @@ -38,7 +38,6 @@ const submitForm = async () => { | @@ -38,7 +38,6 @@ const submitForm = async () => { | ||
| 38 | console.info(basicInfoData) | 38 | console.info(basicInfoData) |
| 39 | console.info(genInfoData) | 39 | console.info(genInfoData) |
| 40 | } | 40 | } |
| 41 | - console.info(1) | ||
| 42 | } | 41 | } |
| 43 | onMounted(() => { | 42 | onMounted(() => { |
| 44 | getList() | 43 | getList() |
yudao-ui-admin-vue3/src/views/infra/codegen/components/GenInfoForm.vue
| @@ -47,6 +47,7 @@ const schema = reactive<FormSchema[]>([ | @@ -47,6 +47,7 @@ const schema = reactive<FormSchema[]>([ | ||
| 47 | label: '模块名', | 47 | label: '模块名', |
| 48 | field: 'moduleName', | 48 | field: 'moduleName', |
| 49 | component: 'Input', | 49 | component: 'Input', |
| 50 | + labelMessage: '模块名,即一级目录,例如 system、infra、tool 等等', | ||
| 50 | colProps: { | 51 | colProps: { |
| 51 | span: 12 | 52 | span: 12 |
| 52 | } | 53 | } |
| @@ -55,6 +56,7 @@ const schema = reactive<FormSchema[]>([ | @@ -55,6 +56,7 @@ const schema = reactive<FormSchema[]>([ | ||
| 55 | label: '业务名', | 56 | label: '业务名', |
| 56 | field: 'businessName', | 57 | field: 'businessName', |
| 57 | component: 'Input', | 58 | component: 'Input', |
| 59 | + labelMessage: '业务名,即二级目录,例如 user、permission、dict 等等', | ||
| 58 | colProps: { | 60 | colProps: { |
| 59 | span: 12 | 61 | span: 12 |
| 60 | } | 62 | } |
| @@ -63,6 +65,7 @@ const schema = reactive<FormSchema[]>([ | @@ -63,6 +65,7 @@ const schema = reactive<FormSchema[]>([ | ||
| 63 | label: '类名称', | 65 | label: '类名称', |
| 64 | field: 'className', | 66 | field: 'className', |
| 65 | component: 'Input', | 67 | component: 'Input', |
| 68 | + labelMessage: '类名称(首字母大写),例如SysUser、SysMenu、SysDictData 等等', | ||
| 66 | colProps: { | 69 | colProps: { |
| 67 | span: 12 | 70 | span: 12 |
| 68 | } | 71 | } |
| @@ -71,6 +74,7 @@ const schema = reactive<FormSchema[]>([ | @@ -71,6 +74,7 @@ const schema = reactive<FormSchema[]>([ | ||
| 71 | label: '类描述', | 74 | label: '类描述', |
| 72 | field: 'classComment', | 75 | field: 'classComment', |
| 73 | component: 'Input', | 76 | component: 'Input', |
| 77 | + labelMessage: '用作类描述,例如 用户', | ||
| 74 | colProps: { | 78 | colProps: { |
| 75 | span: 12 | 79 | span: 12 |
| 76 | } | 80 | } |
| @@ -79,6 +83,7 @@ const schema = reactive<FormSchema[]>([ | @@ -79,6 +83,7 @@ const schema = reactive<FormSchema[]>([ | ||
| 79 | label: '上级菜单', | 83 | label: '上级菜单', |
| 80 | field: 'parentMenuId', | 84 | field: 'parentMenuId', |
| 81 | component: 'Input', | 85 | component: 'Input', |
| 86 | + labelMessage: '分配到指定菜单下,例如 系统管理', | ||
| 82 | colProps: { | 87 | colProps: { |
| 83 | span: 12 | 88 | span: 12 |
| 84 | } | 89 | } |
yudao-ui-admin-vue3/src/views/infra/codegen/components/ImportTable.vue
| @@ -8,17 +8,18 @@ import { | @@ -8,17 +8,18 @@ import { | ||
| 8 | ElForm, | 8 | ElForm, |
| 9 | ElFormItem, | 9 | ElFormItem, |
| 10 | ElInput, | 10 | ElInput, |
| 11 | - ElEmpty | 11 | + ElSelect, |
| 12 | + ElOption | ||
| 12 | } from 'element-plus' | 13 | } from 'element-plus' |
| 13 | import { useI18n } from '@/hooks/web/useI18n' | 14 | import { useI18n } from '@/hooks/web/useI18n' |
| 14 | -import { useEmitt } from '@/hooks/web/useEmitt' | ||
| 15 | import { getDataSourceConfigListApi } from '@/api/infra/dataSourceConfig' | 15 | import { getDataSourceConfigListApi } from '@/api/infra/dataSourceConfig' |
| 16 | import type { DataSourceConfigVO } from '@/api/infra/dataSourceConfig/types' | 16 | import type { DataSourceConfigVO } from '@/api/infra/dataSourceConfig/types' |
| 17 | import type { DatabaseTableVO } from '@/api/infra/codegen/types' | 17 | import type { DatabaseTableVO } from '@/api/infra/codegen/types' |
| 18 | const { t } = useI18n() // 国际化 | 18 | const { t } = useI18n() // 国际化 |
| 19 | -const { emitter } = useEmitt() | 19 | +const emit = defineEmits(['ok']) |
| 20 | // ======== 显示页面 ======== | 20 | // ======== 显示页面 ======== |
| 21 | const visible = ref(false) | 21 | const visible = ref(false) |
| 22 | +const dbLoading = ref(true) | ||
| 22 | const queryParams = reactive({ | 23 | const queryParams = reactive({ |
| 23 | tableName: undefined, | 24 | tableName: undefined, |
| 24 | tableComment: undefined, | 25 | tableComment: undefined, |
| @@ -37,8 +38,10 @@ const dbTableList = ref<DatabaseTableVO[]>([]) | @@ -37,8 +38,10 @@ const dbTableList = ref<DatabaseTableVO[]>([]) | ||
| 37 | 38 | ||
| 38 | /** 查询表数据 */ | 39 | /** 查询表数据 */ |
| 39 | const getList = async () => { | 40 | const getList = async () => { |
| 41 | + dbLoading.value = true | ||
| 40 | const res = await getSchemaTableListApi(queryParams) | 42 | const res = await getSchemaTableListApi(queryParams) |
| 41 | dbTableList.value = res | 43 | dbTableList.value = res |
| 44 | + dbLoading.value = false | ||
| 42 | } | 45 | } |
| 43 | // 查询操作 | 46 | // 查询操作 |
| 44 | const handleQuery = async () => { | 47 | const handleQuery = async () => { |
| @@ -56,19 +59,18 @@ const handleSelectionChange = (val: DatabaseTableVO[]) => { | @@ -56,19 +59,18 @@ const handleSelectionChange = (val: DatabaseTableVO[]) => { | ||
| 56 | tables.value = val.map((item) => item.name) | 59 | tables.value = val.map((item) => item.name) |
| 57 | } | 60 | } |
| 58 | /** 导入按钮操作 */ | 61 | /** 导入按钮操作 */ |
| 59 | -const handleImportTable = () => { | 62 | +const handleImportTable = async () => { |
| 60 | if (tables.value.length === 0) { | 63 | if (tables.value.length === 0) { |
| 61 | ElMessage.error('请选择要导入的表') | 64 | ElMessage.error('请选择要导入的表') |
| 62 | return | 65 | return |
| 63 | } | 66 | } |
| 64 | - createCodegenListApi({ | 67 | + await createCodegenListApi({ |
| 65 | dataSourceConfigId: queryParams.dataSourceConfigId, | 68 | dataSourceConfigId: queryParams.dataSourceConfigId, |
| 66 | tableNames: tables.value | 69 | tableNames: tables.value |
| 67 | - }).then((res) => { | ||
| 68 | - ElMessage.success(res.msg) | ||
| 69 | - visible.value = false | ||
| 70 | - emitter.emit('ok') | ||
| 71 | }) | 70 | }) |
| 71 | + ElMessage.success('导入成功') | ||
| 72 | + visible.value = false | ||
| 73 | + emit('ok') | ||
| 72 | } | 74 | } |
| 73 | defineExpose({ | 75 | defineExpose({ |
| 74 | show | 76 | show |
| @@ -78,7 +80,7 @@ defineExpose({ | @@ -78,7 +80,7 @@ defineExpose({ | ||
| 78 | <!-- 导入表 --> | 80 | <!-- 导入表 --> |
| 79 | <Dialog title="导入表" v-model="visible" maxHeight="500px" width="50%"> | 81 | <Dialog title="导入表" v-model="visible" maxHeight="500px" width="50%"> |
| 80 | <el-form :model="queryParams" ref="queryRef" :inline="true"> | 82 | <el-form :model="queryParams" ref="queryRef" :inline="true"> |
| 81 | - <!-- <el-form-item label="数据源" prop="dataSourceConfigId"> | 83 | + <el-form-item label="数据源" prop="dataSourceConfigId"> |
| 82 | <el-select v-model="queryParams.dataSourceConfigId" placeholder="请选择数据源" clearable> | 84 | <el-select v-model="queryParams.dataSourceConfigId" placeholder="请选择数据源" clearable> |
| 83 | <el-option | 85 | <el-option |
| 84 | v-for="config in dataSourceConfigs" | 86 | v-for="config in dataSourceConfigs" |
| @@ -87,7 +89,7 @@ defineExpose({ | @@ -87,7 +89,7 @@ defineExpose({ | ||
| 87 | :value="config.id" | 89 | :value="config.id" |
| 88 | /> | 90 | /> |
| 89 | </el-select> | 91 | </el-select> |
| 90 | - </el-form-item> --> | 92 | + </el-form-item> |
| 91 | <el-form-item label="表名称" prop="tableName"> | 93 | <el-form-item label="表名称" prop="tableName"> |
| 92 | <el-input v-model="queryParams.tableName" placeholder="请输入表名称" clearable /> | 94 | <el-input v-model="queryParams.tableName" placeholder="请输入表名称" clearable /> |
| 93 | </el-form-item> | 95 | </el-form-item> |
| @@ -109,11 +111,9 @@ defineExpose({ | @@ -109,11 +111,9 @@ defineExpose({ | ||
| 109 | ref="table" | 111 | ref="table" |
| 110 | :data="dbTableList" | 112 | :data="dbTableList" |
| 111 | @selection-change="handleSelectionChange" | 113 | @selection-change="handleSelectionChange" |
| 114 | + v-loading="dbLoading" | ||
| 112 | height="400px" | 115 | height="400px" |
| 113 | > | 116 | > |
| 114 | - <template #empty> | ||
| 115 | - <el-empty description="加载中" /> | ||
| 116 | - </template> | ||
| 117 | <el-table-column type="selection" width="55" /> | 117 | <el-table-column type="selection" width="55" /> |
| 118 | <el-table-column prop="name" label="表名称" :show-overflow-tooltip="true" /> | 118 | <el-table-column prop="name" label="表名称" :show-overflow-tooltip="true" /> |
| 119 | <el-table-column prop="comment" label="表描述" :show-overflow-tooltip="true" /> | 119 | <el-table-column prop="comment" label="表描述" :show-overflow-tooltip="true" /> |
yudao-ui-admin-vue3/src/views/infra/codegen/components/index.ts
0 → 100644
| 1 | +import BasicInfoForm from './BasicInfoForm.vue' | ||
| 2 | +import CloumInfoForm from './CloumInfoForm.vue' | ||
| 3 | +import EditTable from './EditTable.vue' | ||
| 4 | +import GenInfoForm from './GenInfoForm.vue' | ||
| 5 | +import ImportTable from './ImportTable.vue' | ||
| 6 | +import Preview from './Preview.vue' | ||
| 7 | +export { BasicInfoForm, CloumInfoForm, EditTable, GenInfoForm, ImportTable, Preview } |
yudao-ui-admin-vue3/src/views/infra/codegen/index.vue
| @@ -6,8 +6,7 @@ import { useTable } from '@/hooks/web/useTable' | @@ -6,8 +6,7 @@ import { useTable } from '@/hooks/web/useTable' | ||
| 6 | import { CodegenTableVO } from '@/api/infra/codegen/types' | 6 | import { CodegenTableVO } from '@/api/infra/codegen/types' |
| 7 | import { allSchemas } from './codegen.data' | 7 | import { allSchemas } from './codegen.data' |
| 8 | import { useI18n } from '@/hooks/web/useI18n' | 8 | import { useI18n } from '@/hooks/web/useI18n' |
| 9 | -import ImportTable from './components/ImportTable.vue' | ||
| 10 | -import Preview from './components/Preview.vue' | 9 | +import { ImportTable, Preview } from './components' |
| 11 | import download from '@/utils/download' | 10 | import download from '@/utils/download' |
| 12 | import { useRouter } from 'vue-router' | 11 | import { useRouter } from 'vue-router' |
| 13 | import { useMessage } from '@/hooks/web/useMessage' | 12 | import { useMessage } from '@/hooks/web/useMessage' |
yudao-ui-admin/src/views/infra/codegen/index.vue
| @@ -85,7 +85,7 @@ | @@ -85,7 +85,7 @@ | ||
| 85 | 85 | ||
| 86 | <script> | 86 | <script> |
| 87 | import { getCodegenTablePage, previewCodegen, downloadCodegen, deleteCodegen, | 87 | import { getCodegenTablePage, previewCodegen, downloadCodegen, deleteCodegen, |
| 88 | - syncCodegenFromDB, syncCodegenFromSQL, createCodegenListFromSQL } from "@/api/infra/codegen"; | 88 | + syncCodegenFromDB } from "@/api/infra/codegen"; |
| 89 | 89 | ||
| 90 | import importTable from "./importTable"; | 90 | import importTable from "./importTable"; |
| 91 | // 代码高亮插件 | 91 | // 代码高亮插件 |