import React from 'react';
import { Table } from 'antd';
// import { $http } from '../../../containers/config/https';
// import DepartmentFindModel from './DepartmentFindModel.jsx';
// import DepartmentFindAdd from './DepartmentFindAdd'
import store from '../../../store';
import CommonPagination from 'components/pagination/index';

export default class DepartmentFindAddTabel extends React.Component {
	constructor(props) {
		super(props);
		this.state = {
			loading: true,
			// 主菜单分页数据
			total: 0,
			page: 1,
			pageSize: 10,
			flag: '',
			title: '',
			size: 'small',
		};
	}
	componentDidMount() {
		this.setState({ loading: false });
		const locDr = this.props.locID;
		if (locDr !== '') {
			// 初始化列表数据
			//this.handleQuery();
		}
	}

	// 显示分页总条数
	showTotal(total) {
		return `共 ${total} 条`;
	}

	// 页码改变的回调，参数是改变后的页码及每页条数
	onChange = (page, pageSize) => {
		this.setState({ page: page, pageSize: pageSize }, () => {
			// 重新调用查询方法
			this.props.changePages(page, pageSize);
		});

	}

	onShowSizeChange = (current, size) => {
		this.setState({ page: 1, pageSize: size }, () => {
			// 重新调用查询方法
			this.props.changePages(1, size);
		})


	}
	libraryOnRef = (ref) => {
		this.libraryChild = ref
	}

	render() {
		const { selectedRowKeys } = this.state;
		// const rowSelection = {
		// 	selectedRowKeys,
		// 	onChange: this.onSelectChange,
		// }
		return (
			<div style={{ padding: '12px' }}>
				{/* <div style={{marginBottom:"15px"}}> */}
				{/* <a href="javascript:;"  onClick={() => this.setState({ visible_department: true })} style={{display:'inline-block',color:'green',borderBottom:'1px solid green',marginLeft:'20px'}}>设置固定费用</a> */}
				{/* </div>  */}
				<Table
					style={{ height: store.getState().tableHeight.y - 30 + 'px' }}
					dataSource={this.props.data ? this.props.data : []}
					columns={this.props.columns}
					rowKey={(row) => {
						return row.id
					}}
					pagination={false}
					scroll={{ x: 1000, y: store.getState().tableHeight.y - 80 }}
					bordered
					loading={this.state.loading}
				//	rowSelection={rowSelection}
				/>
				<CommonPagination
					size={this.state.size}
					current={this.state.page}
					total={this.props.param.total}
					search={this.state.search}
					onShowSizeChange={this.onShowSizeChange.bind(this)}
					complete={true}
					dataSource={this.props.data}
					loading={this.state.loading} onChange={this.onChange.bind(this)} />

			</div>
		)
	}

}

