mirror of
https://gitee.com/dapppp/ruoyi-plus-vben5.git
synced 2026-03-08 07:31:09 +08:00
feat: 优化审批面板抽屉组件类型与逻辑
- 引入 ApprovalType 类型替代内联联合类型,提升代码可维护性 - 使用 computed 计算属性 showFooter 控制底部操作栏显隐逻辑 - 移除原先通过 drawerApi 动态设置 footer 的方式,改用条件渲染 - 修复 footer 插槽在只读模式下仍渲染内容的问题 - 添加 TODO 注释说明当前 footer 插槽存在的设计问题
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import type { ApprovalType } from './type';
|
||||||
|
|
||||||
import type { FlowInfoResponse } from '#/api/workflow/instance/model';
|
import type { FlowInfoResponse } from '#/api/workflow/instance/model';
|
||||||
import type { TaskInfo } from '#/api/workflow/task/model';
|
import type { TaskInfo } from '#/api/workflow/task/model';
|
||||||
|
|
||||||
import { ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
import { useVbenDrawer, VbenAvatar } from '@vben/common-ui';
|
import { useVbenDrawer, VbenAvatar } from '@vben/common-ui';
|
||||||
import { DictEnum } from '@vben/constants';
|
import { DictEnum } from '@vben/constants';
|
||||||
@@ -22,7 +24,7 @@ const emit = defineEmits<{ reload: [] }>();
|
|||||||
|
|
||||||
interface DrawerProps {
|
interface DrawerProps {
|
||||||
task: TaskInfo;
|
task: TaskInfo;
|
||||||
type: 'admin' | 'approve' | 'myself' | 'readonly';
|
type: ApprovalType;
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentTask = ref<null | TaskInfo>(null);
|
const currentTask = ref<null | TaskInfo>(null);
|
||||||
@@ -31,8 +33,6 @@ const currentType = ref<DrawerProps['type'] | null>(null);
|
|||||||
|
|
||||||
const [BasicDrawer, drawerApi] = useVbenDrawer({
|
const [BasicDrawer, drawerApi] = useVbenDrawer({
|
||||||
title: '流程',
|
title: '流程',
|
||||||
// 默认不显示footer
|
|
||||||
footer: false,
|
|
||||||
onOpenChange: async (isOpen) => {
|
onOpenChange: async (isOpen) => {
|
||||||
if (!isOpen) {
|
if (!isOpen) {
|
||||||
return null;
|
return null;
|
||||||
@@ -62,10 +62,10 @@ const [BasicDrawer, drawerApi] = useVbenDrawer({
|
|||||||
}
|
}
|
||||||
// 最后赋值type
|
// 最后赋值type
|
||||||
currentType.value = type;
|
currentType.value = type;
|
||||||
// 设置是否显示footer
|
// // 设置是否显示footer
|
||||||
drawerApi.setState({
|
// drawerApi.setState({
|
||||||
footer: type !== 'readonly',
|
// footer: type !== 'readonly',
|
||||||
});
|
// });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -88,6 +88,10 @@ async function handleAfterAction() {
|
|||||||
emit('reload');
|
emit('reload');
|
||||||
drawerApi.close();
|
drawerApi.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const showFooter = computed(() => {
|
||||||
|
return ![null, 'readonly'].includes(currentType.value);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -152,12 +156,14 @@ async function handleAfterAction() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
|
<!-- TODO: 暂时只能这样处理 footer常驻但不显示内容 这个插槽有点迷 -->
|
||||||
<FlowActions
|
<FlowActions
|
||||||
v-if="currentTask && currentType"
|
v-if="showFooter && currentTask && currentType"
|
||||||
:task="currentTask"
|
:task="currentTask"
|
||||||
:type="currentType"
|
:type="currentType"
|
||||||
@reload="handleAfterAction"
|
@reload="handleAfterAction"
|
||||||
/>
|
/>
|
||||||
|
<div v-else></div>
|
||||||
</template>
|
</template>
|
||||||
</BasicDrawer>
|
</BasicDrawer>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user