From 4f58d9322c8d73bd08b6f2aa43c0d92bd94bfd15 Mon Sep 17 00:00:00 2001 From: wangsongsole Date: Tue, 9 Aug 2022 11:10:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=20=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/exchangecode/add copy/add.js | 2068 ---------------------- src/pages/exchangecode/add copy/add.less | 268 --- src/pages/exchangecode/add/add.js | 19 +- 3 files changed, 8 insertions(+), 2347 deletions(-) delete mode 100644 src/pages/exchangecode/add copy/add.js delete mode 100644 src/pages/exchangecode/add copy/add.less diff --git a/src/pages/exchangecode/add copy/add.js b/src/pages/exchangecode/add copy/add.js deleted file mode 100644 index badedf4e..00000000 --- a/src/pages/exchangecode/add copy/add.js +++ /dev/null @@ -1,2068 +0,0 @@ -import { deWeightThree } from '../../../utils' -import React from 'react' -import { - Card, - Sweetalert, - DateRangePicker, - Drawer, - Button, - Radio, - Tabs, - Notify, - Select, - Input, - Checkbox, - Switch, - Icon, - RadioGroup, - RadioButton -} from 'zent' -import Ipt from '../../../components/input/main' -import Form from '../../../components/form/main' -import FormItem from '../../../components/form-item/main' -import Grid from '../../../components/gird/main.js' -import { - addPlanStep, - handelResponse, - addKeysBatchInfo, - getKeyBatchDetail, - putKeyBatchDetail, - uploadImg, - getReseller, - getAccessVerification, - keyApproval, - getProductInfoSelect -} from '../../../assets/api.js' -import Productform from '../product/add' -import KnockGold from '@/components/knockGold' /* 立减金 */ - -import Bus from '../../../assets/eventBus.js' -import _ from 'lodash' -import './add.less' -import moment from 'moment' -import { isSameDay } from 'date-fns' -const TabPanel = Tabs.TabPanel - -const initArray = (targetNum) => { - return Array.from({ length: targetNum }, (_, index) => index) -} - -export default class acclist extends React.Component { - constructor(props) { - super(props) - this.state = { - keys: [ - { - style: 1, - quantity: '', - allow_repetition: 0, - allow_loss: 0, - merge_stock: 1, - code_batch: '', - draw_title: '' - } - ], - model: { - //数据模型不可少 - style: 1, - quantity: '', - plan_id: '', - title: '', - allow_repetition: 0, - allow_loss: 0, - merge_stock: 1, - code_batch: '', - draw_title: '', - batch_name: '' - }, - drawerVisible: false, - drawerVisible2: false, - checkedList: [1], - productData: [], - codeInfo: { - //数据模型不可少 - code_name: '', - issued: '', //发放总量 - describe: '', - date_time: '', - range: '' - }, - rank: null, - rankoptions: [], - tempdata: [], - distdata: [], - pagetitle: '新建key', - isEdit: false, - begintime: '', - endtime: '', - rowIndex: -1, - uploading: false, - audit_visible: false, - phone_list: [], - email_list: [], - email_radio: -1, - phone_radio: -1, - paytype: 3, - reseller: null, - payment_direction: ['对私账户', '对公账户', '预付款扣除'], - - import_visible: false, - white_visible: false, - success_visible: false, - fail_visible: false, - file_loading: false, - upload_visible: false, - excel_visible: false, - accessVerify: false, - mobile_excel: '', - mobile_repeat: [], - execel_path: '', - excel_count: 0, - success_count: 0, - error_count: 0, - direct_reseller_id: 0, - newGoodsBtnLoading: false, - newGoldLoading: false, - product_title: '新建商品', - addIsType: '' - } - } - - componentDidMount(e) { - let batch_id = sessionStorage.getItem('keybatch_id') - let copyOpearo = sessionStorage.getItem('copyOpearo') - //key样式 - let keystyle = sessionStorage.getItem('keyStyle') - - if (keystyle == 1) { - let model = this.state.model - model.style = 6 - this.setState({ model: model }) - this.setState({ white_visible: true }) - } - //复制 - if (batch_id > 0 || copyOpearo == 2) { - // this.setState({isEdit:true}) - getKeyBatchDetail(batch_id).then((res) => { - handelResponse( - res, - (req, msg) => { - 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) - ) - } - }) - }) - }) - let model = { - title: req.plan_title, - 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 - } - 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 - }) - - 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 - return item - }) - this.setState({ distdata: list }) - }, - (err) => {} - ) - }) - /* 新增 */ - } else { - let plan_item = sessionStorage.getItem('plan_item') - if (plan_item) { - plan_item = JSON.parse(plan_item) - let model = this.state.model - model.title = plan_item.title - - this.setState({ model: model }) - this.setState({ endtime: plan_item.end_time }) - this.setState({ begintime: plan_item.begin_time }) - - let id = plan_item.reseller_id - - 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({ - direct_reseller_id: req.direct_reseller_id - }) - }) - }) - - let codeInfo = { - //数据模型不可少 - code_name: '', - issued: '', //发放总量 - describe: '', - date_time: [plan_item.begin_time, plan_item.end_time], - range: '' - } - - this.setState({ codeInfo: codeInfo }) - } - } - } - - onPayTypeChange(e) { - this.setState({ paytype: e.target.value }) - } - - async submit() { - let valide = false - if (this.refs.form1.validator()) { - let data = {} - data.batch_name = this.state.model.batch_name - data.style = this.state.model.style - data.quantity = this.state.model.quantity - data.bind_object = this.state.model.bind_object - data.allow_repetition = this.state.model.allow_repetition - data.allow_loss = this.state.model.allow_loss - data.merge_stock = this.state.model.merge_stock - data.code_batch = this.state.distdata - let formdata = {} - formdata.step = 'key' - formdata.data = data - await addPlanStep('', formdata).then((res) => { - handelResponse( - res, - (req, msg) => { - sessionStorage.setItem('plan_id', req.id) - valide = true - return - }, - (err) => { - Notify.error(err) - } - ) - }) - } - return valide - } - - importClick() { - if (this.state.file_loading) { - Notify.error('文件正在解析中请稍等') - } else { - if (this.state.success_visible) { - this.setState({ accessVerify: false }) - this.setState({ excel_visible: true }) - this.setState({ import_visible: false }) - } else { - Notify.error('请上传正确的文件') - } - } - } - Cancel() { - Sweetalert.confirm({ - type: 'warning', - closeBtn: true, - title: '确认操作', - content:

是否取消本次操作?

, - onConfirm: () => { - window.history.back() - }, - onCancel: this.onCancel, - className: 'questModal', - parentComponent: this - }) - } - onCheckChange = (arr) => { - this.setState({ checkedList: arr }) - let checkedList = arr - } - - onStyleChange(e) { - let model2 = this.state.model - model2.style = e.target.value - model2.quantity = 0 - this.setState({ model: model2 }) - if (e.target.value == 6) { - this.setState({ white_visible: true }) - } else { - this.setState({ white_visible: false }) - } - } - - onRepetitionChange(e) { - let model2 = this.state.model - model2.allow_repetition = e.target.value - this.setState({ model: model2 }) - } - - onLossChange(e) { - let model2 = this.state.model - model2.allow_loss = e.target.value - this.setState({ model: model2 }) - } - checkIndex(e) { - switch (e) { - case 0: - this.setState({ draw_title: '新建兑换码' }) - break - case 1: - this.setState({ draw_title: '新建优惠券' }) - break - case 2: - this.setState({ draw_title: '新建立减金' }) - break - default: - return - } - this.setState({ drawerVisible: false }) - this.state.codeInfo = { - //数据模型不可少 - code_name: '', - issued: '', //发放总量 - describe: '', - date_time: [this.state.begintime, this.state.endtime], - range: '' - } - this.setState({ tempdata: [] }) - this.setState({ rank: null }) - this.setState({ rankoptions: [] }) - this.setState({ drawerVisible: true }) - sessionStorage.setItem('productData', '') - sessionStorage.setItem('knockGoldData', '') - } - closeDraw() { - this.setState({ drawerVisible: false }) - } - addProduct(type) { - this.setState({ addIsType: type }) /* 类型 */ - let direct_reseller_ids = this.state.direct_reseller_id - if (direct_reseller_ids <= 0) { - // 老数据不能进行新增商品操作 - Notify.error(`请添加映射分销商`) - return - } - - if (type === 'addProduct') { - this.setState({ product_title: '新建商品', newGoodsBtnLoading: true }) - } else { - this.setState({ product_title: '新增立减金', newGoldLoading: 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 }) - } - if (type === 'addProduct') { - this.setState({ - newGoodsBtnLoading: false - }) - } else { - this.setState({ - newGoldLoading: false - }) - } - }) - } catch (err) { - if (type === 'addProduct') { - this.setState({ - newGoodsBtnLoading: false - }) - } else { - this.setState({ - newGoldLoading: false - }) - } - } - } - //渲染范围列表数据以及数据转换 - async productSubmit() { - let visible = '' - if (this.state.addIsType === 'addProduct') { - visible = await this.refs.product.submit() - } else { - visible = await this.refs.knockGold.submit() - } - - if (visible) { - Notify.success('保存成功') - this.setState({ drawerVisible2: false }) - setTimeout(() => { - let data = null - let temp = null - let concatData = [] - /* 处理商品 */ - if (this.state.addIsType === 'addProduct') { - data = JSON.parse(sessionStorage.getItem('productData')).filter( - (item) => item.type !== 2 - ) - - concatData = this.state.tempdata.filter((item) => item.type !== 1) - - temp = _.map(data, (item) => { - let index = this.state.tempdata.findIndex((o) => { - return o.product_id == item.product_id - }) - - if (index > -1) { - item.checked = this.state.tempdata[index].checked - } - item.type = 1 - item.only = item.product_id - item.upstream = '直连天下' - return item - }) - } else { - /* 处理立减金 */ - data = JSON.parse(sessionStorage.getItem('knockGoldData')).filter( - (item) => item.type !== 1 - ) - - concatData = this.state.tempdata.filter((item) => item.type !== 2) - - temp = _.map(data, (item) => { - let index = this.state.tempdata.findIndex((o) => { - return o.channel_activity_id === item.channel_activity_id - }) - - if (index > -1) { - item.checked = this.state.tempdata[index].checked - } - - /* 转换商品结构 */ - // temp - const newObj = {} - newObj.product_name = item.batch_goods_name - ? item.batch_goods_name - : item.product_name //名字 - newObj.map_product_name = item.product_name - newObj.channel_activity_id = item.channel_activity_id //批次号 - newObj.only = item.channel_activity_id //批次号 - newObj.type = 2 //类型 - newObj.checked = item?.checked - newObj.upstream = String(item.channel) === '1' ? '支付宝' : '微信' //上游 - newObj.edit = 'edit' - newObj.effectDate = item.effectDate - ? item.effectDate - : item.time_limit?.effect_time.start_time + - ' 至 ' + - item.time_limit?.effect_time.end_time //有效时间 - newObj.contract_price = item.contract_price - ? item.contract_price - : item.price //单价 - newObj.official_price = item.official_price - ? item.official_price - : item.reduce_amount //官方价 - newObj.quantity = item.quantity - ? item.quantity - : Math.trunc(item.all_budget / item.reduce_amount) //总库 - newObj.origin = item?.origin ? item?.origin : item - return newObj - }) - } - let newArray = deWeightThree(temp.concat(concatData), 'only') - - //select数据 - let arr = [] - let rank = [] - _.map(newArray, (res) => { - arr.push({ key: res.only, text: res.product_name }) - if (res.checked) { - rank.push({ key: res.only, text: res.product_name }) - } - }) - - arr = deWeightThree(arr, 'key') - this.setState({ tempdata: newArray, rankoptions: arr, rank }) - }, 500) - } - } - onChangeCombinedDate(e) { - let model2 = this.state.codeInfo - model2.date_time = e - this.setState({ codeInfo: model2 }) - } - submit2() { - this.refs.form2.validator() - } - //select - onRankChange(e) { - _.forEach(this.state.tempdata, (item) => { - item.checked = - e.findIndex((checks) => { - return checks.key == item.only - }) > -1 - }) - this.setState({ tempdata: this.state.tempdata }) - this.setState({ rank: e }) - } - codeSubmit() { - if (this.refs.code_info.validator() && this.refs.code_rule.validator()) { - if (this.state.uploading) { - Notify.error('还有图片上传中,不可提交') - return - } - - let productlist = _.filter(this.state.tempdata, (item) => { - return item.checked == true - }) - let sum = 0 - _.forEach(productlist, (o) => { - sum += parseInt(o.quantity) - }) - if (sum < this.state.codeInfo.issued) { - Notify.error('所选商品库存总数小于发放量') - return - } - // let productList = JSON.parse(sessionStorage.getItem("productsList")); - - this.setState({ drawerVisible: false }) - let rank = _.map(this.state.rank, (item) => { - return item.text - }) - - let temp = { - title: this.state.codeInfo.code_name, - describe: this.state.codeInfo.describe, - begin_time: this.state.codeInfo.date_time[0], - end_time: this.state.codeInfo.date_time[1], - quantity: this.state.codeInfo.issued, - range: rank.toString(), - restrict: this.state.codeInfo.restrict - } - - let arr = _.map(productlist, (item) => { - let obj = {} - obj.product_id = item.product_id - obj.product_type = item.product_type - obj.product_name = item.product_name - obj.account_type = item.account_type - obj.contract_price = item.contract_price - obj.cost_price = item.cost_price - obj.official_price = item.official_price - obj.quantity = item.quantity - obj.show_url = item.show_url - obj.describe_url = item.describe_url - obj.detail_url = item.detail_url - obj.map_product_name = item.map_product_name - if (item.type === 2) { - obj.channel_activity_id = item.channel_activity_id //批次号 - obj.effectDate = item.effectDate //有效时间 - obj.origin = item.origin // 原始数据 - } - obj.only = item.only - obj.weight = item.weight - obj.type = item.type - obj.upstream = item.upstream - return obj - }) - temp.product = arr - - if (this.state.rowIndex > -1) { - this.state.distdata[this.state.rowIndex] = temp - this.setState({ distdata: this.state.distdata }) - } else { - let tempdata = this.state.distdata - tempdata.push(temp) - this.setState({ distdata: tempdata }) - } - } - } - onAddKey() { - let obj = { - style: '1', - quantity: '', - allow_repetition: 0, - allow_loss: 0, - merge_stock: '1', - code_batch: '', - draw_title: '', - batch_name: '' - } - let keys = this.state.keys - keys.push(obj) - - this.setState({ keys: keys }) - } - onAudit() { - if (!this.state.reseller) { - Notify.error('对应分销商数据不存在') - return - } - - if (this.state.isEdit) { - let selection = this.refs.bindObj.getSelectData() - let formdata = selection.filter((item) => { - return !item.hasOwnProperty('disabled') - }) - - let id = sessionStorage.getItem('keybatch_id') - let data = { - code_batch: formdata - } - putKeyBatchDetail(id, data).then((res) => { - handelResponse( - res, - (req, msg) => { - setTimeout(() => { - window.history.back() - }, 1000) - }, - (err) => { - Notify.error(err) - } - ) - }) - } else { - if (this.refs.form1.validator()) { - /* 处理数据 区分立减金和商品 开始 2022-05-30 13:40*/ - const dataCopy = this.refs.bindObj.getSelectData() - - dataCopy.map((item) => { - item.products = item.product - }) - - dataCopy.map((item) => - item.products.map(() => { - item.product = { - legal: item.products.filter((item2) => item2.type === 1), - reduce: item.products - .map((item2) => { - if (item2.type === 2) return item2.origin - }) - .filter((item3) => item3) - } - }) - ) - - dataCopy.map((item) => { - delete item.products - }) - /* 处理数据 区分立减金和商品 完成 2022-05-30 13:40*/ - - 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 - data.allow_repetition = this.state.model.allow_repetition - data.allow_loss = this.state.model.allow_loss - data.merge_stock = this.state.model.merge_stock - data.code_batch = dataCopy - - data.reseller_id = this.state.reseller.id - data.reseller_name = this.state.reseller.name - data.company_name = this.state.reseller.company_name - data.receive_email = this.state.reseller.contact_email[0] - data.payment_direction = - this.state.payment_direction[this.state.paytype - 1] - - data.mobile_excel = this.state.mobile_excel - data.mobile_repeat = this.state.mobile_repeat - - if (data.code_batch.length == 0) { - Notify.error('请绑定对象') - return - } - this.setState({ audit_visible: false }) - - let id = sessionStorage.getItem('key_plan_id') - addKeysBatchInfo(id, data).then((res) => { - handelResponse( - res, - (req, msg) => { - keyApproval(id, req.key_batch_id, data).then((res) => { - handelResponse( - res, - (req, msg) => { - Notify.success('成功发起审批') - setTimeout(() => { - // this.props.history.push('/home/key-list/') - window.history.back() - }, 2000) - }, - (err) => { - Notify.error(err) - } - ) - }) - }, - (err) => { - Notify.error(err) - } - ) - }) - } - } - } - - onBindNum(e, row, rowIndex) { - this.state.distdata[rowIndex].restrict = e.target.value - this.setState({ distdata: this.state.distdata }) - } - - onDisabledRange = (date, type) => { - let step1 = JSON.parse(sessionStorage.getItem('plan_item')) - let isdisabled = false - let str = moment(date).format('YYYY-MM-DD HH:mm:ss') - if (type == 'start') { - isdisabled = - moment(str).isBefore(step1.begin_time) || - moment(str).isAfter(step1.end_time) - } - - if (type == 'end') { - isdisabled = - moment(str).add(1, 'days').isBefore(step1.begin_time) || - moment(str).isAfter(step1.end_time) - } - return isdisabled - } - - rowItemClick(row, rowIndex) { - let codeInfo = { - //数据模型不可少 - code_name: row.title, - issued: row.quantity, //发放总量 - describe: row.describe, - date_time: [row.begin_time, row.end_time], - range: row.range, - restrict: row.restrict - } - - let arr = _.map(row.product, (res) => { - let obj = {} - obj.key = res.only - obj.text = res.product_name - return obj - }) - this.setState({ - draw_title: '编辑兑换码', - rankoptions: arr, - rank: arr, - codeInfo: codeInfo, - rowIndex: rowIndex - }) - - let temp = _.map(row.product, (o) => { - o.checked = true - return o - }) - - sessionStorage.setItem('productData', JSON.stringify(row.product)) - sessionStorage.setItem('knockGoldData', JSON.stringify(row.product)) - this.setState({ drawerVisible: true, tempdata: temp }) - } - - onUpload = (file, report) => { - return new Promise((resolve, reject) => { - let path = '' - let formdata = new FormData() - formdata.append('file', file) - formdata.append('path', 'common_image') - uploadImg(formdata).then((res) => { - handelResponse( - res, - (req, msg) => { - path = req.path - }, - (err) => { - reject() - } - ) - }) - - let count = 0 - const update = () => { - if (path) { - resolve(path) - } else { - if (count < 100) { - count += 2 - report(count) - setTimeout(update, 500) - } else { - reject() - } - } - } - setTimeout(update, 500) - }) - } - - onUploadError = (type, data) => { - if (type === 'overMaxAmount') { - Notify.error(`最多可上传 ${data.maxAmount} 张图片`) - } else if (type === 'overMaxSize') { - Notify.error(`图片大小不能超过 ${data.formattedMaxSize}`) - } - } - - onUploadChange1(file, row) { - if (file.length > 0 && file[0].status == 'success') { - let rowIndex = this.state.tempdata.findIndex((o) => { - return o.product_id == row.product_id - }) - this.state.tempdata[rowIndex].describe_url = file[0].src - this.setState({ tempdata: this.state.tempdata }) - } - } - onUploadChange2(file, row) { - if (file.length > 0 && file[0].status == 'success') { - let rowIndex = this.state.tempdata.findIndex((o) => { - return o.product_id == row.product_id - }) - - this.state.tempdata[rowIndex].describe_url = file[0].src - this.setState({ tempdata: this.state.tempdata }) - } - } - - onNameChange(e, row, rowIndex) { - this.state.tempdata[rowIndex].product_name = e.target.value - this.setState({ tempdata: this.state.tempdata }) - } - onQuantityChange(e, row, rowIndex) { - this.state.tempdata[rowIndex].quantity = - e.target.value == '' ? 0 : e.target.value - this.setState({ tempdata: this.state.tempdata }) - } - onPriceChange(e, row, rowIndex) { - let str = e.target.value - let value = str - .replace(/[^\d^\.]+/g, '') - .replace('.', '$#$') - .replace(/\./g, '') - .replace('$#$', '.') - - this.state.tempdata[rowIndex].contract_price = value - this.setState({ tempdata: this.state.tempdata }) - } - onDisabledTime = (date, type) => { - const min = new Date() - const hour = min.getHours() - const minute = min.getMinutes() - const second = min.getSeconds() - const isSame = isSameDay(date, min) - - return isSame - ? { - disabledHours: () => initArray(hour), - disabledMinutes: (hourValue) => - hourValue === hour ? initArray(minute) : [], - disabledSeconds: (hourValue, minuteValue) => - hourValue === hour && minuteValue === minute - ? initArray(second) - : [] - } - : {} - } - - onReturn() { - let self = this - Sweetalert.confirm({ - type: 'warning', - closeBtn: true, - title: '确认操作', - content:

是否返回key列表?

, - onConfirm: () => { - self.props.history.push('/home/key-list/') - }, - onCancel: this.onCancel, - className: 'questModal', - parentComponent: this - }) - } - onPhoneChange(e) { - this.setState({ phone_radio: e.target.value }) - } - onEmailChange(e) { - this.setState({ email_radio: e.target.value }) - } - cancel(e) { - this.setState({ audit_visible: false }) - } - phoneChange = (e) => { - this.setState({ phone: e.target.value }) - } - emailChange = (e) => { - this.setState({ email: e.target.value }) - } - 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 }) - } - - fileChange(e) { - // this.initUpload(); - - let my_file = e.target.files[0] - this.setState({ myfile: my_file }) - this.setState({ upload_visible: true }) - - if ( - my_file.name.indexOf('.xls') || - my_file.name.indexOf('.xlsx') || - my_file.name.indexOf('.csv') - ) { - if (my_file.size > 1024000) { - Notify.error('文件大小不能大于2M') - return - } - let formdata = new FormData() - formdata.append('file', my_file) - formdata.append('path', 'white_list_excel') - this.setState({ file_loading: true }) - uploadImg(formdata).then((res) => { - handelResponse( - res, - (req, msg) => { - let data = { - excel: req.path - } - - this.setState({ mobile_excel: req.path }) - getAccessVerification(data).then((res) => { - this.setState({ file_loading: false }) - 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 }) - }, - (err) => { - Notify.error(err) - this.setState({ success_visible: false }) - } - ) - }) - }, - (err) => { - Notify.error(err) - this.setState({ success_visible: false }) - } - ) - }) - } else { - this.setState({ success_visible: false }) - } - } - - resetUpload() { - this.setState({ excel_visible: false }) - this.setState({ import_visible: true }) - this.setState({ accessVerify: true }) - } - allowImport(data) { - let arr = this.state.mobile_repeat - if (arr.indexOf(data.mobile) < 0) { - arr.push(data.mobile) - } - data.type = 'success' - this.setState({ mobile_repeat: arr }) - } - importConfirmClick() { - let temp = this.state.exceldata.filter((o) => o.type == 'success') - 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 }) - } - resetUpload() { - this.setState({ excel_visible: false }) - this.setState({ import_visible: true }) - this.setState({ accessVerify: true }) - } - switchChange(e, rowData) { - if (e) { - rowData.type = 'success' - } else { - rowData.type = rowData.type == 'success' ? 'repeat' : 'error' - } - } - downLoadTemplate() { - window.location.href = - 'https://lsxdemall.oss-cn-beijing.aliyuncs.com/MarketingSystem/%E7%99%BD%E5%90%8D%E5%8D%95%E6%A8%A1%E6%9D%BF.xlsx' - } - submitAudit() { - if (this.refs.form1.validator()) { - this.setState({ audit_visible: true }) - } - } - keyProductClick(row, index) { - console.log('keyProductClick 13==>', row) - if (this.state.direct_reseller_id > 0) { - /* 区分立减金 */ - if (row.type === 2) { - this.setState({ - product_title: '编辑立减金', - productData: row.origin, - addIsType: 'addKnockGold', - drawerVisible2: true - }) - } else { - this.setState({ - product_title: '编辑商品', - productData: row, - addIsType: 'addProduct', - drawerVisible2: true - }) - } - } else { - // 老数据不能进行新增商品操作 - Notify.error(`请添加映射分销商`) - return - } - } - render() { - const Column = [ - { - title: '兑换名称', - name: 'title', - prop: 'title', - type: 'normal', - width: 'auto' - }, - { - title: '兑换码范围', - - type: 'normal', - prop: 'range', - width: 'auto' - }, - { - title: '有效开始日期', - prop: 'begin_time', - name: 'begin_time', - width: 'auto', - type: 'normal' - }, - { - title: '有效结束日期', - name: 'end_time', - prop: 'end_time', - type: 'normal', - width: 'auto' - }, - { - title: '兑换码数量', - name: 'quantity', - type: 'normal', - prop: 'quantity', - defaultText: 'PM', - width: 'auto' - }, - { - title: '绑定数', - prop: 'restrict', - name: 'restrict', - type: 'slot', - width: 'auto' - }, - { - title: '操作', - prop: 'edit', - name: 'edit', - type: 'slot', - width: 'auto' - } - ] - //校验规则 - const rules = { - quantity: [ - { type: 'required', message: '请输入key数量' }, - { - type: 'regExp', - message: '请输入正整数', - reg: '^([1-9][0-9]*){1,3}$' - } - ], - bind_object: [{ type: 'required', message: '请选择绑定类型' }], - - batch_name: [{ type: 'required', message: '请输入key批次名称' }] - } - - const Column2 = [ - { - title: '商品ID', - name: 'product_id', - prop: 'product_id', - width: 'auto', - type: 'normal' - }, - { - title: '立减金平台批次号', - width: '250px', - prop: 'channel_activity_id', - name: 'channel_activity_id', - type: 'normal' - }, - { - title: '类型', - width: 'auto', - prop: 'type', - name: 'type', - type: 'slot' - }, - { - title: '上游平台', - width: 'auto', - prop: 'upstream', - name: 'upstream', - type: 'normal' - }, - { - title: '有效时间段', - width: '575px', - prop: 'effectDate', - name: 'effectDate', - type: 'normal' - }, - { - title: '商品名称', - width: 'auto', - prop: 'product_name', - name: 'product_name', - type: 'normal' - }, - { - title: '当前成本价格', - prop: 'cost_price', - name: 'cost_price', - width: '250px', - type: 'slot' - }, - { - title: '合同价', - name: 'contract_price', - prop: 'contract_price', - type: 'normal', - width: 'auto' - }, - { - title: '商品官方价', - type: 'normal', - prop: 'official_price', - width: 'auto' - }, - { - title: '库存数量', - prop: 'quantity', - name: 'quantity', - type: 'normal', - width: 'auto' - }, - { - title: '操作', - prop: 'edit', - name: 'edit', - type: 'slot', - width: 'auto' - } - ] - - //基本信息 - const codeInfo = { - code_name: [{ type: 'required', message: '请输入兑换码名称' }], - issued: [ - { type: 'required', message: '请输入发放总量' }, - { - type: 'regExp', - message: '请输入正整数', - reg: '^([1-9][0-9]*){1,3}$' - } - ] - } - - //基本规则 - const rulesInfo = { - date_time: [{ type: 'required', message: '请选择生效时间段' }], - rank: [{ type: 'required', message: '请选择商品范围' }] - } - - const excelColumn = [ - { - title: '行号', - name: 'line', - prop: 'line', - width: '30px', - type: 'normal' - }, - { - title: '手机号', - width: '80px', - prop: 'mobile', - name: 'mobile', - type: 'normal' - }, - { - title: '错误原因', - width: '80px', - prop: 'tips', - name: 'tips', - type: 'normal' - }, - { - title: '是否导入', - width: '50px', - prop: 'is_import', - name: 'is_import', - type: 'slot' - } - ] - return ( -
- -
- -
{this.state.model.title}
-
- - { - let model2 = this.state.model - model2.batch_name = e - this.setState({ model: model2 }) - }} - onClearItem={(e) => { - let model2 = this.state.model - model2.batch_name = '' - this.setState({ model: model2 }) - }} - value={this.state.model.batch_name} - placeholder={'请输入'} - labelWidth={'0px'} - maxLength={12} - height={'36px'} - width={'400px'} - alignment={'left'} - /> - - - { - this.onStyleChange(e) - }} - value={this.state.model.style} - disabled={this.state.isEdit}> - - 串码 - - - 链接 - - - 二维码 - - - 白名单 - - - - - -
- {this.state.isEdit ? ( -
{this.state.model.quantity}
- ) : ( - { - let model2 = this.state.model - model2.quantity = e - this.setState({ model: model2 }) - }} - value={this.state.model.quantity} - disabled={this.state.model.style == 6} - placeholder={'请输入'} - labelWidth={'0px'} - maxLength={5} - height={'36px'} - width={'400px'} - alignment={'left'} - /> - )} - - {this.state.white_visible ? ( - - ) : null} -
-
- - - { - this.onCheckChange(e) - }} - disabled={this.state.isEdit}> - 兑换码 - - 优惠券 - - {/* 立减金 */} - - - {this.state.checkedList.length > 0 ? ( - - {this.state.checkedList.indexOf(1) > -1 ? ( - - ) : null} - - ) : null} - - { - this.pageChange(e) - }} - checkChange={(selection) => {}} - ComponentHandler={(com, rowData, rowIndex) => { - if (com == 'restrict') { - return ( - { - this.onBindNum(e, rowData, rowIndex) - }} - disabled={rowData.disabled} - /> - ) - } - if (com == 'edit') { - return ( - { - this.rowItemClick(rowData, rowIndex) - }} - style={{ color: '#2B66F2' }}> - 编辑 - - ) - } - }} - /> - - - this.onRepetitionChange(e)} - value={this.state.model.allow_repetition}> - - - - - - - this.onLossChange(e)} - value={this.state.model.allow_loss}> - - - - -
-
- -
- - -
- - - - -
- } - visible={this.state.drawerVisible} - onClose={(e) => { - this.closeDraw() - }} - maskClosable={false}> -
- -
-
- - { - let model = this.state.codeInfo - model.code_name = e - this.setState({ codeInfo: model }) - }} - onClearItem={(e) => { - let model = this.state.codeInfo - model.code_name = '' - this.setState({ codeInfo: model }) - }} - value={this.state.codeInfo.code_name} - placeholder={'请输入兑换码名称'} - labelWidth={'0px'} - maxLength={10} - height={'36px'} - width={'520px'} - alignment={'left'} - /> - - - { - let model = this.state.codeInfo - model.issued = e - this.setState({ codeInfo: model }) - }} - onClearItem={(e) => { - let model = this.state.codeInfo - model.issued = '' - this.setState({ codeInfo: model }) - }} - unit='条' - countShow={false} - value={this.state.codeInfo.issued} - placeholder={'请输入发放总量'} - labelWidth={'0px'} - maxLength={12} - height={'36px'} - width={'520px'} - alignment={'left'} - /> - - - { - let model = this.state.codeInfo - model.describe = e.target.value - console.log(model.describe) - this.setState({ codeInfo: model }) - }} - /> - -
-
-
- -
-
- - { - Bus.emit('change', 'date_time', e) - this.onChangeCombinedDate(e) - }} - disabledTime={this.onDisabledTime} - disabledDate={this.onDisabledRange} - /> - - -
- this.fileChange(e)} - /> - - 更新文件 -
- )} -
- {this.state.success_visible ? ( -
- - 文件解析成功,点击确定导入 即可导入 -
- ) : null} - {this.state.fail_visible ? ( -
- - 文件解析失败,请查看导入规则并更新文件 -
- ) : null} -
- ) : ( -
- this.fileChange(e)} - /> - {' '} -
- )} - -
-
下载模板并填写后上传
- -
-
- 请先下载「数字世界营销管理系统_白名单_模板」并按照模板填写后再上传。 -
-
-
- -
-
- - -
-
- - - ) : null} - - {this.state.audit_visible ? ( -
-
-
- { - this.setState({ audit_visible: false }) - }} - /> -
提交审核
-
- { - this.onPayTypeChange(e) - }} - value={this.state.paytype} - className='audit-obj'> - 预付款扣除 - 对私账户 - 对公账户 - -
-
- - -
-
-
- ) : null} - - {this.state.excel_visible ? ( -
-
-
-
-
从Excel导入白名单
- { - this.setState({ excel_visible: false }) - }} - /> -
-
- 文件上传成功.共{this.state.excel_count}条手机号,其中 - {this.state.success_count}条可成功导入 -
-
- 发现以下{this.state.error_count}条不符合要求,将不会被导入 -
- -
- -
- { - this.pageChange(e) - }} - ComponentHandler={(com, rowData, rowIndex) => { - if (com == 'is_import') { - if ( - rowData.type == 'success' || - rowData.type == 'repeat' - ) { - let checked = rowData.type == 'success' - return ( - { - this.switchChange(e, rowData) - }} - /> - ) - } else { - return
-
- } - } - }} - /> -
-
-
- - -
-
-
-
- ) : null} - - ) - } -} diff --git a/src/pages/exchangecode/add copy/add.less b/src/pages/exchangecode/add copy/add.less deleted file mode 100644 index abc1c59f..00000000 --- a/src/pages/exchangecode/add copy/add.less +++ /dev/null @@ -1,268 +0,0 @@ - - .addkey-btn-group{ - margin-left: 10px; - margin-top: 15px; - button{ - width: 100px; - height: 36px; - } - } - .btn-add{ - width: 50%; - margin: 0 auto; - height: 36px; - margin-top: 20px; - text-align: center; - line-height: 36px; - background-color: rgb(249, 250, 252); - } - #addkey .zent-radio-button--disabled[data-zv="9.11.0"].zent-radio-button--checked{ - color: #8a96aa; - background: #dfe8fc!important; - border: 1px solid #8a96aa!important; - } - - - .import-excel - { - width: 451px; - height:600px; - background-color: #FFFFFF; - border-radius: 5px; - - position: fixed; - top: 50%; - margin-top: -280px; - left: 50%; - margin-left: -215px; - z-index: 100; - .import-header{ - width: 100%; - height: 48px; - display: flex; - align-items: center; - .import-title{ - width: 70%; - font-size: 18px; - font-weight: bold; - margin-left: 20px; - } - - .closebtn{ - width: 30%; - - } - - .import-close{ - margin-left: 70px; - font-size: 20px; - font-weight: bold; - } - } - .step-bar{ - width: 80%; - height: 60px; - margin: 10px auto; - display: flex; - justify-content: center; - } - .step-code{ - width: 24px; - height: 24px; - border-radius: 50%; - border: 1px solid #e8e8e8; - display: flex; - align-items: center; - justify-content: center; - color: #e8e8e8; - - } - .step-code.active - { - background-color: #1890ff; - } - - .step-group{ - width: 150px; - height: 50px; - display: flex; - align-items: center; - } - .step-center{ - width: 60px; - height: 50px; - display: flex; - align-items: center; - margin-right: 40px; - } - .step-line{ - width: 50px; - height: 1px; - background-color:#e8e8e8; - - } - .step-line.active{ - background-color: #1890ff; - } - - .step-label{ - color: #8d8d8d; - font-size: 14px; - margin-left: 10px; - font-weight: bold; - } - .step-label.active{ - color: #000000; - } - - - .upload-panel1{ - width: 80%; - margin: 10px auto; - margin-bottom: 20px; - .upload-label{ - font-size: 15px; - font-weight: bold; - margin-bottom: 20px; - } - .upload-info{ - color:#626366; - } - } - - .btn-upload{ - margin-top: 10px; - margin-left: 40px; - margin-bottom: 20px; - background-color:#1890ff; - } - .btn-download{ - margin-top: 10px; - margin-left: 40px; - } - .foot-bar - { - width: 100%; - height: 50px; - position: absolute; - bottom: 20px; - .btn-group{ - width: 240px; - margin-left: 160px; - } - button{ - width: 100px; - } - - } - - .upload-msgbar{ - width: 82%; - background-color: #f5f5f5; - margin: 0 auto; - min-height: 40px; - border-radius: 5px; - - display: flex; - .execel-name{ - width: 75%; - display: flex; - min-height: 40px; - - align-items: center; - .excel-txt{ - font-size: 12px; - margin-left: 10px; - } - .doc-flag{ - font-size: 20px; - margin-left: 5px; - } - - - } - - .file-tag{ - width: 25%; - font-size: 12px; - display: flex; - align-items: center; - color: #1890ff; - - .upload-flag{ - font-size: 20px; - margin-left: 5px; - color: #1890ff; - margin-right: 3px; - } - } - - - } - .file-tip{ - margin-left: 45px; - margin-top: 10px; - margin-bottom: 50px; - } - .error{ - color: #e83f2e; - } - .success{ - color: #98d673; - } - - .error-icon{ - color: #e83f2e; - font-size: 18px; - margin-right: 10px; - } - .success-icon{ - color: #98d673; - font-size: 18px; - margin-right: 10px; - } - .file-upload-tip{ - color: #000000; - font-size: 14px; - font-weight: bold; - margin-left: 40px; - margin-top: 20px; - } - .file-errmsg{ - color: #000000; - font-size: 14px; - margin-left: 40px; - margin-top: 40px; - } - - .gridpanel{ - width: 90%; - height: 400px; - margin: 0 auto; - margin-top: 50px; - } - - - } - .audit-obj{ - margin-left: 30px; - margin-bottom: 10px; - } - .upload-input{ - opacity: 0; - width: 300px; - height: 48px; - position: absolute; - z-index: 5; - } - .file-loading{ - font-size: 24px; - - } - .isImport{ - cursor: "pointer"; - } - .goods-boxs{ - display: flex; - justify-content: flex-start; - } \ No newline at end of file diff --git a/src/pages/exchangecode/add/add.js b/src/pages/exchangecode/add/add.js index 65268608..1e406d6e 100644 --- a/src/pages/exchangecode/add/add.js +++ b/src/pages/exchangecode/add/add.js @@ -176,8 +176,7 @@ export default class acclist extends React.Component { 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 + batch_name: `${req.batch_name}_${++req.copy_count}` } let codeInfo = { //数据模型不可少 @@ -245,13 +244,13 @@ export default class acclist extends React.Component { return obj }) let pr = {} - let productRange = [] - item.product.forEach(item=>{ - productRange.push(item.product_name); - }); - productRange = productRange.toString() - console.log(255,productRange); - pr.range = productRange + let productRange = [] + item.product.forEach((item) => { + productRange.push(item.product_name) + }) + productRange = productRange.toString() + console.log(255, productRange) + pr.range = productRange pr.restrict = item.restrict pr.title = item.title pr.begin_time = item.begin_time @@ -743,7 +742,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 @@ -1581,7 +1579,6 @@ export default class acclist extends React.Component { width={'520px'} alignment={'left'} /> -