mirror of
https://gitee.com/JavaLionLi/plus-ui.git
synced 2026-11-02 13:31:50 +08:00
fix 修复 定时事件任务 表单无法查看流程监控问题
This commit is contained in:
parent
c4b85dd36c
commit
85e45a76d4
@ -76,9 +76,10 @@ export function updateVariable(data: { instanceId?: string | number; key?: strin
|
||||
});
|
||||
}
|
||||
|
||||
export function flowHisTaskList(businessId: string | number) {
|
||||
export function flowHisTaskList(ids: { businessId?: string | number; instanceId?: string | number }) {
|
||||
return request<R<FlowHisTaskResult>>({
|
||||
url: `/workflow/instance/flowHisTaskList/${businessId}?t=${Math.random()}`,
|
||||
method: 'get'
|
||||
url: '/workflow/instance/flowHisTaskList',
|
||||
method: 'get',
|
||||
params: ids
|
||||
});
|
||||
}
|
||||
|
||||
@ -3,12 +3,14 @@ import { normalizePath } from '@/utils/ruoyi';
|
||||
import type { RouterJumpVO } from './types';
|
||||
|
||||
export function routerJump(routerJump: RouterJumpVO) {
|
||||
const query = new URLSearchParams({
|
||||
type: routerJump.type,
|
||||
taskId: String(routerJump.taskId)
|
||||
});
|
||||
if (routerJump.businessId) query.set('id', routerJump.businessId);
|
||||
if (routerJump.instanceId != null) query.set('instanceId', String(routerJump.instanceId));
|
||||
history.push(
|
||||
`${normalizePath(routerJump.formPath || '/workflow/leaveEdit/index')}?${new URLSearchParams({
|
||||
id: routerJump.businessId,
|
||||
type: routerJump.type,
|
||||
taskId: String(routerJump.taskId)
|
||||
}).toString()}`
|
||||
`${normalizePath(routerJump.formPath || '/workflow/leaveEdit/index')}?${query.toString()}`
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
export interface RouterJumpVO {
|
||||
businessId: string;
|
||||
instanceId?: string | number;
|
||||
taskId: string | number;
|
||||
type: string;
|
||||
formCustom: string;
|
||||
|
||||
@ -7,6 +7,8 @@ interface ApprovalButtonProps {
|
||||
status?: string;
|
||||
pageType: ApprovalPageType;
|
||||
id?: string | number;
|
||||
businessId?: string | number;
|
||||
instanceId?: string | number;
|
||||
buttonLoading?: boolean;
|
||||
onSubmitDraft: () => void;
|
||||
onSubmit: () => void;
|
||||
@ -19,6 +21,8 @@ export default function ApprovalButton({
|
||||
status,
|
||||
pageType,
|
||||
id,
|
||||
businessId,
|
||||
instanceId,
|
||||
buttonLoading = false,
|
||||
onSubmitDraft,
|
||||
onSubmit,
|
||||
@ -29,7 +33,7 @@ export default function ApprovalButton({
|
||||
const submitButtonShow =
|
||||
pageType === 'add' || (pageType === 'update' && !!status && ['draft', 'cancel', 'back'].includes(status));
|
||||
const approvalButtonShow = pageType === 'approval' && status === 'waiting';
|
||||
const approvalRecordShow = !!id && status !== 'draft';
|
||||
const approvalRecordShow = !!(id || businessId || instanceId) && status !== 'draft';
|
||||
|
||||
return (
|
||||
<div className="workflow-approval-button-bar">
|
||||
|
||||
@ -15,18 +15,19 @@ import UserNameDisplay from './UserNameDisplay';
|
||||
|
||||
interface ApprovalRecordProps {
|
||||
businessId?: string | number;
|
||||
instanceId?: string | number;
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
width?: string | number;
|
||||
}
|
||||
|
||||
export default function ApprovalRecord({ businessId, open, onOpenChange, width = '80%' }: ApprovalRecordProps) {
|
||||
export default function ApprovalRecord({ businessId, instanceId, open, onOpenChange, width = '80%' }: ApprovalRecordProps) {
|
||||
const dicts = useDict('wf_task_status');
|
||||
const [recordList, setRecordList] = useState<FlowHistoryVO[]>([]);
|
||||
const [instanceId, setInstanceId] = useState<string | number>();
|
||||
const [recordInstanceId, setRecordInstanceId] = useState<string | number>();
|
||||
const { loading, runAsync: loadRecords } = useRequest(
|
||||
async (nextBusinessId: string | number) => {
|
||||
const res = await flowHisTaskList(nextBusinessId);
|
||||
async (ids: { businessId?: string | number; instanceId?: string | number }) => {
|
||||
const res = await flowHisTaskList(ids);
|
||||
const rows = res.data?.list || [];
|
||||
const nextRows = await Promise.all(
|
||||
rows.map(async row => {
|
||||
@ -47,17 +48,17 @@ export default function ApprovalRecord({ businessId, open, onOpenChange, width =
|
||||
manual: true,
|
||||
onSuccess: data => {
|
||||
setRecordList(data.rows);
|
||||
setInstanceId(data.instanceId);
|
||||
setRecordInstanceId(data.instanceId);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// 打开时清空旧数据并加载 打开弹窗同步外部状态属于合理场景
|
||||
const resetAndLoad = useCallback(async (nextBusinessId?: string | number) => {
|
||||
const resetAndLoad = useCallback(async (nextBusinessId?: string | number, nextInstanceId?: string | number) => {
|
||||
setRecordList([]);
|
||||
setInstanceId(undefined);
|
||||
if (nextBusinessId) {
|
||||
await loadRecords(nextBusinessId);
|
||||
setRecordInstanceId(undefined);
|
||||
if (nextBusinessId || nextInstanceId) {
|
||||
await loadRecords({ businessId: nextBusinessId, instanceId: nextInstanceId });
|
||||
}
|
||||
}, [loadRecords]);
|
||||
|
||||
@ -65,8 +66,8 @@ export default function ApprovalRecord({ businessId, open, onOpenChange, width =
|
||||
if (!open) return;
|
||||
// 打开弹窗时同步清空旧数据属于与外部状态对齐的合理场景
|
||||
// oxlint-disable-next-line react/set-state-in-effect
|
||||
void resetAndLoad(businessId);
|
||||
}, [businessId, open, resetAndLoad]);
|
||||
void resetAndLoad(businessId, instanceId);
|
||||
}, [businessId, instanceId, open, resetAndLoad]);
|
||||
|
||||
const downloadAttachment = async (row: OssVO) => {
|
||||
const blob = await downloadOss(row.ossId);
|
||||
@ -153,7 +154,7 @@ export default function ApprovalRecord({ businessId, open, onOpenChange, width =
|
||||
label: '流程图',
|
||||
children: (
|
||||
<Spin spinning={loading}>
|
||||
<FlowChart instanceId={instanceId} />
|
||||
<FlowChart instanceId={recordInstanceId} />
|
||||
</Spin>
|
||||
)
|
||||
},
|
||||
|
||||
@ -38,6 +38,7 @@ export default function WorkflowLeaveEditPage() {
|
||||
const query = useMemo(() => new URLSearchParams(location.search), [location.search]);
|
||||
const pageType = (query.get('type') || 'add') as PageType;
|
||||
const id = query.get('id');
|
||||
const instanceId = query.get('instanceId') || undefined;
|
||||
const taskId = query.get('taskId') || '';
|
||||
const readonly = pageType === 'view';
|
||||
const [flowCode, setFlowCode] = useState('');
|
||||
@ -117,7 +118,7 @@ export default function WorkflowLeaveEditPage() {
|
||||
};
|
||||
|
||||
const openApprovalRecord = () => {
|
||||
if (!formId) return;
|
||||
if (!id && !formId && !instanceId) return;
|
||||
openRecordModal();
|
||||
};
|
||||
|
||||
@ -182,6 +183,8 @@ export default function WorkflowLeaveEditPage() {
|
||||
status={formStatus}
|
||||
pageType={pageType}
|
||||
id={formId}
|
||||
businessId={id || undefined}
|
||||
instanceId={instanceId}
|
||||
buttonLoading={submitLoading}
|
||||
onSubmitDraft={() => saveLeave()}
|
||||
onSubmit={submitFlow}
|
||||
@ -233,7 +236,7 @@ export default function WorkflowLeaveEditPage() {
|
||||
onSubmitted={finishWorkflowAction}
|
||||
/>
|
||||
|
||||
<ApprovalRecord businessId={formId} open={recordOpen} onOpenChange={setRecordOpen} />
|
||||
<ApprovalRecord businessId={id || formId} instanceId={instanceId} open={recordOpen} onOpenChange={setRecordOpen} />
|
||||
</PageContainer>
|
||||
);
|
||||
}
|
||||
|
||||
@ -51,6 +51,7 @@ function requestInstanceList(tab: InstanceTab, query: FlowInstanceQuery): Promis
|
||||
function openBusinessForm(row: FlowInstanceVO) {
|
||||
workflowCommon.routerJump({
|
||||
businessId: row.businessId,
|
||||
instanceId: row.id,
|
||||
taskId: row.id,
|
||||
type: 'view',
|
||||
formCustom: row.formCustom || 'N',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user