// 发票类型维护
import React from 'react';
//import '../../assets/css/system.css';
import store from '../../store';
import {
    Modal, Form, InputNumber, Table, Input, Popconfirm, Row, Col, Button, Pagination, message, Divider, Spin, DatePicker, Select
} from 'antd';
import { $http } from '../../containers/config/https';
import './style/style.less';
import RangeDatePicker from 'components/rangePicker/index';
import CommonPagination from 'components/pagination/index';
import ColumnAuthoritysModel from 'pages/columnAuthority/ColumnAuthoritysModel';
// 主菜单弹框
const Option = Select.Option;
///import { CompositeDisposable } from 'rx';

class InvGrantMain extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            // 主菜单列表数据
            data: [],
            columns: [],
            // 抽屉显示
            visible: false,
            // 主菜单分页数据
            invTypeID: '',
            userID: '',
            userPurchID: '',
            prefixin: '',
            endDate: undefined,
            stDate: undefined,
            total: 0,
            page: 1,
            pageSize: 10,
            flag: '',
            title: '',
            invList: [],
            userList: [],
            dataPur: [],
            totaldataPur: 0,
            // 是否显示loading
            showLoading: true,
            // 表格loading
            loading: true,
            purchID: "",
            currentNoP: "",
            endNoP: "",
            prefixP: "",
            num: "",
            endNoGrant: "",
            currentNoGrant: "",
            useStatus: "",
            grantID: "",
            hospID: "",
            hospList: [],
            userPurchList: [],
            languageTable1: {}, // 国际化Table1
            languageTable2: {}, // 国际化Table2
            languageData: {}, // 国际化语言包
            language: {},   // 国际化语言
            languageCode: JSON.parse(window.sessionStorage.userData).language, // 国际化语言标识

            invIssuedModal: false,
        };
        {/*this.columns = [
            {
                title: '发票类型',
                dataIndex: 'InvTypeDesc',
                width: '150px',
                align: "center"
            },
            {
                title: '领取人',
                dataIndex: 'UseUseName',
                width: '150px',
                align: "center"
            },
            {
                title: '开始号码',
                dataIndex: 'StartNo',
                width: '150px',
                align: "center"
            },
            {
                title: '结束号码',
                dataIndex: 'EndNo',
                width: '150px',
                align: "center"
            },
            {
                title: '当前号码',
                dataIndex: 'CurrentNo',
                width: '150px',
                align: "center"
            },
            {
                title: '前缀',
                dataIndex: 'Prefix',
                width: '150px',
                align: "center"
            },
            {
                title: '可用',
                dataIndex: 'Avilable',
                width: '100px',
                align: "center"
            },
            {
                title: '发放人',
                dataIndex: 'GrantUserName',
                width: '100px',
                align: "center"
            },
            {
                title: '购入人',
                dataIndex: 'PurchUserName',
                width: '100px',
                align: "center"
            },
            {
                title: '医院',
                dataIndex: 'HospDesc',
                width: '150px',
                align: "center"
            },
            {
                title: '操作',
                dataIndex: 'operation',
                width: '100px',
                align: "center",
                render: (text,record) => (
                    <span> 
                       <Divider type="vertical" />
                        <Popconfirm title="回退发票，你确定退回给购入员吗?" onConfirm={this.handleDetele.bind(this, record)}  >
                            <span className='span' style={{color:record.RefFlag==="Y"?'#708090':'#0000FF'}}>回退发票</span>
                        </Popconfirm>
                    </span>
                )
            },
        ];*/}
    }




    //render 自定义项目名称
    listAdd = (i, j, languageCode) => {
        let { columns } = this.state
        columns.splice(i, j,
            {
                title: '操作',
                dataIndex: 'operation',
                width: '100px',
                align: "center",
                render: (text, record) => (
                    <span>
                        {/* <Divider type="vertical" /> */}
                        <div>
                            {record.RefFlag === "Y" ? <span className='span' style={{ color: '#ccc' }}>{languageCode === 'CN' ? "回退发票" : 'Rollback invoice'}</span> : <Popconfirm title={languageCode === 'CN' ? '回退发票，你确定退回给购入员吗?' : 'Are you sure to return the invoice?'} onConfirm={this.handleDetele.bind(this, record)}  >
                                <span className='span' style={{ color: '#1890ff' }}>{languageCode === 'CN' ? "回退发票" : 'Rollback invoice'}</span>
                            </Popconfirm>}

                        </div>
                    </span>
                )
            }
        )
    }
    onColumnRef = (ref) => {
        this.columnRef = ref;
    }
    // 获取主列表columns
    tableList = () => {
        var data = {
            params: [{
                "reactCode": ["grantList"],
                "compontName": "grantList",
                "type": "C"
            }]
        }
        $http.post('urlS', this, {
            code: '01040073',
            data: data,
            success: function (res) {
                if (+res.errorCode === 0) {
                    let resC = res.result.C
                    let { languageCode } = this.state
                    for (var i = 0; i < resC.length; i++) {
                        resC[i].key = i;
                    }
                    if (languageCode === "EN") {
                        resC.map((item, i) => {
                            item.title = item.enDescripts
                        })
                    }

                    if (languageCode === "CN") {
                        resC.map((item, i) => {
                            item.title = item.descripts
                        })
                    }
                    let arr = res.result && resC.length > 0 ? JSON.parse(JSON.stringify(resC)).map(item => {
                        return {
                            align: item.align,
                            widthNum: parseInt(item.width),
                            width: item.width,
                            dataIndex: item.dataIndex,
                            title: <div onDoubleClick={() => this.columnRef.onOpenModel()}>{item.title}</div>,
                            display: item.display,
                            key: item.seqNo
                        }
                    }) : '';
                    let filterArr = arr.filter(function (item) { return item.display === 'Y' });
                    this.setState({
                        columns: filterArr,
                        languageTable1: res.result.B || {},  // 国际化Table1
                        languageTable2: res.result.C || {},  // 国际化Table2
                        languageData: res.result.language || {},  // 国际化语言包
                    }, () => {
                        this.LanCNEN(this.state.languageCode)
                        this.listAdd(filterArr.length + 1, 0, languageCode);
                    })
                }
            }
        })
    }

    LanCNEN = (code) => {
        let { languageData } = this.state
        this.setState({
            language: languageData[code]
        })
    }




    // 删除
    handleDetele(record) {
        //获取sessionStorage的数据
        this.setState({ grantID: record.GrantID })
        let sessionInfo = window.sessionStorage.userData ? JSON.parse(window.sessionStorage.userData) : {};
        let data = {
            params: [{
                grantID: record.GrantID,
                updateUserID: sessionInfo.userID
            }]
        }
        $http.post('urlADS', this, {
            code: '05100062',
            data: data,
            success: function (res) {

                if (+res.errorCode === 0) {
                    message.success('回退发票号段成功');
                    // 刷新列表数据
                    this.handleQuery()
                }
            },
            error: function (error) {
                message.error('回退发票号段失败：' + error);
            }
        })
    }



    // 为了返回第一页
    handleQueryBack = () => {
        this.setState({
            page: 1,
            pageSize: 10,
        }, () => {
            console.log(17523);
            // 重新调用查询方法
            this.handleQuery();
        });

    }

    // 查询
    handleQuery = () => {
        let { invTypeID, userID, prefixin, endDate, stDate, page, useStatus, pageSize, userPurchID, hospID } = this.state;
        var stDateStr = stDate;
        var endDateStr = endDate;
        /* if(JSON.stringify(stDate) == "{}"||stDate===null){
             stDateStr="";
     
         }else{
             stDateStr=stDate.format('YYYY-MM-DD');
         }
     
         if(JSON.stringify(endDate) == "{}"||endDate===null){
             endDateStr="";
     
         }else{
             endDateStr=endDate.format('YYYY-MM-DD');
         }*/
        //获取sessionStorage的数据
        let sessionInfo = window.sessionStorage.userData ? JSON.parse(window.sessionStorage.userData) : {};
        let data = {}

        data = {
            params: [{
                invTypeID: invTypeID,
                userID: userID,
                endDate: endDateStr,
                userPurchID: userPurchID,
                stDate: stDateStr,
                prefix: prefixin,
                hospID: hospID,
                status: useStatus
            }],
            pagination: [{
                pageSize: pageSize,
                currentPage: page,
                sortColumn: "Code",
                sortOrder: "asc"
            }]
        }
        $http.post('urlS', this, {
            code: '05100051',
            data: data,
            success: function (res) {
                if (+res.errorCode === 0 && res.grant) {
                    for (var i = 0; i < res.grant.length; i++) {
                        res.grant[i].key = i;
                    }
                    this.setState({ data: res.grant, total: res.total, loading: false })
                }
                /*else {
                    setTimeout(() => {
                        this.setState({data: [], total: 0, loading: false})
                    }, 3000)
                }*/
            }
        })
    }


    // 查询条件 --- 类型
    onChangeInvTypeID = (value) => {

        this.setState({
            invTypeID: value,
            num: "",
            dataPur: [],
            totaldataPur: 0,
            purchID: "",
            currentNoP: "",
            endNoP: "",
            prefixP: "",
            endNoGrant: "",
            currentNoGrant: "",
            userList: [],
            userPurchList: []
        }, () => {
            if (value) {
                // 重新调用查询方法
                this.handleMinPurDataQuery();
                this.handleUserQuery();
                this.handlePurchUserQuery();
            }



        });

    }

    // 查询条件 --- 人员id
    onChangeUserID = (value) => {
        this.setState({ userID: value });
    }
    // 查询条件 --- gouru人员id
    onChangePurchUserID = (value) => {
        let { invTypeID } = this.state;
        this.setState({
            userPurchID: value,
            num: "",
            dataPur: [],
            totaldataPur: 0,
            purchID: "",
            currentNoP: "",
            endNoP: "",
            prefixP: "",
            endNoGrant: "",
            currentNoGrant: ""
        }, () => {
            if (invTypeID != "") {
                // 重新调用查询方法
                this.handleMinPurDataQuery();
            }



        });
    }
    onChangeStartNo = (e) => {

        this.setState({ currentNoP: e.target.value });
    }
    // 查询条件 ---前缀
    onChangeNum = (e) => {
        let { currentNoP } = this.state;
        if (currentNoP !== "") {
            let num = e.target.value;
            this.setState({ num: num }, () => {
                this.onPressEnter(num);
            });
        } else {
            message.error("请先选择有发票的发票类型");
        }
    }
    onPressEnter = (num) => {
        let { endNoGrant, currentNoGrant } = this.state;
        let data = {
            params: [{
                fStartNo: currentNoGrant,
                fEndNo: endNoGrant,
                num: num
            }]
        }
        if (num !== "") {
            $http.post('urlS', this, {
                code: '05100061',
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        let endNoPNow = res.endNo
                        this.setState({ endNoP: endNoPNow });
                    }
                }
            })
        } else { this.setState({ endNoP: endNoGrant }); }
    }

    // 查询条件 --- 开始日期
    onChangeUseStatus = (value) => {
        this.setState({ useStatus: value });
    }
    // 查询条件 ---前缀
    onChangePrefix = (e) => {
        this.setState({ prefixin: e.target.value });
    }

    // 查询条件 --- 开始日期
    onChangeStDate = (date) => {
        this.setState({ stDate: date });
    }
    // 查询条件 --- 结束日期
    onChangeEndDate = (date) => {
        this.setState({ endDate: date });
    }

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

    // 调用子组件的连接事件
    onRef = (ref) => {
        this.child = ref
    }

    // 重置userInfo
    resetFields = () => {
    }
    // table行样式
    setRowClassName = (record) => {
        return record.GrantID === this.state.grantID ? 'blueClass' : '';
    }




    // 查询发票类型下在使用或代用的最小的rowid发票号
    handleMinPurDataQuery = () => {
        let { invTypeID, page, userPurchID, hospID } = this.state;
        //获取sessionStorage的数据
        let sessionInfo = window.sessionStorage.userData ? JSON.parse(window.sessionStorage.userData) : {};
        let data = {}
        data = {
            params: [{
                hospID: hospID,
                invTypeID: invTypeID,
                userPurchID: userPurchID
            }],
            pagination: [{
                pageSize: 10,
                currentPage: page,
                sortColumn: "Code",
                sortOrder: "asc"
            }]
        }
        $http.post('urlS', this, {
            code: '05100048',
            data: data,
            success: function (res) {
                if (+res.errorCode === 0 && res.purChaseMin) {
                    this.setState({
                        dataPur: res.purChaseMin,
                        totaldataPur: res.purChaseMin.length,
                        loading: false,
                        purchID: res.purChaseMin[0].purchID,
                        currentNoP: res.purChaseMin[0].currentNo,
                        endNoP: res.purChaseMin[0].endNo,
                        prefixP: res.purChaseMin[0].prefix,
                        endNoGrant: res.purChaseMin[0].endNo,
                        currentNoGrant: res.purChaseMin[0].currentNo
                    })
                }
            }
        })
    }
    // 发票类型下拉框
    handleInvTypeQuery = () => {
        let data = {}
        data = {
            params: [{
                code: "",
                descripts: ""
            }]
        }
        $http.post('urlS', this, {
            code: '5001',
            data: data,
            success: function (res) {
                if (+res.errorCode === 0 && res.invType) {
                    let tempList = this.state.invList
                    for (var i = 0; i < res.invType.length; i++) {
                        tempList.push(<Option key={res.invType[i].ID}>{res.invType[i].Descripts}</Option>)
                    }
                    this.setState({
                        invList: tempList,
                        invReType: res.invType
                    })
                }
                /*else {
                    setTimeout(() => {
                        this.setState({ invList: [] })
                    }, 1000)
                }*/
            }
        })
    }
    // 人员下拉框
    handleUserQuery = () => {
        let { invTypeID, hospID } = this.state;
        //获取sessionStorage的数据
        let sessionInfo = window.sessionStorage.userData ? JSON.parse(window.sessionStorage.userData) : {};
        //obj.createUserDr =sessionInfo.userId;
        //obj.updateUserDr =sessionInfo.userId;
        //obj.hospDr=sessionInfo.hospDr;
        let data = {}
        data = {
            params: [{
                hospID: hospID,
                userType: "3",
                invTypeID: invTypeID
            }]
        }
        $http.post('urlS', this, {
            code: '05100053',
            data: data,
            success: function (res) {
                if (+res.errorCode === 0 && res.invUserInfo) {
                    let tempList = []
                    for (var i = 0; i < res.invUserInfo.length; i++) {
                        tempList.push(<Option key={res.invUserInfo[i].id} alias={res.invUserInfo[i].descriptsSPCode}>{res.invUserInfo[i].descripts}</Option>)
                    }
                    this.setState({
                        userList: tempList
                    })
                }
                /*else {
                    setTimeout(() => {
                        this.setState({userList: [] })
                    }, 1000)
                }*/
            }
        })
    }


    // 人员下拉框
    handlePurchUserQuery = () => {
        let { invTypeID, hospID } = this.state;
        //获取sessionStorage的数据
        let sessionInfo = window.sessionStorage.userData ? JSON.parse(window.sessionStorage.userData) : {};
        //obj.createUserDr =sessionInfo.userId;
        //obj.updateUserDr =sessionInfo.userId;
        //obj.hospDr=sessionInfo.hospDr;
        let data = {}
        data = {
            params: [{
                hospID: hospID,
                userType: "2",
                invTypeID: invTypeID
            }]
        }
        $http.post('urlS', this, {
            code: '05100053',
            data: data,
            success: function (res) {
                if (+res.errorCode === 0 && res.invUserInfo) {
                    let tempList = []
                    for (var i = 0; i < res.invUserInfo.length; i++) {
                        tempList.push(<Option key={res.invUserInfo[i].id} alias={res.invUserInfo[i].descriptsSPCode}>{res.invUserInfo[i].descripts}</Option>)
                    }
                    this.setState({
                        userPurchList: tempList
                    })
                }
                /*else {
                    setTimeout(() => {
                        this.setState({userList: [] })
                    }, 1000)
                }*/
            }
        })
    }

    ///输入框值变化时需要绑定
    onChangeHospID = (value) => {
        this.setState({ hospID: value, userList: [], userPurchList: [] }, () => {
            this.handlePurchUserQuery();
            this.handleUserQuery();
            this.handleQuery();
        });
    }
    //医院下拉框
    handleHospQuery = () => {
        let data = {}
        let sessionInfo = window.sessionStorage.userData ? JSON.parse(window.sessionStorage.userData) : {};
        data = {
            params: [{
                hospitalId: "",
                logonGroupID: sessionInfo.groupID,
                logonHospID: sessionInfo.hospID,
                hospRequired: "1",
            }]
        }
        $http.post('urlS', this, {
            code: '01040001',
            data: data,
            success: function (res) {
                if (+res.errorCode === 0 && res.depDoctor) {
                    let tempList = [];
                    for (var i = 0; i < res.depDoctor.length; i++) {
                        tempList.push(<Option key={res.depDoctor[i].id}>{res.depDoctor[i].descripts}</Option>)
                    }
                    this.setState({
						hospList: tempList
                    })
                }
            }
        })
    }
    componentDidMount() {
        let sessionInfo = window.sessionStorage.userData ? JSON.parse(window.sessionStorage.userData) : {};
        this.setState({ hospID: sessionInfo.hospID }, () => {
            // 初始化列表数据
            this.tableList();
            this.handleHospQuery();
            this.handleQuery();
            // 初始化设置table的高度以及表体的高度
            this.handleInvTypeQuery();
        });

        document.querySelector('.ant-table-body').style.height = store.getState().tableHeight.y + 'px';
        // 数据异步请求，请求成功之后setState
        this.setState({
            showLoading: false
        })
    }

    componentWillUnmount() {
        this.setState = (state, callback) => {
            return
        }
    }

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

    // 条数改变的回调
    apponShowSizeChange = (current, size) => {
        this.setState({
            page: current,
            pageSize: size,
        }, () => {
            // 重新调用查询方法
            this.handleQuery();
        });
    }

    handelFunction = () => {
        let msg = "增加";
        let { prefixP, purchID, userID, currentNoP, invTypeID, endNoP, page, hospID } = this.state;
        //获取sessionStorage的数据
        let sessionInfo = window.sessionStorage.userData ? JSON.parse(window.sessionStorage.userData) : {};
        //obj.createUserDr =sessionInfo.userId;
        //obj.updateUserDr =sessionInfo.userId;
        //obj.hospDr=sessionInfo.hospDr;
        let data = {}
        data = {
            params: [{
                useUserID: userID,
                invTypeID: invTypeID,
                startNo: currentNoP,
                endNo: endNoP,
                currentNo: currentNoP,
                avilable: "",
                prefix: prefixP,
                initDr: "",
                returnFlag: "",
                returnDate: "",
                returnTime: "",
                writeOffFlag: "",
                writeOffDate: "",
                writeOffTime: "",
                writeOffUserDr: "",
                grantUserID: sessionInfo.userID,
                hospID: hospID,
                purchID: purchID,
                createUserID: sessionInfo.userID,
                updateUserID: sessionInfo.userID
            }],
            pagination: [{
                pageSize: 10,
                currentPage: page,
                sortColumn: "Code",
                sortOrder: "asc"
            }]
        }
        $http.post('urlADS', this, {
            code: "05100050",
            data: data,
            success: function (res) {
                if (+res.errorCode === 0) {
                    // 提示
                    message.success(msg + '成功');
                    // 新增或编辑成功重置form表单
                    this.resetFields();
                    // 刷新列表数据
                    this.setState({
                        invTypeID: '',
                        userID: '',
                        prefixin: '',
                        endDate: undefined,
                        stDate: undefined,
                        purchID: "",
                        currentNoP: "",
                        endNoP: "",
                        num: "",
                        userID: ""
                    }, () => {
                        this.handleQueryBack();
                    });

                }
            },
            error: function (error) {
                message.error(msg + '失败：' + error);
            }
        })
    }

    //发票发放调用管理平台接口弹窗显示
    invIssuedShow = () => {
        this.setState({ invIssuedModal: true })
    }

    issuedCancel = () => {
        this.setState({ invIssuedModal: false })
    }

    invIssued = () => {
        this.props.form.validateFields((err, values) => {
            if (err) {
                return;
            }
            let { prefixP, purchID, userID, currentNoP, invTypeID, endNoP, page, hospID } = this.state;
            //获取sessionStorage的数据
            let sessionInfo = window.sessionStorage.userData ? JSON.parse(window.sessionStorage.userData) : {};
            let data = {}           //本地调用
            let dataTo = {}         //模拟调用方传参
            let dataResult = {}     //模拟调用方返回
            //未做base64的模拟参数
            dataTo = {
                appid: "7e7f4e61189145c1a5c2cce38a4219b3",  //调用方应用帐号，由平台提供
                data: {                                     //请求业务参数
                    placeCode: values.placeCode,            //开票点编码
                    operator: values.userID,                //领用人
                    remark: values.remark,                  //备注
                    billNoList: [{
                        billCode: values.billCode,                       //票据种类代码
                        billBatchCode: values.billBatchCode,             //票据代码
                        copyNum: values.copyNum,                         //份数
                        billBgnNo: values.billBgnNo,                     //票据起止号码
                        billEndNo: values.billEndNo                      //票据终止号码
                    }]

                },
                noise: "ibuaiVcKdpRxkhJAXXXX",              //请求随机标识，每次请求返回一个唯一编号，全局唯一（建议采用UUID）
                version: "1.0",                             //版本号
                sign: "E9324CF02F95CB072B6DBCEA33E725C3"    //签名
            }
            //未做base64的模拟返回结果，请求成功返回结果，请求方读取message参数中的内容做BASE64解码，读取解码结果
            dataResult = {
                result: "E0000",                            //除S0000表示成功标识，其它都为错误标识
                message: "成功",
                noise: "ibuaiVcKdpRxkhJAXXXX",              //请求随机标识，每次请求返回一个唯一编号，全局唯一（建议采用UUID）
                sign: "E9324CF02F95CB072B6DBCEA33E725C3"    //签名
            }
            
            data = {
                params: [{
                    useUserID: values.userID,
                    invTypeID: invType[0].ID || "",
                    startNo: values.billBgnNo,
                    endNo: values.billEndNo,
                    currentNo: values.billBgnNo,
                    avilable: "",
                    prefix: values.billBgnNo.replace(/-?[1-9]\d*/, ""),
                    initDr: "",
                    returnFlag: "",
                    returnDate: "",
                    returnTime: "",
                    writeOffFlag: "",
                    writeOffDate: "",
                    writeOffTime: "",
                    writeOffUserDr: "",
                    grantUserID: sessionInfo.userID,
                    hospID: hospID,
                    purchID: purchID,
                    createUserID: sessionInfo.userID,
                    updateUserID: sessionInfo.userID
                }],
                pagination: [{
                    pageSize: 10,
                    currentPage: page,
                    sortColumn: "Code",
                    sortOrder: "asc"
                }]
            }
            // $http.post('urlADS', this, {
            //     code: "05100050",
            //     data: data,
            //     success: function (res) {
            //         if (+res.errorCode === 0) {
            //             // 提示
            //             message.success(msg + '成功');
            //             // 新增或编辑成功重置form表单
            //             this.resetFields();
            //             // 刷新列表数据
            //             this.setState({
            //                 invTypeID: '',
            //                 userID: '',
            //                 prefixin: '',
            //                 endDate: undefined,
            //                 stDate: undefined,
            //                 purchID: "",
            //                 currentNoP: "",
            //                 endNoP: "",
            //                 num: "",
            //                 userID: ""
            //             }, () => {
            //                 this.handleQueryBack();
            //             });

            //         }
            //     },
            //     error: function (error) {
            //         message.error(msg + '失败：' + error);
            //     }
            // })
        })
    }

    render() {
        let { language } = this.state
        const { getFieldDecorator } = this.props.form;
        return (
            <Spin tip="加载中..." spinning={this.state.showLoading}>
                <div>
                    <div>
                        <div className="table-operations" style={{ minHeight: '50px', padding: '0 24px 10px 24px' }}>
                            <Row>
                                <Col span={24}>
                                    {language.grantListyy && language.grantListyy.descripts}：<Select
                                        showSearch
                                        allowClear
                                        placeholder="请输入"
                                        optionFilterProp="children"
                                        style={{ width: "150px", margin: '12px 15px 0 0' }}
                                        value={this.state.hospID}
                                        onChange={this.onChangeHospID}
                                        filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                                    >{this.state.hospList}</Select>
                                    {language.grantListfplx && language.grantListfplx.descripts}：<Select
                                        allowClear={true}
                                        showSearch
                                        placeholder="请输入"
                                        optionFilterProp="children"
                                        value={this.state.invTypeID}
                                        onChange={this.onChangeInvTypeID}
                                        style={{ width: '120px', margin: '12px 15px 0 0' }}
                                        filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                                    >{this.state.invList}</Select>
                                    {language.grantListlqry && language.grantListlqry.descripts}：<Select
                                        showSearch
                                        allowClear={true}
                                        placeholder="请输入"
                                        optionFilterProp="children"
                                        onChange={this.onChangePurchUserID}
                                        value={this.state.userPurchID}
                                        style={{ width: '120px', margin: '12px 15px 0 0' }}
                                        filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                                    >{this.state.userPurchList}</Select>
                                    {language.grantListfpzt && language.grantListfpzt.descripts}：<Select
                                        showSearch
                                        allowClear={true}
                                        placeholder="请输入"
                                        optionFilterProp="children"
                                        value={this.state.useStatus}
                                        style={{ width: '120px', margin: '12px 15px 0 0' }}
                                        onChange={this.onChangeUseStatus}
                                        filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                                    >
                                        <Option value="1">可用</Option>
                                        <Option value="2">待用</Option>
                                        <Option value="3">已用完</Option>
                                        <Option value="4">已退回</Option>
                                    </Select>
                                    {language.grantListfpqz && language.grantListfpqz.descripts}：<Input placeholder="请输入" value={this.state.prefixin} style={{ width: '120px', margin: '12px 15px 0 0' }} onChange={this.onChangePrefix} />
                                    <span style={{ display: 'inline-block', margin: '12px 15px 0 0' }}> <RangeDatePicker label={language.grantListgrrq && language.grantListgrrq.descripts} format='YYYY-MM-DD' width={260}
                                        startChange={this.onChangeStDate} endChange={this.onChangeEndDate} /></span>
                                    {/*开始日期: < DatePicker   style={{width: '150px', marginRight: '10px'}}  format="YYYY-MM-DD"  onChange={this.onChangeStDate} />
                                    结束日期：< DatePicker   style={{width: '150px', marginRight: '10px'}}  format="YYYY-MM-DD"  onChange={this.onChangeEndDate} />*/}
                                    <Button type="primary" style={{ margin: '12px 15px 0 0', }} className="margiRight16" onClick={this.handleQueryBack}>{language.grantListcx && language.grantListcx.descripts}</Button>

                                </Col>
                            </Row >

                            <Row  >
                                <Col>
                                    {language.grantListqshm && language.grantListqshm.descripts}：<Input placeholder="请输入" value={this.state.currentNoP} style={{ width: '120px', margin: '12px 15px 0 0' }} disabled={true}/*onChange={this.onChangeStartNo}*/ />
                                    {language.grantListxyzs && language.grantListxyzs.descripts}：<Input placeholder="请输入" value={this.state.num} style={{ width: '120px', margin: '12px 15px 0 0' }} onChange={this.onChangeNum}/*onPressEnter={this.onPressEnter}*/ />
                                    {language.grantListjshm && language.grantListjshm.descripts}：<Input placeholder="请输入" value={this.state.endNoP} style={{ width: '120px', margin: '12px 15px 0 0' }} disabled={true}/*onChange={this.onChangeEndNo}*/ />
                                    {language.grantListgrry && language.grantListgrry.descripts}：<Select
                                        showSearch
                                        allowClear={true}
                                        placeholder="请输入"
                                        optionFilterProp="children"
                                        onChange={this.onChangeUserID}
                                        value={this.state.userID}
                                        style={{ width: '120px', margin: '12px 15px 0 0' }}
                                        filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                                    >{this.state.userList}</Select>
                                    <Button type="primary" onClick={this.handelFunction} style={{ margin: '12px 15px 0 0', }} >{language.grantListxz && language.grantListxz.descripts}</Button>
                                    <Button type="primary" style={{ margin: '12px 15px 0 0', }} className="margiRight16" onClick={this.invIssuedShow}>发放</Button>
                                </Col>
                            </Row>
                        </div>
                        <div style={{ background: '#f0f2f5', height: '10px' }}></div>
                        <div style={{ padding: 24 }}>
                            <Table
                                style={{ height: store.getState().tableHeight.y + 65 + 'px' }}
                                dataSource={this.state.data}
                                columns={this.state.columns}
                                rowClassName={this.setRowClassName}
                                className='TableA'
                                //rowClassName="editable-row"
                                pagination={false}
                                scroll={{ x: 1000, y: store.getState().tableHeight.y }}
                                bordered
                                loading={this.state.loading}
                            />
                            <CommonPagination size="small" current={this.state.page} total={this.state.total} search='search'
                                onShowSizeChange={this.apponShowSizeChange} complete={true} dataSource={this.state.data}
                                onChange={this.appPageChange} />
                            <ColumnAuthoritysModel
                                clientWidth='800px'
                                compontName='grantList'
                                configType="C"
                                onRef={this.onColumnRef}
                                reloadData={this.tableList}
                            />
                            {/* 分页: total--总条数  defaultCurrent--默认的当前页 hideOnSinglePage--只有一页时隐藏分页器 
                            <Pagination
                                size="small"
                                showQuickJumper
                                showSizeChanger
                                defaultCurrent={1}
                                total={this.state.total}
                                onChange={this.onChange}
                                onShowSizeChange={this.onShowSizeChange}
                                style={{textAlign: "right", marginTop: '13px'}}
                            />*/}
                        </div>
                        <Form layout="vertical">
                            <Modal
                                visible={this.state.invIssuedModal}
                                title="库存发票发放"
                                okText="确定"
                                onCancel={this.issuedCancel}
                                onOk={this.invIssued}
                            >
                                <Form.Item label="开票点编码">
                                    {getFieldDecorator('placeCode', {
                                        initialValue: "",
                                        rules: [{ required: true, message: '请输入开票点编码' }]
                                    })(
                                        <Input />
                                    )}
                                </Form.Item>
                                <Form.Item label="领用人员">
                                    {getFieldDecorator('userID', {
                                        initialValue: undefined,
                                        rules: [{ required: true, message: '请选择领用人员' }]
                                    })(
                                        <Select
                                            style={{ width: "100%" }}
                                            showSearch
                                            placeholder="请选择购入人员"
                                            allowClear
                                        >{this.state.userList}</Select>
                                    )}
                                </Form.Item>
                                <Form.Item label="票据种类编码">
                                    {getFieldDecorator('billCode', {
                                        initialValue: undefined,
                                        rules: [{ required: true, message: '请输入票据种类编码' }]
                                    })(
                                        <Input placeholder="请输入票据种类编码" />
                                    )}
                                </Form.Item>
                                <Form.Item label="份数">
                                    {getFieldDecorator('copyNum', {
                                        initialValue: 0,
                                        rules: [{ required: true, message: '请输入份数' }]
                                    })(
                                        <InputNumber min={0} />
                                    )}
                                </Form.Item>
                                <Form.Item label="票据代码">
                                    {getFieldDecorator('billBatchCode', {
                                        initialValue: undefined,
                                        rules: [{ required: true, message: '请选择票据代码' }]
                                    })(
                                        <Select
                                            style={{ width: "100%" }}
                                            showSearch
                                            placeholder="请选择票据代码"
                                            allowClear
                                        >
                                            <Option value="I" key="01">住院发票</Option>
                                            <Option value="O" key="02">门诊发票</Option>
                                            <Option value="R" key="06">挂号发票</Option>
                                        </Select>
                                    )}
                                </Form.Item>
                                <Form.Item label="票据起止号码">
                                    {getFieldDecorator('billBgnNo', {
                                        initialValue: undefined,
                                        rules: [{ required: true, message: '请输入票据起止号码' }]
                                    })(
                                        <Input placeholder="请输入票据起止号码" />
                                    )}
                                </Form.Item>
                                <Form.Item label="票据终止号码">
                                    {getFieldDecorator('billEndNo', {
                                        initialValue: undefined,
                                        rules: [{ required: true, message: '请输入票据终止号码' }]
                                    })(
                                        <Input placeholder="请输入票据终止号码" />
                                    )}
                                </Form.Item>
                                <Form.Item label="备注">
                                    {getFieldDecorator('remark', {
                                        initialValue: ""
                                    })(
                                        <Input />
                                    )}
                                </Form.Item>
                            </Modal>
                        </Form>
                    </div>
                </div>
            </Spin>
        );
    }
}

const InvGrantMainForm = Form.create()(InvGrantMain);
export default InvGrantMainForm;