diff --git a/src/pages/exchangecode/add/add.js b/src/pages/exchangecode/add/add.js index 2c623d16..24fa59ab 100644 --- a/src/pages/exchangecode/add/add.js +++ b/src/pages/exchangecode/add/add.js @@ -43,6 +43,7 @@ import { getReseller, getAccessVerification, keyApproval, + getProductInfoSelect, } from "../../../assets/api.js"; import Productform from "../product/add"; import Bus from "../../../assets/eventBus.js"; @@ -129,6 +130,8 @@ export default class acclist extends React.Component { excel_count: 0, success_count: 0, error_count: 0, + direct_reseller_id: 0, + newGoodsBtnLoading: false, }; } @@ -206,6 +209,9 @@ export default class acclist extends React.Component { this.setState({ phone_list: req.contact_phone }); this.setState({ email_list: req.contact_email }); + this.setState({ + direct_reseller_id: req.direct_reseller_id, + }); }); }); @@ -347,8 +353,36 @@ export default class acclist extends React.Component { this.setState({ drawerVisible: false }); } addProduct() { - this.setState({ drawerVisible2: true }); - this.setState({ productData: null }); + let direct_reseller_ids = this.state.direct_reseller_id; + if (direct_reseller_ids <= 0) { + // 老数据不能进行新增商品操作 + Notify.error(`请编辑映射分销商`); + return; + } + + this.setState({ + newGoodsBtnLoading: true, + }); + + let param = { + reseller_id: direct_reseller_ids, + }; + try { + getProductInfoSelect(param).then((res) => { + if (res.code === 200) { + sessionStorage.setItem("productsList", JSON.stringify(res.data.data)); + this.setState({ productData: null }); + this.setState({ drawerVisible2: true }); + } + this.setState({ + newGoodsBtnLoading: false, + }); + }); + } catch (err) { + this.setState({ + newGoodsBtnLoading: false, + }); + } } async productSubmit() { let visible = await this.refs.product.submit(); @@ -1400,25 +1434,28 @@ export default class acclist extends React.Component { /> - { + this.onRankChange(e); + }} + /> + + 0) { getReseller(reseller_id).then((res) => { @@ -140,6 +139,9 @@ export default class acclist extends React.Component { this.setState({ reseller: req }); this.setState({ phone_list: req.contact_phone }); this.setState({ email_list: req.contact_email }); + this.setState({ + direct_reseller_id: req.direct_reseller_id, + }); }); }); @@ -327,8 +329,38 @@ export default class acclist extends React.Component { this.setState({ drawerVisible: false }); } addProduct() { - this.setState({ drawerVisible2: true }); - this.setState({ productData: null }); + let direct_reseller_ids = this.state.direct_reseller_id; + if (direct_reseller_ids <= 0) { + // 老数据不能进行新增商品操作 + Notify.error(`请编辑映射分销商`); + return; + } + + this.setState({ + newGoodsBtnLoading: true, + }); + let param = { + reseller_id: direct_reseller_ids, + }; + try { + getProductInfoSelect(param).then((res) => { + if (res.code === 200) { + sessionStorage.setItem( + "productData", + JSON.stringify(this.state.tempdata) + ); + this.setState({ productData: null }); + this.setState({ drawerVisible2: true }); + } + this.setState({ + newGoodsBtnLoading: false, + }); + }); + } catch (err) { + this.setState({ + newGoodsBtnLoading: false, + }); + } } async productSubmit() { let visible = await this.refs.product.submit(); @@ -1378,25 +1410,28 @@ export default class acclist extends React.Component { /> - { + this.onRankChange(e); + }} + /> + +