新增兑换码复制逻辑
This commit is contained in:
parent
e36f8c6f3f
commit
8ab5cfb506
|
@ -52,6 +52,7 @@ export default class exchangeAdd extends React.Component {
|
||||||
this.setState({ isState })
|
this.setState({ isState })
|
||||||
if (isState === 1) {
|
if (isState === 1) {
|
||||||
/* 复制 */
|
/* 复制 */
|
||||||
|
this.copyFunction()
|
||||||
} else if (isState === 2) {
|
} else if (isState === 2) {
|
||||||
/* 编辑 */
|
/* 编辑 */
|
||||||
this.editFunction()
|
this.editFunction()
|
||||||
|
@ -278,6 +279,226 @@ export default class exchangeAdd extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 复制处理数据 */
|
||||||
|
copyFunction() {
|
||||||
|
let code_batch_id = sessionStorage.getItem("code_id")
|
||||||
|
let approval_id = sessionStorage.getItem("approval_id")
|
||||||
|
let approval_status = sessionStorage.getItem("approval_status")
|
||||||
|
/* 被复制得兑换码id */
|
||||||
|
let copy_code_id = ~~sessionStorage.getItem("copy_code_id")
|
||||||
|
if (Number(approval_id) > 0) {
|
||||||
|
//此处为审核中
|
||||||
|
getApprovalsInfo(approval_id)
|
||||||
|
.then((res) => {
|
||||||
|
handelResponse(
|
||||||
|
res,
|
||||||
|
(req, msg) => {
|
||||||
|
let resller_obj = {
|
||||||
|
id: req.reseller_id,
|
||||||
|
name: req.reseller_name,
|
||||||
|
company_name: req.company_name,
|
||||||
|
receive_email: req.receive_email
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取分销商
|
||||||
|
getReseller(req.reseller_id).then((res) => {
|
||||||
|
handelResponse(res, (req1, msg) => {
|
||||||
|
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 = [...this.transFormData1(req.update_product)]
|
||||||
|
req.new_product = [...this.transFormData1(req.new_product, true)]
|
||||||
|
|
||||||
|
let codeInfo = {
|
||||||
|
code_name: req.title,
|
||||||
|
issued: req.quantity,
|
||||||
|
stock: req.stock,
|
||||||
|
describe: req.describe,
|
||||||
|
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
|
||||||
|
return item
|
||||||
|
})
|
||||||
|
codeInfo.range = codeInfo.range.concat(req.new_product)
|
||||||
|
}
|
||||||
|
|
||||||
|
let new_ids = _.map(req.new_product, (o) => {
|
||||||
|
return o.only
|
||||||
|
})
|
||||||
|
|
||||||
|
this.setState({ new_product: new_ids })
|
||||||
|
let delete_product = req.delete_product
|
||||||
|
let payment_direction = req.payment_direction
|
||||||
|
getCodesDetail(code_batch_id)
|
||||||
|
.then((res) => {
|
||||||
|
handelResponse(
|
||||||
|
res,
|
||||||
|
(req, msg) => {
|
||||||
|
codeInfo.stock = req.stock
|
||||||
|
this.setState({ plan_time: req.plan.end_time })
|
||||||
|
let reqCopy = _.cloneDeep(req)
|
||||||
|
const resData = this.transFormData(reqCopy)
|
||||||
|
this.setState({ oldTable: resData })
|
||||||
|
let deleteArr = []
|
||||||
|
|
||||||
|
for (let i = 0; i < delete_product.length; i++) {
|
||||||
|
let deleteData = resData.find(
|
||||||
|
(o) => o.only == delete_product[i]
|
||||||
|
)
|
||||||
|
deleteData.checked = false
|
||||||
|
deleteArr.push(deleteData)
|
||||||
|
}
|
||||||
|
this.setState({ codeInfo: codeInfo })
|
||||||
|
this.setState({ isload: true })
|
||||||
|
codeInfo.range = codeInfo.range.concat(deleteArr)
|
||||||
|
let table = _.map(codeInfo.range, (res) => {
|
||||||
|
let obj = resData.find((o) => o.only == res.only)
|
||||||
|
|
||||||
|
res.usage = obj ? obj.usage : 0
|
||||||
|
res.stock = obj ? obj.stock : res.quantity - res.usage
|
||||||
|
res.checked = res.hasOwnProperty("checked")
|
||||||
|
? res.checked
|
||||||
|
: true
|
||||||
|
if (approval_status == 7 && obj) {
|
||||||
|
res.checked = true
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
})
|
||||||
|
|
||||||
|
this.setState({ deleteProduct: [] })
|
||||||
|
|
||||||
|
this.setState({ tempdata: codeInfo.range })
|
||||||
|
|
||||||
|
let arr = []
|
||||||
|
let temp = []
|
||||||
|
_.map(codeInfo.range, (res) => {
|
||||||
|
let obj = {}
|
||||||
|
obj.key = res.only
|
||||||
|
obj.text = res.product_name
|
||||||
|
if (new_ids.indexOf(res.only) < 0) {
|
||||||
|
this.state.oldProduct.push(res.id)
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
table.find((o) => o.only == res.only).checked == true
|
||||||
|
) {
|
||||||
|
temp.push(obj)
|
||||||
|
}
|
||||||
|
arr.push(obj)
|
||||||
|
return obj
|
||||||
|
})
|
||||||
|
|
||||||
|
this.setState({ rankoptions: arr })
|
||||||
|
this.setState({ rank: temp })
|
||||||
|
|
||||||
|
if (payment_direction) {
|
||||||
|
let index =
|
||||||
|
this.state.payment_direction.indexOf(
|
||||||
|
payment_direction
|
||||||
|
)
|
||||||
|
this.setState({ paytype: index + 1 })
|
||||||
|
}
|
||||||
|
sessionStorage.setItem(
|
||||||
|
"productData",
|
||||||
|
JSON.stringify(codeInfo.range)
|
||||||
|
)
|
||||||
|
sessionStorage.setItem(
|
||||||
|
"knockGoldData",
|
||||||
|
JSON.stringify(codeInfo.range)
|
||||||
|
)
|
||||||
|
},
|
||||||
|
(err) => {}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.catch((err) => {})
|
||||||
|
},
|
||||||
|
(err) => {}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.catch((err) => {})
|
||||||
|
} else {
|
||||||
|
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 /* 兑换码名称 count++ */,
|
||||||
|
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) => {
|
||||||
|
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) => {
|
||||||
|
res.checked = true
|
||||||
|
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) => {
|
||||||
|
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({ rank: arr })
|
||||||
|
},
|
||||||
|
(err) => {}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.catch((err) => {})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 立减金 加款后 商品范围列表数据进行变动
|
// 立减金 加款后 商品范围列表数据进行变动
|
||||||
getTableList() {
|
getTableList() {
|
||||||
if (sessionStorage.getItem("addMoneyData")) {
|
if (sessionStorage.getItem("addMoneyData")) {
|
||||||
|
@ -950,24 +1171,22 @@ export default class exchangeAdd extends React.Component {
|
||||||
alignment={"left"}
|
alignment={"left"}
|
||||||
/>
|
/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
{this.state.isload ? (
|
<FormItem
|
||||||
<FormItem
|
labelname='兑换码名称'
|
||||||
labelname='兑换码名称'
|
prop='code_name'
|
||||||
prop='code_name'
|
id='code_name'>
|
||||||
id='code_name'>
|
<Ipt
|
||||||
<Ipt
|
onChange={(e) => this.handleChange(e, "code_name")}
|
||||||
onChange={(e) => this.handleChange(e, "code_name")}
|
onClearItem={() => this.handleChange("", "code_name")}
|
||||||
onClearItem={() => this.handleChange("", "code_name")}
|
value={this.state.codeInfo.code_name}
|
||||||
value={this.state.codeInfo.code_name}
|
placeholder={"请输入兑换码名称"}
|
||||||
placeholder={"请输入兑换码名称"}
|
labelWidth={"0px"}
|
||||||
labelWidth={"0px"}
|
maxLength={10}
|
||||||
maxLength={10}
|
height={"36px"}
|
||||||
height={"36px"}
|
width={"520px"}
|
||||||
width={"520px"}
|
alignment={"left"}
|
||||||
alignment={"left"}
|
/>
|
||||||
/>
|
</FormItem>
|
||||||
</FormItem>
|
|
||||||
) : null}
|
|
||||||
|
|
||||||
<FormItem labelname='发放总量' prop='issued' id='issued'>
|
<FormItem labelname='发放总量' prop='issued' id='issued'>
|
||||||
<div className='line'>{this.state.codeInfo.issued}</div>
|
<div className='line'>{this.state.codeInfo.issued}</div>
|
||||||
|
@ -1017,6 +1236,7 @@ export default class exchangeAdd extends React.Component {
|
||||||
format: "HH:mm:ss",
|
format: "HH:mm:ss",
|
||||||
defaultTime: ["00:00:00", "23:59:59"]
|
defaultTime: ["00:00:00", "23:59:59"]
|
||||||
}}
|
}}
|
||||||
|
disabled={[this.state.isState === 2, false]}
|
||||||
format='YYYY-MM-DD HH:mm:ss'
|
format='YYYY-MM-DD HH:mm:ss'
|
||||||
value={this.state.codeInfo.date_time}
|
value={this.state.codeInfo.date_time}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
|
|
Loading…
Reference in New Issue