Commit 3140ec896080252c988ac68fee0a59d65bdf3f4d

Authored by YunaiV
2 parents 951663b6 78e69421

Merge remote-tracking branch 'origin/master-jdk17' into master-jdk17

yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/schema/views/data.ts.vm
1 1 import type { VbenFormSchema } from '#/adapter/form';
2   -import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
  2 +import type { VxeTableGridOptions } from '#/adapter/vxe-table';
3 3 import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${table.businessName}';
4 4  
5 5 import { z } from '#/adapter/form';
... ... @@ -12,9 +12,6 @@ import {
12 12 import { get${simpleClassName}List } from '#/api/${table.moduleName}/${table.businessName}';
13 13 import { handleTree } from '@vben/utils';
14 14 #end
15   -import { useAccess } from '@vben/access';
16   -
17   -const { hasAccessByCodes } = useAccess();
18 15  
19 16 /** 新增/修改的表单 */
20 17 export function useFormSchema(): VbenFormSchema[] {
... ... @@ -189,9 +186,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
189 186 }
190 187  
191 188 /** 列表的字段 */
192   -export function useGridColumns(
193   - onActionClick?: OnActionClickFn<${simpleClassName}Api.${simpleClassName}>,
194   -): VxeTableGridOptions<${simpleClassName}Api.${simpleClassName}>['columns'] {
  189 +export function useGridColumns(): VxeTableGridOptions<${simpleClassName}Api.${simpleClassName}>['columns'] {
195 190 return [
196 191 #if ($table.templateType != 2 && $deleteBatchEnable)
197 192 { type: 'checkbox', width: 40 },
... ... @@ -223,43 +218,10 @@ export function useGridColumns(
223 218 #end
224 219 #end
225 220 {
226   - field: 'operation',
227 221 title: '操作',
228   - minWidth: 200,
229   - align: 'center',
  222 + width: 200,
230 223 fixed: 'right',
231   - headerAlign: 'center',
232   - showOverflow: false,
233   - cellRender: {
234   - attrs: {
235   - nameField: '${columns[0].javaField}',
236   - nameTitle: '${table.classComment}',
237   - onClick: onActionClick,
238   - },
239   - name: 'CellOperation',
240   - options: [
241   -#if (${table.templateType} == 2)## 树表特有操作
242   - {
243   - code: 'append',
244   - text: '新增下级',
245   - show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:create']),
246   - },
247   -#end
248   - {
249   - code: 'edit',
250   - show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:update']),
251   - },
252   - {
253   - code: 'delete',
254   - show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:delete']),
255   -#if (${table.templateType} == 2)## 树表禁止删除带有子节点的数据
256   - disabled: (row: ${simpleClassName}Api.${simpleClassName}) => {
257   - return !!(row.children && row.children.length > 0);
258   - },
259   -#end
260   - },
261   - ],
262   - },
  224 + slots: { default: 'actions' },
263 225 },
264 226 ];
265 227 }
... ... @@ -427,9 +389,7 @@ export function use${subSimpleClassName}GridFormSchema(): VbenFormSchema[] {
427 389 }
428 390  
429 391 /** 列表的字段 */
430   -export function use${subSimpleClassName}GridColumns(
431   - onActionClick?: OnActionClickFn<${simpleClassName}Api.${subSimpleClassName}>,
432   -): VxeTableGridOptions<${simpleClassName}Api.${subSimpleClassName}>['columns'] {
  392 +export function use${subSimpleClassName}GridColumns(): VxeTableGridOptions<${simpleClassName}Api.${subSimpleClassName}>['columns'] {
433 393 return [
434 394 #if ($table.templateType != 2 && $deleteBatchEnable)
435 395 { type: 'checkbox', width: 40 },
... ... @@ -455,31 +415,10 @@ export function use${subSimpleClassName}GridColumns(
455 415 #end
456 416 #end
457 417 {
458   - field: 'operation',
459 418 title: '操作',
460   - minWidth: 200,
461   - align: 'center',
  419 + width: 200,
462 420 fixed: 'right',
463   - headerAlign: 'center',
464   - showOverflow: false,
465   - cellRender: {
466   - attrs: {
467   - nameField: '${columns[0].javaField}',
468   - nameTitle: '${subTable.classComment}',
469   - onClick: onActionClick,
470   - },
471   - name: 'CellOperation',
472   - options: [
473   - {
474   - code: 'edit',
475   - show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:update']),
476   - },
477   - {
478   - code: 'delete',
479   - show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:delete']),
480   - },
481   - ],
482   - },
  421 + slots: { default: 'actions' },
483 422 },
484 423 ];
485 424 }
... ... @@ -525,27 +464,10 @@ export function use${subSimpleClassName}GridColumns(
525 464 #end
526 465 #end
527 466 {
528   - field: 'operation',
529 467 title: '操作',
530   - minWidth: 60,
531   - align: 'center',
  468 + width: 200,
532 469 fixed: 'right',
533   - headerAlign: 'center',
534   - showOverflow: false,
535   - cellRender: {
536   - attrs: {
537   - nameField: '${columns[0].javaField}',
538   - nameTitle: '${table.classComment}',
539   - onClick: onActionClick,
540   - },
541   - name: 'CellOperation',
542   - options: [
543   - {
544   - code: 'delete',
545   - show: hasAccessByCodes(['${table.moduleName}:${simpleClassName_strikeCase}:delete']),
546   - },
547   - ],
548   - },
  470 + slots: { default: 'actions' },
549 471 },
550 472 ];
551 473 }
... ... @@ -680,7 +602,6 @@ export function use${subSimpleClassName}GridColumns(
680 602 #end
681 603 ];
682 604 }
683   -
684 605 #end
685 606 #end
686 607 #end
... ...
yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/schema/views/index.vue.vm
1 1 <script lang="ts" setup>
2   -import type { OnActionClickParams, VxeTableGridOptions } from '#/adapter/vxe-table';
  2 +import type { VxeTableGridOptions } from '#/adapter/vxe-table';
3 3 import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${table.businessName}';
4 4  
5 5 import { Page, useVbenModal } from '@vben/common-ui';
6   -import { Button, message,Tabs } from 'ant-design-vue';
7   -import { Download, Plus, Trash2 } from '@vben/icons';
  6 +import { message,Tabs } from 'ant-design-vue';
8 7 import Form from './modules/form.vue';
9 8  
10 9 ## 特殊:主子表专属逻辑
... ... @@ -12,13 +11,13 @@ import Form from &#39;./modules/form.vue&#39;;
12 11 #foreach ($subSimpleClassName in $subSimpleClassNames)
13 12 #set ($index = $foreach.count - 1)
14 13 #set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($index))
15   - import ${subSimpleClassName}List from './modules/${subSimpleClassName_strikeCase}-list.vue'
  14 +import ${subSimpleClassName}List from './modules/${subSimpleClassName_strikeCase}-list.vue'
16 15 #end
17 16 #end
18 17  
19   -import { ref, h, computed } from 'vue';
  18 +import { ref, computed } from 'vue';
20 19 import { $t } from '#/locales';
21   -import { useVbenVxeGrid } from '#/adapter/vxe-table';
  20 +import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
22 21 #if (${table.templateType} == 2)## 树表接口
23 22 import { get${simpleClassName}List, delete${simpleClassName}, export${simpleClassName} } from '#/api/${table.moduleName}/${table.businessName}';
24 23 #else## 标准表接口
... ... @@ -60,32 +59,34 @@ function onRefresh() {
60 59 }
61 60  
62 61 /** 创建${table.classComment} */
63   -function onCreate() {
  62 +function handleCreate() {
64 63 formModalApi.setData({}).open();
65 64 }
66 65  
67 66 /** 编辑${table.classComment} */
68   -function onEdit(row: ${simpleClassName}Api.${simpleClassName}) {
  67 +function handleEdit(row: ${simpleClassName}Api.${simpleClassName}) {
69 68 formModalApi.setData(row).open();
70 69 }
71 70  
72 71 #if (${table.templateType} == 2)## 树表特有:新增下级
73 72 /** 新增下级${table.classComment} */
74   -function onAppend(row: ${simpleClassName}Api.${simpleClassName}) {
  73 +function handleAppend(row: ${simpleClassName}Api.${simpleClassName}) {
75 74 formModalApi.setData({ ${treeParentColumn.javaField}: row.id }).open();
76 75 }
77 76 #end
78 77  
79 78 /** 删除${table.classComment} */
80   -async function onDelete(row: ${simpleClassName}Api.${simpleClassName}) {
  79 +async function handleDelete(row: ${simpleClassName}Api.${simpleClassName}) {
81 80 const hideLoading = message.loading({
82 81 content: $t('ui.actionMessage.deleting', [row.id]),
83   - duration: 0,
84   - key: 'action_process_msg',
  82 + key: 'action_key_msg',
85 83 });
86 84 try {
87 85 await delete${simpleClassName}(row.id as number);
88   - message.success( $t('ui.actionMessage.deleteSuccess', [row.id]) );
  86 + message.success({
  87 + content: $t('ui.actionMessage.deleteSuccess', [row.id]),
  88 + key: 'action_key_msg',
  89 + });
89 90 onRefresh();
90 91 } finally {
91 92 hideLoading();
... ... @@ -94,15 +95,17 @@ async function onDelete(row: ${simpleClassName}Api.${simpleClassName}) {
94 95  
95 96 #if ($table.templateType != 2 && $deleteBatchEnable)
96 97 /** 批量删除${table.classComment} */
97   -async function onDeleteBatch() {
  98 +async function handleDeleteBatch() {
98 99 const hideLoading = message.loading({
99 100 content: $t('ui.actionMessage.deleting'),
100   - duration: 0,
101   - key: 'action_process_msg',
  101 + key: 'action_key_msg',
102 102 });
103 103 try {
104 104 await delete${simpleClassName}ListByIds(deleteIds.value);
105   - message.success( $t('ui.actionMessage.deleteSuccess') );
  105 + message.success({
  106 + content: $t('ui.actionMessage.deleteSuccess'),
  107 + key: 'action_key_msg',
  108 + });
106 109 onRefresh();
107 110 } finally {
108 111 hideLoading();
... ... @@ -120,40 +123,17 @@ function setDeleteIds({
120 123 #end
121 124  
122 125 /** 导出表格 */
123   -async function onExport() {
  126 +async function handleExport() {
124 127 const data = await export${simpleClassName}(await gridApi.formApi.getValues());
125 128 downloadFileFromBlobPart({ fileName: '${table.classComment}.xls', source: data });
126 129 }
127 130  
128   -/** 表格操作按钮的回调函数 */
129   -function onActionClick({
130   - code,
131   - row,
132   -}: OnActionClickParams<${simpleClassName}Api.${simpleClassName}>) {
133   - switch (code) {
134   - #if (${table.templateType} == 2)## 树表特有:新增下级
135   - case 'append': {
136   - onAppend(row);
137   - break;
138   - }
139   - #end
140   - case 'edit': {
141   - onEdit(row);
142   - break;
143   - }
144   - case 'delete': {
145   - onDelete(row);
146   - break;
147   - }
148   - }
149   -}
150   -
151 131 const [Grid, gridApi] = useVbenVxeGrid({
152 132 formOptions: {
153 133 schema: useGridFormSchema(),
154 134 },
155 135 gridOptions: {
156   - columns: useGridColumns(onActionClick),
  136 + columns: useGridColumns(),
157 137 #if (${table.templateType} == 11)
158 138 height: '600px',
159 139 #else
... ... @@ -245,36 +225,75 @@ const [Grid, gridApi] = useVbenVxeGrid({
245 225 </template>
246 226 #end
247 227 <template #toolbar-tools>
248   -#if (${table.templateType} == 2)## 树表特有:展开/收缩按钮
249   - <Button @click="toggleExpand" class="mr-2">
250   - {{ isExpanded ? '收缩' : '展开' }}
251   - </Button>
252   -#end
253   - <Button :icon="h(Plus)" type="primary" @click="onCreate" v-access:code="['${table.moduleName}:${simpleClassName_strikeCase}:create']">
254   - {{ $t('ui.actionTitle.create', ['${table.classComment}']) }}
255   - </Button>
256   - <Button
257   - :icon="h(Download)"
258   - type="primary"
259   - class="ml-2"
260   - @click="onExport"
261   - v-access:code="['${table.moduleName}:${simpleClassName_strikeCase}:export']"
262   - >
263   - {{ $t('ui.actionTitle.export') }}
264   - </Button>
265   -#if ($table.templateType != 2 && $deleteBatchEnable)
266   - <Button
267   - :icon="h(Trash2)"
268   - type="primary"
269   - danger
270   - class="ml-2"
271   - :disabled="isEmpty(deleteIds)"
272   - @click="onDeleteBatch"
273   - v-access:code="['${table.moduleName}:${simpleClassName_strikeCase}:delete']"
274   - >
275   - 批量删除
276   - </Button>
277   -#end
  228 + <TableAction
  229 + :actions="[
  230 + #if (${table.templateType} == 2)## 树表特有:展开/收缩按钮
  231 + {
  232 + label: isExpanded ? '收缩' : '展开',
  233 + type: 'primary',
  234 + onClick: toggleExpand,
  235 + },
  236 + #end
  237 + {
  238 + label: $t('ui.actionTitle.create', ['${table.classComment}']),
  239 + type: 'primary',
  240 + icon: ACTION_ICON.ADD,
  241 + auth: ['${table.moduleName}:${simpleClassName_strikeCase}:create'],
  242 + onClick: handleCreate,
  243 + },
  244 + {
  245 + label: $t('ui.actionTitle.export'),
  246 + type: 'primary',
  247 + icon: ACTION_ICON.DOWNLOAD,
  248 + auth: ['${table.moduleName}:${simpleClassName_strikeCase}:export'],
  249 + onClick: handleExport,
  250 + },
  251 + #if ($table.templateType != 2 && $deleteBatchEnable)
  252 + {
  253 + label: $t('ui.actionTitle.deleteBatch'),
  254 + type: 'primary',
  255 + danger: true,
  256 + icon: ACTION_ICON.DELETE,
  257 + disabled: isEmpty(deleteIds),
  258 + auth: ['${table.moduleName}:${simpleClassName_strikeCase}:delete'],
  259 + onClick: handleDeleteBatch,
  260 + },
  261 + #end
  262 + ]"
  263 + />
  264 + </template>
  265 + <template #actions="{ row }">
  266 + <TableAction
  267 + :actions="[
  268 + #if (${table.templateType} == 2)## 树表特有:新增下级
  269 + {
  270 + label: '新增下级',
  271 + type: 'link',
  272 + icon: ACTION_ICON.ADD,
  273 + auth: ['${table.moduleName}:${simpleClassName_strikeCase}:create'],
  274 + onClick: handleAppend.bind(null, row),
  275 + },
  276 + #end
  277 + {
  278 + label: $t('common.edit'),
  279 + type: 'link',
  280 + icon: ACTION_ICON.EDIT,
  281 + auth: ['${table.moduleName}:${simpleClassName_strikeCase}:update'],
  282 + onClick: handleEdit.bind(null, row),
  283 + },
  284 + {
  285 + label: $t('common.delete'),
  286 + type: 'link',
  287 + danger: true,
  288 + icon: ACTION_ICON.DELETE,
  289 + auth: ['${table.moduleName}:${simpleClassName_strikeCase}:delete'],
  290 + popConfirm: {
  291 + title: $t('ui.actionMessage.deleteConfirm', [row.id]),
  292 + confirm: handleDelete.bind(null, row),
  293 + },
  294 + },
  295 + ]"
  296 + />
278 297 </template>
279 298 </Grid>
280 299  
... ...
yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/schema/views/modules/list_sub_erp.vue.vm
... ... @@ -6,45 +6,43 @@
6 6 #set ($subSimpleClassName_strikeCase = $subSimpleClassName_strikeCases.get($subIndex))
7 7 #set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写
8 8 <script lang="ts" setup>
9   - import type { OnActionClickParams, VxeTableGridOptions } from '#/adapter/vxe-table';
10   - import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${table.businessName}';
  9 +import type { VxeTableGridOptions } from '#/adapter/vxe-table';
  10 +import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${table.businessName}';
11 11  
12 12 #if ($table.templateType == 11) ## erp
13   - import ${subSimpleClassName}Form from './${subSimpleClassName_strikeCase}-form.vue'
  13 +import ${subSimpleClassName}Form from './${subSimpleClassName_strikeCase}-form.vue'
14 14 #end
15   - import { useVbenModal } from '@vben/common-ui';
16   - import { Button, message } from 'ant-design-vue';
17   - import { Plus, Trash2 } from '@vben/icons';
18   - import { ref, computed, h, nextTick,watch } from 'vue';
19   - import { $t } from '#/locales';
20   - import { useVbenVxeGrid } from '#/adapter/vxe-table';
21   -
  15 +import { useVbenModal } from '@vben/common-ui';
  16 +import { message } from 'ant-design-vue';
  17 +import { ref, computed, nextTick,watch } from 'vue';
  18 +import { $t } from '#/locales';
  19 +import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
22 20  
23 21 #if ($table.templateType == 11) ## erp
24   - import { delete${subSimpleClassName},#if ($deleteBatchEnable) delete${subSimpleClassName}ListByIds,#end get${subSimpleClassName}Page } from '#/api/${table.moduleName}/${table.businessName}';
25   - import { use${subSimpleClassName}GridFormSchema, use${subSimpleClassName}GridColumns } from '../data';
26   - import { isEmpty } from '@vben/utils';
27   - #else
28   - #if ($subTable.subJoinMany) ## 一对多
29   - import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${table.businessName}';
30   - #else
31   - import { get${subSimpleClassName}By${SubJoinColumnName} } from '#/api/${table.moduleName}/${table.businessName}';
32   - #end
33   - import { use${subSimpleClassName}GridColumns } from '../data';
  22 +import { delete${subSimpleClassName},#if ($deleteBatchEnable) delete${subSimpleClassName}ListByIds,#end get${subSimpleClassName}Page } from '#/api/${table.moduleName}/${table.businessName}';
  23 +import { use${subSimpleClassName}GridFormSchema, use${subSimpleClassName}GridColumns } from '../data';
  24 +import { isEmpty } from '@vben/utils';
  25 +#else
  26 +#if ($subTable.subJoinMany) ## 一对多
  27 +import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${table.businessName}';
  28 +#else
  29 +import { get${subSimpleClassName}By${SubJoinColumnName} } from '#/api/${table.moduleName}/${table.businessName}';
  30 +#end
  31 +import { use${subSimpleClassName}GridColumns } from '../data';
34 32 #end
35 33  
36 34 const props = defineProps<{
37   - ${subJoinColumn.javaField}?: number // ${subJoinColumn.columnComment}(主表的关联字段)
  35 + ${subJoinColumn.javaField}?: number // ${subJoinColumn.columnComment}(主表的关联字段)
38 36 }>()
39 37  
40 38 #if ($table.templateType == 11) ## erp
41   - const [FormModal, formModalApi] = useVbenModal({
42   - connectedComponent: ${subSimpleClassName}Form,
43   - destroyOnClose: true,
44   - });
  39 +const [FormModal, formModalApi] = useVbenModal({
  40 + connectedComponent: ${subSimpleClassName}Form,
  41 + destroyOnClose: true,
  42 +});
45 43  
46 44 /** 创建${subTable.classComment} */
47   -function onCreate() {
  45 +function handleCreate() {
48 46 if (!props.${subJoinColumn.javaField}){
49 47 message.warning("请先选择一个${table.classComment}!")
50 48 return
... ... @@ -53,20 +51,22 @@ function onCreate() {
53 51 }
54 52  
55 53 /** 编辑${subTable.classComment} */
56   -function onEdit(row: ${simpleClassName}Api.${subSimpleClassName}) {
  54 +function handleEdit(row: ${simpleClassName}Api.${subSimpleClassName}) {
57 55 formModalApi.setData(row).open();
58 56 }
59 57  
60 58 /** 删除${subTable.classComment} */
61   -async function onDelete(row: ${simpleClassName}Api.${subSimpleClassName}) {
  59 +async function handleDelete(row: ${simpleClassName}Api.${subSimpleClassName}) {
62 60 const hideLoading = message.loading({
63 61 content: $t('ui.actionMessage.deleting', [row.id]),
64   - duration: 0,
65 62 key: 'action_process_msg',
66 63 });
67 64 try {
68 65 await delete${subSimpleClassName}(row.id as number);
69   - message.success( $t('ui.actionMessage.deleteSuccess', [row.id]) );
  66 + message.success({
  67 + content: $t('ui.actionMessage.deleteSuccess', [row.id]),
  68 + key: 'action_key_msg',
  69 + });
70 70 onRefresh();
71 71 } finally {
72 72 hideLoading();
... ... @@ -75,15 +75,17 @@ async function onDelete(row: ${simpleClassName}Api.${subSimpleClassName}) {
75 75  
76 76 #if ($deleteBatchEnable)
77 77 /** 批量删除${subTable.classComment} */
78   -async function onDeleteBatch() {
  78 +async function handleDeleteBatch() {
79 79 const hideLoading = message.loading({
80 80 content: $t('ui.actionMessage.deleting'),
81   - duration: 0,
82   - key: 'action_process_msg',
  81 + key: 'action_key_msg',
83 82 });
84 83 try {
85 84 await delete${subSimpleClassName}ListByIds(deleteIds.value);
86   - message.success( $t('ui.actionMessage.deleteSuccess') );
  85 + message.success({
  86 + content: $t('ui.actionMessage.deleteSuccess', [row.id]),
  87 + key: 'action_key_msg',
  88 + });
87 89 onRefresh();
88 90 } finally {
89 91 hideLoading();
... ... @@ -100,103 +102,86 @@ function setDeleteIds({
100 102 }
101 103 #end
102 104  
103   -/** 表格操作按钮的回调函数 */
104   -function onActionClick({
105   - code,
106   - row,
107   -}: OnActionClickParams<${simpleClassName}Api.${subSimpleClassName}>) {
108   - switch (code) {
109   - case 'edit': {
110   - onEdit(row);
111   - break;
112   - }
113   - case 'delete': {
114   - onDelete(row);
115   - break;
116   - }
117   - }
118   -}
119   -
120 105 #end
121   - const [Grid, gridApi] = useVbenVxeGrid({
  106 +const [Grid, gridApi] = useVbenVxeGrid({
122 107 #if ($table.templateType == 11)
123   - formOptions: {
124   - schema: use${subSimpleClassName}GridFormSchema(),
125   - },
  108 + formOptions: {
  109 + schema: use${subSimpleClassName}GridFormSchema(),
  110 + },
126 111 #end
127   - gridOptions: {
  112 + gridOptions: {
128 113 #if ($table.templateType == 11)
129   - columns: use${subSimpleClassName}GridColumns(onActionClick),
130   - proxyConfig: {
131   - ajax: {
132   - query: async ({ page }, formValues) => {
133   - if (!props.${subJoinColumn.javaField}){
134   - return []
135   - }
136   - return await get${subSimpleClassName}Page({
137   - pageNo: page.currentPage,
138   - pageSize: page.pageSize,
139   - ${subJoinColumn.javaField}: props.${subJoinColumn.javaField},
140   - ...formValues,
141   - });
142   - },
  114 + columns: use${subSimpleClassName}GridColumns(),
  115 + proxyConfig: {
  116 + ajax: {
  117 + query: async ({ page }, formValues) => {
  118 + if (!props.${subJoinColumn.javaField}){
  119 + return []
  120 + }
  121 + return await get${subSimpleClassName}Page({
  122 + pageNo: page.currentPage,
  123 + pageSize: page.pageSize,
  124 + ${subJoinColumn.javaField}: props.${subJoinColumn.javaField},
  125 + ...formValues,
  126 + });
143 127 },
144 128 },
145   - pagerConfig: {
146   - enabled: true,
147   - },
148   - toolbarConfig: {
149   - refresh: { code: 'query' },
150   - search: true,
151 129 },
  130 + pagerConfig: {
  131 + enabled: true,
  132 + },
  133 + toolbarConfig: {
  134 + refresh: { code: 'query' },
  135 + search: true,
  136 + },
152 137 #else
153   - columns: use${subSimpleClassName}GridColumns(),
154   - pagerConfig: {
155   - enabled: false,
156   - },
157   - toolbarConfig: {
158   - enabled: false,
159   - },
  138 + columns: use${subSimpleClassName}GridColumns(),
  139 + pagerConfig: {
  140 + nabled: false,
  141 + },
  142 + toolbarConfig: {
  143 + enabled: false,
  144 + },
160 145 #end
161   - height: '600px',
162   - rowConfig: {
163   - keyField: 'id',
164   - isHover: true,
165   - },
166   - } as VxeTableGridOptions<${simpleClassName}Api.${subSimpleClassName}>,
167   - #if (${table.templateType} == 11 && $deleteBatchEnable)
168   - gridEvents:{
169   - checkboxAll: setDeleteIds,
170   - checkboxChange: setDeleteIds,
171   - }
172   - #end
173   - });
  146 + height: '600px',
  147 + rowConfig: {
  148 + keyField: 'id',
  149 + isHover: true,
  150 + },
  151 + } as VxeTableGridOptions<${simpleClassName}Api.${subSimpleClassName}>,
  152 + #if (${table.templateType} == 11 && $deleteBatchEnable)
  153 + gridEvents:{
  154 + checkboxAll: setDeleteIds,
  155 + checkboxChange: setDeleteIds,
  156 + }
  157 + #end
  158 +});
174 159  
175 160 /** 刷新表格 */
176   -const onRefresh = async ()=> {
  161 +async function onRefresh() {
177 162 #if ($table.templateType == 11) ## erp
178   - await gridApi.query();
  163 + await gridApi.query();
179 164 #else
180   - #if ($subTable.subJoinMany) ## 一对多
181   - await gridApi.grid.loadData(await get${subSimpleClassName}ListBy${SubJoinColumnName}(props.${subJoinColumn.javaField}!));
182   - #else
183   - await gridApi.grid.loadData([await get${subSimpleClassName}By${SubJoinColumnName}(props.${subJoinColumn.javaField}!)]);
184   - #end
  165 + #if ($subTable.subJoinMany) ## 一对多
  166 + await gridApi.grid.loadData(await get${subSimpleClassName}ListBy${SubJoinColumnName}(props.${subJoinColumn.javaField}!));
  167 + #else
  168 + await gridApi.grid.loadData([await get${subSimpleClassName}By${SubJoinColumnName}(props.${subJoinColumn.javaField}!)]);
  169 + #end
185 170 #end
186 171 }
187 172  
188   - /** 监听主表的关联字段的变化,加载对应的子表数据 */
189   - watch(
190   - () => props.${subJoinColumn.javaField},
191   - async (val) => {
192   - if (!val) {
193   - return;
194   - }
195   - await nextTick();
196   - await onRefresh()
197   - },
198   - { immediate: true },
199   - );
  173 +/** 监听主表的关联字段的变化,加载对应的子表数据 */
  174 +watch(
  175 + () => props.${subJoinColumn.javaField},
  176 + async (val) => {
  177 + if (!val) {
  178 + return;
  179 + }
  180 + await nextTick();
  181 + await onRefresh()
  182 + },
  183 + { immediate: true },
  184 +);
200 185 </script>
201 186  
202 187 <template>
... ... @@ -204,22 +189,52 @@ const onRefresh = async ()=&gt; {
204 189 <FormModal @success="onRefresh" />
205 190 <Grid table-title="${subTable.classComment}列表">
206 191 <template #toolbar-tools>
207   - <Button :icon="h(Plus)" type="primary" @click="onCreate" v-access:code="['${table.moduleName}:${simpleClassName_strikeCase}:create']">
208   - {{ $t('ui.actionTitle.create', ['${subTable.classComment}']) }}
209   - </Button>
210   - #if ($table.templateType == 11 && $deleteBatchEnable)
211   - <Button
212   - :icon="h(Trash2)"
213   - type="primary"
214   - danger
215   - class="ml-2"
216   - :disabled="isEmpty(deleteIds)"
217   - @click="onDeleteBatch"
218   - v-access:code="['${table.moduleName}:${simpleClassName_strikeCase}:delete']"
219   - >
220   - 批量删除
221   - </Button>
222   - #end
  192 + <TableAction
  193 + :actions="[
  194 + {
  195 + label: $t('ui.actionTitle.create', ['${table.classComment}']),
  196 + type: 'primary',
  197 + icon: ACTION_ICON.ADD,
  198 + auth: ['${table.moduleName}:${simpleClassName_strikeCase}:create'],
  199 + onClick: handleCreate,
  200 + },
  201 + #if ($table.templateType == 11 && $deleteBatchEnable)
  202 + {
  203 + label: $t('ui.actionTitle.deleteBatch'),
  204 + type: 'primary',
  205 + danger: true,
  206 + icon: ACTION_ICON.DELETE,
  207 + disabled: isEmpty(deleteIds),
  208 + auth: ['${table.moduleName}:${simpleClassName_strikeCase}:delete'],
  209 + onClick: handleDeleteBatch,
  210 + },
  211 + #end
  212 + ]"
  213 + />
  214 + </template>
  215 + <template #actions="{ row }">
  216 + <TableAction
  217 + :actions="[
  218 + {
  219 + label: $t('common.edit'),
  220 + type: 'link',
  221 + icon: ACTION_ICON.EDIT,
  222 + auth: ['${table.moduleName}:${simpleClassName_strikeCase}:update'],
  223 + onClick: handleEdit.bind(null, row),
  224 + },
  225 + {
  226 + label: $t('common.delete'),
  227 + type: 'link',
  228 + danger: true,
  229 + icon: ACTION_ICON.DELETE,
  230 + auth: ['${table.moduleName}:${simpleClassName_strikeCase}:delete'],
  231 + popConfirm: {
  232 + title: $t('ui.actionMessage.deleteConfirm', [row.id]),
  233 + confirm: handleDelete.bind(null, row),
  234 + },
  235 + },
  236 + ]"
  237 + />
223 238 </template>
224 239 </Grid>
225 240 #else
... ...