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 { 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 { DictTag } from '#/components/dict-tag';
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 { VxeColumn, VxeTable } from 'vxe-table';
import { TableToolbar } from '#/components/table-toolbar';
import { getRangePickerDefaultProps } from '#/utils/date';
## 特殊:主子表专属逻辑
#if ( $table.templateType == 11 || $table.templateType == 12 )
@ -31,7 +30,7 @@ import { get${simpleClassName}List, delete${simpleClassName}, export${simpleClas
#else## 标准表接口
import { get${simpleClassName}Page, delete${simpleClassName}, export${simpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
#end
import { downloadByData } from '#/utils/download';
import { downloadFileFromBlobPart } from '@vben/utils';
#if ($table.templateType == 12 || $table.templateType == 11) ## 内嵌和erp情况
/** 子表的列表 */
@ -162,7 +161,7 @@ async function onExport() {
try {
exportLoading.value = true;
const data = await export${simpleClassName}(queryParams);
downloadByData(data, '${table.classComment}.xls');
downloadFileFromBlobPart({ fileName: '${table.classComment}.xls', source: data });
}finally {
exportLoading.value = false;
}
@ -281,7 +280,7 @@ onMounted(async () => {
</Form.Item>
</Form>
</ContentWrap>
<!-- 列表 -->
<ContentWrap title="${table.classComment}">
<template #extra>

View File

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

View File

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

View File

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

View File

@ -24,7 +24,7 @@ import { get${simpleClassName}List, delete${simpleClassName}, export${simpleClas
#else## 标准表接口
import { get${simpleClassName}Page, delete${simpleClassName}, export${simpleClassName} } from '#/api/${table.moduleName}/${simpleClassName_strikeCase}';
#end
import { downloadByData } from '#/utils/download';
import { downloadFileFromBlobPart } from '@vben/utils';
import { useGridColumns, useGridFormSchema } from './data';
@ -85,10 +85,7 @@ async function onDelete(row: ${simpleClassName}Api.${simpleClassName}) {
});
try {
await delete${simpleClassName}(row.id as number);
message.success({
content: $t('ui.actionMessage.deleteSuccess', [row.id]),
key: 'action_process_msg',
});
message.success( $t('ui.actionMessage.deleteSuccess', [row.id]) );
onRefresh();
} catch {
hideLoading();
@ -98,7 +95,7 @@ async function onDelete(row: ${simpleClassName}Api.${simpleClassName}) {
/** 导出表格 */
async function onExport() {
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();
emit('success');
message.success({
content: $t('ui.actionMessage.operationSuccess'),
key: 'action_process_msg',
});
message.success( $t('ui.actionMessage.operationSuccess') );
} finally {
modalApi.unlock();
}

View File

@ -65,10 +65,7 @@ async function onDelete(row: ${simpleClassName}Api.${subSimpleClassName}) {
});
try {
await delete${subSimpleClassName}(row.id as number);
message.success({
content: $t('ui.actionMessage.deleteSuccess', [row.id]),
key: 'action_process_msg',
});
message.success( $t('ui.actionMessage.deleteSuccess', [row.id]) );
onRefresh();
} catch {
hideLoading();
@ -181,4 +178,4 @@ const onRefresh = async ()=> {
#else
<Grid table-title="${subTable.classComment}列表" />
#end
</template>
</template>