perf: vben5 代码生成

This commit is contained in:
xingyu4j 2025-05-06 22:14:10 +08:00
parent a34de9f223
commit 6ba0484f33
7 changed files with 15 additions and 28 deletions

View File

@ -3,7 +3,7 @@ import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleCl
import type { VxeTableInstance } from 'vxe-table'; import type { VxeTableInstance } from 'vxe-table';
import { Page, useVbenModal } from '@vben/common-ui'; import { Page, useVbenModal } from '@vben/common-ui';
import { cloneDeep, formatDateTime } from '@vben/utils'; import { cloneDeep, formatDateTime, getRangePickerDefaultProps } from '@vben/utils';
import { Button, message,Tabs,Pagination,Form,RangePicker,DatePicker,Select,Input } from 'ant-design-vue'; import { Button, message,Tabs,Pagination,Form,RangePicker,DatePicker,Select,Input } from 'ant-design-vue';
import { DictTag } from '#/components/dict-tag'; import { DictTag } from '#/components/dict-tag';
import { DICT_TYPE, getDictOptions } from '#/utils/dict'; import { DICT_TYPE, getDictOptions } from '#/utils/dict';
@ -12,7 +12,6 @@ import { Download, Plus, RefreshCw, Search } from '@vben/icons';
import { ContentWrap } from "#/components/content-wrap"; import { ContentWrap } from "#/components/content-wrap";
import { VxeColumn, VxeTable } from 'vxe-table'; import { VxeColumn, VxeTable } from 'vxe-table';
import { TableToolbar } from '#/components/table-toolbar'; import { TableToolbar } from '#/components/table-toolbar';
import { getRangePickerDefaultProps } from '#/utils/date';
## 特殊:主子表专属逻辑 ## 特殊:主子表专属逻辑
#if ( $table.templateType == 11 || $table.templateType == 12 ) #if ( $table.templateType == 11 || $table.templateType == 12 )
@ -31,7 +30,7 @@ import { get${simpleClassName}List, delete${simpleClassName}, export${simpleClas
#else## 标准表接口 #else## 标准表接口
import { get${simpleClassName}Page, delete${simpleClassName}, export${simpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; import { get${simpleClassName}Page, delete${simpleClassName}, export${simpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
#end #end
import { downloadByData } from '#/utils/download'; import { downloadFileFromBlobPart } from '@vben/utils';
#if ($table.templateType == 12 || $table.templateType == 11) ## 内嵌和erp情况 #if ($table.templateType == 12 || $table.templateType == 11) ## 内嵌和erp情况
/** 子表的列表 */ /** 子表的列表 */
@ -162,7 +161,7 @@ async function onExport() {
try { try {
exportLoading.value = true; exportLoading.value = true;
const data = await export${simpleClassName}(queryParams); const data = await export${simpleClassName}(queryParams);
downloadByData(data, '${table.classComment}.xls'); downloadFileFromBlobPart({ fileName: '${table.classComment}.xls', source: data });
}finally { }finally {
exportLoading.value = false; exportLoading.value = false;
} }

View File

@ -26,7 +26,7 @@
import { Plus } from '@vben/icons'; import { Plus } from '@vben/icons';
import { $t } from '#/locales'; import { $t } from '#/locales';
import { TableToolbar } from '#/components/table-toolbar'; import { TableToolbar } from '#/components/table-toolbar';
import { getRangePickerDefaultProps } from '#/utils/date'; import { getRangePickerDefaultProps } from '@vben/utils';
#end #end
#if ($table.templateType == 11) ## erp #if ($table.templateType == 11) ## erp

View File

@ -5,10 +5,10 @@ import type { ${simpleClassName}Api } from '#/api/${table.moduleName}/${simpleCl
import { z } from '#/adapter/form'; import { z } from '#/adapter/form';
#if(${table.templateType} == 2)## 树表需要导入这些 #if(${table.templateType} == 2)## 树表需要导入这些
import { get${simpleClassName}List } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; import { get${simpleClassName}List } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
import { handleTree } from '#/utils/tree'; import { handleTree } from '@vben/utils';
#end #end
import { DICT_TYPE, getDictOptions } from '#/utils/dict'; import { DICT_TYPE, getDictOptions } from '#/utils/dict';
import { getRangePickerDefaultProps } from '#/utils/date'; import { getRangePickerDefaultProps } from '@vben/utils';
import { useAccess } from '@vben/access'; import { useAccess } from '@vben/access';
const { hasAccessByCodes } = useAccess(); const { hasAccessByCodes } = useAccess();

View File

@ -102,10 +102,7 @@ const [Modal, modalApi] = useVbenModal({
// 关闭并提示 // 关闭并提示
await modalApi.close(); await modalApi.close();
emit('success'); emit('success');
message.success({ message.success( $t('ui.actionMessage.operationSuccess') );
content: $t('ui.actionMessage.operationSuccess'),
key: 'action_process_msg',
});
} finally { } finally {
modalApi.unlock(); modalApi.unlock();
} }

View File

@ -24,7 +24,7 @@ import { get${simpleClassName}List, delete${simpleClassName}, export${simpleClas
#else## 标准表接口 #else## 标准表接口
import { get${simpleClassName}Page, delete${simpleClassName}, export${simpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}'; import { get${simpleClassName}Page, delete${simpleClassName}, export${simpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
#end #end
import { downloadByData } from '#/utils/download'; import { downloadFileFromBlobPart } from '@vben/utils';
import { useGridColumns, useGridFormSchema } from './data'; import { useGridColumns, useGridFormSchema } from './data';
@ -85,10 +85,7 @@ async function onDelete(row: ${simpleClassName}Api.${simpleClassName}) {
}); });
try { try {
await delete${simpleClassName}(row.id as number); await delete${simpleClassName}(row.id as number);
message.success({ message.success( $t('ui.actionMessage.deleteSuccess', [row.id]) );
content: $t('ui.actionMessage.deleteSuccess', [row.id]),
key: 'action_process_msg',
});
onRefresh(); onRefresh();
} catch { } catch {
hideLoading(); hideLoading();
@ -98,7 +95,7 @@ async function onDelete(row: ${simpleClassName}Api.${simpleClassName}) {
/** 导出表格 */ /** 导出表格 */
async function onExport() { async function onExport() {
const data = await export${simpleClassName}(await gridApi.formApi.getValues()); const data = await export${simpleClassName}(await gridApi.formApi.getValues());
downloadByData(data, '${table.classComment}.xls'); downloadFileFromBlobPart({ fileName: '${table.classComment}.xls', source: data });
} }
/** 表格操作按钮的回调函数 */ /** 表格操作按钮的回调函数 */

View File

@ -52,10 +52,7 @@
// 关闭并提示 // 关闭并提示
await modalApi.close(); await modalApi.close();
emit('success'); emit('success');
message.success({ message.success( $t('ui.actionMessage.operationSuccess') );
content: $t('ui.actionMessage.operationSuccess'),
key: 'action_process_msg',
});
} finally { } finally {
modalApi.unlock(); modalApi.unlock();
} }

View File

@ -65,10 +65,7 @@ async function onDelete(row: ${simpleClassName}Api.${subSimpleClassName}) {
}); });
try { try {
await delete${subSimpleClassName}(row.id as number); await delete${subSimpleClassName}(row.id as number);
message.success({ message.success( $t('ui.actionMessage.deleteSuccess', [row.id]) );
content: $t('ui.actionMessage.deleteSuccess', [row.id]),
key: 'action_process_msg',
});
onRefresh(); onRefresh();
} catch { } catch {
hideLoading(); hideLoading();