diff --git a/win-module-infra/win-module-infra-biz/src/main/java/com/win/module/infra/service/codegen/inner/CodegenEngine.java b/win-module-infra/win-module-infra-biz/src/main/java/com/win/module/infra/service/codegen/inner/CodegenEngine.java index fc9fc6da..a741984d 100644 --- a/win-module-infra/win-module-infra-biz/src/main/java/com/win/module/infra/service/codegen/inner/CodegenEngine.java +++ b/win-module-infra/win-module-infra-biz/src/main/java/com/win/module/infra/service/codegen/inner/CodegenEngine.java @@ -103,10 +103,12 @@ public class CodegenEngine { .put(CodegenFrontTypeEnum.VUE2.getType(), vueTemplatePath("api/api.js"), vueFilePath("api/${table.moduleName}/${classNameVar}.js")) // Vue3 标准模版 + .put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/data.ts"), + vue3FilePath("views/${table.moduleName}/${classNameVar}/${classNameVar}.data.ts")) .put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/index.vue"), vue3FilePath("views/${table.moduleName}/${classNameVar}/index.vue")) - .put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/form.vue"), - vue3FilePath("views/${table.moduleName}/${classNameVar}/${simpleClassName}Form.vue")) +// .put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/form.vue"), +// vue3FilePath("views/${table.moduleName}/${classNameVar}/${simpleClassName}Form.vue")) .put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("api/api.ts"), vue3FilePath("api/${table.moduleName}/${classNameVar}/index.ts")) // Vue3 Schema 模版 diff --git a/win-module-infra/win-module-infra-biz/src/main/resources/codegen/vue3/api/api.ts.vm b/win-module-infra/win-module-infra-biz/src/main/resources/codegen/vue3/api/api.ts.vm index 401796db..d88e8359 100644 --- a/win-module-infra/win-module-infra-biz/src/main/resources/codegen/vue3/api/api.ts.vm +++ b/win-module-infra/win-module-infra-biz/src/main/resources/codegen/vue3/api/api.ts.vm @@ -17,7 +17,13 @@ export interface ${simpleClassName}VO { // 查询${table.classComment}列表 export const get${simpleClassName}Page = async (params) => { - return await request.get({ url: `${baseURL}/page`, params }) + if (params.isSearch) { + delete params.isSearch + const data = {...params} + return await request.post({ url: '${baseURL}/senior', data }) + } else { + return await request.get({ url: `${baseURL}/page`, params }) + } } // 查询${table.classComment}详情 @@ -44,3 +50,8 @@ export const delete${simpleClassName} = async (id: number) => { export const export${simpleClassName} = async (params) => { return await request.download({ url: `${baseURL}/export-excel`, params }) } + +// 下载用户导入模板 +export const importTemplate = () => { + return request.download({ url: '/wms/${classNameVar}/get-import-template' }) +} \ No newline at end of file diff --git a/win-module-infra/win-module-infra-biz/src/main/resources/codegen/vue3/views/data.ts.vm b/win-module-infra/win-module-infra-biz/src/main/resources/codegen/vue3/views/data.ts.vm new file mode 100644 index 00000000..575616bf --- /dev/null +++ b/win-module-infra/win-module-infra-biz/src/main/resources/codegen/vue3/views/data.ts.vm @@ -0,0 +1,138 @@ +import type { CrudSchema } from '@/hooks/web/useCrudSchemas' +#foreach ($column in $columns) + #if ($column.listOperationResult && $column.htmlType == "datetime") +import { dateFormatter } from '@/utils/formatTime' + #break + #end +#end + +// 表单校验 +export const ${simpleClassName}Rules = reactive({ +#foreach ($column in $columns) +#if (($column.createOperation || $column.updateOperation) && !$column.nullable && !${column.primaryKey})## 创建或者更新操作 && 要求非空 && 非主键 +#set($comment=$column.columnComment) + $column.javaField: [required], +#end +#end +}) + +export const ${simpleClassName} = useCrudSchemas(reactive([ +#foreach($column in $columns) +#if ($column.listOperation || $column.listOperationResult || $column.createOperation || $column.updateOperation) +#set ($dictType = $column.dictType) +#set ($javaField = $column.javaField) +#set ($javaType = $column.javaType) + { + label: '${column.columnComment}', + field: '${column.javaField}', +## ========= 排序部分 ========= + sort: 'custom', +## ========= 字典部分 ========= + #if ("" != $dictType)## 有数据字典 + dictType: DICT_TYPE.$dictType.toUpperCase(), + dictClass: 'string', // 默认都是字符串类型其他暂不考虑 + #end +## ========= Table 表格部分 ========= + #if (!$column.listOperationResult) + isTable: false, + #else + #if ($column.htmlType == "datetime") + formatter: dateFormatter, + #end + #end +## ========= Search 表格部分 ========= + #if ($column.listOperation) + isSearch: true, + #if ($column.htmlType == "datetime") + search: { + component: 'DatePicker', + componentProps: { + valueFormat: 'YYYY-MM-DD HH:mm:ss', + type: 'daterange', + defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')] + } + }, + #end + #end +## ========= Form 表单部分 ========= + #if ((!$column.createOperation && !$column.updateOperation) || $column.primaryKey) + isForm: false, + #else + #if($column.htmlType == "imageUpload")## 图片上传 + form: { + component: 'UploadImg' + }, + #elseif($column.htmlType == "fileUpload")## 文件上传 + form: { + component: 'UploadFile' + }, + #elseif($column.htmlType == "editor")## 文本编辑器 + form: { + component: 'Editor', + componentProps: { + valueHtml: '', + height: 200 + } + }, + #elseif($column.htmlType == "select")## 下拉框 + #if($dictType.toUpperCase() == "TRUE_FALSE")## Switch开关 + form: { + component: 'Switch', + value: 'TRUE', + componentProps: { + inactiveValue: 'FALSE', + activeValue: 'TRUE' + } + }, + #else + form: { + component: 'SelectV2' + }, + #end + #elseif($column.htmlType == "checkbox")## 多选框 + form: { + component: 'Checkbox' + }, + #elseif($column.htmlType == "radio")## 单选框 + form: { + component: 'Radio' + }, + #elseif($column.htmlType == "datetime")## 时间框 + form: { + component: 'DatePicker', + componentProps: { + type: 'datetime', + valueFormat: 'x' + } + }, + #elseif($column.htmlType == "textarea")## 文本框 + form: { + component: 'Input', + componentProps: { + type: 'textarea', + rows: 4 + }, + colProps: { + span: 24 + } + }, + #elseif(${javaType.toLowerCase()} == "long" || ${javaType.toLowerCase()} == "integer")## 文本框 + form: { + component: 'InputNumber', + value: 0 + }, + #end + #end + }, +#end +#end + { + label: '操作', + field: 'action', + isForm: false, + table: { + width: 150, + fixed: 'right' + } + } +])) diff --git a/win-module-infra/win-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm b/win-module-infra/win-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm index e7eef8d0..eaf0d1af 100644 --- a/win-module-infra/win-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm +++ b/win-module-infra/win-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm @@ -1,255 +1,172 @@ diff --git a/win-module-infra/win-module-infra-biz/src/main/resources/codegen/vue3_back/api/api.ts.vm b/win-module-infra/win-module-infra-biz/src/main/resources/codegen/vue3_back/api/api.ts.vm new file mode 100644 index 00000000..401796db --- /dev/null +++ b/win-module-infra/win-module-infra-biz/src/main/resources/codegen/vue3_back/api/api.ts.vm @@ -0,0 +1,46 @@ +import request from '@/config/axios' +#set ($baseURL = "/${table.moduleName}/${simpleClassName_strikeCase}") + +export interface ${simpleClassName}VO { +#foreach ($column in $columns) +#if ($column.createOperation || $column.updateOperation) +#if(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer" || ${column.javaType.toLowerCase()} == "short" || ${column.javaType.toLowerCase()} == "double" || ${column.javaType.toLowerCase()} == "bigdecimal") + ${column.javaField}: number +#elseif(${column.javaType.toLowerCase()} == "date" || ${column.javaType.toLowerCase()} == "localdatetime") + ${column.javaField}: Date +#else + ${column.javaField}: ${column.javaType.toLowerCase()} +#end +#end +#end +} + +// 查询${table.classComment}列表 +export const get${simpleClassName}Page = async (params) => { + return await request.get({ url: `${baseURL}/page`, params }) +} + +// 查询${table.classComment}详情 +export const get${simpleClassName} = async (id: number) => { + return await request.get({ url: `${baseURL}/get?id=` + id }) +} + +// 新增${table.classComment} +export const create${simpleClassName} = async (data: ${simpleClassName}VO) => { + return await request.post({ url: `${baseURL}/create`, data }) +} + +// 修改${table.classComment} +export const update${simpleClassName} = async (data: ${simpleClassName}VO) => { + return await request.put({ url: `${baseURL}/update`, data }) +} + +// 删除${table.classComment} +export const delete${simpleClassName} = async (id: number) => { + return await request.delete({ url: `${baseURL}/delete?id=` + id }) +} + +// 导出${table.classComment} Excel +export const export${simpleClassName} = async (params) => { + return await request.download({ url: `${baseURL}/export-excel`, params }) +} diff --git a/win-module-infra/win-module-infra-biz/src/main/resources/codegen/vue3/views/form.vue.vm b/win-module-infra/win-module-infra-biz/src/main/resources/codegen/vue3_back/views/form.vue.vm similarity index 100% rename from win-module-infra/win-module-infra-biz/src/main/resources/codegen/vue3/views/form.vue.vm rename to win-module-infra/win-module-infra-biz/src/main/resources/codegen/vue3_back/views/form.vue.vm diff --git a/win-module-infra/win-module-infra-biz/src/main/resources/codegen/vue3_back/views/index.vue.vm b/win-module-infra/win-module-infra-biz/src/main/resources/codegen/vue3_back/views/index.vue.vm new file mode 100644 index 00000000..e7eef8d0 --- /dev/null +++ b/win-module-infra/win-module-infra-biz/src/main/resources/codegen/vue3_back/views/index.vue.vm @@ -0,0 +1,287 @@ + + +