fix: 修复 复制不能编辑多主体

This commit is contained in:
zhangds 2024-05-13 15:07:25 +08:00
parent e0296bb3ea
commit aae48e2210
2 changed files with 7 additions and 3 deletions

View File

@ -954,6 +954,7 @@ export default class addKnockGold extends Component {
{this.state.subjectList.length > 0 && (
<VoucherBatch
ref="voucherBatchRef"
isEdit={!!this.props.data?.id}
channel={this.state.model.channel}
subjectList={this.state.subjectList}
voucherBatchData={this.props.data?.voucher_batch}

View File

@ -2,7 +2,7 @@ import { Grid, Input, Select, Button, Notify } from "zent"
import { useCallback, useState, useMemo, forwardRef, useImperativeHandle, useEffect } from "react"
const VoucherBatch = forwardRef((props, ref) => {
const { channel, voucherBatchData, subjectList } = props
const { channel, voucherBatchData, subjectList, isEdit } = props
const onPriceChange = useCallback(
(rowIndex, key, valueType) => (val) => {
setDatasets((prev) => {
@ -28,13 +28,16 @@ const VoucherBatch = forwardRef((props, ref) => {
if (voucherBatchData) {
let new_data = voucherBatchData.map((item) => {
let provider_el = subjectList.find((row) => row.key === item.provider)
return {
id: item.id,
let obj = {
provider: provider_el ? provider_el : subjectList[0],
channel_activity_id: item.channel_activity_id,
temp_no: item.temp_no,
weight: item.weight
}
if (isEdit) {
obj.id = item.id
}
return obj
})
return new_data
} else {