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 FormItem from '@/components/form-item/main'
import rules from './rules'
import _ from 'lodash'
import { Button, Notify } from 'zent'
import { addFund, handelResponse } from '@/assets/api'
export default ({ data, onChangeMoney }) => {
@ -28,6 +29,14 @@ export default ({ data, onChangeMoney }) => {
Notify.success('加款成功')
setIsCount(true)
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))
}, 1000)
},

View File

@ -241,95 +241,58 @@ export default class exchangedit extends React.Component {
})
.catch((err) => {})
} else {
this.getTableList()
}
}
getCodesDetail(code_batch_id)
.then((res) => {
handelResponse(
res,
(req, msg) => {
let reqCopy = _.cloneDeep(req)
const resData = this.transFormData(reqCopy)
reqCopy.goods = resData
let codeInfo = {
code_name: reqCopy.title,
issued: reqCopy.quantity,
stock: reqCopy.stock,
describe: reqCopy.describe,
date_time: [reqCopy.begin_time, reqCopy.end_time],
range: reqCopy.goods
}
getTableList(cancel) {
let code_batch_id = sessionStorage.getItem('code_id')
getCodesDetail(code_batch_id)
.then((res) => {
handelResponse(
res,
(req, msg) => {
let reqCopy = _.cloneDeep(req)
const resData = this.transFormData(reqCopy)
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)
this.setState({ plan_time: reqCopy.plan.end_time })
//获取分销商
getReseller(reqCopy.plan.reseller_id).then((res) => {
handelResponse(res, (req1, msg) => {
console.log('req ==>1', req1)
req1.receive_email = req1.contact_email[0]
this.setState({ reseller: req1 })
this.setState({ phone_list: req1.contact_phone })
this.setState({ email_list: req1.contact_email })
this.setState({
direct_reseller_id: req1.direct_reseller_id
})
})
})
reqCopy.goods = newConcatData
}
let codeInfo = {
code_name: reqCopy.title,
issued: reqCopy.quantity,
stock: reqCopy.stock,
describe: reqCopy.describe,
date_time: [reqCopy.begin_time, reqCopy.end_time],
range: reqCopy.goods
}
this.setState({ plan_time: reqCopy.plan.end_time })
//获取分销商
getReseller(reqCopy.plan.reseller_id).then((res) => {
handelResponse(res, (req1, msg) => {
console.log('req ==>1', req1)
req1.receive_email = req1.contact_email[0]
this.setState({ reseller: req1 })
this.setState({ phone_list: req1.contact_phone })
this.setState({ email_list: req1.contact_email })
this.setState({
direct_reseller_id: req1.direct_reseller_id
})
})
})
this.setState({ codeInfo: codeInfo })
this.setState({ isload: true })
_.map(reqCopy.goods, (res) => {
if (cancel) {
if (res.checked) {
res.checked = true
}
} else {
this.setState({ codeInfo: codeInfo })
this.setState({ isload: true })
_.map(reqCopy.goods, (res) => {
res.checked = true
}
return res
})
this.setState({ tempdata: reqCopy.goods || [] })
return res
})
this.setState({ tempdata: reqCopy.goods || [] })
let a1 = reqCopy.goods.map((item) => {
let obj = {
...item,
in: true
}
return obj
})
sessionStorage.setItem('productData', JSON.stringify(a1))
sessionStorage.setItem('knockGoldData', JSON.stringify(a1))
let arr = []
_.map(reqCopy.goods, (res) => {
if (cancel) {
if (res.checked) {
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
let a1 = reqCopy.goods.map((item) => {
let obj = {
...item,
in: true
}
} else {
return obj
})
sessionStorage.setItem('productData', JSON.stringify(a1))
sessionStorage.setItem('knockGoldData', JSON.stringify(a1))
let arr = []
_.map(reqCopy.goods, (res) => {
let obj = {}
obj.key = res.only
obj.text = res.product_name
@ -337,15 +300,28 @@ export default class exchangedit extends React.Component {
this.state.oldProduct.push(res.id)
arr.push(obj)
return obj
}
})
this.setState({ rankoptions: arr })
this.setState({ rank: arr })
},
(err) => {}
)
})
this.setState({ rankoptions: arr })
this.setState({ rank: arr })
},
(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
})
.catch((err) => {})
this.setState({ tempdata })
}
}
/* 转换数据 */
@ -795,7 +771,7 @@ export default class exchangedit extends React.Component {
})
}
let newArray = deWeightThree(temp.concat(concatData), 'only')
console.log(newArray)
//select数据
let arr = []
let rank = []
@ -809,6 +785,7 @@ export default class exchangedit extends React.Component {
arr = deWeightThree(arr, 'key')
this.setState({ tempdata: newArray, rankoptions: arr, rank })
this.getTableList()
}, 500)
}
}
@ -1403,7 +1380,7 @@ export default class exchangedit extends React.Component {
<Button
onClick={(e) => {
this.setState({ drawerVisible2: false })
this.getTableList('cancel')
this.getTableList()
}}>
取消
</Button>