fix(approval): wire workflow task drawer actions
This commit is contained in:
@@ -9,8 +9,10 @@
|
||||
// 此处替换为自定义 fetcher,统一注入 Bearer(由 http 拦截器完成)并复用宿主 axios,
|
||||
// 后端 /api/entity 已是 amis CRUD 格式 {status,msg,data:{items,total}},无需再适配响应。
|
||||
// ============================================================================
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { http } from '../api/http';
|
||||
import { APPROVAL_COMPLETED_EVENT } from '../amis/approvalActionEvents';
|
||||
import { registerApprovalAction } from '../amis/registerApprovalAction';
|
||||
import { registerReplayAction } from '../amis/registerReplayAction';
|
||||
import { getProfile } from '../auth/token';
|
||||
|
||||
@@ -31,6 +33,13 @@ interface AmisFetcherOptions {
|
||||
export function AmisRenderer({ schema }: AmisRendererProps) {
|
||||
const rootRef = useRef<HTMLDivElement>(null);
|
||||
const instanceRef = useRef<{ unmount?: () => void } | null>(null);
|
||||
const [reloadSeq, setReloadSeq] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
const reload = () => setReloadSeq((n) => n + 1);
|
||||
window.addEventListener(APPROVAL_COMPLETED_EVENT, reload);
|
||||
return () => window.removeEventListener(APPROVAL_COMPLETED_EVENT, reload);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!rootRef.current || typeof amisRequire !== 'function') return;
|
||||
@@ -44,6 +53,11 @@ export function AmisRenderer({ schema }: AmisRendererProps) {
|
||||
} catch {
|
||||
// amis-core 未暴露 registerAction 时静默降级(onEvent 重放不可用,不阻断渲染)
|
||||
}
|
||||
try {
|
||||
registerApprovalAction(amisRequire('amis'));
|
||||
} catch {
|
||||
// amis-core 未暴露 registerAction 时静默降级(审批抽屉入口不可用,不阻断渲染)
|
||||
}
|
||||
|
||||
// 自定义 fetcher:复用宿主 axios(已带 Bearer 注入 + 401 跳登录拦截)
|
||||
const fetcher = (options: AmisFetcherOptions) => {
|
||||
@@ -89,7 +103,7 @@ export function AmisRenderer({ schema }: AmisRendererProps) {
|
||||
instanceRef.current?.unmount?.();
|
||||
instanceRef.current = null;
|
||||
};
|
||||
}, [schema]);
|
||||
}, [schema, reloadSeq]);
|
||||
|
||||
return <div ref={rootRef} style={{ height: '100%' }} />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user