refactor(todo page): 统一数据字段映射与key绑定
1. 将列表循环的key从item.actionId改为item.coilId,确保唯一标识正确 2. 新增mapDataFields方法统一处理后端字段到前端字段的映射 3. 替换fetchList中原有的直接赋值逻辑,使用映射后的新数据 4. 简化handleViewRecord和handleViewDetail中的coilId获取逻辑
This commit is contained in:
@@ -42,7 +42,7 @@
|
|||||||
<view v-if="activeTab === 'label'" class="coil-list">
|
<view v-if="activeTab === 'label'" class="coil-list">
|
||||||
<coil-card
|
<coil-card
|
||||||
v-for="item in list"
|
v-for="item in list"
|
||||||
:key="item.actionId"
|
:key="item.coilId"
|
||||||
:data="item"
|
:data="item"
|
||||||
@relabel="handleRelabel"
|
@relabel="handleRelabel"
|
||||||
@view-record="handleViewRecord"
|
@view-record="handleViewRecord"
|
||||||
@@ -149,6 +149,32 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 数据字段映射 - 将后端字段映射到前端使用的字段
|
||||||
|
// 后端 WmsMaterialCoilVo 字段:coilId, enterCoilNo, currentCoilNo,
|
||||||
|
// itemName, specification, material, manufacturer,
|
||||||
|
// actualWarehouseName, warehouseName, remark, transferType
|
||||||
|
mapDataFields(row) {
|
||||||
|
return {
|
||||||
|
// 钢卷ID
|
||||||
|
coilId: row.coilId,
|
||||||
|
// 钢卷号
|
||||||
|
enterCoilNo: row.enterCoilNo || '-',
|
||||||
|
currentCoilNo: row.currentCoilNo || '-',
|
||||||
|
// 产品信息(注意后端使用 specification/material/manufacturer,非 item 前缀)
|
||||||
|
itemName: row.itemName || '-',
|
||||||
|
itemSpecification: row.specification || '-',
|
||||||
|
itemMaterial: row.material || '-',
|
||||||
|
itemManufacturer: row.manufacturer || '-',
|
||||||
|
// 库区信息
|
||||||
|
actualWarehouseName: row.actualWarehouseName || row.warehouseName || '-',
|
||||||
|
// 其他字段
|
||||||
|
remark: row.remark || '-',
|
||||||
|
transferType: row.transferType || '',
|
||||||
|
// 改判原因(后端 WmsMaterialCoilVo 无此字段,仅通过 listWithRejudge 接口传入)
|
||||||
|
changeReason: row.changeReason || ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// 获取列表数据
|
// 获取列表数据
|
||||||
async fetchList(isLoadMore = false) {
|
async fetchList(isLoadMore = false) {
|
||||||
if (this.loading) return
|
if (this.loading) return
|
||||||
@@ -162,12 +188,14 @@ export default {
|
|||||||
const rows = res.rows || []
|
const rows = res.rows || []
|
||||||
this.total = res.total || 0
|
this.total = res.total || 0
|
||||||
|
|
||||||
console.log('解析后的数据:', { rows, total: this.total })
|
// 映射数据字段
|
||||||
|
const mappedRows = rows.map(row => this.mapDataFields(row))
|
||||||
|
console.log('映射后的数据:', { mappedRows, total: this.total })
|
||||||
|
|
||||||
if (isLoadMore) {
|
if (isLoadMore) {
|
||||||
this.list = [...this.list, ...rows]
|
this.list = [...this.list, ...mappedRows]
|
||||||
} else {
|
} else {
|
||||||
this.list = rows
|
this.list = mappedRows
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新待贴标签数量
|
// 更新待贴标签数量
|
||||||
@@ -249,7 +277,7 @@ export default {
|
|||||||
|
|
||||||
// 查看记录
|
// 查看记录
|
||||||
handleViewRecord(coilInfo) {
|
handleViewRecord(coilInfo) {
|
||||||
const coilId = coilInfo.coilId || coilInfo.materialCoilId
|
const coilId = coilInfo.coilId
|
||||||
if (!coilId) {
|
if (!coilId) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '无法获取钢卷ID',
|
title: '无法获取钢卷ID',
|
||||||
@@ -262,7 +290,7 @@ export default {
|
|||||||
|
|
||||||
// 查看详情
|
// 查看详情
|
||||||
handleViewDetail(coilInfo) {
|
handleViewDetail(coilInfo) {
|
||||||
const coilId = coilInfo.coilId || coilInfo.materialCoilId
|
const coilId = coilInfo.coilId
|
||||||
if (!coilId) {
|
if (!coilId) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '无法获取钢卷ID',
|
title: '无法获取钢卷ID',
|
||||||
|
|||||||
Reference in New Issue
Block a user