新增 兑换码驳回编辑

This commit is contained in:
wangsongsole 2022-06-19 20:24:27 +08:00
parent cc5efc4f4d
commit dbbb13e2da
1 changed files with 85 additions and 41 deletions

View File

@ -118,45 +118,24 @@ export default class exchangedit extends React.Component {
receive_email: req.receive_email
}
//获取分销商
getReseller(req.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({ reseller: resller_obj })
/* 转换数据结构 */
req.update_product.legal.map((item1) => {
item1.type = 1
item1.only = item1.product_id
item1.upstream = '直连天下'
})
req.update_product.reduce.map((item1) => {
item1.type = 2
item1.only = item1.channel_activity_id
item1.upstream =
String(item1.channel) === '1' ? '支付宝' : '微信' //上游
item1.origin = item1
item1.product_type_text = '立减金'
item1.contract_price = item1.price
item1.create_time = item1.create_time
item1.official_price = item1.reduce_amount
item1.channel_activity_id = item1.channel_activity_id
item1.product_name = item1.batch_goods_name
item1.quantity = item1.stock
item1.stock = Math.trunc(
item1.all_budget / item1.reduce_amount -
item1.used_amount / item1.reduce_amount
)
item1.usage = Math.trunc(
item1.all_budget / item1.reduce_amount -
(item1.all_budget - item1.used_amount) / item1.reduce_amount
)
item1.effectDate =
item1.time_limit.effect_time.start_time +
' 至 ' +
item1.time_limit.effect_time.end_time //有效时间
})
req.update_product = [
...req.update_product.legal,
...req.update_product.reduce
]
req.update_product = [...this.transFormData1(req.update_product)]
req.new_product = [...this.transFormData1(req.new_product, true)]
let codeInfo = {
code_name: req.title,
@ -166,6 +145,7 @@ export default class exchangedit extends React.Component {
date_time: [req.begin_time, req.end_time],
range: req.update_product
}
if (req.new_product.length > 0) {
req.new_product = _.map(req.new_product, (item) => {
item.checked = false
@ -229,7 +209,7 @@ export default class exchangedit extends React.Component {
obj.key = res.only
obj.text = res.product_name
if (new_ids.indexOf(res.only) < 0) {
this.state.oldProduct.push(res.only)
this.state.oldProduct.push(res.id)
}
if (
table.find((o) => o.only == res.only).checked == true
@ -250,6 +230,14 @@ export default class exchangedit extends React.Component {
)
this.setState({ paytype: index + 1 })
}
sessionStorage.setItem(
'productData',
JSON.stringify(codeInfo.range)
)
sessionStorage.setItem(
'knockGoldData',
JSON.stringify(codeInfo.range)
)
},
(err) => {}
)
@ -347,6 +335,58 @@ export default class exchangedit extends React.Component {
}
}
transFormData1(req, type) {
const newData = []
/* 转换数据结构 */
req.legal.map((item1) => {
item1.type = 1
item1.only = item1.product_id
item1.upstream = '直连天下'
if (item1?.goods_id) {
item1.id = item1.goods_id
}
newData.push(item1)
})
req.reduce.map((item1) => {
let obj = {}
obj.type = 2
obj.only = item1.channel_activity_id
obj.upstream = String(item1.channel) === '1' ? '支付宝' : '微信' //上游
obj.origin = item1
if (item1?.goods_id) {
obj.id = item1?.goods_id
}
obj.product_type_text = '立减金'
obj.contract_price = item1.price
obj.create_time = item1.create_time
obj.official_price = item1.reduce_amount
obj.channel_activity_id = item1.channel_activity_id
obj.product_name = item1.batch_goods_name
if (type) {
obj.quantity = Math.trunc(item1.all_budget / item1.reduce_amount)
obj.stock = Math.trunc(item1.all_budget / item1.reduce_amount)
obj.usage = 0
} else {
obj.quantity = item1.stock
obj.stock = Math.trunc(
item1.all_budget / item1.reduce_amount -
item1.used_amount / item1.reduce_amount
)
obj.usage = Math.trunc(
item1.all_budget / item1.reduce_amount -
(item1.all_budget - item1.used_amount) / item1.reduce_amount
)
}
obj.effectDate =
item1.time_limit.effect_time.start_time +
' 至 ' +
item1.time_limit.effect_time.end_time
newData.push(obj)
}) //有效时间
return newData
}
/* 转换数据 */
transFormData(reqCopy) {
const resData = []
@ -527,7 +567,7 @@ export default class exchangedit extends React.Component {
delete_product: deleteProduct
}
return data
return { data, addProduct, updateProduct }
}
submitCodeData() {
if (!this.state.reseller) {
@ -536,7 +576,7 @@ export default class exchangedit extends React.Component {
}
let code_batch_id = sessionStorage.getItem('code_id')
let data = this.buildData()
let { data } = this.buildData()
putCodesBatch(code_batch_id, data).then((res) => {
handelResponse(
res,
@ -573,7 +613,11 @@ export default class exchangedit extends React.Component {
return
}
let code_batch_id = sessionStorage.getItem('code_id')
let data = this.buildData()
let { data, addProduct, updateProduct } = this.buildData()
if ([...updateProduct, ...addProduct].length < 1) {
return Notify.error('请绑定对象')
}
let approval_id = sessionStorage.getItem('approval_id')
console.log('approval_id ==>', approval_id)