diff --git a/src/pages/exchangecode/add/add.js b/src/pages/exchangecode/add/add.js index badedf4e..8107c08d 100644 --- a/src/pages/exchangecode/add/add.js +++ b/src/pages/exchangecode/add/add.js @@ -140,7 +140,8 @@ export default class acclist extends React.Component { this.setState({ model: model }) this.setState({ white_visible: true }) } - //复制 + + //编辑 if (batch_id > 0 || copyOpearo == 2) { // this.setState({isEdit:true}) getKeyBatchDetail(batch_id).then((res) => { @@ -150,110 +151,31 @@ export default class acclist extends React.Component { this.setState({ pagetitle: '复制key' }) getReseller(req.reseller_id).then((res) => { handelResponse(res, (req, msg) => { - this.setState({ - phone_list: req.contact_phone, - direct_reseller_id: req.direct_reseller_id, - email_list: req.contact_email, - reseller: req - }) - getProductInfoSelect({ - reseller_id: req.direct_reseller_id - }).then((res) => { - if (res.code === 200) { - sessionStorage.setItem( - 'productsList', - JSON.stringify(res.data.data) - ) - } - }) + this.setState({ reseller: req }) + + this.setState({ phone_list: req.contact_phone }) + this.setState({ email_list: req.contact_email }) }) }) + let model = { title: req.plan_title, + batch_name: '', style: req.style, quantity: req.quantity, allow_repetition: req.allow_repetition, allow_loss: req.allow_loss, merge_stock: req.merge_stock, - code_batch: req.code_batch, - batch_name: `${req.batch_name}_${++req.copy_count}`, - copy_code_batch_id: req.id + code_batch: req.code_batch } - let codeInfo = { - //数据模型不可少 - date_time: [req.begin_time, req.end_time] - } - sessionStorage.setItem( - 'plan_item', - JSON.stringify({ - begin_time: req.begin_time, - end_time: req.end_time - }) - ) - this.setState({ - checkedList: req.bind_object, - model: model, - endtime: req.end_time, - begintime: req.begin_time, - codeInfo: codeInfo - }) + this.setState({ checkedList: req.bind_object }) + this.setState({ model: model }) + this.setState({ endtime: req.end_time }) + this.setState({ begintime: req.begin_time }) let list = _.map(req.code_batch, (item) => { - item.product = item.product.map((item1) => { - let obj = {} - if (item1.type === 1) { - obj = item1.entity - obj.upstream = '直连天下' - obj.only = item1.entity.product_id - obj.id = item1.entity.product_id - obj.weight = item1.weight - obj.type = item1.type - } else if (item1.type === 2) { - obj.type = item1.type - obj.product_id = item1.entity.goods_id - obj.product_type_text = '立减金' - obj.only = item1.entity.channel_activity_id - obj.id = item1.entity.goods_id - obj.upstream = - String(item1.entity.channel) === '1' ? '支付宝' : '微信' - obj.code_batch_id = item1.code_batch_id - obj.contract_price = item1.entity.price - obj.create_time = item1.create_time - obj.official_price = item1.entity.reduce_amount - obj.channel_activity_id = item1.entity.channel_activity_id - obj.product_name = item1.entity.batch_goods_name - obj.quantity = item1.entity.stock - item1.entity.weight = item1.weight - obj.stock = Math.trunc( - item1.entity.all_budget / item1.entity.reduce_amount - - item1.entity.used_amount / item1.entity.reduce_amount - ) - obj.usage = Math.trunc( - item1.entity.all_budget / item1.entity.reduce_amount - - (item1.entity.all_budget - item1.entity.used_amount) / - item1.entity.reduce_amount - ) - obj.effectDate = - item1.entity.time_limit.effect_time.start_time + - ' 至 ' + - item1.entity.time_limit.effect_time.end_time - //有效时间 - delete item1.entity.id - obj.origin = item1.entity - } - - return obj - }) - let pr = {} - pr.range = item.range - pr.restrict = item.restrict - pr.title = item.title - pr.begin_time = item.begin_time - pr.end_time = item.end_time - pr.quantity = item.quantity - pr.describe = item.describe - pr.product = item.product - item = pr + // item.disabled = true; + // item.checked = true; return item }) this.setState({ distdata: list }) @@ -261,7 +183,6 @@ export default class acclist extends React.Component { (err) => {} ) }) - /* 新增 */ } else { let plan_item = sessionStorage.getItem('plan_item') if (plan_item) { @@ -278,6 +199,7 @@ export default class acclist extends React.Component { getReseller(id).then((res) => { handelResponse(res, (req, msg) => { this.setState({ reseller: req }) + this.setState({ phone_list: req.contact_phone }) this.setState({ email_list: req.contact_email }) this.setState({ @@ -737,7 +659,6 @@ export default class acclist extends React.Component { let data = {} data.batch_name = this.state.model.batch_name - data.copy_code_batch_id = this.state.model?.copy_code_batch_id data.style = this.state.model.style data.quantity = this.state.model.quantity data.bind_object = this.state.checkedList