This commit is contained in:
zhangds 2022-09-01 15:03:56 +08:00
commit 86d1c00b25
3 changed files with 78 additions and 32 deletions

View File

@ -285,12 +285,13 @@ export default class exchangeAdd extends React.Component {
// //
this.getResellerFunction(reqCopy.plan.reseller_id) this.getResellerFunction(reqCopy.plan.reseller_id)
this.setState({ codeInfo: codeInfo }) this.setState({ codeInfo: codeInfo, isload: true })
this.setState({ isload: true })
_.map(reqCopy.goods, (res) => { _.map(reqCopy.goods, (res) => {
res.checked = true res.checked = true
return res return res
}) })
this.setState({ tempdata: reqCopy.goods || [] }) this.setState({ tempdata: reqCopy.goods || [] })
let a1 = reqCopy.goods.map((item) => { let a1 = reqCopy.goods.map((item) => {
@ -339,9 +340,9 @@ export default class exchangeAdd extends React.Component {
} }
} }
/* 审核中转换数据 */
transFormData1(req, type) { transFormData1(req, type) {
const newData = [] const newData = []
/* 转换数据结构 */
req.legal.map((item1) => { req.legal.map((item1) => {
item1.type = 1 item1.type = 1
item1.only = item1.product_id item1.only = item1.product_id
@ -362,6 +363,7 @@ export default class exchangeAdd extends React.Component {
obj.id = item1?.goods_id obj.id = item1?.goods_id
} }
obj.product_id = item1?.goods_id obj.product_id = item1?.goods_id
obj.code_batch_id = item1?.code_batch_id
obj.product_type_text = "立减金" obj.product_type_text = "立减金"
obj.contract_price = item1.price obj.contract_price = item1.price
obj.create_time = item1.create_time obj.create_time = item1.create_time
@ -392,7 +394,7 @@ export default class exchangeAdd extends React.Component {
return newData return newData
} }
/* 转换数据 */ /* 无审核转换数据 */
transFormData(reqCopy) { transFormData(reqCopy) {
const resData = [] const resData = []
reqCopy.goods.map((item) => { reqCopy.goods.map((item) => {
@ -406,6 +408,8 @@ export default class exchangeAdd extends React.Component {
item.entity.weight = item.weight item.entity.weight = item.weight
resData.push(item.entity) resData.push(item.entity)
} else if (item.type === 2) { } else if (item.type === 2) {
/* 复制状态下删除id */
if (this.state.isState === 1) delete item.entity.id
item.entity.weight = item.weight item.entity.weight = item.weight
resData.push({ resData.push({
origin: item.entity, origin: item.entity,
@ -587,16 +591,26 @@ export default class exchangeAdd extends React.Component {
end_time: this.state.codeInfo.date_time[1], end_time: this.state.codeInfo.date_time[1],
describe: this.state.codeInfo.describe, describe: this.state.codeInfo.describe,
quantity: this.state.codeInfo.issued, quantity: this.state.codeInfo.issued,
range, range: range.join(),
title: this.state.codeInfo.code_name, title: this.state.codeInfo.code_name,
product: [ restrict: "50",
{ product: {
legal: selection.filter((item2) => item2.type == 1), legal: selection.filter((item2) => {
if (item2.type == 1) {
delete item2.goods_id
delete item2.id
delete item2.only
delete item2.type
return item2
}
}),
reduce: selection reduce: selection
.filter((item3) => item3.type === 2) .filter((item3) => item3.type === 2)
.map((item4) => item4.origin) .map((item4) => {
delete item4.origin.goods_id
return item4.origin
})
} }
]
} }
if (this.state.isState === 1) { if (this.state.isState === 1) {
@ -604,7 +618,7 @@ export default class exchangeAdd extends React.Component {
} }
let data = { let data = {
code_batch: newData, code_batch: [newData],
reseller_id: this.state.reseller.id, reseller_id: this.state.reseller.id,
reseller_name: this.state.reseller.name, reseller_name: this.state.reseller.name,
company_name: this.state.reseller.company_name, company_name: this.state.reseller.company_name,
@ -646,7 +660,7 @@ export default class exchangeAdd extends React.Component {
/* 复制\新增状态下数据提交 */ /* 复制\新增状态下数据提交 */
submitCopyOrAddCodeData() { submitCopyOrAddCodeData() {
let data = this.copyOrAddBuildData() let data = this.copyOrAddBuildData()
let id = sessionStorage.getItem("keybatch_id") let id = sessionStorage.getItem("keyBatch_id")
keyEditApproval(id, data).then((res) => { keyEditApproval(id, data).then((res) => {
handelResponse( handelResponse(
@ -937,13 +951,29 @@ export default class exchangeAdd extends React.Component {
onDisabledRange = (date, type) => { onDisabledRange = (date, type) => {
let isdisabled = false let isdisabled = false
let str = moment(date).format("YYYY-MM-DD HH:mm:ss") let str = moment(date).format("YYYY-MM-DD HH:mm:ss")
const isDay = moment(this.state.plan_time[1]).format("HH:mm:ss")
if (type === "start") { /* 新增和复制时才生效 */
isdisabled = moment(str).isBefore(this.state.plan_time[0]) if (type === "start" && this.state.isState !== 2) {
if (isDay < "23:59:59") {
isdisabled =
moment(str).isBefore(this.state.plan_time[0]) ||
moment(str).subtract(1, "days").isAfter(this.state.plan_time[1])
} else {
isdisabled =
moment(str).isBefore(this.state.plan_time[0]) ||
moment(str).isAfter(this.state.plan_time[1])
}
} }
if (type === "end") { if (type === "end") {
isdisabled = moment(str).isAfter(this.state.plan_time[1]) if (this.state.isState !== 2) {
isdisabled =
moment(str).add(1, "days").isBefore(this.state.plan_time[0]) ||
moment(str).isAfter(this.state.plan_time[1])
} else {
isdisabled = moment(str).isAfter(this.state.plan_time)
}
} }
return isdisabled return isdisabled
@ -1036,6 +1066,22 @@ export default class exchangeAdd extends React.Component {
this.setState({ codeInfo: model }) this.setState({ codeInfo: model })
} }
/* 新增处理处理归属计划关联数据 */
vestingPlanFunction(e) {
if (!e?.key) return
this.getKeyBatchSelect(e.key)
this.getResellerFunction(e.reseller_id)
this.handleChange("", "keyBatchSelect")
this.setState({
plan_time: [e.start_time, e.end_time]
})
const time = {
start_time: e.start_time,
end_time: e.end_time
}
sessionStorage.setItem("knockGold_effectDate", JSON.stringify(time))
}
render() { render() {
return ( return (
<div id='editcode'> <div id='editcode'>
@ -1057,13 +1103,7 @@ export default class exchangeAdd extends React.Component {
<Select <Select
onChange={(e) => { onChange={(e) => {
this.handleChange(e, "planSelect") this.handleChange(e, "planSelect")
if (e?.key) { this.vestingPlanFunction(e)
this.getKeyBatchSelect(e.key)
this.getResellerFunction(e.reseller_id)
this.setState({
plan_time: [e.start_time, e.end_time]
})
}
}} }}
clearable clearable
value={this.state.codeInfo.planSelect} value={this.state.codeInfo.planSelect}
@ -1083,7 +1123,11 @@ export default class exchangeAdd extends React.Component {
prop='keyBatchSelect' prop='keyBatchSelect'
id='keyBatchSelect'> id='keyBatchSelect'>
<Select <Select
onChange={(e) => this.handleChange(e, "keyBatchSelect")} onChange={(e) => {
this.handleChange(e, "keyBatchSelect")
/* 新增时保存key批次 */
sessionStorage.setItem("keyBatch_id", e?.id)
}}
clearable clearable
value={this.state.codeInfo.keyBatchSelect} value={this.state.codeInfo.keyBatchSelect}
options={this.state.keyBatchSelectData} options={this.state.keyBatchSelectData}

View File

@ -161,8 +161,8 @@ export const init = () => {
tableLoading: false, tableLoading: false,
newGoldLoading: false, newGoldLoading: false,
addIsType: "", addIsType: "",
isState: 0, isState: 0 /* 0:新增 1:复制 2:编辑 */,
planSelectData: [] /* 营销计划数据 */, planSelectData: [] /* 归属计划数据 */,
keyBatchSelectData: [] /* 营销计划ID */ keyBatchSelectData: [] /* 归属key数据 */
} }
} }

View File

@ -172,18 +172,20 @@ export default class acclist extends React.Component {
"knockGold_effectDate", "knockGold_effectDate",
JSON.stringify(param.keyBatch.plan) JSON.stringify(param.keyBatch.plan)
) )
sessionStorage.setItem("keybatch_id", param.key_batch_id) /* 复制兑换码的key批次Id */
sessionStorage.setItem("key_reseller_id", param.keyBatch.plan.reseller_id) sessionStorage.setItem("keyBatch_id", param.key_batch_id)
sessionStorage.setItem("approval_id", param.keyBatch.approval_id)
} else if (type === 2) { } else if (type === 2) {
activerou[0].pagetitle = "编辑" activerou[0].pagetitle = "编辑"
activerou[0].items[1].name = `编辑:${param.title}兑换码的商品范围列表` activerou[0].items[1].name = `编辑:${param.title}兑换码的商品范围列表`
sessionStorage.setItem("approval_id", param.keyBatch.approval_id)
sessionStorage.setItem("approval_status", param.status)
} }
sessionStorage.setItem("code_id", param?.id) sessionStorage.setItem("code_id", param?.id)
sessionStorage.setItem("isState", type) sessionStorage.setItem("isState", type)
sessionStorage.setItem("breaknav", JSON.stringify(activerou)) sessionStorage.setItem("breaknav", JSON.stringify(activerou))
sessionStorage.setItem("pathname2", "/home/exchangecode-exchangecodeAdd") sessionStorage.setItem("pathname2", "/home/exchangecode-exchangecodeAdd")
this.props.history.push("/home/exchangecode-exchangecodeAdd") this.props.history.push("/home/exchangecode-exchangecodeAdd")
} }