Commit 716ac2f9ff48054a46b2e6900c0d2a6081f13656

Authored by YunaiV
1 parent bc9d9bcd

reactor:【infra 基础设施】处理 vben + element-plus 树形模版

yudao-module-infra/src/main/resources/codegen/vue3_vben5_ele/schema/api/api.ts.vm
1 1 #set ($apiName = "${table.moduleName.substring(0,1).toUpperCase()}${table.moduleName.substring(1)}${simpleClassName}Api")
  2 +#if ( $table.templateType != 2 )
2 3 import type { PageParam, PageResult } from '@vben/request';
  4 +#end
3 5 import type { Dayjs } from 'dayjs';
4 6  
5 7 import { requestClient } from '#/api/request';
... ... @@ -97,8 +99,8 @@ export function update${simpleClassName}(data: ${apiName}.${simpleClassName}) {
97 99 export function delete${simpleClassName}(id: number) {
98 100 return requestClient.delete(`${baseURL}/delete?id=${id}`);
99 101 }
100   -
101 102 #if ( $table.templateType != 2 && $deleteBatchEnable)
  103 +
102 104 /** 批量删除${table.classComment} */
103 105 export function delete${simpleClassName}List(ids: number[]) {
104 106 return requestClient.delete(
... ...
yudao-module-infra/src/main/resources/codegen/vue3_vben5_ele/schema/views/form.vue.vm
... ... @@ -117,6 +117,10 @@ const [Modal, modalApi] = useVbenModal({
117 117 // 加载数据
118 118 const data = modalApi.getData<${apiName}.${simpleClassName}>();
119 119 if (!data || !data.id) {
  120 +#if (${table.templateType} == 2)## 树表特有
  121 + // 设置上级
  122 + await formApi.setValues(data);
  123 +#end
120 124 return;
121 125 }
122 126 modalApi.lock();
... ...
yudao-module-infra/src/main/resources/codegen/vue3_vben5_ele/schema/views/index.vue.vm
... ... @@ -6,7 +6,7 @@ import type { ${apiName} } from &#39;#/api/${table.moduleName}/${table.businessName}
6 6 import { ref } from 'vue';
7 7  
8 8 import {#if ($table.templateType != 2 && $deleteBatchEnable) confirm,#end Page, useVbenModal } from '@vben/common-ui';
9   -import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
  9 +import { downloadFileFromBlobPart#if ($table.templateType != 2 && $deleteBatchEnable), isEmpty#end } from '@vben/utils';
10 10  
11 11 import { ElLoading, ElMessage#if ($table.templateType == 11), ElTabs, ElTabPane#end } from 'element-plus';
12 12  
... ... @@ -73,19 +73,19 @@ function onRefresh() {
73 73 function handleCreate() {
74 74 formModalApi.setData(null).open();
75 75 }
76   -
77   -/** 编辑${table.classComment} */
78   -function handleEdit(row: ${apiName}.${simpleClassName}) {
79   - formModalApi.setData(row).open();
80   -}
81 76 #if (${table.templateType} == 2)## 树表特有:新增下级
82 77  
83   -/** 新增下级${table.classComment} */
  78 +/** 添加下级${table.classComment} */
84 79 function handleAppend(row: ${apiName}.${simpleClassName}) {
85 80 formModalApi.setData({ ${treeParentColumn.javaField}: row.id }).open();
86 81 }
87 82 #end
88 83  
  84 +/** 编辑${table.classComment} */
  85 +function handleEdit(row: ${apiName}.${simpleClassName}) {
  86 + formModalApi.setData(row).open();
  87 +}
  88 +
89 89 /** 删除${table.classComment} */
90 90 async function handleDelete(row: ${apiName}.${simpleClassName}) {
91 91 const loadingInstance = ElLoading.service({
... ... @@ -145,16 +145,9 @@ const [Grid, gridApi] = useVbenVxeGrid({
145 145 height: 'auto',
146 146 #end
147 147 #if (${table.templateType} == 2)## 树表设置
148   - treeConfig: {
149   - parentField: '${treeParentColumn.javaField}',
150   - rowField: 'id',
151   - transform: true,
152   - expandAll: true,
153   - reserve: true,
154   - },
155   - pagerConfig: {
156   - enabled: false,
157   - },
  148 + pagerConfig: {
  149 + enabled: false,
  150 + },
158 151 #else## 标准表设置
159 152 keepSource: true,
160 153 #end
... ... @@ -186,15 +179,24 @@ const [Grid, gridApi] = useVbenVxeGrid({
186 179 refresh: true,
187 180 search: true,
188 181 },
  182 +#if (${table.templateType} == 2)## 树表设置
  183 + treeConfig: {
  184 + parentField: '${treeParentColumn.javaField}',
  185 + rowField: 'id',
  186 + transform: true,
  187 + expandAll: true,
  188 + reserve: true,
  189 + },
  190 +#end
189 191 } as VxeTableGridOptions<${apiName}.${simpleClassName}>,
190   -#if (${table.templateType} == 11 || $deleteBatchEnable)
  192 +#if (${table.templateType} == 11 || (${table.templateType} != 2 && $deleteBatchEnable))
191 193 gridEvents: {
192 194 #if(${table.templateType} == 11)
193 195 cellClick: ({ row }: { row: ${apiName}.${simpleClassName}}) => {
194 196 select${simpleClassName}.value = row;
195 197 },
196 198 #end
197   - #if(${table.templateType} != 2 && $deleteBatchEnable)
  199 + #if (${table.templateType} != 2 && $deleteBatchEnable)
198 200 checkboxAll: handleRowCheckboxChange,
199 201 checkboxChange: handleRowCheckboxChange,
200 202 #end
... ... @@ -229,13 +231,6 @@ const [Grid, gridApi] = useVbenVxeGrid({
229 231 <template #toolbar-tools>
230 232 <TableAction
231 233 :actions="[
232   - #if (${table.templateType} == 2)## 树表特有:展开/收缩按钮
233   - {
234   - label: isExpanded ? '收缩' : '展开',
235   - type: 'primary',
236   - onClick: toggleExpand,
237   - },
238   - #end
239 234 {
240 235 label: $t('ui.actionTitle.create', ['${table.classComment}']),
241 236 type: 'primary',
... ... @@ -243,6 +238,13 @@ const [Grid, gridApi] = useVbenVxeGrid({
243 238 auth: ['${table.moduleName}:${simpleClassName_strikeCase}:create'],
244 239 onClick: handleCreate,
245 240 },
  241 + #if (${table.templateType} == 2)## 树表特有:展开/收缩按钮
  242 + {
  243 + label: isExpanded ? '收缩' : '展开',
  244 + type: 'primary',
  245 + onClick: toggleExpand,
  246 + },
  247 + #end
246 248 {
247 249 label: $t('ui.actionTitle.export'),
248 250 type: 'primary',
... ...