diff --git a/src/pages/exchangecode/add/add.js b/src/pages/exchangecode/add/add.js
index a157a5a8..15d91aed 100644
--- a/src/pages/exchangecode/add/add.js
+++ b/src/pages/exchangecode/add/add.js
@@ -1,20 +1,25 @@
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 ,Tabs, Notify,CombinedDateRangePicker,Select,Input,Checkbox,Switch ,Swiper,Dropdown,DropdownPosition,DropdownClickTrigger,Icon,MenuItem,DropdownContent,Menu,RadioGroup,RadioButton } from 'zent';
+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
+import {addPlanStep,handelResponse,getPlanList,addKeysBatchInfo,getKeyBatchDetail,putKeyBatchDetail,uploadImg,postKeyEmail,getReseller
} 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';
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)
@@ -61,6 +66,11 @@ export default class acclist extends React.Component{
endtime:"",
rowIndex:-1,
uploading:false,
+ audit_visible:false,
+ phone_list:[],
+ email_list:[],
+ email_radio:-1,
+ phone_radio:-1
}
}
@@ -78,7 +88,7 @@ export default class acclist extends React.Component{
console.log("和编辑",req)
this.setState({pagetitle:"编辑key"})
let model = {
- batch_name:req.batch_name,
+ batch_name:req.batch_name,
style: req.style,
quantity:req.quantity,
allow_repetition:req.allow_repetition,
@@ -114,8 +124,6 @@ export default class acclist extends React.Component{
if(plan_item)
{
plan_item = JSON.parse(plan_item)
- console.log("计划认为")
- console.log(plan_item)
let model = this.state.model;
model.title = plan_item.title;
@@ -219,7 +227,7 @@ export default class acclist extends React.Component{
break;
}
this.setState({drawerVisible:false})
- this.state.codeInfo={ //数据模型不可少
+ this.state.codeInfo={ //数据模型不可少
code_name:"",
issued:'',//发放总量
describe:'',
@@ -421,9 +429,21 @@ export default class acclist extends React.Component{
putKeyBatchDetail(id,data).then((res)=>{
handelResponse(res,(req,msg)=>{
Notify.success("更新key成功");
- setTimeout(()=>{
- window.history.back()
- },1000);
+ // setTimeout(()=>{
+ // window.history.back()
+ // },1000);
+
+ getReseller(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})
+
+ })
+ })
+
},(err)=>{
Notify.error(err);
})
@@ -453,11 +473,23 @@ export default class acclist extends React.Component{
addKeysBatchInfo(id,data).then((res)=>{
handelResponse(res,(req,msg)=>{
Notify.success("创建key成功");
- setTimeout(()=>{
- window.history.back()
- },1000);
+ sessionStorage.setItem("keyBatchId",req.key_batch_id)
+ getReseller(req.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})
+
+ })
+ })
+
+
+
+
},(err)=>{
- Notify.success(err);
+ Notify.error(err);
})
})
@@ -475,16 +507,23 @@ export default class acclist extends React.Component{
}
- onDisabledCombinedDate = (val)=>{
- console.log(this.state.begintime)
- console.log(this.state.endtime)
- let str = moment(val).format("YYYY-MM-DD HH:mm:ss")
- let now = moment(new Date().getTime()).format("YYYY-MM-DD HH:mm:ss")
-
- let isBetween = moment(str).isBetween(now,this.state.endtime,null,'(]');
- return !isBetween
+ onDisabledRange = (date, type)=>{
+ let step1 = JSON.parse (sessionStorage.getItem("step1"));
+ 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){
@@ -619,9 +658,101 @@ export default class acclist extends React.Component{
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)
+ : [],
+ }
+ : {};
+ };
+
+ send(e)
+ {
+ let key_id = sessionStorage.getItem("keyBatchId")
+ 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
+ }
+
+ 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_-]+)+$");
+
+
+ if (!phoneReg.test(data.phone)) {
+
+ Notify.error("手机号格式不正确")
+ return;
+ }
+ if(!emailReg.test(data.email)){
+
+ Notify.error("邮箱格式不正确")
+ return;
+
+ }
+
+
+ postKeyEmail(key_id,data).then((res)=>{
+ handelResponse(res,(req,msg)=>{
+ Notify.success("发送成功,请在1-2分钟后查看")
+ this.props.history.push('/home/plan-list/');
+ },(err)=>{
+ Notify.error(err)
+ this.props.history.push('/home/plan-list/');
+ })
+ })
+
+
+ }
+
+ 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})
+
+ }
render(){
const Column = [
{
@@ -1088,8 +1219,71 @@ export default class acclist extends React.Component{