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 | 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_antd/schema/views/index.vue.vm
| ... | ... | @@ -6,7 +6,7 @@ import type { ${apiName} } from '#/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 { message#if ($table.templateType == 11), Tabs#end } from 'ant-design-vue'; |
| 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 hideLoading = message.loading({ |
| ... | ... | @@ -147,16 +147,9 @@ const [Grid, gridApi] = useVbenVxeGrid({ |
| 147 | 147 | height: 'auto', |
| 148 | 148 | #end |
| 149 | 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 | 153 | #else## 标准表设置 |
| 161 | 154 | keepSource: true, |
| 162 | 155 | #end |
| ... | ... | @@ -188,15 +181,24 @@ const [Grid, gridApi] = useVbenVxeGrid({ |
| 188 | 181 | refresh: true, |
| 189 | 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 | 193 | } as VxeTableGridOptions<${apiName}.${simpleClassName}>, |
| 192 | -#if (${table.templateType} == 11 || $deleteBatchEnable) | |
| 194 | +#if (${table.templateType} == 11 || (${table.templateType} != 2 && $deleteBatchEnable)) | |
| 193 | 195 | gridEvents: { |
| 194 | 196 | #if(${table.templateType} == 11) |
| 195 | 197 | cellClick: ({ row }: { row: ${apiName}.${simpleClassName}}) => { |
| 196 | 198 | select${simpleClassName}.value = row; |
| 197 | 199 | }, |
| 198 | 200 | #end |
| 199 | - #if(${table.templateType} != 2 && $deleteBatchEnable) | |
| 201 | + #if (${table.templateType} != 2 && $deleteBatchEnable) | |
| 200 | 202 | checkboxAll: handleRowCheckboxChange, |
| 201 | 203 | checkboxChange: handleRowCheckboxChange, |
| 202 | 204 | #end |
| ... | ... | @@ -231,13 +233,6 @@ const [Grid, gridApi] = useVbenVxeGrid({ |
| 231 | 233 | <template #toolbar-tools> |
| 232 | 234 | <TableAction |
| 233 | 235 | :actions="[ |
| 234 | - #if (${table.templateType} == 2)## 树表特有:展开/收缩按钮 | |
| 235 | - { | |
| 236 | - label: isExpanded ? '收缩' : '展开', | |
| 237 | - type: 'primary', | |
| 238 | - onClick: toggleExpand, | |
| 239 | - }, | |
| 240 | - #end | |
| 241 | 236 | { |
| 242 | 237 | label: $t('ui.actionTitle.create', ['${table.classComment}']), |
| 243 | 238 | type: 'primary', |
| ... | ... | @@ -245,6 +240,13 @@ const [Grid, gridApi] = useVbenVxeGrid({ |
| 245 | 240 | auth: ['${table.moduleName}:${simpleClassName_strikeCase}:create'], |
| 246 | 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 | 251 | label: $t('ui.actionTitle.export'), |
| 250 | 252 | type: 'primary', | ... | ... |