From 6cf56f78f252b4d186c5b0d582ae2bbfb9ff37c9 Mon Sep 17 00:00:00 2001 From: wangsongsole Date: Wed, 3 Jan 2024 16:49:23 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=AA=20optimize:=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/plan/add/step2.js | 129 +++++++++++++++++------------------- src/pages/plan/add/step3.js | 5 +- 2 files changed, 60 insertions(+), 74 deletions(-) diff --git a/src/pages/plan/add/step2.js b/src/pages/plan/add/step2.js index f8f75407..6b341c2f 100644 --- a/src/pages/plan/add/step2.js +++ b/src/pages/plan/add/step2.js @@ -230,11 +230,13 @@ export default class acclist extends React.Component { let input = items[1].getElementsByTagName("input")[0] input.focus() if (this.props.name > 0) { - this.setState({ whiteStyle: this.props.whiteStyle }) - this.setState({ white_visible: this.props.whiteStyle }) let model = this.state.model model.style = this.props.keyStyle - this.setState({ model: model }) + this.setState({ + whiteStyle: this.props.whiteStyle, + white_visible: this.props.whiteStyle, + model: model + }) } } @@ -350,8 +352,7 @@ export default class acclist extends React.Component { this.refs.addEditCouponEl.clearCouponForm() }, 300) } - this.setState({ rowIndex: -1 }) - this.setState({ drawerVisible: true }) + this.setState({ drawerVisible: true, rowIndex: -1 }) } closeDraw() { @@ -413,8 +414,7 @@ export default class acclist extends React.Component { newGoldLoading: false }) } - this.setState({ productData: null }) - this.setState({ drawerVisible2: true }) + this.setState({ drawerVisible2: true, productData: null }) }) } @@ -514,11 +514,9 @@ export default class acclist extends React.Component { } setkeyStyle(style) { if (style == 6) { - this.setState({ whiteStyle: true }) - this.setState({ white_visible: true }) + this.setState({ white_visible: true, whiteStyle: true }) } else { - this.setState({ whiteStyle: false }) - this.setState({ white_visible: false }) + this.setState({ white_visible: false, whiteStyle: false }) } let model = this.state.model @@ -542,8 +540,7 @@ export default class acclist extends React.Component { return checks.key == item.only }) > -1 }) - this.setState({ tempdata: this.state.tempdata }) - this.setState({ rank: e }) + this.setState({ tempdata: this.state.tempdata, rank: e }) } codeSubmit() { @@ -666,8 +663,6 @@ export default class acclist extends React.Component { code_batch: data.code_batch, draw_title: data.draw_title } - this.setState({ mobile_excel: data.mobile_excel }) - this.setState({ mobile_repeat: data.mobile_repeat }) if (model.style == 6) { sessionStorage.setItem("white", 1) this.setState({ white_visible: true }) @@ -675,16 +670,18 @@ export default class acclist extends React.Component { sessionStorage.setItem("white", 3) } - this.setState({ model: model }) - this.setState({ checkedList: data.bind_object.map(Number)[0] }) - let temp = map(data.code_batch, (o) => { o.checked = true return o }) - - this.setState({ distdata: temp }) - this.setState({ isload: true }) + this.setState({ + mobile_repeat: data.mobile_repeat, + mobile_excel: data.mobile_excel, + model: model, + checkedList: data.bind_object.map(Number)[0], + distdata: temp, + isload: true + }) } coupon_edit(data) { @@ -699,23 +696,24 @@ export default class acclist extends React.Component { draw_title: data.draw_title, coupon: data.coupon } - this.setState({ mobile_excel: data.mobile_excel }) - this.setState({ mobile_repeat: data.mobile_repeat }) + if (model.style == 6) { sessionStorage.setItem("white", 1) this.setState({ white_visible: true }) } else { sessionStorage.setItem("white", 3) } - this.setState({ model: model }) - let temp = map(data.coupon, (o) => { o.checked = true return o }) - - this.setState({ couponData: temp }) - this.setState({ isload: true }) + this.setState({ + mobile_repeat: data.mobile_repeat, + mobile_excel: data.mobile_excel, + model: model, + couponData: temp, + isload: true + }) } onUpload = (file, report) => { @@ -790,9 +788,7 @@ export default class acclist extends React.Component { obj.text = res.product_name return obj }) - this.setState({ rankoptions: arr }) - this.setState({ rank: arr }) - this.setState({ tempdata: this.state.tempdata }) + this.setState({ rank: arr, rankoptions: arr, tempdata: this.state.tempdata }) } onQuantityChange(e, row, rowIndex) { this.state.tempdata[rowIndex].quantity = e.target.value == "" ? 0 : e.target.value @@ -831,13 +827,15 @@ export default class acclist extends React.Component { } initUpload() { - this.setState({ import_visible: false }) - this.setState({ success_visible: false }) - this.setState({ fail_visible: false }) - this.setState({ file_loading: false }) - this.setState({ upload_visible: false }) - this.setState({ excel_visible: false }) - this.setState({ accessVerify: false }) + this.setState({ + accessVerify: false, + excel_visible: false, + upload_visible: false, + file_loading: false, + fail_visible: false, + success_visible: false, + import_visible: false + }) } importConfirmClick() { @@ -846,17 +844,17 @@ export default class acclist extends React.Component { let mobile_repeat = map(temp, (o) => { return o.mobile }) - this.setState({ mobile_repeat: mobile_repeat }) let model = this.state.model model.quantity = this.state.excel_count - this.state.error_count + mobile_repeat.length - - this.setState({ model: model }) - this.setState({ accessVerify: false }) - this.setState({ excel_visible: false }) - this.setState({ import_visible: false }) - - this.setState({ import_success: true }) + this.setState({ + import_success: true, + model: model, + accessVerify: false, + excel_visible: false, + import_visible: false, + mobile_repeat: mobile_repeat + }) } importClick() { @@ -864,9 +862,7 @@ export default class acclist extends React.Component { Notify.error("文件正在解析中请稍等") } else { if (this.state.success_visible) { - this.setState({ accessVerify: false }) - this.setState({ excel_visible: true }) - this.setState({ import_visible: false }) + this.setState({ excel_visible: true, accessVerify: false, import_visible: false }) } else { Notify.error("请上传正确的文件") } @@ -876,8 +872,7 @@ export default class acclist extends React.Component { // this.initUpload(); let my_file = e.target.files[0] - this.setState({ myfile: my_file }) - this.setState({ upload_visible: true }) + this.setState({ upload_visible: true, myfile: my_file }) if ( my_file.name.indexOf(".xls") || @@ -906,13 +901,15 @@ export default class acclist extends React.Component { handelResponse( res, (req, msg) => { - this.setState({ accessVerify: true }) - this.setState({ excel_count: req.count }) - this.setState({ error_count: req.errorCount }) let success = req.count - req.errorCount - this.setState({ success_count: success }) - this.setState({ exceldata: req.validationFailed }) - this.setState({ success_visible: true }) + this.setState({ + excel_count: req.count, + accessVerify: true, + error_count: req.errorCount, + success_count: success, + exceldata: req.validationFailed, + success_visible: true + }) }, (err) => { Notify.error(err) @@ -933,9 +930,7 @@ export default class acclist extends React.Component { } resetUpload() { - this.setState({ excel_visible: false }) - this.setState({ import_visible: true }) - this.setState({ accessVerify: true }) + this.setState({ import_visible: true, excel_visible: false, accessVerify: true }) } switchChange(e, rowData) { @@ -969,10 +964,7 @@ export default class acclist extends React.Component { addIsType: "addKnockGold" }) setTimeout(() => { - this.setState({ - tableLoading: false - }) - this.setState({ drawerVisible2: true }) + this.setState({ drawerVisible2: true, tableLoading: false }) }, 300) } else if (rowData.type === 3) { let obj = rowData.origin @@ -987,9 +979,9 @@ export default class acclist extends React.Component { }) setTimeout(() => { this.setState({ - tableLoading: false + tableLoading: false, + drawerVisible2: true }) - this.setState({ drawerVisible2: true }) }, 300) } else { this.getProductInfoSelectData(this.props.direct_reseller_id).then((data) => { @@ -1004,10 +996,7 @@ export default class acclist extends React.Component { addIsType: "addProduct" }) setTimeout(() => { - this.setState({ - tableLoading: false - }) - this.setState({ drawerVisible2: true }) + this.setState({ drawerVisible2: true, tableLoading: false }) }, 300) }) } diff --git a/src/pages/plan/add/step3.js b/src/pages/plan/add/step3.js index e4534fa1..76c94440 100644 --- a/src/pages/plan/add/step3.js +++ b/src/pages/plan/add/step3.js @@ -72,13 +72,10 @@ export default class accList extends React.Component { model.theme_id = "" this.setState({ model: model }) if (this.props.data && this.props.data.theme_id) { - this.setState({ theme_id: this.props.data.theme_id }) - let selctobj = this.state.options.find((o) => o.key == this.props.data.theme_id) - let model = this.state.model model.theme_id = selctobj - this.setState({ model: model }) + this.setState({ model: model, theme_id: this.props.data.theme_id }) } }, (err) => {}