feat(regulatory): 展示法规核查工作流卡片
This commit is contained in:
@@ -455,6 +455,12 @@
|
||||
return summaryPanel.getAttribute(attributeName).replace(token, value);
|
||||
}
|
||||
|
||||
function statusUrlForWorkflow(workflow_type, batchId) {
|
||||
var attributeName =
|
||||
workflow_type === "regulatory_review" ? "data-regulatory-status-url-template" : "data-status-url-template";
|
||||
return templateUrl(attributeName, "__batch_id__", batchId);
|
||||
}
|
||||
|
||||
function renderAttachments(attachments) {
|
||||
if (!attachmentList) {
|
||||
return;
|
||||
@@ -542,13 +548,17 @@
|
||||
if (empty) {
|
||||
empty.remove();
|
||||
}
|
||||
var card = workflowCardList.querySelector('[data-batch-id="' + batch.batch_id + '"]');
|
||||
var workflow_type = batch.workflow_type || "file_summary";
|
||||
var card = workflowCardList.querySelector(
|
||||
'[data-batch-id="' + batch.batch_id + '"][data-workflow-type="' + workflow_type + '"]'
|
||||
);
|
||||
if (card) {
|
||||
return card;
|
||||
}
|
||||
card = document.createElement("article");
|
||||
card.className = "workflow-card";
|
||||
card.setAttribute("data-batch-id", batch.batch_id);
|
||||
card.setAttribute("data-workflow-type", workflow_type);
|
||||
card.innerHTML =
|
||||
"<header><strong>" +
|
||||
escapeHtml(batch.batch_no || "文件汇总") +
|
||||
@@ -634,13 +644,13 @@
|
||||
selectWorkflowBatchIndex(activeIndex);
|
||||
}
|
||||
|
||||
async function refreshWorkflowCard(batchId) {
|
||||
async function refreshWorkflowCard(batchId, workflow_type) {
|
||||
if (!summaryPanel || !batchId) {
|
||||
return "";
|
||||
}
|
||||
var response;
|
||||
try {
|
||||
response = await fetch(templateUrl("data-status-url-template", "__batch_id__", batchId), {
|
||||
response = await fetch(statusUrlForWorkflow(workflow_type || "file_summary", batchId), {
|
||||
cache: "no-store",
|
||||
});
|
||||
} catch (error) {
|
||||
@@ -655,6 +665,7 @@
|
||||
var card = ensureWorkflowCard({
|
||||
batch_id: payload.batch.id,
|
||||
batch_no: payload.batch.batch_no,
|
||||
workflow_type: payload.batch.workflow_type || workflow_type || "file_summary",
|
||||
});
|
||||
if (!card) {
|
||||
return payload.batch.status || "";
|
||||
@@ -673,6 +684,17 @@
|
||||
} else if (batchError) {
|
||||
batchError.remove();
|
||||
}
|
||||
var riskSummary = card.querySelector(".workflow-risk-summary");
|
||||
if (payload.batch.risk_summary_text) {
|
||||
if (!riskSummary) {
|
||||
riskSummary = document.createElement("p");
|
||||
riskSummary.className = "workflow-risk-summary";
|
||||
card.insertBefore(riskSummary, card.querySelector("ol"));
|
||||
}
|
||||
riskSummary.textContent = payload.batch.risk_summary_text;
|
||||
} else if (riskSummary) {
|
||||
riskSummary.remove();
|
||||
}
|
||||
var list = card.querySelector("ol");
|
||||
list.innerHTML = "";
|
||||
(payload.nodes || []).forEach(function (node) {
|
||||
@@ -724,29 +746,37 @@
|
||||
return status === "success" || status === "failed";
|
||||
}
|
||||
|
||||
function stopWorkflowPolling(batchId) {
|
||||
if (!workflowPollingTimers[batchId]) {
|
||||
function workflowTimerKey(batchId, workflow_type) {
|
||||
return (workflow_type || "file_summary") + ":" + batchId;
|
||||
}
|
||||
|
||||
function stopWorkflowPolling(batchId, workflow_type) {
|
||||
var key = workflowTimerKey(batchId, workflow_type);
|
||||
if (!workflowPollingTimers[key]) {
|
||||
return;
|
||||
}
|
||||
window.clearInterval(workflowPollingTimers[batchId]);
|
||||
delete workflowPollingTimers[batchId];
|
||||
window.clearInterval(workflowPollingTimers[key]);
|
||||
delete workflowPollingTimers[key];
|
||||
}
|
||||
|
||||
function startWorkflowPolling(batchId) {
|
||||
if (!batchId || workflowPollingTimers[batchId]) {
|
||||
var card = workflowCardList ? workflowCardList.querySelector('[data-batch-id="' + batchId + '"]') : null;
|
||||
var workflow_type = card ? card.getAttribute("data-workflow-type") || "file_summary" : "file_summary";
|
||||
var key = workflowTimerKey(batchId, workflow_type);
|
||||
if (!batchId || workflowPollingTimers[key]) {
|
||||
return;
|
||||
}
|
||||
workflowPollingTimers[batchId] = window.setInterval(async function () {
|
||||
var status = await refreshWorkflowCard(batchId);
|
||||
workflowPollingTimers[key] = window.setInterval(async function () {
|
||||
var status = await refreshWorkflowCard(batchId, workflow_type);
|
||||
if (isWorkflowTerminalStatus(status)) {
|
||||
refreshConversationMessages();
|
||||
stopWorkflowPolling(batchId);
|
||||
stopWorkflowPolling(batchId, workflow_type);
|
||||
}
|
||||
}, WORKFLOW_POLL_INTERVAL_MS);
|
||||
refreshWorkflowCard(batchId).then(function (status) {
|
||||
refreshWorkflowCard(batchId, workflow_type).then(function (status) {
|
||||
if (isWorkflowTerminalStatus(status)) {
|
||||
refreshConversationMessages();
|
||||
stopWorkflowPolling(batchId);
|
||||
stopWorkflowPolling(batchId, workflow_type);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -757,10 +787,11 @@
|
||||
}
|
||||
workflowCardList.querySelectorAll(".workflow-card").forEach(function (card) {
|
||||
var batchId = card.getAttribute("data-batch-id");
|
||||
var workflow_type = card.getAttribute("data-workflow-type") || "file_summary";
|
||||
var status = card.querySelector(".workflow-status");
|
||||
var statusText = status ? status.textContent.trim() : "";
|
||||
if (!isWorkflowTerminalStatus(statusText)) {
|
||||
startWorkflowPolling(batchId);
|
||||
startWorkflowPolling(batchId, workflow_type);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user