From 3656836f443a774aee710e6dd5c59b933c16bee2 Mon Sep 17 00:00:00 2001 From: zhangds Date: Wed, 13 Apr 2022 16:12:08 +0800 Subject: [PATCH] =?UTF-8?q?1)=20=E5=88=A0=E9=99=A4=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/exchangecode/add/add.js | 3392 +++++++++++++++-------------- 1 file changed, 1815 insertions(+), 1577 deletions(-) diff --git a/src/pages/exchangecode/add/add.js b/src/pages/exchangecode/add/add.js index 68d3646c..96d191d2 100644 --- a/src/pages/exchangecode/add/add.js +++ b/src/pages/exchangecode/add/add.js @@ -1,1588 +1,1826 @@ -import ReactDOM from 'react-dom'; -import React, { Component } from 'react'; +import ReactDOM from "react-dom"; +import React, { Component } from "react"; import { HashRouter as Router, Route, Link } from "react-router-dom"; -import {Card,Sweetalert,DateRangePicker,ImageUpload, Drawer,Button,Radio ,Tabs, Notify,CombinedDateRangePicker,Select,Input,Checkbox,Switch ,Swiper,Dropdown,DropdownPosition,DropdownClickTrigger,Icon,MenuItem,DropdownContent,Menu,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,getPlanList,addKeysBatchInfo,getKeyBatchDetail,putKeyBatchDetail,uploadImg,postKeyEmail,getReseller,getAccessVerification,keyApproval} from "../../../assets/api.js" -import Productform from "../product/add" -import Bus from "../../../assets/eventBus.js" +import { + Card, + Sweetalert, + DateRangePicker, + ImageUpload, + Drawer, + Button, + Radio, + Tabs, + Notify, + CombinedDateRangePicker, + Select, + Input, + Checkbox, + Switch, + Swiper, + Dropdown, + DropdownPosition, + DropdownClickTrigger, + Icon, + MenuItem, + DropdownContent, + Menu, + 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, + getPlanList, + addKeysBatchInfo, + getKeyBatchDetail, + putKeyBatchDetail, + uploadImg, + postKeyEmail, + getReseller, + getAccessVerification, + keyApproval, +} from "../../../assets/api.js"; +import Productform from "../product/add"; +import Bus from "../../../assets/eventBus.js"; import _ from "lodash"; -import "./add.less" -import moment from "moment" -import { isSameDay, addDays, parse } from 'date-fns'; +import "./add.less"; +import moment from "moment"; +import { isSameDay, addDays, parse } from "date-fns"; const TabPanel = Tabs.TabPanel; -const initArray = targetNum => { +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 - +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, + }; + } + + 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({ 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, + }; + 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.disabled = true; + // item.checked = true; + 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 }); + }); + }); + + let codeInfo = { + //数据模型不可少 + code_name: "", + issued: "", //发放总量 + describe: "", + date_time: [plan_item.begin_time, plan_item.end_time], + range: "", + }; + + this.setState({ codeInfo: codeInfo }); + } } } - 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({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, - } - 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.disabled = true; - // item.checked = true; - 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}) - - }) - }) - - 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; - } - 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","") - } - closeDraw(){ - this.setState({drawerVisible:false}) - } - addProduct(){ - this.setState({drawerVisible2:true}) - this.setState({productData:null}) - } - async productSubmit(){ - let visible = await this.refs.product.submit() - if(visible) - { - Notify.success("保存成功") - this.setState({drawerVisible2:false}) - setTimeout(()=>{ - - let data = JSON.parse(sessionStorage.getItem("productData")); - - let 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 - } - - return item - }) - - - - this.setState({tempdata:temp }) - let arr = []; - _.map(data,(res)=>{ - let obj = {}; - obj.key = res.product_id; - obj.text= res.product_name; - arr.push(obj) - return obj; - }) - this.setState({rankoptions:arr}) - },500) - } - - - } - - onChangeCombinedDate(e){ - let model2 = this.state.codeInfo; - model2.date_time = e; - this.setState({codeInfo:model2}) - } - submit2(){ - this.refs.form2.validator() - } - onRankChange(e){ - _.forEach(this.state.tempdata, (item) => { - item.checked = e.findIndex((checks)=>{return checks.key == item.product_id}) > -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 tableData = this.state.distdata; - 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; - 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}) - } - let id = sessionStorage.getItem("key_plan_id") - - } - } - 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()) - { - 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.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 = this.refs.bindObj.getSelectData(); - - 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/'); - },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.product_id; - obj.text= res.product_name; - return obj; - }) - this.setState({rankoptions:arr}) - - this.setState({rank:arr}) - this.setState({codeInfo:codeInfo}) - this.setState({rowIndex:rowIndex}) - let temp = _.map(row.product,(o)=>{ - o.checked = true; - return o - }) - - sessionStorage.setItem("productData", JSON.stringify(row.product)) - - this.setState({tempdata:temp}) - this.setState({drawerVisible:true}) - - } - - - 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){ - this.setState({drawerVisible2:true}) - this.setState({productData:row}) - this.setState({product_title:"编辑商品"}) - } - 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:'auto', - prop:'product_name', - name:'product_name', - type: "slot", - - }, { - title: '当前成本价格', - prop:'cost_price', - name: 'cost_price', - width:'auto', - type: "normal", - }, { - title: '合同价', - name: 'contract_price', - prop:'contract_price', - type: "slot", - width:'auto', - }, - { - title: '商品官方价', - type: "normal", - prop:'official_price', - width:'auto' - }, - { - title: '库存数量', - prop: 'quantity', - name: 'quantity', - type: "slot", - 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.onNameChange(e,rowData,rowIndex)}} /> - } - if(com=="quantity") - { - return {this.onQuantityChange(e,rowData,rowIndex)}} /> - } - if(com =="contract_price" ) - { - return {this.onPriceChange(e,rowData,rowIndex)}} /> - } - - - if(com == "edit") - { - return {this.keyProductClick(rowData,rowIndex)}} style={{color:"#2B66F2"}} >编辑 - } - - - }} - /> - -
-

-
-
- - - - - - } - visible={this.state.drawerVisible2} - onClose={(e) =>{this.setState({drawerVisible2:false})} } - maskClosable = {false} - > -
- - - - - -
-
- { - this.state.import_visible ? ( -
-
-
-
-
从Excel导入白名单
- - {this.setState({import_visible:false}) }} /> - -
-
-
-
1
- 上传文件 -
-
-
-
-
-
-
2
- 导入完成 - -
-
- -
- -
- 直接上传 -
- - -
-
支持文件类型:xls,xlsx,csv
-
- 支持所有基础字段的导入,一次至多导入 10000 条手机号(不符合规则整条任务不予以导入)
-
-
- { - this.state.upload_visible ? (
-
-
- - {this.state.myfile.name} -
- - { - this.state.file_loading ? (
- - - 解析中 -
) :(
- 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 - - - - - } - - - ) + onPayTypeChange(e) { + this.setState({ paytype: e.target.value }); } -} \ No newline at end of file + + 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; + } + 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", ""); + } + closeDraw() { + this.setState({ drawerVisible: false }); + } + addProduct() { + this.setState({ drawerVisible2: true }); + this.setState({ productData: null }); + } + async productSubmit() { + let visible = await this.refs.product.submit(); + if (visible) { + Notify.success("保存成功"); + this.setState({ drawerVisible2: false }); + setTimeout(() => { + let data = JSON.parse(sessionStorage.getItem("productData")); + + let 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; + } + + return item; + }); + + this.setState({ tempdata: temp }); + let arr = []; + _.map(data, (res) => { + let obj = {}; + obj.key = res.product_id; + obj.text = res.product_name; + arr.push(obj); + return obj; + }); + this.setState({ rankoptions: arr }); + }, 500); + } + } + + onChangeCombinedDate(e) { + let model2 = this.state.codeInfo; + model2.date_time = e; + this.setState({ codeInfo: model2 }); + } + submit2() { + this.refs.form2.validator(); + } + onRankChange(e) { + _.forEach(this.state.tempdata, (item) => { + item.checked = + e.findIndex((checks) => { + return checks.key == item.product_id; + }) > -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 tableData = this.state.distdata; + 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; + 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 }); + } + let id = sessionStorage.getItem("key_plan_id"); + } + } + 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()) { + 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.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 = this.refs.bindObj.getSelectData(); + + 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/"); + }, 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.product_id; + obj.text = res.product_name; + return obj; + }); + this.setState({ rankoptions: arr }); + + this.setState({ rank: arr }); + this.setState({ codeInfo: codeInfo }); + this.setState({ rowIndex: rowIndex }); + let temp = _.map(row.product, (o) => { + o.checked = true; + return o; + }); + + sessionStorage.setItem("productData", JSON.stringify(row.product)); + + this.setState({ tempdata: temp }); + this.setState({ drawerVisible: true }); + } + + 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) { + this.setState({ drawerVisible2: true }); + this.setState({ productData: row }); + this.setState({ product_title: "编辑商品" }); + } + 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: "auto", + prop: "product_name", + name: "product_name", + type: "slot", + }, + { + title: "当前成本价格", + prop: "cost_price", + name: "cost_price", + width: "auto", + type: "normal", + }, + { + title: "合同价", + name: "contract_price", + prop: "contract_price", + type: "slot", + width: "auto", + }, + { + title: "商品官方价", + type: "normal", + prop: "official_price", + width: "auto", + }, + { + title: "库存数量", + prop: "quantity", + name: "quantity", + type: "slot", + 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.onNameChange(e, rowData, rowIndex); + }} + /> + ); + } + if (com == "quantity") { + return ( + { + this.onQuantityChange(e, rowData, rowIndex); + }} + /> + ); + } + if (com == "contract_price") { + return ( + { + this.onPriceChange(e, rowData, rowIndex); + }} + /> + ); + } + + if (com == "edit") { + return ( + { + this.keyProductClick(rowData, rowIndex); + }} + style={{ color: "#2B66F2" }} + > + 编辑 + + ); + } + }} + /> + +
+

+
+
+ + + + + + } + visible={this.state.drawerVisible2} + onClose={(e) => { + this.setState({ drawerVisible2: false }); + }} + maskClosable={false} + > +
+ + + +
+
+ {this.state.import_visible ? ( +
+
+
+
+
从Excel导入白名单
+ + { + this.setState({ import_visible: false }); + }} + /> +
+
+
+
1
+ 上传文件 +
+
+
+
+
+
2
+ 导入完成 +
+
+ +
+
直接上传
+ +
+
支持文件类型:xls,xlsx,csv
+
+ - 支持所有基础字段的导入,一次至多导入 10000 + 条手机号(不符合规则整条任务不予以导入) +
+
+
+ {this.state.upload_visible ? ( +
+
+
+ + + {this.state.myfile.name} + +
+ + {this.state.file_loading ? ( +
+ + 解析中 +
+ ) : ( +
+ 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} + + ); + } +}