fix: 预览改为message提示,修复Modal渲染问题和权限key

This commit is contained in:
zhouz
2026-07-15 19:57:02 +08:00
parent cfe111a698
commit 9f89f16771

View File

@@ -7,6 +7,7 @@ import { ref } from 'vue';
import { confirm, Page, useVbenModal } from '@vben/common-ui';
import { isEmpty } from '@vben/utils';
import { message } from 'antdv-next';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { deleteCodeRule, getCodeRulePage, previewCode } from '#/api/base/codegen';
@@ -70,19 +71,17 @@ async function handleDeleteBatch() {
}
/** 预览下一个编码 */
const previewVisible = ref(false);
const previewLoading = ref(false);
const previewCodeValue = ref('');
const previewTitle = ref('');
async function handlePreview(row: BaseCodeRuleApi.CodeRule) {
previewTitle.value = row.ruleName;
previewLoading.value = true;
previewVisible.value = true;
try {
const result = await previewCode(row.ruleCode);
previewCodeValue.value = result ?? '';
message.success({
content: `${row.ruleName}】下一个编码:${result}`,
duration: 5,
});
} catch {
previewCodeValue.value = '预览失败';
message.error('预览失败');
} finally {
previewLoading.value = false;
}
@@ -145,7 +144,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
label: $t('ui.actionTitle.create', ['编码规则']),
type: 'primary',
icon: ACTION_ICON.ADD,
auth: ['base:codeGen:create'],
auth: ['base:code-rule:create'],
onClick: handleCreate,
},
{
@@ -153,7 +152,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
type: 'primary',
danger: true,
icon: ACTION_ICON.DELETE,
auth: ['base:codeGen:delete'],
auth: ['base:code-rule:delete'],
disabled: isEmpty(checkedIds),
onClick: handleDeleteBatch,
},
@@ -167,14 +166,14 @@ const [Grid, gridApi] = useVbenVxeGrid({
label: '预览',
type: 'link',
icon: ACTION_ICON.SEARCH,
auth: ['base:codeGen:query'],
auth: ['base:code-rule:query'],
onClick: handlePreview.bind(null, row),
},
{
label: $t('common.edit'),
type: 'link',
icon: ACTION_ICON.EDIT,
auth: ['base:codeGen:update'],
auth: ['base:code-rule:update'],
onClick: handleEdit.bind(null, row),
},
{
@@ -182,7 +181,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
type: 'link',
danger: true,
icon: ACTION_ICON.DELETE,
auth: ['base:codeGen:delete'],
auth: ['base:code-rule:delete'],
popConfirm: {
title: $t('ui.actionMessage.deleteConfirm', [row.ruleName]),
confirm: handleDelete.bind(null, row),
@@ -192,23 +191,5 @@ const [Grid, gridApi] = useVbenVxeGrid({
/>
</template>
</Grid>
<!-- 预览弹窗 -->
<Modal
v-model:open="previewVisible"
title="编码预览"
:footer="null"
:width="500"
>
<div v-if="previewLoading" class="py-8 text-center text-gray-400">
加载中...
</div>
<div v-else class="py-4">
<p class="mb-2 text-sm text-gray-500">规则{{ previewTitle }}</p>
<p class="text-2xl font-mono font-bold tracking-wider text-blue-600">
{{ previewCodeValue }}
</p>
</div>
</Modal>
</Page>
</template>