|
|
|
@ -109,7 +109,8 @@
|
|
|
|
|
|
|
|
|
|
// 修改后的维护按钮显示逻辑
|
|
|
|
|
const isThirdLevel = node.parent_id && allNodes.find(n => n.id === node.parent_id)?.parent_id;
|
|
|
|
|
html += '<td>' + (node.prerequisite || '') +
|
|
|
|
|
html += '<td>' + (node.prerequisite && node.prerequisite.length > 0 ?
|
|
|
|
|
node.prerequisite.map(p => p.title).join(', ') : '') +
|
|
|
|
|
(isThirdLevel ? '<button onclick="prerequisiteUpdate(\'' + node.id + '\')">维护</button>' : '') + '</td>';
|
|
|
|
|
html += '<td>' + (node.related || '') +
|
|
|
|
|
(isThirdLevel ? '<button onclick="relatedUpdate(\'' + node.id + '\')">维护</button>' : '') + '</td>';
|
|
|
|
@ -213,7 +214,7 @@
|
|
|
|
|
|
|
|
|
|
// 为每个节点创建checkbox
|
|
|
|
|
allNodes.forEach(node => {
|
|
|
|
|
// 只处理二级节点
|
|
|
|
|
console.log('Node title:', typeof node.title, node.title); // 添加调试
|
|
|
|
|
if (node.id !== currentNodeId && !node.isParent) {
|
|
|
|
|
const div = document.createElement('div');
|
|
|
|
|
const checkbox = document.createElement('input');
|
|
|
|
@ -223,7 +224,7 @@
|
|
|
|
|
|
|
|
|
|
const label = document.createElement('label');
|
|
|
|
|
label.htmlFor = `node_${node.id}`;
|
|
|
|
|
label.textContent = `【${findParentTitle(node)}】${node.title}`;
|
|
|
|
|
label.textContent = node.title; // 修改这里,直接显示节点title
|
|
|
|
|
|
|
|
|
|
div.appendChild(checkbox);
|
|
|
|
|
div.appendChild(label);
|
|
|
|
@ -248,9 +249,8 @@
|
|
|
|
|
console.error('找不到当前节点:', currentNodeId);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log(`当前操作的二级节点ID: ${currentNodeId}, 名称: ${currentNode.title}`);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const selectedNodes = [];
|
|
|
|
|
const checkboxes = container.querySelectorAll('input[type="checkbox"]:checked');
|
|
|
|
|
checkboxes.forEach(checkbox => {
|
|
|
|
@ -258,12 +258,11 @@
|
|
|
|
|
if (node) {
|
|
|
|
|
selectedNodes.push({
|
|
|
|
|
id: node.id,
|
|
|
|
|
title: node.title,
|
|
|
|
|
parentTitle: node.isParent ? '' : findParentTitle(node)
|
|
|
|
|
title: node.title
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
console.log(`当前操作的三级节点ID: ${currentNodeId}, 名称: ${currentNode.title}`);
|
|
|
|
|
console.log('选中的先修知识:');
|
|
|
|
|
selectedNodes.forEach(node => {
|
|
|
|
|
if (node.parentTitle) {
|
|
|
|
@ -272,7 +271,31 @@
|
|
|
|
|
console.log(`ID: ${node.id}, 名称: ${node.title}`);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 调用后端接口
|
|
|
|
|
fetch('/api/update-prerequisites', {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
|
},
|
|
|
|
|
body: JSON.stringify({
|
|
|
|
|
node_id: currentNodeId,
|
|
|
|
|
prerequisites: selectedNodes
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
.then(response => response.json())
|
|
|
|
|
.then(data => {
|
|
|
|
|
if (data.code === 0) {
|
|
|
|
|
alert('保存成功');
|
|
|
|
|
location.reload(); // 刷新页面
|
|
|
|
|
} else {
|
|
|
|
|
alert('保存失败: ' + data.message);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.catch(error => {
|
|
|
|
|
console.error('Error:', error);
|
|
|
|
|
alert('保存出错');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modal.remove();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|