import React, { Component } from 'react';
import { getControl } from 'zorod/components/Zform/controls';
import { ZsearchListHOC } from 'zorod';
import api from '../Api';
import { Card, Form, Input, Button, message, Icon, Checkbox, Select, Cascader, Table, Popconfirm, Divider, Upload, Progress } from 'antd';
import DataTashSetPop from '../popComponents/DataTashSetPop'
import echarts from 'echarts';

const FormItem=Form.Item;
const TextArea=Input.TextArea;

const formItemLayout = {
    labelCol: { span: 8 },
    wrapperCol: { span: 16 },
}
const formTailLayout = {
	labelCol: { span: 4 },
	wrapperCol: { span: 12, offset: 4 },
}
const formButtom={
	wrapperCol: { span: 12, offset: 6 }
}
const residences=["baijing","hunian","guangxi"];

class ecConsensus extends Component {
	constructor(props) {
			super(props)
			this.state = {
				dataSource: [],
				batchNameList: [],
				selectInitialValue: '',
				loading: false,
				popShow: true,
				popMode: '',
				popData: {},
				pagination: {},
				searchValues: {"DATABASE_TYPE": "0"}
			}
	}

	// 页面加载函数
	componentDidMount() {
		api.system.getListPayConsensus(1, 10, '').then(res => {
			const pagination = { ...this.state.pagination }
			pagination.total = res.data.total
			this.setState({
				dataSource: res.data.list,
				pagination
			})
		})
	}
	// 选择一条数据
	sourceDetailSet = (id) => {
		
	}
	// 搜索
	search = () => {
		this.props.form.validateFields((err, values)=>{
			api.system.getListPayConsensus(1, 10, values.keyword).then(res => {
				const pagination = { ...this.state.pagination }
				pagination.total = res.data.total
				this.setState({
					dataSource: res.data.list,
					pagination
				})
			})
		})
	}
	// 点击翻页
	handleTableChange = pagination => {
		const pager = { ...this.state.pagination }
		pager.current = pagination.current
		this.setState({
			pagination: pager,
		})
		api.system.getListPayConsensus( pagination.current, pagination.pageSize, '').then(res => {
			const pagination = { ...this.state.pagination }
			pagination.total = res.data.total
			this.setState({
				dataSource: res.data.list,
				pagination
			})
		})
	}

	render() { 
		const { getFieldDecorator, getFieldsError, getFieldError, isFieldTouched } = this.props.form
		const { dataSource } = this.state
		const columns = [
			{
				title: '统一社会信用代码',
				dataIndex: 'creditCode',
				key: 'creditCode',
				width: '200px'
			},
			{
				title: '企业名称',
				dataIndex: 'companyName',
				key: 'companyName',
				width: '200px'
			},
			{
				title: '负责人',
				dataIndex: 'mainPerson',
				key: 'mainPerson',
				width: '100px'
			},
			{
				title: '经营状态',
				dataIndex: 'operatingStatus',
				key: 'operatingStatus',
				width: '100px'
			},
			{
				title: '行业类型',
				dataIndex: 'industry',
				key: 'industry',
				width: '100px'
			},
			{
				title: '分类',
				dataIndex: 'sort',
				key: 'sort',
				width: '100px'
			},
			{
				title: '内容',
				dataIndex: 'content',
				key: 'content',
				width: '300px'
			},
			{
				title: '关键字',
				dataIndex: 'keyword',
				key: 'keyword',
				width: '100px'
			},
			{
				title: '正负面',
				dataIndex: 'yuqing',
				key: 'yuqing',
				width: '100px'
			},
			{
				title: '日期',
				dataIndex: 'date',
				key: 'date',
				width: '120px'
			},
			{
				title: '热度',
				dataIndex: 'influence',
				key: 'influence',
				width: '100px'
			},
			// {
			// 	title: '操作',
			// 	key: 'actions',
			// 	render: (text, record) => (
			// 		<div>
			// 			<Button icon='eye' type='default' size='small' onClick={() => this.sourceDetailSet(record.zzjgdm, record.qymc)}>查看</Button>
			// 		</div>
			// 	)
			// }
		]
		
		return ( 
			<div>
				<div>
					<Card title="舆情信息">
						
						<FormItem label="关键字" {...formItemLayout}
							style={{ display: 'inline-block', width: 'calc( 40% - 12px )' }}
						>
							{
								getFieldDecorator('keyword', {
									initialValue: null,
									rules: [
										{
											required: false,
											message: '请输入搜索关键字',
										},
									],
								})(<Input placeholder='请输入搜索关键字（支持全字段搜索）'/>)
							}
						</FormItem>
						
						<FormItem
							style={{ display: 'inline-block', width: 'calc(10% - 12px)', marginLeft: '10px' }}
						>
							<Button icon='search' onClick={this.search} type='primary'>搜索</Button>
						</FormItem>
						
						<Table
							pagination={this.state.pagination}
							loading={this.state.loading}
							onChange={this.handleTableChange}
							columns={columns}
							dataSource={this.state.dataSource}
						></Table>
					</Card>
				</div>
			</div>
		)
	}
}
export default Form.create({ name: 'ecConsensus' })(ecConsensus);
//export default EcTashAdd;