import React from 'react';
import { Icon, Button, Spin, message, Table } from 'antd';
import ajax from 'jquery/src/ajax/xhr.js';
import $ from 'jquery/src/ajax';

const Star = React.createClass({
    loadData() {
        this.setState({
            loading: true
        });
        $.ajax({
            method: "get",
            dataType: "json",
            crossDomain: false,
            url: globalConfig.context + '',
            data: {
            },
            success: function (data) {
                let theArr = [];
            }.bind(this),
        }).always(function () {
            this.setState({
                loading: false
            });
        }.bind(this));
    },
    getInitialState() {
        return {
            loading: false,
            selectedRowKeys: [],
            selectedRows: [],
            columns: [
                {
                    title: '姓名',
                    dataIndex: 'name',
                    key: 'name',
                }, {
                    title: '从事领域',
                    dataIndex: 'field',
                    key: 'field',
                }, {
                    title: '职称名字',
                    dataIndex: 'keyword',
                    key: 'keyword',
                }, {
                    title: '工作单位',
                    dataIndex: 'unit',
                    key: 'unit',
                }
            ],
            dataSource: []
        };
    },
    componentWillMount() {
        this.loadData();
    },
    componentWillReceiveProps(nextProps) {
    },
    render() {
        const rowSelection = {
            selectedRowKeys: this.state.selectedRowKeys,
            onChange: (selectedRowKeys, selectedRows) => {
                this.setState({
                    selectedRows: selectedRows.slice(-1),
                    selectedRowKeys: selectedRowKeys.slice(-1)
                });
            }
        };
        const hasSelected = this.state.selectedRowKeys.length > 0;
        return (
            <div className="admin-content" >
                <div className="admin-content-title">科技明星管理</div>
                <div className="admin-content-warp">
                    <div>专家列表</div>
                    <div className="user-search">
                        <Input placeholder="编号"
                            value={this.state.searchNumber}
                            onChange={(e) => { this.setState({ searchNumber: e.target.value }); }} />
                        <Input placeholder="用户名"
                            value={this.state.username}
                            onChange={(e) => { this.setState({ username: e.target.value }); }} />
                        <Input placeholder="职称名字"
                            value={this.state.keyword}
                            onChange={(e) => { this.setState({ keyword: e.target.value }); }} />
                        <Input placeholder="工作单位"
                            value={this.state.searchName}
                            onChange={(e) => { this.setState({ searchName: e.target.value }); }} />
                        <Button type="primary" onClick={this.search}>搜索</Button>
                        <Button onClick={this.reset}>重置</Button>
                    </div>
                    <Spin spinning={this.state.loading}>
                        <Table columns={this.state.columns}
                            dataSource={this.state.dataSource}
                            pagination={this.state.pagination} />
                    </Spin>
                </div>
            </div >
        );
    }
});

export default Star;