fix(regulatory): 轮询时加载条件确认卡
This commit is contained in:
@@ -644,6 +644,74 @@
|
||||
selectWorkflowBatchIndex(activeIndex);
|
||||
}
|
||||
|
||||
function ensureConditionConfirmationCard(confirmation) {
|
||||
if (!chatScroll || !confirmation || !confirmation.candidates) {
|
||||
return;
|
||||
}
|
||||
var cardId = "condition-confirmation-" + confirmation.batch_id;
|
||||
if (document.getElementById(cardId)) {
|
||||
return;
|
||||
}
|
||||
var article = document.createElement("article");
|
||||
article.className = "message assistant";
|
||||
article.id = cardId;
|
||||
article.setAttribute("data-node-label", "AI 适用条件确认");
|
||||
|
||||
var avatar = document.createElement("div");
|
||||
avatar.className = "message-avatar";
|
||||
avatar.textContent = "AI";
|
||||
|
||||
var bubble = document.createElement("div");
|
||||
bubble.className = "message-bubble";
|
||||
var form = document.createElement("form");
|
||||
form.className = "condition-confirm-form";
|
||||
form.setAttribute("data-condition-confirm-form", "");
|
||||
form.setAttribute("data-batch-id", confirmation.batch_id);
|
||||
form.setAttribute("data-confirm-url", confirmation.confirm_url);
|
||||
form.innerHTML =
|
||||
'<input type="hidden" name="csrfmiddlewaretoken" value="' +
|
||||
escapeHtml(new FormData(composer).get("csrfmiddlewaretoken") || "") +
|
||||
'">' +
|
||||
"<strong>适用条件确认</strong>" +
|
||||
"<p>请确认 " +
|
||||
escapeHtml(confirmation.batch_no || "") +
|
||||
" 的产品类别、注册类型和临床评价路径,确认后我会继续法规核查。</p>" +
|
||||
renderConditionFields(confirmation.candidates) +
|
||||
'<button type="submit">确认并继续</button>' +
|
||||
'<p class="condition-confirm-status" data-condition-confirm-status></p>';
|
||||
bubble.appendChild(form);
|
||||
article.appendChild(avatar);
|
||||
article.appendChild(bubble);
|
||||
chatScroll.appendChild(article);
|
||||
bindConditionConfirmForms();
|
||||
scrollChatToBottom();
|
||||
}
|
||||
|
||||
function renderConditionFields(candidates) {
|
||||
var html = "";
|
||||
Object.keys(candidates || {}).forEach(function (field) {
|
||||
var config = candidates[field] || {};
|
||||
html += "<label><span>" + escapeHtml(config.label || field) + "</span>";
|
||||
if (config.input_type === "select") {
|
||||
html += '<select name="' + escapeHtml(field) + '">';
|
||||
(config.options || []).forEach(function (option) {
|
||||
var selected = option === config.suggested ? " selected" : "";
|
||||
html += '<option value="' + escapeHtml(option) + '"' + selected + ">" + escapeHtml(option) + "</option>";
|
||||
});
|
||||
html += "</select>";
|
||||
} else {
|
||||
html +=
|
||||
'<input type="text" name="' +
|
||||
escapeHtml(field) +
|
||||
'" value="' +
|
||||
escapeHtml(config.suggested || "") +
|
||||
'">';
|
||||
}
|
||||
html += "</label>";
|
||||
});
|
||||
return html;
|
||||
}
|
||||
|
||||
async function refreshWorkflowCard(batchId, workflow_type) {
|
||||
if (!summaryPanel || !batchId) {
|
||||
return "";
|
||||
@@ -662,6 +730,9 @@
|
||||
return "";
|
||||
}
|
||||
var payload = await response.json();
|
||||
if (payload.condition_confirmation) {
|
||||
ensureConditionConfirmationCard(payload.condition_confirmation);
|
||||
}
|
||||
var card = ensureWorkflowCard({
|
||||
batch_id: payload.batch.id,
|
||||
batch_no: payload.batch.batch_no,
|
||||
|
||||
Reference in New Issue
Block a user