Commit 74712db1a8083a8f195e10cf0626347064dabe5e

Authored by puhui999
1 parent 38c76806

perf: vben5 代码生成

yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/general/views/index.vue.vm
1 1 <script lang="ts" setup>
2 2 import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
3   -import type { VxeTableInstance } from 'vxe-table';
  3 +import type { VxeTableInstance } from '#/adapter/vxe-table';
4 4  
5 5 import { Page, useVbenModal } from '@vben/common-ui';
6 6 import { cloneDeep, formatDateTime } from '@vben/utils';
... ... @@ -9,9 +9,10 @@ import { DictTag } from &#39;#/components/dict-tag&#39;;
9 9 import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';
10 10 import ${simpleClassName}Form from './modules/form.vue';
11 11 import { Download, Plus, RefreshCw, Search } from '@vben/icons';
12   -import { ContentWrap } from "#/components/content-wrap";
13   -import { VxeColumn, VxeTable } from 'vxe-table';
  12 +import { ContentWrap } from '#/components/content-wrap';
  13 +import { VxeColumn, VxeTable } from '#/adapter/vxe-table';
14 14 import { TableToolbar } from '#/components/table-toolbar';
  15 +import { useTableToolbar } from '#/hooks';
15 16  
16 17 ## 特殊:主子表专属逻辑
17 18 #if ( $table.templateType == 11 || $table.templateType == 12 )
... ... @@ -167,11 +168,6 @@ try {
167 168 }
168 169 }
169 170  
170   -/** 隐藏搜索栏 */
171   -const hiddenSearchBar = ref(false);
172   -const tableToolbarRef = ref<InstanceType<typeof TableToolbar>>();
173   -const tableRef = ref<VxeTableInstance>();
174   -
175 171 #if (${table.templateType} == 2)
176 172 /** 切换树形展开/收缩状态 */
177 173 const isExpanded = ref(true);
... ... @@ -182,15 +178,9 @@ function toggleExpand() {
182 178 #end
183 179  
184 180 /** 初始化 */
185   -onMounted(async () => {
186   - await getList();
187   - await nextTick();
188   - // 挂载 toolbar 工具栏
189   - const table = tableRef.value;
190   - const tableToolbar = tableToolbarRef.value;
191   - if (table && tableToolbar) {
192   - await table.connect(tableToolbar.getToolbarRef()!);
193   - }
  181 +const { hiddenSearchBar, tableToolbarRef, tableRef } = useTableToolbar();
  182 +onMounted(() => {
  183 + getList();
194 184 });
195 185 </script>
196 186  
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/general/views/modules/form_sub_normal.vue.vm
... ... @@ -13,9 +13,9 @@
13 13 import { DICT_TYPE, getDictOptions } from '#/utils';
14 14  
15 15 #if ($subTable.subJoinMany) ## 一对多
16   -import type { VxeTableInstance } from 'vxe-table';
  16 +import type { VxeTableInstance } from '#/adapter/vxe-table';
17 17 import { Plus } from "@vben/icons";
18   -import { VxeColumn, VxeTable } from 'vxe-table';
  18 +import { VxeColumn, VxeTable } from '#/adapter/vxe-table';
19 19 import { get${subSimpleClassName}ListBy${SubJoinColumnName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
20 20 #else
21 21 import type { Rule } from 'ant-design-vue/es/form';
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3_vben5_antd/general/views/modules/list_sub_erp.vue.vm
... ... @@ -7,14 +7,14 @@
7 7 #set ($SubJoinColumnName = $subJoinColumn.javaField.substring(0,1).toUpperCase() + ${subJoinColumn.javaField.substring(1)})##首字母大写
8 8 <script lang="ts" setup>
9 9 import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
10   - import type { VxeTableInstance } from 'vxe-table';
  10 + import type { VxeTableInstance } from '#/adapter/vxe-table';
11 11  
12 12 import { DictTag } from '#/components/dict-tag';
13 13 import { DICT_TYPE, getDictOptions } from '#/utils';
14   - import { VxeColumn, VxeTable } from 'vxe-table';
  14 + import { VxeColumn, VxeTable } from '#/adapter/vxe-table';
15 15 import { reactive,ref, h, nextTick,watch,onMounted } from 'vue';
16 16 import { cloneDeep, formatDateTime } from '@vben/utils';
17   - import { ContentWrap } from "#/components/content-wrap";
  17 + import { ContentWrap } from '#/components/content-wrap';
18 18  
19 19 #if ($table.templateType == 11) ## erp
20 20 import { useVbenModal } from '@vben/common-ui';
... ... @@ -26,6 +26,7 @@
26 26 import { Plus } from '@vben/icons';
27 27 import { $t } from '#/locales';
28 28 import { TableToolbar } from '#/components/table-toolbar';
  29 + import { useTableToolbar } from '#/hooks';
29 30 #end
30 31  
31 32 #if ($table.templateType == 11) ## erp
... ... @@ -165,21 +166,10 @@ const resetQuery = () =&gt; {
165 166 );
166 167  
167 168 #if ($table.templateType == 11) ## erp
168   -/** 隐藏搜索栏 */
169   -const hiddenSearchBar = ref(false);
170   -const tableToolbarRef = ref<InstanceType<typeof TableToolbar>>();
171   -const tableRef = ref<VxeTableInstance>();
172   -
173 169 /** 初始化 */
174   -onMounted(async () => {
175   - await getList();
176   - await nextTick();
177   - // 挂载 toolbar 工具栏
178   - const table = tableRef.value;
179   - const tableToolbar = tableToolbarRef.value;
180   - if (table && tableToolbar) {
181   - await table.connect(tableToolbar.getToolbarRef()!);
182   - }
  170 +const { hiddenSearchBar, tableToolbarRef, tableRef } = useTableToolbar();
  171 +onMounted(() => {
  172 + getList();
183 173 });
184 174 #end
185 175 </script>
... ...