This commit is contained in:
Leo
2026-01-06 18:28:43 +08:00
parent 7871acf214
commit acfc5e60f4

View File

@@ -288,8 +288,22 @@ export default {
async loadBatchRecords() {
try {
const res = await getBatchPushRecords({ limit: 20 })
console.log('加载推送记录响应:', res)
if (res.code === 200) {
this.batchRecords = res.data || []
const records = res.data || []
// 确保每条记录都有 operationLogs 字段(即使为空数组)
records.forEach(record => {
if (!record.hasOwnProperty('operationLogs')) {
this.$set(record, 'operationLogs', [])
}
// 重置详情加载标记,允许重新加载
this.$set(record, 'detailLoaded', false)
})
this.batchRecords = records
console.log('推送记录数量:', records.length)
records.forEach(r => {
console.log(`记录 ${r.batchId}: operationLogs数量=${r.operationLogs ? r.operationLogs.length : 'undefined'}`)
})
}
} catch (e) {
console.error('加载推送记录失败', e)
@@ -361,8 +375,9 @@ export default {
const record = this.batchRecords.find(r => r.batchId === batchId)
if (!record) return
// 如果已经加载过详情,则不再重复加载
if (record.operationLogs && record.operationLogs.length > 0) {
// 如果已经明确加载过详情(有 loadingDetail 标记且已完成),则不再重复加载
// 注意:即使 operationLogs 为空数组,也可能是数据确实为空,需要重新加载确认
if (record.detailLoaded) {
return
}
@@ -370,11 +385,24 @@ export default {
this.$set(record, 'loadingDetail', true)
const res = await getBatchPushRecordDetail(batchId)
console.log('加载推送详情响应:', res)
console.log('响应数据:', JSON.stringify(res.data, null, 2))
if (res.code === 200 && res.data) {
// 更新记录的详细信息
this.$set(record, 'operationLogs', res.data.operationLogs || [])
const operationLogs = res.data.operationLogs || []
console.log('操作日志数量:', operationLogs.length, 'batchId:', batchId)
console.log('操作日志详情:', operationLogs)
this.$set(record, 'operationLogs', operationLogs)
this.$set(record, 'errorMessage', res.data.errorMessage)
this.$set(record, 'resultMessage', res.data.remark)
// 使用 resultMessage 字段,如果没有则使用 remark
this.$set(record, 'resultMessage', res.data.resultMessage || res.data.remark)
// 标记已加载详情
this.$set(record, 'detailLoaded', true)
// 如果操作日志为空,输出警告信息用于调试
if (operationLogs.length === 0) {
console.warn('操作日志为空 - batchId:', batchId, '记录数据:', res.data)
}
} else {
this.$message.warning('加载详情失败: ' + (res.msg || '未知错误'))
}