import { PureComponent, Fragment } from 'react';
import { DownOutlined, SearchOutlined, EditOutlined, DeleteOutlined, PlusOutlined } from '@ant-design/icons';
import { history, connect } from 'umi';

import {
    Card,
    Button,
    Dropdown,
    Menu,
    message,
    DatePicker,
    Divider,
    Popconfirm,
    Tooltip
} from 'antd';

import { initTreeSelect } from '@/utils/globalCommon'
import { XQ, AE, AX, _09, AB, OR, BG, AT, HC, OC, OD, RF, X4 } from '@/utils/pr_new_datadictionary';
import Aa01CreateForm from './form/Aa01CreateForm'; //新增表单
import Aa01UpdateForm from './form/Aa01UpdateForm'; //修改表单
import Aa01ViewForm from './form/Aa01ViewForm'; //查看表单
import Aa01RenderSimpleForm from './form/Aa01RenderSimpleForm'; //简单查询表单
import Aa01RenderAdvancedForm from './form/Aa01RenderAdvancedForm'; //高级查询表单
import {formatDate,formartDateObject} from '@/utils/formatUtils'


import StandardTable from '@/components/StandardTable';

import style from '@/global.less';
import styles from './index.less';

const { RangePicker } = DatePicker;


/* eslint react/no-multi-comp:0 */
@connect(({ baseinfodata, loading }) => ({
    baseinfodata,
    loading: loading.models.baseinfodata,
}))
class Aa01Table extends PureComponent {

    state = {
        modalVisible: false,
        updateModalVisible: false,
        viewModalVisible: false,
        expandForm: false,
        selectedRows: [],
        formValues: {},
        updateFormValues: {},
        viewFormValues: {},
    };

    columns = [
        // {
        //     title: 'ID主键',
        //     dataIndex: 'id',
        //     key: 'id',
        // },
        {
            title: '工号',
            dataIndex: 'gh',
            key: 'gh',
            width: 100,
            fixed: 'left'
        },
        {
            title: '姓名',
            dataIndex: 'za0101',
            key: 'za0101',
            width: 80,
            fixed: 'left',
        },
        {
            title: '性别',
            dataIndex: 'aa0107',
            key: 'aa0107',
            render: val => {
                const list = AX || [];
                if (val) {
                    return (
                        <Tooltip title={initTreeSelect(list, val)}>
                            <span className={style.nowrapper} style={{ width: '150px' }}>
                                {initTreeSelect(list, val)}</span>
                        </Tooltip>
                    )
                }
            }
        },
        {
            title: '手机',
            dataIndex: 'ak010b',
            key: 'ak010b',
        },
        {
            title: '电话',
            dataIndex: 'ak010i',
            key: 'ak010i',
        },

        {
            title: '年龄',
            dataIndex: 'ae0141',
            key: 'ae0141',
        },
        {
            title: '助记码',
            dataIndex: 'zjm',
            key: 'zjm',
        },
        {
            title: '公司',
            dataIndex: 'gs',
            key: 'gs',
        },
        {
            title: '部门',
            dataIndex: 'v_aa011c',
            key: 'v_aa011c',
        },
        {
            title: '职位',
            dataIndex: 'zw',
            key: 'zw',
        },
        {
            title: '职称',
            dataIndex: 'zc',
            key: 'zc',
        },
        {
            title: '险种',
            dataIndex: 'xz',
            key: 'xz',
        },
        {
            title: '身份证',
            dataIndex: 'aa0177',
            key: 'aa0177',
        },
        {
            title: '考勤卡号',
            dataIndex: 'kqkh',
            key: 'kqkh',
        },
        {
            title: '学历',
            dataIndex: 'xl',
            key: 'xl',
        },
        {
            title: '婚姻状况',
            dataIndex: 'aa0127',
            key: 'aa0127',
            render: val => {
                const list = BG || [];
                if (val) {
                    return (
                        <Tooltip title={initTreeSelect(list, val)}>
                            <span className={style.nowrapper} style={{ width: '150px' }}>
                                {initTreeSelect(list, val)}</span>
                        </Tooltip>
                    )
                }
            }
        },
        {
            title: '员工密码',
            dataIndex: 'ygmm',
            key: 'ygmm',
        },
        {
            title: '确认密码',
            dataIndex: 'qrmm',
            key: 'qrmm',
        },
        {
            title: '学位',
            dataIndex: 'xw',
            key: 'xw',
        },
        {
            title: '籍贯',
            dataIndex: 'aa0114',
            key: 'aa0114',
            render: val => {
                const list = AB || [];
                if (val) {
                    return (
                        <Tooltip title={initTreeSelect(list, val)}>
                            <span className={style.nowrapper} style={{ width: '150px' }}>
                                {initTreeSelect(list, val)}</span>
                        </Tooltip>
                    )
                }
            }
        },
        {
            title: '出生日期',
            dataIndex: 'aa0111',
            key: 'aa0111',
        },
        {
            title: '民族',
            dataIndex: 'aa0121',
            key: 'aa0121',
            render: val => {
                const list = AE || [];
                if (val) {
                    return (
                        <Tooltip title={initTreeSelect(list, val)}>
                            <span className={style.nowrapper} style={{ width: '150px' }}>
                                {initTreeSelect(list, val)}</span>
                        </Tooltip>
                    )
                }
            }
        },
        {
            title: '政治面貌',
            dataIndex: 'aa2205',
            key: 'aa2205',
            render: val => {
                const list = AT || [];
                if (val) {
                    return (
                        <Tooltip title={initTreeSelect(list, val)}>
                            <span className={style.nowrapper} style={{ width: '150px' }}>
                                {initTreeSelect(list, val)}</span>
                        </Tooltip>
                    )
                }
            }
        },
        {
            title: '类别',
            dataIndex: 'lb',
            key: 'lb',
        },
        {
            title: '毕业学校',
            dataIndex: 'byxx',
            key: 'byxx',
        },
        {
            title: '所学专业',
            dataIndex: 'sxzy',
            key: 'sxzy',
        },
        {
            title: '毕业日期',
            dataIndex: 'byrq',
            key: 'byrq',
        },
        {
            title: '基本工资',
            dataIndex: 'jbgz',
            key: 'jbgz',
        },
        {
            title: '家庭住址',
            dataIndex: 'ak010n',
            key: 'ak010n',
        },
        {
            title: '户口地址',
            dataIndex: 'ak010m',
            key: 'ak010m',
        },
        {
            title: '微信账号',
            dataIndex: 'wxzh',
            key: 'wxzh',
        },
        {
            title: '档案地址',
            dataIndex: 'dadz',
            key: 'dadz',
        },
        {
            title: '联系人',
            dataIndex: 'lxr',
            key: 'lxr',
        },
        {
            title: '联系人电话',
            dataIndex: 'lxrdh',
            key: 'lxrdh',
        },
        {
            title: '紧急联系人',
            dataIndex: 'ae010m',
            key: 'ae010m',
        },
        {
            title: '紧急联系人电话',
            dataIndex: 'ai0102',
            key: 'ai0102',
            width: 120
        },
        {
            title: '招聘专员',
            dataIndex: 'zpzy',
            key: 'zpzy',
        },
        {
            title: '入职日期',
            dataIndex: 'rzrq',
            key: 'rzrq',
        },
        {
            title: '上岗日期',
            dataIndex: 'sgrq',
            key: 'sgrq',
        },
        {
            title: '工作场所',
            dataIndex: 'gzcs',
            key: 'gzcs',
        },
        {
            title: '个人爱好',
            dataIndex: 'grah',
            key: 'grah',
        },
        {
            title: '工作日期',
            dataIndex: 'gzrq',
            key: 'gzrq',
        },
        {
            title: '职称日期',
            dataIndex: 'zcrq',
            key: 'zcrq',
        },

        {
            title: '工作电话',
            dataIndex: 'gzdh',
            key: 'gzdh',
        },
        {
            title: 'QQ账号',
            dataIndex: 'qqzh',
            key: 'qqzh',
        },
        {
            title: '合同开始',
            dataIndex: 'htks',
            key: 'htks',
        },
        {
            title: '合同结束',
            dataIndex: 'htks',
            key: 'htks',
        },
        {
            title: '实习开始',
            dataIndex: 'sxks',
            key: 'sxks',
        },
        {
            title: '实习结束',
            dataIndex: 'sxjs',
            key: 'sxjs',
        },
        {
            title: '试用开始',
            dataIndex: 'syks',
            key: 'syks',
        },
        {
            title: '试用结束',
            dataIndex: 'syjs',
            key: 'syjs',
        },
        {
            title: '单位工龄',
            dataIndex: 'aa0101',
            key: 'aa0101',
        },
        {
            title: '人员类别',
            dataIndex: 'aa010d',
            key: 'aa010d',
            render: val => {
                const list = OR || [];
                if (val) {
                    return (
                        <Tooltip title={initTreeSelect(list, val)}>
                            <span className={style.nowrapper} style={{ width: '150px' }}>
                                {initTreeSelect(list, val)}</span>
                        </Tooltip>
                    )
                }
            }
        },
        {
            title: '合同类别',
            dataIndex: 'htlb',
            key: 'htlb',
        },
        {
            title: '招聘来源',
            dataIndex: 'zply',
            key: 'zply',
        },
        {
            title: '部门岗位',
            dataIndex: 'bmgw',
            key: 'bmgw',
        },
        {
            title: '岗位级别',
            dataIndex: 'gwjb',
            key: 'gwjb',
        },
        {
            title: '员工状态',
            dataIndex: 'ygzt',
            key: 'ygzt',
        },
        {
            title: '邮箱',
            dataIndex: 'yx',
            key: 'yx',
        },
        {
            title: '出生地',
            dataIndex: 'aa0117',
            key: 'aa0117',
            render: val => {
                const list = AB || [];
                if (val) {
                    return (
                        <Tooltip title={initTreeSelect(list, val)}>
                            <span className={style.nowrapper} style={{ width: '150px' }}>
                                {initTreeSelect(list, val)}</span>
                        </Tooltip>
                    )
                }
            }
        },
        {
            title: '离职方式',
            dataIndex: 'lzfs',
            key: 'lzfs',
        },
        {
            title: '离职原因',
            dataIndex: 'lzyy',
            key: 'lzyy',
        },
        {
            title: '货币编码',
            dataIndex: 'aa0115',
            key: 'aa0115',
        },
        {
            title: '参加工作日期',
            dataIndex: 'aa0141',
            key: 'aa0141',
        },
        {
            title: '工资类别',
            dataIndex: 'aa5510',
            key: 'aa5510',
            render: val => {
                const list = HC || [];
                if (val) {
                    return (
                        <Tooltip title={initTreeSelect(list, val)}>
                            <span className={style.nowrapper} style={{ width: '150px' }}>
                                {initTreeSelect(list, val)}</span>
                        </Tooltip>
                    )
                }
            }
        },
        {
            title: '扣税标准',
            dataIndex: 'ksbz',
            key: 'ksbz',
        },
        {
            title: '进入本单位日期',
            dataIndex: 'aa0144',
            key: 'aa0144',
            width: 120
        },

        {
            title: '工龄',
            dataIndex: 'aa0151',
            key: 'aa0151',
        },
        {
            title: '开户银行',
            dataIndex: 'khyh',
            key: 'khyh',
        },
        {
            title: '工资账号',
            dataIndex: 'ak010e',
            key: 'ak010e',
        },
        {
            title: '港澳台及外籍人士',
            dataIndex: 'aa0181',
            key: 'aa0181',
            width: 130,
            render: val => {
                const list = OC || [];
                if (val) {
                    return (
                        <Tooltip title={initTreeSelect(list, val)}>
                            <span className={style.nowrapper} style={{ width: '150px' }}>
                                {initTreeSelect(list, val)}</span>
                        </Tooltip>
                    )
                }
            }
        },
        {
            title: '参加党派时间',
            dataIndex: 'cjdpsj',
            key: 'cjdpsj',
        },
        {
            title: '养老账号',
            dataIndex: 'ylzh',
            key: 'ylzh',
        },
        {
            title: '医保账号',
            dataIndex: 'ybzh',
            key: 'ybzh',
        },
        {
            title: '单位',
            dataIndex: 'ab0111',
            key: 'ab0111',
        },
        {
            title: '下属部门',
            dataIndex: 'ab0112',
            key: 'ab0112',
        },
        {
            title: '失业账号',
            dataIndex: 'syzh',
            key: 'syzh',
        },
        {
            title: '公积金账号',
            dataIndex: 'gjjzh',
            key: 'gjjzh',
        },
        {
            title: '特长',
            dataIndex: 'ae0103',
            key: 'ae0103',
        },
        {
            title: '减员时间',
            dataIndex: 'ae0112',
            key: 'ae0112',
        },
        {
            title: '有效证件类别',
            dataIndex: 'ae0117',
            key: 'ae0117',
            render: val => {
                const list = OD || [];
                if (val) {
                    return (
                        <Tooltip title={initTreeSelect(list, val)}>
                            <span className={style.nowrapper} style={{ width: '150px' }}>
                                {initTreeSelect(list, val)}</span>
                        </Tooltip>
                    )
                }
            }
        },
        {
            title: '成本类别',
            dataIndex: 'ak010a',
            key: 'ak010a',
            render: val => {
                const list = X4 || [];
                if (val) {
                    return (
                        <Tooltip title={initTreeSelect(list, val)}>
                            <span className={style.nowrapper} style={{ width: '150px' }}>
                                {initTreeSelect(list, val)}</span>
                        </Tooltip>
                    )
                }
            }
        },
        {
            title: '工资卡状态',
            dataIndex: 'ak010k',
            key: 'ak010k',
        },
        {
            title: '连续工龄',
            dataIndex: 'ak010o',
            key: 'ak010o',
        },
        {
            title: '工资卡发放状态',
            dataIndex: 'ak010j',
            key: 'ak010j',
            width: 120
        },
        {
            title: '备注',
            dataIndex: 'aa0108',
            key: 'aa0108',
        },
        // {
        //     title: '照片',
        //     dataIndex: 'za9998',
        //     key: 'za9998',
        // },
        {
            title: '操作',
            width: 220,
            fixed: 'right',
            render: (text, record) => (
                <Fragment>
                    <a onClick={() => this.handleViewModalVisible(true, record)}> <SearchOutlined style={{ color: '#00FFFF' }} />查看 </a>
                    <Divider type="vertical" />
                    <a onClick={() => this.handleUpdateModalVisible(true, record)}> <EditOutlined style={{ color: '#FF4500' }} />编辑 </a>
                    <Divider type="vertical" />
                    <Popconfirm title="你确定要删除吗?" okText="确定" cancelText="取消" onConfirm={() => this.handleDeleteRecord(record)} >
                        <a href={"javascript"} > <DeleteOutlined style={{ color: '#40E0D0' }} /> 删除</a>
                    </Popconfirm>
                </Fragment>
            ),
        },
    ];


    componentDidMount() {
        const { dispatch } = this.props;
        dispatch({
            type: 'baseinfodata/query_page_for_aa01',
        });
    }



    handleStandardTableChange = (pagination, filtersArg, sorter) => {

        const { dispatch } = this.props;
        const { formValues } = this.state;

        const params = {
            currentPage: pagination.current,
            pageSize: pagination.pageSize,
            ...formValues,
        };

        if (sorter.field) {
            params.sorter = `${sorter.field}_${sorter.order}`;
        }

        dispatch({
            type: 'baseinfodata/query_page_for_aa01',
            payload: params,
        });


    };

    previewItem = record => {
        const id = record.id;
        //history.push(`/baseinfodata/basic/${id}{id}`);
    };

    handleFormReset = () => {
        const { dispatch } = this.props;
        this.setState({
            formValues: {},
        });
        dispatch({
            type: 'baseinfodata/query_page_for_aa01',
            payload: {},
        });

    };

    toggleForm = () => {

        const { expandForm } = this.state;
        this.setState({
            expandForm: !expandForm,
        });
    };



    handleSelectRows = rows => {
        this.setState({
            selectedRows: rows,
        });
        const { getChildrenMsg } = this.props;
        if(getChildrenMsg){
            getChildrenMsg(rows);
        }
    };

    handleSearch = values => {
        const { dispatch } = this.props;
        this.setState({
            formValues: values,
        });

        dispatch({
            type: 'baseinfodata/query_page_for_aa01',
            payload: values,
        });

    };




    handleModalVisible = flag => {
        this.setState({
            modalVisible: !!flag,
        });
    };

    handleUpdateModalVisible = (flag, record) => {
        this.setState({
            updateModalVisible: !!flag,
            updateFormValues: record || {},
        });
    };

    handleViewModalVisible = (flag, record) => {

        this.setState({
            viewModalVisible: !!flag,
            viewFormValues: record || {},
        });

    };

    handleAdd = (fields, form, loading) => {
        const { dispatch } = this.props;
        if(!!fields.imageFile){
            const formData = new FormData()
            formData.append('file', fields.imageFile)
            dispatch({
                type: 'baseinfodata/upload_single_file',
                payload: formData,
                callback: ({ success, datarecord}) => {
                    if(success){
                        fields.za9998 = datarecord.id
                        this.handleFormData(fields, form, loading)
                    }else{
                        message.error('上传图片失败')
                    }
                }
            })
        }else{
            this.handleFormData(fields, form, loading)
        }
    };

    handleFormData = (fields, form, loading) => {
        const { dispatch } = this.props
        dispatch({
            type: 'baseinfodata/insert_for_aa01',
            payload: {
                id: fields.id,//ID主键
                gh: fields.gh,    //工号，
                za0101: fields.za0101,    //姓名,
                aa0107: fields.aa0107,    //性别,
                za9998: fields.za9998,    //照片,
                ak010b: fields.ak010b,    //手机,
                ak010i: fields.ak010i,    //电话,
                ae0141: fields.ae0141,    //年龄,
                zjm: fields.zjm,    //助记码,
                gs: fields.gs,    //公司,
                bm: fields.bm,    //部门,
                zw: fields.zw,    //职位,
                zc: fields.zc,    //职称,
                xz: fields.xz,    //险种,
                aa0177: fields.aa0177,    //身份证,
                kqkh: fields.kqkh,    //考勤卡号,
                xl: fields.xl,    //学历,
                aa0127: fields.aa0127,    //婚姻状况,
                ygmm: fields.ygmm,    //员工密码,
                qrmm: fields.qrmm,    //确认密码,
                xw: fields.xw,    //学位,
                aa0114: fields.aa0114,    //籍贯,
                aa0111: formatDate(fields.aa0111,"YYYY-MM-DD HH:mm:ss"),    //出生日期,
                aa0121: fields.aa0121,    //民族,
                aa2205: fields.aa2205,    //政治面貌,
                lb: fields.lb,    //类别,
                byxx: fields.byxx,    //毕业学校,
                sxzy: fields.sxzy,    //所学专业,
                byrq: fields.byrq,    //毕业日期,
                jbgz: fields.jbgz,    //基本工资,
                ak010n: fields.ak010n,    //家庭住址,
                ak010m: fields.ak010m,    //户口地址,
                wxzh: fields.wxzh,    //微信账号,
                dadz: fields.dadz,    //档案地址,
                lxr: fields.lxr,    //联系人,
                lxrdh: fields.lxrdh,    //联系人电话,
                ae010m: fields.ae010m,    //紧急联系人,
                ai0102: fields.ai0102,    //紧急联系人电话,
                zpzy: fields.zpzy,    //招聘专员
                rzrq: fields.rzrq,    //入职日期
                sgrq: fields.sgrq,    //上岗日期
                gzcs: fields.gzcs,    //工作场所
                grah: fields.grah,    //个人爱好
                gzrq: fields.gzrq,    //工作日期
                zcrq: fields.zcrq,    //职称日期
                gzdh: fields.gzdh,    //工作电话
                qqzh: fields.qqzh,    //QQ账号
                htks: fields.htks,    //合同开始
                htjs: fields.htjs,    //合同结束
                sxks: fields.sxks,    //实习开始
                sxjs: fields.sxjs,    //实习结束
                syks: fields.syks,    //试用开始
                syjs: fields.syjs,    //试用结束
                aa0101: fields.aa0101,    //单位工龄
                aa010d: fields.aa010d,    //人员类别
                htlb: fields.htlb,    //合同类别
                zply: fields.zply,    //招聘来源
                bmgw: fields.bmgw,    //部门岗位
                gwjb: fields.gwjb,    //岗位级别
                ygzt: fields.ygzt,    //员工状态
                lzrq: fields.lzrq,    //离职日期
                yx: fields.yx,    //邮箱
                aa0117: fields.aa0117,    //出生地
                lzfs: fields.lzfs,    //离职方式
                lzyy: fields.lzyy,    //离职原因
                aa0115: fields.aa0115,    //货币编码
                aa0141: fields.aa0141,    //参加工作日期
                aa5510: fields.aa5510,    //工资类别
                ksbz: fields.ksbz,    //扣税标准
                aa0144: fields.aa0144,    //进入本单位日期
                aa0151: fields.aa0151,    //工龄
                khyh: fields.khyh,    //开户银行
                ak010e: fields.ak010e,    //工资账号
                aa0181: fields.aa0181,    //港澳台及外籍人士
                cjdpsj: fields.cjdpsj,    //参加党派时间
                ylzh: fields.ylzh,    //养老账号
                ybzh: fields.ybzh,    //医保账号
                ab0111: fields.ab0111,    //单位
                ab0112: fields.ab0112,    //下属部门
                syzh: fields.syzh,    //失业账号
                gjjzh: fields.gjjzh,    //公积金账号
                ae0103: fields.ae0103,    //特长
                ae0112: fields.ae0112,    //减员时间
                ae0117: fields.ae0117,    //有效证件类别
                ak010a: fields.ak010a,    //成本类别
                ak010k: fields.ak010k,    //工资卡状态
                ak010o: fields.ak010o,    //连续工龄
                ak010j: fields.ak010j,    //工资卡发放状态
                aa0108: fields.aa0108,    //备注
            },
            callback: (res) => {
                loading(false);
                if (res.success == true) {
                    message.success('添加成功');
                    form.resetFields();
                    this.handleModalVisible();
                }else{
                    loading(false);
                }
            }
        });
    }


    handleDeleteRecord = record => {

        const { dispatch } = this.props;

        dispatch({
            type: 'baseinfodata/delete_by_primarykey_for_aa01',
            payload: {
                recordid: record.id,
            },
            callback: () => {
                this.setState({
                    selectedRows: [],
                });
            },
        });

        message.success('删除成功');


    };

    handleUpdate = (fields, form, loading) => {

        const { dispatch } = this.props;
        if(!!fields.imageFile){
            const formData = new FormData()
            formData.append('file', fields.imageFile)
            dispatch({
                type: 'baseinfodata/upload_single_file',
                payload: formData,
                callback: ({ success, datarecord}) => {
                    if(success){
                        fields.za9998 = datarecord.id
                        this.handleUpdateData(fields, form, loading)
                    }else{
                        message.error('上传图片失败')
                    }
                }
            })
        }else{
            this.handleUpdateData(fields, form, loading)
        }
    };

    handleUpdateData = (fields, form, loading) => {
        const { dispatch } = this.props
        dispatch({
            type: 'baseinfodata/update_for_aa01',
            payload: {
                id: fields.id,//ID主键
                gh: fields.gh,    //工号，
                za0101: fields.za0101,    //姓名,
                aa0107: fields.aa0107,    //性别,
                za9998: fields.za9998,    //照片,
                ak010b: fields.ak010b,    //手机,
                ak010i: fields.ak010i,    //电话,
                ae0141: fields.ae0141,    //年龄,
                zjm: fields.zjm,    //助记码,
                gs: fields.gs,    //公司,
                bm: fields.bm,    //部门,
                zw: fields.zw,    //职位,
                zc: fields.zc,    //职称,
                xz: fields.xz,    //险种,
                aa0177: fields.aa0177,    //身份证,
                kqkh: fields.kqkh,    //考勤卡号,
                xl: fields.xl,    //学历,
                aa0127: fields.aa0127,    //婚姻状况,
                ygmm: fields.ygmm,    //员工密码,
                qrmm: fields.qrmm,    //确认密码,
                xw: fields.xw,    //学位,
                aa0114: fields.aa0114,    //籍贯,
                aa0111: fields.aa0111,    //出生日期,
                aa0121: fields.aa0121,    //民族,
                aa2205: fields.aa2205,    //政治面貌,
                lb: fields.lb,    //类别,
                byxx: fields.byxx,    //毕业学校,
                sxzy: fields.sxzy,    //所学专业,
                byrq: fields.byrq,    //毕业日期,
                jbgz: fields.jbgz,    //基本工资,
                ak010n: fields.ak010n,    //家庭住址,
                ak010m: fields.ak010m,    //户口地址,
                wxzh: fields.wxzh,    //微信账号,
                dadz: fields.dadz,    //档案地址,
                lxr: fields.lxr,    //联系人,
                lxrdh: fields.lxrdh,    //联系人电话,
                ae010m: fields.ae010m,    //紧急联系人,
                ai0102: fields.ai0102,    //紧急联系人电话,
                zpzy: fields.zpzy,    //招聘专员
                rzrq: fields.rzrq,    //入职日期
                sgrq: fields.sgrq,    //上岗日期
                gzcs: fields.gzcs,    //工作场所
                grah: fields.grah,    //个人爱好
                gzrq: fields.gzrq,    //工作日期
                zcrq: fields.zcrq,    //职称日期
                gzdh: fields.gzdh,    //工作电话
                qqzh: fields.qqzh,    //QQ账号
                htks: fields.htks,    //合同开始
                htjs: fields.htjs,    //合同结束
                sxks: fields.sxks,    //实习开始
                sxjs: fields.sxjs,    //实习结束
                syks: fields.syks,    //试用开始
                syjs: fields.syjs,    //试用结束
                aa0101: fields.aa0101,    //单位工龄
                aa010d: fields.aa010d,    //人员类别
                htlb: fields.htlb,    //合同类别
                zply: fields.zply,    //招聘来源
                bmgw: fields.bmgw,    //部门岗位
                gwjb: fields.gwjb,    //岗位级别
                ygzt: fields.ygzt,    //员工状态
                lzrq: fields.lzrq,    //离职日期
                yx: fields.yx,    //邮箱
                aa0117: fields.aa0117,    //出生地
                lzfs: fields.lzfs,    //离职方式
                lzyy: fields.lzyy,    //离职原因
                aa0115: fields.aa0115,    //货币编码
                aa0141: fields.aa0141,    //参加工作日期
                aa5510: fields.aa5510,    //工资类别
                ksbz: fields.ksbz,    //扣税标准
                aa0144: fields.aa0144,    //进入本单位日期
                aa0151: fields.aa0151,    //工龄
                khyh: fields.khyh,    //开户银行
                ak010e: fields.ak010e,    //工资账号
                aa0181: fields.aa0181,    //港澳台及外籍人士
                cjdpsj: fields.cjdpsj,    //参加党派时间
                ylzh: fields.ylzh,    //养老账号
                ybzh: fields.ybzh,    //医保账号
                ab0111: fields.ab0111,    //单位
                ab0112: fields.ab0112,    //下属部门
                syzh: fields.syzh,    //失业账号
                gjjzh: fields.gjjzh,    //公积金账号
                ae0103: fields.ae0103,    //特长
                ae0112: fields.ae0112,    //减员时间
                ae0117: fields.ae0117,    //有效证件类别
                ak010a: fields.ak010a,    //成本类别
                ak010k: fields.ak010k,    //工资卡状态
                ak010o: fields.ak010o,    //连续工龄
                ak010j: fields.ak010j,    //工资卡发放状态
                aa0108: fields.aa0108,    //备注
                fileId: fields?.fileId ?? '',
                filePath: fields?.filePath ?? '',
            },
            callback: (res) => {
                loading(false);
                if (res.success == true) {
                    message.success('修改成功');
                    form.resetFields();
                    this.handleUpdateModalVisible();
                }else{
                    loading(false)
                }
            }
        });
    }

    renderSimpleForm() {

        const parentMethods = {
            handleSearch: this.handleSearch,
            handleFormReset: this.handleFormReset,
            toggleForm: this.toggleForm,
            submitButtons: styles.submitButtons,
        };

        return (

            <Aa01RenderSimpleForm {...parentMethods} />

        );

    }



    renderAdvancedForm() {

        const parentMethods = {
            handleSearch: this.handleSearch,
            handleFormReset: this.handleFormReset,
            toggleForm: this.toggleForm,
        };

        return (

            <Aa01RenderAdvancedForm  {...parentMethods} />
        );

    }

    renderForm() {
        const { expandForm } = this.state;
        return expandForm ? this.renderAdvancedForm() : this.renderSimpleForm();
    }

    render() {

        const {
            baseinfodata: { data },
            loading,
        } = this.props;


        const { selectedRows, modalVisible, updateModalVisible, viewModalVisible, updateFormValues, viewFormValues } = this.state;
        const menu = (
            <Menu onClick={this.handleMenuClick} selectedKeys={[]}>
                <Menu.Item key="remove">删除</Menu.Item>
                <Menu.Item key="approval">批量审批</Menu.Item>
            </Menu>
        );
        const parentMethods = {
            handleAdd: this.handleAdd,
            handleModalVisible: this.handleModalVisible,
        };
        const updateMethods = {
            handleUpdateModalVisible: this.handleUpdateModalVisible,
            handleUpdate: this.handleUpdate,
        };
        const viewMethods = {
            handleViewModalVisible: this.handleViewModalVisible
        };
        return (

            <>
                <Card bordered={false}>
                    <div className={styles.aa01tableList}>

                        <div className={styles.aa01tableListForm}>{this.renderForm()}</div>


                        <div className={styles.aa01tableListOperator}>

                            <Button type="primary" onClick={() => this.handleModalVisible(true)}>
                                <PlusOutlined /> 新建
                            </Button>
                            {selectedRows.length > 0 && (
                                <span>
                                    <Button>批量操作</Button>
                                    <Dropdown overlay={menu}>
                                        <Button>
                                            更多操作 <DownOutlined />
                                        </Button>
                                    </Dropdown>
                                </span>
                            )}
                        </div>

                        <StandardTable
                            rowKey={"id"}
                            selectedRows={selectedRows}
                            loading={loading}
                            data={data}
                            columns={this.columns}
                            scroll={{ x: 9500 }}
                            onSelectRow={this.handleSelectRows}
                            onChange={this.handleStandardTableChange}
                        />
                    </div>
                </Card>

                <Aa01CreateForm {...parentMethods} modalVisible={modalVisible} />


                {updateFormValues && Object.keys(updateFormValues).length ? (
                    <Aa01UpdateForm
                        {...updateMethods}
                        updateModalVisible={updateModalVisible}
                        values={updateFormValues}
                    />
                ) : null}


                {viewFormValues && Object.keys(viewFormValues).length ? (
                    <Aa01ViewForm
                        {...viewMethods}
                        viewModalVisible={viewModalVisible}
                        values={viewFormValues}
                    />
                ) : null}

            </>

        );
    }
}


export default Aa01Table;

