1 .修改了新建评估指标删除的bug
This commit is contained in:
@@ -114,6 +114,10 @@
|
||||
activeContent.classList.remove('hidden');
|
||||
activeContent.classList.add('active');
|
||||
}
|
||||
// 切换到评测维度tab时刷新数据
|
||||
if (tabId === 'dimensions') {
|
||||
loadDimensions();
|
||||
}
|
||||
};
|
||||
|
||||
// 加载评测任务数据
|
||||
@@ -195,38 +199,49 @@
|
||||
`).join('');
|
||||
}
|
||||
|
||||
// 加载评测维度数据(模拟数据)
|
||||
// 加载评测维度数据
|
||||
async function loadDimensions() {
|
||||
// 模拟评测维度数据
|
||||
const mockData = [
|
||||
{ id: 1, name: '准确率', type: 'accuracy', desc: '模型预测正确的比例', status: '启用' },
|
||||
{ id: 2, name: '召回率', type: 'recall', desc: '找出所有正例的能力', status: '启用' },
|
||||
{ id: 3, name: 'F1分数', type: 'f1', desc: '准确率和召回率的调和平均', status: '启用' },
|
||||
{ id: 4, name: '推理速度', type: 'speed', desc: '模型推理响应时间', status: '启用' },
|
||||
{ id: 5, name: 'BLEU分数', type: 'bleu', desc: '机器翻译质量评估', status: '停用' }
|
||||
];
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/dimension`);
|
||||
const result = await response.json();
|
||||
|
||||
const tbody = document.getElementById('dimensionsBody');
|
||||
tbody.innerHTML = mockData.map(item => `
|
||||
<tr class="hover:bg-gray-50">
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">${item.name}</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${item.type}</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${item.desc}</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<span class="px-2 py-1 text-xs font-medium rounded-full ${item.status === '启用' ? 'bg-green-100 text-green-700' : 'bg-gray-100 text-gray-500'}">
|
||||
${item.status}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||
<button onclick="editDimension(${item.id})" class="text-primary hover:text-primary/80 mr-3">
|
||||
<i class="fa fa-edit"></i> 编辑
|
||||
</button>
|
||||
<button onclick="deleteDimension(${item.id})" class="text-red-500 hover:text-red-600">
|
||||
<i class="fa fa-trash"></i> 删除
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
`).join('');
|
||||
const tbody = document.getElementById('dimensionsBody');
|
||||
|
||||
if (result.code !== 0 || !result.data || result.data.length === 0) {
|
||||
tbody.innerHTML = `
|
||||
<tr>
|
||||
<td colspan="5" class="px-6 py-12 text-center text-gray-400">
|
||||
<i class="fa fa-inbox text-4xl mb-3"></i>
|
||||
<p>暂无评测维度</p>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
return;
|
||||
}
|
||||
|
||||
tbody.innerHTML = result.data.map(item => `
|
||||
<tr class="hover:bg-gray-50">
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">${item.name || '-'}</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${item.type || '-'}</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${item.description || '-'}</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap">
|
||||
<span class="px-2 py-1 text-xs font-medium rounded-full bg-green-100 text-green-700">
|
||||
启用
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
||||
<button onclick="editDimension(${item.id})" class="text-primary hover:text-primary/80 mr-3">
|
||||
<i class="fa fa-edit"></i> 编辑
|
||||
</button>
|
||||
<button onclick="deleteDimension(${item.id})" class="text-red-500 hover:text-red-600">
|
||||
<i class="fa fa-trash"></i> 删除
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
`).join('');
|
||||
} catch (error) {
|
||||
console.error('加载评测维度失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// 状态样式
|
||||
@@ -267,9 +282,36 @@
|
||||
alert('编辑维度功能开发中');
|
||||
}
|
||||
|
||||
function deleteDimension(id) {
|
||||
if (confirm('确定要删除此维度吗?')) {
|
||||
alert('删除维度功能开发中');
|
||||
async function deleteDimension(id) {
|
||||
showConfirm('确认删除', '确定要删除此评测维度吗?', () => {
|
||||
executeDelete(id);
|
||||
});
|
||||
}
|
||||
|
||||
async function executeDelete(id) {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/dimension/${id}`, {
|
||||
method: 'DELETE'
|
||||
});
|
||||
const result = await response.json();
|
||||
if (result.code === 0) {
|
||||
// 切换到评测维度tab并刷新列表
|
||||
switchToDimensionsTab();
|
||||
showMessage('成功', '删除成功', 'success');
|
||||
} else {
|
||||
showMessage('错误', result.message || '删除失败', 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('删除维度失败:', error);
|
||||
showMessage('错误', '删除失败: ' + error.message, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
// 切换到评测维度tab
|
||||
function switchToDimensionsTab() {
|
||||
const dimBtn = document.querySelector('[data-tab="dimensions"]');
|
||||
if (dimBtn) {
|
||||
dimBtn.click();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user