fix: 预览改为message提示,修复Modal渲染问题和权限key
This commit is contained in:
@@ -7,6 +7,7 @@ import { ref } from 'vue';
|
|||||||
import { confirm, Page, useVbenModal } from '@vben/common-ui';
|
import { confirm, Page, useVbenModal } from '@vben/common-ui';
|
||||||
import { isEmpty } from '@vben/utils';
|
import { isEmpty } from '@vben/utils';
|
||||||
|
|
||||||
|
import { message } from 'antdv-next';
|
||||||
|
|
||||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
import { deleteCodeRule, getCodeRulePage, previewCode } from '#/api/base/codegen';
|
import { deleteCodeRule, getCodeRulePage, previewCode } from '#/api/base/codegen';
|
||||||
@@ -70,19 +71,17 @@ async function handleDeleteBatch() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 预览下一个编码 */
|
/** 预览下一个编码 */
|
||||||
const previewVisible = ref(false);
|
|
||||||
const previewLoading = ref(false);
|
const previewLoading = ref(false);
|
||||||
const previewCodeValue = ref('');
|
|
||||||
const previewTitle = ref('');
|
|
||||||
async function handlePreview(row: BaseCodeRuleApi.CodeRule) {
|
async function handlePreview(row: BaseCodeRuleApi.CodeRule) {
|
||||||
previewTitle.value = row.ruleName;
|
|
||||||
previewLoading.value = true;
|
previewLoading.value = true;
|
||||||
previewVisible.value = true;
|
|
||||||
try {
|
try {
|
||||||
const result = await previewCode(row.ruleCode);
|
const result = await previewCode(row.ruleCode);
|
||||||
previewCodeValue.value = result ?? '';
|
message.success({
|
||||||
|
content: `【${row.ruleName}】下一个编码:${result}`,
|
||||||
|
duration: 5,
|
||||||
|
});
|
||||||
} catch {
|
} catch {
|
||||||
previewCodeValue.value = '预览失败';
|
message.error('预览失败');
|
||||||
} finally {
|
} finally {
|
||||||
previewLoading.value = false;
|
previewLoading.value = false;
|
||||||
}
|
}
|
||||||
@@ -145,7 +144,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
label: $t('ui.actionTitle.create', ['编码规则']),
|
label: $t('ui.actionTitle.create', ['编码规则']),
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
icon: ACTION_ICON.ADD,
|
icon: ACTION_ICON.ADD,
|
||||||
auth: ['base:codeGen:create'],
|
auth: ['base:code-rule:create'],
|
||||||
onClick: handleCreate,
|
onClick: handleCreate,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -153,7 +152,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
type: 'primary',
|
type: 'primary',
|
||||||
danger: true,
|
danger: true,
|
||||||
icon: ACTION_ICON.DELETE,
|
icon: ACTION_ICON.DELETE,
|
||||||
auth: ['base:codeGen:delete'],
|
auth: ['base:code-rule:delete'],
|
||||||
disabled: isEmpty(checkedIds),
|
disabled: isEmpty(checkedIds),
|
||||||
onClick: handleDeleteBatch,
|
onClick: handleDeleteBatch,
|
||||||
},
|
},
|
||||||
@@ -167,14 +166,14 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
label: '预览',
|
label: '预览',
|
||||||
type: 'link',
|
type: 'link',
|
||||||
icon: ACTION_ICON.SEARCH,
|
icon: ACTION_ICON.SEARCH,
|
||||||
auth: ['base:codeGen:query'],
|
auth: ['base:code-rule:query'],
|
||||||
onClick: handlePreview.bind(null, row),
|
onClick: handlePreview.bind(null, row),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: $t('common.edit'),
|
label: $t('common.edit'),
|
||||||
type: 'link',
|
type: 'link',
|
||||||
icon: ACTION_ICON.EDIT,
|
icon: ACTION_ICON.EDIT,
|
||||||
auth: ['base:codeGen:update'],
|
auth: ['base:code-rule:update'],
|
||||||
onClick: handleEdit.bind(null, row),
|
onClick: handleEdit.bind(null, row),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -182,7 +181,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
type: 'link',
|
type: 'link',
|
||||||
danger: true,
|
danger: true,
|
||||||
icon: ACTION_ICON.DELETE,
|
icon: ACTION_ICON.DELETE,
|
||||||
auth: ['base:codeGen:delete'],
|
auth: ['base:code-rule:delete'],
|
||||||
popConfirm: {
|
popConfirm: {
|
||||||
title: $t('ui.actionMessage.deleteConfirm', [row.ruleName]),
|
title: $t('ui.actionMessage.deleteConfirm', [row.ruleName]),
|
||||||
confirm: handleDelete.bind(null, row),
|
confirm: handleDelete.bind(null, row),
|
||||||
@@ -192,23 +191,5 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</Grid>
|
</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>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user