|
|
|
@ -259,9 +259,9 @@ export default { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
console.log("🔥 准备插入新记录:", newRecord); |
|
|
|
console.log("🔥 准备插入新记录:", newRecord); |
|
|
|
this.allSavedFileList.unshift(newRecord); |
|
|
|
// this.allSavedFileList.unshift(newRecord); |
|
|
|
this.total = this.allSavedFileList.length; |
|
|
|
// this.total = this.allSavedFileList.length; |
|
|
|
this.updateCurrentPageData(); |
|
|
|
// this.updateCurrentPageData(); |
|
|
|
console.log("🔥 已插入列表,当前总数:", this.total); |
|
|
|
console.log("🔥 已插入列表,当前总数:", this.total); |
|
|
|
|
|
|
|
|
|
|
|
// 调用上传接口 |
|
|
|
// 调用上传接口 |
|
|
|
@ -333,7 +333,8 @@ export default { |
|
|
|
record.analysisDate = JSON.stringify(result.data); |
|
|
|
record.analysisDate = JSON.stringify(result.data); |
|
|
|
|
|
|
|
|
|
|
|
// 保存上传记录到本地 |
|
|
|
// 保存上传记录到本地 |
|
|
|
await window.api.saveFileInfo([{ |
|
|
|
await window.api.saveFileInfo([ |
|
|
|
|
|
|
|
{ |
|
|
|
deviceId: device.code, |
|
|
|
deviceId: device.code, |
|
|
|
orderNumber: file.fileName.replace(/\.[^/.]+$/, ""), |
|
|
|
orderNumber: file.fileName.replace(/\.[^/.]+$/, ""), |
|
|
|
deviceModel: device.codeType, |
|
|
|
deviceModel: device.codeType, |
|
|
|
@ -342,15 +343,19 @@ export default { |
|
|
|
type: "auto", |
|
|
|
type: "auto", |
|
|
|
date: this.getCurrentDateTime(), |
|
|
|
date: this.getCurrentDateTime(), |
|
|
|
uploadType: "自动上传", |
|
|
|
uploadType: "自动上传", |
|
|
|
}]); |
|
|
|
}, |
|
|
|
|
|
|
|
]); |
|
|
|
console.log("自动上传成功"); |
|
|
|
console.log("自动上传成功"); |
|
|
|
this.lastUploadStatus = { title: "上传成功", type: "success" }; |
|
|
|
this.lastUploadStatus = { title: "上传成功", type: "success" }; |
|
|
|
|
|
|
|
this.getSavedFileInfo(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// 🔥 更新列表中的记录状态为失败 |
|
|
|
|
|
|
|
record.uploading = false; |
|
|
|
record.uploading = false; |
|
|
|
record.analysisDate = "上传失败: " + result.msg; |
|
|
|
|
|
|
|
console.error("上传失败:", result.msg); |
|
|
|
record.analysisDate = "上传失败: " + (result.msg || "上传异常"); |
|
|
|
this.lastUploadStatus = { title: result.msg, type: "error" }; |
|
|
|
this.lastUploadStatus = { |
|
|
|
|
|
|
|
title: result.msg || "上传异常", |
|
|
|
|
|
|
|
type: "error", |
|
|
|
|
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (err) { |
|
|
|
} catch (err) { |
|
|
|
// 🔥 更新列表中的记录状态为失败 |
|
|
|
// 🔥 更新列表中的记录状态为失败 |
|
|
|
@ -373,10 +378,32 @@ export default { |
|
|
|
this.tableLoading = true; |
|
|
|
this.tableLoading = true; |
|
|
|
const res = await window.api.getSavedFileInfo(); |
|
|
|
const res = await window.api.getSavedFileInfo(); |
|
|
|
if (res.success) { |
|
|
|
if (res.success) { |
|
|
|
// 只显示自动上传的记录 |
|
|
|
// 1. 筛选出自动上传的记录 |
|
|
|
this.allSavedFileList = res.data.filter( |
|
|
|
const autoUploadRecords = res.data.filter( |
|
|
|
(item) => item.uploadType === "自动上传" |
|
|
|
(item) => item.uploadType === "自动上传" |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 2. 去重逻辑:根据 orderNumber 和 fileName 去重,保留最新的一条 |
|
|
|
|
|
|
|
// 假设 res.data 已经是按时间倒序排列(最新的在前) |
|
|
|
|
|
|
|
const uniqueMap = new Map(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
autoUploadRecords.forEach(item => { |
|
|
|
|
|
|
|
// 生成唯一键:订单号_文件名 |
|
|
|
|
|
|
|
// 如果 orderNumber 可能为空,可以加个默认值防止 key 冲突,例如: (item.orderNumber || 'unknown') + '_' + item.fileName |
|
|
|
|
|
|
|
const key = `${item.orderNumber}_${item.fileName}`; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 如果 Map 中不存在该 key,则存入。 |
|
|
|
|
|
|
|
// 因为是从前向后遍历(最新 -> 最旧),所以第一次遇到的就是最新的,后续的重复项会被忽略 |
|
|
|
|
|
|
|
if (!uniqueMap.has(key)) { |
|
|
|
|
|
|
|
uniqueMap.set(key, item); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 3. 将 Map 的值转换回数组 |
|
|
|
|
|
|
|
// 注意:Map.values() 保持插入顺序,所以这里依然是按时间倒序 |
|
|
|
|
|
|
|
this.allSavedFileList = Array.from(uniqueMap.values()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 4. 更新总数和当前页数据 |
|
|
|
this.total = this.allSavedFileList.length; |
|
|
|
this.total = this.allSavedFileList.length; |
|
|
|
this.updateCurrentPageData(); |
|
|
|
this.updateCurrentPageData(); |
|
|
|
console.log(`成功读取${this.total}条自动上传记录`); |
|
|
|
console.log(`成功读取${this.total}条自动上传记录`); |
|
|
|
|