feat:【infra】优化 codegen 的 vben 模版
This commit is contained in:
parent
5e46e0c4f8
commit
11dd2308b3
@ -123,7 +123,7 @@ const [FormModal, formModalApi] = useVbenModal({
|
|||||||
|
|
||||||
/** 创建${table.classComment} */
|
/** 创建${table.classComment} */
|
||||||
function handleCreate() {
|
function handleCreate() {
|
||||||
formModalApi.setData({}).open();
|
formModalApi.setData(null).open();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 编辑${table.classComment} */
|
/** 编辑${table.classComment} */
|
||||||
|
|||||||
@ -43,7 +43,6 @@
|
|||||||
if (!valid) {
|
if (!valid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
modalApi.lock();
|
modalApi.lock();
|
||||||
// 提交表单
|
// 提交表单
|
||||||
const data = (await formApi.getValues()) as ${apiName}.${subSimpleClassName};
|
const data = (await formApi.getValues()) as ${apiName}.${subSimpleClassName};
|
||||||
@ -63,7 +62,6 @@
|
|||||||
formData.value = undefined;
|
formData.value = undefined;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载数据
|
// 加载数据
|
||||||
let data = modalApi.getData<${apiName}.${subSimpleClassName}>();
|
let data = modalApi.getData<${apiName}.${subSimpleClassName}>();
|
||||||
if (!data) {
|
if (!data) {
|
||||||
|
|||||||
@ -38,7 +38,7 @@ function onActionClick({
|
|||||||
}: OnActionClickParams<${apiName}.${subSimpleClassName}>) {
|
}: OnActionClickParams<${apiName}.${subSimpleClassName}>) {
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case 'delete': {
|
case 'delete': {
|
||||||
onDelete(row);
|
handleDelete(row);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -64,12 +64,12 @@ gridOptions: {
|
|||||||
});
|
});
|
||||||
|
|
||||||
/** 添加${subTable.classComment} */
|
/** 添加${subTable.classComment} */
|
||||||
const onAdd = async () => {
|
const handleAdd = async () => {
|
||||||
await gridApi.grid.insertAt({} as ${apiName}.${subSimpleClassName}, -1);
|
await gridApi.grid.insertAt({} as ${apiName}.${subSimpleClassName}, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 删除${subTable.classComment} */
|
/** 删除${subTable.classComment} */
|
||||||
const onDelete = async (row: ${apiName}.${subSimpleClassName}) => {
|
const handleDelete = async (row: ${apiName}.${subSimpleClassName}) => {
|
||||||
await gridApi.grid.remove(row);
|
await gridApi.grid.remove(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,7 +188,7 @@ watch(
|
|||||||
#end
|
#end
|
||||||
</Grid>
|
</Grid>
|
||||||
<div class="flex justify-center -mt-4">
|
<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}']) }}
|
{{ $t('ui.actionTitle.create', ['${subTable.classComment}']) }}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import type { ${apiName} } from '#/api/${table.moduleName}/${table.businessName}
|
|||||||
#if ($table.templateType == 11) ## erp
|
#if ($table.templateType == 11) ## erp
|
||||||
import ${subSimpleClassName}Form from './${subSimpleClassName_strikeCase}-form.vue'
|
import ${subSimpleClassName}Form from './${subSimpleClassName_strikeCase}-form.vue'
|
||||||
#end
|
#end
|
||||||
import { useVbenModal } from '@vben/common-ui';
|
import { confirm, useVbenModal } from '@vben/common-ui';
|
||||||
import { message } from 'ant-design-vue';
|
import { message } from 'ant-design-vue';
|
||||||
import { ref, computed, nextTick,watch } from 'vue';
|
import { ref, computed, nextTick,watch } from 'vue';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
@ -74,8 +74,9 @@ async function handleDelete(row: ${apiName}.${subSimpleClassName}) {
|
|||||||
#if ($deleteBatchEnable)
|
#if ($deleteBatchEnable)
|
||||||
/** 批量删除${subTable.classComment} */
|
/** 批量删除${subTable.classComment} */
|
||||||
async function handleDeleteBatch() {
|
async function handleDeleteBatch() {
|
||||||
|
await confirm($t('ui.actionMessage.deleteBatchConfirm'));
|
||||||
const hideLoading = message.loading({
|
const hideLoading = message.loading({
|
||||||
content: $t('ui.actionMessage.deleting'),
|
content: $t('ui.actionMessage.deletingBatch'),
|
||||||
duration: 0,
|
duration: 0,
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -123,7 +123,7 @@ const [FormModal, formModalApi] = useVbenModal({
|
|||||||
|
|
||||||
/** 创建${table.classComment} */
|
/** 创建${table.classComment} */
|
||||||
function handleCreate() {
|
function handleCreate() {
|
||||||
formModalApi.setData({}).open();
|
formModalApi.setData(null).open();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 编辑${table.classComment} */
|
/** 编辑${table.classComment} */
|
||||||
@ -142,7 +142,6 @@ function handleAppend(row: ${simpleClassName}Api.${simpleClassName}) {
|
|||||||
async function handleDelete(row: ${simpleClassName}Api.${simpleClassName}) {
|
async function handleDelete(row: ${simpleClassName}Api.${simpleClassName}) {
|
||||||
const loadingInstance = ElLoading.service({
|
const loadingInstance = ElLoading.service({
|
||||||
text: $t('ui.actionMessage.deleting', [row.id]),
|
text: $t('ui.actionMessage.deleting', [row.id]),
|
||||||
background: 'rgba(0, 0, 0, 0.7)',
|
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await delete${simpleClassName}(row.id as number);
|
await delete${simpleClassName}(row.id as number);
|
||||||
@ -158,7 +157,6 @@ async function handleDelete(row: ${simpleClassName}Api.${simpleClassName}) {
|
|||||||
async function handleDeleteBatch() {
|
async function handleDeleteBatch() {
|
||||||
const loadingInstance = ElLoading.service({
|
const loadingInstance = ElLoading.service({
|
||||||
text: $t('ui.actionMessage.deleting'),
|
text: $t('ui.actionMessage.deleting'),
|
||||||
background: 'rgba(0, 0, 0, 0.7)',
|
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await delete${simpleClassName}List(checkedIds.value);
|
await delete${simpleClassName}List(checkedIds.value);
|
||||||
|
|||||||
@ -69,7 +69,6 @@ function handleEdit(row: ${simpleClassName}Api.${subSimpleClassName}) {
|
|||||||
async function handleDelete(row: ${simpleClassName}Api.${subSimpleClassName}) {
|
async function handleDelete(row: ${simpleClassName}Api.${subSimpleClassName}) {
|
||||||
const loadingInstance = ElLoading.service({
|
const loadingInstance = ElLoading.service({
|
||||||
text: $t('ui.actionMessage.deleting', [row.id]),
|
text: $t('ui.actionMessage.deleting', [row.id]),
|
||||||
background: 'rgba(0, 0, 0, 0.7)',
|
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await delete${subSimpleClassName}(row.id as number);
|
await delete${subSimpleClassName}(row.id as number);
|
||||||
@ -85,7 +84,6 @@ async function handleDelete(row: ${simpleClassName}Api.${subSimpleClassName}) {
|
|||||||
async function handleDeleteBatch() {
|
async function handleDeleteBatch() {
|
||||||
const loadingInstance = ElLoading.service({
|
const loadingInstance = ElLoading.service({
|
||||||
text: $t('ui.actionMessage.deleting'),
|
text: $t('ui.actionMessage.deleting'),
|
||||||
background: 'rgba(0, 0, 0, 0.7)',
|
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await delete${subSimpleClassName}List(checkedIds.value);
|
await delete${subSimpleClassName}List(checkedIds.value);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user