From 677191c5860ba20e68afbd55aa8cb3ac65752565 Mon Sep 17 00:00:00 2001 From: wangsongsole Date: Fri, 17 Jun 2022 15:44:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=91=E6=8D=A2=E7=A0=81=20=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=88=97=E8=A1=A8=E5=8F=8D=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/knockGold/Dialog.jsx | 19 ++++++++++++++++--- src/pages/exchangecode/edit/edit.js | 8 +++++--- 2 files changed, 21 insertions(+), 6 deletions(-) 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 })