Commit 5b29d5ff130374d22b19a8252d622a588ada4881
1 parent
716ac2f9
reactor:【infra 基础设施】处理 vben + vben 树形模版
Showing
2 changed files
with
32 additions
and
26 deletions
yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/schema/views/form.vue.vm
| @@ -117,6 +117,10 @@ const [Modal, modalApi] = useVbenModal({ | @@ -117,6 +117,10 @@ const [Modal, modalApi] = useVbenModal({ | ||
| 117 | // 加载数据 | 117 | // 加载数据 |
| 118 | const data = modalApi.getData<${apiName}.${simpleClassName}>(); | 118 | const data = modalApi.getData<${apiName}.${simpleClassName}>(); |
| 119 | if (!data || !data.id) { | 119 | if (!data || !data.id) { |
| 120 | +#if (${table.templateType} == 2)## 树表特有 | ||
| 121 | + // 设置上级 | ||
| 122 | + await formApi.setValues(data); | ||
| 123 | +#end | ||
| 120 | return; | 124 | return; |
| 121 | } | 125 | } |
| 122 | modalApi.lock(); | 126 | modalApi.lock(); |
yudao-module-infra/src/main/resources/codegen/vue3_vben5_antd/schema/views/index.vue.vm
| @@ -6,7 +6,7 @@ import type { ${apiName} } from '#/api/${table.moduleName}/${table.businessName} | @@ -6,7 +6,7 @@ import type { ${apiName} } from '#/api/${table.moduleName}/${table.businessName} | ||
| 6 | import { ref } from 'vue'; | 6 | import { ref } from 'vue'; |
| 7 | 7 | ||
| 8 | import {#if ($table.templateType != 2 && $deleteBatchEnable) confirm,#end Page, useVbenModal } from '@vben/common-ui'; | 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 | import { message#if ($table.templateType == 11), Tabs#end } from 'ant-design-vue'; | 11 | import { message#if ($table.templateType == 11), Tabs#end } from 'ant-design-vue'; |
| 12 | 12 | ||
| @@ -73,19 +73,19 @@ function onRefresh() { | @@ -73,19 +73,19 @@ function onRefresh() { | ||
| 73 | function handleCreate() { | 73 | function handleCreate() { |
| 74 | formModalApi.setData(null).open(); | 74 | formModalApi.setData(null).open(); |
| 75 | } | 75 | } |
| 76 | - | ||
| 77 | -/** 编辑${table.classComment} */ | ||
| 78 | -function handleEdit(row: ${apiName}.${simpleClassName}) { | ||
| 79 | - formModalApi.setData(row).open(); | ||
| 80 | -} | ||
| 81 | #if (${table.templateType} == 2)## 树表特有:新增下级 | 76 | #if (${table.templateType} == 2)## 树表特有:新增下级 |
| 82 | 77 | ||
| 83 | -/** 新增下级${table.classComment} */ | 78 | +/** 添加下级${table.classComment} */ |
| 84 | function handleAppend(row: ${apiName}.${simpleClassName}) { | 79 | function handleAppend(row: ${apiName}.${simpleClassName}) { |
| 85 | formModalApi.setData({ ${treeParentColumn.javaField}: row.id }).open(); | 80 | formModalApi.setData({ ${treeParentColumn.javaField}: row.id }).open(); |
| 86 | } | 81 | } |
| 87 | #end | 82 | #end |
| 88 | 83 | ||
| 84 | +/** 编辑${table.classComment} */ | ||
| 85 | +function handleEdit(row: ${apiName}.${simpleClassName}) { | ||
| 86 | + formModalApi.setData(row).open(); | ||
| 87 | +} | ||
| 88 | + | ||
| 89 | /** 删除${table.classComment} */ | 89 | /** 删除${table.classComment} */ |
| 90 | async function handleDelete(row: ${apiName}.${simpleClassName}) { | 90 | async function handleDelete(row: ${apiName}.${simpleClassName}) { |
| 91 | const hideLoading = message.loading({ | 91 | const hideLoading = message.loading({ |
| @@ -147,16 +147,9 @@ const [Grid, gridApi] = useVbenVxeGrid({ | @@ -147,16 +147,9 @@ const [Grid, gridApi] = useVbenVxeGrid({ | ||
| 147 | height: 'auto', | 147 | height: 'auto', |
| 148 | #end | 148 | #end |
| 149 | #if (${table.templateType} == 2)## 树表设置 | 149 | #if (${table.templateType} == 2)## 树表设置 |
| 150 | - treeConfig: { | ||
| 151 | - parentField: '${treeParentColumn.javaField}', | ||
| 152 | - rowField: 'id', | ||
| 153 | - transform: true, | ||
| 154 | - expandAll: true, | ||
| 155 | - reserve: true, | ||
| 156 | - }, | ||
| 157 | - pagerConfig: { | ||
| 158 | - enabled: false, | ||
| 159 | - }, | 150 | + pagerConfig: { |
| 151 | + enabled: false, | ||
| 152 | + }, | ||
| 160 | #else## 标准表设置 | 153 | #else## 标准表设置 |
| 161 | keepSource: true, | 154 | keepSource: true, |
| 162 | #end | 155 | #end |
| @@ -188,15 +181,24 @@ const [Grid, gridApi] = useVbenVxeGrid({ | @@ -188,15 +181,24 @@ const [Grid, gridApi] = useVbenVxeGrid({ | ||
| 188 | refresh: true, | 181 | refresh: true, |
| 189 | search: true, | 182 | search: true, |
| 190 | }, | 183 | }, |
| 184 | +#if (${table.templateType} == 2)## 树表设置 | ||
| 185 | + treeConfig: { | ||
| 186 | + parentField: '${treeParentColumn.javaField}', | ||
| 187 | + rowField: 'id', | ||
| 188 | + transform: true, | ||
| 189 | + expandAll: true, | ||
| 190 | + reserve: true, | ||
| 191 | + }, | ||
| 192 | +#end | ||
| 191 | } as VxeTableGridOptions<${apiName}.${simpleClassName}>, | 193 | } as VxeTableGridOptions<${apiName}.${simpleClassName}>, |
| 192 | -#if (${table.templateType} == 11 || $deleteBatchEnable) | 194 | +#if (${table.templateType} == 11 || (${table.templateType} != 2 && $deleteBatchEnable)) |
| 193 | gridEvents: { | 195 | gridEvents: { |
| 194 | #if(${table.templateType} == 11) | 196 | #if(${table.templateType} == 11) |
| 195 | cellClick: ({ row }: { row: ${apiName}.${simpleClassName}}) => { | 197 | cellClick: ({ row }: { row: ${apiName}.${simpleClassName}}) => { |
| 196 | select${simpleClassName}.value = row; | 198 | select${simpleClassName}.value = row; |
| 197 | }, | 199 | }, |
| 198 | #end | 200 | #end |
| 199 | - #if(${table.templateType} != 2 && $deleteBatchEnable) | 201 | + #if (${table.templateType} != 2 && $deleteBatchEnable) |
| 200 | checkboxAll: handleRowCheckboxChange, | 202 | checkboxAll: handleRowCheckboxChange, |
| 201 | checkboxChange: handleRowCheckboxChange, | 203 | checkboxChange: handleRowCheckboxChange, |
| 202 | #end | 204 | #end |
| @@ -231,13 +233,6 @@ const [Grid, gridApi] = useVbenVxeGrid({ | @@ -231,13 +233,6 @@ const [Grid, gridApi] = useVbenVxeGrid({ | ||
| 231 | <template #toolbar-tools> | 233 | <template #toolbar-tools> |
| 232 | <TableAction | 234 | <TableAction |
| 233 | :actions="[ | 235 | :actions="[ |
| 234 | - #if (${table.templateType} == 2)## 树表特有:展开/收缩按钮 | ||
| 235 | - { | ||
| 236 | - label: isExpanded ? '收缩' : '展开', | ||
| 237 | - type: 'primary', | ||
| 238 | - onClick: toggleExpand, | ||
| 239 | - }, | ||
| 240 | - #end | ||
| 241 | { | 236 | { |
| 242 | label: $t('ui.actionTitle.create', ['${table.classComment}']), | 237 | label: $t('ui.actionTitle.create', ['${table.classComment}']), |
| 243 | type: 'primary', | 238 | type: 'primary', |
| @@ -245,6 +240,13 @@ const [Grid, gridApi] = useVbenVxeGrid({ | @@ -245,6 +240,13 @@ const [Grid, gridApi] = useVbenVxeGrid({ | ||
| 245 | auth: ['${table.moduleName}:${simpleClassName_strikeCase}:create'], | 240 | auth: ['${table.moduleName}:${simpleClassName_strikeCase}:create'], |
| 246 | onClick: handleCreate, | 241 | onClick: handleCreate, |
| 247 | }, | 242 | }, |
| 243 | + #if (${table.templateType} == 2)## 树表特有:展开/收缩按钮 | ||
| 244 | + { | ||
| 245 | + label: isExpanded ? '收缩' : '展开', | ||
| 246 | + type: 'primary', | ||
| 247 | + onClick: toggleExpand, | ||
| 248 | + }, | ||
| 249 | + #end | ||
| 248 | { | 250 | { |
| 249 | label: $t('ui.actionTitle.export'), | 251 | label: $t('ui.actionTitle.export'), |
| 250 | type: 'primary', | 252 | type: 'primary', |