diff --git a/src/pages/exchangecode/exchangecodeAdd/index.jsx b/src/pages/exchangecode/exchangecodeAdd/index.jsx index 5030e262..3f67d0e2 100644 --- a/src/pages/exchangecode/exchangecodeAdd/index.jsx +++ b/src/pages/exchangecode/exchangecodeAdd/index.jsx @@ -285,12 +285,13 @@ export default class exchangeAdd extends React.Component { //获取分销商 this.getResellerFunction(reqCopy.plan.reseller_id) - this.setState({ codeInfo: codeInfo }) - this.setState({ isload: true }) + this.setState({ codeInfo: codeInfo, isload: true }) + _.map(reqCopy.goods, (res) => { res.checked = true return res }) + this.setState({ tempdata: reqCopy.goods || [] }) let a1 = reqCopy.goods.map((item) => { @@ -339,9 +340,9 @@ export default class exchangeAdd extends React.Component { } } + /* 审核中转换数据 */ transFormData1(req, type) { const newData = [] - /* 转换数据结构 */ req.legal.map((item1) => { item1.type = 1 item1.only = item1.product_id @@ -362,6 +363,7 @@ export default class exchangeAdd extends React.Component { obj.id = item1?.goods_id } obj.product_id = item1?.goods_id + obj.code_batch_id = item1?.code_batch_id obj.product_type_text = "立减金" obj.contract_price = item1.price obj.create_time = item1.create_time @@ -392,7 +394,7 @@ export default class exchangeAdd extends React.Component { return newData } - /* 转换数据 */ + /* 无审核转换数据 */ transFormData(reqCopy) { const resData = [] reqCopy.goods.map((item) => { @@ -406,6 +408,8 @@ export default class exchangeAdd extends React.Component { item.entity.weight = item.weight resData.push(item.entity) } else if (item.type === 2) { + /* 复制状态下删除id */ + if (this.state.isState === 1) delete item.entity.id item.entity.weight = item.weight resData.push({ origin: item.entity, @@ -587,16 +591,26 @@ export default class exchangeAdd extends React.Component { end_time: this.state.codeInfo.date_time[1], describe: this.state.codeInfo.describe, quantity: this.state.codeInfo.issued, - range, + range: range.join(), title: this.state.codeInfo.code_name, - product: [ - { - legal: selection.filter((item2) => item2.type == 1), - reduce: selection - .filter((item3) => item3.type === 2) - .map((item4) => item4.origin) - } - ] + restrict: "50", + product: { + 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 + .filter((item3) => item3.type === 2) + .map((item4) => { + delete item4.origin.goods_id + return item4.origin + }) + } } if (this.state.isState === 1) { @@ -604,7 +618,7 @@ export default class exchangeAdd extends React.Component { } let data = { - code_batch: newData, + code_batch: [newData], reseller_id: this.state.reseller.id, reseller_name: this.state.reseller.name, company_name: this.state.reseller.company_name, @@ -646,7 +660,7 @@ export default class exchangeAdd extends React.Component { /* 复制\新增状态下数据提交 */ submitCopyOrAddCodeData() { let data = this.copyOrAddBuildData() - let id = sessionStorage.getItem("keybatch_id") + let id = sessionStorage.getItem("keyBatch_id") keyEditApproval(id, data).then((res) => { handelResponse( @@ -937,13 +951,29 @@ export default class exchangeAdd extends React.Component { onDisabledRange = (date, type) => { let isdisabled = false 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") { - 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 @@ -1036,6 +1066,22 @@ export default class exchangeAdd extends React.Component { 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() { return (
@@ -1057,13 +1103,7 @@ export default class exchangeAdd extends React.Component { this.handleChange(e, "keyBatchSelect")} + onChange={(e) => { + this.handleChange(e, "keyBatchSelect") + /* 新增时保存key批次 */ + sessionStorage.setItem("keyBatch_id", e?.id) + }} clearable value={this.state.codeInfo.keyBatchSelect} options={this.state.keyBatchSelectData} diff --git a/src/pages/exchangecode/exchangecodeAdd/utils.js b/src/pages/exchangecode/exchangecodeAdd/utils.js index 58c0caad..9025d510 100644 --- a/src/pages/exchangecode/exchangecodeAdd/utils.js +++ b/src/pages/exchangecode/exchangecodeAdd/utils.js @@ -161,8 +161,8 @@ export const init = () => { tableLoading: false, newGoldLoading: false, addIsType: "", - isState: 0, - planSelectData: [] /* 营销计划数据 */, - keyBatchSelectData: [] /* 营销计划ID */ + isState: 0 /* 0:新增 1:复制 2:编辑 */, + planSelectData: [] /* 归属计划数据 */, + keyBatchSelectData: [] /* 归属key数据 */ } } diff --git a/src/pages/exchangecode/list/list.js b/src/pages/exchangecode/list/list.js index 2ce60ed9..cabb64f7 100644 --- a/src/pages/exchangecode/list/list.js +++ b/src/pages/exchangecode/list/list.js @@ -172,18 +172,20 @@ export default class acclist extends React.Component { "knockGold_effectDate", JSON.stringify(param.keyBatch.plan) ) - sessionStorage.setItem("keybatch_id", param.key_batch_id) - sessionStorage.setItem("key_reseller_id", param.keyBatch.plan.reseller_id) - sessionStorage.setItem("approval_id", param.keyBatch.approval_id) + /* 复制兑换码的key批次Id */ + sessionStorage.setItem("keyBatch_id", param.key_batch_id) } else if (type === 2) { activerou[0].pagetitle = "编辑" 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("isState", type) sessionStorage.setItem("breaknav", JSON.stringify(activerou)) sessionStorage.setItem("pathname2", "/home/exchangecode-exchangecodeAdd") + this.props.history.push("/home/exchangecode-exchangecodeAdd") }