From 00d84202bfecb55d395c77c19599921cfa99271c Mon Sep 17 00:00:00 2001 From: wangsongsole Date: Fri, 29 Jul 2022 16:24:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=85=91=E6=8D=A2=E7=A0=81?= =?UTF-8?q?=E5=A4=8D=E5=88=B6=E6=93=8D=E4=BD=9C=20=20=E7=AD=89=E5=BE=85?= =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/exchangecode/add/add.js | 101 +++++++++++++++++++++++++----- 1 file changed, 86 insertions(+), 15 deletions(-) diff --git a/src/pages/exchangecode/add/add.js b/src/pages/exchangecode/add/add.js index 8107c08d..4213c835 100644 --- a/src/pages/exchangecode/add/add.js +++ b/src/pages/exchangecode/add/add.js @@ -140,8 +140,7 @@ 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) => { @@ -151,31 +150,103 @@ export default class acclist extends React.Component { this.setState({ pagetitle: '复制key' }) getReseller(req.reseller_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({ + 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) + ) + } + }) }) }) 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 + code_batch: req.code_batch, + batch_name: `${req.batch_name}_1` } - this.setState({ checkedList: req.bind_object }) - this.setState({ model: model }) - this.setState({ endtime: req.end_time }) - this.setState({ begintime: req.begin_time }) + let codeInfo = { + //数据模型不可少 + date_time: [req.begin_time, req.end_time] + } + this.setState({ + checkedList: req.bind_object, + model: model, + endtime: req.end_time, + begintime: req.begin_time, + codeInfo: codeInfo + }) let list = _.map(req.code_batch, (item) => { - // item.disabled = true; - // item.checked = true; + 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 return item }) this.setState({ distdata: list }) @@ -183,6 +254,7 @@ export default class acclist extends React.Component { (err) => {} ) }) + /* 新增 */ } else { let plan_item = sessionStorage.getItem('plan_item') if (plan_item) { @@ -199,7 +271,6 @@ 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({