This commit is contained in:
wangsongsole 2022-06-17 15:19:38 +08:00
parent 1bc75b1870
commit 37e415a9d9
2 changed files with 78 additions and 92 deletions

View File

@ -4,6 +4,7 @@ import Ipt from '@/components/input/main'
import Form from '@/components/form/main' import Form from '@/components/form/main'
import FormItem from '@/components/form-item/main' import FormItem from '@/components/form-item/main'
import rules from './rules' import rules from './rules'
import _ from 'lodash'
import { Button, Notify } from 'zent' import { Button, Notify } from 'zent'
import { addFund, handelResponse } from '@/assets/api' import { addFund, handelResponse } from '@/assets/api'
export default ({ data, onChangeMoney }) => { export default ({ data, onChangeMoney }) => {
@ -28,6 +29,14 @@ export default ({ data, onChangeMoney }) => {
Notify.success('加款成功') Notify.success('加款成功')
setIsCount(true) setIsCount(true)
setTimeout(() => { setTimeout(() => {
const newData = _.cloneDeep(stateData)
newData.recharge_amount = (
Number(stateData.addNew) + Number(stateData.recharge_amount)
).toFixed(2)
sessionStorage.setItem(
'addMoneyData',
JSON.stringify(newData)
)
onChangeMoney(false, Number(stateData.addNew)) onChangeMoney(false, Number(stateData.addNew))
}, 1000) }, 1000)
}, },

View File

@ -241,12 +241,6 @@ export default class exchangedit extends React.Component {
}) })
.catch((err) => {}) .catch((err) => {})
} else { } else {
this.getTableList()
}
}
getTableList(cancel) {
let code_batch_id = sessionStorage.getItem('code_id')
getCodesDetail(code_batch_id) getCodesDetail(code_batch_id)
.then((res) => { .then((res) => {
handelResponse( handelResponse(
@ -255,20 +249,6 @@ export default class exchangedit extends React.Component {
let reqCopy = _.cloneDeep(req) let reqCopy = _.cloneDeep(req)
const resData = this.transFormData(reqCopy) const resData = this.transFormData(reqCopy)
reqCopy.goods = resData reqCopy.goods = resData
//取消
if (cancel) {
const newConcatData = []
reqCopy.goods.filter((item) => {
this.state.tempdata.filter((item1) => {
if (item.only === item1.only) {
item1.origin.recharge_amount = item.origin.recharge_amount
}
newConcatData.push(item1)
})
})
reqCopy.goods = newConcatData
}
let codeInfo = { let codeInfo = {
code_name: reqCopy.title, code_name: reqCopy.title,
issued: reqCopy.quantity, issued: reqCopy.quantity,
@ -296,13 +276,7 @@ export default class exchangedit extends React.Component {
this.setState({ codeInfo: codeInfo }) this.setState({ codeInfo: codeInfo })
this.setState({ isload: true }) this.setState({ isload: true })
_.map(reqCopy.goods, (res) => { _.map(reqCopy.goods, (res) => {
if (cancel) {
if (res.checked) {
res.checked = true res.checked = true
}
} else {
res.checked = true
}
return res return res
}) })
this.setState({ tempdata: reqCopy.goods || [] }) this.setState({ tempdata: reqCopy.goods || [] })
@ -319,8 +293,6 @@ export default class exchangedit extends React.Component {
let arr = [] let arr = []
_.map(reqCopy.goods, (res) => { _.map(reqCopy.goods, (res) => {
if (cancel) {
if (res.checked) {
let obj = {} let obj = {}
obj.key = res.only obj.key = res.only
obj.text = res.product_name obj.text = res.product_name
@ -328,16 +300,6 @@ export default class exchangedit extends React.Component {
this.state.oldProduct.push(res.id) this.state.oldProduct.push(res.id)
arr.push(obj) arr.push(obj)
return obj return obj
}
} else {
let obj = {}
obj.key = res.only
obj.text = res.product_name
obj.id = res.id
this.state.oldProduct.push(res.id)
arr.push(obj)
return obj
}
}) })
this.setState({ rankoptions: arr }) this.setState({ rankoptions: arr })
this.setState({ rank: arr }) this.setState({ rank: arr })
@ -347,6 +309,20 @@ export default class exchangedit extends React.Component {
}) })
.catch((err) => {}) .catch((err) => {})
} }
}
getTableList() {
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
}
return item
})
this.setState({ tempdata })
}
}
/* 转换数据 */ /* 转换数据 */
transFormData(reqCopy) { transFormData(reqCopy) {
@ -795,7 +771,7 @@ export default class exchangedit extends React.Component {
}) })
} }
let newArray = deWeightThree(temp.concat(concatData), 'only') let newArray = deWeightThree(temp.concat(concatData), 'only')
console.log(newArray)
//select数据 //select数据
let arr = [] let arr = []
let rank = [] let rank = []
@ -809,6 +785,7 @@ export default class exchangedit extends React.Component {
arr = deWeightThree(arr, 'key') arr = deWeightThree(arr, 'key')
this.setState({ tempdata: newArray, rankoptions: arr, rank }) this.setState({ tempdata: newArray, rankoptions: arr, rank })
this.getTableList()
}, 500) }, 500)
} }
} }
@ -1403,7 +1380,7 @@ export default class exchangedit extends React.Component {
<Button <Button
onClick={(e) => { onClick={(e) => {
this.setState({ drawerVisible2: false }) this.setState({ drawerVisible2: false })
this.getTableList('cancel') this.getTableList()
}}> }}>
取消 取消
</Button> </Button>