diff --git a/src/pages/plan/add/add.js b/src/pages/plan/add/add.js index 7118287e..c3cbeeb0 100644 --- a/src/pages/plan/add/add.js +++ b/src/pages/plan/add/add.js @@ -64,6 +64,7 @@ export default class add extends React.Component { whiteStyle: false, keyStyle: 1, direct_reseller_id: 0, + keyType: 1, }; } @@ -412,6 +413,8 @@ export default class add extends React.Component { }} getStep3Theme={() => this.getStep3Theme()} keyStyle={this.state.keyStyle} + keyType={this.state.keyType} + setKeyType={(val) => this.setState({ keyType: val })} isload={this.state.isload} curstep={this.state.curstep} direct_reseller_id={this.state.direct_reseller_id} diff --git a/src/pages/plan/add/edit.js b/src/pages/plan/add/edit.js index 59821016..2d5f33b4 100644 --- a/src/pages/plan/add/edit.js +++ b/src/pages/plan/add/edit.js @@ -225,6 +225,9 @@ export default class add extends React.Component { tranFormData(req) { // 需要转译的类型 let type = Number(req.keys[0].bind_object[0]); + this.setState({ + keyType: type, + }); sessionStorage.setItem("keyType", type); if (type === 2) { // 优惠券的转译-弹窗已做了优化 @@ -709,6 +712,10 @@ export default class add extends React.Component { this.onStyleChange(e); }} is_Edit={true} + keyType={this.state.keyType} + setKeyType={(val) => + this.setState({ keyType: val }) + } getStep3Theme={() => this.getStep3Theme()} curstep={this.state.curstep} whiteStyle={this.state.whiteStyle} diff --git a/src/pages/plan/add/plan-copy.js b/src/pages/plan/add/plan-copy.js index 0ddb2ca0..cd4da5c1 100644 --- a/src/pages/plan/add/plan-copy.js +++ b/src/pages/plan/add/plan-copy.js @@ -158,6 +158,9 @@ export default class add extends React.Component { tranFormData(req) { // 需要转译的类型 let type = Number(req.keys[0].bind_object[0]); + this.setState({ + keyType: type, + }); sessionStorage.setItem("keyType", type); if (type === 2) { // 优惠券的转译-弹窗已做了优化 @@ -521,6 +524,8 @@ export default class add extends React.Component { keyStyle={this.state.keyStyle} getStep3Theme={() => this.getStep3Theme()} curstep={this.state.curstep} + keyType={this.state.keyType} + setKeyType={(val) => this.setState({ keyType: val })} isCopy={true} isload={this.state.isload} direct_reseller_id={this.state.direct_reseller_id} diff --git a/src/pages/plan/add/step2.js b/src/pages/plan/add/step2.js index a814dc60..d287c425 100644 --- a/src/pages/plan/add/step2.js +++ b/src/pages/plan/add/step2.js @@ -210,9 +210,6 @@ export default class acclist extends React.Component { width: "auto", }, ], - keyType: sessionStorage.getItem("keyType") - ? Number(sessionStorage.getItem("keyType")) - : 1, }; } @@ -233,7 +230,7 @@ export default class acclist extends React.Component { submit() { let valide = false; // 兑换码 - if (this.state.keyType === 1) { + if (this.props.keyType === 1) { if (this.refs.form1.validator()) { /* 处理数据 区分立减金和商品 开始 2022-05-30 13:40*/ const dataCopy = this.refs.tempdata.getSelectData(); @@ -260,7 +257,7 @@ export default class acclist extends React.Component { data.batch_name = this.state.model.batch_name; data.style = this.state.model.style; data.quantity = this.state.model.quantity; - data.bind_object = [this.state.keyType]; + data.bind_object = [this.props.keyType]; data.allow_repetition = this.state.model.allow_repetition; data.allow_loss = this.state.model.allow_loss; data.merge_stock = this.state.model.merge_stock; @@ -277,7 +274,7 @@ export default class acclist extends React.Component { data.batch_name = this.state.model.batch_name; data.style = this.state.model.style; data.quantity = this.state.model.quantity; - data.bind_object = [this.state.keyType]; + data.bind_object = [this.props.keyType]; data.allow_repetition = this.state.model.allow_repetition; data.allow_loss = this.state.model.allow_loss; data.merge_stock = this.state.model.merge_stock; @@ -296,9 +293,7 @@ export default class acclist extends React.Component { onCheckChange = ({ target }) => { sessionStorage.setItem("keyType", target.value); - this.setState({ - keyType: target.value, - }); + this.props.setKeyType(target.value); // 获取落地页 select if (this.props.getStep3Theme) { this.props.getStep3Theme(); @@ -371,7 +366,7 @@ export default class acclist extends React.Component { this.setState({ codeInfo: codeInfo }); this.setState({ tempdata: [] }); this.setState({ drawerVisible: true }); - if (this.state.keyType === 2) { + if (this.props.keyType === 2) { setTimeout(() => { this.refs.addEditCouponEl.clearCouponForm(); }); @@ -379,7 +374,7 @@ export default class acclist extends React.Component { this.setState({ rowIndex: -1 }); } closeDraw() { - if (this.state.keyType === 2) { + if (this.props.keyType === 2) { setTimeout(() => { this.refs.addEditCouponEl.clearCouponForm(); }); @@ -573,7 +568,7 @@ export default class acclist extends React.Component { codeSubmit() { // 优惠券数据 - if (this.state.keyType === 2) { + if (this.props.keyType === 2) { let coupon_validator = this.refs.addEditCouponEl.submit(); if (coupon_validator) { let param = this.refs.addEditCouponEl.getModel(); @@ -672,7 +667,7 @@ export default class acclist extends React.Component { let text = e.target.value; text = text.replace(/[^\d]/g, ""); - if (this.state.keyType === 1) { + if (this.props.keyType === 1) { this.state.distdata[index].restrict = text; this.setState({ distdata: this.state.distdata }); } else { @@ -897,7 +892,7 @@ export default class acclist extends React.Component { rowItemClick(row, rowIndex) { // 兑换码 - if (this.state.keyType === 1) { + if (this.props.keyType === 1) { let codeInfo = { //数据模型不可少 code_name: row.title, @@ -1370,7 +1365,7 @@ export default class acclist extends React.Component { ) : null} { this.onCheckChange(e); }} @@ -1385,7 +1380,7 @@ export default class acclist extends React.Component { - {this.state.keyType === 1 ? ( + {this.props.keyType === 1 ? ( { this.checkIndex(0); @@ -1410,12 +1405,12 @@ export default class acclist extends React.Component { isShowPageBar={false} spliteColor={"#fff"} tableData={ - this.state.keyType === 1 + this.props.keyType === 1 ? this.state.distdata : this.state.couponData } Column={ - this.state.keyType === 1 + this.props.keyType === 1 ? this.state.Column : this.state.Column_coupon } @@ -1442,7 +1437,7 @@ export default class acclist extends React.Component { ); } // 优惠券范围 - if (com === "product" && this.state.keyType === 2) { + if (com === "product" && this.props.keyType === 2) { return coupon_range(rowData.product); } if (com == "edit") { @@ -1521,7 +1516,7 @@ export default class acclist extends React.Component { }} maskClosable={false} > - {this.state.keyType === 1 ? ( + {this.props.keyType === 1 ? ( - {this.state.keyType === 1 ? ( + {this.props.keyType === 1 ? ( <>