【代码优化】代码生成: vue3_vben5_antd schema 主子表模板优化
This commit is contained in:
parent
436eb29d30
commit
b3a40af214
|
@ -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,7 @@ export function use${subSimpleClassName}FormSchema(): VbenFormSchema[] {
|
||||||
#end
|
#end
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 列表的字段 */
|
/** 列表的字段 */
|
||||||
export function use${subSimpleClassName}GridColumns(
|
export function use${subSimpleClassName}GridColumns(
|
||||||
onActionClick?: OnActionClickFn<${simpleClassName}Api.${subSimpleClassName}>,
|
onActionClick?: OnActionClickFn<${simpleClassName}Api.${subSimpleClassName}>,
|
||||||
|
@ -445,6 +447,7 @@ export function use${subSimpleClassName}GridColumns(
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#if ($subTable.subJoinMany) ## 一对多
|
#if ($subTable.subJoinMany) ## 一对多
|
||||||
/** 新增/修改列表的字段 */
|
/** 新增/修改列表的字段 */
|
||||||
|
@ -510,6 +513,7 @@ export function use${subSimpleClassName}GridColumns(
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
/** 新增/修改的表单 */
|
/** 新增/修改的表单 */
|
||||||
export function use${subSimpleClassName}FormSchema(): VbenFormSchema[] {
|
export function use${subSimpleClassName}FormSchema(): VbenFormSchema[] {
|
||||||
|
@ -562,7 +566,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 +626,7 @@ export function use${subSimpleClassName}GridColumns(
|
||||||
#end
|
#end
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
#end
|
#end
|
||||||
#if ($table.templateType == 12) ## 内嵌情况
|
#if ($table.templateType == 12) ## 内嵌情况
|
||||||
/** 列表的字段 */
|
/** 列表的字段 */
|
||||||
|
@ -649,6 +654,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
|
||||||
|
|
||||||
|
@ -54,12 +56,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 +92,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 +110,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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +181,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
#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))
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -28,7 +28,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 ($table.templateType == 11) ## erp
|
#if ($table.templateType == 11) ## erp
|
||||||
|
@ -46,6 +46,7 @@ function onCreate() {
|
||||||
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,16 +72,17 @@ 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({
|
||||||
gridOptions: {
|
gridOptions: {
|
||||||
|
@ -119,7 +121,6 @@ const onRefresh = async ()=> {
|
||||||
if (!val) {
|
if (!val) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await nextTick();
|
await nextTick();
|
||||||
await onRefresh()
|
await onRefresh()
|
||||||
},
|
},
|
||||||
|
@ -128,18 +129,16 @@ 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="['${subTable.moduleName}:${subSimpleClassName_strikeCase}:create']">
|
{{ $t('ui.actionTitle.create', ['${subTable.classComment}']) }}
|
||||||
{{ $t('ui.actionTitle.create', ['${subTable.classComment}']) }}
|
</Button>
|
||||||
</Button>
|
</template>
|
||||||
</template>
|
</Grid>
|
||||||
</Grid>
|
#else
|
||||||
#else
|
<Grid table-title="${subTable.classComment}列表" />
|
||||||
<Grid table-title="${subTable.classComment}列表" />
|
#end
|
||||||
#end
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
Loading…
Reference in New Issue