This commit is contained in:
姜棚 2021-12-13 15:04:35 +08:00
parent 181d665a41
commit 382dc77706
3 changed files with 157 additions and 137 deletions

View File

@ -32,9 +32,9 @@ const Column = [
type: "normal", type: "normal",
width:'100px' width:'100px'
}, { }, {
title: 'key-批次ID', title: '兑换码-批次ID',
name: 'key_batch_id', name: 'code_batch_id',
prop:'key_batch_id', prop:'code_batch_id',
type: "normal", type: "normal",
width:'100px' width:'100px'
}, },

View File

@ -1,7 +1,7 @@
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import {Input,openDialog,closeDialog,Notify,Menu, MenuItem,Button,Tag,Sweetalert,CombinedDateRangePicker,Dropdown,DropdownPosition,DropdownClickTrigger,Icon,DropdownContent} from 'zent'; import {Input,RadioGroup,Radio,openDialog,closeDialog,Notify,Menu, MenuItem,Button,Tag,Sweetalert,CombinedDateRangePicker,Dropdown,DropdownPosition,DropdownClickTrigger,Icon,DropdownContent} from 'zent';
import "./list.less" import "./list.less"
import { Switch } from 'zent'; import { Switch } from 'zent';
import "../../../assets/comm.css" import "../../../assets/comm.css"
@ -10,7 +10,7 @@ import Grid from "../../../components/gird/main.js"
import TabPage from "../../../components/tabPage/main.js" import TabPage from "../../../components/tabPage/main.js"
import Filterbar from "../../../components/filterbar/main.js" import Filterbar from "../../../components/filterbar/main.js"
import menu from "../../../assets/enum.js" import menu from "../../../assets/enum.js"
import {getKeyList,handelResponse,startOrStopKeybatch,resKeyEmail,planResend,putKeyEmail,cancelKey,keysIsSend} from "../../../assets/api.js" import {getKeyList,planIsSend,getReseller,handelResponse,startOrStopKeybatch,resKeyEmail,planResend,putKeyEmail,cancelKey,keysIsSend} from "../../../assets/api.js"
import _ from "lodash"; import _ from "lodash";
const Column = [ const Column = [
{ {
@ -130,7 +130,15 @@ export default class acclist extends React.Component{
phone:"", phone:"",
isSend:false, isSend:false,
isEmail : false, isEmail : false,
isSms :false isSms :false,
audit_visible:false,
phone_list:[],
email_list:[],
phone:"",
email:"",
email_radio:-1,
phone_radio:-1,
} }
} }
@ -340,6 +348,41 @@ onEditRow(status,row){
this.getKeyList(); this.getKeyList();
} }
cancel(e){
this.setState({audit_visible:false})
}
send(e)
{
let phoneReg = new RegExp("^[1][3,4,5,6,7,8,9][0-9]{9}$");
let emailReg = new RegExp( "^[A-Za-z0-9\u4e00-\u9fa5\.]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$");
let plan_id = this.state.plan_id;
let data ={
phone: this.state.phone_radio > -1 ? this.state.phone_list[this.state.phone_radio] : this.state.phone ,
email: this.state.email_radio > -1 ? this.state.email_list[this.state.email_radio] : this.state.email
}
if (!phoneReg.test(data.phone)) {
Notify.error("手机号格式不正确")
return;
}
if(!emailReg.test(data.email)){
Notify.error("邮箱格式不正确")
return;
}
}
componentWillMount(){ componentWillMount(){
this.setState({tableHeight:window.innerHeight-390}); this.setState({tableHeight:window.innerHeight-390});
if(sessionStorage.getItem("key_plan_status")==6 || sessionStorage.getItem("key_plan_status")== 0) if(sessionStorage.getItem("key_plan_status")==6 || sessionStorage.getItem("key_plan_status")== 0)
@ -363,139 +406,37 @@ phoneChange=(e)=>
} }
menuItemClick(e,key,row){ menuItemClick(e,key,row){
let self =this let self =this
if(key == 1) if(key == 1)
{ {
let reseller_id = sessionStorage.getItem("reseller_id")
if(this.state.isSms == false) getReseller(reseller_id).then((res)=>{
{
Notify.error("还没发送过密码")
return;
}
let data ={
"type":"sms"
}
resKeyEmail(row.id,data).then((res)=>{
handelResponse(res,(req,msg)=>{ handelResponse(res,(req,msg)=>{
this.setState({phone_list:req.contact_phone})
Notify.success("发送成功") this.setState({email_list:req.contact_email})
this.setState({audit_visible:true})
},(err)=>{ },(err)=>{
Notify.error(err) Notify.error(err)
}) })
}) })
} // planIsSend(row.id).then((res)=>{
// handelResponse(res,(req,msg)=>{
// this.setState({cur_item:row})
// getReseller(row.reseller_id).then((res)=>{
// handelResponse(res,(req,msg)=>{
// this.setState({phone_list:req.contact_phone})
// this.setState({email_list:req.contact_email})
// this.setState({audit_visible:true})
if(key == 2) // },(err)=>{
{ // Notify.error(err)
console.log("状态",this.state.isEmail) // })
// })
if(this.state.isEmail == false)
{
Notify.error("还没发送过key")
return;
}
let data ={
"type":"email"
}
resKeyEmail(row.id,data).then((res)=>{
handelResponse(res,(req,msg)=>{
Notify.success("发送成功")
},(err)=>{
Notify.error(err)
})
})
}
if(key == 3) // })
{ // });
let email = ""
openDialog({
closeBtn:true,
dialogId: 1, // id is used to close the dialog
title: '请输入接收邮箱',
children: <Input placeholder="请输入接收邮箱" onChange={self.emailChange}></Input>,
footer: <Button onClick={() => {
if(self.state.email=="")
{
Notify.error("接收邮箱不能为空")
return
}
let plan_id = row.id
let data ={
type:"email",
to: self.state.email
}
putKeyEmail(plan_id,data).then((res)=>{
handelResponse(res,(req,msg)=>{
Notify.success("发送成功")
closeDialog(1)
},(err)=>{
Notify.error(err)
})
})
}}>发送</Button>,
onClose() {
},
});
}
if(key == 4)
{
let phone = ""
openDialog({
closeBtn:true,
dialogId: 2, // id is used to close the dialog
title: '请输入接收手机',
children: <Input placeholder="请输入接收手机号" onChange={self.phoneChange}></Input>,
footer: <Button onClick={
()=>{
if(self.state.phone=="")
{
Notify.error("接收手机号不能为空")
return
}
let plan_id = row.id
let data ={
type:"sms",
to: self.state.phone
}
putKeyEmail(plan_id,data).then((res)=>{
handelResponse(res,(req,msg)=>{
Notify.success("发送成功")
closeDialog(2)
},(err)=>{
Notify.error(err)
})
})
}
}>发送</Button>,
onClose() {
},
});
} }
if(key == 5) if(key == 5)
{ {
@ -661,11 +602,7 @@ onChangeCombinedDate(e){
</DropdownClickTrigger> </DropdownClickTrigger>
<DropdownContent> <DropdownContent>
<Menu onClick={(e,key)=>this.menuItemClick(e,key,rowData)} style={{width:"400px"}}> <Menu onClick={(e,key)=>this.menuItemClick(e,key,rowData)} style={{width:"400px"}}>
<MenuItem key="1" >再次发送key密码</MenuItem> <MenuItem key="1">发送密码及压缩包</MenuItem>
<MenuItem key="2"
>再次发送key</MenuItem>
<MenuItem key="3">修改接收邮箱发送</MenuItem>
<MenuItem key="4">修改接收手机发送</MenuItem>
<MenuItem key="5">作废</MenuItem> <MenuItem key="5">作废</MenuItem>
</Menu> </Menu>
</DropdownContent> </DropdownContent>
@ -684,6 +621,85 @@ onChangeCombinedDate(e){
/> />
</div> </div>
</TabPage> </TabPage>
{
this.state.audit_visible ? (
<div>
<div className="modal"> </div>
<div className="audit-box" >
<Icon type="close" className="audit-close" onClick={(e)=>{this.cancel(e)}} />
<div className="audit-box-title">发送</div>
<div className="audit-box-question">是否立即发送key以及解压密码?</div>
<div className="phone-group">
<div >
接收手机号
</div>
<div className="phone-list">
<RadioGroup
value={this.state.phone_radio}
isValueEqual={this.isValueEqual}
onChange={(e)=>{this.onPhoneChange(e)}}
>
{
this.state.phone_list.map((item, index) => {
return <Radio value={index}>{item}</Radio>
})
}
</RadioGroup>
</div>
</div>
<div className="email-group">
<div >
接收邮箱
</div>
<div className="email-list">
<RadioGroup
value={this.state.email_radio}
isValueEqual={this.isValueEqual}
onChange={ (e)=>{this.onEmailChange(e)} }
>
{
this.state.email_list.map((item, index) => {
return <Radio value={index}>{item}</Radio>
})
}
</RadioGroup>
</div>
</div>
<div className="design-group">
<div>自定义</div>
<div className="input-group">
<Input placeholder="请输入接收手机号" onChange={this.phoneChange} disabled={this.state.phone_radio > -1} ></Input>
</div>
<div className="input-group">
<Input placeholder="请输入接收邮箱" onChange={this.emailChange} disabled={this.state.email_radio > -1} ></Input>
</div>
</div>
<div className="audit-btn-group">
<Button onClick={(e)=>{this.cancel(e)}}>取消</Button>
<Button type="primary" onClick={(e)=>{this.send(e)}} >发送</Button>
</div>
</div>
</div>
):null
}
</div> </div>
) )
} }

View File

@ -283,6 +283,7 @@ export default class acclist extends React.Component{
sessionStorage.setItem('breaknav',JSON.stringify(arr)); sessionStorage.setItem('breaknav',JSON.stringify(arr));
sessionStorage.setItem('linkshowname',"营销计划管理"); sessionStorage.setItem('linkshowname',"营销计划管理");
sessionStorage.setItem("key_plan_id",row.id) sessionStorage.setItem("key_plan_id",row.id)
sessionStorage.setItem("reseller_id",row.reseller_id);
sessionStorage.setItem("key_plan_status",row.status) sessionStorage.setItem("key_plan_status",row.status)
this.props.history.push('/home/key-list'); this.props.history.push('/home/key-list');
} }
@ -410,6 +411,7 @@ export default class acclist extends React.Component{
onEdit(e,row){ onEdit(e,row){
console.log("计划任务ID") console.log("计划任务ID")
console.log(row)
sessionStorage.setItem('showflag',true); sessionStorage.setItem('showflag',true);
let editarr=[{pagetitle:'编辑',items:[{path:'/home/key-list',name:'营销计划管理'}, let editarr=[{pagetitle:'编辑',items:[{path:'/home/key-list',name:'营销计划管理'},
{path:'/home/key-list',name:'编辑:'+row.title} {path:'/home/key-list',name:'编辑:'+row.title}
@ -421,6 +423,8 @@ export default class acclist extends React.Component{
Notify.error("不可编辑") Notify.error("不可编辑")
return; return;
} }
sessionStorage.setItem("plan_id",row.id) sessionStorage.setItem("plan_id",row.id)
sessionStorage.setItem("plan_status",row.status) sessionStorage.setItem("plan_status",row.status)
let link = window.location.href.replace(window.location.hash,"#/home/plan-edit"); let link = window.location.href.replace(window.location.hash,"#/home/plan-edit");