ORDERLIST_RESPONSE_ADAPTATION.md
3.88 KB
OrderList.vue 接口响应适配更新
更新时间
2026-01-23 16:30
更新原因
根据实际的 getQualityCheckList 接口返回结构调整代码
实际接口返回结构
{
"msg": "操作成功",
"code": 200,
"data": {
"records": [
{
"applyId": "AP2008001564517023744",
"campaignId": "123456",
"accNbr": "13112345678",
"areaName": "北京丰台",
"checkStatus": 1,
"checkStatusDesc": "未开始",
"failReason": null,
"startTime": null,
"endTime": null,
"noShowNum": 0,
"manualInputNum": 0,
"cheatNum": 0,
"isCheat": 0
}
],
"total": 1071,
"size": 10,
"current": 1,
"pages": 108
},
"timestamp": 1769154819516
}
主要修改点
1. 数据列表字段
-
❌ 之前:data.list -
✅ 现在:data.records
2. 字段映射关系
| 后端字段 | 前端字段 | 说明 |
|---|---|---|
| applyId | applyId, id | Apply ID,同时作为唯一标识 |
| campaignId | workerId | 师傅工号 |
| accNbr | businessAccount | 业务账号 |
| areaName | city | 所属地市 |
| checkStatus | - | 质检状态(数字) |
| checkStatusDesc | status | 质检状态(文字描述) |
| failReason | cannotQcReason | 无法质检原因 |
| startTime | startTime | 开始时间 |
| endTime | endTime | 结束时间 |
| noShowNum | noPhotoCount | 无法拍摄次数 |
| manualInputNum | manualInputCount | 手动输入次数 |
| cheatNum | envAbnormalCount | 环境异常次数 |
| isCheat | isCheating | 是否作弊(0/1 → false/true) |
3. 状态转换
添加了 getStatusText 辅助函数,用于将数字状态转换为文字:
const getStatusText = (status: number): string => {
const statusMap: Record<number, string> = {
0: '未开始',
1: '未开始',
2: '进行中',
3: '已完成',
4: '无法质检'
}
return statusMap[status] || '未知'
}
优先使用后端返回的 checkStatusDesc,如果没有则使用 getStatusText 转换。
4. 数据映射逻辑
tableData.value = (data.records || []).map((item: any) => ({
id: item.applyId,
applyId: item.applyId,
workerId: item.campaignId,
businessAccount: item.accNbr,
orderIds: [], // 工单ID列表需要单独查询
city: item.areaName,
status: item.checkStatusDesc || getStatusText(item.checkStatus),
cannotQcReason: item.failReason || '',
startTime: item.startTime || '',
endTime: item.endTime || '',
noPhotoCount: item.noShowNum || 0,
manualInputCount: item.manualInputNum || 0,
envAbnormalCount: item.cheatNum || 0,
isCheating: item.isCheat === 1,
cheatingReason: '',
cheatingRemark: '',
cheatingTime: ''
}))
注意事项
1. 工单ID列表
orderIds 字段在当前接口中没有返回,设置为空数组。如果需要显示工单ID列表,可能需要:
- 调用其他接口获取
- 或者后端在 records 中增加该字段
2. 作弊相关信息
列表接口中的作弊信息(cheatingReason, cheatingRemark, cheatingTime)需要在点击"查看作弊详情"时通过 getCheatMarkDetail 接口获取。
3. 分页信息
后端返回了完整的分页信息:
-
total: 总记录数 -
size: 每页大小 -
current: 当前页 -
pages: 总页数
目前只使用了 total,其他字段可以根据需要使用。
测试建议
-
✅ 测试列表数据是否正确显示 -
✅ 测试各个字段的映射是否正确 -
✅ 测试状态显示是否正确 -
✅ 测试作弊标记显示(isCheat = 1 时显示"是") -
✅ 测试分页功能 -
✅ 测试筛选条件
下一步
如果其他接口(如 getProcessDetailList, getCheatMarkDetail 等)的返回结构与预期不同,也需要进行类似的适配调整。