fix: 删除/修改后前端缓存未清除导致数据不刷新
预警模块: - batchDeleteAlerts 清除所有 alerts_* 缓存,强制刷新 loadAlerts(1, true) - resolveAlert 同样清除缓存并强制刷新 工单模块: - batchDeleteWorkorders 修复参数错误(loadWorkOrders(true) loadWorkOrders(1, true)) - deleteWorkOrder 添加缓存清除 - createWorkOrder 添加缓存清除和强制刷新 - saveWorkOrder 添加缓存清除和强制刷新 - importWorkOrders 添加缓存清除和强制刷新 知识库模块: - batchDeleteKnowledge 清除所有 knowledge_* 缓存
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -196,17 +196,13 @@ Object.assign(TSPDashboard.prototype, {
|
||||
if (data.success) {
|
||||
this.showNotification(data.message, 'success');
|
||||
|
||||
// 清除所有相关缓存
|
||||
this.cache.delete('alerts');
|
||||
this.cache.delete('alerts_stats');
|
||||
// 清除所有预警相关缓存
|
||||
for (const key of this.cache.keys()) {
|
||||
if (key.startsWith('alerts')) this.cache.delete(key);
|
||||
}
|
||||
|
||||
// 立即更新统计数字,避免跳动
|
||||
await this.updateStatsAfterDelete(selectedIds.length);
|
||||
|
||||
// 重新加载预警列表
|
||||
await this.loadAlerts();
|
||||
|
||||
// 重置批量删除按钮状态
|
||||
// 强制刷新预警列表和统计
|
||||
await this.loadAlerts(1, true);
|
||||
this.updateBatchDeleteAlertsButton();
|
||||
} else {
|
||||
this.showNotification(data.error || '批量删除失败', 'error');
|
||||
@@ -327,16 +323,10 @@ Object.assign(TSPDashboard.prototype, {
|
||||
|
||||
if (data.success) {
|
||||
this.showNotification('预警已解决', 'success');
|
||||
|
||||
// 清除缓存
|
||||
this.cache.delete('alerts');
|
||||
this.cache.delete('alerts_stats');
|
||||
|
||||
// 立即更新统计数字
|
||||
await this.updateStatsAfterResolve(alertId);
|
||||
|
||||
// 重新加载预警列表
|
||||
this.loadAlerts();
|
||||
for (const key of this.cache.keys()) {
|
||||
if (key.startsWith('alerts')) this.cache.delete(key);
|
||||
}
|
||||
await this.loadAlerts(1, true);
|
||||
} else {
|
||||
this.showNotification('解决预警失败', 'error');
|
||||
}
|
||||
|
||||
@@ -632,7 +632,7 @@ Object.assign(TSPDashboard.prototype, {
|
||||
this.showNotification(data.message, 'success');
|
||||
|
||||
// 清除缓存并强制刷新
|
||||
this.cache.delete('knowledge');
|
||||
for (const key of this.cache.keys()) { if (key.startsWith('knowledge')) this.cache.delete(key); }
|
||||
|
||||
// Task 7.3: 删除后检查是否所有条目已删除,若是则返回租户列表
|
||||
if (this.knowledgeCurrentTenantId) {
|
||||
|
||||
@@ -211,8 +211,10 @@ Object.assign(TSPDashboard.prototype, {
|
||||
const data = await response.json();
|
||||
if (data.success) {
|
||||
this.showNotification(data.message, 'success');
|
||||
this.cache.delete('workorders');
|
||||
await this.loadWorkOrders(true);
|
||||
for (const key of this.cache.keys()) {
|
||||
if (key.startsWith('workorders')) this.cache.delete(key);
|
||||
}
|
||||
await this.loadWorkOrders(1, true);
|
||||
await this.loadAnalytics();
|
||||
this.updateBatchDeleteButton();
|
||||
} else { this.showNotification(data.error || '批量删除失败', 'error'); }
|
||||
@@ -233,7 +235,8 @@ Object.assign(TSPDashboard.prototype, {
|
||||
this.showNotification('工单创建成功', 'success');
|
||||
bootstrap.Modal.getInstance(document.getElementById('createWorkOrderModal')).hide();
|
||||
document.getElementById('work-order-form').reset();
|
||||
await this.loadWorkOrders();
|
||||
for (const key of this.cache.keys()) { if (key.startsWith('workorders')) this.cache.delete(key); }
|
||||
await this.loadWorkOrders(1, true);
|
||||
await this.loadAnalytics();
|
||||
} else { this.showNotification('创建工单失败: ' + (data.error || '未知错误'), 'error'); }
|
||||
} catch (error) { console.error('创建工单失败:', error); this.showNotification('创建工单失败', 'error'); }
|
||||
@@ -340,6 +343,7 @@ Object.assign(TSPDashboard.prototype, {
|
||||
const data = await response.json();
|
||||
if (data.success) {
|
||||
this.showNotification('工单删除成功', 'success');
|
||||
for (const key of this.cache.keys()) { if (key.startsWith('workorders')) this.cache.delete(key); }
|
||||
await this.loadWorkOrders(this.paginationConfig.currentWorkOrderPage, true);
|
||||
await this.loadAnalytics();
|
||||
} else { this.showNotification('删除工单失败: ' + (data.error || '未知错误'), 'error'); }
|
||||
@@ -403,7 +407,8 @@ Object.assign(TSPDashboard.prototype, {
|
||||
if (result.success) {
|
||||
this.showNotification('工单更新成功', 'success');
|
||||
bootstrap.Modal.getInstance(document.getElementById('editWorkOrderModal')).hide();
|
||||
await this.loadWorkOrders();
|
||||
for (const key of this.cache.keys()) { if (key.startsWith('workorders')) this.cache.delete(key); }
|
||||
await this.loadWorkOrders(1, true);
|
||||
await this.loadAnalytics();
|
||||
} else { throw new Error(result.error || '更新工单失败'); }
|
||||
} catch (error) { console.error('更新工单失败:', error); this.showNotification('更新工单失败: ' + error.message, 'error'); }
|
||||
@@ -447,7 +452,8 @@ Object.assign(TSPDashboard.prototype, {
|
||||
document.getElementById('import-result').classList.remove('d-none');
|
||||
document.getElementById('import-success-message').textContent = `成功导入 ${result.imported_count} 个工单`;
|
||||
this.showNotification(result.message, 'success');
|
||||
this.loadWorkOrders();
|
||||
for (const key of this.cache.keys()) { if (key.startsWith('workorders')) this.cache.delete(key); }
|
||||
this.loadWorkOrders(1, true);
|
||||
setTimeout(() => { bootstrap.Modal.getInstance(document.getElementById('importWorkOrderModal')).hide(); }, 3000);
|
||||
} else { throw new Error(result.error || '导入工单失败'); }
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user