import React from 'react';
import { Select } from 'antd';
import { DataTable } from '../../../components';

const Option = Select.Option;

export default ({ dispatch, total, list, loading }) => {
  const domain = 'suppUserModel';

  const tableProps = {
    scroll: { x: '100%', y: '100%' },
    domain,
    dispatch,
    loading,
    total,
    showEdit: false,
    showDelete: false,
    showAdd: false,
    dataSource: list,
    filter: [{
      title: '用户',
      dataIndex: 'userLike',
    }, {
      title: '状态',
      dataIndex: 'disabled',
      options: {
        initialValue: 0,
      },
      tag: <Select>
        <Option key={2} value={''}>全部</Option>
        <Option key={0} value={0}>有效</Option>
        <Option key={1} value={1}>无效</Option>
      </Select>,
    }],
    columns: [{
      title: '用户名称',
      dataIndex: 'name',
      width: '20%',
    }, {
      title: '企业编号',
      dataIndex: 'entCode',
      width: '15%',
    }, {
      title: '员工编号',
      dataIndex: 'empCode',
      width: '15%',
    }, {
      title: '邮箱',
      dataIndex: 'email',
      width: '15%',
    }, {
      title: '电话',
      dataIndex: 'phone',
      width: '15%',
    }, {
      title: '有效',
      dataIndex: 'deleteFlag',
      width: '10%',
      render: (value, record, index) => (value ? '否' : '是')
    }],
    buttons: [{
      key: 'updatePassword',
      type: 'primary',
      name: '修改密码',
      requiredSelected: 1,
      cb: (selectedKeys, selectedRows) => {
        dispatch({
          type: `users/showPWModal`,
          payload: {
            id: selectedKeys[0],
          },
        });
      }
    }],
  };


  return (
    <DataTable {...tableProps} />
  );
}
