Pre Merge pull request !1328 from puhui999/master-jdk17
This commit is contained in:
commit
493d8f6dd5
|
@ -154,15 +154,15 @@ public class CodegenEngine {
|
||||||
.put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("api/api.ts"),
|
.put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("api/api.ts"),
|
||||||
vue3FilePath("api/${table.moduleName}/${table.businessName}/index.ts"))
|
vue3FilePath("api/${table.moduleName}/${table.businessName}/index.ts"))
|
||||||
.put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("views/modules/form_sub_normal.vue"), // 特殊:主子表专属逻辑
|
.put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("views/modules/form_sub_normal.vue"), // 特殊:主子表专属逻辑
|
||||||
vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName}Form.vue"))
|
vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName_strikeCase}-form.vue"))
|
||||||
.put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("views/modules/form_sub_inner.vue"), // 特殊:主子表专属逻辑
|
.put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("views/modules/form_sub_inner.vue"), // 特殊:主子表专属逻辑
|
||||||
vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName}Form.vue"))
|
vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName_strikeCase}-form.vue"))
|
||||||
.put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("views/modules/form_sub_erp.vue"), // 特殊:主子表专属逻辑
|
.put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("views/modules/form_sub_erp.vue"), // 特殊:主子表专属逻辑
|
||||||
vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName}Form.vue"))
|
vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName_strikeCase}-form.vue"))
|
||||||
.put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("views/modules/list_sub_inner.vue"), // 特殊:主子表专属逻辑
|
.put(CodegenFrontTypeEnum.VUE3_VBEN5_ANTD_SCHEMA.getType(), vue3Vben5AntdSchemaTemplatePath("views/modules/list_sub_inner.vue"), // 特殊:主子表专属逻辑
|
||||||
vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName}List.vue"))
|
vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName_strikeCase}-list.vue"))
|
||||||
.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}List.vue"))
|
vue3FilePath("views/${table.moduleName}/${table.businessName}/modules/${subSimpleClassName_strikeCase}-list.vue"))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -451,6 +451,8 @@ public class CodegenEngine {
|
||||||
filePath = StrUtil.replace(filePath, "${subTable.className}", subTable.getClassName());
|
filePath = StrUtil.replace(filePath, "${subTable.className}", subTable.getClassName());
|
||||||
filePath = StrUtil.replace(filePath, "${subSimpleClassName}",
|
filePath = StrUtil.replace(filePath, "${subSimpleClassName}",
|
||||||
((List<String>) bindingMap.get("subSimpleClassNames")).get(subIndex));
|
((List<String>) bindingMap.get("subSimpleClassNames")).get(subIndex));
|
||||||
|
filePath = StrUtil.replace(filePath, "${subSimpleClassName_strikeCase}",
|
||||||
|
((List<String>) bindingMap.get("subSimpleClassName_strikeCases")).get(subIndex));
|
||||||
}
|
}
|
||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ export namespace ${simpleClassName}Api {
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
#end
|
#end
|
||||||
/** ${table.classComment}信息 */
|
/** ${table.classComment}信息 */
|
||||||
export interface ${simpleClassName} {
|
export interface ${simpleClassName} {
|
||||||
|
@ -104,6 +105,7 @@ export function export${simpleClassName}(params: any) {
|
||||||
#set ($subClassNameVar = $subClassNameVars.get($index))
|
#set ($subClassNameVar = $subClassNameVars.get($index))
|
||||||
|
|
||||||
// ==================== 子表($subTable.classComment) ====================
|
// ==================== 子表($subTable.classComment) ====================
|
||||||
|
|
||||||
## 情况一:MASTER_ERP 时,需要分查询页子表
|
## 情况一:MASTER_ERP 时,需要分查询页子表
|
||||||
#if ( $table.templateType == 11 )
|
#if ( $table.templateType == 11 )
|
||||||
/** 获得${subTable.classComment}分页 */
|
/** 获得${subTable.classComment}分页 */
|
||||||
|
|
|
@ -88,7 +88,7 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||||
maxCount: 1,
|
maxCount: 1,
|
||||||
},
|
},
|
||||||
#elseif($column.htmlType == "editor")## 文本编辑器
|
#elseif($column.htmlType == "editor")## 文本编辑器
|
||||||
component: 'Editor',
|
component: 'RichTextarea',
|
||||||
#elseif($column.htmlType == "select")## 下拉框
|
#elseif($column.htmlType == "select")## 下拉框
|
||||||
component: 'Select',
|
component: 'Select',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
|
@ -279,6 +279,7 @@ export function useGridColumns(
|
||||||
#set ($subJoinColumn = $subJoinColumns.get($index))##当前 join 字段
|
#set ($subJoinColumn = $subJoinColumns.get($index))##当前 join 字段
|
||||||
#set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($index))
|
#set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($index))
|
||||||
// ==================== 子表($subTable.classComment) ====================
|
// ==================== 子表($subTable.classComment) ====================
|
||||||
|
|
||||||
#if ($table.templateType == 11) ## erp 情况
|
#if ($table.templateType == 11) ## erp 情况
|
||||||
/** 新增/修改的表单 */
|
/** 新增/修改的表单 */
|
||||||
export function use${subSimpleClassName}FormSchema(): VbenFormSchema[] {
|
export function use${subSimpleClassName}FormSchema(): VbenFormSchema[] {
|
||||||
|
@ -331,7 +332,7 @@ export function use${subSimpleClassName}FormSchema(): VbenFormSchema[] {
|
||||||
maxCount: 1,
|
maxCount: 1,
|
||||||
},
|
},
|
||||||
#elseif($column.htmlType == "editor")## 文本编辑器
|
#elseif($column.htmlType == "editor")## 文本编辑器
|
||||||
component: 'Editor',
|
component: 'RichTextarea',
|
||||||
#elseif($column.htmlType == "select")## 下拉框
|
#elseif($column.htmlType == "select")## 下拉框
|
||||||
component: 'Select',
|
component: 'Select',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
|
@ -391,6 +392,56 @@ export function use${subSimpleClassName}FormSchema(): VbenFormSchema[] {
|
||||||
#end
|
#end
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 列表的搜索表单 */
|
||||||
|
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(
|
export function use${subSimpleClassName}GridColumns(
|
||||||
onActionClick?: OnActionClickFn<${simpleClassName}Api.${subSimpleClassName}>,
|
onActionClick?: OnActionClickFn<${simpleClassName}Api.${subSimpleClassName}>,
|
||||||
|
@ -434,17 +485,18 @@ export function use${subSimpleClassName}GridColumns(
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
code: 'edit',
|
code: 'edit',
|
||||||
show: hasAccessByCodes(['${subTable.moduleName}:${subSimpleClassName_strikeCase}:update']),
|
show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:update']),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
code: 'delete',
|
code: 'delete',
|
||||||
show: hasAccessByCodes(['${subTable.moduleName}:${subSimpleClassName_strikeCase}:delete']),
|
show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:delete']),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#if ($subTable.subJoinMany) ## 一对多
|
#if ($subTable.subJoinMany) ## 一对多
|
||||||
/** 新增/修改列表的字段 */
|
/** 新增/修改列表的字段 */
|
||||||
|
@ -510,6 +562,7 @@ export function use${subSimpleClassName}GridColumns(
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
/** 新增/修改的表单 */
|
/** 新增/修改的表单 */
|
||||||
export function use${subSimpleClassName}FormSchema(): VbenFormSchema[] {
|
export function use${subSimpleClassName}FormSchema(): VbenFormSchema[] {
|
||||||
|
@ -562,7 +615,7 @@ export function use${subSimpleClassName}GridColumns(
|
||||||
maxCount: 1,
|
maxCount: 1,
|
||||||
},
|
},
|
||||||
#elseif($column.htmlType == "editor")## 文本编辑器
|
#elseif($column.htmlType == "editor")## 文本编辑器
|
||||||
component: 'Editor',
|
component: 'RichTextarea',
|
||||||
#elseif($column.htmlType == "select")## 下拉框
|
#elseif($column.htmlType == "select")## 下拉框
|
||||||
component: 'Select',
|
component: 'Select',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
|
@ -622,6 +675,7 @@ export function use${subSimpleClassName}GridColumns(
|
||||||
#end
|
#end
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
#end
|
#end
|
||||||
#if ($table.templateType == 12) ## 内嵌情况
|
#if ($table.templateType == 12) ## 内嵌情况
|
||||||
/** 列表的字段 */
|
/** 列表的字段 */
|
||||||
|
@ -649,6 +703,7 @@ export function use${subSimpleClassName}GridColumns(
|
||||||
#end
|
#end
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
|
@ -6,7 +6,9 @@ import { message, Tabs, Checkbox, Input, Textarea, Select,RadioGroup,CheckboxGro
|
||||||
## 特殊:主子表专属逻辑
|
## 特殊:主子表专属逻辑
|
||||||
#if ( $table.templateType == 10 || $table.templateType == 12 )
|
#if ( $table.templateType == 10 || $table.templateType == 12 )
|
||||||
#foreach ($subSimpleClassName in $subSimpleClassNames)
|
#foreach ($subSimpleClassName in $subSimpleClassNames)
|
||||||
import ${subSimpleClassName}Form from './${subSimpleClassName}Form.vue'
|
#set ($index = $foreach.count - 1)
|
||||||
|
#set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($index))
|
||||||
|
import ${subSimpleClassName}Form from './${subSimpleClassName_strikeCase}-form.vue'
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
@ -125,9 +127,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.id) {
|
if (data.id) {
|
||||||
// 编辑
|
|
||||||
modalApi.lock();
|
modalApi.lock();
|
||||||
try {
|
try {
|
||||||
data = await get${simpleClassName}(data.id);
|
data = await get${simpleClassName}(data.id);
|
||||||
|
|
|
@ -10,7 +10,9 @@ import Form from './modules/form.vue';
|
||||||
## 特殊:主子表专属逻辑
|
## 特殊:主子表专属逻辑
|
||||||
#if ( $table.templateType == 11 || $table.templateType == 12 )
|
#if ( $table.templateType == 11 || $table.templateType == 12 )
|
||||||
#foreach ($subSimpleClassName in $subSimpleClassNames)
|
#foreach ($subSimpleClassName in $subSimpleClassNames)
|
||||||
import ${subSimpleClassName}List from './modules/${subSimpleClassName}List.vue'
|
#set ($index = $foreach.count - 1)
|
||||||
|
#set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($index))
|
||||||
|
import ${subSimpleClassName}List from './modules/${subSimpleClassName_strikeCase}-list.vue'
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
@ -26,9 +28,12 @@ import { downloadByData } from '#/utils/download';
|
||||||
|
|
||||||
import { useGridColumns, useGridFormSchema } from './data';
|
import { useGridColumns, useGridFormSchema } from './data';
|
||||||
|
|
||||||
#if ($table.templateType == 12) ## 内嵌情况
|
#if ($table.templateType == 12 || $table.templateType == 11) ## 内嵌和erp情况
|
||||||
/** 子表的列表 */
|
/** 子表的列表 */
|
||||||
const subTabsName = ref('$subClassNameVars.get(0)')
|
const subTabsName = ref('$subClassNameVars.get(0)')
|
||||||
|
#if ($table.templateType == 11)
|
||||||
|
const select${simpleClassName} = ref<${simpleClassName}Api.${simpleClassName}>();
|
||||||
|
#end
|
||||||
#end
|
#end
|
||||||
|
|
||||||
const [FormModal, formModalApi] = useVbenModal({
|
const [FormModal, formModalApi] = useVbenModal({
|
||||||
|
@ -54,12 +59,6 @@ function onRefresh() {
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 导出表格 */
|
|
||||||
async function onExport() {
|
|
||||||
const data = await export${simpleClassName}(await gridApi.formApi.getValues());
|
|
||||||
downloadByData(data, '${table.classComment}.xls');
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 创建${table.classComment} */
|
/** 创建${table.classComment} */
|
||||||
function onCreate() {
|
function onCreate() {
|
||||||
formModalApi.setData({}).open();
|
formModalApi.setData({}).open();
|
||||||
|
@ -96,6 +95,12 @@ async function onDelete(row: ${simpleClassName}Api.${simpleClassName}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 导出表格 */
|
||||||
|
async function onExport() {
|
||||||
|
const data = await export${simpleClassName}(await gridApi.formApi.getValues());
|
||||||
|
downloadByData(data, '${table.classComment}.xls');
|
||||||
|
}
|
||||||
|
|
||||||
/** 表格操作按钮的回调函数 */
|
/** 表格操作按钮的回调函数 */
|
||||||
function onActionClick({
|
function onActionClick({
|
||||||
code,
|
code,
|
||||||
|
@ -108,14 +113,14 @@ function onActionClick({
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#end
|
#end
|
||||||
case 'delete': {
|
|
||||||
onDelete(row);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'edit': {
|
case 'edit': {
|
||||||
onEdit(row);
|
onEdit(row);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'delete': {
|
||||||
|
onDelete(row);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +130,11 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
},
|
},
|
||||||
gridOptions: {
|
gridOptions: {
|
||||||
columns: useGridColumns(onActionClick),
|
columns: useGridColumns(onActionClick),
|
||||||
|
#if (${table.templateType} == 11)
|
||||||
|
height: '600px',
|
||||||
|
#else
|
||||||
height: 'auto',
|
height: 'auto',
|
||||||
|
#end
|
||||||
#if (${table.templateType} == 2)## 树表设置
|
#if (${table.templateType} == 2)## 树表设置
|
||||||
treeConfig: {
|
treeConfig: {
|
||||||
parentField: '${treeParentColumn.javaField}',
|
parentField: '${treeParentColumn.javaField}',
|
||||||
|
@ -162,12 +171,22 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
rowConfig: {
|
rowConfig: {
|
||||||
keyField: 'id',
|
keyField: 'id',
|
||||||
isHover: true,
|
isHover: true,
|
||||||
|
#if (${table.templateType} == 11)
|
||||||
|
isCurrent: true,
|
||||||
|
#end
|
||||||
},
|
},
|
||||||
toolbarConfig: {
|
toolbarConfig: {
|
||||||
refresh: { code: 'query' },
|
refresh: { code: 'query' },
|
||||||
search: true,
|
search: true,
|
||||||
},
|
},
|
||||||
} as VxeTableGridOptions<${simpleClassName}Api.${simpleClassName}>,
|
} as VxeTableGridOptions<${simpleClassName}Api.${simpleClassName}>,
|
||||||
|
#if (${table.templateType} == 11)
|
||||||
|
gridEvents:{
|
||||||
|
cellClick: ({ row }: { row: ${simpleClassName}Api.${simpleClassName}}) => {
|
||||||
|
select${simpleClassName}.value = row;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
#end
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -175,11 +194,14 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
<Page auto-content-height>
|
<Page auto-content-height>
|
||||||
<FormModal @success="onRefresh" />
|
<FormModal @success="onRefresh" />
|
||||||
|
|
||||||
|
#if ($table.templateType == 11) ## erp情况
|
||||||
|
<div>
|
||||||
|
#end
|
||||||
<Grid table-title="${table.classComment}列表">
|
<Grid table-title="${table.classComment}列表">
|
||||||
#if ($table.templateType == 12) ## 内嵌情况
|
#if ($table.templateType == 12) ## 内嵌情况
|
||||||
<template #expand_content="{ row }">
|
<template #expand_content="{ row }">
|
||||||
<!-- 子表的表单 -->
|
<!-- 子表的表单 -->
|
||||||
<Tabs v-model:active-key="subTabsName">
|
<Tabs v-model:active-key="subTabsName" class="mx-8">
|
||||||
#foreach ($subTable in $subTables)
|
#foreach ($subTable in $subTables)
|
||||||
#set ($index = $foreach.count - 1)
|
#set ($index = $foreach.count - 1)
|
||||||
#set ($subClassNameVar = $subClassNameVars.get($index))
|
#set ($subClassNameVar = $subClassNameVars.get($index))
|
||||||
|
@ -212,5 +234,21 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
</Button>
|
</Button>
|
||||||
</template>
|
</template>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
#if ($table.templateType == 11) ## erp情况
|
||||||
|
<!-- 子表的表单 -->
|
||||||
|
<Tabs v-model:active-key="subTabsName" class="mt-2">
|
||||||
|
#foreach ($subTable in $subTables)
|
||||||
|
#set ($index = $foreach.count - 1)
|
||||||
|
#set ($subClassNameVar = $subClassNameVars.get($index))
|
||||||
|
#set ($subSimpleClassName = $subSimpleClassNames.get($index))
|
||||||
|
#set ($subJoinColumn_strikeCase = $subJoinColumn_strikeCases.get($index))
|
||||||
|
<Tabs.TabPane key="$subClassNameVar" tab="${subTable.classComment}" force-render>
|
||||||
|
<${subSimpleClassName}List :${subJoinColumn_strikeCase}="select${simpleClassName}?.id" />
|
||||||
|
</Tabs.TabPane>
|
||||||
|
#end
|
||||||
|
</Tabs>
|
||||||
|
</div>
|
||||||
|
#end
|
||||||
</Page>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -2,192 +2,85 @@
|
||||||
#set ($subColumns = $subColumnsList.get($subIndex))##当前字段数组
|
#set ($subColumns = $subColumnsList.get($subIndex))##当前字段数组
|
||||||
#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段
|
#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段
|
||||||
#set ($subSimpleClassName = $subSimpleClassNames.get($subIndex))
|
#set ($subSimpleClassName = $subSimpleClassNames.get($subIndex))
|
||||||
#set ($subClassNameVar = $subClassNameVars.get($subIndex))
|
|
||||||
#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写
|
|
||||||
<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 { computed, ref, h, onMounted,watch,nextTick } from 'vue';
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
import { message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
|
import { get${subSimpleClassName}, create${subSimpleClassName}, update${subSimpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||||
|
|
||||||
#if ($subTable.subJoinMany) ## 一对多
|
import { use${subSimpleClassName}FormSchema } from '../data';
|
||||||
import { Plus } from "@vben/icons";
|
|
||||||
import { Button, Tabs, Checkbox, Input, Textarea, Select,RadioGroup,CheckboxGroup, DatePicker } from 'ant-design-vue';
|
|
||||||
import type { OnActionClickParams } from '#/adapter/vxe-table';
|
|
||||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
|
||||||
import { use${subSimpleClassName}GridColumns } from '../data';
|
|
||||||
import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
|
||||||
#else
|
|
||||||
import { useVbenForm } from '#/adapter/form';
|
|
||||||
import { use${subSimpleClassName}FormSchema } from '../data';
|
|
||||||
import { get${subSimpleClassName}By${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
|
||||||
#end
|
|
||||||
|
|
||||||
const props = defineProps<{
|
const emit = defineEmits(['success']);
|
||||||
${subJoinColumn.javaField}?: any // ${subJoinColumn.columnComment}(主表的关联字段)
|
const formData = ref<${simpleClassName}Api.${subSimpleClassName}>();
|
||||||
}>()
|
const getTitle = computed(() => {
|
||||||
|
return formData.value?.id
|
||||||
|
? $t('ui.actionTitle.edit', ['${subTable.classComment}'])
|
||||||
|
: $t('ui.actionTitle.create', ['${subTable.classComment}']);
|
||||||
|
});
|
||||||
|
|
||||||
#if ($subTable.subJoinMany) ## 一对多
|
const [Form, formApi] = useVbenForm({
|
||||||
/** 表格操作按钮的回调函数 */
|
layout: 'horizontal',
|
||||||
function onActionClick({
|
schema: use${subSimpleClassName}FormSchema(),
|
||||||
code,
|
showDefaultActions: false
|
||||||
row,
|
});
|
||||||
}: OnActionClickParams<${simpleClassName}Api.${subSimpleClassName}>) {
|
|
||||||
switch (code) {
|
|
||||||
case 'delete': {
|
|
||||||
onDelete(row);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const [${subSimpleClassName}Grid, ${subClassNameVar}GridApi] = useVbenVxeGrid({
|
const [Modal, modalApi] = useVbenModal({
|
||||||
gridOptions: {
|
async onConfirm() {
|
||||||
columns: use${subSimpleClassName}GridColumns(onActionClick),
|
const { valid } = await formApi.validate();
|
||||||
border: true,
|
if (!valid) {
|
||||||
showOverflow: true,
|
|
||||||
autoResize: true,
|
|
||||||
keepSource: true,
|
|
||||||
rowConfig: {
|
|
||||||
keyField: 'id',
|
|
||||||
},
|
|
||||||
pagerConfig: {
|
|
||||||
enabled: false,
|
|
||||||
},
|
|
||||||
toolbarConfig: {
|
|
||||||
enabled: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
/** 删除${subTable.classComment} */
|
|
||||||
const onDelete = async (row: ${simpleClassName}Api.${subSimpleClassName}) => {
|
|
||||||
await ${subClassNameVar}GridApi.grid.remove(row);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 添加${subTable.classComment} */
|
|
||||||
const handleAdd = async () => {
|
|
||||||
await ${subClassNameVar}GridApi.grid.insertAt({} as ${simpleClassName}Api.${subSimpleClassName}, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 提供获取表格数据的方法供父组件调用 */
|
|
||||||
defineExpose({
|
|
||||||
getData: (): ${simpleClassName}Api.${subSimpleClassName}[] => {
|
|
||||||
return [
|
|
||||||
...${subClassNameVar}GridApi.grid.getData(),
|
|
||||||
...${subClassNameVar}GridApi.grid.getInsertRecords().map((row) => {
|
|
||||||
delete row.id;
|
|
||||||
return row;
|
|
||||||
}),
|
|
||||||
];
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
/** 监听主表的关联字段的变化,加载对应的子表数据 */
|
|
||||||
watch(
|
|
||||||
() => props.${subJoinColumn.javaField},
|
|
||||||
async (val) => {
|
|
||||||
if (!val) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await nextTick();
|
modalApi.lock();
|
||||||
await ${subClassNameVar}GridApi.grid.loadData(await get${subSimpleClassName}ListBy${SubJoinColumnName}(props.${subJoinColumn.javaField}!));
|
// 提交表单
|
||||||
|
const data = (await formApi.getValues()) as ${simpleClassName}Api.${subSimpleClassName};
|
||||||
|
data.${subJoinColumn.javaField} = formData.value?.${subJoinColumn.javaField};
|
||||||
|
try {
|
||||||
|
await (formData.value?.id ? update${subSimpleClassName}(data) : create${subSimpleClassName}(data));
|
||||||
|
// 关闭并提示
|
||||||
|
await modalApi.close();
|
||||||
|
emit('success');
|
||||||
|
message.success({
|
||||||
|
content: $t('ui.actionMessage.operationSuccess'),
|
||||||
|
key: 'action_process_msg',
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
modalApi.lock(false);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
);
|
async onOpenChange(isOpen: boolean) {
|
||||||
#else
|
if (!isOpen) {
|
||||||
const [${subSimpleClassName}Form, ${subClassNameVar}FormApi] = useVbenForm({
|
formData.value = undefined;
|
||||||
layout: 'horizontal',
|
|
||||||
schema: use${subSimpleClassName}FormSchema(),
|
|
||||||
showDefaultActions: false
|
|
||||||
});
|
|
||||||
|
|
||||||
/** 暴露出表单校验方法和表单值获取方法 */
|
|
||||||
defineExpose({
|
|
||||||
validate: async () => {
|
|
||||||
const { valid } = await ${subClassNameVar}FormApi.validate();
|
|
||||||
return valid;
|
|
||||||
},
|
|
||||||
getValues: ${subClassNameVar}FormApi.getValues,
|
|
||||||
});
|
|
||||||
|
|
||||||
/** 监听主表的关联字段的变化,加载对应的子表数据 */
|
|
||||||
watch(
|
|
||||||
() => props.${subJoinColumn.javaField},
|
|
||||||
async (val) => {
|
|
||||||
if (!val) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await nextTick();
|
// 加载数据
|
||||||
await ${subClassNameVar}FormApi.setValues(await get${subSimpleClassName}By${SubJoinColumnName}(props.${subJoinColumn.javaField}!));
|
let data = modalApi.getData<${simpleClassName}Api.${subSimpleClassName}>();
|
||||||
|
if (!data) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (data.id) {
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
data = await get${subSimpleClassName}(data.id);
|
||||||
|
} finally {
|
||||||
|
modalApi.lock(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 设置到 values
|
||||||
|
formData.value = data;
|
||||||
|
await formApi.setValues(formData.value);
|
||||||
},
|
},
|
||||||
);
|
});
|
||||||
#end
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
#if ($subTable.subJoinMany) ## 一对多
|
<Modal :title="getTitle">
|
||||||
<${subSimpleClassName}Grid class="mx-4">
|
<Form class="mx-4" />
|
||||||
#foreach($column in $subColumns)
|
</Modal>
|
||||||
#if ($column.createOperation || $column.updateOperation)
|
|
||||||
#set ($javaField = $column.javaField)
|
|
||||||
#if ( $column.id == $subJoinColumn.id) ## 特殊:忽略主子表的 join 字段,不用填写
|
|
||||||
#elseif ($column.htmlType == "input" && !$column.primaryKey)## 忽略主键,不用在表单里
|
|
||||||
<template #${javaField}="{ row }">
|
|
||||||
<Input v-model:value="row.${javaField}" />
|
|
||||||
</template>
|
|
||||||
#elseif($column.htmlType == "imageUpload")## 图片上传
|
|
||||||
<template #${javaField}="{ row }">
|
|
||||||
<UploadImg v-model:value="row.${javaField}" />
|
|
||||||
</template>
|
|
||||||
#elseif($column.htmlType == "fileUpload")## 文件上传
|
|
||||||
<template #${javaField}="{ row }">
|
|
||||||
<UploadFile v-model:value="row.${javaField}" />
|
|
||||||
</template>
|
|
||||||
#elseif($column.htmlType == "editor")## 文本编辑器
|
|
||||||
<template #${javaField}="{ row }">
|
|
||||||
<Textarea v-model:value="row.${javaField}" />
|
|
||||||
</template>
|
|
||||||
#elseif($column.htmlType == "select")## 下拉框
|
|
||||||
<template #${javaField}="{ row, column }">
|
|
||||||
<Select v-model:value="row.${javaField}" class="w-full">
|
|
||||||
<Select.Option v-for="option in column.params.options" :key="option.value" :value="option.value">
|
|
||||||
{{ option.label }}
|
|
||||||
</Select.Option>
|
|
||||||
</Select>
|
|
||||||
</template>
|
|
||||||
#elseif($column.htmlType == "checkbox")## 多选框
|
|
||||||
<template #${javaField}="{ row, column }">
|
|
||||||
<CheckboxGroup v-model:value="row.${javaField}" :options="column.params.options" />
|
|
||||||
</template>
|
|
||||||
#elseif($column.htmlType == "radio")## 单选框
|
|
||||||
<template #${javaField}="{ row, column }">
|
|
||||||
<RadioGroup v-model:value="row.${javaField}" :options="column.params.options" />
|
|
||||||
</template>
|
|
||||||
#elseif($column.htmlType == "datetime")## 时间框
|
|
||||||
<template #${javaField}="{ row }">
|
|
||||||
<DatePicker
|
|
||||||
v-model:value="row.${javaField}"
|
|
||||||
:showTime="true"
|
|
||||||
format="YYYY-MM-DD HH:mm:ss"
|
|
||||||
valueFormat='x'
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
#elseif($column.htmlType == "textarea")## 文本框
|
|
||||||
<template #${javaField}="{ row }">
|
|
||||||
<Textarea v-model:value="row.${javaField}" />
|
|
||||||
</template>
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
</${subSimpleClassName}Grid>
|
|
||||||
<div class="flex justify-center">
|
|
||||||
<Button :icon="h(Plus)" type="primary" ghost @click="handleAdd" v-access:code="['${subTable.moduleName}:${simpleClassName_strikeCase}:create']">
|
|
||||||
{{ $t('ui.actionTitle.create', ['${subTable.classComment}']) }}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
#else
|
|
||||||
<${subSimpleClassName}Form class="mx-4" />
|
|
||||||
#end
|
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -24,7 +24,7 @@ import { get${subSimpleClassName}By${SubJoinColumnName} } from '#/api/${table.mo
|
||||||
#end
|
#end
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
${subJoinColumn.javaField}?: any // ${subJoinColumn.columnComment}(主表的关联字段)
|
${subJoinColumn.javaField}?: number // ${subJoinColumn.columnComment}(主表的关联字段)
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
#if ($subTable.subJoinMany) ## 一对多
|
#if ($subTable.subJoinMany) ## 一对多
|
||||||
|
@ -41,7 +41,7 @@ function onActionClick({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const [${subSimpleClassName}Grid, ${subClassNameVar}GridApi] = useVbenVxeGrid({
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
gridOptions: {
|
gridOptions: {
|
||||||
columns: use${subSimpleClassName}GridEditColumns(onActionClick),
|
columns: use${subSimpleClassName}GridEditColumns(onActionClick),
|
||||||
border: true,
|
border: true,
|
||||||
|
@ -60,34 +60,25 @@ gridOptions: {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
/** 删除${subTable.classComment} */
|
/** 添加${subTable.classComment} */
|
||||||
const onDelete = async (row: ${simpleClassName}Api.${subSimpleClassName}) => {
|
const onAdd = async () => {
|
||||||
await ${subClassNameVar}GridApi.grid.remove(row);
|
await gridApi.grid.insertAt({} as ${simpleClassName}Api.${subSimpleClassName}, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 添加${subTable.classComment} */
|
/** 删除${subTable.classComment} */
|
||||||
const handleAdd = async () => {
|
const onDelete = async (row: ${simpleClassName}Api.${subSimpleClassName}) => {
|
||||||
await ${subClassNameVar}GridApi.grid.insertAt({} as ${simpleClassName}Api.${subSimpleClassName}, -1);
|
await gridApi.grid.remove(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 提供获取表格数据的方法供父组件调用 */
|
/** 提供获取表格数据的方法供父组件调用 */
|
||||||
defineExpose({
|
defineExpose({
|
||||||
getData: (): ${simpleClassName}Api.${subSimpleClassName}[] => {
|
getData: (): ${simpleClassName}Api.${subSimpleClassName}[] => {
|
||||||
// 获取当前数据,但排除已删除的记录
|
const data = gridApi.grid.getData() as ${simpleClassName}Api.${subSimpleClassName}[];
|
||||||
const allData = ${subClassNameVar}GridApi.grid.getData();
|
const removeRecords = gridApi.grid.getRemoveRecords() as ${simpleClassName}Api.${subSimpleClassName}[];
|
||||||
const removedData = ${subClassNameVar}GridApi.grid.getRemoveRecords();
|
const insertRecords = gridApi.grid.getInsertRecords() as ${simpleClassName}Api.${subSimpleClassName}[];
|
||||||
const removedIds = new Set(removedData.map((row) => row.id));
|
return data
|
||||||
|
.filter((row) => !removeRecords.some((removed) => removed.id === row.id))
|
||||||
// 过滤掉已删除的记录
|
.concat(insertRecords.map((row: any) => ({ ...row, id: undefined })));
|
||||||
const currentData = allData.filter((row) => !removedIds.has(row.id));
|
|
||||||
|
|
||||||
// 获取新插入的记录并移除id
|
|
||||||
const insertedData = ${subClassNameVar}GridApi.grid.getInsertRecords().map((row) => {
|
|
||||||
delete row.id;
|
|
||||||
return row;
|
|
||||||
});
|
|
||||||
|
|
||||||
return [...currentData, ...insertedData];
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -98,14 +89,13 @@ watch(
|
||||||
if (!val) {
|
if (!val) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await nextTick();
|
await nextTick();
|
||||||
await ${subClassNameVar}GridApi.grid.loadData(await get${subSimpleClassName}ListBy${SubJoinColumnName}(props.${subJoinColumn.javaField}!));
|
await gridApi.grid.loadData(await get${subSimpleClassName}ListBy${SubJoinColumnName}(props.${subJoinColumn.javaField}!));
|
||||||
},
|
},
|
||||||
{ immediate: true },
|
{ immediate: true },
|
||||||
);
|
);
|
||||||
#else
|
#else
|
||||||
const [${subSimpleClassName}Form, ${subClassNameVar}FormApi] = useVbenForm({
|
const [Form, formApi] = useVbenForm({
|
||||||
layout: 'horizontal',
|
layout: 'horizontal',
|
||||||
schema: use${subSimpleClassName}FormSchema(),
|
schema: use${subSimpleClassName}FormSchema(),
|
||||||
showDefaultActions: false
|
showDefaultActions: false
|
||||||
|
@ -114,10 +104,10 @@ showDefaultActions: false
|
||||||
/** 暴露出表单校验方法和表单值获取方法 */
|
/** 暴露出表单校验方法和表单值获取方法 */
|
||||||
defineExpose({
|
defineExpose({
|
||||||
validate: async () => {
|
validate: async () => {
|
||||||
const { valid } = await ${subClassNameVar}FormApi.validate();
|
const { valid } = await formApi.validate();
|
||||||
return valid;
|
return valid;
|
||||||
},
|
},
|
||||||
getValues: ${subClassNameVar}FormApi.getValues,
|
getValues: formApi.getValues,
|
||||||
});
|
});
|
||||||
|
|
||||||
/** 监听主表的关联字段的变化,加载对应的子表数据 */
|
/** 监听主表的关联字段的变化,加载对应的子表数据 */
|
||||||
|
@ -127,9 +117,8 @@ watch(
|
||||||
if (!val) {
|
if (!val) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await nextTick();
|
await nextTick();
|
||||||
await ${subClassNameVar}FormApi.setValues(await get${subSimpleClassName}By${SubJoinColumnName}(props.${subJoinColumn.javaField}!));
|
await formApi.setValues(await get${subSimpleClassName}By${SubJoinColumnName}(props.${subJoinColumn.javaField}!));
|
||||||
},
|
},
|
||||||
{ immediate: true },
|
{ immediate: true },
|
||||||
);
|
);
|
||||||
|
@ -138,7 +127,7 @@ watch(
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
#if ($subTable.subJoinMany) ## 一对多
|
#if ($subTable.subJoinMany) ## 一对多
|
||||||
<${subSimpleClassName}Grid class="mx-4">
|
<Grid class="mx-4">
|
||||||
#foreach($column in $subColumns)
|
#foreach($column in $subColumns)
|
||||||
#if ($column.createOperation || $column.updateOperation)
|
#if ($column.createOperation || $column.updateOperation)
|
||||||
#set ($javaField = $column.javaField)
|
#set ($javaField = $column.javaField)
|
||||||
|
@ -191,13 +180,13 @@ watch(
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
</${subSimpleClassName}Grid>
|
</Grid>
|
||||||
<div class="flex justify-center">
|
<div class="flex justify-center -mt-4">
|
||||||
<Button :icon="h(Plus)" type="primary" ghost @click="handleAdd" v-access:code="['${subTable.moduleName}:${simpleClassName_strikeCase}:create']">
|
<Button :icon="h(Plus)" type="primary" ghost @click="onAdd" v-access:code="['${subTable.moduleName}:${simpleClassName_strikeCase}:create']">
|
||||||
{{ $t('ui.actionTitle.create', ['${subTable.classComment}']) }}
|
{{ $t('ui.actionTitle.create', ['${subTable.classComment}']) }}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
#else
|
#else
|
||||||
<${subSimpleClassName}Form class="mx-4" />
|
<Form class="mx-4" />
|
||||||
#end
|
#end
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -3,32 +3,37 @@
|
||||||
#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段
|
#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段
|
||||||
#set ($subSimpleClassName = $subSimpleClassNames.get($subIndex))
|
#set ($subSimpleClassName = $subSimpleClassNames.get($subIndex))
|
||||||
#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段
|
#set ($subJoinColumn = $subJoinColumns.get($subIndex))##当前 join 字段
|
||||||
#set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($index))
|
#set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($subIndex))
|
||||||
#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写
|
#set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { OnActionClickParams, VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { OnActionClickParams, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||||
|
|
||||||
|
#if ($table.templateType == 11) ## erp
|
||||||
|
import ${subSimpleClassName}Form from './${subSimpleClassName_strikeCase}-form.vue'
|
||||||
|
#end
|
||||||
import { useVbenModal } from '@vben/common-ui';
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
import { Button, message } from 'ant-design-vue';
|
import { Button, message } from 'ant-design-vue';
|
||||||
import { Plus } from '@vben/icons';
|
import { Plus } from '@vben/icons';
|
||||||
import { ref, h, nextTick,watch } from 'vue';
|
import { #if($table.templateType != 11)ref,#end h, nextTick,watch } from 'vue';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
|
||||||
|
|
||||||
#if ($table.templateType == 11) ## erp
|
#if ($table.templateType == 11) ## erp
|
||||||
import ${subSimpleClassName}Form from './${subSimpleClassName}Form.vue';
|
import { delete${subSimpleClassName}, get${subSimpleClassName}Page } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||||
#end
|
import { use${subSimpleClassName}GridFormSchema, use${subSimpleClassName}GridColumns } from '../data';
|
||||||
|
#else
|
||||||
|
#if ($subTable.subJoinMany) ## 一对多
|
||||||
|
import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||||
|
#else
|
||||||
|
import { get${subSimpleClassName}By${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
||||||
|
#end
|
||||||
import { use${subSimpleClassName}GridColumns } from '../data';
|
import { use${subSimpleClassName}GridColumns } from '../data';
|
||||||
#if ($subTable.subJoinMany) ## 一对多
|
|
||||||
import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
|
||||||
#else
|
|
||||||
import { get${subSimpleClassName}By${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
|
|
||||||
#end
|
#end
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
${subJoinColumn.javaField}?: any // ${subJoinColumn.columnComment}(主表的关联字段)
|
${subJoinColumn.javaField}?: number // ${subJoinColumn.columnComment}(主表的关联字段)
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
#if ($table.templateType == 11) ## erp
|
#if ($table.templateType == 11) ## erp
|
||||||
|
@ -39,13 +44,18 @@ const props = defineProps<{
|
||||||
|
|
||||||
/** 创建${subTable.classComment} */
|
/** 创建${subTable.classComment} */
|
||||||
function onCreate() {
|
function onCreate() {
|
||||||
formModalApi.setData({}).open();
|
if (!props.${subJoinColumn.javaField}){
|
||||||
|
message.warning("请先选择一个${table.classComment}!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
formModalApi.setData({${subJoinColumn.javaField}: props.${subJoinColumn.javaField}}).open();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 编辑${subTable.classComment} */
|
/** 编辑${subTable.classComment} */
|
||||||
function onEdit(row: ${simpleClassName}Api.${subSimpleClassName}) {
|
function onEdit(row: ${simpleClassName}Api.${subSimpleClassName}) {
|
||||||
formModalApi.setData(row).open();
|
formModalApi.setData(row).open();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 删除${subTable.classComment} */
|
/** 删除${subTable.classComment} */
|
||||||
async function onDelete(row: ${simpleClassName}Api.${subSimpleClassName}) {
|
async function onDelete(row: ${simpleClassName}Api.${subSimpleClassName}) {
|
||||||
const hideLoading = message.loading({
|
const hideLoading = message.loading({
|
||||||
|
@ -71,45 +81,77 @@ function onActionClick({
|
||||||
row,
|
row,
|
||||||
}: OnActionClickParams<${simpleClassName}Api.${subSimpleClassName}>) {
|
}: OnActionClickParams<${simpleClassName}Api.${subSimpleClassName}>) {
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case 'delete': {
|
|
||||||
onDelete(row);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'edit': {
|
case 'edit': {
|
||||||
onEdit(row);
|
onEdit(row);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'delete': {
|
||||||
|
onDelete(row);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#end
|
#end
|
||||||
const [Grid, gridApi] = useVbenVxeGrid({
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
#if ($table.templateType == 11)
|
||||||
|
formOptions: {
|
||||||
|
schema: use${subSimpleClassName}GridFormSchema(),
|
||||||
|
},
|
||||||
|
#end
|
||||||
gridOptions: {
|
gridOptions: {
|
||||||
#if ($table.templateType == 11)
|
#if ($table.templateType == 11)
|
||||||
columns: use${subSimpleClassName}GridColumns(onActionClick),
|
columns: use${subSimpleClassName}GridColumns(onActionClick),
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
query: async ({ page }, formValues) => {
|
||||||
|
if (!props.${subJoinColumn.javaField}){
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
return await get${subSimpleClassName}Page({
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
${subJoinColumn.javaField}: props.${subJoinColumn.javaField},
|
||||||
|
...formValues,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
pagerConfig: {
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: { code: 'query' },
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
#else
|
#else
|
||||||
columns: use${subSimpleClassName}GridColumns(),
|
columns: use${subSimpleClassName}GridColumns(),
|
||||||
#end
|
|
||||||
height: 'auto',
|
|
||||||
rowConfig: {
|
|
||||||
keyField: 'id',
|
|
||||||
isHover: true,
|
|
||||||
},
|
|
||||||
pagerConfig: {
|
pagerConfig: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
},
|
},
|
||||||
toolbarConfig: {
|
toolbarConfig: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
},
|
},
|
||||||
} as VxeTableGridOptions<${simpleClassName}Api.${simpleClassName}>,
|
#end
|
||||||
|
height: '600px',
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<${simpleClassName}Api.${subSimpleClassName}>,
|
||||||
});
|
});
|
||||||
|
|
||||||
/** 刷新表格 */
|
/** 刷新表格 */
|
||||||
const onRefresh = async ()=> {
|
const onRefresh = async ()=> {
|
||||||
|
#if ($table.templateType == 11) ## erp
|
||||||
|
await gridApi.query();
|
||||||
|
#else
|
||||||
#if ($subTable.subJoinMany) ## 一对多
|
#if ($subTable.subJoinMany) ## 一对多
|
||||||
await gridApi.grid.loadData(await get${subSimpleClassName}ListBy${SubJoinColumnName}(props.${subJoinColumn.javaField}!));
|
await gridApi.grid.loadData(await get${subSimpleClassName}ListBy${SubJoinColumnName}(props.${subJoinColumn.javaField}!));
|
||||||
#else
|
#else
|
||||||
await gridApi.grid.loadData([await get${subSimpleClassName}By${SubJoinColumnName}(props.${subJoinColumn.javaField}!)]);
|
await gridApi.grid.loadData([await get${subSimpleClassName}By${SubJoinColumnName}(props.${subJoinColumn.javaField}!)]);
|
||||||
#end
|
#end
|
||||||
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 监听主表的关联字段的变化,加载对应的子表数据 */
|
/** 监听主表的关联字段的变化,加载对应的子表数据 */
|
||||||
|
@ -119,7 +161,6 @@ const onRefresh = async ()=> {
|
||||||
if (!val) {
|
if (!val) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await nextTick();
|
await nextTick();
|
||||||
await onRefresh()
|
await onRefresh()
|
||||||
},
|
},
|
||||||
|
@ -128,12 +169,11 @@ const onRefresh = async ()=> {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="mx-4">
|
|
||||||
#if ($table.templateType == 11) ## erp
|
#if ($table.templateType == 11) ## erp
|
||||||
<FormModal @success="onRefresh" />
|
<FormModal @success="onRefresh" />
|
||||||
<Grid table-title="${subTable.classComment}列表">
|
<Grid table-title="${subTable.classComment}列表">
|
||||||
<template #toolbar-tools>
|
<template #toolbar-tools>
|
||||||
<Button :icon="h(Plus)" type="primary" @click="onCreate" v-access:code="['${subTable.moduleName}:${subSimpleClassName_strikeCase}:create']">
|
<Button :icon="h(Plus)" type="primary" @click="onCreate" v-access:code="['${table.moduleName}:${simpleClassName_strikeCase}:create']">
|
||||||
{{ $t('ui.actionTitle.create', ['${subTable.classComment}']) }}
|
{{ $t('ui.actionTitle.create', ['${subTable.classComment}']) }}
|
||||||
</Button>
|
</Button>
|
||||||
</template>
|
</template>
|
||||||
|
@ -141,5 +181,4 @@ const onRefresh = async ()=> {
|
||||||
#else
|
#else
|
||||||
<Grid table-title="${subTable.classComment}列表" />
|
<Grid table-title="${subTable.classComment}列表" />
|
||||||
#end
|
#end
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
Loading…
Reference in New Issue