修复AI建议逻辑和字段映射问题
- 修复AI建议基于问题描述而不是处理过程生成 - 修复工单详情页面显示逻辑 - 修复飞书时间字段处理(毫秒时间戳转换) - 优化字段映射和转换逻辑 - 添加飞书集成功能 - 改进对话历史合并功能 - 优化系统优化反馈机制
This commit is contained in:
@@ -924,6 +924,7 @@ class TSPDashboard {
|
||||
</div>
|
||||
<div>
|
||||
<span class="badge ${success >= 80 ? 'bg-success' : success >= 50 ? 'bg-warning' : 'bg-secondary'}">${success}%</span>
|
||||
<button class="btn btn-sm btn-outline-primary ms-2" data-tool="${tool.name}">执行</button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
@@ -931,6 +932,39 @@ class TSPDashboard {
|
||||
|
||||
toolsList.innerHTML = toolsHtml;
|
||||
|
||||
// 绑定执行事件
|
||||
toolsList.querySelectorAll('button[data-tool]').forEach(btn => {
|
||||
btn.addEventListener('click', async () => {
|
||||
const tool = btn.getAttribute('data-tool');
|
||||
// 简单参数输入(可扩展为动态表单)
|
||||
let params = {};
|
||||
try {
|
||||
const input = prompt('请输入执行参数(JSON):', '{}');
|
||||
if (input) params = JSON.parse(input);
|
||||
} catch (e) {
|
||||
this.showNotification('参数格式错误,应为JSON', 'warning');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const resp = await fetch('/api/agent/tools/execute', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ tool, parameters: params })
|
||||
});
|
||||
const res = await resp.json();
|
||||
if (res.success) {
|
||||
this.showNotification(`工具 ${tool} 执行成功`, 'success');
|
||||
await this.loadAgentData();
|
||||
} else {
|
||||
this.showNotification(res.error || `工具 ${tool} 执行失败`, 'error');
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('执行工具失败:', err);
|
||||
this.showNotification('执行工具失败: ' + err.message, 'error');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 追加自定义工具注册入口
|
||||
const addDiv = document.createElement('div');
|
||||
addDiv.className = 'mt-3';
|
||||
@@ -1508,7 +1542,7 @@ class TSPDashboard {
|
||||
<div class="d-flex justify-content-between align-items-start">
|
||||
<div class="flex-grow-1">
|
||||
<h6 class="mb-1">${workorder.title}</h6>
|
||||
<p class="text-muted mb-2">${workorder.description}</p>
|
||||
<p class="text-muted mb-2">${workorder.description ? workorder.description.substring(0, 100) + (workorder.description.length > 100 ? '...' : '') : '无处理过程'}</p>
|
||||
<div class="d-flex gap-3">
|
||||
<span class="badge bg-${this.getPriorityColor(workorder.priority)}">${this.getPriorityText(workorder.priority)}</span>
|
||||
<span class="badge bg-${this.getStatusColor(workorder.status)}">${this.getStatusText(workorder.status)}</span>
|
||||
@@ -1656,8 +1690,14 @@ class TSPDashboard {
|
||||
<div class="col-md-6">
|
||||
<h6>问题描述</h6>
|
||||
<div class="border p-3 rounded">
|
||||
${workorder.description}
|
||||
${workorder.title || '无问题描述'}
|
||||
</div>
|
||||
${workorder.description ? `
|
||||
<h6 class="mt-3">处理过程</h6>
|
||||
<div class="border p-3 rounded bg-light">
|
||||
${workorder.description}
|
||||
</div>
|
||||
` : ''}
|
||||
${workorder.resolution ? `
|
||||
<h6 class="mt-3">解决方案</h6>
|
||||
<div class="border p-3 rounded bg-light">
|
||||
@@ -1857,7 +1897,7 @@ class TSPDashboard {
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="editDescription" class="form-label">描述 *</label>
|
||||
<label for="editDescription" class="form-label">处理过程 *</label>
|
||||
<textarea class="form-control" id="editDescription" rows="4" required>${workorder.description}</textarea>
|
||||
</div>
|
||||
|
||||
@@ -2154,6 +2194,10 @@ class TSPDashboard {
|
||||
}
|
||||
|
||||
async refreshConversationHistory() {
|
||||
// 先尝试触发一次合并迁移(幂等,重复调用也安全)
|
||||
try {
|
||||
await fetch('/api/conversations/migrate-merge', { method: 'POST' });
|
||||
} catch (e) { /* 忽略迁移失败 */ }
|
||||
await this.loadConversationHistory();
|
||||
this.showNotification('对话历史已刷新', 'success');
|
||||
}
|
||||
@@ -2206,6 +2250,7 @@ class TSPDashboard {
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
data.user_id = data.user_id || '匿名';
|
||||
this.showConversationModal(data);
|
||||
} else {
|
||||
throw new Error(data.error || '获取对话详情失败');
|
||||
@@ -2760,8 +2805,11 @@ class TSPDashboard {
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
this.showNotification('CPU优化完成', 'success');
|
||||
this.showNotification(data.message || 'CPU优化完成', 'success');
|
||||
this.updateOptimizationProgress('cpu-optimization', data.progress || 100);
|
||||
// 刷新状态并回落进度条
|
||||
await this.loadSystemOptimizer();
|
||||
setTimeout(() => this.updateOptimizationProgress('cpu-optimization', 0), 1500);
|
||||
} else {
|
||||
throw new Error(data.error || 'CPU优化失败');
|
||||
}
|
||||
@@ -2777,8 +2825,10 @@ class TSPDashboard {
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
this.showNotification('内存优化完成', 'success');
|
||||
this.showNotification(data.message || '内存优化完成', 'success');
|
||||
this.updateOptimizationProgress('memory-optimization', data.progress || 100);
|
||||
await this.loadSystemOptimizer();
|
||||
setTimeout(() => this.updateOptimizationProgress('memory-optimization', 0), 1500);
|
||||
} else {
|
||||
throw new Error(data.error || '内存优化失败');
|
||||
}
|
||||
@@ -2794,8 +2844,10 @@ class TSPDashboard {
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
this.showNotification('磁盘优化完成', 'success');
|
||||
this.showNotification(data.message || '磁盘优化完成', 'success');
|
||||
this.updateOptimizationProgress('disk-optimization', data.progress || 100);
|
||||
await this.loadSystemOptimizer();
|
||||
setTimeout(() => this.updateOptimizationProgress('disk-optimization', 0), 1500);
|
||||
} else {
|
||||
throw new Error(data.error || '磁盘优化失败');
|
||||
}
|
||||
@@ -2916,6 +2968,40 @@ class TSPDashboard {
|
||||
this.showNotification('系统状态已刷新', 'success');
|
||||
}
|
||||
|
||||
async clearCache() {
|
||||
try {
|
||||
const response = await fetch('/api/system-optimizer/clear-cache', { method: 'POST' });
|
||||
const data = await response.json();
|
||||
if (data.success) {
|
||||
this.showNotification(data.message || '缓存已清理', 'success');
|
||||
await this.loadSystemOptimizer();
|
||||
} else {
|
||||
throw new Error(data.error || '清理缓存失败');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('清理缓存失败:', error);
|
||||
this.showNotification('清理缓存失败: ' + error.message, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
async optimizeAll() {
|
||||
try {
|
||||
const response = await fetch('/api/system-optimizer/optimize-all', { method: 'POST' });
|
||||
const data = await response.json();
|
||||
if (data.success) {
|
||||
this.showNotification(data.message || '一键优化完成', 'success');
|
||||
await this.loadSystemOptimizer();
|
||||
['cpu-optimization','memory-optimization','disk-optimization'].forEach(id => this.updateOptimizationProgress(id, 100));
|
||||
setTimeout(() => ['cpu-optimization','memory-optimization','disk-optimization'].forEach(id => this.updateOptimizationProgress(id, 0)), 1500);
|
||||
} else {
|
||||
throw new Error(data.error || '一键优化失败');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('一键优化失败:', error);
|
||||
this.showNotification('一键优化失败: ' + error.message, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
async loadSecuritySettings() {
|
||||
try {
|
||||
const response = await fetch('/api/system-optimizer/security-settings');
|
||||
|
||||
Reference in New Issue
Block a user