feat:【infra】优化 codegen 的 vben 模版

This commit is contained in:
YunaiV 2025-10-01 15:39:36 +08:00
parent 5e46e0c4f8
commit 11dd2308b3
6 changed files with 9 additions and 14 deletions

View File

@ -123,7 +123,7 @@ const [FormModal, formModalApi] = useVbenModal({
/** 创建${table.classComment} */
function handleCreate() {
formModalApi.setData({}).open();
formModalApi.setData(null).open();
}
/** 编辑${table.classComment} */

View File

@ -43,7 +43,6 @@
if (!valid) {
return;
}
modalApi.lock();
// 提交表单
const data = (await formApi.getValues()) as ${apiName}.${subSimpleClassName};
@ -63,7 +62,6 @@
formData.value = undefined;
return;
}
// 加载数据
let data = modalApi.getData<${apiName}.${subSimpleClassName}>();
if (!data) {

View File

@ -38,7 +38,7 @@ function onActionClick({
}: OnActionClickParams<${apiName}.${subSimpleClassName}>) {
switch (code) {
case 'delete': {
onDelete(row);
handleDelete(row);
break;
}
}
@ -64,12 +64,12 @@ gridOptions: {
});
/** 添加${subTable.classComment} */
const onAdd = async () => {
const handleAdd = async () => {
await gridApi.grid.insertAt({} as ${apiName}.${subSimpleClassName}, -1);
}
/** 删除${subTable.classComment} */
const onDelete = async (row: ${apiName}.${subSimpleClassName}) => {
const handleDelete = async (row: ${apiName}.${subSimpleClassName}) => {
await gridApi.grid.remove(row);
}
@ -188,7 +188,7 @@ watch(
#end
</Grid>
<div class="flex justify-center -mt-4">
<Button :icon="h(Plus)" type="primary" ghost @click="onAdd" v-access:code="['${subTable.moduleName}:${simpleClassName_strikeCase}:create']">
<Button :icon="h(Plus)" type="primary" ghost @click="handleAdd" v-access:code="['${subTable.moduleName}:${simpleClassName_strikeCase}:create']">
{{ $t('ui.actionTitle.create', ['${subTable.classComment}']) }}
</Button>
</div>

View File

@ -13,7 +13,7 @@ import type { ${apiName} } from '#/api/${table.moduleName}/${table.businessName}
#if ($table.templateType == 11) ## erp
import ${subSimpleClassName}Form from './${subSimpleClassName_strikeCase}-form.vue'
#end
import { useVbenModal } from '@vben/common-ui';
import { confirm, useVbenModal } from '@vben/common-ui';
import { message } from 'ant-design-vue';
import { ref, computed, nextTick,watch } from 'vue';
import { $t } from '#/locales';
@ -74,8 +74,9 @@ async function handleDelete(row: ${apiName}.${subSimpleClassName}) {
#if ($deleteBatchEnable)
/** 批量删除${subTable.classComment} */
async function handleDeleteBatch() {
await confirm($t('ui.actionMessage.deleteBatchConfirm'));
const hideLoading = message.loading({
content: $t('ui.actionMessage.deleting'),
content: $t('ui.actionMessage.deletingBatch'),
duration: 0,
});
try {

View File

@ -123,7 +123,7 @@ const [FormModal, formModalApi] = useVbenModal({
/** 创建${table.classComment} */
function handleCreate() {
formModalApi.setData({}).open();
formModalApi.setData(null).open();
}
/** 编辑${table.classComment} */
@ -142,7 +142,6 @@ function handleAppend(row: ${simpleClassName}Api.${simpleClassName}) {
async function handleDelete(row: ${simpleClassName}Api.${simpleClassName}) {
const loadingInstance = ElLoading.service({
text: $t('ui.actionMessage.deleting', [row.id]),
background: 'rgba(0, 0, 0, 0.7)',
});
try {
await delete${simpleClassName}(row.id as number);
@ -158,7 +157,6 @@ async function handleDelete(row: ${simpleClassName}Api.${simpleClassName}) {
async function handleDeleteBatch() {
const loadingInstance = ElLoading.service({
text: $t('ui.actionMessage.deleting'),
background: 'rgba(0, 0, 0, 0.7)',
});
try {
await delete${simpleClassName}List(checkedIds.value);

View File

@ -69,7 +69,6 @@ function handleEdit(row: ${simpleClassName}Api.${subSimpleClassName}) {
async function handleDelete(row: ${simpleClassName}Api.${subSimpleClassName}) {
const loadingInstance = ElLoading.service({
text: $t('ui.actionMessage.deleting', [row.id]),
background: 'rgba(0, 0, 0, 0.7)',
});
try {
await delete${subSimpleClassName}(row.id as number);
@ -85,7 +84,6 @@ async function handleDelete(row: ${simpleClassName}Api.${subSimpleClassName}) {
async function handleDeleteBatch() {
const loadingInstance = ElLoading.service({
text: $t('ui.actionMessage.deleting'),
background: 'rgba(0, 0, 0, 0.7)',
});
try {
await delete${subSimpleClassName}List(checkedIds.value);