From df69fecbb4a7fbd3b671dd22b72e17258dc3c82c Mon Sep 17 00:00:00 2001 From: puhui999 Date: Fri, 17 Nov 2023 17:03:35 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90?= =?UTF-8?q?=EF=BC=9A=E9=87=8D=E6=9E=84=20vue2=20=E6=A8=A1=E7=89=88?= =?UTF-8?q?=EF=BC=8C=E9=80=82=E9=85=8D=E6=A0=91=E8=A1=A8=E5=92=8C=E4=B8=BB?= =?UTF-8?q?=E5=AD=90=E8=A1=A8=EF=BC=8880%=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql/ruoyi-vue-pro.sql | 5 + .../main/resources/codegen/vue/api/api.js.vm | 102 ++++- .../vue/views/components/form_sub_erp.vue.vm | 204 ++++++++++ .../views/components/form_sub_inner.vue.vm | 2 + .../views/components/form_sub_normal.vue.vm | 362 ++++++++++++++++++ .../vue/views/components/list_sub_erp.vue.vm | 181 +++++++++ .../views/components/list_sub_inner.vue.vm | 4 + .../resources/codegen/vue/views/form.vue.vm | 333 ++++++++++++++++ .../resources/codegen/vue/views/index.vue.vm | 340 ++++++++-------- .../resources/codegen/vue3/views/form.vue.vm | 2 + .../resources/codegen/vue3/views/index.vue.vm | 12 +- .../src/main/resources/application-local.yaml | 8 +- 12 files changed, 1351 insertions(+), 204 deletions(-) create mode 100644 yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_erp.vue.vm create mode 100644 yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_inner.vue.vm create mode 100644 yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_normal.vue.vm create mode 100644 yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/list_sub_erp.vue.vm create mode 100644 yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/list_sub_inner.vue.vm create mode 100644 yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/form.vue.vm diff --git a/sql/mysql/ruoyi-vue-pro.sql b/sql/mysql/ruoyi-vue-pro.sql index 7b13fbec0a..ce201e19be 100644 --- a/sql/mysql/ruoyi-vue-pro.sql +++ b/sql/mysql/ruoyi-vue-pro.sql @@ -450,6 +450,11 @@ CREATE TABLE `infra_codegen_table` ( `template_type` tinyint NOT NULL DEFAULT 1 COMMENT '模板类型', `front_type` tinyint NOT NULL COMMENT '前端类型', `parent_menu_id` bigint NULL DEFAULT NULL COMMENT '父菜单编号', + `master_table_id` bigint NULL DEFAULT NULL COMMENT '主表的编号', + `sub_join_column_id` bigint NULL DEFAULT NULL COMMENT '【自己】子表关联主表的字段编号', + `sub_join_many` bit(1) NULL DEFAULT NULL COMMENT '主表与子表是否一对多', + `tree_parent_column_id` bigint NULL DEFAULT NULL COMMENT '树表的父字段编号', + `tree_name_column_id` bigint NULL DEFAULT NULL COMMENT '树表的名字字段编号', `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/api/api.js.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/api/api.js.vm index 5e9da3238c..fdafffd540 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/api/api.js.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/api/api.js.vm @@ -35,21 +35,113 @@ export function get${simpleClassName}(id) { }) } +#if ( $table.templateType != 2 ) // 获得${table.classComment}分页 -export function get${simpleClassName}Page(query) { +export function get${simpleClassName}Page(params) { return request({ url: '${baseURL}/page', method: 'get', - params: query + params }) } - +#else +// 获得${table.classComment}列表 +export function get${simpleClassName}List(params) { + return request({ + url: '${baseURL}/list', + method: 'get', + params + }) +} +#end // 导出${table.classComment} Excel -export function export${simpleClassName}Excel(query) { +export function export${simpleClassName}Excel(params) { return request({ url: '${baseURL}/export-excel', method: 'get', - params: query, + params, responseType: 'blob' }) } +## 特殊:主子表专属逻辑 +#foreach ($subTable in $subTables) + #set ($index = $foreach.count - 1) + #set ($subSimpleClassName = $subSimpleClassNames.get($index)) + #set ($subPrimaryColumn = $subPrimaryColumns.get($index))##当前 primary 字段 + #set ($subJoinColumn = $subJoinColumns.get($index))##当前 join 字段 + #set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写 + #set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($index)) + #set ($subJoinColumn_strikeCase = $subJoinColumn_strikeCases.get($index)) + #set ($subClassNameVar = $subClassNameVars.get($index)) + +// ==================== 子表($subTable.classComment) ==================== + ## 情况一:MASTER_ERP 时,需要分查询页子表 + #if ( $table.templateType == 11 ) + + // 获得${subTable.classComment}分页 + export function get${simpleClassName}Page(params) { + return request({ + url: '${baseURL}/${subSimpleClassName_strikeCase}/page', + method: 'get', + params + }) + } + ## 情况二:非 MASTER_ERP 时,需要列表查询子表 + #else + #if ( $subTable.subJoinMany ) + + // 获得${subTable.classComment}列表 + export function get${subSimpleClassName}ListBy${SubJoinColumnName}(${subJoinColumn.javaField}) { + return request({ + url: `${baseURL}/${subSimpleClassName_strikeCase}/list-by-${subJoinColumn_strikeCase}?${subJoinColumn.javaField}=` + ${subJoinColumn.javaField}, + method: 'get' + }) + } + #else + + // 获得${subTable.classComment} + export function get${subSimpleClassName}By${SubJoinColumnName}(${subJoinColumn.javaField}) { + return request({ + url: `${baseURL}/${subSimpleClassName_strikeCase}/get-by-${subJoinColumn_strikeCase}?${subJoinColumn.javaField}=` + ${subJoinColumn.javaField}, + method: 'get' + }) + } + #end + #end + ## 特殊:MASTER_ERP 时,支持单个的新增、修改、删除操作 + #if ( $table.templateType == 11 ) + // 新增${subTable.classComment} + export function create${subSimpleClassName}(data) { + return request({ + url: `${baseURL}/${subSimpleClassName_strikeCase}/create`, + method: 'post', + data + }) + } + + // 修改${subTable.classComment} + export function update${subSimpleClassName}(data) { + return request({ + url: `${baseURL}/${subSimpleClassName_strikeCase}/update`, + method: 'post', + data + }) + } + + // 删除${subTable.classComment} + export function delete${subSimpleClassName}(id) { + return request({ + url: `${baseURL}/${subSimpleClassName_strikeCase}/delete?id=` + id, + method: 'delete' + }) + } + + // 获得${subTable.classComment} + export function get${subSimpleClassName}(id) { + return request({ + url: `${baseURL}/${subSimpleClassName_strikeCase}/get?id=` + id, + method: 'get' + }) + } + #end +#end \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_erp.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_erp.vue.vm new file mode 100644 index 0000000000..c1b4a0a0f5 --- /dev/null +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_erp.vue.vm @@ -0,0 +1,204 @@ +#set ($subColumns = $subColumnsList.get($subIndex))##当前字段数组 +#set ($subSimpleClassName = $subSimpleClassNames.get($subIndex)) +#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段 + + \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_inner.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_inner.vue.vm new file mode 100644 index 0000000000..d8542c3d5c --- /dev/null +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_inner.vue.vm @@ -0,0 +1,2 @@ +## 主表的 normal 和 inner 使用相同的 form 表单 +#parse("codegen/vue3/views/components/form_sub_normal.vue.vm") \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_normal.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_normal.vue.vm new file mode 100644 index 0000000000..90df798124 --- /dev/null +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_normal.vue.vm @@ -0,0 +1,362 @@ +#set ($subTable = $subTables.get($subIndex))##当前表 +#set ($subColumns = $subColumnsList.get($subIndex))##当前字段数组 +#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段 +#set ($subSimpleClassName = $subSimpleClassNames.get($subIndex)) +#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段 +#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写 + + \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/list_sub_erp.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/list_sub_erp.vue.vm new file mode 100644 index 0000000000..5ad208b3b4 --- /dev/null +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/list_sub_erp.vue.vm @@ -0,0 +1,181 @@ +#set ($subTable = $subTables.get($subIndex))##当前表 +#set ($subColumns = $subColumnsList.get($subIndex))##当前字段数组 +#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段 +#set ($subSimpleClassName = $subSimpleClassNames.get($subIndex)) +#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段 +#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写 + + \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/list_sub_inner.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/list_sub_inner.vue.vm new file mode 100644 index 0000000000..3fe648892a --- /dev/null +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/list_sub_inner.vue.vm @@ -0,0 +1,4 @@ +## 子表的 erp 和 inner 使用相似的 list 列表,差异主要两点: +## 1)inner 使用 list 不分页,erp 使用 page 分页 +## 2)erp 支持单个子表的新增、修改、删除,inner 不支持 +#parse("codegen/vue3/views/components/list_sub_erp.vue.vm") \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/form.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/form.vue.vm new file mode 100644 index 0000000000..7be0ed089d --- /dev/null +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/form.vue.vm @@ -0,0 +1,333 @@ + + + diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/index.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/index.vue.vm index 7a6add604e..58b41890d7 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/index.vue.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/index.vue.vm @@ -47,18 +47,67 @@ - 新增 导出 + #if ( $table.templateType == 2 ) + + + 展开/折叠 + + + #end - - + ## 特殊:主子表专属逻辑 TODO puhui999: 普通模式 + #if ( $table.templateType == 11 && $subTables && $subTables.size() > 0 ) + + ## 特殊:树表专属逻辑 + #elseif ( $table.templateType == 2 ) + + #else + + #end + ## 特殊:主子表专属逻辑 TODO puhui999: 内嵌模式 + #if ( $table.templateType == 12 && $subTables && $subTables.size() > 0 ) + + + + + #end #foreach($column in $columns) #if ($column.listOperationResult) #set ($dictType=$column.dictType) @@ -84,7 +133,7 @@ #end diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/form.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/form.vue.vm index 5536c39c4c..432a968f87 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/form.vue.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/form.vue.vm @@ -146,9 +146,11 @@ import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.busine import { defaultProps, handleTree } from '@/utils/tree' #end ## 特殊:主子表专属逻辑 +#if ( $subTables && $subTables.size() > 0 ) #foreach ($subSimpleClassName in $subSimpleClassNames) import ${subSimpleClassName}Form from './components/${subSimpleClassName}Form.vue' #end +#end const { t } = useI18n() // 国际化 const message = useMessage() // 消息弹窗 diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm index eab90c12a3..13c4480543 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm @@ -113,7 +113,7 @@ -## 特殊:主子表专属逻辑 +## 特殊:主子表专属逻辑 TODO puhui999: 普通模式 #if ( $table.templateType == 11 && $subTables && $subTables.size() > 0 ) #end -## 特殊:主子表专属逻辑 +## 特殊:主子表专属逻辑 TODO puhui999: 内嵌模式 #if ( $table.templateType == 12 && $subTables && $subTables.size() > 0 ) @@ -213,7 +213,7 @@ <${simpleClassName}Form ref="formRef" @success="getList" /> -## 特殊:主子表专属逻辑 +## 特殊:主子表专属逻辑 TODO puhui999: ERP 模式 #if ( $table.templateType == 11 && $subTables && $subTables.size() > 0 ) @@ -243,7 +243,7 @@ import download from '@/utils/download' import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}' import ${simpleClassName}Form from './${simpleClassName}Form.vue' ## 特殊:主子表专属逻辑 -#if ( $table.templateType != 10 ) +#if ( $subTables && $subTables.size() > 0 ) #foreach ($subSimpleClassName in $subSimpleClassNames) import ${subSimpleClassName}List from './components/${subSimpleClassName}List.vue' #end @@ -343,9 +343,9 @@ const handleExport = async () => { exportLoading.value = false } } -## 特殊:主子表专属逻辑 -#if ( $table.templateType == 11 ) +## 特殊:主子表专属逻辑 +#if ( $subTables && $subTables.size() > 0 ) /** 选中行操作 */ const currentRow = ref({}) // 选中行 const handleCurrentChange = (row) => { diff --git a/yudao-server/src/main/resources/application-local.yaml b/yudao-server/src/main/resources/application-local.yaml index f15b0cf8dd..264ad7e107 100644 --- a/yudao-server/src/main/resources/application-local.yaml +++ b/yudao-server/src/main/resources/application-local.yaml @@ -48,7 +48,7 @@ spring: primary: master datasource: master: - name: ruoyi-vue-pro + name: ruoyi-vue-pro4 url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 # url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT # MySQL Connector/J 5.X 连接的示例 # url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.master.name} # PostgreSQL 连接的示例 @@ -62,7 +62,7 @@ spring: # username: SYSDBA # DM 连接的示例 # password: SYSDBA # DM 连接的示例 slave: # 模拟从库,可根据自己需要修改 - name: ruoyi-vue-pro + name: ruoyi-vue-pro4 lazy: true # 开启懒加载,保证启动速度 url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 # url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT # MySQL Connector/J 5.X 连接的示例 @@ -78,8 +78,8 @@ spring: redis: host: 127.0.0.1 # 地址 port: 6379 # 端口 - database: 0 # 数据库索引 -# password: dev # 密码,建议生产环境开启 + database: 4 # 数据库索引 + password: 123456 # 密码,建议生产环境开启 --- #################### 定时任务相关配置 #################### From a88c93fc609a3e435a98e492b53b4612a5297f57 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Fri, 17 Nov 2023 18:18:27 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90?= =?UTF-8?q?=EF=BC=9A=E9=87=8D=E6=9E=84=20vue2=20=E6=A8=A1=E7=89=88?= =?UTF-8?q?=EF=BC=8C=E9=80=82=E9=85=8D=E6=A0=91=E8=A1=A8=E5=92=8C=E4=B8=BB?= =?UTF-8?q?=E5=AD=90=E8=A1=A8=EF=BC=8890%=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vue/views/components/form_sub_erp.vue.vm | 400 ++++++------ .../views/components/form_sub_inner.vue.vm | 2 +- .../views/components/form_sub_normal.vue.vm | 570 +++++++----------- .../views/components/list_sub_inner.vue.vm | 2 +- 4 files changed, 431 insertions(+), 543 deletions(-) diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_erp.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_erp.vue.vm index c1b4a0a0f5..2293189f6e 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_erp.vue.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_erp.vue.vm @@ -2,203 +2,211 @@ #set ($subSimpleClassName = $subSimpleClassNames.get($subIndex)) #set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段 - \ No newline at end of file + #if ($hasEditorColumn) + import Editor from '@/components/Editor'; + #end + export default { + name: "${simpleClassName}", + components: { + #if ($hasImageUploadColumn) + ImageUpload, + #end + #if ($hasFileUploadColumn) + FileUpload, + #end + #if ($hasEditorColumn) + Editor, + #end + }, + data() { + return { + // 弹出层标题 + dialogTitle: "", + // 是否显示弹出层 + dialogVisible: false, + // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用 + formLoading: false, + // 表单参数 + formData: { + #foreach ($column in $columns) + #if ($column.createOperation || $column.updateOperation) + #if ($column.htmlType == "checkbox") + $column.javaField: [], + #else + $column.javaField: undefined, + #end + #end + #end + }, + // 表单校验 + formRules: { + #foreach ($column in $columns) + #if (($column.createOperation || $column.updateOperation) && !$column.nullable && !${column.primaryKey})## 创建或者更新操作 && 要求非空 && 非主键 + #set($comment=$column.columnComment) + $column.javaField: [{ required: true, message: "${comment}不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#end }], + #end + #end + }, + }; + }, + methods: { + /** 表单重置 */ + reset() { + this.formData = { + #foreach ($column in $columns) + #if ($column.createOperation || $column.updateOperation) + #if ($column.htmlType == "checkbox") + $column.javaField: [], + #else + $column.javaField: undefined, + #end + #end + #end + }; + this.resetForm("formRef"); + }, + /** 打开弹窗 */ + open(id) { + this.dialogVisible = true; + this.reset(); + const that = this; + // 修改时,设置数据 + if (id) { + this.formLoading = true; + try { + ${simpleClassName}Api.get${subSimpleClassName}(id).then(res=>{ + that.formData = res.data; + that.title = "修改${table.classComment}"; + }) + } finally { + this.formLoading = false; + } + } + this.title = "新增${table.classComment}"; + }, + /** 提交按钮 */ + submitForm() { + this.formLoading = true; + try { + let data = this.formData; + this.#[[$]]#refs["formRef"].validate(valid => { + if (!valid) { + return; + } + // 修改的提交 + if (data.${primaryColumn.javaField}) { + ${simpleClassName}Api.update${simpleClassName}(data).then(response => { + this.#[[$modal]]#.msgSuccess("修改成功"); + this.dialogVisible = false; + this.#[[$]]#emit('success'); + }); + return; + } + // 添加的提交 + ${simpleClassName}Api.create${simpleClassName}(data).then(response => { + this.#[[$modal]]#.msgSuccess("新增成功"); + this.dialogVisible = false; + this.#[[$]]#emit('success'); + }); + }); + }finally { + this.formLoading = false + } + } + } + }; + diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_inner.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_inner.vue.vm index d8542c3d5c..ca266be9d0 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_inner.vue.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_inner.vue.vm @@ -1,2 +1,2 @@ ## 主表的 normal 和 inner 使用相同的 form 表单 -#parse("codegen/vue3/views/components/form_sub_normal.vue.vm") \ No newline at end of file +#parse("codegen/vue/views/components/form_sub_normal.vue.vm") \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_normal.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_normal.vue.vm index 90df798124..b3f0a332b9 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_normal.vue.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_normal.vue.vm @@ -4,359 +4,239 @@ #set ($subSimpleClassName = $subSimpleClassNames.get($subIndex)) #set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段 #set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写 + - \ No newline at end of file + }; + diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/list_sub_inner.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/list_sub_inner.vue.vm index 3fe648892a..90b8e41535 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/list_sub_inner.vue.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/list_sub_inner.vue.vm @@ -1,4 +1,4 @@ ## 子表的 erp 和 inner 使用相似的 list 列表,差异主要两点: ## 1)inner 使用 list 不分页,erp 使用 page 分页 ## 2)erp 支持单个子表的新增、修改、删除,inner 不支持 -#parse("codegen/vue3/views/components/list_sub_erp.vue.vm") \ No newline at end of file +#parse("codegen/vue/views/components/list_sub_erp.vue.vm") \ No newline at end of file From 80db28ee5bccf8612394e48b9f9d6e9c58d42da7 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Tue, 21 Nov 2023 10:49:43 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90?= =?UTF-8?q?=EF=BC=9A=E9=87=8D=E6=9E=84=20vue2=20=E6=A8=A1=E7=89=88?= =?UTF-8?q?=EF=BC=8C=E9=80=82=E9=85=8D=E6=A0=91=E8=A1=A8=E5=92=8C=E4=B8=BB?= =?UTF-8?q?=E5=AD=90=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/codegen/inner/CodegenEngine.java | 14 +- .../vue/views/components/form_sub_erp.vue.vm | 86 +-- .../views/components/form_sub_normal.vue.vm | 214 ++++-- .../vue/views/components/list_sub_erp.vue.vm | 319 ++++----- .../resources/codegen/vue/views/form.vue.vm | 294 ++++---- .../resources/codegen/vue/views/index.vue.vm | 25 +- .../resources/codegen/vue3/views/form.vue.vm | 540 +++++++-------- .../resources/codegen/vue3/views/index.vue.vm | 647 +++++++++--------- .../codegen/inner/CodegenEngineVue2Test.java | 202 ++++++ 9 files changed, 1342 insertions(+), 999 deletions(-) create mode 100644 yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineVue2Test.java diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java index 4ce4c2f98b..933b27a46e 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java @@ -104,6 +104,18 @@ public class CodegenEngine { vueFilePath("views/${table.moduleName}/${table.businessName}/index.vue")) .put(CodegenFrontTypeEnum.VUE2.getType(), vueTemplatePath("api/api.js"), vueFilePath("api/${table.moduleName}/${classNameVar}.js")) + .put(CodegenFrontTypeEnum.VUE2.getType(), vueTemplatePath("views/form.vue"), + vueFilePath("views/${table.moduleName}/${table.businessName}/${simpleClassName}Form.vue")) + .put(CodegenFrontTypeEnum.VUE2.getType(), vueTemplatePath("views/components/form_sub_normal.vue"), // 特殊:主子表专属逻辑 + vueFilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}Form.vue")) + .put(CodegenFrontTypeEnum.VUE2.getType(), vueTemplatePath("views/components/form_sub_inner.vue"), // 特殊:主子表专属逻辑 + vueFilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}Form.vue")) + .put(CodegenFrontTypeEnum.VUE2.getType(), vueTemplatePath("views/components/form_sub_erp.vue"), // 特殊:主子表专属逻辑 + vueFilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}Form.vue")) + .put(CodegenFrontTypeEnum.VUE2.getType(), vueTemplatePath("views/components/list_sub_inner.vue"), // 特殊:主子表专属逻辑 + vueFilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}List.vue")) + .put(CodegenFrontTypeEnum.VUE2.getType(), vueTemplatePath("views/components/list_sub_erp.vue"), // 特殊:主子表专属逻辑 + vueFilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}List.vue")) // Vue3 标准模版 .put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/index.vue"), vue3FilePath("views/${table.moduleName}/${table.businessName}/index.vue")) @@ -452,7 +464,7 @@ public class CodegenEngine { } private static String vueFilePath(String path) { - return "yudao-ui-${sceneEnum.basePackage}/" + // 顶级目录 + return "yudao-ui-${sceneEnum.basePackage}-vue2/" + // 顶级目录 "src/" + path; } diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_erp.vue.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_erp.vue.vm index 2293189f6e..eb7c45b3b8 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_erp.vue.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue/views/components/form_sub_erp.vue.vm @@ -4,8 +4,8 @@