Commit 174de5ea authored by drigle's avatar drigle

feat: add editor submission withdrawal

parent 7b2ec68f
{
"name": "problem_rectification_new",
"name": "integrity_practice_management_new",
"version": "1.0.7",
"build": "abc",
"description": "merge master",
"description": "廉洁从业管理",
"date": "2025-07-14 19:27:20",
"author": "yang"
}
......@@ -26,6 +26,7 @@ import {
approveBySender,
loadProblemRectificationFlow,
markEditorComplete,
withdrawEditorSubmission,
refreshRelatedProblemRecords,
rejectByAuditor,
rejectBySender,
......@@ -155,6 +156,7 @@ export default function ProblemRectificationFormPage() {
const currentStep = flowData?.currentStep || 'editor';
const viewerRole = flowData?.viewerRole || 'guest';
const canEditRecords = Boolean(flowData?.canEditRecords);
const canWithdrawSubmission = viewerRole === 'editor' && currentStep === 'auditor';
const hasLockedRecords = relatedRecords.some((record) => record.isLocked);
const metadata = messageRecord?.metadata || {};
......@@ -220,6 +222,15 @@ export default function ProblemRectificationFormPage() {
});
};
const handleEditorWithdraw = async () => {
await withSubmit(async () => {
await withdrawEditorSubmission({
messageRecord,
currentUser: userInfo,
});
});
};
const handleAuditorApprove = async () => {
await withSubmit(async () => {
await approveByAuditor({
......@@ -424,6 +435,11 @@ export default function ProblemRectificationFormPage() {
页面根据当前步骤和你的身份自动开放可执行动作。
</div>
<div className="mt-5 flex flex-wrap gap-3">
{canWithdrawSubmission ? (
<Button color="zinc" disabled={submitting} onClick={handleEditorWithdraw}>
{submitting ? '撤回中...' : '撤回提交'}
</Button>
) : null}
{currentStep === 'editor' && viewerRole === 'editor' ? (
<Button color="blue" disabled={submitting || hasLockedRecords || relatedRecords.length === 0} onClick={handleEditorSubmit}>
{submitting ? '送审中...' : '填写完成并送审'}
......
......@@ -343,6 +343,30 @@ export async function markEditorComplete({
});
}
export async function withdrawEditorSubmission({ messageRecord, currentUser }) {
const messageName = messageRecord?.name || messageRecord?._id;
if (!messageName) throw new Error('流程主单不存在,无法撤回。');
const latestRecord = await loadRecord(messageName);
const metadata = latestRecord?.metadata || {};
const currentUserId = toIdString(currentUser?._id);
if (!normalizeUserIds(metadata.editor).includes(currentUserId)) {
throw new Error('仅填写人可以撤回提交。');
}
if (metadata.editor_status !== COMPLETED_STATUS || metadata.auditor_status === COMPLETED_STATUS) {
throw new Error('当前流程不满足撤回条件,审核人可能已经处理。');
}
await completeProgressTasks(metadata.progress_id_auditor);
await updateRecord(latestRecord._id || latestRecord.name, {
metadata: {
editor_status: DEFAULT_STATUS,
auditor_status: DEFAULT_STATUS,
progress_id_auditor: [],
},
});
}
export async function approveByAuditor({
messageRecord,
currentUser,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment