From e784e7df495727fa1d77cdd6e62a2df14257b0c0 Mon Sep 17 00:00:00 2001 From: wangsongsole Date: Tue, 16 Aug 2022 11:26:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20=E5=85=91=E6=8D=A2?= =?UTF-8?q?=E7=A0=81=E5=A4=8D=E5=88=B6=EF=BC=8C=E5=AE=A1=E6=A0=B8=E9=A9=B3?= =?UTF-8?q?=E5=9B=9E=E7=9A=84=E5=85=91=E6=8D=A2=E7=A0=81=E4=B8=8D=E5=BA=94?= =?UTF-8?q?=E8=AF=A5=E8=A2=AB=E5=A4=8D=E5=88=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/exchangecode/copyCode/index.jsx | 367 +++++++--------------- 1 file changed, 106 insertions(+), 261 deletions(-) diff --git a/src/pages/exchangecode/copyCode/index.jsx b/src/pages/exchangecode/copyCode/index.jsx index 31fb324c..f7fef904 100644 --- a/src/pages/exchangecode/copyCode/index.jsx +++ b/src/pages/exchangecode/copyCode/index.jsx @@ -91,7 +91,6 @@ export default class acclist extends React.Component { tempdata: [], distdata: [], pagetitle: '编辑key', - isEdit: false, begintime: '', endtime: '', isCancel: false, @@ -119,7 +118,6 @@ export default class acclist extends React.Component { /* key批次分销商id */ let reseller_id = sessionStorage.getItem('key_reseller_id') /* 审核id */ - let approval_id = sessionStorage.getItem('approval_id') /* 被复制得兑换码id */ let copy_code_id = ~~sessionStorage.getItem('copy_code_id') @@ -145,13 +143,6 @@ export default class acclist extends React.Component { if (req.status == 7) { this.setState({ isCancel: true }) } - - if (req.status == 1) { - this.setState({ isEdit: false }) - } else { - this.setState({ isEdit: true }) - } - req.code_batch = req.code_batch || [] this.setState({ pagetitle: '复制兑换码', @@ -232,68 +223,6 @@ export default class acclist extends React.Component { }) let temp = [...list] - //获取审批单信息 - if (approval_id > 0) { - getApprovalsInfo(approval_id).then((res) => { - handelResponse(res, (req, msg) => { - /*当为创建中和审核驳回时 转换数据结构 */ - const newProduct = [] - req.code_batch.map((item) => { - item.product.legal.map((item1) => { - newProduct.push({ - type: 1, - only: item1.product_id, - upstream: '直连天下', - ...item1 - }) - }) - - item.product.reduce.map((item1) => { - newProduct.push({ - type: 2, - only: item1.channel_activity_id, - upstream: - String(item.channel) === '1' ? '支付宝' : '微信', - origin: item1, - product_name: item1.batch_goods_name, - effectDate: - item1.time_limit?.effect_time.start_time + - ' 至 ' + - item1.time_limit?.effect_time.end_time, //有效时间 - contract_price: item1.price, //单价 - official_price: item1.reduce_amount, //官方价 - quantity: Math.trunc( - item1.all_budget / item1.reduce_amount - ), //总库 - ...item1 - }) - }) - - item.product = [...newProduct] - }) - - for (let i = 0; i < req.code_batch.length; i++) { - let code_batch = req.code_batch[i] - let range = [] - for (let j = 0; j < code_batch.product.length; j++) { - let product = code_batch.product[j] - range.push(product.product_name) - } - req.code_batch[i].disabled = true - req.code_batch[i].checked = true - req.code_batch[i].range = range.toString() - temp.push(req.code_batch[i]) - } - if (req.payment_direction) { - let index = this.state.payment_direction.indexOf( - req.payment_direction - ) - this.setState({ paytype: index + 1 }) - } - }) - }) - } - let model = { style: req.style, batch_name: req.batch_name, @@ -696,202 +625,118 @@ export default class acclist extends React.Component { delete item.products }) - //除了创建中 编辑key - if (this.state.isEdit) { - this.setState({ audit_visible: false }) - let approval_id = sessionStorage.getItem('approval_id') - if (approval_id > 0) { - getApprovalsStatus(approval_id).then((res) => { - handelResponse( - res, - (req, msg) => { - if (req.status == 0) { - this.setState({ recall_visible: true }) - } - if (req.status == 1) { - this.setState({ audit_visible: true }) - } - if (req.status == 2 || req.status == 3) { - let id = sessionStorage.getItem('keybatch_id') - let data = { - code_batch: dataCopy, - reseller_id: this.state.reseller.id, - reseller_name: this.state.reseller.name, - company_name: this.state.reseller.company_name, - receive_email: this.state.reseller.contact_email[0], - payment_direction: - this.state.payment_direction[this.state.paytype - 1] - } - - keyEditApproval(id, data).then((res) => { - handelResponse( - res, - (req, msg) => { - Notify.success('成功发起审批') - setTimeout(() => { - window.history.back() - }, 1000) - }, - (err) => { - Notify.error(err) - } - ) - }) - } - }, - (err) => { - Notify.error(err) + this.setState({ audit_visible: false }) + let approval_id = sessionStorage.getItem('approval_id') + if (approval_id > 0) { + getApprovalsStatus(approval_id).then((res) => { + handelResponse( + res, + (req, msg) => { + if (req.status == 0) { + this.setState({ recall_visible: true }) } - ) - }) - } else { - if (this.state.key_status != 1) { - let id = sessionStorage.getItem('keybatch_id') - let data = { - code_batch: dataCopy, - reseller_id: this.state.reseller?.id, - reseller_name: this.state.reseller?.name, - company_name: this.state.reseller?.company_name, - receive_email: this.state.reseller?.contact_email[0], - payment_direction: - this.state.payment_direction[this.state.paytype - 1] - } - - keyEditApproval(id, data).then((res) => { - handelResponse( - res, - (req, msg) => { - Notify.success('成功发起审批') - setTimeout(() => { - window.history.back() - }, 1000) - }, - (err) => { - Notify.error(err) + if (req.status == 1) { + this.setState({ audit_visible: true }) + } + if (req.status == 2 || req.status == 3) { + let id = sessionStorage.getItem('keybatch_id') + let data = { + code_batch: dataCopy, + reseller_id: this.state.reseller.id, + reseller_name: this.state.reseller.name, + company_name: this.state.reseller.company_name, + receive_email: this.state.reseller.contact_email[0], + payment_direction: + this.state.payment_direction[this.state.paytype - 1] } - ) - }) - } else { - let data = { - batch_name: this.state.model.batch_name, - style: this.state.model.style, - quantity: this.state.model.quantity, - bind_object: this.state.checkedList, - allow_repetition: this.state.model.allow_repetition, - allow_loss: this.state.model.allow_loss, - merge_stock: this.state.model.merge_stock, - mobile_excel: this.state.mobile_excel, - mobile_repeat: this.state.mobile_repeat, - code_batch: dataCopy, - reseller_id: this.state.reseller.id, - reseller_name: this.state.reseller.name, - company_name: this.state.reseller.company_name, - receive_email: this.state.reseller.contact_email[0], - payment_direction: - this.state.payment_direction[this.state.paytype - 1] - } - let id = sessionStorage.getItem('keybatch_id') - putKeyBatchDetail(id, data).then((res) => { - handelResponse( - res, - (req, msg) => { - keyApproval(this.state.plan_id, id, data).then((res) => { - handelResponse( - res, - (req, msg) => { - Notify.success('成功发起审批') - setTimeout(() => { - this.props.history.push('/home/key-list/') - }, 2000) - }, - (err) => { - Notify.error(err) - } - ) - }) - }, - (err) => { - Notify.error(err) - } - ) - }) - } - } + keyEditApproval(id, data).then((res) => { + handelResponse( + res, + (req, msg) => { + Notify.success('成功发起审批') + setTimeout(() => { + window.history.back() + }, 1000) + }, + (err) => { + Notify.error(err) + } + ) + }) + } + }, + (err) => { + Notify.error(err) + } + ) + }) } else { - //创建中 编辑key - let data = { - batch_name: this.state.model.batch_name, - style: this.state.model.style, - quantity: this.state.model.quantity, - bind_object: this.state.checkedList, - allow_repetition: this.state.model.allow_repetition, - allow_loss: this.state.model.allow_loss, - merge_stock: this.state.model.merge_stock, - mobile_excel: this.state.mobile_excel, - mobile_repeat: this.state.mobile_repeat, - code_batch: dataCopy, - reseller_id: this.state.reseller.id, - reseller_name: this.state.reseller.name, - company_name: this.state.reseller.company_name, - receive_email: this.state.reseller.contact_email[0], - payment_direction: this.state.payment_direction[this.state.paytype - 1] - } + if (this.state.key_status != 1) { + let id = sessionStorage.getItem('keybatch_id') + let data = { + code_batch: dataCopy, + reseller_id: this.state.reseller?.id, + reseller_name: this.state.reseller?.name, + company_name: this.state.reseller?.company_name, + receive_email: this.state.reseller?.contact_email[0], + payment_direction: + this.state.payment_direction[this.state.paytype - 1] + } - let id = sessionStorage.getItem('keybatch_id') - let approval_id = sessionStorage.getItem('approval_id') - if (approval_id > 0) { - getApprovalsStatus(approval_id).then((res) => { - handelResponse( - res, - (req, msg) => { - if (req.status == 0) { - this.setState({ recall_visible: true }) - } - if (req.status == 1) { - this.setState({ audit_visible: true }) - } - if (req.status == 2 || req.status == 3) { - putKeyBatchDetail(id, data).then((res) => { - handelResponse( - res, - (req, msg) => { - keyApproval(this.state.plan_id, id, data).then((res) => { - handelResponse( - res, - (req, msg) => { - Notify.success('成功发起审批') - setTimeout(() => { - this.props.history.push('/home/key-list/') - }, 2000) - }, - (err) => { - Notify.error(err) - } - ) - }) - }, - (err) => { - Notify.error(err) - } - ) - }) - } - }, - (err) => { - Notify.error(err) - } - ) - }) - } else { - keyApproval(this.state.plan_id, id, data).then((res) => { + keyEditApproval(id, data).then((res) => { handelResponse( res, (req, msg) => { Notify.success('成功发起审批') setTimeout(() => { - this.props.history.push('/home/key-list/') - }, 2000) + window.history.back() + }, 1000) + }, + (err) => { + Notify.error(err) + } + ) + }) + } else { + let data = { + batch_name: this.state.model.batch_name, + style: this.state.model.style, + quantity: this.state.model.quantity, + bind_object: this.state.checkedList, + allow_repetition: this.state.model.allow_repetition, + allow_loss: this.state.model.allow_loss, + merge_stock: this.state.model.merge_stock, + mobile_excel: this.state.mobile_excel, + mobile_repeat: this.state.mobile_repeat, + code_batch: dataCopy, + reseller_id: this.state.reseller.id, + reseller_name: this.state.reseller.name, + company_name: this.state.reseller.company_name, + receive_email: this.state.reseller.contact_email[0], + payment_direction: + this.state.payment_direction[this.state.paytype - 1] + } + + let id = sessionStorage.getItem('keybatch_id') + putKeyBatchDetail(id, data).then((res) => { + handelResponse( + res, + (req, msg) => { + keyApproval(this.state.plan_id, id, data).then((res) => { + handelResponse( + res, + (req, msg) => { + Notify.success('成功发起审批') + setTimeout(() => { + this.props.history.push('/home/key-list/') + }, 2000) + }, + (err) => { + Notify.error(err) + } + ) + }) }, (err) => { Notify.error(err) @@ -1039,7 +884,7 @@ export default class acclist extends React.Component { this.onStyleChange(e) }} value={this.state.model.style} - disabled={this.state.isEdit}> + disabled={true}> 串码 链接 二维码 @@ -1059,7 +904,7 @@ export default class acclist extends React.Component { this.setState({ checkedList: arr })} - disabled={this.state.isEdit}> + disabled={true}> 兑换码 优惠券 @@ -1124,7 +969,7 @@ export default class acclist extends React.Component { id='allow_repetition' prop='allow_repetition'> this.onRepetitionChange(e)} value={this.state.model.allow_repetition}> @@ -1137,7 +982,7 @@ export default class acclist extends React.Component { id='allow_loss' prop='allow_loss'> this.onLossChange(e)} value={this.state.model.allow_loss}>