【代码优化】INFRA:代码生成 vben5 antd 模版
This commit is contained in:
parent
380cc87ea4
commit
ed920f3fd3
|
@ -164,8 +164,6 @@ public class CodegenEngine {
|
||||||
.put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("views/modules/list_sub_erp.vue"), // 特殊:主子表专属逻辑
|
.put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("views/modules/list_sub_erp.vue"), // 特殊:主子表专属逻辑
|
||||||
vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName_strikeCase}-list.vue"))
|
vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName_strikeCase}-list.vue"))
|
||||||
// VUE3_VBEN5_ANTD
|
// VUE3_VBEN5_ANTD
|
||||||
.put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD.getType(), vue3Vben5AntdGeneralTemplatePath("views/data.ts"),
|
|
||||||
vue3FilePath("views/${table.moduleName}/${table.businessName}/data.ts"))
|
|
||||||
.put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD.getType(), vue3Vben5AntdGeneralTemplatePath("views/index.vue"),
|
.put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD.getType(), vue3Vben5AntdGeneralTemplatePath("views/index.vue"),
|
||||||
vue3FilePath("views/${table.moduleName}/${table.businessName}/index.vue"))
|
vue3FilePath("views/${table.moduleName}/${table.businessName}/index.vue"))
|
||||||
.put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD.getType(), vue3Vben5AntdGeneralTemplatePath("views/form.vue"),
|
.put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD.getType(), vue3Vben5AntdGeneralTemplatePath("views/form.vue"),
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import type { PageParam, PageResult } from '@vben/request';
|
import type { PageParam, PageResult } from '@vben/request';
|
||||||
|
import type { Dayjs } from 'dayjs';
|
||||||
|
|
||||||
import { requestClient } from '#/api/request';
|
import { requestClient } from '#/api/request';
|
||||||
#set ($baseURL = "/${table.moduleName}/${simpleClassName_strikeCase}")
|
#set ($baseURL = "/${table.moduleName}/${simpleClassName_strikeCase}")
|
||||||
|
@ -16,7 +17,7 @@ export namespace ${simpleClassName}Api {
|
||||||
#if(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer" || ${column.javaType.toLowerCase()} == "short" || ${column.javaType.toLowerCase()} == "double" || ${column.javaType.toLowerCase()} == "bigdecimal")
|
#if(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer" || ${column.javaType.toLowerCase()} == "short" || ${column.javaType.toLowerCase()} == "double" || ${column.javaType.toLowerCase()} == "bigdecimal")
|
||||||
${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: number; // ${column.columnComment}
|
${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: number; // ${column.columnComment}
|
||||||
#elseif(${column.javaType.toLowerCase()} == "date" || ${column.javaType.toLowerCase()} == "localdate" || ${column.javaType.toLowerCase()} == "localdatetime")
|
#elseif(${column.javaType.toLowerCase()} == "date" || ${column.javaType.toLowerCase()} == "localdate" || ${column.javaType.toLowerCase()} == "localdatetime")
|
||||||
${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: Date; // ${column.columnComment}
|
${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: string | Dayjs; // ${column.columnComment}
|
||||||
#else
|
#else
|
||||||
${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: ${column.javaType.toLowerCase()}; // ${column.columnComment}
|
${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: ${column.javaType.toLowerCase()}; // ${column.columnComment}
|
||||||
#end
|
#end
|
||||||
|
@ -32,7 +33,7 @@ export namespace ${simpleClassName}Api {
|
||||||
#if(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer" || ${column.javaType.toLowerCase()} == "short" || ${column.javaType.toLowerCase()} == "double" || ${column.javaType.toLowerCase()} == "bigdecimal")
|
#if(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer" || ${column.javaType.toLowerCase()} == "short" || ${column.javaType.toLowerCase()} == "double" || ${column.javaType.toLowerCase()} == "bigdecimal")
|
||||||
${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: number; // ${column.columnComment}
|
${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: number; // ${column.columnComment}
|
||||||
#elseif(${column.javaType.toLowerCase()} == "date" || ${column.javaType.toLowerCase()} == "localdate" || ${column.javaType.toLowerCase()} == "localdatetime")
|
#elseif(${column.javaType.toLowerCase()} == "date" || ${column.javaType.toLowerCase()} == "localdate" || ${column.javaType.toLowerCase()} == "localdatetime")
|
||||||
${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: Date; // ${column.columnComment}
|
${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: string | Dayjs; // ${column.columnComment}
|
||||||
#else
|
#else
|
||||||
${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: ${column.javaType.toLowerCase()}; // ${column.columnComment}
|
${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: ${column.javaType.toLowerCase()}; // ${column.columnComment}
|
||||||
#end
|
#end
|
||||||
|
|
|
@ -1,349 +0,0 @@
|
||||||
import type { VxeTableGridOptions } from '@vben/plugins/vxe-table';
|
|
||||||
import type { VbenFormSchema } from '#/adapter/form';
|
|
||||||
import type { OnActionClickFn } from '#/adapter/vxe-table';
|
|
||||||
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
|
||||||
|
|
||||||
import { z } from '#/adapter/form';
|
|
||||||
#if(${table.templateType} == 2)## 树表需要导入这些
|
|
||||||
import { get${simpleClassName}List } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
|
||||||
import { handleTree } from '#/utils/tree';
|
|
||||||
#end
|
|
||||||
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
|
||||||
import { getRangePickerDefaultProps } from '#/utils/date';
|
|
||||||
import { useAccess } from '@vben/access';
|
|
||||||
|
|
||||||
const { hasAccessByCodes } = useAccess();
|
|
||||||
|
|
||||||
/** 列表的搜索表单 */
|
|
||||||
export function useGridFormSchema(): VbenFormSchema[] {
|
|
||||||
return [
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#if ($column.listOperation)
|
|
||||||
#set ($dictType = $column.dictType)
|
|
||||||
#set ($javaType = $column.javaType)
|
|
||||||
#set ($javaField = $column.javaField)
|
|
||||||
#set ($comment = $column.columnComment)
|
|
||||||
#if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short")
|
|
||||||
#set ($dictMethod = "number")
|
|
||||||
#elseif ($javaType == "String")
|
|
||||||
#set ($dictMethod = "string")
|
|
||||||
#elseif ($javaType == "Boolean")
|
|
||||||
#set ($dictMethod = "boolean")
|
|
||||||
#end
|
|
||||||
{
|
|
||||||
fieldName: '${javaField}',
|
|
||||||
label: '${comment}',
|
|
||||||
#if ($column.htmlType == "input" || $column.htmlType == "textarea" || $column.htmlType == "editor")
|
|
||||||
component: 'Input',
|
|
||||||
componentProps: {
|
|
||||||
allowClear: true,
|
|
||||||
placeholder: '请输入${comment}',
|
|
||||||
},
|
|
||||||
#elseif ($column.htmlType == "select" || $column.htmlType == "radio")
|
|
||||||
component: 'Select',
|
|
||||||
componentProps: {
|
|
||||||
allowClear: true,
|
|
||||||
#if ("" != $dictType)## 设置了 dictType 数据字典的情况
|
|
||||||
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod'),
|
|
||||||
#else## 未设置 dictType 数据字典的情况
|
|
||||||
options: [],
|
|
||||||
#end
|
|
||||||
placeholder: '请选择${comment}',
|
|
||||||
},
|
|
||||||
#elseif($column.htmlType == "datetime")
|
|
||||||
component: 'RangePicker',
|
|
||||||
componentProps: {
|
|
||||||
...getRangePickerDefaultProps(),
|
|
||||||
allowClear: true,
|
|
||||||
},
|
|
||||||
#end
|
|
||||||
},
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 列表的字段 */
|
|
||||||
export function useGridColumns(
|
|
||||||
onActionClick?: OnActionClickFn<${simpleClassName}Api.${simpleClassName}>,
|
|
||||||
): VxeTableGridOptions<${simpleClassName}Api.${simpleClassName}>['columns'] {
|
|
||||||
return [
|
|
||||||
#if ($table.templateType == 12) ## 内嵌情况
|
|
||||||
{ type: 'expand', width: 80, slots: { content: 'expand_content' } },
|
|
||||||
#end
|
|
||||||
#foreach($column in $columns)
|
|
||||||
#if ($column.listOperationResult)
|
|
||||||
#set ($dictType = $column.dictType)
|
|
||||||
#set ($javaField = $column.javaField)
|
|
||||||
#set ($comment = $column.columnComment)
|
|
||||||
{
|
|
||||||
field: '${javaField}',
|
|
||||||
title: '${comment}',
|
|
||||||
minWidth: 120,
|
|
||||||
#if ($column.javaType == "LocalDateTime")## 时间类型
|
|
||||||
formatter: 'formatDateTime',
|
|
||||||
#elseif("" != $dictType)## 数据字典
|
|
||||||
cellRender: {
|
|
||||||
name: 'CellDict',
|
|
||||||
props: { type: DICT_TYPE.$dictType.toUpperCase() },
|
|
||||||
},
|
|
||||||
#end
|
|
||||||
#if (${table.templateType} == 2 && $column.id == $treeNameColumn.id)## 树表特有:标记树节点列
|
|
||||||
treeNode: true,
|
|
||||||
#end
|
|
||||||
},
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
{
|
|
||||||
field: 'operation',
|
|
||||||
title: '操作',
|
|
||||||
minWidth: 200,
|
|
||||||
align: 'center',
|
|
||||||
fixed: 'right',
|
|
||||||
headerAlign: 'center',
|
|
||||||
showOverflow: false,
|
|
||||||
cellRender: {
|
|
||||||
attrs: {
|
|
||||||
nameField: '${columns[0].javaField}',
|
|
||||||
nameTitle: '${table.classComment}',
|
|
||||||
onClick: onActionClick,
|
|
||||||
},
|
|
||||||
name: 'CellOperation',
|
|
||||||
options: [
|
|
||||||
#if (${table.templateType} == 2)## 树表特有操作
|
|
||||||
{
|
|
||||||
code: 'append',
|
|
||||||
text: '新增下级',
|
|
||||||
show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:create']),
|
|
||||||
},
|
|
||||||
#end
|
|
||||||
{
|
|
||||||
code: 'edit',
|
|
||||||
show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:update']),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
code: 'delete',
|
|
||||||
show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:delete']),
|
|
||||||
#if (${table.templateType} == 2)## 树表禁止删除带有子节点的数据
|
|
||||||
disabled: (row: ${simpleClassName}Api.${simpleClassName}) => {
|
|
||||||
return !!(row.children && row.children.length > 0);
|
|
||||||
},
|
|
||||||
#end
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
## 标准模式和内嵌模式时,主子关系一对一则生成表单schema,一对多则生成列表schema(内嵌模式时表单schema也要生成)。erp 模式时都生成
|
|
||||||
## 特殊:主子表专属逻辑
|
|
||||||
#foreach ($subTable in $subTables)
|
|
||||||
#set ($index = $foreach.count - 1)
|
|
||||||
#set ($subColumns = $subColumnsList.get($index))##当前字段数组
|
|
||||||
#set ($subSimpleClassName = $subSimpleClassNames.get($index))
|
|
||||||
#set ($subJoinColumn = $subJoinColumns.get($index))##当前 join 字段
|
|
||||||
#set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($index))
|
|
||||||
// ==================== 子表($subTable.classComment) ====================
|
|
||||||
|
|
||||||
#if ($table.templateType == 11) ## erp 情况
|
|
||||||
/** 列表的搜索表单 */
|
|
||||||
export function use${subSimpleClassName}GridFormSchema(): VbenFormSchema[] {
|
|
||||||
return [
|
|
||||||
#foreach($column in $subColumns)
|
|
||||||
#if ($column.listOperation)
|
|
||||||
#set ($dictType = $column.dictType)
|
|
||||||
#set ($javaType = $column.javaType)
|
|
||||||
#set ($javaField = $column.javaField)
|
|
||||||
#set ($comment = $column.columnComment)
|
|
||||||
#if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short")
|
|
||||||
#set ($dictMethod = "number")
|
|
||||||
#elseif ($javaType == "String")
|
|
||||||
#set ($dictMethod = "string")
|
|
||||||
#elseif ($javaType == "Boolean")
|
|
||||||
#set ($dictMethod = "boolean")
|
|
||||||
#end
|
|
||||||
{
|
|
||||||
fieldName: '${javaField}',
|
|
||||||
label: '${comment}',
|
|
||||||
#if ($column.htmlType == "input" || $column.htmlType == "textarea" || $column.htmlType == "editor")
|
|
||||||
component: 'Input',
|
|
||||||
componentProps: {
|
|
||||||
allowClear: true,
|
|
||||||
placeholder: '请输入${comment}',
|
|
||||||
},
|
|
||||||
#elseif ($column.htmlType == "select" || $column.htmlType == "radio")
|
|
||||||
component: 'Select',
|
|
||||||
componentProps: {
|
|
||||||
allowClear: true,
|
|
||||||
#if ("" != $dictType)## 设置了 dictType 数据字典的情况
|
|
||||||
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod'),
|
|
||||||
#else## 未设置 dictType 数据字典的情况
|
|
||||||
options: [],
|
|
||||||
#end
|
|
||||||
placeholder: '请选择${comment}',
|
|
||||||
},
|
|
||||||
#elseif($column.htmlType == "datetime")
|
|
||||||
component: 'RangePicker',
|
|
||||||
componentProps: {
|
|
||||||
...getRangePickerDefaultProps(),
|
|
||||||
allowClear: true,
|
|
||||||
},
|
|
||||||
#end
|
|
||||||
},
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 列表的字段 */
|
|
||||||
export function use${subSimpleClassName}GridColumns(
|
|
||||||
onActionClick?: OnActionClickFn<${simpleClassName}Api.${subSimpleClassName}>,
|
|
||||||
): VxeTableGridOptions<${simpleClassName}Api.${subSimpleClassName}>['columns'] {
|
|
||||||
return [
|
|
||||||
#foreach($column in $subColumns)
|
|
||||||
#if ($column.listOperationResult)
|
|
||||||
#set ($dictType = $column.dictType)
|
|
||||||
#set ($javaField = $column.javaField)
|
|
||||||
#set ($comment = $column.columnComment)
|
|
||||||
{
|
|
||||||
field: '${javaField}',
|
|
||||||
title: '${comment}',
|
|
||||||
minWidth: 120,
|
|
||||||
#if ($column.javaType == "LocalDateTime")## 时间类型
|
|
||||||
formatter: 'formatDateTime',
|
|
||||||
#elseif("" != $dictType)## 数据字典
|
|
||||||
cellRender: {
|
|
||||||
name: 'CellDict',
|
|
||||||
props: { type: DICT_TYPE.$dictType.toUpperCase() },
|
|
||||||
},
|
|
||||||
#end
|
|
||||||
},
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
{
|
|
||||||
field: 'operation',
|
|
||||||
title: '操作',
|
|
||||||
minWidth: 200,
|
|
||||||
align: 'center',
|
|
||||||
fixed: 'right',
|
|
||||||
headerAlign: 'center',
|
|
||||||
showOverflow: false,
|
|
||||||
cellRender: {
|
|
||||||
attrs: {
|
|
||||||
nameField: '${columns[0].javaField}',
|
|
||||||
nameTitle: '${subTable.classComment}',
|
|
||||||
onClick: onActionClick,
|
|
||||||
},
|
|
||||||
name: 'CellOperation',
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
code: 'edit',
|
|
||||||
show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:update']),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
code: 'delete',
|
|
||||||
show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:delete']),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
#if ($subTable.subJoinMany) ## 一对多
|
|
||||||
/** 新增/修改列表的字段 */
|
|
||||||
export function use${subSimpleClassName}GridEditColumns(
|
|
||||||
onActionClick?: OnActionClickFn<${simpleClassName}Api.${subSimpleClassName}>,
|
|
||||||
): VxeTableGridOptions<${simpleClassName}Api.${subSimpleClassName}>['columns'] {
|
|
||||||
return [
|
|
||||||
#foreach($column in $subColumns)
|
|
||||||
#if ($column.createOperation || $column.updateOperation)
|
|
||||||
#if (!$column.primaryKey && $column.listOperationResult && $column.id != $subJoinColumn.id) ## 特殊:忽略主子表的 join 字段,不用填写
|
|
||||||
#set ($dictType = $column.dictType)
|
|
||||||
#set ($javaField = $column.javaField)
|
|
||||||
#set ($comment = $column.columnComment)
|
|
||||||
#if ($javaType == "Integer" || $javaType == "Long" || $javaType == "Byte" || $javaType == "Short")
|
|
||||||
#set ($dictMethod = "number")
|
|
||||||
#elseif ($javaType == "String")
|
|
||||||
#set ($dictMethod = "string")
|
|
||||||
#elseif ($javaType == "Boolean")
|
|
||||||
#set ($dictMethod = "boolean")
|
|
||||||
#end
|
|
||||||
{
|
|
||||||
field: '${javaField}',
|
|
||||||
title: '${comment}',
|
|
||||||
minWidth: 120,
|
|
||||||
slots: { default: '${javaField}' },
|
|
||||||
#if ($column.htmlType == "select" || $column.htmlType == "checkbox" || $column.htmlType == "radio")
|
|
||||||
#if ("" != $dictType)## 有数据字典
|
|
||||||
params: {
|
|
||||||
options: getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod'),
|
|
||||||
},
|
|
||||||
#else
|
|
||||||
params: {
|
|
||||||
options: [],
|
|
||||||
},
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
},
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
{
|
|
||||||
field: 'operation',
|
|
||||||
title: '操作',
|
|
||||||
minWidth: 60,
|
|
||||||
align: 'center',
|
|
||||||
fixed: 'right',
|
|
||||||
headerAlign: 'center',
|
|
||||||
showOverflow: false,
|
|
||||||
cellRender: {
|
|
||||||
attrs: {
|
|
||||||
nameField: '${columns[0].javaField}',
|
|
||||||
nameTitle: '${table.classComment}',
|
|
||||||
onClick: onActionClick,
|
|
||||||
},
|
|
||||||
name: 'CellOperation',
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
code: 'delete',
|
|
||||||
show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:delete']),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
#if ($table.templateType == 12) ## 内嵌情况
|
|
||||||
/** 列表的字段 */
|
|
||||||
export function use${subSimpleClassName}GridColumns(): VxeTableGridOptions<${simpleClassName}Api.${subSimpleClassName}>['columns'] {
|
|
||||||
return [
|
|
||||||
#foreach($column in $subColumns)
|
|
||||||
#if ($column.listOperationResult)
|
|
||||||
#set ($dictType = $column.dictType)
|
|
||||||
#set ($javaField = $column.javaField)
|
|
||||||
#set ($comment = $column.columnComment)
|
|
||||||
{
|
|
||||||
field: '${javaField}',
|
|
||||||
title: '${comment}',
|
|
||||||
minWidth: 120,
|
|
||||||
#if ($column.javaType == "LocalDateTime")## 时间类型
|
|
||||||
formatter: 'formatDateTime',
|
|
||||||
#elseif("" != $dictType)## 数据字典
|
|
||||||
cellRender: {
|
|
||||||
name: 'CellDict',
|
|
||||||
props: { type: DICT_TYPE.$dictType.toUpperCase() },
|
|
||||||
},
|
|
||||||
#end
|
|
||||||
},
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
|
@ -25,9 +25,8 @@ import { $t } from '#/locales';
|
||||||
import { get${simpleClassName}, create${simpleClassName}, update${simpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import { get${simpleClassName}, create${simpleClassName}, update${simpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||||
|
|
||||||
const emit = defineEmits(['success']);
|
const emit = defineEmits(['success']);
|
||||||
|
|
||||||
const formRef = ref();
|
const formRef = ref();
|
||||||
const labelCol = { span: 5 };
|
|
||||||
const wrapperCol = { span: 13 };
|
|
||||||
const formData = ref<Partial<${simpleClassName}Api.${simpleClassName}>>({
|
const formData = ref<Partial<${simpleClassName}Api.${simpleClassName}>>({
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if ($column.createOperation || $column.updateOperation)
|
#if ($column.createOperation || $column.updateOperation)
|
||||||
|
@ -156,7 +155,6 @@ const [Modal, modalApi] = useVbenModal({
|
||||||
resetForm()
|
resetForm()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载数据
|
// 加载数据
|
||||||
let data = modalApi.getData<${simpleClassName}Api.${simpleClassName}>();
|
let data = modalApi.getData<${simpleClassName}Api.${simpleClassName}>();
|
||||||
if (!data) {
|
if (!data) {
|
||||||
|
@ -185,8 +183,8 @@ const [Modal, modalApi] = useVbenModal({
|
||||||
ref="formRef"
|
ref="formRef"
|
||||||
:model="formData"
|
:model="formData"
|
||||||
:rules="rules"
|
:rules="rules"
|
||||||
:label-col="labelCol"
|
:label-col="{ span: 5 }"
|
||||||
:wrapper-col="wrapperCol"
|
:wrapper-col="{ span: 18 }"
|
||||||
>
|
>
|
||||||
#foreach($column in $columns)
|
#foreach($column in $columns)
|
||||||
#if ($column.createOperation || $column.updateOperation)
|
#if ($column.createOperation || $column.updateOperation)
|
||||||
|
@ -239,9 +237,10 @@ const [Modal, modalApi] = useVbenModal({
|
||||||
<Select.Option
|
<Select.Option
|
||||||
v-for="dict in getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod')"
|
v-for="dict in getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod')"
|
||||||
:key="dict.value"
|
:key="dict.value"
|
||||||
:label="dict.label"
|
|
||||||
:value="dict.value"
|
:value="dict.value"
|
||||||
/>
|
>
|
||||||
|
{{ dict.label }}
|
||||||
|
</Select.Option>
|
||||||
#else##没数据字典
|
#else##没数据字典
|
||||||
<Select.Option label="请选择字典生成" value="" />
|
<Select.Option label="请选择字典生成" value="" />
|
||||||
#end
|
#end
|
||||||
|
@ -254,9 +253,10 @@ const [Modal, modalApi] = useVbenModal({
|
||||||
<Checkbox
|
<Checkbox
|
||||||
v-for="dict in getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod')"
|
v-for="dict in getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod')"
|
||||||
:key="dict.value"
|
:key="dict.value"
|
||||||
:label="dict.label"
|
|
||||||
:value="dict.value"
|
:value="dict.value"
|
||||||
/>
|
>
|
||||||
|
{{ dict.label }}
|
||||||
|
</Checkbox>
|
||||||
#else##没数据字典
|
#else##没数据字典
|
||||||
<Checkbox label="请选择字典生成" />
|
<Checkbox label="请选择字典生成" />
|
||||||
#end
|
#end
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||||
|
import type { VxeTableInstance } from 'vxe-table';
|
||||||
|
|
||||||
import { Page, useVbenModal } from '@vben/common-ui';
|
import { Page, useVbenModal } from '@vben/common-ui';
|
||||||
import { formatDateTime } from '@vben/utils';
|
import { cloneDeep, formatDateTime } from '@vben/utils';
|
||||||
import { Button, message,Tabs,Pagination,Form,RangePicker,DatePicker,Select,Input } from 'ant-design-vue';
|
import { Button, message,Tabs,Pagination,Form,RangePicker,DatePicker,Select,Input } from 'ant-design-vue';
|
||||||
import { DictTag } from '#/components/dict-tag';
|
import { DictTag } from '#/components/dict-tag';
|
||||||
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
||||||
|
@ -10,6 +11,7 @@ import ${simpleClassName}Form from './modules/form.vue';
|
||||||
import { Download, Plus, RefreshCw, Search } from '@vben/icons';
|
import { Download, Plus, RefreshCw, Search } from '@vben/icons';
|
||||||
import { ContentWrap } from "#/components/content-wrap";
|
import { ContentWrap } from "#/components/content-wrap";
|
||||||
import { VxeColumn, VxeTable } from 'vxe-table';
|
import { VxeColumn, VxeTable } from 'vxe-table';
|
||||||
|
import { TableToolbar } from '#/components/table-toolbar';
|
||||||
import { getRangePickerDefaultProps } from '#/utils/date';
|
import { getRangePickerDefaultProps } from '#/utils/date';
|
||||||
|
|
||||||
## 特殊:主子表专属逻辑
|
## 特殊:主子表专属逻辑
|
||||||
|
@ -21,7 +23,7 @@ import { getRangePickerDefaultProps } from '#/utils/date';
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
|
||||||
import { ref, h, reactive,onMounted } from 'vue';
|
import { ref, h, reactive,onMounted,nextTick } from 'vue';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
#if (${table.templateType} == 2)## 树表接口
|
#if (${table.templateType} == 2)## 树表接口
|
||||||
import { handleTree } from '@/utils/tree'
|
import { handleTree } from '@/utils/tree'
|
||||||
|
@ -69,12 +71,22 @@ const exportLoading = ref(false) // 导出的加载中
|
||||||
const getList = async () => {
|
const getList = async () => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
|
const params = cloneDeep(queryParams) as any;
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if ($column.listOperation)
|
||||||
|
#if ($column.htmlType == "datetime" || $column.listOperationCondition == "BETWEEN")
|
||||||
|
if (params.${column.javaField} && Array.isArray(params.${column.javaField})) {
|
||||||
|
params.${column.javaField} = (params.${column.javaField} as string[]).join(',');
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
## 特殊:树表专属逻辑(树不需要分页接口)
|
## 特殊:树表专属逻辑(树不需要分页接口)
|
||||||
#if ( $table.templateType == 2 )
|
#if ( $table.templateType == 2 )
|
||||||
const data = await get${simpleClassName}List(queryParams)
|
const data = await get${simpleClassName}List(params)
|
||||||
list.value = handleTree(data, 'id', '${treeParentColumn.javaField}')
|
list.value = handleTree(data, 'id', '${treeParentColumn.javaField}')
|
||||||
#else
|
#else
|
||||||
const data = await get${simpleClassName}Page(queryParams)
|
const data = await get${simpleClassName}Page(params)
|
||||||
list.value = data.list
|
list.value = data.list
|
||||||
total.value = data.total
|
total.value = data.total
|
||||||
#end
|
#end
|
||||||
|
@ -147,20 +159,30 @@ try {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 初始化 **/
|
/** 隐藏搜索栏 */
|
||||||
onMounted(() => {
|
const hiddenSearchBar = ref(false);
|
||||||
getList()
|
const tableToolbarRef = ref<InstanceType<typeof TableToolbar>>();
|
||||||
})
|
const tableRef = ref<VxeTableInstance>();
|
||||||
|
/** 初始化 */
|
||||||
|
onMounted(async () => {
|
||||||
|
await getList();
|
||||||
|
await nextTick();
|
||||||
|
// 挂载 toolbar 工具栏
|
||||||
|
const table = tableRef.value;
|
||||||
|
const tableToolbar = tableToolbarRef.value;
|
||||||
|
if (table && tableToolbar) {
|
||||||
|
await table.connect(tableToolbar.getToolbarRef()!);
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page auto-content-height>
|
<Page auto-content-height>
|
||||||
<FormModal @success="getList" />
|
<FormModal @success="getList" />
|
||||||
|
|
||||||
<ContentWrap>
|
<ContentWrap v-if="!hiddenSearchBar">
|
||||||
<!-- 搜索工作栏 -->
|
<!-- 搜索工作栏 -->
|
||||||
<Form
|
<Form
|
||||||
class="-mb-15px"
|
|
||||||
:model="queryParams"
|
:model="queryParams"
|
||||||
ref="queryFormRef"
|
ref="queryFormRef"
|
||||||
layout="inline"
|
layout="inline"
|
||||||
|
@ -185,7 +207,7 @@ onMounted(() => {
|
||||||
placeholder="请输入${comment}"
|
placeholder="请输入${comment}"
|
||||||
allowClear
|
allowClear
|
||||||
@pressEnter="handleQuery"
|
@pressEnter="handleQuery"
|
||||||
class="!w-240px"
|
class="w-full"
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
#elseif ($column.htmlType == "select" || $column.htmlType == "radio" || $column.htmlType == "checkbox")
|
#elseif ($column.htmlType == "select" || $column.htmlType == "radio" || $column.htmlType == "checkbox")
|
||||||
|
@ -194,15 +216,16 @@ onMounted(() => {
|
||||||
v-model:value="queryParams.${javaField}"
|
v-model:value="queryParams.${javaField}"
|
||||||
placeholder="请选择${comment}"
|
placeholder="请选择${comment}"
|
||||||
allowClear
|
allowClear
|
||||||
class="!w-240px"
|
class="w-full"
|
||||||
>
|
>
|
||||||
#if ("" != $dictType)## 设置了 dictType 数据字典的情况
|
#if ("" != $dictType)## 设置了 dictType 数据字典的情况
|
||||||
<Select.Option
|
<Select.Option
|
||||||
v-for="dict in getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod')"
|
v-for="dict in getDictOptions(DICT_TYPE.$dictType.toUpperCase(), '$dictMethod')"
|
||||||
:key="dict.value"
|
:key="dict.value"
|
||||||
:label="dict.label"
|
|
||||||
:value="dict.value"
|
:value="dict.value"
|
||||||
/>
|
>
|
||||||
|
{{ dict.label }}
|
||||||
|
</Select.Option>
|
||||||
#else## 未设置 dictType 数据字典的情况
|
#else## 未设置 dictType 数据字典的情况
|
||||||
<Select.Option label="请选择字典生成" value="" />
|
<Select.Option label="请选择字典生成" value="" />
|
||||||
#end
|
#end
|
||||||
|
@ -216,7 +239,7 @@ onMounted(() => {
|
||||||
valueFormat="YYYY-MM-DD"
|
valueFormat="YYYY-MM-DD"
|
||||||
placeholder="选择${comment}"
|
placeholder="选择${comment}"
|
||||||
allowClear
|
allowClear
|
||||||
class="!w-240px"
|
class="w-full"
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
#else## 范围
|
#else## 范围
|
||||||
|
@ -224,7 +247,7 @@ onMounted(() => {
|
||||||
<RangePicker
|
<RangePicker
|
||||||
v-model:value="queryParams.${javaField}"
|
v-model:value="queryParams.${javaField}"
|
||||||
v-bind="getRangePickerDefaultProps()"
|
v-bind="getRangePickerDefaultProps()"
|
||||||
class="!w-220px"
|
class="w-full"
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
#end
|
#end
|
||||||
|
@ -232,8 +255,21 @@ onMounted(() => {
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
<Form.Item>
|
<Form.Item>
|
||||||
<Button class="ml-2" @click="handleQuery" :icon="h(Search)">搜索</Button>
|
<Button class="ml-2" @click="resetQuery"> 重置 </Button>
|
||||||
<Button class="ml-2" @click="resetQuery" :icon="h(RefreshCw)">重置</Button>
|
<Button class="ml-2" @click="handleQuery" type="primary">
|
||||||
|
搜索
|
||||||
|
</Button>
|
||||||
|
</Form.Item>
|
||||||
|
</Form>
|
||||||
|
</ContentWrap>
|
||||||
|
|
||||||
|
<!-- 列表 -->
|
||||||
|
<ContentWrap title="${table.classComment}">
|
||||||
|
<template #extra>
|
||||||
|
<TableToolbar
|
||||||
|
ref="tableToolbarRef"
|
||||||
|
v-model:hidden-search="hiddenSearchBar"
|
||||||
|
>
|
||||||
<Button
|
<Button
|
||||||
class="ml-2"
|
class="ml-2"
|
||||||
:icon="h(Plus)"
|
:icon="h(Plus)"
|
||||||
|
@ -253,13 +289,9 @@ onMounted(() => {
|
||||||
>
|
>
|
||||||
{{ $t('ui.actionTitle.export') }}
|
{{ $t('ui.actionTitle.export') }}
|
||||||
</Button>
|
</Button>
|
||||||
</Form.Item>
|
</TableToolbar>
|
||||||
</Form>
|
</template>
|
||||||
</ContentWrap>
|
<vxe-table ref="tableRef" :data="list" show-overflow :loading="loading">
|
||||||
|
|
||||||
<!-- 列表 -->
|
|
||||||
<ContentWrap>
|
|
||||||
<vxe-table :data="list" show-overflow :loading="loading">
|
|
||||||
## 特殊:主子表专属逻辑
|
## 特殊:主子表专属逻辑
|
||||||
#if ( $table.templateType == 12 && $subTables && $subTables.size() > 0 )
|
#if ( $table.templateType == 12 && $subTables && $subTables.size() > 0 )
|
||||||
<!-- 子表的列表 -->
|
<!-- 子表的列表 -->
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import type { PageParam, PageResult } from '@vben/request';
|
import type { PageParam, PageResult } from '@vben/request';
|
||||||
|
import type { Dayjs } from 'dayjs';
|
||||||
|
|
||||||
import { requestClient } from '#/api/request';
|
import { requestClient } from '#/api/request';
|
||||||
#set ($baseURL = "/${table.moduleName}/${simpleClassName_strikeCase}")
|
#set ($baseURL = "/${table.moduleName}/${simpleClassName_strikeCase}")
|
||||||
|
@ -16,7 +17,7 @@ export namespace ${simpleClassName}Api {
|
||||||
#if(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer" || ${column.javaType.toLowerCase()} == "short" || ${column.javaType.toLowerCase()} == "double" || ${column.javaType.toLowerCase()} == "bigdecimal")
|
#if(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer" || ${column.javaType.toLowerCase()} == "short" || ${column.javaType.toLowerCase()} == "double" || ${column.javaType.toLowerCase()} == "bigdecimal")
|
||||||
${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: number; // ${column.columnComment}
|
${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: number; // ${column.columnComment}
|
||||||
#elseif(${column.javaType.toLowerCase()} == "date" || ${column.javaType.toLowerCase()} == "localdate" || ${column.javaType.toLowerCase()} == "localdatetime")
|
#elseif(${column.javaType.toLowerCase()} == "date" || ${column.javaType.toLowerCase()} == "localdate" || ${column.javaType.toLowerCase()} == "localdatetime")
|
||||||
${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: Date; // ${column.columnComment}
|
${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: string | Dayjs; // ${column.columnComment}
|
||||||
#else
|
#else
|
||||||
${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: ${column.javaType.toLowerCase()}; // ${column.columnComment}
|
${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: ${column.javaType.toLowerCase()}; // ${column.columnComment}
|
||||||
#end
|
#end
|
||||||
|
@ -32,7 +33,7 @@ export namespace ${simpleClassName}Api {
|
||||||
#if(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer" || ${column.javaType.toLowerCase()} == "short" || ${column.javaType.toLowerCase()} == "double" || ${column.javaType.toLowerCase()} == "bigdecimal")
|
#if(${column.javaType.toLowerCase()} == "long" || ${column.javaType.toLowerCase()} == "integer" || ${column.javaType.toLowerCase()} == "short" || ${column.javaType.toLowerCase()} == "double" || ${column.javaType.toLowerCase()} == "bigdecimal")
|
||||||
${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: number; // ${column.columnComment}
|
${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: number; // ${column.columnComment}
|
||||||
#elseif(${column.javaType.toLowerCase()} == "date" || ${column.javaType.toLowerCase()} == "localdate" || ${column.javaType.toLowerCase()} == "localdatetime")
|
#elseif(${column.javaType.toLowerCase()} == "date" || ${column.javaType.toLowerCase()} == "localdate" || ${column.javaType.toLowerCase()} == "localdatetime")
|
||||||
${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: Date; // ${column.columnComment}
|
${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: string | Dayjs; // ${column.columnComment}
|
||||||
#else
|
#else
|
||||||
${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: ${column.javaType.toLowerCase()}; // ${column.columnComment}
|
${column.javaField}#if($column.updateOperation && !$column.primaryKey && !$column.nullable)?#end: ${column.javaType.toLowerCase()}; // ${column.columnComment}
|
||||||
#end
|
#end
|
||||||
|
|
|
@ -21,24 +21,11 @@ import { useFormSchema } from '../data';
|
||||||
|
|
||||||
const emit = defineEmits(['success']);
|
const emit = defineEmits(['success']);
|
||||||
const formData = ref<${simpleClassName}Api.${simpleClassName}>();
|
const formData = ref<${simpleClassName}Api.${simpleClassName}>();
|
||||||
#if (${table.templateType} == 2)## 树表特有:父ID处理
|
|
||||||
const parentId = ref<number>(); // 新增下级时的父级 ID
|
|
||||||
|
|
||||||
const getTitle = computed(() => {
|
|
||||||
if (formData.value?.id) {
|
|
||||||
return $t('ui.actionTitle.edit', ['${table.classComment}']);
|
|
||||||
}
|
|
||||||
return parentId.value
|
|
||||||
? $t('ui.actionTitle.create', ['下级${table.classComment}'])
|
|
||||||
: $t('ui.actionTitle.create', ['${table.classComment}']);
|
|
||||||
});
|
|
||||||
#else## 标准表标题
|
|
||||||
const getTitle = computed(() => {
|
const getTitle = computed(() => {
|
||||||
return formData.value?.id
|
return formData.value?.id
|
||||||
? $t('ui.actionTitle.edit', ['${table.classComment}'])
|
? $t('ui.actionTitle.edit', ['${table.classComment}'])
|
||||||
: $t('ui.actionTitle.create', ['${table.classComment}']);
|
: $t('ui.actionTitle.create', ['${table.classComment}']);
|
||||||
});
|
});
|
||||||
#end
|
|
||||||
|
|
||||||
## 特殊:主子表专属逻辑
|
## 特殊:主子表专属逻辑
|
||||||
#if ( $table.templateType == 10 || $table.templateType == 12 )
|
#if ( $table.templateType == 10 || $table.templateType == 12 )
|
||||||
|
@ -121,7 +108,6 @@ const [Modal, modalApi] = useVbenModal({
|
||||||
formData.value = undefined;
|
formData.value = undefined;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载数据
|
// 加载数据
|
||||||
let data = modalApi.getData<${simpleClassName}Api.${simpleClassName}>();
|
let data = modalApi.getData<${simpleClassName}Api.${simpleClassName}>();
|
||||||
if (!data) {
|
if (!data) {
|
||||||
|
|
Loading…
Reference in New Issue