import React, { Component } from 'react';
import SearchList from './SearchList/SearchList';
import {Select ,Row, Col,Button,Icon,Input,Form,DatePicker,Table} from 'antd';
const FormItem=Form.Item;
import './search.css';
import '../../styles/antd.css'
const Option = Select.Option;
import moment from 'moment';
const RangePicker = DatePicker.RangePicker;
import {appHistory} from '../app';
import { getStore } from '../../base/common-func';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import * as Actions from '../../actions/customer-management';
// 搜索列表
class SearchComponent extends Component{
constructor(props, context){
super(props, context);
this.state={
secondChannels:[],
thirdChannels:[],
}
this.FirstChange = this.FirstChange.bind(this);
this.SecondChange = this.SecondChange.bind(this);
this.onChange=this.onChange.bind(this);
}
onChange=(dates, dateStrings)=> {
console.log('From: ', dates[0], ', to: ', dates[1]);
console.log('From: ', dateStrings[0], ', to: ', dateStrings[1]);
}
handleReset=()=>{
this.props.form.resetFields();
}
FirstChange(value) {
var id=parseInt(value);
var channel2List = [];
var {oneChannel} = this.props.customerManagement;
oneChannel.forEach(function(element) {
if(element.parentId == id){
channel2List.push(element);
}
}, this);
this.setState({secondChannels:channel2List});
console.log(`selected ${value}`);
}
SecondChange(value) {
var id=parseInt(value);
var channel2List = [];
var {oneChannel} = this.props.customerManagement;
oneChannel.forEach(function(element) {
if(element.parentId == id){
channel2List.push(element);
}
}, this);
this.setState({thirdChannels:channel2List});
console.log(`selected ${value}`);
}
handelChannel(){
var {oneChannel} = this.props.customerManagement;
var array =[];
oneChannel.forEach(function(element) {
if(element.level == 0){
array.push(element);
}
}, this);
return array;
}
componentDidMount(){
//this.props.actions._getDataForCustomerManag();
this.props.actions._getCarType();
this.props.actions. _getGuestStatus();
this.props.actions._getIntention();
this.props.actions._getGuestStatus();
this.props.actions._getOneChannel();
this.props.actions._getElectricity();
}
handleSearch = (e) => {
e.preventDefault();
this.props.form.validateFields((err, values) => {
console.log('Received values of form: ', values);
});
}
getCarType(){
this.props.actions._getCarType();
}
getElectricity(){
this.props.actions._getElectricity();
}
getGuestStatus(){
this.props.actions. _getGuestStatus();
}
getIntention(){
this.props.actions._getIntention();
}
getOneChannel(){
this.props.actions._getOneChannel();
}
getOptionsView(list){
var { languageType } = this.props.common;
return list.map(v=><Option key={v.id}>{languageType == 'zh_cn'?v.nameCn:v.nameEn}</Option>);
}
getOptionsView2(list){
var { languageType } = this.props.common;
return list.map(v=><Option key={v.id}>{languageType == 'zh_cn'?v.nameCn:v.nameEn}</Option>);
}
getOptionsGuestView(list){
var { languageType } = this.props.common;
return list.map(v=><Option key={v.id}>{languageType == 'zh_cn'?v.valueCn:v.valueEn}</Option>);
}
render(){
var {carTypes,guestStatus,intention,oneChannel,electricity} = this.props.customerManagement;
var {secondChannels,thirdChannels}=this.state;
var channel=this.handelChannel();
var {Beginning_and_ending_time,begin_end_Check} =this.props.common.languageKeyMap;
return(
<div className="wrapper-search">
{/*高级搜索标题*/}
<Row>
<Col span={2} className="search_title" style={{fontWeight:"bold"}}>高级搜索</Col>
<Col span={22}><div className="line"></div></Col>
</Row>
{/*搜索的条件和搜索列表*/}
<div style={{marginTop:20 }}>
<Form className="ant-advanced-search-form"
onSubmit={this.handleSearch}>
<Row style={{marginLeft:120}} >
<Col span={2}>
<FormItem label="意向车型:" style={{fontSize:12,color:'black'
}}>
</FormItem>
</Col>
<Col span={5}>
<Select defaultValue="0" style={{width:160}} onChange={this.handleChange} >
<Option value="0" style="font-weight:bold">请选择</Option>
{this.getOptionsView(carTypes)}
</Select>
</Col>
<Col span={2}>
<FormItem label="潜客状态:">
</FormItem>
</Col>
<Col span={6}>
<Select defaultValue="0" style={{width:160}} onChange={this.handleChange} >
<Option value="0" style="font-weight:bold">请选择</Option>
{this.getOptionsGuestView(guestStatus)}
</Select>
</Col>
<Col span={2}>
<FormItem label="意向级别:">
</FormItem>
</Col>
<Col span={7}style={{paddingLeft:8}}>
<Select defaultValue="0" style={{width:160}} onChange={this.handleChange} >
<Option value="0" style="font-weight:bold">请选择</Option>
{this.getOptionsGuestView(intention)}
</Select>
</Col>
</Row>
<div>
<Row style={{marginLeft:120}} >
<Col span={2}>
<FormItem label="一级渠道:">
</FormItem>
</Col>
<Col span={5}>
<Select defaultValue="0" style={{width:160}} onChange={this.FirstChange} onSelect={this.handeSelect} >
<Option value="0" style="font-weight:bold">请选择</Option>
{this.getOptionsView(channel)}
</Select>
</Col>
<Col span={2}>
<FormItem label="二级渠道:">
</FormItem>
</Col>
<Col span={6}>
<Select defaultValue="0" style={{width:160}} onChange={this.SecondChange}>
<Option value="0" style="font-weight:bold">请选择</Option>
{this.getOptionsView2(secondChannels)}
</Select>
</Col>
<Col span={2}>
<FormItem label="三级渠道:">
</FormItem>
</Col>
<Col span={7} style={{paddingLeft:8}}>
<Select defaultValue="0" style={{width:160}} onChange={this.handleChange} >
<Option value="0" style="font-weight:bold">请选择</Option>
{this.getOptionsView2(thirdChannels)}
</Select>
</Col>
</Row>
</div>
<div>
<Row style={{marginLeft:120}} >
<Col span={2}>
<FormItem label="时间条件:">
</FormItem>
</Col>
<Col span={5}>
<Select defaultValue="0" style={{width:160}} onChange={this.handleChange} >
<Option value="0" style="font-weight:bold">请选择</Option>
<Option value="jack">{Beginning_and_ending_time}</Option>
<Option value="lucy">{begin_end_Check}</Option>
<Option value="disabled" disabled>Disabled</Option>
<Option value="Yiminghe">yiminghe</Option>
</Select>
</Col>
<Col span={2}>
<FormItem label="起止时间:">
</FormItem>
</Col>
<Col span={6} >
<RangePicker
style={{width:160}}
placeholder={{placeholder:""}}
ranges={{ Today: [moment(), moment()], 'This Month': [moment(), moment().endOf('month')] }}
showTime
format="YYYY/MM/DD HH:mm:ss"
onChange={this.onChange}
/>
</Col>
<Col span={2}>
<FormItem label="PMP电销专员:">
</FormItem>
</Col>
<Col span={7} style={{paddingLeft:8}}>
<Select defaultValue="0" style={{width:160}} onChange={this.handleChange} >
<Option value="0" style="font-weight:bold">请选择</Option>
<Option value="jack">Jack</Option>
<Option value="lucy">Lucy</Option>
<Option value="disabled" disabled>Disabled</Option>
<Option value="Yiminghe">yiminghe</Option>
</Select>
</Col>
</Row>
</div>
<Row style={{marginLeft:120}}>
<Col span={2}>
<FormItem label="PMP电销顾问:">
</FormItem>
</Col>
<Col span={8}style={{paddingLeft:8}}>
<Select defaultValue="0" style={{width:160}} onChange={this.handleChange} >
<Option value="0" style="font-weight:bold">请选择</Option>
{this.getOptionsView(electricity)}
</Select>
</Col>
</Row>
</Form>
<Row style={{marginRight:6}}>
<Col span={24} style={{ textAlign: 'right' }}>
<Button style={{ marginRight: 30 }} onClick={this.handleReset} >
重置
</Button>
<Button style={{marginRight: 5}} className="btn btn-success">搜索</Button>
</Col>
</Row>
<Row >
<div style={{marginTop:8,paddingBottom:30}}>
<Col span={2} className="search_title" >搜索结果</Col>
<Col span={22}><div className="line"></div></Col>
</div>
</Row>
<Row style={{padding:5}}>
<Col span={2} className='num' >
数量:num
</Col>
<Col span={22} style={{ textAlign: 'right' }}>
<div style={{marginRight:5}}>
<Button style={{marginRight:30}}>导入</Button>
<Button style={{marginRight:30}}>导出</Button>
<Button style={{marginRight:30}}>分派 PMP 电销专员</Button>
<Button >分派 PMP 电销顾问</Button>
</div>
</Col>
</Row>
<Row style={{marginTop:10,textAlign:"center"}}>
<SearchList/>
</Row>
</div>
<div>
</div>
</div>
)
}
}
SearchComponent.propTypes = {}
SearchComponent.defaultProps = {}
export default connect(
state => ({ customerManagement: state.customerManagement,common:state.common }),
dispatch => ({ actions: bindActionCreators(Actions, dispatch) })
)(SearchComponent)
resetFields :重置一组输入控件的值(为 initialValue)与状态,如不传入参数,则重置所有组件 。