From 72b4dae442d5c54bc5e46b8e1efe8605b6959d63 Mon Sep 17 00:00:00 2001 From: Wind-58 Date: Thu, 1 Sep 2022 10:42:40 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=9A=82=E5=AD=98=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exchangecode/exchangecodeAdd/index.jsx | 45 ++++++++++++++----- src/pages/exchangecode/list/list.js | 2 + 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/src/pages/exchangecode/exchangecodeAdd/index.jsx b/src/pages/exchangecode/exchangecodeAdd/index.jsx index 5030e262..ed999300 100644 --- a/src/pages/exchangecode/exchangecodeAdd/index.jsx +++ b/src/pages/exchangecode/exchangecodeAdd/index.jsx @@ -937,13 +937,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 +1052,21 @@ 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.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 +1088,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 20ce8636..cabb64f7 100644 --- a/src/pages/exchangecode/list/list.js +++ b/src/pages/exchangecode/list/list.js @@ -172,12 +172,12 @@ 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) } From f052646034e075b3b947676c97216b2b401c7863 Mon Sep 17 00:00:00 2001 From: Wind-58 Date: Thu, 1 Sep 2022 14:16:32 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=85=91=E6=8D=A2?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exchangecode/exchangecodeAdd/index.jsx | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/pages/exchangecode/exchangecodeAdd/index.jsx b/src/pages/exchangecode/exchangecodeAdd/index.jsx index 1780d36e..3f67d0e2 100644 --- a/src/pages/exchangecode/exchangecodeAdd/index.jsx +++ b/src/pages/exchangecode/exchangecodeAdd/index.jsx @@ -400,7 +400,6 @@ export default class exchangeAdd extends React.Component { reqCopy.goods.map((item) => { /* type 1为商品 2为立减金 转译字符方便处理 */ /* 此处only 商品为product_id 立减金为channel_activity_id */ - if (this.state.isState === 1) delete item.entity.id /* 复制时删除id */ if (item.type === 1) { item.entity.upstream = "直连天下" item.entity.only = item.entity.product_id @@ -409,8 +408,9 @@ 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 - item.entity.code_batch_id = item.code_batch_id resData.push({ origin: item.entity, type: item.type, @@ -591,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) { @@ -608,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, @@ -1061,6 +1071,7 @@ export default class exchangeAdd extends React.Component { 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] })