fix:修复编辑和复制兑换码数据勾选不正确问题

This commit is contained in:
wangsongsole 2022-10-26 10:28:14 +08:00
parent 51fc29c8f4
commit 3e6139bb65
1 changed files with 7 additions and 18 deletions

View File

@ -153,6 +153,7 @@ export default class exchangeAdd extends React.Component {
}
}
const checkedArray = [] /* 要勾选得数据 */
/* 处理新老数据 */
if (resData.length > 0) {
let new_ids = [] /* 新数据唯一id */
@ -160,6 +161,11 @@ export default class exchangeAdd extends React.Component {
codeInfo.range = resData.map((item) => {
if (item?.id) {
/* 老数据 */
checkedArray.push({
key: item.only,
text: item.product_name,
id: item.id
})
item.checked = true
old_ids.push(item.id)
} else {
@ -189,23 +195,6 @@ export default class exchangeAdd extends React.Component {
arr.push(obj)
return obj
})
// is_delete
_.map(reqCopy.goods, (item) => {
if (item.type === 2) {
if (item.origin.is_delete) {
item.checked = false
} else {
item.checked = true
}
} else {
if (item.is_delete) {
item.checked = false
} else {
item.checked = true
}
}
return item
})
/* 统一设置state */
this.setState({
@ -213,7 +202,7 @@ export default class exchangeAdd extends React.Component {
isload: true,
tempdata: reqCopy.goods || [],
plan_time: [reqCopy.plan.start_time, reqCopy.plan.end_time],
rank: arr,
rank: checkedArray,
rankoptions: arr
})