import React from 'react';
import { Radio, Icon, Button, AutoComplete,Cascader,Input, Select, Spin, Popconfirm, Table, Switch, message,Calendar , DatePicker, Upload, Form ,Modal,Tabs,Card ,Col} from 'antd';
import ajax from 'jquery/src/ajax/xhr.js';
import $ from 'jquery/src/ajax';
import Jquery from 'jquery/dist/jquery.js';
import moment from 'moment';
import {boutique ,tepi,jiedian} from '@/dataDic.js';
import { getLiquidationStatus,getApprovedState,getProcessStatus,splitUrl,getjiedian,getboutique} from '@/tools.js';
import './customer.less';
const TabPane = Tabs.TabPane;
const Dragger = Upload.Dragger;
//图片组件
const PicturesWall = React.createClass({
	getInitialState() {
		return {
			previewVisible: false,
			previewImage: '',
			fileList: [],
		}
	},
	handleCancel() {
		this.setState({
			previewVisible: false
		})
	},
	handlePreview(file) {
		this.setState({
			previewImage: file.url || file.thumbUrl,
			previewVisible: true,
		});
	},
	handleChange(info) {
		let fileList = info.fileList;
		this.setState({
			fileList
		});
		this.props.fileList(fileList);
	},
	componentWillReceiveProps(nextProps) {
		this.state.fileList = nextProps.pictureUrl;
		this.state.pojectApplicationUrl = undefined;
	},
	render() {
		const {
			previewVisible,
			previewImage,
			fileList
		} = this.state;
		const uploadButton = (
			
		);
		return(
			
                
                    {fileList.length >= 8 ? null : uploadButton}
                
                
                     
                
             
		);
	}
});
const IntentionCustomer = Form.create()(React.createClass({
	loadData(pageNo, apiUrl) {
		this.setState({
			visitModul:false,
			loading: true,
			ispage:pageNo,
			modalVisible:false
		});
		$.ajax({
			method: "get",
			dataType: "json",
			crossDomain: false,
			url: globalConfig.context +"/api/admin/newOrder/orderNewList",
			data: {
				pageNo: pageNo || 1,
				pageSize: this.state.pagination.pageSize,
				specially: 2,//审核列表
				name: this.state.name,//名称
				orderNo: this.state.orderNo,//订单编号
				starTime: this.state.releaseDate[0],//开始时间
				endTime: this.state.releaseDate[1],//结束时间
			},
			success: function(data) {
				let theArr = [];
				if(data.error.length || data.data.list == "") {
					if(data.error && data.error.length) {
						message.warning(data.error[0].message);
					};
				} else {
					for(let i = 0; i < data.data.list.length; i++) {
						let thisdata = data.data.list[i];
						let diqu=(thisdata.province==null?"":thisdata.province)+(thisdata.city==null?"":"-"+thisdata.city)+(thisdata.area==null?"":"-"+thisdata.area);
						theArr.push({
							 key: i,
							 id: thisdata.id,//用户ID
							 orderNo: thisdata.orderNo,//订单编号
	                         totalAmount:thisdata.totalAmount,//签单金额
	                         processStatus:thisdata.processStatus,//流程状态
	                         liquidationStatus:thisdata.liquidationStatus,//结算状态
	                         approval:thisdata.approval,//特批状态
	                         signDate:thisdata.signDate,//签单时间
	                         userName:thisdata.userName,//客户名称
	                         salesmanName:thisdata.salesmanName,//营销员名称
	                         financeName:thisdata.financeName,//财务名称
	                         createDate:thisdata.createDate,//下单时间
	                         initiateName:thisdata.initiateName,//驳回人
	                         reason:thisdata.reason,//驳回信息
	                         backDate:thisdata.backDate,//驳回日期
	                         backId:thisdata.backId,//驳回编号
						});
					};
				    this.state.pagination.total = data.data.totalCount;
				    this.state.pagination.current = data.data.pageNo;
				};
				if(data.data&&data.data.list&&!data.data.list.length){
					this.state.pagination.total=0
				}
				this.setState({
					dataSource: theArr,
					pageNo: pageNo,
					pagination: this.state.pagination,
					selectedRowKeys:[]
				});
			}.bind(this),
		}).always(function() {
			this.setState({
				loading: false
			});
		}.bind(this));
	},
	getInitialState() {
		return {
			page:1,
			releaseDate: [],
			selectedRowKeys: [],
			orgCodeUrl:[],
			customerArr:[],
			pagination: {
				defaultCurrent: 1,
				defaultPageSize: 10,
				showQuickJumper: true,
				pageSize: 10,
				onChange: function(page) {
					this.loadData(page);
				}.bind(this),
				showTotal: function(total) {
					return '共' + total + '条数据';
				}
			},
			columns: [
				{
                    title: '驳回编号',
                    dataIndex: 'backId',
                    key: 'backId'
                },{
                    title: '驳回日期',
                    dataIndex: 'backDate',
                    key: 'backDate'
                },
				{
                    title: '订单编号',
                    dataIndex: 'orderNo',
                    key: 'orderNo'
                }, {
                    title: '客户名称',
                    dataIndex: 'userName',
                    key: 'userName',
                    render:(text)=>{
                    	return (text&&text.length>9?text.substr(0,9)+'...':text)
                    }
                },  {
                    title: '驳回人',
                    dataIndex: 'initiateName',
                    key: 'initiateName'
                },{
                    title: '驳回原因',
                    dataIndex: 'reason',
                    key: 'reason',
                    render:(text)=>{
                    	return (text&&text.length>24?text.substr(0,24)+'...':text)
                    }
                }
			],
			data: [],
			dataSource: [],
			columnsX: [
				{
                    title: '业务项目名称',
                    dataIndex: 'commodityName',
                    key: 'commodityName'
                }, {
                    title: '项目类别',
                    dataIndex: 'cname',
                    key: 'cname',
                    
                },{
                    title: '项目数量',
                    dataIndex: 'commodityQuantity',
                    key: 'commodityQuantity'
                }, {
                    title: '金额(万元)',
                    dataIndex: 'commodityPrice',
                    key: 'commodityPrice'
                }, {
                    title: '负责人',
                    dataIndex: 'contacts',
                    key: 'contacts'
                }, {
                    title: '负责人电话',
                    dataIndex: 'contactsMobile',
                    key: 'contactsMobile'
                }, {
                    title: '主要项目',
                    dataIndex: 'main',
                    key: 'main',
                    render:(text)=>{
                    	return (text?'是':'否')
                    }
                }, {
                    title: '项目说明',
                    dataIndex: 'taskComment',
                    key: 'taskComment',
					render:(text)=>{
						return (text&&text.length>8?text.substr(0,8)+'…':text)
					}
                }, {
                    title: '操作',
                    dataIndex: 'ABC',
                    key: 'ABC',
                    render: (text, record, index) => {
						return 
									{this.state.processStatus==0?
{this.delectRow(record)}} okText="是" cancelText="否">
										                     
										:""}
								
		                        {this.state.processStatus==0?
{this.confirmDelet(record.key)}} okText="删除" cancelText="不删除">
									    
									
									:''}
								{record.id?'': 
}