feat(regulatory): 增加适用条件确认暂停恢复
This commit is contained in:
@@ -796,6 +796,60 @@
|
||||
});
|
||||
}
|
||||
|
||||
function bindConditionConfirmForms() {
|
||||
document.querySelectorAll("[data-condition-confirm-form]").forEach(function (form) {
|
||||
if (form.dataset.bound === "true") {
|
||||
return;
|
||||
}
|
||||
form.dataset.bound = "true";
|
||||
form.addEventListener("submit", async function (event) {
|
||||
event.preventDefault();
|
||||
var batchId = form.getAttribute("data-batch-id");
|
||||
var status = form.querySelector("[data-condition-confirm-status]");
|
||||
var submitButton = form.querySelector('button[type="submit"]');
|
||||
var formData = new FormData(form);
|
||||
var conditions = {};
|
||||
formData.forEach(function (value, key) {
|
||||
if (key !== "csrfmiddlewaretoken") {
|
||||
conditions[key] = value;
|
||||
}
|
||||
});
|
||||
if (submitButton) {
|
||||
submitButton.disabled = true;
|
||||
}
|
||||
if (status) {
|
||||
status.textContent = "正在恢复法规核查...";
|
||||
}
|
||||
try {
|
||||
var response = await fetch(form.getAttribute("data-confirm-url"), {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-CSRFToken": formData.get("csrfmiddlewaretoken"),
|
||||
},
|
||||
body: JSON.stringify({ conditions: conditions }),
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error("确认失败。");
|
||||
}
|
||||
if (status) {
|
||||
status.textContent = "已确认,工作流继续执行。";
|
||||
}
|
||||
form.classList.add("confirmed");
|
||||
startWorkflowPolling(batchId);
|
||||
await refreshWorkflowCard(batchId, "regulatory_review");
|
||||
} catch (error) {
|
||||
if (status) {
|
||||
status.textContent = "确认失败,请稍后重试。";
|
||||
}
|
||||
if (submitButton) {
|
||||
submitButton.disabled = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function streamChat(event) {
|
||||
event.preventDefault();
|
||||
if (!composer || !promptInput || !sendButton || !chatStage) {
|
||||
@@ -955,6 +1009,7 @@
|
||||
renderExistingAssistantMessages();
|
||||
refreshWorkflowBatchCarousel(0);
|
||||
bindWorkflowBatchCarouselControls();
|
||||
bindConditionConfirmForms();
|
||||
refreshRunningWorkflowCards();
|
||||
|
||||
if (chatScroll) {
|
||||
|
||||
Reference in New Issue
Block a user