mirror of
https://gitee.com/dapppp/ruoyi-plus-vben5.git
synced 2026-03-15 03:52:00 +08:00
refactor: drawer实现请假流程 & 重新编辑跳转
This commit is contained in:
33
apps/web-antd/src/views/workflow/leave/hook.ts
Normal file
33
apps/web-antd/src/views/workflow/leave/hook.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { onActivated, onMounted, ref } from 'vue';
|
||||
|
||||
import { createGlobalState } from '@vueuse/core';
|
||||
|
||||
export function useRouteIdEdit(callback: (id: string) => void, timeout = 500) {
|
||||
const { businessId } = useQueryId();
|
||||
function openEditFromRouteId() {
|
||||
const id = businessId.value;
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
setTimeout(() => {
|
||||
// 回调
|
||||
callback?.(id);
|
||||
// 执行完 清理id
|
||||
businessId.value = '';
|
||||
}, timeout);
|
||||
}
|
||||
|
||||
onMounted(openEditFromRouteId);
|
||||
onActivated(openEditFromRouteId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用来存储业务ID 传值
|
||||
*/
|
||||
export const useQueryId = createGlobalState(() => {
|
||||
const businessId = ref('');
|
||||
|
||||
return {
|
||||
businessId,
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user