// 病人账户管理
import React from 'react';
import moment from 'moment';
import { Select, Input, Row, Col, Button, Card, message, Icon, Form, Table, Modal } from 'antd';
import { Util } from 'tools/index';
import { $http } from 'containers/config/https';
import { $loadTemplate } from '../../lodop/Common/Print.js';
import { Keup, ArraySome, dayFormat } from '../../../tools/index';
import store from '../../../store';
import TipHeader from './component/TipHeader'
import HopNumber from './component/HopNumber'
import FindPatients from 'pages/registercard/FindPatients';
import RangeDatePicker from 'components/rangePicker/index';
import CommonPagination from 'components/pagination/index';
import ReadCard from '../../../components/readcard/ReadCard';
import ColumnAuthoritysModel from 'pages/columnAuthority/ColumnAuthoritysModel';

import avatarFemale from 'assets/images/avatar_female.png';
import avatarMale from 'assets/images/avatar_male.png';
import './style/style.less'

// 组件const
const { Option } = Select;
const icon_name = require('assets/images/img/icon_name.png');
const icon_gender = require('assets/images/img/icon_gender.png');
const icon_expense = require('assets/images/img/icon_expense.png');
// const icon_icon = require('assets/images/img/icon_icon.png');
const { Search } = Input;
const formItemLayout = {    // label 和input宽度
    labelCol: { span: 8 },
    wrapperCol: { span: 14, offset: 2 },
};
let user;
class PatientAccountManagement extends React.Component {
    constructor(props) {
        super(props)
        var date = new Date()
        user = window.sessionStorage.userData ? JSON.parse(window.sessionStorage.userData) : {};
        let userData = JSON.parse(sessionStorage.getItem('userData'));
        this.state = {
            depositType: window.sessionStorage.accountType ? window.sessionStorage.accountType : '',
            dataPatChar: [], //账户管理table数据
            tableData: [], // 账户管理table数据
            cardTypeData: [], // 卡类型
            cardType: '', // 卡类型
            userInfo: {},
            patNo: '', // 登记号
            cardNo: '', // 卡号
            cardType: '', // 卡类型
            // 表格数据
            // 表格数据总条数
            total: 0,
            showLoading: true,
            page: 1,
            pageSize: 10,
            subAccManagementID: '',
            findFlag: '4',
            endDate: moment(date).format(dayFormat),
            startDate: moment().subtract(2, 'days').format(dayFormat),
            doType: '4',
            modalShow: false,
            modalShowNumber: false,
            modalPayTitle: '',
            payButtonNum: 0,
            modalType: '',
            accmanID: '',							//账户ID
            patID: '',						//Pat_Dr 病人ID
            accAbleReturn: 0,
            accBlance: 0,
            accDPAllPayAmt: 0,
            accStatusDesc: '—',
            accTSubIDL: '',
            modalWidth: '600px',
            otherPayData: [],
            payotherID: '', //支付方式ID 充值
            rechargeMoney: '', //缴款金额 缴款金额
            rechargeReceipts: '', // 实收
            rechargeGive: '0.00', // 找零
            rechargeMark: '',  //备注 保存备注信息(支票号、银行卡(号)等) 充值
            reasonsRefundType: '', // 退费原因
            reasonsRefundData: [], // 退费原因
            refundAmount: '',// 提交 退款金额
            refundChannel: '', // 提交 退款渠道
            refundRemarks: '', //  退费备注
            refundGive: '0.00', // 退款找零

            originaPassword: '',
            confirmPassword: '', //输入确认密码
            newPassword: '', //输入新密码
            IsSame: false, //是否显示新密码与确认密码一致信息标志

            languageTable1: {}, // 国际化Table1
            languageTable2: {}, // 国际化Table2
            languageData: {}, // 国际化语言包
            language: {},   // 国际化语言
            languageCode: JSON.parse(window.sessionStorage.userData).language, // 国际化语言标识
            columns: [],
            readModeI: true,
            readModeR: true,
            accDID: '',
            invoice: '', // 发票
            accPurpose: [], // 账户用途
            accPurposeCode: undefined,// 用途代码
            purposeBlance: '', //用途余额
            // accPurposeID: undefined,   // 账户用途ID
            admList: [],        // 就诊列表
            admID: '',
            ifAdmFlag: '',      // 是否按就诊计算
            templateCode: '',   // 打印模板
            allAccoutBalance: 0,
        }

        // 就诊咯i额表table
        this.admListColums = [{
            title: '就诊时间',
            dataIndex: 'admDateTime',
            key: '1',
            align: "center",
            width: 80,
        }, {
            title: '就诊科室',
            dataIndex: 'admLocDesc',
            key: '2',
            align: "center",
            width: 80,
        }]
    }

    componentDidMount() {
        if (this.props && this.props.onRef) {
            this.props.onRef(this)
        }
        this.tableList();
        this.cardTypeList() //卡类型
        this.reasonsRefund() //退费原因
        // 数据加载成功关闭loading
        //this.child.handleLoading()
        if (this.props.number && this.props.number != '') {
            this.setState({
                patNo: this.props.number || ''
            }, () => {
                this.searchUser()  //查询
            })
        }
        let { depositType } = this.state;
        if (!depositType) {
            if (this.props.location) {
                if (this.props.location.state) {
                    depositType = this.props.location.state.AcountType ? this.props.location.state.AcountType : "O";
                    window.sessionStorage.setItem('accountType', depositType)
                }
            }
            if (this.props.typeCinFlage) {
                depositType = this.props.typeCinFlage ? this.props.typeCinFlage : 'O'
            }
        }
        this.setState({
            depositType: depositType,
            templateCode: depositType == 'I' ? 'AdvancePayment' : 'OAdvancePayment'
        }, () => {
            this.getAccPurPoseSelectData(); // 用途下拉数据
            this.initJuris(); //权限
        })
        // else {
        //     if (this.props.paras) {
        //         depositType = this.props.paras.depositType ? this.props.paras.depositType : "";
        //     } else {
        //         accountType = window.sessionStorage.getItem('accountType')
        //         if (accountType) {
        //             depositType = accountType
        //         }else{
        //             depositType = this.props.depositType ? this.props.depositType : "";
        //         }

        //     }
        // }
        // if (depositType === "") return

        document.querySelector('.ant-table-body').style.height = store.getState().tableHeight.y + 180 + 'px';
        document.getElementById("patInfo").focus();
    }

    // 获取账户用途下拉数据
    getAccPurPoseSelectData = () => {
        let data = {
            params: [{
                "type": this.props.typeCinFlage ? 'I' : this.state.depositType ? this.state.depositType : 'O'
            }]
        }
        $http.post('urlS', this, {
            code: '05100355',
            data: data,
            success: function (res) {
                if (+res.errorCode === 0) {
                    let accPurpose = res.result.data;
                    let defaultPurpose = res.result.defaultCode
                    let defaultIfAdmFlag = res.result.defaultIfAdmFlag
                    this.setState({ accPurpose, accPurposeCode: defaultPurpose, ifAdmFlag: defaultIfAdmFlag })
                }
            }
        })
    }

    // 账户用途修改
    onPurposeChange = (val, opt) => {
        // let { accmanID, admID } = this.state;
        if (val) {
            this.setState({
                accPurposeCode: val,
                refundAmount: '',
                refundGive: '0.00',
                ifAdmFlag: opt.props.ifAdmFlag
            }, () => {
                this.getPurposeBlance();
            })
        } else {
            this.setState({
                accPurposeCode: '',
                refundAmount: '',
                refundGive: '0.00',
                ifAdmFlag: '',
                purposeBlance: '0.00'
            })
        }
    }

    // 获取账户用途金额
    getPurposeBlance = () => {
        let { accmanID, accPurposeCode, admID } = this.state
        console.log("getPurposeBlance", 1232131)
        let data = {
            params: [{
                accmanID: accmanID,
                puposeCode: accPurposeCode,
                admID: admID
            }]
        }

        $http.post('urlADS', this, {
            code: "03040039",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (+errorCode === 0) {
                    this.setState({
                        purposeBlance: res.purposeBlance,
                        accBlance: res.purposeBlance.toFixed(2),
                        allAccoutBalance: res.allAccoutBalance
                    })
                }
            }
        });
    }

    // 获取就诊列表数据
    getAdmList = (patNo) => {
        if (this.state.ifAdmFlag != "Y") {
            return
        }
        let data = {
            params: [{
                hospID: user.hospID,
                locID: user.locID,
                patNo: patNo,
                startDate: this.state.startDate,
                stopDate: this.state.endDate,
                admType: this.props.typeCinFlage ? 'I' : this.state.depositType ? this.state.depositType : 'O'
            }]
        }
        $http.post('urlDeault', this, {
            code: "04080006",
            data: data,
            success: (res) => {
                if (+res.errorCode === 0) {
                    if (res.result.admList.length > 0) {
                        let admID = res.result.admList[0].admID;
                        this.setState({
                            patNo: res.result.baseInfo.patNo,
                            admList: res.result.admList,
                            admID: admID,
                        }, () => {
                            this.handleQuery() // 查询
                        })
                    }

                } else {
                    this.setState({
                        admList: [],
                        admID: '',
                    })
                }
            }
        })
    }

    /* 设置input获得焦点 */
    setInputFocus = (currentInput) => {
        let { input } = currentInput;
        input.focus();
    }

    onColumnRef = (ref) => {
        this.columnRef = ref;
    }

    // 获取主列表columns
    tableList = (reactCode, compontName) => {
        var data = {
            params: [{
                "reactCode": ["PatientAccountManagement"],
                "compontName": "PatientAccountManagement",
                "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)
                    })
                }
            }
        })
    }

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

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

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

    //退费原因
    reasonsRefund = () => {
        var data = {
            params: [{
                "typeCode": "RefundInv"
            }]
        }

        $http.post('urlS', this, {
            code: "05210011",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (+errorCode === 0) {
                    this.setState({
                        reasonsRefundData: res.reason,  // 退费原因
                    });
                }
            }
        });
    }

    // 权限
    initJuris = () => {
        let { depositType } = this.state;
        let data = {
            params: [{
                logonHospID: JSON.parse(window.sessionStorage.userData).hospID, //医院id
                logonGroupID: JSON.parse(window.sessionStorage.userData).groupID,  //角色id
                logonUserID: JSON.parse(window.sessionStorage.userData).userID, //人员id
                invTypeCode: depositType == 'I' ? "IP" : this.props.location && this.props.location.state && this.props.location.state.depositType === 'I' ? 'IP' : 'OP',   // 类型
            }]
        }
        $http.post('urlS', this, {
            code: "05210001",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (+errorCode === 0) {
                    let ChargeFlag = res.groupConfig.IfDEPChargeFlag;
                    let otherPayData = [];
                    let payotherID = '';
                    if (this.state.depositType == "I") {
                        otherPayData = res.groupConfig.HBOPConfigPaymode[0].IPPre || [];  // 其他付款方式
                    } else {
                        otherPayData = res.groupConfig.HBOPConfigPaymode[0].OPPre || [];  // 其他付款方式
                    }
                    if (otherPayData && Array.isArray(otherPayData) && otherPayData.length > 0) { // 默认支付方式 - 先取后台默认的default，后台没默认前端默认第一个
                        payotherID = Util.returnDataCccordingToAttributes(otherPayData, 'Y', 'default')?.paywID || otherPayData[0]?.paywID || '';
                    }
                    this.setState({
                        payotherID,
                        otherPayData, // 支付方式下拉数据
                        invoice: res.currentInvNoInfo,  // 发票号
                    });
                    if (ChargeFlag === 'Y') {
                        if (res.groupConfig.IfDEPInvNo === 'Y' && res.currentInvNoInfo.split('^')[0] !== '0') {
                            message.error('该收费员无发票号')
                        }
                    } else {
                        message.error('无收费权限')
                        this.setState({
                            disabledInput: true,  // 收费权限
                        });
                    }
                }
            }
        });
    }

    // 读卡 --- 根据卡号取病人信息
    handleReadCard = (value, event) => {
        let { readModeI, readModeR, cardType } = this.state
        if (event.keyCode) {
            if (readModeI) {
                this.searchUser('cardNo'); // 重新调用查询接口
            }
            return false
        }
        if (readModeR) {
            this.readCard.ReadCard(cardType, "R", (json) => {
                let patNo = json && json.patInfo ? json.patInfo.patNo : ''
                this.setState({ patNo, cardNo: json.cardNo }, () => {

                    //this.searchUser('cardNo'); // 重新调用查询接口
                    if (patNo) {
                        this.searchUser('patNo'); // 重新调用查询接口
                    } else {
                        this.searchUser('cardNo'); // 重新调用查询接口
                    }
                })
            })
        }
    }

    // // 回车读卡 --- 根据卡号取病人信息
    // handleReadCarddownE = (e, type) => {
    //     if (e.keyCode === 13) {

    //         this.searchUser('cardNo') // 读卡 --- 根据卡号取病人信息
    //     }
    // }

    // 读卡
    searchUser = (type) => {
        var data;
        let { cardType, cardNo, patNo, cardTypeData } = this.state
        if (!type) {   // 查询全部
            data = {
                params: [{
                    "number": patNo || '', // 登记号/身份证号
                    "cardTypeID": cardType,   //卡类型id
                    "cardNo": cardNo,    //卡号
                }]
            }
        }

        if (type === 'patNo') {
            data = {
                params: [{
                    "number": patNo || '', // 登记号/身份证号
                    "cardTypeID": "",   //卡类型id
                    "cardNo": "",    //卡号
                }]
            }

            if (patNo === '') {
                return false
            }
        }

        if (type === 'cardNo') {
            data = {
                params: [{
                    "number": '', // 登记号/身份证号
                    "cardTypeID": cardType || '',     //卡类型id
                    "cardNo": cardNo || '', //卡号
                }]
            }

            if (cardNo === '') {
                return false
            }
            if (cardType === '') {
                message.error('请选择卡类型')
                return false
            }

            let cardTypeFilter = cardTypeData.filter(function (item) {
                return item.id == cardType;
            })

            let zeroLength = cardTypeFilter[0].cardLength

            if (zeroLength && zeroLength != '' && parseFloat(zeroLength) != 0) {
                this.setState({
                    cardNo: ArraySome.addPreZero(cardNo, zeroLength)
                })
                data = {
                    params: [{
                        "number": '', // 登记号/身份证号
                        "cardTypeID": cardType || '',     //卡类型id
                        "cardNo": ArraySome.addPreZero(cardNo, zeroLength) || '', //卡号
                    }]
                }
            }
        }

        $http.post('urlS', this, {
            code: "03040004",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (+errorCode === 0) {
                    this.setState({
                        userInfo: res.data || [],  // 用户数据
                        subAccManagementID: res.data.accTSubID || '',
                        accmanID: res.data.accTSubID.split('||')[0],//账户ID
                        patID: res.data.patID || '',						//Pat_Dr 病人ID
                        accTSubID: res.data.accTSubID || '',
                    }, () => {
                        this.getAdmList(res.data.patNo);
                        this.handleQuery();
                    });

                } else {
                    this.setState({
                        userInfo: [],  // 用户数据
                        subAccManagementID: '',
                        accmanID: '',//账户ID
                        patID: '',						//Pat_Dr 病人ID
                        accTSubID: '',
                        tableData: [],
                        total: 0
                    });
                    message.error(res.errorMessage)
                }
            }
        });
    }

    // 回车查询登记号
    patNodownE = (e, type) => {
        if (e.keyCode === 13) {
            // this.searchUser(type);
            this.getPatientData(type);
        }
    }

    // 请求列表数据
    getPatientData = (type) => {
        let { patNo } = this.state;
        if (!patNo) return;
        let data = {
            params: [{
                number: patNo,
            }],
            pagination: [{
                pageSize: 100,
                currentPage: 1,
            }]
        }
        $http.post('urlS', this, {
            code: '03030004',
            data: data,
            success: function (res) {
                if (res.errorCode === '0') {
                    let patData = res.result?.Data || [];
                    if (patData && patData.length === 1) {
                        let patInfo = patData[0];
                        this.setState({ patNo: patInfo?.patNo || '' }, () => {
                            this.searchUser(type);
                        });
                    } else if (patData && patData.length > 1) {
                        this.findPatientsRef && this.findPatientsRef.showModal();
                        this.findPatientsRef && this.findPatientsRef.setValue(patNo);
                    } else {
                        message.error('未查询到患者信息。')
                    }
                }
            },
            error: function (error) {
                console.log(error)
            }
        })
    }

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

    //卡类型
    cardTypeList = () => {
        var data = {
            params: [{
                hospID: JSON.parse(window.sessionStorage.userData).hospID, //医院id
            }]
        }
        $http.post('urlS', this, {
            code: "01040059",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (+errorCode === 0) {
                    let cardDeffault = res.cardType.filter((item) => {
                        return item.defaultFlag === 'Y';
                    })
                    this.setState({
                        cardType: cardDeffault[0].id, // 默认卡
                        cardTypeData: res.cardType,  // 用户数据

                    }, () => {
                        this.CardTypeChange(this.state.cardType)
                    });
                }
            }
        });
    }

    // 查询条件 --- 类型·
    cardType = (e) => {
        this.setState({ cardType: e }, () => {
            this.CardTypeChange(e)
        });
    }

    // 查询条件 --- 卡号
    cardNo = (e) => {
        let { readModeI } = this.state
        if (!readModeI) {
            return false
        }
        this.setState({ cardNo: e.target.value });
    }

    // Card
    CardTypeChange = (e) => {
        if (!e) {
            return false
        }
        let { cardTypeData } = this.state
        let readMode = cardTypeData.filter((item, i) => {
            return item.id == e;
        })

        switch (readMode[0] && readMode[0].readMode) {
            // 只可input
            case 'I':
                this.setState({
                    readModeI: true,
                    readModeR: false,
                    cardNo: "",

                })
                break;
            // 只可读卡
            case 'R':
                this.setState({
                    readModeR: true,
                    readModeI: false,
                    cardNo: "",
                })
                break;
            // 皆可
            default:
                this.setState({
                    readModeI: true,
                    readModeR: true,
                    cardNo: "",
                })
                break;
        }
    }

    // 查询条件 --- 登记号
    patNo = (e) => {
        this.setState({ patNo: e.target.value });
    }

    // 查询条件 --- 操作类型
    doType = (e) => {
        this.setState({ findFlag: e }, () => {
            this.handleQuery() //查询
        });
    }

    // 提交 充值金额
    rechargeMoney = (e) => {
        if (e.target.value) {
            this.setState({ rechargeMoney: Keup.MoneyReplace(e.target.value), rechargeReceipts: Keup.MoneyReplace(e.target.value) });
        } else {
            this.setState({ rechargeMoney: undefined, rechargeReceipts: Keup.MoneyReplace(e.target.value) });
        }
    }

    // 提交 备注
    rechargeMark = (e) => {
        this.setState({ rechargeMark: e.target.value });
    }

    // 提交 实收
    rechargeReceipts = (e) => {
        let val = Keup.MoneyReplace(e.target.value)
        // let { rechargeMoney } = this.state
        this.setState({ rechargeReceipts: val });

        // if (parseFloat(Keup.MoneyReplace(val)) > parseFloat(rechargeMoney)) {
        //     this.setState({
        //         rechargeGive: parseFloat(parseFloat(Keup.MoneyReplace(val)) - parseFloat(rechargeMoney)).toFixed(2)// 找零
        //     })

        // } else {
        //     this.setState({
        //         rechargeGive: '0.00', // 找零
        //     })
        // }
    }

    // 提交 退款金额
    refundAmount = (e) => {
        let val = Keup.MoneyReplace(e.target.value)
        let { accAbleReturn, purposeBlance } = this.state
        if (!accAbleReturn) {
            message.error('无可退金额')
            return false
        }
        if (parseFloat(Keup.MoneyReplace(val)) > parseFloat(purposeBlance)) {
            message.error('申请退款金额不能大于可退金额')
            return false
        }

        if (parseFloat(Keup.MoneyReplace(val)) < parseFloat(accAbleReturn)) {
            this.setState({
                refundGive: parseFloat(parseFloat(accAbleReturn) - parseFloat(Keup.MoneyReplace(val))).toFixed(2)    // 退款找零
            })

        } else {
            this.setState({
                refundGive: '0.00', // 退款找零
            })
        }

        this.setState({ refundAmount: val });
    }

    // 梭哈全部退款
    whole = () => {
        let { purposeBlance } = this.state
        this.setState({ refundAmount: purposeBlance, refundGive: '0.00', });
    }

    // 提交 退款渠道
    refundChannel = (e) => {
        this.setState({ refundChannel: e });
    }

    //  退费原因
    reasonsRefundType = (e) => {
        this.setState({ reasonsRefundType: e });
    }

    //  退费备注
    refundRemarks = (e) => {
        this.setState({ refundRemarks: e.target.value });
    }

    // 查询
    handleQuery = () => {
        let { page, pageSize, subAccManagementID, findFlag, startDate, endDate, patNo, depositType } = this.state;
        // if ((!subAccManagementID || subAccManagementID === '') && (patNo === '' || !patNo)) {
        //     message.error('请输入查询内容')
        //     return false
        // }
        let data = {
            params: [{
                subAccManagementID: subAccManagementID,
                findFlag: findFlag,
                startDate: startDate,
                endDate: endDate,
                accountType: depositType
            }],
            pagination: [{
                pageSize: pageSize,
                currentPage: page,
            }]
        };
        $http.post('urlS', this, {
            code: "05210019",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (+errorCode === 0) {
                    for (var i = 0; i < res.accDPInfo.length; i++) {
                        res.accDPInfo[i].key = i;
                    }
                    this.setState({
                        accDID: '',
                        tableData: res.accDPInfo,
                        total: res.totalCount,
                        accDPAllPayAmt: res.accDPAllPayAmt.toFixed(2),
                        accAbleReturn: res.accAbleReturn.toFixed(2),
                        accStatusDesc: res.accStatusDesc,
                    }, () => this.getPurposeBlance())
                } else {
                    this.setState({
                        accDID: '',
                        tableData: [],
                        total: 0
                    })
                }
            }
        });
        // 数据加载成功关闭loading
        //this.child.handleLoading()
    }

    // 时间
    onChangeTime = (date, dateString) => {
        this.setState({
            startDate: dateString[0],    //开始日期
            endDate: dateString[1],  //结束日期
        })
    }

    startChange(date) {
        this.setState({
            startDate: date,
        })
    }

    endChange(date) {
        this.setState({
            endDate: date,
        })
    }

    //密码设置二次弹框加载
    changeModalType(e) {
        this.setState({
            modalType: e,
            originaPassword: '',
            confirmPassword: '', //输入确认密码
            newPassword: '', //输入新密码
            IsSame: false, //是否显示新密码与确认密码一致信息标志
        })
    }

    //弹框打开
    modal = (type) => {
        if (!this.state.patID || this.state.patID === '') {
            message.error(this.state.languageCode === "CN" ? '无病人数据' : 'No Patient Data')
            return false
        }
        if (type == '0' || type == '3') {
            if (!this.state.accPurposeCode) {
                message.error(this.state.languageCode === "CN" ? '请先选择用途' : 'Please select purpose')
                return false
            }
            if (this.state.admID === '' && this.state.ifAdmFlag == 'Y') {
                message.error(this.state.languageCode === "CN" ? '无就诊信息' : 'No Patient Data')
                return false
            }
        }
        let { modalPayTitle } = this.state
        switch (type) {
            case '0':
                modalPayTitle = this.state.languageCode === "CN" ? '充值' : "Charge"
                break;
            case '1':
                modalPayTitle = this.state.languageCode === "CN" ? '请确认病人身份，选择设置类型' : "Please confirm the patient's identity and choose the type of setting"
                break;
            case '2':
                modalPayTitle = this.state.languageCode === "CN" ? '补打凭条' : "Reprint the receipt"
                break;
            case '3':
                modalPayTitle = this.state.languageCode === "CN" ? '设置退款金额' : "Set refund amount"
                break;
            case '4':
                modalPayTitle = this.state.languageCode === "CN" ? '确认取消冻结' : "Confirm unfreeze"
                break;
            default:
                break;
        }
        this.setState({
            modalShow: true,
            payButtonNum: 1,
            modalPayTitle,
            // modalPayTitle: this.state.languageCode === "CN" ? '身份验证' : 'Authentication',
            modalType: type
        }, () => {
            if (type == 0) {
                // document.getElementById('rechargeMoney-input').focus()
                // this.money.focus()
            }
            if (type == 3) {
                // document.getElementById('refundAmount-input').focus()
            }
        })
        // , () => {
        //     // 渲染速度慢 无法按时准确识别this指向属性 加个延时器
        //     setTimeout(() => {
        //         this.setInputFocus(this.pwd);   // 获取光标
        //     }, 100);
        // }
    }

    //弹框取消
    handleCancel = () => {
        this.clearn() // 清空
    }

    // 清空
    clearn = () => {
        this.props.form.resetFields();
        this.setState({
            modalShow: false,
            modalShowNumber: false,
            payButtonNum: 0,
            modalType: '',
            rechargeMoney: '', //缴款金额 缴款金额
            rechargeReceipts: '', // 实收
            rechargeGive: '0.00', // 找零
            payotherID: '', //支付方式ID 充值
            rechargeMark: '',  //备注 保存备注信息(支票号、银行卡(号)等) 充值
            refundAmount: '',// 提交 退款金额
            refundChannel: '', // 提交 退款渠道
            refundRemarks: '', //  退费备注
            refundGive: '0.00', // 退款找零
            // endDate: undefined,
            // startDate: undefined,
            readModeI: true,
            readModeR: true,
            // accPurposeCode: '',
        })
    }

    //新密码输入框改变
    onChangeNewPassword = (event) => {
        this.setState({
            newPassword: event.target.value
        })
        if (this.state.confirmPassword !== event.target.value) {
            this.setState({
                IsSame: true
            })
        } else {
            this.setState({
                IsSame: false
            })
        }
    }

    //确认密码输入框改变判断与新密码是否一致
    onChangeConfirmPassword = (event) => {
        this.setState({
            confirmPassword: event.target.value
        })
        if (this.state.newPassword !== event.target.value) {
            this.setState({
                IsSame: true
            })
        } else {
            this.setState({
                IsSame: false
            })
        }
    }

    //弹框确认
    payButtonOk = () => {
        let { accTSubID, payButtonNum, depositType, accmanID, patID, refundRemarks, refundChannel, refundAmount, modalPayTitle, modalType, payotherID, rechargeMoney, rechargeMark, reasonsRefundType, rechargeReceipts, rechargeGive, admID } = this.state
        let data = {};
        if (payButtonNum === 0) {
            // 未执行完
            switch (modalType) {
                case '0':
                    modalPayTitle = this.state.languageCode === "CN" ? '充值' : "Charge"
                    break;
                case '1':
                    modalPayTitle = this.state.languageCode === "CN" ? '请确认病人身份，选择设置类型' : "Please confirm the patient's identity and choose the type of setting"
                    break;
                case '2':
                    modalPayTitle = this.state.languageCode === "CN" ? '补打凭条' : "Reprint the receipt"
                    break;
                case '3':
                    modalPayTitle = this.state.languageCode === "CN" ? '设置退款金额' : "Set refund amount"
                    break;
                case '4':
                    modalPayTitle = this.state.languageCode === "CN" ? '确认取消冻结' : "Confirm unfreeze"
                    break;
                default:
                    break;
            }
            this.setState({
                payButtonNum: payButtonNum + 1,
                modalPayTitle: modalPayTitle,
            }, () => {
                if (this.state.payButtonNum === 1 && this.state.modalType === '0') {
                    this.setInputFocus(this.money)
                }

                if (this.state.payButtonNum === 1 && this.state.modalType === '3') {
                    this.setInputFocus(this.tfei)
                }
            })
        } else {
            // 执行
            let that = this;
            switch (modalType) {
                case '0':
                    if ((!rechargeMoney || rechargeMoney == '0') && (!this.props.inDeposit)) {
                        message.error('充值金额不正确！')
                        return false
                    }
                    data = {
                        params: [{
                            depositType: depositType === '' ? 'O' : depositType,
                            accmanID: accmanID || '',							//账户ID
                            patID: patID || '',						//Pat_Dr 病人ID
                            paywID: payotherID || '',					       //支付方式ID
                            paymenttype: "P" || '',         //缴款类型 P 充值,R 退款,F 结算账户的退款(账户不再可用)
                            channel: depositType === 'I' ? 'IP' : 'OP', //缴款渠道 OP 门诊窗口充值、SM 自助机充值、IP住院预交金充值
                            payamt: rechargeMoney ? rechargeMoney : this.props.inDeposit,							//缴款金额 缴款金额
                            remark: rechargeMark || '',        //备注 保存备注信息(支票号、银行卡(号)等)
                            purPose: this.state.accPurposeCode,
                            admID: this.state.ifAdmFlag == 'Y' ? admID : '',
                        }]
                    };
                    if (modalType === '0' && parseFloat(rechargeReceipts) + parseFloat(rechargeGive) < parseFloat(rechargeMoney)) {
                        message.error(this.state.languageCode === "CN" ? '实付金额小于应付金额' : "The actual payment amount is less than the amount payable")
                        return false
                    }
                    if (parseFloat(refundAmount) === 0) {  //parseFloat(rechargeReceipts) === 0 ||

                        message.error(this.state.languageCode === "CN" ? '金额需要大于0元' : "The amount needs to be greater than zero")
                        return false
                    }
                    $http.post('urlADS', this, {
                        code: "05210020",
                        data: data,
                        success: function (res) {
                            let errorCode = res.errorCode;
                            if (+errorCode === 0) {
                                message.success(res.errorMessage)
                                that.handleCancel()  //弹框取消
                                that.initJuris();
                                // that.handleQuery() //查询
                                that.searchUser()  //查询
                                that.getPurposeBlance();
                                that.setState({
                                    accDID: res.accDID,
                                }, () => {
                                    that.print(res.num) //打印
                                })

                            }
                        }
                    });
                    break;
                case '1':
                    this.handleCancel()
                    break;
                case '2':

                    break;
                case '3':
                    data = {
                        params: [{
                            accmanID: accmanID || '',							//账户ID
                            patID: patID || '',						//Pat_Dr 病人ID
                            paywID: refundChannel || '',					       //支付方式ID
                            paymenttype: "R" || '',         //缴款类型 P 充值,R 退款,F 结算账户的退款(账户不再可用)
                            channel: depositType === 'I' ? 'IP' : 'OP', //缴款渠道 OP 门诊窗口充值、SM 自助机充值、IP住院预交金充值
                            payamt: refundAmount || '',							//缴款金额 缴款金额
                            refundreason: reasonsRefundType || '',				//退款原因 退款原因 CB_Reason 表ID
                            remark: refundRemarks || '',        //备注 保存备注信息(支票号、银行卡(号)等)
                            purPose: this.state.accPurposeCode,
                            admID: this.state.ifAdmFlag == 'Y' ? admID : '',
                        }]
                    };
                    if (modalType === '0' && parseFloat(rechargeReceipts) + parseFloat(rechargeGive) < parseFloat(rechargeMoney)) {
                        message.error(this.state.languageCode === "CN" ? '实付金额小于应付金额' : "The actual payment amount is less than the amount payable")
                        return false
                    }
                    if (parseFloat(refundAmount) === 0) {  //parseFloat(rechargeReceipts) === 0 ||

                        message.error(this.state.languageCode === "CN" ? '金额需要大于0元' : "The amount needs to be greater than zero")
                        return false
                    }
                    $http.post('urlADS', this, {
                        code: "05210020",
                        data: data,
                        success: function (res) {
                            let errorCode = res.errorCode;
                            if (+errorCode === 0) {
                                message.success(res.errorMessage)

                                that.handleCancel(); // 弹框取消
                                // that.handleQuery(); // 查询
                                that.searchUser(); // 查询
                                that.getPurposeBlance();
                                that.initJuris();
                                that.setState({
                                    accDID: res.accDID,
                                }, () => {
                                    /*
                                    * Creater:     zxz
                                    * CreateDate:  2022/05/19
                                    * Describe：   成都普瑞退预交金后不打印凭证
                                    * */
                                    if ((sessionStorage.userData && JSON.parse(sessionStorage.userData).hospCode === 'H02') || (sessionStorage.userData && JSON.parse(sessionStorage.userData).hospCode === 'H02') || (sessionStorage.userData && JSON.parse(sessionStorage.userData).hospCode === 'H11')) {

                                    } else {
                                        this.print(res.num) //打印
                                    }
                                })

                            }
                        }
                    });
                    break;
                case '4':

                    break;
                case '5':
                    this.props.form.validateFields((err, values) => {
                        if (err || this.state.IsSame) {
                            return;
                        }
                        data = {
                            params: [{
                                patId: patID,
                                originaPassword: values.OriginaPassword,
                                newPassword: values.NewPassword,
                                confirmPassword: values.ConfirmPassword,
                                accTSubID: accTSubID,
                            }]
                        }
                        $http.post('urlADS', this, {
                            code: "05100266",
                            data: data,
                            success: function (res) {
                                if (+res.errorCode === 0) {
                                    message.success(res.errorMessage);
                                    that.props.form.resetFields();
                                    that.handleCancel()
                                }
                            }
                        })
                    })
                    break;
                case '6':
                    data = {
                        params: [{
                            patId: patID,
                            accTSubID: accTSubID,
                            hospID: JSON.parse(window.sessionStorage.userData).hospID,
                        }]
                    }
                    $http.post('urlADS', this, {
                        code: "05100267",
                        data: data,
                        success: function (res) {
                            if (+res.errorCode === 0) {
                                message.success(res.errorMessage);
                                this.handleCancel()
                            }
                        }
                    })
                    break;
                default:
                    break;
            }
        }
    }

    // table行样式
    setRowClassNameSelect = (record) => {
        return record.id === this.state.accDID ? 'clickRowStyle' : '';
    }

    setRowClassNameSelectAdm = (record) => {
        return record.admID === this.state.admID ? 'clickRowStyle' : '';
    }

    // 历史记录
    historyModal = () => {
        this.setState({
            modalShowNumber: true,
        });
    }

    otherPay = (code) => {
        this.setState({
            payotherID: code,
        })
    }

    accPurpose = (code) => {
        let { accmanID, admID } = this.state;
        this.setState({
            accPurposeCode: code,
            refundAmount: '',
            refundGive: '0.00',
        }, () => {
            var data = {
                params: [{
                    accmanID: accmanID,
                    puposeCode: code,
                    admID: admID
                }]
            }

            $http.post('urlADS', this, {
                code: "03040039",
                data: data,
                success: function (res) {
                    let errorCode = res.errorCode;
                    if (+errorCode === 0) {
                        this.setState({
                            purposeBlance: res.purposeBlance,
                            accBlance: res.purposeBlance.toFixed(2),
                            allAccoutBalance: res.allAccoutBalance
                        })
                    }
                }
            });
        })
    }

    // 打印
    print = (num) => {
        let { userInfo, templateCode, depositType } = this.state;
        var data = {
            params: [{
                "accDID": this.state.accDID,
                patID: userInfo && userInfo.patID ? userInfo.patID : undefined,
                depositType
            }]
        }
        $http.post('urlADS', this, {
            code: "04150025",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                var hospCode = JSON.parse(window.sessionStorage.userData).hospCode
                /*
                * Creater:     zxz
                * CreateDate:  2022/06/25
                * Describe：   预交金模板名称后端返回，不在前端判断
                * */
                templateCode = res.templateCode
                if (+errorCode === 0) {
                    ///长春普瑞打印样式
                    if ((hospCode === 'H19')) {
                        templateCode = 'IAdvancePayment',
                            num = 1
                    }
                    $loadTemplate(templateCode, res.result);
                    if (num === 2 && ((templateCode == 'AdvancePayment') || (templateCode == 'IAdvancePayment') || (templateCode == 'OAdvancePayment'))) {
                        $loadTemplate(templateCode, res.result);
                    }
                }
            }
        });
    }

    // 确认选择改患者
    handleConfirm = (patientInfo) => {
        this.setState({ patNo: patientInfo?.patNo || '' }, () => {
            this.searchUser('patNo');
        })
    }

    render() {
        let { language, languageCode, userInfo } = this.state
        const { getFieldDecorator } = this.props.form;
        // 组件所需参数
        const param = {
            // 表头配置
            columns: this.columns,
            // 表格数据
            data: this.state.tableData,
            // 数据总条数
            total: this.state.total,
            // 数据页数
            page: this.state.page,
            x: 1800
        }
        let windowHost = window.location && window.location.origin ? window.location.origin : (window.location && window.location.protocol ? (window.location.protocol + '//' + window.location.hostname) : "");
        let patientUrl = !Util.isEmpty(userInfo) ? userInfo.patImage : ''
        let patientImg = patientUrl ? (patientUrl.indexOf("http") !== -1 ? patientUrl : windowHost + patientUrl) : '';
        return (
            <div style={{ width: '100%', height: '100%', background: '#F5F7FE' }} className='hosptial-adm-body'>
                <ReadCard ref={r => this.readCard = r} />
                <div className="department-header" style={{ width: '20%', float: 'left', height: store.getState().tableHeight.y + 236 }}>
                    <Card bodyStyle={{ padding: 10 }} style={{ height: 230 }}>
                        {/* <TipHeader userInfo={this.state.userInfo} key={this.state.userInfo.patID + this.state.userInfo.accTSubID} /> */}
                        <div style={{ display: 'flex' }}>
                            {/* <div style={{ textAlign: 'center', marginTop: 20 }}>
                                {
                                    <div className={this.state.userInfo && this.state.userInfo.patSexCode == '1' ?
                                        'splice-boys' : (this.state.userInfo && this.state.userInfo.patSexCode == '2' ? 'splice-girls' : 'splice-girls')}></div>
                                }
                            </div> */}
                            {!Util.isEmpty(patientUrl) ? <img className='splice-patient-img' src={patientImg} style={{ width: '134px', height: '165px' }} /> : <div style={{
                                background: `url(${userInfo && userInfo.patSexCode == "1" ? avatarMale :
                                    (userInfo.patSexCode == "2" ? avatarFemale : avatarMale)})`, width: "134px", height: "165px"
                            }}></div>}
                            <div style={{ marginLeft: 20 }}>
                                <div style={{ color: '#333333', fontWeight: 'bold', cursor: 'pointer' }}>
                                    <img src={icon_name} style={{ marginRight: 20, marginBottom: 3 }} />
                                    <span>{this.state.userInfo ? this.state.userInfo.patName || '--' : '--'}</span></div>

                                <div style={{ marginTop: 5 }}><img src={icon_gender} style={{ marginRight: 20, marginBottom: 3 }} />
                                    {this.state.userInfo ? this.state.userInfo.patSexDesc || '--' : '--'}</div>

                                <div style={{ marginTop: 5 }}><img src={icon_expense} style={{ marginRight: 20, marginBottom: 3 }} />
                                    {this.state.userInfo ? this.state.userInfo.patAge || '--' : '--'}</div>

                                <div style={{ marginTop: 5 }}><Icon style={{ marginRight: 20, marginBottom: 3, color: '#CDCDCD' }} type="user" />
                                    {this.state.userInfo ? this.state.userInfo.patNo || '--' : '--'}</div>

                                <div style={{ marginTop: 5 }}><Icon className='statusdesc-splice' style={{ marginRight: 20 }} />
                                    {this.state.userInfo ? this.state.userInfo.patSocialStatusDesc || '--' : '--'}</div>

                                <div style={{ marginTop: 5 }}><Icon className='typeDesc-splice' style={{ marginRight: 20 }} />
                                    {this.state.userInfo ? this.state.userInfo.patTypeDesc || '--' : '--'}</div>

                                <div style={{ color: '#007AFF', marginTop: 5 }}>
                                    <Icon className='account-splice' style={{ marginRight: 20 }} />
                                    {this.state.userInfo ? this.state.userInfo.totalBalance || '--' : 0}</div>
                                <div style={{ color: '#007AFF', marginTop: 5 }}>
                                    <Icon className='account-splice' style={{ marginRight: 20 }} />
                                    {this.state.userInfo ? this.state.userInfo.inHospitalNo || '--' : '--'}</div>
                            </div>
                        </div>
                    </Card>
                    <Card bodyStyle={{ padding: 10 }} style={{ marginTop: 10, height: store.getState().tableHeight.y }} className="table-operations">

                        <Col span={25} className='common-col-ul'>
                            <Select allowClear style={{ width: '100px', margin: '0 15px 0 0' }} placeholder={languageCode === "CN" ? "请选择卡类型" : 'Select Card Type'} value={this.state.cardType} onChange={(event) => { this.cardType(event) }}  >
                                <Option value=''>{languageCode === "CN" ? "请选择" : 'Please Select'}</Option>
                                {this.state.cardTypeData.map(item => <Option title={item.descripts + '^' + item.descriptsSPCode} key={item.id} value={item.id}  >{item.descripts}</Option>)}
                            </Select>
                            <Search className={`search ${!this.state.readModeI ? 'disabled' : ''}`} style={{ width: '235px' }}
                                allowClear placeholder={language.PatientAccountManagementreadCard && language.PatientAccountManagementreadCard.message}
                                disabled={this.state.disabledInput} value={this.state.cardNo} enterButton={language.PatientAccountManagementreadCard && language.PatientAccountManagementreadCard.descripts}
                                onChange={(event) => { this.cardNo(event) }} onSearch={this.handleReadCard} />
                        </Col>

                        <Col span={25} className='common-col-ul' style={{ marginTop: 10 }}>
                            <span className='common-span-ui'>{language.PatientAccountManagementpatientInfo && language.PatientAccountManagementpatientInfo.descripts}：</span>
                            <Input allowClear style={{ width: '80%' }} placeholder={language.PatientAccountManagementpatientInfo && language.PatientAccountManagementpatientInfo.message}
                                className='input' value={this.state.patNo}
                                id='patInfo'
                                onChange={(event) => { this.patNo(event) }} onKeyUp={(e) => { this.patNodownE(e, 'patNo'); }} />
                        </Col>

                        <Col span={25} className='common-col-ul' style={{ marginTop: 10 }}>
                            <span className='common-span-ui'>{language.PatientAccountManagementoperateType && language.PatientAccountManagementoperateType.descripts}：</span>
                            <Select allowClear style={{ width: '80%' }} className='common-right-ui'
                                placeholder={language.PatientAccountManagementoperateType && language.PatientAccountManagementoperateType.message} value={this.state.findFlag} onChange={(event) => { this.doType(event) }}  >
                                <Option value='1'>{languageCode === "CN" ? "充值" : 'Recharge'}</Option>
                                <Option value='2'>{languageCode === "CN" ? "退款" : 'Refund'}</Option>
                                <Option value='3'>{languageCode === "CN" ? "消费" : 'Consumption'}</Option>
                                <Option value='4'>{languageCode === "CN" ? "全部" : 'All'}</Option>
                            </Select>
                        </Col>

                        <Col span={25} className='common-col-ul' style={{ marginTop: 10 }}>
                            <div style={{ width: '34%' }} className='common-span-ui'>{language.PatientAccountManagementoperateDate && language.PatientAccountManagementoperateDate.descripts + '：'}</div>
                            <RangeDatePicker
                                startDate={this.state.startDate} endDate={this.state.endDate}
                                format='YYYY-MM-DD'
                                startChange={this.startChange.bind(this)} endChange={this.endChange.bind(this)} />
                        </Col>

                        <Col span={25} style={{ marginTop: 10 }}>
                            <Button onClick={() => this.searchUser()} type='primary' style={{ width: '100%' }}>
                                {language.PatientAccountManagementquery && language.PatientAccountManagementquery.descripts}</Button>
                        </Col>
                        {this.state.ifAdmFlag === "Y" ?
                            <Col span={25} style={{ marginTop: 10 }}>
                                <div >
                                    <Table
                                        dataSource={this.state.admList}
                                        columns={this.admListColums}
                                        pagination={false}
                                        scroll={{ y: store.getState().tableHeight.y - 270 }}
                                        bordered
                                        loading={this.state.loading}
                                        rowKey={(row) => {
                                            return row.admID
                                        }}
                                        onRow={(record) => {
                                            return {
                                                onClick: (event) => {
                                                    this.setState({
                                                        admID: record.admID
                                                    }, () => { this.getPurposeBlance() }
                                                    )
                                                },
                                            };
                                        }}
                                        rowClassName={this.setRowClassNameSelectAdm}
                                    />
                                </div>
                            </Col>
                            : ""}
                    </Card>
                </div>

                <Card bodyStyle={{ padding: 10 }} style={{ width: '79.5%', float: 'right' }}>
                    <div>
                        {/* handelThis将夫组件的属性与方法给子组件访问 */}
                        {/* <PubilcTablePagination param={param} handelThis={this} onRef={this.onRef} /> */}
                        <Table
                            dataSource={this.state.tableData}
                            columns={this.state.columns}
                            title={() => {
                                return <Row className='clearfix' >
                                    <div style={{ float: 'left' }}>
                                        <span>{languageCode === "CN" ? "累计充值" : 'Accumulated Recharge'}：
                                            <span style={{ color: '#00C197' }}>￥{this.state.purposeBlance}</span></span>
                                        <span style={{ marginLeft: '20px' }}> {languageCode === "CN" ? "账户状态" : 'Account Status'}：
                                            <span style={{ color: '#007AFF' }}>{this.state.accStatusDesc}</span></span>
                                        <span style={{ marginLeft: '20px' }}> {languageCode === "CN" ? "所有账户余额" : 'ALL Account Balance'}：
                                            <span style={{ color: '#007AFF' }}>{this.state.allAccoutBalance}</span></span>
                                        <span style={{ marginLeft: '20px' }}>{language.PatientAccountManagementAdvance && language.PatientAccountManagementAdvance.descripts}:</span><span className='curP' style={{ color: '#1890FF', fontWeight: 'bold' }} onClick={() => { this.historyModal() }} > {this.state.invoice ? this.state.invoice.split('^')[2] : ''}</span>
                                        <span style={{ marginLeft: '20px' }}>{language.PatientAccountManagementaccPurPose && language.PatientAccountManagementaccPurPose.descripts}：
                                            <Select style={{ width: '100px' }} allowClear={true} placeholder={languageCode === "CN" ? '请选择' : 'Please Select'} value={this.state.accPurposeCode} onChange={(val, opt) => { this.onPurposeChange(val, opt) }}>
                                                {this.state.accPurpose.map(item => <Option title={item.descripts + '^' + item.code} key={item.id} value={item.code} ifAdmFlag={item.ifAdmFlag} >{item.descripts}</Option>)}
                                            </Select>
                                        </span>
                                    </div>
                                    <div style={{ float: 'right' }}>
                                        <Button disabled={this.state.disabledInput} onClick={() => this.modal('0')} style={{ float: 'left', border: 'none', marginLeft: ' 20px', }}><i className="f1"></i>{language.PatientAccountManagementrecharge && language.PatientAccountManagementrecharge.descripts}</Button>
                                        <Button onClick={() => this.modal('1')} style={{ float: 'left', border: 'none', marginLeft: ' 20px', }}>{language.PatientAccountManagementpasswordSet && language.PatientAccountManagementpasswordSet.descripts}</Button>
                                        <Button onClick={() => this.print(1)} style={{ float: 'left', border: 'none', marginLeft: ' 20px', }} disabled={this.state.accDID === '' ? true : false} >{language.PatientAccountManagementprintedSlip && language.PatientAccountManagementprintedSlip.descripts}</Button>
                                        <Button disabled={this.state.disabledInput} onClick={() => this.modal('3')} style={{ float: 'left', border: 'none', marginLeft: ' 20px', }}><i className="money1"></i>{language.PatientAccountManagementrefund && language.PatientAccountManagementrefund.descripts}</Button>
                                        <Button onClick={() => this.modal('4')} style={{ float: 'left', border: 'none', marginLeft: ' 20px', }}>{language.PatientAccountManagementaccountFreeze && language.PatientAccountManagementaccountFreeze.descripts}</Button>
                                    </div>
                                </Row>
                            }}
                            pagination={false}
                            // style={{ height: store.getState().tableHeight.y + 62 }}
                            scroll={{ x: 900, y: store.getState().tableHeight.y + 62 + 'px' }}
                            bordered
                            loading={this.state.loading}
                            rowKey={(row) => {
                                return row.id
                            }}
                            onRow={(record) => {
                                return {
                                    onClick: (event) => {
                                        this.setState({
                                            accDID: record.id
                                        })
                                    },
                                };
                            }}
                            rowClassName={this.setRowClassNameSelect}
                        />
                        <CommonPagination size="small" current={this.state.page} total={this.state.total} search='search'
                            onShowSizeChange={this.apponShowSizeChange} complete={true} dataSource={this.state.tableData}
                            onChange={this.appPageChange} />
                        <ColumnAuthoritysModel
                            clientWidth='900px'
                            compontName='PatientAccountManagement'
                            configType="C"
                            onRef={this.onColumnRef}
                            reloadData={this.tableList}
                        />

                    </div>
                </Card>
                {/* 设置发票号弹框 */}
                <Modal
                    visible={this.state.modalShowNumber}
                    title='设置预交金票据号'
                    onCancel={this.handleCancel}
                    onOk={this.handleCancel}
                    width='600px'
                    footer={null}
                >
                    {/* <HistoryModal userInfo={this.state.userInfo} updateParent={this.updateParent}></HistoryModal> */}
                    <HopNumber invTypeCode='OP' key={this.state.invoice} handleCancel={this.handleCancel} handelThis={this} />

                </Modal>

                {/* 弹框 */}
                <Modal
                    visible={this.state.modalShow}
                    title={this.state.modalPayTitle}
                    onCancel={this.handleCancel}
                    onOk={this.payButtonOk}
                    className='modalPay'
                    width={this.state.modalWidth}
                    centered={true}            //窗口居中显示  createBY: DYK
                >
                    {/* {<div style={{ display: this.state.payButtonNum === 0 ? 'block' : 'none' }}>
                        <Row >
                            <Col span={3} className='modalLabel' >{language.PatientAccountManagementpasswordCharge && language.PatientAccountManagementpasswordCharge.descripts}：</Col>
                            <Col span={21} ><Input ref={(input) => { this.pwd = input; }} allowClear placeholder={language.PatientAccountManagementpasswordCharge && language.PatientAccountManagementpasswordCharge.message} size="large" onPressEnter={this.payButtonOk} className='input' /></Col>
                        </Row>
                    </div>} */}
                    <div style={{ display: this.state.payButtonNum === 1 && this.state.modalType === '0' ? 'block' : 'none' }}>
                        {/* 充值 */}
                        <Row span={24} className='mB20' style={{ background: 'rgb(240, 242, 245)', }}>
                            <TipHeader userInfo={this.state.userInfo} key={this.state.userInfo.patID + this.state.userInfo.accTSubID} />
                        </Row>
                        <Row className='mB20'>
                            <Col span={6} className='modalLabel' >{language.PatientAccountManagementrechargeAmount && language.PatientAccountManagementrechargeAmount.descripts}：</Col>
                            <Col span={18} >
                                <Input
                                    id='rechargeMoney-input'
                                    ref={(input) => { this.money = input; }}
                                    onPressEnter={() => this.setInputFocus(this.typeMoney1)}
                                    addonBefore="￥"
                                    allowClear
                                    placeholder={language.PatientAccountManagementrechargeAmount && language.PatientAccountManagementrechargeAmount.message}
                                    size="large"
                                    className='input'
                                    value={this.state.rechargeMoney === '' ? this.props.inDeposit : this.state.rechargeMoney}
                                    onChange={(event) => this.rechargeMoney(event)}
                                // onBlur={(event) => { if (event.target.value === '') { event.target.value = '0.00' } this.setState({ rechargeMoney: parseFloat(event.target.value).toFixed(2) }) }}
                                // onFocus={(event) => { if (event.target.value === '0.00') { event.target.value = '' } }}
                                />
                            </Col>
                        </Row>
                        <Row className='mB20'>
                            <Col span={6} className="modalLabel">{language.PatientAccountManagementpaymentType && language.PatientAccountManagementpaymentType.descripts}：</Col>
                            <Col span={18} className="clearfix" >
                                {this.state.otherPayData.map((item, i) => <Col span={5} offset={1} className="mB10">
                                    <Input
                                        readOnly
                                        key={item.paywID}
                                        value={item.paywDesc}
                                        ref={(input) => { i === 0 ? this.typeMoney1 = input : this.typeMoneyOuther = input }}
                                        onPressEnter={() => { this.setInputFocus(this.textArea), this.otherPay(item.paywID) }}
                                        className={`payCode mR20 ${item.paywID === this.state.payotherID ? 'selected' : ''}`}
                                        onClick={() => this.otherPay(item.paywID)}
                                    >
                                    </Input>
                                </Col>
                                )}
                            </Col>
                        </Row>
                        {/* <Row className='mB20'>
                            <Col span={6} className='modalLabel' >{language.PatientAccountManagementaccPurPose && language.PatientAccountManagementaccPurPose.descripts}：</Col>
                            <Col span={18} className='clearfix' >
                                {this.state.accPurpose.map((item, i) => {
                                    return <Col span={5} offset={1} className='mB10' > <Input ref={(input) => { i === 0 ? this.typeMoney1 = input : this.typeMoneyOuther = input }} onPressEnter={() => { this.setInputFocus(this.textArea), this.accPurpose(item.code) }} readOnly key={item.id} className={`payCode mR20 ${item.code === this.state.accPurposeCode ? 'selected' : ''}`} onClick={() => this.accPurpose(item.code)} value={item.descripts} ></Input></Col>
                                })}
                            </Col>
                        </Row> */}
                        <Row className='mB20'>
                            <Col span={6} className='modalLabel' >{language.PatientAccountManagementremarks && language.PatientAccountManagementremarks.descripts}：</Col>
                            <Col span={18} ><Input ref={(input) => { this.textArea = input; }} onPressEnter={this.payButtonOk} placeholder={language.PatientAccountManagementremarks && language.PatientAccountManagementremarks.message} size="large" className='input' rows={2} value={this.state.rechargeMark} onChange={(event) => this.rechargeMark(event)} /></Col>
                        </Row>
                        {/* <Row className='mB20'>
                            <Col span={6} className='modalLabel' >{language.PatientAccountManagementactualHarvest && language.PatientAccountManagementactualHarvest.descripts}：</Col>
                            <Col span={18} ><Input ref={(input) => { this.shimoney = input; }} onPressEnter={this.payButtonOk} addonBefore="￥" allowClear placeholder={language.PatientAccountManagementactualHarvest && language.PatientAccountManagementactualHarvest.message} size="large" className='input' value={this.state.rechargeReceipts} onChange={(event) => this.rechargeReceipts(event)} onBlur={(event) => { if (event.target.value === '') { event.target.value = '0.00' } this.setState({ rechargeReceipts: parseFloat(event.target.value).toFixed(2) }) }} onFocus={(event) => { if (event.target.value === '0.00') { event.target.value = '' } }} /></Col>
                        </Row>
                        <Row className='mB20'>
                            <Col span={6} className='modalLabel' >{language.PatientAccountManagementchange && language.PatientAccountManagementchange.descripts}：</Col>
                            <Col span={18} ><Input addonBefore="￥" allowClear placeholder="找零" size="large" className='input' value={this.state.rechargeGive} disabled /></Col>
                        </Row> */}
                    </div>
                    <div style={{ display: this.state.payButtonNum === 1 && this.state.modalType === '1' ? 'block' : 'none' }}>
                        {/* 密码设置选择 */}
                        <Row span={24} className='mB20' style={{ background: 'rgb(240, 242, 245)', }}>
                            <TipHeader userInfo={this.state.userInfo} key={this.state.userInfo.patID + this.state.userInfo.accTSubID} />
                        </Row>
                        <Row span={24} className='mB20' >
                            <Button onClick={() => this.changeModalType('5')} style={{ float: 'left', width: '100%', }}>{language.PatientAccountManagementchangePassword && language.PatientAccountManagementchangePassword.descripts}</Button>
                        </Row>
                        <Row span={24} className='mB20' >
                            <Button onClick={() => this.changeModalType('6')} style={{ float: 'left', width: '100%', }}>{language.PatientAccountManagementresetPassword && language.PatientAccountManagementresetPassword.descripts}</Button>
                        </Row>
                    </div>
                    <div style={{ display: this.state.payButtonNum === 1 && this.state.modalType === '5' ? 'block' : 'none' }}>
                        {/* 修改密码 */}
                        <Form layout="inline">
                            <Row span={24}>
                                <Form.Item label={language.PatientAccountManagementoriginalPassword && language.PatientAccountManagementoriginalPassword.descripts} {...formItemLayout} style={{ width: '100%' }}>
                                    {getFieldDecorator("OriginaPassword", {
                                        initialValue: this.state.originaPassword,
                                        rules: [{ required: true, message: languageCode === "CN" ? '原密码不能为空' : 'The original password cannot be empty', }]
                                    })(
                                        <Input type="password" allowClear maxLength={6} placeholder={language.PatientAccountManagementoriginalPassword && language.PatientAccountManagementoriginalPassword.message} className='input' />
                                    )}
                                </Form.Item>
                            </Row>
                            <Row span={24}>
                                <Form.Item label={language.PatientAccountManagementnewPassword && language.PatientAccountManagementnewPassword.descripts} {...formItemLayout} style={{ width: '100%' }} >
                                    {getFieldDecorator("NewPassword", {
                                        initialValue: this.state.newPassword,
                                        rules: [{ required: true, message: languageCode === "CN" ? '新密码不能为空' : 'New password cannot be empty' }]
                                    })(
                                        <Input type="password" onChange={(event) => this.onChangeNewPassword(event)} allowClear maxLength={6} placeholder={language.PatientAccountManagementnewPassword && language.PatientAccountManagementnewPassword.message} className='input' />)}
                                </Form.Item>
                            </Row>
                            <Row span={24}>
                                <Form.Item label={language.PatientAccountManagementconfirmPassword && language.PatientAccountManagementconfirmPassword.descripts} {...formItemLayout} style={{ width: '100%' }} >
                                    {getFieldDecorator("ConfirmPassword", {
                                        initialValue: this.state.confirmPassword,
                                        rules: [{ required: true, message: languageCode === "CN" ? '确认密码不能为空' : 'Confirm password cannot be empty' }]
                                    })(
                                        <Input type="password" onChange={(event) => this.onChangeConfirmPassword(event)} allowClear maxLength={6} placeholder={language.PatientAccountManagementconfirmPassword && language.PatientAccountManagementconfirmPassword.message} className='input' />,

                                    )}
                                </Form.Item>
                                <p style={{ display: this.state.IsSame ? 'block' : 'none', color: '#f5222d', textAlign: 'center', }}>{languageCode === "CN" ? '确认密码与新密码不一致' : 'Confirm password is inconsistent with new password'}</p>
                            </Row>
                        </Form>
                    </div>
                    <div style={{ display: this.state.payButtonNum === 1 && this.state.modalType === '6' ? 'block' : 'none' }}>
                        {/* 重置密码 */}
                        <Row span={24} className='mB20' style={{ background: 'rgb(240, 242, 245)', }}>
                            <p>{languageCode === "CN" ? '请再次核对病人信息重置密码' : 'Please check the patient information reset password again'}</p>
                            <TipHeader userInfo={this.state.userInfo} key={this.state.userInfo.patID + this.state.userInfo.accTSubID} />
                        </Row>
                    </div>
                    <div style={{ display: this.state.payButtonNum === 1 && this.state.modalType === '3' ? 'block' : 'none' }}>
                        {/* 退款 */}
                        <Row span={24} className='mB20' style={{ background: 'rgb(240, 242, 245)', }}>
                            <TipHeader userInfo={this.state.userInfo} key={this.state.userInfo.patID + this.state.userInfo.accTSubID} />
                        </Row>
                        <Row span={24} className='mB20' >
                            <Col span={8} style={{ color: 'rgb(66, 185, 131)' }} >
                                {language.PatientAccountManagementbalance && language.PatientAccountManagementbalance.descripts}:{this.state.accBlance}
                            </Col>
                            <Col span={8} style={{ color: 'rgb(66, 185, 131)' }} >
                                用途金额:   <span style={{ color: this.state.purposeBlance ? '' : 'red' }}>{this.state.purposeBlance ? this.state.purposeBlance : 0}</span>
                            </Col>
                            <Col span={8} style={{ textAlign: 'right', color: 'rgb(66, 185, 131)' }} >
                                {language.PatientAccountManagementrefundable && language.PatientAccountManagementrefundable.descripts}:{this.state.purposeBlance ? this.state.purposeBlance : 0}
                            </Col>
                        </Row>
                        {/* <Row className='mB20'>
                            <Col span={6} className='modalLabel' >{language.PatientAccountManagementaccPurPose && language.PatientAccountManagementaccPurPose.descripts}：</Col>
                            <Col span={18} className='clearfix' >
                                {this.state.accPurpose.map((item, i) => {
                                    return <Col span={5} offset={1} className='mB10' > <Input ref={(input) => { i === 0 ? this.typeMoney1 = input : this.typeMoneyOuther = input }} onPressEnter={() => { this.setInputFocus(this.textArea), this.accPurpose(item.code) }} readOnly key={item.id} className={`payCode mR20 ${item.code === this.state.accPurposeCode ? 'selected' : ''}`} onClick={() => this.accPurpose(item.code)} value={item.descripts} ></Input></Col>
                                })}
                            </Col>
                        </Row> */}
                        <Row className='mB20'>
                            <Col span={6} className='modalLabel' >{language.PatientAccountManagementrequestRefund && language.PatientAccountManagementrequestRefund.descripts}:</Col>
                            <Col span={16} ><Input id='refundAmount-input' ref={(input) => { this.tfei = input; }} allowClear placeholder={language.PatientAccountManagementrequestRefund && language.PatientAccountManagementrequestRefund.message} size="large" className='input' value={this.state.refundAmount} onChange={(event) => this.refundAmount(event)} onBlur={(event) => { if (event.target.value === '') { event.target.value = '0.00' } this.setState({ refundAmount: parseFloat(event.target.value).toFixed(2) }) }} onFocus={(event) => { if (event.target.value === '0.00') { event.target.value = '' } }} /></Col>
                            <Col span={2} style={{ color: '#1890ff', lineHeight: '40px', textAlign: 'center', cursor: 'pointer', }} onClick={() => this.whole()} >全部</Col>
                            <Col span={16} offset={6} style={{ color: '#f5222d', display: this.state.refundGive === '0.00' ? 'none' : 'block' }} >
                                {language.PatientAccountManagementremain && language.PatientAccountManagementremain.descripts}:{this.state.refundGive}
                            </Col>
                        </Row>
                        <Row className='mB20'>
                            <Col span={6} className='modalLabel' >{language.PatientAccountManagementtefundChannel && language.PatientAccountManagementtefundChannel.descripts}：</Col>
                            <Col span={18} >
                                <Select onSelect={() => this.setInputFocus(this.tfeiNote)} allowClear style={{ width: '100%' }} size="large" placeholder={language.PatientAccountManagementtefundChannel && language.PatientAccountManagementtefundChannel.message} value={this.state.refundChannel} onChange={(event) => { this.refundChannel(event) }}  >
                                    <Option value=''>{languageCode === "CN" ? '请选择' : 'Please Select'}</Option>
                                    {this.state.otherPayData.map(item => <Option title={item.paywDesc + '^' + item.paywCode} key={item.paywID} value={item.paywID}  >{item.paywDesc}</Option>)}
                                </Select>
                            </Col>
                        </Row>

                        <Row className='mB20'>
                            <Col span={6} className='modalLabel' >{language.PatientAccountManagementremark && language.PatientAccountManagementremark.descripts}：</Col>
                            <Col span={18} ><Input ref={(input) => { this.tfeiNote = input; }} onPressEnter={this.payButtonOk} placeholder={language.PatientAccountManagementremark && language.PatientAccountManagementremark.message} size="large" className='input' rows={2} value={this.state.refundRemarks} onChange={(event) => { this.refundRemarks(event) }} /></Col>
                        </Row>
                    </div>
                </Modal>
                <FindPatients handleParms={this.handleConfirm} OnChildrefs={ref => this.findPatientsRef = ref} />
            </div>
        )
    }
}

const PatientAccountManagementForm = Form.create()(PatientAccountManagement);
export default PatientAccountManagementForm;
