diff --git a/src/components/knockGold/Dialog.jsx b/src/components/knockGold/Dialog.jsx index b913353d..8d742dc1 100644 --- a/src/components/knockGold/Dialog.jsx +++ b/src/components/knockGold/Dialog.jsx @@ -33,10 +33,23 @@ export default ({ data, onChangeMoney }) => { newData.recharge_amount = ( Number(stateData.addNew) + Number(stateData.recharge_amount) ).toFixed(2) - sessionStorage.setItem( - 'addMoneyData', - JSON.stringify(newData) + + let origin = [] + if (sessionStorage.getItem('addMoneyData')) { + origin = JSON.parse(sessionStorage.getItem('addMoneyData')) + } + + let index = origin.findIndex( + (o) => o.channel_activity_id == newData.channel_activity_id ) + if (index !== -1) { + origin[index] = newData + } else { + origin.push(newData) + } + + sessionStorage.setItem('addMoneyData', JSON.stringify(origin)) + onChangeMoney(false, Number(stateData.addNew)) }, 1000) }, diff --git a/src/pages/exchangecode/edit/edit.js b/src/pages/exchangecode/edit/edit.js index 2538f651..bedd1873 100644 --- a/src/pages/exchangecode/edit/edit.js +++ b/src/pages/exchangecode/edit/edit.js @@ -315,9 +315,11 @@ export default class exchangedit extends React.Component { if (sessionStorage.getItem('addMoneyData')) { const addMoneyData = JSON.parse(sessionStorage.getItem('addMoneyData')) const tempdata = _.cloneDeep(this.state.tempdata).map((item) => { - if (item.channel_activity_id === addMoneyData.channel_activity_id) { - item.origin.recharge_amount = addMoneyData.recharge_amount - } + addMoneyData.map((item1) => { + if (item.channel_activity_id === item1.channel_activity_id) { + item.origin.recharge_amount = item1.recharge_amount + } + }) return item }) this.setState({ tempdata })