// 出院结算

import React from 'react';
import { Select, Input, Row, Col, Button, Spin, List, Divider, Popconfirm, message, Icon, Form, DatePicker, Table, Tabs, Modal, Card, Pagination, Popover } from 'antd';
import { $http } from 'containers/config/https';
import moment from 'moment';
import { Keup, ArraySome } from '../../../tools/index';
import PubilcTablePagination from '../../common/PubilcTablePagination.jsx'; // 公共table组件
import DatePickerFormat from '../../../components/datePicker/DatePickerFormat';
import TipHeader from './component/TipHeader'
import HopNumber from './component/HopNumber'
import ListOfHospitalizationExpenses from './ListOfHospitalizationExpenses'
import SplitBills from '../SplitBills'
import { $loadTemplate } from '../../lodop/Common/Print.js';
import fetchJsonp from 'fetch-jsonp';
import $ from 'pages/workstation/component/js/jquery-3.2.1.min.js';
import './style/style.less'
import store from 'store';
import ReadCard from '../../../components/readcard/ReadCard';
import RangeDatePicker from 'components/rangePicker/index';
import CommonPagination from 'components/pagination/index';
import ColumnAuthoritysModel from 'pages/columnAuthority/ColumnAuthoritysModel';
import { INSUYBUtil } from '../../../tools/index';
import INSURegister from 'pages/Cashier/INSURegister.jsx';
import { Util } from 'tools/index';
import PublicModalTable from 'pages/common/PublicModalTable';
import { $loopPrint } from '../../lodop/Common/Print';
// 组件const
const { Option } = Select;
const { RangePicker } = DatePicker;
const dateFormat = 'YYYY-MM-DD' || undefined;
const { Search } = Input;
const cost_type = require('../../../assets/images/icon_Inquire.png')
const istvisits = require('../../../assets/images/icon_listvisits.png')
const billdetails = require('../../../assets/images/icon_billdetails.png')

const EditableContext = React.createContext();

class EditableCell extends React.Component {
    getInput = () => {
        if (this.props.inputType === 'select') {
            return <Select style={{ width: '80%' }} onSelect={(event) => { this.props.source.paywselect(event) }} >
                {this.props.option}
            </Select>;
        }
        return <Input style={{ width: '80%' }} onChange={(event) => { this.props.source.paymoney(event) }} onFocus={(event) => { this.props.source.paymoneyonfocus(event) }} />;

    };

    renderCell = ({ getFieldDecorator }) => {
        const {
            editing,
            dataIndex,
            title,
            option,
            inputType,
            record,
            index,
            children,
            ...restProps
        } = this.props;
        return (
            <td {...restProps}>
                {editing ? (
                    <Form.Item style={{ margin: 0 }}>
                        {getFieldDecorator(dataIndex, {
                            rules: [
                                {
                                    required: true,
                                    message: `${title + (JSON.parse(window.sessionStorage.userData).language == 'EN' ? ' Can not be empty!' : '不能为空!')}`,
                                },
                            ],
                            initialValue: record[dataIndex],
                        })(this.getInput())}
                    </Form.Item>
                ) : (
                    children
                )}
            </td>
        );
    };

    render() {
        return <EditableContext.Consumer>{this.renderCell}</EditableContext.Consumer>;
    }
}

class DischargeSettlement extends React.Component {
    constructor(props) {
        super(props)
        let userData = JSON.parse(sessionStorage.getItem('userData'));
        this.state = {
            userInfo: {}, // 用户数据
            dataTableTop: [], // table数据 上列表table
            dataTable1: [], // table数据 主列表table
            dataTable2: [], // table数据 折扣记账系数配置列表
            dataTable3: [], // table数据 不属于折扣内明细

            selectListData1: [],
            selectListData2: [],
            selectListData3: [],
            payWListData: [], // table数据 支付方式列表
            paywamtData: '',
            payWListkey: 10,
            totalTop: 0,
            pageTop: 1,
            pageSizeTop: 10,
            // 表格数据总条数1
            total1: 0,
            page1: 1,
            pageSize1: 10,
            StartDateTop: undefined,  // //开始日期
            EndDateTop: undefined,  // //结束日期
            StartDate1: undefined,  // //
            EndDate1: undefined,  // //结束日期
            cardType: '', // 卡类型
            cardTypeData: [], // 卡类型
            cardNo: '', // 卡号
            patNo: '',
            select1: '',
            select2: '',
            select3: '',
            nameNo: '',
            execID: [],
            ordID: '',
            modalShow: false,
            columnsTop: [],
            ipPayWListTop: [],
            columns1: [],
            selectedRowKeys: [],
            money: {},
            bqType: '',
            jsType: '',
            chargeStatus: 'B',
            bqData: [],
            jsTypeData: [],
            time1: '2',
            allMoney: 0,
            accSubStatus: {}, //账户状态
            userPayData: {}, //账户状态
            patBillID: '',
            paras: {},
            subTypeFeeArr: [],
            dataTable2: [],
            otherPayData: [], //其他付款方式:
            sysConfigIP: '',
            payType: '', // 付款方式

            otherPay: '', //其他支付方式
            otherPayDis: false, //其他支付方式不可选
            otherPayMoney: '0.00', // 其他支付金额
            cashInCashVal: '0.00', // 实收现金
            payAccIPAmt: '0.00',	//住院结算参与账户的金额
            selectedRows: [],
            recordID: '',
            ipInsuType: '',
            visible: false,
            visibleMoney: false,
            visibleMoney2: false,
            leftAmt: '',
            patAmt: '',
            payWListData: [],
            paywamtData: '',
            payWListkey: 10,
            accAmtBalance: '',
            accpayBalance: '',
            leftAmtSur: '',
            zeroPay: '0.00', // 找零
            disBtton1: true,
            disBtton2: true,
            disBtton3: true,
            disBtton4: true,
            disBtton5: true,
            disBtton6: true,
            disBtton7: true,
            accDepositIDinfo: '',
            readModeI: true,
            readModeR: true,
            recordData: {},
            languageData: {}, // 国际化语言包
            language: {},   // 国际化语言
            languageCode: JSON.parse(window.sessionStorage.userData).language, // 国际化语言标识
            ColumnAuthority: '',
            INSURegisterVisable: false,
            contextMenuvisible: false,
            disXJ: false,
            comepnCode: '2101',
            xnhBCTYPE: '',
            ifsubmit: '0',
            YBPatDivdata: [],
            comepnCodeList: [],
            xnhBCTYPEList: [],
            insuPayID: '',
            ybPayDivdata: '',
            InsuIPPayButton: '0',
            InsuIPPayModalvisible: false,
            secondsToGo: 0,
            trialflag: '',
            editingKey: '',
            xnhtreatCodeist: [],
            treatCode: '',
            icdAllNoEList: [],
            icdAllNo: '',       // 医保诊断code
            modalPageSize: 10,
            modalPage: 1,
            modalTotal: 0,
            INSUICDDesc: '',    // 医保诊断描述
            searchCode: '',
            ifNeedTreatWay: 'N',     // 治疗方式是否需要必填
            userData: userData,
            admReasonCode: '',
            surplusamt: 0,
        }

        this.myRef1 = React.createRef();
        this.myRef2 = React.createRef();
        this.myRef3 = React.createRef();
        this.myRef4 = React.createRef();
        this.myRef5 = React.createRef();
        this.myRef6 = React.createRef();
        this.refHandleOK = React.createRef();

        this.columns2 = [
            {
                title: '金额*规格',
                dataIndex: 'invNo',
                key: '1',
                align: "center",
                width: 200,
            }, {
                title: '支付方式',
                dataIndex: 'patBillCUnitPrice',
                key: '2',
                align: "center",
                width: 100,
            },
        ]
        this.modalColumns = [{
            title: 'ICD诊断代码',
            dataIndex: 'code',
            key: 'code'
        }, {
            title: 'ICD诊断描述',
            dataIndex: 'descripts',
            key: 'descripts'
        }]
    }

    componentDidMount() {
        this.cardTypeList() //卡类型
        this.initJuris() //权限
        this.jsList() //结算
        this.bqList() //病区
        this.tableList("IPPayBillList", "IPPayBillList");
        this.tableList("IPAdmList", "IPAdmList");
        this.tableList("IPPayWList", "IPPayWList");
        this.ordList1() //国际化
        this.dataTableTopData() // 查询
        document.addEventListener('click', this.handleClick)
        this.loadGoldTaxMessage()
    }

    //调用金税，获取库存信息
    loadGoldTaxMessage() {
        let that = this
        var source = encodeURIComponent("{ fpzl: 2 }");
        var dllInput = 'SID=0\&\&\&\SIDParam=' + source; // JSON.stringify({ "SID": "0", "SIDParam": source })
        // var dllPath = 'JSInv/prykjsapplication.dll'
        // var className = 'prykjsapplication.JSHelper'
        // var funcName = 'GetJSData'
        // let data = 'input={"inputDir":"' + dllPath + '","clsName":"' + className + '","funcName":"' + funcName + '","dllInput":"' + dllInput + '"}'
        let dllParams = JSON.stringify({ 'inputDir': 'JSInv/prykjsapplication.dll', 'clsName': 'prykjsapplication.JSHelper', 'funcName': 'GetJSData', 'dllInput': dllInput });
        if (typeof (CefSharp) != "undefined") {   // 新元素定制浏览器
            CefSharp.BindObjectAsync("xysCefToJavaScripts");
            setTimeout(() => {
                xysCefToJavaScripts.driveLocalHardware(dllParams).then((returnVale) => {
                    var res = JSON.parse(returnVale);
                    if (res.resultCode == '0') {
                        var source = JSON.parse(decodeURIComponent(res.result))
                        if (source && source.ENCMSG.invStock == 0) {
                            that.setState({
                                disBtn: true
                            })
                        }
                    }
                })
            }, 100);
        } else {
            const frame = chrome?.webview?.hostObjects?.Bridge || ''; // 新版浏览器
            if (frame) {
                frame.DynamicLoadingDLL(dllParams)
                    .then(
                        data => {
                            var res = JSON.parse(data);
                            if (res.resultCode == '0') {
                                var source = JSON.parse(decodeURIComponent(res.result))
                                if (source && source.ENCMSG.invStock == 0) {
                                    that.setState({
                                        disBtn: true
                                    })
                                }
                            }
                        },
                        err => {
                            console.log('error', err);
                        }
                    )
            } else {
                $.getJSON("http://127.0.0.1:62534/XYSWCFService/DynamicLoadingDLL?JsonCallback=?", {
                    input: dllParams
                },
                    function (data) {
                        var res = JSON.parse(data);
                        if (res.resultCode == '0') {
                            var source = JSON.parse(decodeURIComponent(res.result))
                            if (source && source.ENCMSG.invStock == 0) {
                                that.setState({
                                    disBtn: true
                                })
                            }
                        }
                    });
            }
        }
    }

    //获取金税开票信息
    loadInvoiceMessage() {
        var params = {
            params: [{
                userID: this.state.userData.userID,
                recordID: [this.state.compleRecordIDinfo]
            }]
        }
        $http.post('urlADS', this, {
            code: "05210077",
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    var source = res.result;
                    if (!Util.isEmpty(source)) {
                        source['listed'] = (source.listed == 'true' ? true : false)
                    }
                    this.setState({
                        invoiceSource: source
                    }, () => {
                        if (this.state.userData && this.state.userData.hospCode === "H19") {
                            source && source.invoiceFileUrl ? window.open(source.invoiceFileUrl) : "";
                        } else {
                            this.loadInvoiceSource()//获取发票开具信息
                        }
                    })
                }
            }
        });
    }

    loadInvoiceSource() {
        let that = this;
        var source = encodeURIComponent(JSON.stringify(that.state.invoiceSource));
        var dllInput = 'SID=1\&\&\&\SIDParam=' + source; // JSON.stringify({ "SID": "0", "SIDParam": source })
        let dllParams = JSON.stringify({ 'inputDir': 'JSInv/prykjsapplication.dll', 'clsName': 'prykjsapplication.JSHelper', 'funcName': 'GetJSData', 'dllInput': dllInput });
        if (typeof (CefSharp) != "undefined") { // 新元素定制浏览器
            CefSharp.BindObjectAsync("xysCefToJavaScripts");
            setTimeout(() => {
                xysCefToJavaScripts.driveLocalHardware(dllParams).then((returnVale) => {
                    var res = JSON.parse(returnVale);
                    if (res.resultCode == '0') {
                        var source = JSON.parse(decodeURIComponent(res.result));
                        that.setState({
                            fpSource: source ? source.ENCMSG : ''
                        }, () => {
                            that.saveInviceMessage()
                        })
                    }
                })
            }, 100);
        } else {
            const frame = chrome?.webview?.hostObjects?.Bridge || ''; // 新版浏览器
            if (frame) {
                frame.DynamicLoadingDLL(dllParams)
                    .then(
                        data => {
                            var res = JSON.parse(data);
                            if (res.resultCode == '0') {
                                var source = JSON.parse(decodeURIComponent(res.result));
                                that.setState({
                                    fpSource: source ? source.ENCMSG : ''
                                }, () => {
                                    that.saveInviceMessage()
                                })
                            }
                        },
                        err => {
                            console.log('error', err);
                        }
                    )
            } else {
                $.getJSON("http://127.0.0.1:62534/XYSWCFService/DynamicLoadingDLL?JsonCallback=?", {
                    input: dllParams
                },
                    function (data) {
                        var res = JSON.parse(data);
                        if (res.resultCode == '0') {
                            var source = JSON.parse(decodeURIComponent(res.result))
                            that.setState({
                                fpSource: source ? source.ENCMSG : ''
                            }, () => {
                                that.saveInviceMessage()
                            })
                        }
                    });
            }
        }
    }

    //保存金税信息
    saveInviceMessage() {
        var params = {
            params: [{
                recordID: [this.state.compleRecordIDinfo],
                ...this.state.fpSource
            }]
        }
        $http.post('urlADS', this, {
            code: "05210078",
            data: params,
            success: function (res) {
                if (res.errorCode == '0') {
                    this.printButtont()
                    // this.loadPrintGoldTax()
                }
            }
        });
    }

    printButtont = () => {
        var data = {
            recordIDArr: [this.state.compleRecordIDinfo],
            params: [{
                userID: React.$getSessionData()?.userID || '',             //收费员
                paywIDinfo: '',//个人自付支付方式数据(不包括    医保) ID^金额^合作单位ID_$c(2)_ID^金额^合作单位ID
                accmID: '',//账户ID
                IfPayInvMode: 'N',//集中打印发票是否重新计费支付方式（集中打印是医保结算也是重新计算支付方式）Y 是,N 否
                ifDirectPrint: 'N', //是否缴费直接打印标志
                groupID: JSON.parse(window.sessionStorage.userData).groupID,//登录安全组
                locID: JSON.parse(window.sessionStorage.userData).locID,//登录科室
                hospID: JSON.parse(window.sessionStorage.userData).hospID, //医院id //登录医院
                ip: React.$getSessionData('ipConfig')?.ipv4 || '',
                invNo: this.state.fpSource ? this.state.fpSource.fphm : ''//金税发票号码
            }]
        }

        $http.post('urlADS', this, {
            code: "05210034",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {
                    this.setState({
                        invIDSt: res.invIDStr
                    }, () => {
                        this.loadPrintGoldTax()//金税打印
                    })
                }
            }
        });
    }

    loadPrintGoldTax() {
        let that = this
        var data = {
            'fpzl': 2,
            'fphm': this.state.fpSource ? this.state.fpSource.fphm : '', // 金税发票号码
            'fpdm': this.state.fpSource ? this.state.fpSource.fpdm : '', // 金税发票代码
            'showPrintDlg': 0
        }
        var source = encodeURIComponent(JSON.stringify(data));
        var dllInput = 'SID=2\&\&\&\SIDParam=' + source; // JSON.stringify({ "SID": "0", "SIDParam": source })
        let dllParams = JSON.stringify({ 'inputDir': 'JSInv/prykjsapplication.dll', 'clsName': 'prykjsapplication.JSHelper', 'funcName': 'GetJSData', 'dllInput': dllInput });
        if (typeof (CefSharp) != "undefined") { // 新元素定制浏览器
            CefSharp.BindObjectAsync("xysCefToJavaScripts");
            setTimeout(() => {
                xysCefToJavaScripts.driveLocalHardware(dllParams).then((returnVale) => {
                    var res = JSON.parse(returnVale);
                    if (res.resultCode == '0') {
                        message.success('打印成功！');
                        that.loadGoldTaxMessage();
                        that.dataTable1Data();
                    }
                })
            }, 100);
        } else {
            const frame = chrome?.webview?.hostObjects?.Bridge || ''; // 新版浏览器
            if (frame) {
                frame.DynamicLoadingDLL(dllParams)
                    .then(
                        data => {
                            var res = JSON.parse(data);
                            if (res.resultCode == '0') {
                                message.success('打印成功！');
                                that.loadGoldTaxMessage();
                                that.dataTable1Data();
                            }
                        },
                        err => {
                            console.log('error', err);
                        }
                    )
            } else {
                $.getJSON("http://127.0.0.1:62534/XYSWCFService/DynamicLoadingDLL?JsonCallback=?", {
                    input: dllParams
                },
                    function (data) {
                        var res = JSON.parse(data);
                        if (res.resultCode == '0') {
                            message.success('打印成功！');
                            that.loadGoldTaxMessage();
                            that.dataTable1Data();
                        }
                    });
            }
        }
    }

    // 鼠标单击事件，当鼠标在任何地方单击时，设置菜单不显示
    handleClick = () => {
        const { contextMenuvisible } = this.state
        if (contextMenuvisible) {
            this.setState({ contextMenuvisible: false })
        }
    };
    componentWillUnmount() {
        document.removeEventListener('click', this.handleClick)
        // 组件销毁前将静止让setState修改state的状态
        this.setState = (state, callback) => { return; }
    }

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

    historyModal = () => {
        this.setState({
            modalShow: true,
        });
    }

    // 费用类型table
    ordList1 = () => {
        let data = {
            params: [{
                "reactCode": ["DischargeSettlement"],
                "compontName": "DischargeSettlement",
                "type": "C"

            }]
        }
        $http.post('urlS', this, {
            code: "01040073",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {
                    this.setState({
                        languageData: res.result.language || {},  // 国际化语言包
                    }, () => {
                        this.LanCNEN(this.state.languageCode)
                    })
                }
            }
        });
    }

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

    // 权限
    initJuris = () => {
        var 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: 'I'  // 类型
            }]
        }
        $http.post('urlS', this, {
            code: "05210001",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {


                    this.setState({
                        otherPayData: res.groupConfig.HBOPConfigPaymode[0].IPCharge || [],  // 其他付款方式
                        payType: res.groupConfig.HBOPConfigPaymode[0].IPCharge[0].paywID || '',
                        otherPay: res.groupConfig.HBOPConfigPaymode[0].IPCharge[1].paywID || '',
                    });


                }
            }
        });
    }

    clearnUserPayData = () => {
        this.setState({
            userPayData: {}, //账户状态
            cashInCashVal: '0.00', // 实收现金
            payAccIPAmt: '0.00',	//住院结算参与账户的金额
            otherPayDis: false, //其他支付方式不可选
            otherPayMoney: '0.00', // 其他支付金额
            disBtton1: true,
            disBtton2: true,
            disBtton3: true,
            disBtton4: true,
            disBtton5: true,
            disBtton6: true,
            disBtton7: true,
            accDepositIDinfo: '',
            subTypeFeeArr: [],
            INSURegisterVisable: false,
            disXJ: false,
            comepnCode: '2101',
            xnhBCTYPE: '',
            ifsubmit: '0',
            YBPatDivdata: [],
            comepnCodeList: [],
            xnhBCTYPEList: [],
            insuPayID: '',
            ybPayDivdata: '',
            InsuIPPayButton: '0',
            InsuIPPayModalvisible: false,
            trialflag: '',
            xnhtreatCodeist: [],
            treatCode: '',
            icdAllNoEList: [],
            icdAllNo: '',
            ifNeedTreatWay: 'N',     // 治疗方式是否需要必填
            surplusamt: 0,
        })
    }

    clearn = () => {
        this.setState({
            userInfo: {}, // 用户数据
            dataTableTop: [], // table数据 上列表table
            dataTable1: [], // table数据 主列表table
            dataTable2: [], // table数据 折扣记账系数配置列表
            dataTable3: [], // table数据 不属于折扣内明细
            selectListData1: [],
            selectListData2: [],
            selectListData3: [],
            totalTop: 0,
            pageTop: 1,
            pageSizeTop: 10,
            // 表格数据总条数1
            total1: 0,
            page1: 1,
            pageSize1: 10,
            StartDateTop: undefined,  // //开始日期
            EndDateTop: undefined,  // //结束日期
            StartDate1: undefined,  // //开始日期
            EndDate1: undefined,  // //结束日期

            cardNo: '', // 卡号
            patNo: '',
            select1: '',
            select2: '',
            select3: '',
            nameNo: '',
            execID: [],
            ordID: '',
            modalShow: false,
            selectedRowKeys: [],
            money: {},
            bqType: '',
            jsType: '',
            chargeStatus: 'B',
            time1: '2',
            allMoney: 0,
            accSubStatus: {}, //账户状态
            userPayData: {}, //账户状态
            patBillID: '',
            subTypeFeeArr: [],
            dataTable2: [],
            cashInCashVal: '0.00', // 实收现金
            payAccIPAmt: '0.00',	//住院结算参与账户的金额
            otherPayDis: false, //其他支付方式不可选
            otherPayMoney: '0.00', // 其他支付金额
            selectedRows: [],
            recordID: '',
            ipInsuType: '',
            visible: false,
            visibleMoney: false,
            visibleMoney2: false,
            leftAmt: '',
            patAmt: '',
            payWListData: [],
            paywamtData: '',
            payWListkey: 10,
            accAmtBalance: '',
            leftAmtSur: '',
            disBtton1: true,
            disBtton2: true,
            disBtton3: true,
            disBtton4: true,
            disBtton5: true,
            disBtton6: true,
            disBtton7: true,
            accDepositIDinfo: '',
            readModeI: true,
            readModeR: true,
            INSURegisterVisable: false,
            comepnCode: '2101',
            xnhBCTYPE: '',
            ifsubmit: '0',
            YBPatDivdata: [],
            comepnCodeList: [],
            xnhBCTYPEList: [],
            insuPayID: '',
            ybPayDivdata: '',
            InsuIPPayButton: '0',
            InsuIPPayModalvisible: false,
            trialflag: '',
            xnhtreatCodeist: [],
            treatCode: '',
            icdAllNoEList: [],
            icdAllNo: '',
            ifNeedTreatWay: 'N',     // 治疗方式是否需要必填
            surplusamt: 0,
        })
    }

    // 数据配置
    tableList = (reactCode, compontName) => {
        var data = {
            params: [{
                "reactCode": [reactCode],
                "compontName": compontName,
                "type": "C"
            }]
        }

        $http.post('urlS', this, {
            code: "01040073",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (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.setState({ ColumnAuthority: compontName }, () => this.columnRef.onOpenModel())}>{item.title}</div>,
                            display: item.display,
                            key: item.seqNo
                        }
                    }) : '';

                    let filterArr = arr.filter(function (item) { return item.display === 'Y' });

                    if (compontName === 'IPPayBillList') {
                        this.setState({
                            columns1: filterArr, // 费用类型table
                        })
                    } else if (compontName === 'IPAdmList') {
                        this.setState({
                            columnsTop: filterArr, // 费用类型table
                        })
                    } else if (compontName === 'IPPayWList') {
                        let columns = [
                            {
                                title: '支付方式',
                                dataIndex: 'payWDesc',
                                editable: true,
                                width: '150px',
                                align: 'center'
                            },
                            {
                                title: '金额',
                                dataIndex: 'payWamt',
                                editable: true,
                                width: '150px',
                                align: 'center'
                            },
                            {
                                dataIndex: 'operation',
                                width: '20px',
                                align: 'center',
                                render: (text, record) => {
                                    const { editingKey } = this.state;
                                    const editable = this.isEditing(record);
                                    return (
                                        <span className="span" style={{ color: 'rgba(240,65,52,1)' }} onClick={() => this.handleDelete(record)}>X</span>
                                    );
                                },
                            },
                        ];
                        this.setState({
                            ipPayWListTop: columns, // 费用类型table
                        })
                    }

                }
            }
        });
    }
    // 新增表格数据
    handleAddTableData = () => {
        this.props.form.resetFields();
        const { payWListkey, payWListData } = this.state;
        let leg = payWListkey + 1;
        this.setState({
            payWListkey: leg,
        })
        let arr = [];
        const newData = {
            key: leg,
            payWID: '',
            payWCode: '',
            payWDesc: '',
            payWamt: ""
        };
        arr.push(newData)
        this.setState({
            payWListData: payWListData && payWListData.length > 0 ? [...payWListData, newData] : arr,
            editingKey: leg
        });
        this.checkpayMoneySurplus()
    }

    // 本地删除数据
    handleDelete = (rowData) => {
        if (this.state.payWListData.length === 1) {
            for (var i = 0; i < this.state.payWListData.length; i++) {
                if (this.state.payWListData[i].key === rowData.key) {
                    this.state.payWListData[i].payWID = this.state.otherPayData[0].paywID
                    this.state.payWListData[i].payWCode = this.state.otherPayData[0].paywCode
                    this.state.payWListData[i].payWDesc = this.state.otherPayData[0].paywDesc
                    this.state.payWListData[i].payWamt = ""
                    this.setState({ payWListData: this.state.payWListData });
                }
            }
        } else {
            const payWListData = JSON.parse(JSON.stringify(this.state.payWListData));
            this.setState({ payWListData: payWListData.filter(item => item.key !== rowData.key) });
        }
        this.checkpayMoneySurplus()
    }
    // 数据配置
    columns1(resC) {

        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
            })
        }

        this.setState({
            columns1: resC, // 费用类型table
        });
    }

    // 数据配置
    columnsTop(resC) {

        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
            })
        }

        this.setState({
            columnsTop: resC, // 费用类型table
        });
    }


    //卡类型
    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)
                    });
                }
            }
        });
    }

    //1.1.49.住院费用明细相关下拉框（病区）
    bqList = () => {
        var data = {
            params: [{
                "hospID": JSON.parse(window.sessionStorage.userData).hospID || '', //医院id
                "type": "W",
            }]
        }

        $http.post('urlS', this, {
            code: "04020008",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {

                    this.setState({
                        bqData: res.result.Data || [], // 数据
                    });
                }
            }
        });
    }

    //1.1.49.住院费用明细相关下拉框（结算）
    jsList = () => {
        var data = {
            params: [{
                "hospID": JSON.parse(window.sessionStorage.userData).hospID || '', //医院id
            }]
        }

        $http.post('urlS', this, {
            code: "05100129",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {

                    this.setState({
                        jsTypeData: res.data || [], // 数据
                    });
                }
            }
        });
    }




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


    // 读卡 --- 根据卡号取病人信息
    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'); // 重新调用查询接口
                    }
                })
            })
        }

    }


    // 读卡
    searchUser = (type, dataTableNo) => {
        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 || [],  // 用户数据
                        patNo: res.data.patNo || '',  // ID
                    }, () => {
                        if (!dataTableNo || dataTableNo != 'Y') {
                            this.dataTableTopData() // 就诊信息
                        }
                    });

                }
            }
        });
    }

    // 查询条件 --- 病区
    bqType = (e) => {
        this.setState({ bqType: e });
    }

    // 查询条件 --- 结算
    jsType = (e) => {
        this.setState({ jsType: e });
    }
    // 查询条件 --- 结算类型
    chargeStatus = (e) => {
        this.setState({ chargeStatus: e });
    }
    // 查询条件 --- 时间类型
    time1 = (e) => {
        this.setState({ time1: e });
    }

    // 查询条件 --- 卡类型·
    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 });
    }
    // 1.1.52.住院费用明细相关接口（就诊信息及费用信息接口）
    dataTableTopData = (e) => {
        let { pageSizeTop, pageTop, StartDateTop, EndDateTop, time1, bqType, jsType, cardType, cardNo, patNo, chargeStatus } = this.state
        var data = {
            params: [{
                "number": patNo || '', // 登记号/身份证号
                "cardTypeID": cardType,   //卡类型id
                "cardNo": cardNo,    //卡号
                hospID: JSON.parse(window.sessionStorage.userData).hospID || '', //医院id
                // patID: this.state.userInfo.patID,  //病人id
                "stopDate": EndDateTop,
                "startDate": StartDateTop,
                "condition": time1,
                "wardID": bqType, //病区
                "payReasonID": jsType,  //费别
                "chargeStatus": chargeStatus

            }],
            pagination: [{
                pageSize: pageSizeTop,
                currentPage: pageTop,
            }]
        }

        $http.post('urlS', this, {
            code: "05300013",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {
                    for (var i = 0; i < res.data.length; i++) {
                        res.data[i].key = i;
                    }
                    this.setState({
                        dataTableTop: res.data,
                        totalTop: res.total,
                    });

                }
            }
        });
    }

    // // 1.1.52.住院费用明细相关接口（医嘱清单）
    dataTable1Data = (e) => {
        let { pageSize1, page1, } = this.state
        if (!this.state.admID || this.state.admID === '') {
            message.error('请先选择就诊信息')
            return false
        }
        var data = {
            params: [{
                "admID": this.state.admID || '', //就诊ID
            }],
            pagination: [{
                pageSize: pageSize1,
                currentPage: page1,
            }]
        }

        $http.post('urlS', this, {
            code: "05300015",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {
                    for (var i = 0; i < res.data.length; i++) {
                        res.data[i].key = i;
                    }
                    this.setState({
                        dataTable1: res.data,
                        total1: res.total,
                        patBillID: '',
                    }, () => {
                        let { recordData, dataTable1 } = this.state
                        let newData = dataTable1.filter((item) => {
                            return item.number === recordData.number;
                        })
                        if (newData[0]) {
                            this.onClickRowPublic1(newData[0])
                        } else {
                            this.clearnUserPayData()
                        }
                    });

                } else {
                    this.setState({
                        dataTable1: [],
                        total1: 0,
                        patBillID: '',

                    })
                    this.clearnUserPayData()
                }


            }
        });

        var data2 = {
            params: [{
                "admID": this.state.admID || '', //就诊ID
                "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                "userID": JSON.parse(window.sessionStorage.userData).userID, //人员id
                "invTypeCode": "I",
            }],
            pagination: [{
                pageSize: pageSize1,
                currentPage: page1,
            }]
        }

        $http.post('urlS', this, {
            code: "05300014",
            data: data2,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {

                    this.setState({
                        accSubStatus: res.data[0] || {}, //账户状态
                    });

                } else {
                    this.setState({
                        accSubStatus: {},
                    })
                }
            }
        });
    }
    // 操作行
    onClickRowPublicTop = (record) => {
        this.setState({
            admID: record.admID,
            dataTable1: [],
            patNo: record.patNo,
            admReasonCode: record.admReasonCode
        }, () => {
            this.searchUser('patNo', 'Y')
            this.dataTable1Data()
        })
    }
    // 选中行操作
    setRowClassNamePublicTop = (record) => {
        return record.admID === this.state.admID ? 'clickRowStyle' : (record.chargeFlag === 'Y' ? "chargeFlag" : "");

    }
    // 操作行
    onClickRowPublic1 = (record) => {
        this.setState({ comepnCode: '2101', YBPatDivdata: [], comepnCodeList: [], ybPayDivdata: '', InsuIPPayButton: '0', InsuIPPayModalvisible: false, trialflag: '', insuPayID: '', xnhBCTYPEList: [], xnhBCTYPE: '', ifsubmit: '0', });
        let { recordData } = this.state
        this.setState({
            patBillID: record ? record.patBillID : recordData.patBillID, recordData: record ? record : recordData,
            source: record, fphm: record.fphm, fpdm: record.fpdm
        }, () => {
            this.userPayData()
            this.dataTable2()
            let payStatusCode = record ? record.payStatusCode : recordData.payStatusCode
            if (payStatusCode === 'TP') {
                //OB 需交费 TP预结算 P已结算
                this.setState({
                    disBtton1: false,
                    disBtton2: true,
                    disBtton3: false,
                    disBtton4: false,
                    disBtton5: true,
                    disBtton6: true,
                    disBtton7: false,
                })
            }
            if (payStatusCode === 'OB') {
                //OB 需交费 TP预结算 P已结算
                this.setState({
                    disBtton1: false,
                    disBtton2: false,
                    disBtton3: true,
                    disBtton4: false,		//结算
                    disBtton5: true,
                    disBtton6: false,
                    disBtton7: false,
                })
            }
            if (payStatusCode === 'P') {
                //OB 需交费 TP预结算 P已结算
                this.setState({
                    disBtton1: false,
                    disBtton2: true,
                    disBtton3: true,
                    disBtton4: true,
                    disBtton5: false,
                    disBtton6: true,
                    disBtton7: false,
                })
            }
        })
    }
    // 选中行操作
    setRowClassNamePublic1 = (record) => {
        return record.patBillID === this.state.patBillID ? 'clickRowStyle' : '';
    }

    // userPayData
    userPayData = (record) => {

        var data2 = {
            params: [{
                "patBillID": this.state.patBillID || '', //就诊ID
            }],
        }
        $http.post('urlS', this, {
            code: "05300016",
            data: data2,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {

                    this.setState({
                        userPayData: res.data[0] || {}, //账户状态
                        subTypeFeeArr: res.subTypeFeeArr || [],
                    });

                } else {
                    this.setState({
                        userPayData: {},
                        subTypeFeeArr: [],
                    })
                }
            }
        });
    }
    // 显示分页总条数
    showTotal(total) {
        return `共 ${total} 条`;
    }
    onChangeTop = (page, pageSize) => {
        this.setState({ pageTop: page, pageSizeTop: pageSize, patNo: '' }, () => {
            // 重新调用查询方法
            this.dataTableTopData();
        })
    }

    // 条数改变的回调
    onShowSizeChangeTop = (current, size) => {
        this.setState({ pageTop: 1, pageSizeTop: size, patNo: '' }, () => {
            // 重新调用查询方法
            this.dataTableTopData();
        })

    }

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

    // 条数改变的回调
    onShowSizeChange1 = (current, size) => {
        this.setState({ page1: 1, pageSize1: size }, () => {
            // 重新调用查询方法
            this.dataTable1Data();
        })

    }


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

    }

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

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


    //checkChange
    onSelectChange = (selectedRowKeys, selectedRows) => {
        let { accDepositIDinfo } = this.state
        selectedRows.map((item, i) => {
            accDepositIDinfo += item.accDID + '^'
        })

        this.setState({
            selectedRowKeys: selectedRowKeys,
            selectedRows: selectedRows,
            accDepositIDinfo: accDepositIDinfo
        })

    }

    // 试算
    budgetAndSettlement = () => {

        var data = {
            params: [{
                "billID": this.state.patBillID || '', //就诊ID,
                "userID": JSON.parse(window.sessionStorage.userData).userID, //人员id
            }],
        }

        $http.post('urlS', this, {
            code: "05300024",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {
                    this.dataTable1Data()
                    // setTimeout(() => {
                    //     let { recordData } = this.state
                    //     this.onClickRowPublic1(recordData)
                    // }, 100);
                    // Keup.ModalMessage(3, this, res.errorMessage, '关闭', 'destroy', "现在就去", 'success')
                }
            }
        });


    }
    //医保费用上传
    InsuUPloadItem = async () => {
        let openModal = Modal.info({
            title: "正在医保费用上传，请稍后......",
            content: <Spin size="large" />,
            onOk() { },
        });

        let insupaydata = {
            params: [{
                "billID": this.state.patBillID || '',
                "userID": JSON.parse(window.sessionStorage.userData).userID || '',
                "locID": JSON.parse(window.sessionStorage.userData).locID,
                "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id
                "ip": React.$getSessionData('ipConfig')?.ipv4 || '',
                "patID": this.state.userInfo.patID,  //病人id
                "reasonCode": this.state.recordData.admReasonCode

            }],
            "code": "05210054"
        }
        let YBPatDivdata = await INSUYBUtil.insuYBAHSYB("InsuUPloadItem", insupaydata);
        let res = JSON.parse(YBPatDivdata);
        let errorCode = res.errorCode
        openModal.destroy();
        if (res.errorCode == '0') {
            this.setState({ insuAdmID: res.insuAdmID });
            Keup.ModalMessage(3, this, '医保费用上传成功!', '自动关闭', 'destroy', '确定', 'success')
        }
        else {
            ///message.warn(res.errorMessage);
            //this.unbudgetAndSettlement()
            Keup.ModalMessage(15, this, res.errorMessage, '自动关闭', 'destroy', '确定', 'error')
        }
        return errorCode
    }
    //取消医保费用上传
    CancleInsuUPloadItem = async () => {
        let openModal = Modal.info({
            title: "正在取消医保费用上传，请稍后......",
            content: <Spin size="large" />,
            onOk() { },
        });
        let insupaydata = {
            params: [{
                "billID": this.state.patBillID || '',
                "userID": JSON.parse(window.sessionStorage.userData).userID || '',
                "locID": JSON.parse(window.sessionStorage.userData).locID,
                "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id
                "ip": React.$getSessionData('ipConfig')?.ipv4 || '',
                "patID": this.state.userInfo.patID,  //病人id
                "reasonCode": this.state.recordData.admReasonCode,
            }],
            "code": "05210056"
        }
        let YBPatDivdata = await INSUYBUtil.insuYBAHSYB("CancleInsuUPloadItem", insupaydata);
        let res = JSON.parse(YBPatDivdata);
        let errorCode = res.errorCode
        openModal.destroy();
        if (res.errorCode == '0') {
            this.setState({ insuAdmID: res.insuAdmID });
            Keup.ModalMessage(3, this, '医保费用取消成功!', '自动关闭', 'destroy', '确定', 'success')
        }
        else {
            ///message.warn(res.errorMessage);
            this.Cancellationoftrialcalculation()
            Keup.ModalMessage(15, this, res.errorMessage, '自动关闭', 'destroy', '确定', 'error')
        }
        return errorCode
    }
    comepnCodeonChange = (val, opt) => {
        this.setState({
            comepnCode: val,
            ifNeedTreatWay: opt.props.title.includes('按病种') ? 'Y' : 'N',
        });
    }

    ifsubmitonChange = (e) => {
        this.setState({ ifsubmit: e });
    }
    xnhBCTYPEListChange = (e) => {
        this.setState({ xnhBCTYPE: e });
    }
    xnhredeemNo = async () => {
        try {
            if (this.state.xnhjgCode !== '') {
                var paramsdata = {
                    params: [{
                        "insuAdmID": this.state.insuAdmID,
                        "userID": JSON.parse(window.sessionStorage.userData).userID || '',
                        "locID": JSON.parse(window.sessionStorage.userData).locID,
                        "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                        "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id
                        "xnhjgCode": (this.state.xnhjgCode),			//
                    }]
                }
                let YBPatDataobj = await INSUYBUtil.GoTOHISHttp(paramsdata, "05210063");    //调用his接口
                if (YBPatDataobj.errorCode == '0') {
                    let xnhBCTYPEList = YBPatDataobj.xnhBCTYPEList;
                    this.setState({
                        xnhBCTYPEList: xnhBCTYPEList,
                    });
                }
                else {
                    message.warn(res.errorMessage);
                }
            }
        } catch (error) {
            message.warning("异常:" + error)
        }
    }

    //医保预结算界面
    InsuIPPayModal = async (flag) => {
        let openModal = Modal.info({
            title: "正在医保费用预结算，请稍后......",
            content: <Spin size="large" />,
            onOk() { },
        });
        this.setState({
            YBPatDivdata: [], comepnCodeList: [], ybPayDivdata: '', InsuIPPayButton: '0', InsuIPPayModalvisible: false, insuPayID: '', xnhtreatCodeist: [],
            treatCode: '', icdAllNoEList: [], icdAllNo: '', INSUICDCode: '', INSUICDDesc: '',
        });
        this.setState({ InsuIPPayButton: flag });
        let errorCode = '0'
        this.xnhredeemNo()
        //查询有没记录医保病人信息
        var paramsdata = {
            params: [{
                "admID": this.state.admID, //就诊记录
                "userID": JSON.parse(window.sessionStorage.userData).userID || '', //操作人
                "ip": React.$getSessionData('ipConfig')?.ipv4 || '', //ip
                "hospID": JSON.parse(window.sessionStorage.userData).hospID || '', //医院
            }]
        }
        let YBPatDataobj = await INSUYBUtil.GoTOHISHttp(paramsdata, "05210048");    //调用his接口
        errorCode = YBPatDataobj.errorCode
        if (YBPatDataobj.errorCode == '0') {
            this.setState({
                insuAdmID: YBPatDataobj.insuAdmID,
                xnhjgCode: YBPatDataobj.xnhjgCode,
                treatCode: YBPatDataobj.treatCode,
                icdAllNo: YBPatDataobj.icdAllNo,
                INSUICDCode: YBPatDataobj.icdAllNo,
                INSUICDDesc: YBPatDataobj.icdAllDesc,
            }, () => {
                this.xnhtreatment()		//加载治疗方式
            });
            let { hospID } = JSON.parse(window.sessionStorage.userData).hospID;
            let paramsdata = {
                params: [{
                    hospID: hospID,
                    admReasonID: YBPatDataobj.admReasomID,
                    ybPatdata: YBPatDataobj.result,
                    admType: 'I'
                }]
            }
            let YBPatDivdata = await INSUYBUtil.GoTOHISHttp(paramsdata, "05210040");    //调用his接口    //组织医保病人信息
            errorCode = YBPatDataobj.errorCode
            if (YBPatDivdata.errorCode == '0') {
                openModal.destroy();
                let Divdata = YBPatDivdata.result;
                let ComepnCodeList = YBPatDivdata.comepnCodeList;
                this.setState({ YBPatDivdata: Divdata, comepnCodeList: ComepnCodeList, personalData: YBPatDataobj.result, InsuIPPayModalvisible: true });
                openModal.destroy();
            }
        }
        else {
            message.warn(res.errorMessage);
            openModal.destroy();
        }
        return errorCode
    }
    //医保结算
    InsuIPPay = async (ybPayType) => {
        let openModal = Modal.info({
            title: ybPayType === 'PAY' ? "正在医保结算，请稍后......" : '正在医保预结算，请稍后......',
            content: <Spin size="large" />,
            onOk() { },
        });
        //进入医保结算
        let itemselect = this.state.xnhtreatCodeist.filter((item) => {
            return item.subCode == this.state.treatCode;
        })
        let treatDesc = ""
        if (itemselect != '') {
            treatDesc = itemselect[0].subDesc
        }

        let insupaydata = {
            params: [{
                "ybPayType": ybPayType,  //医保预结算
                "insuPayID": this.state.insuPayID,  //医保预结算记录ID
                "admIDinfo": this.state.admID || '', // 结算类型
                "userID": JSON.parse(window.sessionStorage.userData).userID || '',
                "paytype": "I",
                "locID": JSON.parse(window.sessionStorage.userData).locID,
                "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id
                "ip": React.$getSessionData('ipConfig')?.ipv4 || '',
                "billID": this.state.patBillID, //交款记录id
                "recordID": this.state.recordID || '',
                "comepnCode": this.state.comepnCode,                    //结算类型编码(20190620新增) （请参阅附表结算类型字典，下同）
                "xnhBCTYPE": this.state.xnhBCTYPE,                    //农合补偿类型
                "treatCode": this.state.treatCode,                    //治疗方式
                "treatDesc": treatDesc,                              //治疗方式
                "icdAllNo": this.state.icdAllNo,                    //icd诊断
                "icdAllDesc": this.state.INSUICDDesc,
                "qrCode": '',
                "patID": this.state.userInfo.patID,  //病人id
                "reasonCode": this.state.recordData.admReasonCode,
                "ifsubmit": this.state.ifsubmit

            }],
            "code": "05210057"
        }
        let YBPayobj = await INSUYBUtil.insuYBAHSYB("InsuIPPay", insupaydata);
        openModal.destroy() //关闭等待界面
        return YBPayobj
    }
    //医保预结算
    InsuIPPrePay = async () => {
        //InsuIPPayButton Pay 医保结算
        if (this.state.recordData.admReasonCode === 'INSUHFXNHY') {
            if (this.state.xnhBCTYPE === '') {
                //农合补偿类型
                message.warn("请选择农合补偿类型");
                return
            }
        }
        // 按病种必须选治疗方式
        if (this.state.ifNeedTreatWay == 'Y' && this.state.treatCode == '') {
            message.warning('请选择治疗方式')
            return
        }
        // 选治疗方式必须选诊断
        if (this.state.icdAllNo == '' && this.state.treatCode != '') {
            message.warning('请选择诊断')
            return
        }
        this.setState({ InsuIPPayModalvisible: false, comepnCodeList: [], insuPayID: '', ifNeedTreatWay: 'N' });
        let YBPayobj = await this.InsuIPPay("PRE");
        let res = JSON.parse(YBPayobj);
        if (res.errorCode == '0') {
            //let secondsToGo=10
            this.setState({ insuPayID: res.insuPayID, ybPayDivdata: res.ybPayDivdata });
            if (this.state.InsuIPPayButton === '4') {
                //结算按钮
                ///打开结算界面
                this.OpenSettlement()
            }
            if (this.state.InsuIPPayButton === '2') {
                message.success(res.errorMessage)
                this.setState({ InsuIPPayModalvisible: false });
                // this.InsuIPPayModal(2)	//刷新界面  2022-7-21 ByYQL  当前预结算已完成，可取消再次弹框展示信息
            }
        }
        else {
            //医保结算失败
            this.setState({ YBPatDivdata: [], comepnCodeList: [], ybPayDivdata: '', InsuIPPayButton: '0', InsuIPPayModalvisible: false, xnhBCTYPEList: [] });
            //Smessage.warn(res.errorMessage);
            Keup.ModalMessage(30, this, res.errorMessage, '自动关闭', 'destroy', '确定', 'error')
        }


    }
    //金额1回车
    onPressEnter1 = () => {
        let { payType, otherPay, otherPayDis } = this.state
        setTimeout(() => {
            this.myRef3.current.focus();
        }, 300)



    }

    //金额1回车
    onPressEnter2 = () => {
        let { payType, otherPay, otherPayDis } = this.state
        // if setTimeout(() => {
        //     this.myRef5.current.focus();
        // }, 300)
    }
    // 结算弹框
    Settlement = async () => {
        let payopenModal = Modal.info({
            title: "正在his结算，请稍后......",
            content: <Spin size="large" />,
            onOk() { },
        });
        //先账单
        this.setState({
            recordID: '',
            ipInsuType: ''
        })
        let hisDataobj = await this.bill('1')
        let { recordData } = this.state

        if (hisDataobj.errorCode === '0') {
            this.setState({
                ipInsuType: recordData.ipInsuType
            })
            let ipInsuType = recordData.ipInsuType
            if (ipInsuType === 'Y') {
                ///读卡？
                //判断是否是医保，进行医保费用上传
                let errorCode = await this.InsuUPloadItem()	//进行医保费用上传
                if (errorCode === '0') {
                    //进行医保预结算
                    let errorCode = await this.InsuIPPayModal('4')
                }
                else {
                    this.handleCancel()
                }
            }
            else {
                this.OpenSettlement()
            }
        } else {
            Keup.ModalMessage(15, this, hisDataobj.errorMessage, '自动关闭', 'destroy', '确定', 'error')
        }
        setTimeout(() => {
            payopenModal.destroy() //关闭等待界面
        }, 1000);

    }
    // 结算弹框
    OpenSettlement = async () => {
        var paramsdata = {
            params: [{
                "admID": this.state.admID || '', //就诊ID,
                "billID": this.state.patBillID || '', //账单ID,
                "insuPayID": this.state.insuPayID,
                "paytype": "I",
                "userID": JSON.parse(window.sessionStorage.userData).userID, //人员id
                "accDepositIDinfo": this.state.accDepositIDinfo,
                "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id,
                "locID": JSON.parse(window.sessionStorage.userData).locID,//登录科室,
                "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                "ip": React.$getSessionData('ipConfig')?.ipv4 || '', 				//IP
            }],
        }
        let hisprepayobj = await INSUYBUtil.GoTOHISHttp(paramsdata, "05300017");    //his预算
        let errorCode = hisprepayobj.errorCode
        if (errorCode === '0') {
            this.setState({
                recordID: hisprepayobj.recordID
            })
        }
        else {
            Keup.ModalMessage(15, this, hisprepayobj.errorMessage, '自动关闭', 'destroy', '确定', 'error')
            return
        }
        var paramsdata = {
            params: [{
                recordID: this.state.recordID || '',
            }],
        }
        let hisdataobj = await INSUYBUtil.GoTOHISHttp(paramsdata, "05300021");    //his结算数据
        errorCode = hisdataobj.errorCode
        let accpayBalance = 0
        let payAccIPAmt = 0
        if (errorCode === '0') {
            payAccIPAmt = parseFloat(hisdataobj.data[0].accAmtBalance)
            this.setState({
                payAccIPAmt: parseFloat(payAccIPAmt).toFixed(2),
                accpayBalance: 0.00
            })
            // accpayBalance = parseFloat(Keup.MoneyReplace(hisdataobj.data[0].accAmtBalance)) - parseFloat(hisdataobj.data[0].leftAmt)
            // if (parseFloat(accpayBalance) < 0) {
            //     payAccIPAmt = parseFloat(hisdataobj.data[0].accAmtBalance)
            //     this.setState({
            //         payAccIPAmt: parseFloat(payAccIPAmt).toFixed(2),
            //         accpayBalance: 0.00
            //     })

            // }
            // else {
            //     payAccIPAmt = parseFloat(hisdataobj.data[0].leftAmt)
            //     this.setState({
            //         payAccIPAmt: parseFloat(payAccIPAmt).toFixed(2),
            //         accpayBalance: parseFloat(accpayBalance).toFixed(2),
            //     })
            // }
            this.setState({
                leftAmt: hisdataobj.data[0].leftAmt,
                leftAmtSur: hisdataobj.data[0].leftAmt,
                accAmtBalance: hisdataobj.data[0].accAmtBalance,
                patAmt: hisdataobj.data[0].patAmt,
                paywamtData: hisdataobj.data[0].paywamtData
            })
            let payWListData = [
                {
                    key: 1,
                    payWID: this.state.otherPayData[0].paywID,
                    payWCode: this.state.otherPayData[0].paywCode,
                    payWDesc: this.state.otherPayData[0].paywDesc,
                    payWamt: parseFloat(parseFloat(hisdataobj.data[0].leftAmt) - parseFloat(payAccIPAmt)).toFixed(2),
                }
            ]
            this.setState({
                payWListData: payWListData,
            })
            this.checkCash()
            this.checkpayMoneySurplus()
            this.setState({
                visible: true
            })

        }
    }
    handleCancel = () => {
        this.setState({
            visible: false,
            visibleMoney: false,
            visibleMoney2: false,
        })
        this.dataTable1Data()
        // setTimeout(() => {
        //     let { recordData } = this.state
        //     this.onClickRowPublic1(recordData)
        // }, 100);
    }

    handleCancelMoney = () => {
        this.setState({
            leftAmt: '',
            patAmt: '',
            payWListData: [],
            paywamtData: '',
            leftAmtSur: '',
            accAmtBalance: '',
            accpayBalance: '',
            zeroPay: '0.00', // 找零
            otherPayMoney: '0.00', // 其他支付金额
            cashInCashVal: '0.00', // 实收现金
            disXJ: false,
            payAccIPAmt: '0.00',	//住院结算参与账户的金额
        })
        this.handleCancel()
        this.unbudgetAndSettlement()
    }
    handleCancelInsuIPPayModal = () => {
        this.setState({ comepnCode: '2101', YBPatDivdata: [], comepnCodeList: [], ybPayDivdata: '', InsuIPPayButton: '0', InsuIPPayModalvisible: false, xnhBCTYPEList: [], xnhBCTYPE: '', ifsubmit: '', });
    }
    //账单
    bill = async (flag) => {
        var paramsdata = {
            params: [{
                "admID": this.state.admID || '', //就诊ID,
                "billID": this.state.patBillID || '', //账单ID,
                "userID": JSON.parse(window.sessionStorage.userData).userID, //人员id
                'ordExecStr': ''
            }]
        }
        let hisDataobj = await INSUYBUtil.GoTOHISHttp(paramsdata, "05300012");    //his试算
        let errorCode = hisDataobj.errorCode
        if (errorCode === '0' && flag !== '1') {
            Keup.ModalMessage(3, this, hisDataobj.errorMessage, '关闭', 'destroy', "现在就去", 'success')
        }
        return hisDataobj
    }
    handleOK = async () => {
        let { payType, cashInCashVal, zeroPay, otherPayMoney, leftAmt, payAccIPAmt } = this.state
        if ((cashInCashVal !== '') & (parseFloat(cashInCashVal) !== 0)) {
            if (parseFloat(zeroPay) < 0) {
                message.error('应找金额小于0，请核实实收金额是否正确')
                return false
            }
        }
        let paywAmt = 0 			//支付方式金额
        let notpayleftAmt = 0 	//剩余没结算金额
        let payWIDinfo = ""
        let errormessage = ''
        for (var i = 0; i < this.state.payWListData.length; i++) {
            if ((parseFloat(this.state.payWListData[i].payWamt) !== 0) & (this.state.payWListData[i].payWamt !== '')) {
                if (this.state.payWListData[i].payWID === '') {
                    errormessage = "支付方式列表存在支付方式为空，请选择支付方式"
                }
                paywAmt = paywAmt + parseFloat(this.state.payWListData[i].payWamt)
                if (payWIDinfo === '') {
                    payWIDinfo = this.state.payWListData[i].payWID + '^' + parseFloat(this.state.payWListData[i].payWamt)
                }
                else {
                    payWIDinfo = payWIDinfo + String.fromCharCode('2') + this.state.payWListData[i].payWID + '^' + parseFloat(this.state.payWListData[i].payWamt)
                }
            }
        }
        if (errormessage !== '') {
            message.error(errormessage)
            return false
        }
        notpayleftAmt = parseFloat(leftAmt) - parseFloat(payAccIPAmt) - parseFloat(paywAmt)
        if (parseFloat(notpayleftAmt) !== 0) {
            message.error('结算金额不符，还存在金额：' + parseFloat(notpayleftAmt) + "没计算进支付方式")
            return false
        }
        let openModalpay = Modal.info({
            title: "正在结算，请稍后......",
            content: <Spin size="large" />,
            onOk() { },
        });
        var paramsdata = {
            params: [{
                "recordID": this.state.recordID || '',
                "userID": JSON.parse(window.sessionStorage.userData).userID, //人员id
                "payWIDinfo": payWIDinfo,
                "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id,
                "locID": JSON.parse(window.sessionStorage.userData).locID,//登录科室,
                "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                "ip": React.$getSessionData('ipConfig')?.ipv4 || '', 				//IP
                'patBillID': this.state.patBillID || '', //账单ID,
                'payAccIPAmt': parseFloat(payAccIPAmt), //参与结算的账户金额,
            }]
        }
        let Updatapaywobj = await INSUYBUtil.GoTOHISHttp(paramsdata, "05300018");    //his更新支付方式
        let errorCode = Updatapaywobj.errorCode;
        if (errorCode === '0') {
            if (this.state.ipInsuType === 'Y') {
                //医保确认结算
                let YBPayobj = await this.InsuIPPay("PAY");
                let res = JSON.parse(YBPayobj);
                if (res.errorCode == '0') {

                }
                else {
                    message.error(res.errorMessage)
                    Keup.ModalMessage(5, this, res.errorMessage, '自动关闭', 'destroy', '确定', 'error')
                    this.unbudgetAndSettlement()	//删除预结算记录
                    this.handleCancel()
                    return
                }
            }
            var paramsdata = {
                params: [{
                    "recordID": this.state.recordID || '',
                    "admID": this.state.admID || '', //就诊ID,
                    "billID": this.state.patBillID || '', //就诊ID,
                    "paytype": "I",
                    "userID": JSON.parse(window.sessionStorage.userData).userID, //人员id
                    "accDepositIDinfo": this.state.accDepositIDinfo,
                    "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id,
                    "locID": JSON.parse(window.sessionStorage.userData).locID,//登录科室,
                    "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                    "ip": React.$getSessionData('ipConfig')?.ipv4 || '', 				//IP
                }]
            }
            let Compaywobj = await INSUYBUtil.GoTOHISHttp(paramsdata, "05300019");    //his收费确认
            let errorCode = Compaywobj.errorCode;
            if (errorCode === '0') {
                message.success(Compaywobj.errorMessage)
                this.handleCancel()
                this.setState({
                    compleRecordIDinfo: Compaywobj.compleRecordIDinfo
                }, () => {
                    this.loadInvoiceMessage()
                })
            } else {
                message.error(Compaywobj.errorMessage)
                this.unbudgetAndSettlement()	//删除预结算记录
            }
        }
        else {
            message.error(Updatapaywobj.errorMessage)
        }
        openModalpay.destroy() //关闭等待界面

    }
    // 收取住院账户余额
    onChangepayAccIPAmt = (e) => {
        let val = e.target.value
        let newVal = Keup.inputMoneyReplace(val)
        if (newVal === '') { newVal = 0 }
        //判断账户余额
        if (parseFloat(newVal) > parseFloat(this.state.accAmtBalance)) {
            message.error('住院账户余额只有：' + this.state.accAmtBalance + ' 不能超出')
            this.setState({
                payAccIPAmt: this.state.payAccIPAmt
            })
            return
        }
        let accpayBalance = parseFloat(Keup.inputMoneyReplace(this.state.accAmtBalance)) - parseFloat(newVal)
        if (parseFloat(accpayBalance) < 0) {
            this.setState({
                accpayBalance: 0.00
            })
        }
        else {
            this.setState({
                accpayBalance: parseFloat(accpayBalance).toFixed(2),
            })
        }
        this.setState({
            payAccIPAmt: newVal
        })
        //先对支付方式列表初始化
        let payWListData = [
            {
                key: 1,
                payWID: this.state.otherPayData[0].paywID,
                payWCode: this.state.otherPayData[0].paywCode,
                payWDesc: this.state.otherPayData[0].paywDesc,
                payWamt: parseFloat(parseFloat(this.state.leftAmt) - parseFloat(newVal)).toFixed(2),
            }
        ]
        this.setState({
            payWListData: payWListData,
        })
        this.checkCash()
        this.checkpayMoneySurplus()
    }
    //检查现金支付
    checkCash = () => {
        let payCashCodeamt = 0 	//现金金额
        for (var i = 0; i < this.state.payWListData.length; i++) {
            if (this.state.payWListData[i].payWCode === 'CASH') {
                if (parseFloat(this.state.payWListData[i].payWamt) !== 0) {
                    payCashCodeamt = payCashCodeamt + parseFloat(this.state.payWListData[i].payWamt)
                }
            }
        }
        if (parseFloat(payCashCodeamt) < 0) {
            this.setState({ zeroPay: parseFloat(payCashCodeamt).toFixed(2), cashInCashVal: 0.00 })
        } else {
            this.setState({ disXJ: true, cashInCashVal: parseFloat(payCashCodeamt).toFixed(2), zeroPay: 0.00 })
        }
    }
    //判断返回支付方式代码
    checkPayCode = (value) => {
        for (var i = 0; i < this.state.otherPayData.length; i++) {
            if (this.state.otherPayData[i].paywID === value) {
                return this.state.otherPayData[i].paywCode + '^' + this.state.otherPayData[i].paywDesc
            }
        }
        return ''
    }
    // 实收现金
    cashInCash = (val) => {
        let cashInCashVal = Keup.MoneyReplace(val)
        if (cashInCashVal === '') { cashInCashVal = 0 }
        let payCashCodeamt = 0 	//现金金额
        for (var i = 0; i < this.state.payWListData.length; i++) {
            if (this.state.payWListData[i].payWCode === 'CASH') {
                if (parseFloat(this.state.payWListData[i].payWamt) !== 0) {
                    payCashCodeamt = payCashCodeamt + parseFloat(this.state.payWListData[i].payWamt)
                }
            }
        }
        this.setState({
            cashInCashVal: cashInCashVal // 金额过滤
        })
        let zeroPay = parseFloat(parseFloat(cashInCashVal) - parseFloat(payCashCodeamt)).toFixed(2)// 找零
        this.setState({
            zeroPay: zeroPay // 找零
        })

    }
    // 支付方式选择
    payWSelect = (e) => {
        //editingKey
        const newData = [...this.state.payWListData];
        const index = newData.findIndex(item => this.state.editingKey === item.key);
        if (index > -1) {
            const item = newData[index];
            newData[index].payWID = e
            for (var i = 0; i < this.state.otherPayData.length; i++) {
                if (this.state.otherPayData[i].paywID === e) {
                    newData[index].payWCode = this.state.otherPayData[i].paywCode
                    newData[index].payWDesc = this.state.otherPayData[i].paywDesc
                }
            }
        }
        this.setState({ payWListData: newData });
        this.checkCash()
        this.checkpayMoneySurplus()
    }
    ///列表支付方式金额输入
    payMoney = (e) => {
        let val = e.target.value
        let newVal = Keup.inputMoneyReplace(val)
        if (newVal === '') { newVal = 0 }
        const newData = [...this.state.payWListData];
        const index = newData.findIndex(item => this.state.editingKey === item.key);
        if (index > -1) {
            newData[index].payWamt = newVal
        }
        this.setState({ payWListData: newData });
        this.checkCash()
        this.checkpayMoneySurplus()
    }
    ///检查支付方式剩余金额
    checkpayMoneySurplus = () => {
        let { leftAmt, payAccIPAmt } = this.state
        let paywAmt = 0 			//支付方式金额
        let surplusamt = 0 	//剩余没结算金额
        for (var i = 0; i < this.state.payWListData.length; i++) {
            if ((parseFloat(this.state.payWListData[i].payWamt) !== 0) & (this.state.payWListData[i].payWamt !== '')) {
                paywAmt = paywAmt + parseFloat(this.state.payWListData[i].payWamt)
            }
        }
        surplusamt = parseFloat(leftAmt) - parseFloat(payAccIPAmt) - parseFloat(paywAmt)
        this.setState({ surplusamt: surplusamt });
    }
    ///列表支付方式金额输入焦点事件
    payMoneyonFocus = (e) => {
        let val = e.target.value
        let newVal = Keup.inputMoneyReplace(val)
        if (newVal === '0.00') { newVal = '' }
        if (newVal === '0') { newVal = '' }
        const newData = [...this.state.payWListData];
        const index = newData.findIndex(item => this.state.editingKey === item.key);
        if (index > -1) {
            newData[index].payWamt = newVal
        }
        this.setState({ payWListData: newData });

    }
    dataTable2 = () => {
        var data = {
            params: [{
                "patBillID": this.state.patBillID || '', //就诊ID,
            }],
        }

        $http.post('urlS', this, {
            code: "05300020",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {

                    this.setState({
                        dataTable2: res.data || []
                    })
                }
            }
        });
    }


    // 费用清单
    ListOfHospitalizationExpenses = () => {


        this.setState({
            visibleMoney: true
        })
    }
    // 设置支付方式列表行属性
    ChangepayWonRow = (record) => {
        return {
            // 双击行编辑
            onDoubleClick: () => {
                this.props.form.resetFields();
                this.setState({ editingKey: record.key });
            },
        }
    }
    // 拆分账单

    SplitTheBill = () => {
        this.setState({
            visibleMoney2: true,
            paras: {
                patBillID: this.state.patBillID,
                userInfo: this.state.userInfo,
            }
        })
    }

    // 取消试算
    Cancellationoftrialcalculation = () => {
        var data = {
            params: [{
                "billID": this.state.patBillID || '', //就诊ID,
                "userID": JSON.parse(window.sessionStorage.userData).userID, //人员id
            }],
        }

        $http.post('urlS', this, {
            code: "05300025",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {
                    this.dataTable1Data()
                    // let { recordData } = this.state
                    // setTimeout(() => {
                    //     let { recordData } = this.state
                    //     this.onClickRowPublic1(recordData)
                    // }, 100);
                    // Keup.ModalMessage(3, this, res.errorMessage, '关闭', 'destroy', "现在就去", 'success')
                }
            }
        });
    }
    // 取消预结算
    unbudgetAndSettlement = async () => {

        //获取医保结算数据
        ///判断付款记录是否是医保记录
        var paramsdata = {
            params: [{
                "billID": this.state.patBillID, //付款记录串
                "invtype": "PAY",   //his交易流水
                "userID": JSON.parse(window.sessionStorage.userData).userID || '', //操作人
                "ip": React.$getSessionData('ipConfig')?.ipv4 || '', //ip
                "hospID": JSON.parse(window.sessionStorage.userData).hospID || '', //医院
            }]
        }
        let hisdataobj = await INSUYBUtil.GoTOHISHttp(paramsdata, "05210047");    //调用his接口
        if (hisdataobj.errorCode != '0') {
            message.warn(res.errorMessage);
            return
        }
        var insuPayID = hisdataobj.insuPayIDinfo
        if (insuPayID != "") {
            ///医保退费
            let dllInputdata = {
                "params": [{
                    "billID": this.state.patBillID, //账单ID
                    "userID": JSON.parse(window.sessionStorage.userData).userID,
                    "insuPayID": insuPayID,
                    "insuPayData": hisdataobj,
                    "hospID": JSON.parse(window.sessionStorage.userData).hospID,
                    "patID": this.state.userInfo.patID || '',  //病人id
                }],
                "code": "05210059"
            }
            let YBPatDivdata = await INSUYBUtil.insuYBAHSYB("InsuIPPayRefund", dllInputdata);
            let res = JSON.parse(YBPatDivdata);
            if (res.errorCode != '0') {
                message.warn(res.errorMessage);
                return
            }
        }
        var data = {
            params: [{
                "patBillID": this.state.patBillID || '', //就诊ID,
                "recordID": this.state.recordID || '', //就诊ID,
                "userID": JSON.parse(window.sessionStorage.userData).userID, //人员id
                "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id,
                "locID": JSON.parse(window.sessionStorage.userData).locID,//登录科室,
                "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                "ip": React.$getSessionData('ipConfig')?.ipv4 || '', 				//IP
            }],
        }

        $http.post('urlS', this, {
            code: "05300022",
            data: data,
            success: function (res) {
                let errorCode = res.errorCode;
                if (errorCode === '0') {

                    // Keup.ModalMessage(3, this, res.errorMessage, '关闭', 'destroy', "现在就去", 'success')
                }
                else {
                    message.error(res.errorMessage)
                }
            }
        });
    }
    onChangeINSURegisterVisable() {
        if (!this.state.admID || this.state.admID === '') {
            message.error('请先选择就诊信息')
            return false
        }
        this.setState({
            INSURegisterVisable: true,
        })
        this.child.resetFields()
        this.child.showModal()
        this.child.readYBPatdata(this.state.admID, this.state.userInfo)
    }
    // 调用子组件的连接事件
    onRef = (ref) => {
        this.child = ref
    }
    // 取消结算
    Cancellation = async () => {
        let openModal = Modal.info({
            title: "正在退费，请稍后......",
            content: <Spin size="large" />,
            onOk() { },
        });
        let errorCode = '0'
        let { recordData } = this.state
        let ipInsuType = recordData.ipInsuType
        ///判断付款记录是否是医保记录
        var paramsdata = {
            params: [{
                "billID": this.state.patBillID, //付款记录串
                "invtype": "PAY",   //his交易流水
                "userID": JSON.parse(window.sessionStorage.userData).userID || '', //操作人
                "ip": React.$getSessionData('ipConfig')?.ipv4 || '', //ip
                "hospID": JSON.parse(window.sessionStorage.userData).hospID || '', //医院
            }]
        }
        let hisdataobj = await INSUYBUtil.GoTOHISHttp(paramsdata, "05210047");    //调用his接口
        if (hisdataobj.errorCode != '0') {
            message.warn(res.errorMessage);
            return
        }
        var insuPayID = hisdataobj.insuPayIDinfo
        if (insuPayID != "") {
            ///医保退费
            let dllInputdata = {
                "params": [{
                    "userID": JSON.parse(window.sessionStorage.userData).userID,
                    "insuPayID": insuPayID,
                    "insuPayData": hisdataobj,
                    "hospID": JSON.parse(window.sessionStorage.userData).hospID,
                    "patID": this.state.userInfo.patID || '',  //病人id
                }],
                "code": "05210059"
            }
            let YBPatDivdata = await INSUYBUtil.insuYBAHSYB("InsuIPPayRefund", dllInputdata);
            let res = JSON.parse(YBPatDivdata);
            if (res.errorCode != '0') {
                message.warn(res.errorMessage);
                return
            }
        }
        if (errorCode === '0') {
            var data = {
                params: [{
                    "billID": this.state.patBillID || '', //就诊ID,
                    "userID": JSON.parse(window.sessionStorage.userData).userID, //人员id
                    "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id,
                    "locID": JSON.parse(window.sessionStorage.userData).locID,//登录科室,
                    "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                    "ip": React.$getSessionData('ipConfig')?.ipv4 || '', 				//IP
                }]
            }
            $http.post('urlS', this, {
                code: "05300023",
                data: data,
                success: function (res) {
                    let errorCode = res.errorCode;
                    if (errorCode === '0') {
                        this.dataTable1Data()
                        if (!Util.isEmpty(this.state.source) && !Util.isEmpty(this.state.source.fphm)) {
                            this.handleDelPrint()
                        }
                        // setTimeout(() => {
                        //     let { recordData } = this.state
                        //     this.onClickRowPublic1(recordData)
                        // }, 100);
                        // Keup.ModalMessage(3, this, res.errorMessage, '关闭', 'destroy', "现在就去", 'success')
                    }
                }
            });
        }
        openModal.destroy() //关闭等待界面
    }

    //金税作废发票
    handleDelPrint() {
        let that = this
        var data = {
            'fpzl': 2,
            'fphm': this.state.source ? this.state.source.fphm : '', // 金税发票号码
            'fpdm': this.state.source ? this.state.source.fpdm : '', // 金税发票代码
        }
        var source = encodeURIComponent(JSON.stringify(data));
        var dllInput = 'SID=4\&\&\&\SIDParam=' + source; // JSON.stringify({ "SID": "0", "SIDParam": source })
        let dllParams = JSON.stringify({ 'inputDir': 'JSInv/prykjsapplication.dll', 'clsName': 'prykjsapplication.JSHelper', 'funcName': 'GetJSData', 'dllInput': dllInput });
        if (typeof (CefSharp) != "undefined") { // 新元素定制浏览器
            CefSharp.BindObjectAsync("xysCefToJavaScripts");
            setTimeout(() => {
                xysCefToJavaScripts.driveLocalHardware(dllParams).then((returnVale) => {
                    var res = JSON.parse(returnVale);
                    if (res.resultCode == '0') {
                        message.success('作废成功！')
                    }
                })
            }, 100);
        } else {
            const frame = chrome?.webview?.hostObjects?.Bridge || ''; // 新版浏览器
            if (frame) {
                frame.DynamicLoadingDLL(dllParams)
                    .then(
                        data => {
                            var res = JSON.parse(data);
                            if (res.resultCode == '0') {
                                message.success('作废成功！')
                            }
                        },
                        err => {
                            console.log('error', err);
                        }
                    )
            } else {
                $.getJSON("http://127.0.0.1:62534/XYSWCFService/DynamicLoadingDLL?JsonCallback=?", {
                    input: dllParams
                },
                    function (data) {
                        var res = JSON.parse(data);
                        if (res.resultCode == '0') {
                            message.success('作废成功！')
                        }
                    });
            }
        }
    }

    // 右键菜单事件
    handleContextMenu = (record, event) => {
        if (this.root)
            event.preventDefault()
        this.onClickRowPublic1(record)
        this.setState({ contextMenuvisible: true })
        // clientX/Y 获取到的是触发点相对于浏览器可视区域左上角距离
        const clickX = event.clientX
        const clickY = event.clientY
        // window.innerWidth/innerHeight 获取的是当前浏览器窗口的视口宽度/高度
        const screenW = window.innerWidth
        const screenH = window.innerHeight
        // 获取自定义菜单的宽度/高度
        const rootW = this.root.offsetWidth
        const rootH = this.root.offsetHeight
        // right为true，说明鼠标点击的位置到浏览器的右边界的宽度可以放下菜单。否则，菜单放到左边。
        // bottom为true，说明鼠标点击位置到浏览器的下边界的高度可以放下菜单。否则，菜单放到上边。
        const right = (screenW - clickX) > rootW
        const left = !right
        const bottom = (screenH - clickY) > rootH
        const top = !bottom
        if (right) {
            this.root.style.left = `${clickX}px`
        }
        if (left) {
            this.root.style.left = `${clickX - rootW}px`
        }
        if (bottom) {
            this.root.style.top = `${clickY}px`
        }
        if (top) {
            this.root.style.top = `${clickY - rootH}px`
        }
    };

    //治疗方式
    xnhtreatment = async () => {
        try {
            if (((this.state.xnhjgCode !== '') && (this.state.recordData.admReasonCode != 'INSUHFSYB')) || (this.state.recordData.admReasonCode == 'INSUHFSYB')) {
                var paramsdata = {
                    params: [{
                        "insuAdmID": this.state.insuAdmID,
                        "userID": JSON.parse(window.sessionStorage.userData).userID || '',
                        "locID": JSON.parse(window.sessionStorage.userData).locID,
                        "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                        "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id
                        "xnhjgCode": (this.state.xnhjgCode),			//
                        "reasonCode": this.state.recordData.admReasonCode,
                    }]
                }
                let YBPatDataobj = await INSUYBUtil.GoTOHISHttp(paramsdata, "05210064");    //调用his接口
                if (YBPatDataobj.errorCode == '0') {
                    let xnhtreatCodeist = YBPatDataobj.xnhtreatCodeist;
                    this.setState({
                        xnhtreatCodeist: xnhtreatCodeist,
                    });
                }
                else {
                    message.warn(res.errorMessage);
                }
            }
        } catch (error) {
            message.warning("异常:" + error)
        }
    }

    xnhtreatCodeistChange = (val) => {
        this.setState({
            treatCode: val,
            icdAllNo: '',
            INSUICDDesc: ''
        });

        // setTimeout(() => {
        //     this.xnhtreatmentICD();
        // }, 10);
    }

    //治疗方式ICD诊断
    xnhtreatmentICD = async () => {
        try {
            if (this.state.xnhjgCode !== '') {
                var paramsdata = {
                    params: [{
                        "insuAdmID": this.state.insuAdmID,
                        "userID": JSON.parse(window.sessionStorage.userData).userID || '',
                        "locID": JSON.parse(window.sessionStorage.userData).locID,
                        "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                        "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id
                        "xnhjgCode": (this.state.xnhjgCode),			//
                        "treatCode": (this.state.treatCode),			//
                    }]
                }
                let YBPatDataobj = await INSUYBUtil.GoTOHISHttp(paramsdata, "05210068");    //调用his接口
                if (YBPatDataobj.errorCode == '0') {
                    let icdAllNoEList = YBPatDataobj.icdAllNoEList;
                    this.setState({
                        icdAllNoEList: icdAllNoEList,
                    });
                }
                else {
                    message.warn(res.errorMessage);
                }
            }
        } catch (error) {
            message.warning("异常:" + error)
        }
    }

    icdAllNoEListChange = (e) => {
        this.setState({ icdAllNo: e });
    }

    isEditing = record => record.key === this.state.editingKey;

    handleTableCancel = (record) => {
        let status = Util.checkAttributeIsEmpty(this.props.form.getFieldsValue());
        if (status) {
            // 都为空则删除该条记录
            this.setState({ editingKey: '' }, () => {
                this.handleDelete(record);
            })
        } else {
            this.setState({ editingKey: '' })
        }
    };

    // -- ICD诊断
    modalOnRef = (ref) => {
        this.modalChild = ref
    }

    // 诊断回车事件
    itmOnPressEnter = () => {
        let top = document.getElementById('inputDiag-id').getBoundingClientRect().top + 30 + 'px';
        let left = document.getElementById('inputDiag-id').getBoundingClientRect().left + 'px';
        this.setState({
            top,
            left,
            modalPage: 1
        });
        this.getModalListData(this.state.searchCode);
        //
    }

    itmOnChange = (e) => {
        if (!e.target.value) {
            this.setState({
                searchCode: '',
                INSUICDDesc: '',
                icdAllNo: ''
            })
        } else {
            this.setState({ searchCode: e.target.value })
        }
    }

    handleCompilePage = (page, pageSize) => {
        this.setState({ modalPageSize: pageSize, modalPage: page }, () => {
            this.getModalListData(this.state.searchCode);
        })
    }

    // 获取描述列表数据
    getModalListData(searchCode) {
        let { modalPageSize, modalPage, pageSize, page, admReasomID } = this.state;
        let data = {
            params: [
                {
                    insuAdmID: this.state.insuAdmID,
                    userID: JSON.parse(window.sessionStorage.userData).userID || '',
                    locID: JSON.parse(window.sessionStorage.userData).locID,
                    hospID: JSON.parse(window.sessionStorage.userData).hospID, //医院id
                    groupID: JSON.parse(window.sessionStorage.userData).groupID,  //角色id
                    xnhjgCode: (this.state.xnhjgCode),			//
                    treatCode: (this.state.treatCode),			//
                    searchCode: searchCode,
                    reasonCode: this.state.recordData.admReasonCode
                }
            ],
            pagination: [{
                pageSize: modalPageSize,
                currentPage: modalPage,
                sortColumn: "Describe",
                sortOrder: "asc"
            }]
        }
        $http.post('urlS', this, {
            code: "05210068",
            data: data,
            success: function (res) {
                if (res.errorCode == '0') {
                    var source = res.result.data
                    for (var i = 0; i < source.length; i++) {
                        source[i].key = i + 1
                    }
                    this.setState({ icdAllNoEList: source, modalTotal: res.result.totalCount }, () => {
                        this.modalChild.showModal();
                    })
                } else {
                    this.setState({ icdAllNoEList: [], modalTotal: 0 })
                }
            }
        })
    }

    // 下拉table双击
    onClickRowPublic = (record) => {
        return {
            onDoubleClick: () => {
                this.setState({
                    icdAllNo: record.code,
                    INSUICDDesc: record.descripts,
                    searchCode: ''
                }, () => this.modalChild.handleCancel())
            }
        }

    }

    setRowClassNamePublic = () => {
        // return (record.id) === this.state.diagID ? 'clickRowStyle' : '';
    }

    handlePrintList() {
        let that = this
        var data = {
            'fpzl': 2,
            'fphm': this.state.source ? this.state.source.fphm : '', // 金税发票号码
            'fpdm': this.state.source ? this.state.source.fpdm : '', // 金税发票代码
            'showPrintDlg': 0
        }
        var source = encodeURIComponent(JSON.stringify(data))
        var dllInput = 'SID=3\&\&\&\SIDParam=' + source; // JSON.stringify({ "SID": "0", "SIDParam": source })
        let dllParams = JSON.stringify({ 'inputDir': 'JSInv/prykjsapplication.dll', 'clsName': 'prykjsapplication.JSHelper', 'funcName': 'GetJSData', 'dllInput': dllInput });
        if (typeof (CefSharp) != "undefined") { // 新元素定制浏览器
            CefSharp.BindObjectAsync("xysCefToJavaScripts");
            setTimeout(() => {
                xysCefToJavaScripts.driveLocalHardware(dllParams).then((returnVale) => {
                    var res = JSON.parse(returnVale);
                    if (res.resultCode == '0') {
                        message.success('打印成功！');
                    }
                })
            }, 100);
        } else {
            const frame = chrome?.webview?.hostObjects?.Bridge || ''; // 新版浏览器
            if (frame) {
                frame.DynamicLoadingDLL(dllParams)
                    .then(
                        data => {
                            var res = JSON.parse(data);
                            if (res.resultCode == '0') {
                                message.success('打印成功！');
                            }
                        },
                        err => {
                            console.log('error', err);
                        }
                    )
            } else {
                $.getJSON("http://127.0.0.1:62534/XYSWCFService/DynamicLoadingDLL?JsonCallback=?", {
                    input: dllParams
                },
                    function (data) {
                        var res = JSON.parse(data);
                        if (res.resultCode == '0') {
                            message.success('打印成功！');
                        }
                    });
            }
        }
    }

    printSettlementList = () => {
        let { insuPayID, admReasonCode } = this.state;
        let data = {
            params: [
                {
                    insuPayID: insuPayID || '21',
                    admReasonCode
                }
            ]
        }
        $http.post('urlS', this, {
            code: "05210079",
            data: data,
            success: function (res) {
                if (+res.errorCode === 0) {
                    $loopPrint('', res.result);
                }
            }
        })
    }

    //原号重打
    handlePrintReceive() {
        let that = this
        var data = {
            'fpzl': 2,
            'fphm': this.state.fphm,//金税发票号码
            'fpdm': this.state.fpdm,//金税发票代码
            'showPrintDlg': 0
        }
        var source = encodeURIComponent(JSON.stringify(data));
        var dllInput = 'SID=2\&\&\&\SIDParam=' + source; // JSON.stringify({ "SID": "0", "SIDParam": source })
        let dllParams = JSON.stringify({ 'inputDir': 'JSInv/prykjsapplication.dll', 'clsName': 'prykjsapplication.JSHelper', 'funcName': 'GetJSData', 'dllInput': dllInput });
        if (typeof (CefSharp) != "undefined") {   // 新元素定制浏览器
            CefSharp.BindObjectAsync("xysCefToJavaScripts");
            setTimeout(() => {
                xysCefToJavaScripts.driveLocalHardware(dllParams).then((returnVale) => {
                    var res = JSON.parse(returnVale);
                    if (res.resultCode == '0') {
                        message.success('打印成功！');
                    }
                })
            }, 100);
        } else {
            const frame = chrome?.webview?.hostObjects?.Bridge || ''; // 新版浏览器
            if (frame) {
                frame.DynamicLoadingDLL(dllParams)
                    .then(
                        data => {
                            var res = JSON.parse(data);
                            if (res.resultCode == '0') {
                                message.success('打印成功！');
                            }
                        },
                        err => {
                            console.log('error', err);
                        }
                    )
            } else {
                $.getJSON("http://127.0.0.1:62534/XYSWCFService/DynamicLoadingDLL?JsonCallback=?", {
                    input: dllParams
                },
                    function (data) {
                        var res = JSON.parse(data);
                        if (res.resultCode == '0') {
                            message.success('打印成功！');
                        }
                    });
            }
        }
    }

    render() {
        // 组件所需参数
        const paramTop = {

            // 数据总条数
            total: this.state.totalTop,
            // 数据页数
            page: this.state.pageTop,
        }

        // 组件所需参数
        const param1 = {
            // 表头配置
            columns: this.state.columns1,
            // 表格数据
            data: this.state.dataTable1,
            // 数据总条数
            total: this.state.total1,
            // 数据页数
            page: this.state.page1,
        }

        const { userPayData, accSubStatus, language, modalTotal, modalPage, icdAllNoEList, top, left, } = this.state

        let rowSelection = {
            selectedRowKeys: this.state.selectedRowKeys,
            onChange: this.onSelectChange,
        };

        const components = {
            body: {
                cell: EditableCell,
            },
        };


        let operTypeDescOption = this.state.otherPayData && this.state.otherPayData.map((item, index) => {
            return (<Option title={item.paywDesc + '^' + item.paywCode} key={item.paywID} value={item.paywID}>{item.paywDesc}</Option>)
        })

        const filterColumns = this.state.ipPayWListTop.map(col => {
            if (!col.editable) {
                return col;
            }
            return {
                ...col,
                onCell: record => ({
                    record,
                    option: col.dataIndex === 'payWDesc' ? operTypeDescOption : "",
                    inputType: col.dataIndex === 'payWDesc' ? 'select' : 'text',
                    dataIndex: col.dataIndex,
                    title: col.title,
                    editing: this.isEditing(record),
                    source: {
                        paywselect: this.payWSelect,
                        paymoney: this.payMoney,
                        paymoneyonfocus: this.payMoneyonFocus,
                    }
                }),
            };
        });
        const addUSerInfo = (
            < div >
                <span style={{ marginRight: '20px' }}> 账户状态：<span style={{ color: '#007AFF', fontWeight: 'bold' }}>{accSubStatus.accSubStatusDesc || '正常'}</span></span>
                <span style={{ marginRight: '20px' }}> 本次就诊押金：<span style={{ color: '#007AFF', fontWeight: 'bold' }}>￥：{accSubStatus.admYJAmt || '0'}</span></span>
                <span style={{ marginRight: '20px' }}> 账户余额：<span style={{ color: '#007AFF', fontWeight: 'bold' }}>￥：{accSubStatus.accSubBlance || '0'}</span></span>
                <span style={{ marginRight: '20px' }}> 冻结金额：<span style={{ color: '#007AFF', fontWeight: 'bold' }}>￥：{accSubStatus.ipLockAccount || '0'}</span></span>
                <span style={{ marginRight: '20px' }}>可用金额：<span style={{ color: '#007AFF', fontWeight: 'bold' }}>￥：{accSubStatus.opBalance || '0'}</span></span>
            </div >
        )
        const contentPopover = (
            <div>
                <Table
                    className="smallTable"
                    pagination={false}
                    bordered
                    columns={this.columns2}
                    dataSource={this.state.dataTable2}
                    rowSelection={rowSelection}
                    scroll={{ y: 300, x: 700 }}
                    style={{ minHeight: '150px' }}
                />
            </div>
        );
        const modalParam = {
            width: '600px',
            total: modalTotal,
            page: modalPage,
            top: top,
            left: left,
            columns: this.modalColumns,
            data: icdAllNoEList,
            isOnRow: true,
            showPagination: true,
        }
        return (
            <div style={{ background: '#e8e8e8', height: '100%', overflow: 'hidden' }} className='hospital-zation-express'>

                <ReadCard ref={r => this.readCard = r} />
                <Row>
                    <Col span={6}>
                        <Card style={{ width: '100%', padding: '0' }} className='pd0'
                            title={<span><img src={cost_type} style={{ marginRight: 5 }} />{language.DischargeSettlementQueryvisitrecords && language.DischargeSettlementQueryvisitrecords.descripts} </span>}>
                            <div style={{ padding: 12, lineHeight: '32px' }}>
                                <Row className='mB10'>
                                    <Col span={7}>
                                        <Select allowClear style={{ width: '100%', }} placeholder={language.DischargeSettlementVisitingward && language.DischargeSettlementVisitingward.message} value={this.state.cardType} onChange={(event) => { this.cardType(event) }}  >
                                            <Option value=''>{language.DischargeSettlementVisitingward && language.DischargeSettlementVisitingward.message}</Option>
                                            {this.state.cardTypeData.map(item => <Option title={item.descripts + '^' + item.descriptsSPCode} key={item.id} value={item.id}  >{item.descripts}</Option>)}
                                        </Select>
                                    </Col>
                                    <Col span={16} offset={1}>
                                        <Search className={`search ${!this.state.readModeI ? 'disabled' : ''}`} style={{ width: '100%', }} allowClear placeholder={language.DischargeSettlementCardnumber && language.DischargeSettlementCardnumber.message} disabled={this.state.disabledInput} value={this.state.cardNo} enterButton="读卡" onChange={(event) => { this.cardNo(event) }} onSearch={this.handleReadCard} />
                                    </Col>
                                </Row>
                                <Row className='mB10'  >
                                    <Col span={25}>
                                        <Input.Group>
                                            <Input className='express-input-disable' style={{ width: '30%', textAlign: 'center' }} value={language.DischargeSettlementPatientinformation && language.DischargeSettlementPatientinformation.descripts + '：'} disabled />
                                            <Input allowClear style={{ width: '69.9%', }} placeholder={language.DischargeSettlementPatientinformation && language.DischargeSettlementPatientinformation.message} className='input' value={this.state.patNo} onChange={(event) => { this.patNo(event) }} onKeyUp={(e) => { this.patNodownE(e, 'patNo'); }} />
                                        </Input.Group>
                                    </Col>
                                </Row>
                                <Row className='mB10'   >
                                    <Col span={25}>
                                        <Input.Group>
                                            <Input className='express-input-disable' style={{ width: '30%', textAlign: 'center' }} value={language.DischargeSettlementInpatientNo && language.DischargeSettlementInpatientNo.descripts + '：'} disabled />
                                            <Input allowClear style={{ width: '69.9%' }} placeholder={language.DischargeSettlementInpatientNo && language.DischargeSettlementInpatientNo.message} className='input' />
                                        </Input.Group>
                                    </Col>
                                </Row>
                                <Row className='mB10'  >
                                    <Col span={25}>
                                        <Input.Group>
                                            <Input className='express-input-disable' style={{ width: '30%', textAlign: 'center' }} value={language.DischargeSettlementVisitingward && language.DischargeSettlementVisitingward.descripts + '：'} disabled />
                                            <Select className='express-select-border' allowClear style={{ width: '69.9%' }} placeholder={language.DischargeSettlementVisitingward && language.DischargeSettlementVisitingward.message} value={this.state.bqType} onChange={(event) => { this.bqType(event) }}  >
                                                <Option value=''>{language.DischargeSettlementVisitingward && language.DischargeSettlementVisitingward.message}</Option>
                                                {this.state.bqData.map(item => <Option title={item.descripts + '^' + item.descriptsSPCode} key={item.id} value={item.id}  >{item.descripts}</Option>)}
                                            </Select>
                                        </Input.Group>
                                    </Col>
                                </Row>
                                <Row className='mB10'>
                                    <Col span={25}>
                                        <Input.Group>
                                            <Input className='express-input-disable' style={{ width: '30%', textAlign: 'center' }} value={language.DischargeSettlementSettlementtype && language.DischargeSettlementSettlementtype.descripts + '：'} disabled />
                                            <Select className='express-select-border' allowClear style={{ width: '69.9%' }} placeholder={language.DischargeSettlementVisitingward && language.DischargeSettlementVisitingward.message} value={this.state.jsType} onChange={(event) => { this.jsType(event) }}  >
                                                <Option value=''>{language.DischargeSettlementVisitingward && language.DischargeSettlementVisitingward.message}</Option>
                                                {this.state.jsTypeData.map(item => <Option title={item.descripts + '^' + item.descriptsSPCode} key={item.id} value={item.id}  >{item.descripts}</Option>)}
                                            </Select>
                                        </Input.Group>
                                    </Col>
                                </Row>
                                <Row className='mB10'>
                                    <Input.Group>
                                        <Input className='express-input-disable' style={{ width: '30%', textAlign: 'center' }} value={language.DischargeSettlementChargeStatus && language.DischargeSettlementChargeStatus.descripts + '：'} disabled />
                                        <Select
                                            className='express-select-border'
                                            allowClear style={{ width: '69.9%' }}
                                            placeholder={language.DischargeSettlementChargeStatus && language.DischargeSettlementChargeStatus.message}
                                            value={this.state.chargeStatus}
                                            onChange={(event) => { this.chargeStatus(event) }}
                                        >
                                            <Option value='P'>已结算</Option>
                                            <Option value='B'>未结算</Option>
                                        </Select>
                                    </Input.Group>
                                </Row>
                                <Row className='mB10'>

                                    <Col span={25}>
                                        <Input.Group style={{ display: 'flex' }}>
                                            <div style={{ width: '37%' }}><Select className='express-select-right' style={{ width: '100%' }} allowClear placeholder="请选择时间" value={this.state.time1} onChange={(event) => { this.time1(event) }}  >
                                                <Option value='1'>入院时间</Option>
                                                <Option value='2'>出院时间</Option>
                                            </Select></div>
                                            <div><RangeDatePicker className='express-select-border' format='YYYY-MM-DD' style={{ width: '100%' }}
                                                startChange={this.startChange.bind(this)} endChange={this.endChange.bind(this)} /></div>
                                        </Input.Group>
                                    </Col>
                                </Row>
                                <Row style={{ textAlign: 'right', marginTop: '20px' }}>
                                    <Button type='primary' style={{ marginRight: '25px', width: 210 }} onClick={() => this.dataTableTopData()} >{language.DischargeSettlementquery && language.DischargeSettlementquery.descripts}</Button>
                                    <Button onClick={() => this.clearn()} style={{ width: 210 }}>{language.DischargeSettlementempty && language.DischargeSettlementempty.descripts}</Button>
                                </Row>
                            </div>
                        </Card>
                        <Card style={{ width: '100%', padding: '0' }} className='pd0'
                            title={<span><img src={istvisits} style={{ marginRight: 5 }} />{language.DischargeSettlementVisitinglist && language.DischargeSettlementVisitinglist.descripts}</span>}  >
                            <Button style={{ position: 'absolute', right: '180px', top: '2px' }} onClick={this.onChangeINSURegisterVisable.bind(this)} >医保登记</Button>
                            <Button style={{ position: 'absolute', right: '12px', top: '2px' }} onClick={() => this.bill()} >{language.DischargeSettlementbill && language.DischargeSettlementbill.descripts}</Button>
                            <div style={{ padding: 12, }} >
                                <Table
                                    pagination={false}
                                    bordered
                                    scroll={{ y: (store.getState().tableHeight.y) - 300, x: 1100 }}
                                    columns={this.state.columnsTop}
                                    dataSource={this.state.dataTableTop}
                                    style={{ minHeight: (store.getState().tableHeight.y) - 300 + 'px' }}
                                    onRow={(record) => {
                                        return {
                                            onClick: (event) => {
                                                this.onClickRowPublicTop(record)
                                            },
                                        };
                                    }}
                                    rowClassName={(record) => this.setRowClassNamePublicTop(record)}
                                />
                                <ColumnAuthoritysModel
                                    clientWidth='900px'
                                    compontName={this.state.ColumnAuthority}
                                    configType="C"
                                    onRef={this.onColumnRef}
                                    reloadData={() => {
                                        this.tableList(this.state.ColumnAuthority, this.state.ColumnAuthority)
                                    }}
                                />
                                <CommonPagination size="small" current={paramTop.page} total={paramTop.total} search='search'
                                    onShowSizeChange={this.onShowSizeChangeTop.bind(this)} complete={false} dataSource={this.state.dataTableTop}
                                    onChange={this.onChangeTop.bind(this)} />
                            </div>
                        </Card>
                    </Col>
                    <Col span={18}>
                        <div>
                            <Card>
                                <Row >
                                    <Col span={10}>
                                        <div >
                                            <TipHeader userInfo={this.state.userInfo} key={this.state.userInfo.patID + this.state.userInfo.accTSubID} />
                                        </div>
                                    </Col>
                                    <Col span={14} >
                                        <Row>
                                            <Col span={4} style={{ textAlign: 'center', background: '#F7FBFF' }}>
                                                <div className='payBox'>
                                                    <p className='p2' style={{ color: '#007AFF' }}><span style={{ color: '#1890FF', cursor: "pointer" }} onClick={() => { this.historyModal() }}>
                                                        {(accSubStatus.currentInvNoInfo && accSubStatus.currentInvNoInfo.split('^')[2]) || '--'}</span>
                                                        <span style={{ color: 'red', display: accSubStatus.invNum && parseFloat(accSubStatus.invNum) < 10 ? 'block' : 'none' }}>发票剩余数：{accSubStatus.invNum}，请进行购买补充</span></p>
                                                    <p>{language.DischargeSettlementIssueCurrent && language.DischargeSettlementIssueCurrent.descripts}</p>
                                                </div>
                                            </Col>
                                            <Col span={4} style={{ textAlign: 'center', background: '#F7FBFF', marginLeft: 10 }}>
                                                <div className='payBox'>
                                                    <p className='p2' style={{ color: '#007AFF' }}><span>{accSubStatus.accSubStatusDesc || '正常'}</span></p>
                                                    <p>{language.DischargeSettlementAccountstatus && language.DischargeSettlementAccountstatus.descripts}</p>
                                                </div>
                                            </Col>
                                            <Col span={4} style={{ textAlign: 'center', background: '#F7FBFF', marginLeft: 10 }}>
                                                <div className='payBox'>
                                                    <p className='p2' style={{ color: '#007AFF' }}>￥<span>{accSubStatus.accSubBlance || '0'}</span></p>
                                                    <p>{language.DischargeSettlementAccountbalance && language.DischargeSettlementAccountbalance.descripts}</p>
                                                </div>
                                            </Col>
                                        </Row>
                                    </Col>
                                </Row>
                            </Card>
                            <Card style={{ width: '100%', padding: '0' }} className='pd0'>
                                <div style={{ padding: 12 }}>
                                    <Table
                                        // className="smallTable"
                                        pagination={false}
                                        bordered
                                        scroll={{ y: 220, x: 1100 }}
                                        columns={this.state.columns1}
                                        dataSource={this.state.dataTable1}
                                        style={{ minHeight: '269px' }}
                                        onRow={(record) => {
                                            return {
                                                onClick: (event) => {
                                                    this.onClickRowPublic1(record)
                                                },
                                                onContextMenu: (event) => {
                                                    this.handleContextMenu(record, event);            //选中行右键
                                                },
                                            };
                                        }}
                                        rowClassName={(record) => this.setRowClassNamePublic1(record)}
                                    />

                                </div>
                            </Card>
                            <Card style={{ width: '100%', padding: '0' }} className='pd0'
                                title={
                                    <div><span><img src={billdetails} style={{ marginRight: 5 }} />{language.DischargeSettlementBilldetails && language.DischargeSettlementBilldetails.descripts}</span>
                                        <span style={{ marginLeft: 100 }}>
                                            <span style={{ color: '#333333', fontSize: '14px', fontWeight: '400' }}>{language.DischargeSettlementOverallamount && language.DischargeSettlementOverallamount.descripts}：</span>
                                            <span style={{ color: '#00C197' }}>¥{userPayData.insuTCAmt || '0'}</span>
                                        </span><Divider type="vertical" />

                                        <span style={{ marginLeft: 20 }}>
                                            <span style={{ color: '#333333', fontSize: '14px', fontWeight: '400' }}>{language.DischargeSettlementDiscount && language.DischargeSettlementDiscount.descripts}：</span>
                                            <span style={{ color: '#00C197' }}>￥<span>{userPayData.allowAmt || '0'}</span></span>
                                        </span><Divider type="vertical" />

                                        <span style={{ marginLeft: 20 }}>
                                            <span style={{ color: '#333333', fontSize: '14px', fontWeight: '400' }}>{language.DischargeSettlementPersonalexpense && language.DischargeSettlementPersonalexpense.descripts}：</span>
                                            <span style={{ color: '#00C197' }}>￥<span>{userPayData.insuGRAmt || '0'}</span></span>
                                        </span>

                                    </div>} >
                                <div style={{ padding: 12 }}>
                                    <Row >
                                        <Col span={22}>
                                            <Card >
                                                <Row >
                                                    <Col span={20} offset={1} style={{ textAlign: 'center', paddingTop: '10px' }}>
                                                        <h1>{language.DischargeSettlementHospitalizationProvince && language.DischargeSettlementHospitalizationProvince.descripts}</h1>
                                                        <Row style={{ textAlign: 'left' }}>
                                                            <p><span><span className='greenSpan'>{language.DischargeSettlementChargingunit && language.DischargeSettlementChargingunit.descripts}：</span>{userPayData.chargeHosp}</span></p>
                                                            <p><span><span className='greenSpan'>{language.DischargeSettlementInpatientdepartment && language.DischargeSettlementInpatientdepartment.descripts}：</span>{userPayData.admLocDesc}</span><span><span className='greenSpan'>{language.DischargeSettlementSocialnumber && language.DischargeSettlementSocialnumber.descripts}：</span>{userPayData.insuCredNo}</span></p>
                                                            <p><span><span className='greenSpan'>{language.DischargeSettlementFullname && language.DischargeSettlementFullname.descripts}：</span>{userPayData.patName}</span><span><span className='greenSpan'>{language.DischargeSettlementGender && language.DischargeSettlementGender.descripts}：</span>{userPayData.patSexDesc}</span><span><span className='greenSpan'>{language.DischargeSettlementAge && language.DischargeSettlementAge.descripts}：</span>{userPayData.patAge}</span><span><span className='greenSpan'>{language.DischargeSettlementHospitalizationnumber && language.DischargeSettlementHospitalizationnumber.descripts}：</span>{userPayData.patNo}</span><span><span className='greenSpan'></span><span className='greenSpan'>{language.DischargeSettlementSettlingtime && language.DischargeSettlementSettlingtime.descripts}：</span>{userPayData.payDate}</span> <span><span className='greenSpan'>{language.DischargeSettlementTypesnsurance && language.DischargeSettlementTypesnsurance.descripts}：</span>{userPayData.payReasonDesc}</span></p>
                                                            <Divider />
                                                            <p><span><span className='greenSpan'>{language.DischargeSettlementAdmissiontime && language.DischargeSettlementAdmissiontime.descripts}：</span>{userPayData.admDate}  {userPayData.admTime}</span><span><span className='greenSpan'>{language.DischargeSettlementDischargetime && language.DischargeSettlementDischargetime.descripts}：</span>{userPayData.nurseChargeDate}  {userPayData.nurseChargeTime}</span><span><span className='greenSpan'>{language.DischargeSettlementTotalAStay && language.DischargeSettlementTotalAStay.descripts}：</span>{userPayData.ipDays}</span></p>
                                                            <Divider />
                                                            <ul>
                                                                {this.state.subTypeFeeArr.map((item, i) => {
                                                                    return <span key={i} style={{ listStyleType: 'none', marginLeft: '10px' }}>{item + '；'}</span>
                                                                })}
                                                            </ul>
                                                            <Divider />
                                                            <p><span><span className='greenSpan'>{language.DischargeSettlementTotalamount && language.DischargeSettlementTotalamount.descripts}：</span>{userPayData.patBillPatAmt}</span></p>
                                                            <Divider />
                                                            <p><span><span className='greenSpan'>{language.DischargeSettlementTollcollector && language.DischargeSettlementTollcollector.descripts}：</span>{userPayData.userDesc}</span></p>
                                                        </Row>
                                                    </Col>
                                                </Row>
                                            </Card>
                                        </Col>
                                        <Col span={2}>
                                            <Card style={{ padding: 5 }}>
                                                <Button className='buttonBox' onClick={() => this.clearnUserPayData()} disabled={this.state.disBtton1}  >
                                                    <span><Icon type="rest" theme="filled" style={{ color: '#F5222D', fontSize: '20px' }} /></span>
                                                    <span style={{ marginLeft: 5 }}>{language.DischargeSettlementempty && language.DischargeSettlementempty.descripts}</span>
                                                </Button>
                                                {/*disBtton2 试算 disBtton3 取消试算*/
                                                /*<Button className='buttonBox bkb' onClick={() => this.budgetAndSettlement()} disabled={this.state.disBtton2}>
                                                    <span><Icon type="calculator" theme="filled" style={{ color: '#FA541C', fontSize: '20px' }} /></span>
                                                    <span style={{marginLeft:5}}>{language.DischargeSettlementtrial && language.DischargeSettlementtrial.descripts}</span>
                                                </Button>
                                                <Button className='buttonBox bkb' onClick={() => this.Cancellationoftrialcalculation()} disabled={this.state.disBtton3}  >
                                                    <span><Icon type="calculator" theme="filled" style={{ color: '#FAAD14', fontSize: '20px' }} /></span>
                                                    <span style={{marginLeft:5}}>{language.DischargeSettlementCancellationcalculation && language.DischargeSettlementCancellationcalculation.descripts}</span>
                                                </Button>*/}
                                                <Button className='buttonBox bkb' onClick={() => this.Settlement()} disabled={this.state.disBtton4 || this.state.disBtn}>
                                                    <span><Icon type="file-done" style={{ color: '#13C2C2', fontSize: '20px' }} /></span>
                                                    <span style={{ marginLeft: 5 }}>{language.DischargeSettlementSettlement && language.DischargeSettlementSettlement.descripts}</span>
                                                </Button>
                                                <Button className='buttonBox bkb' onClick={() => this.Cancellation()} disabled={this.state.disBtton5}>
                                                    <span><Icon type="file-sync" style={{ color: '#1890FF', fontSize: '20px' }} /></span>
                                                    <span style={{ marginLeft: 5 }}>{language.DischargeSettlementCancellationSettlement && language.DischargeSettlementCancellationSettlement.descripts}</span>
                                                </Button>
                                                <Button className='buttonBox bkb' onClick={this.SplitTheBill} disabled={this.state.disBtton6}>
                                                    <span><Icon type="tags" theme="filled" style={{ color: '#FA8C16', fontSize: '20px' }} /></span>
                                                    <span style={{ marginLeft: 5 }}>{language.DischargeSettlementSplitbill && language.DischargeSettlementSplitbill.descripts}</span>
                                                </Button>
                                                <Button className='buttonBox bkb' onClick={() => this.ListOfHospitalizationExpenses()} disabled={this.state.disBtton7}>
                                                    <span><Icon type="account-book" theme="filled" style={{ color: '#06B66E', fontSize: '20px' }} /></span>
                                                    <span style={{ marginLeft: 5 }}>{language.DischargeSettlementCostlist && language.DischargeSettlementCostlist.descripts}</span>
                                                </Button>
                                                <Button className='buttonBox bkb' onClick={this.handlePrintList.bind(this)} disabled={this.state.disBtton7 ||
                                                    Util.isEmpty(this.state.fphm)}>
                                                    <span><Icon type="container" theme="filled" style={{ color: '#13C2C2', fontSize: '20px' }} /></span>
                                                    <span style={{ marginLeft: 5 }}>发票清单<br />打印</span>
                                                </Button>
                                                <Button className='buttonBox bkb' onClick={this.printSettlementList} disabled={this.state.recordData.ipInsuType != 'Y' || !this.state.recordData.insuPayID ? true : false}>
                                                    <span><Icon type="container" theme="filled" style={{ color: '#13C2C2', fontSize: '20px' }} /></span>
                                                    <span style={{ marginLeft: 5 }}>结算单<br />打印</span>
                                                </Button>
                                                <Button className='buttonBox bkb' onClick={this.handlePrintReceive.bind(this)} disabled={this.state.disBtton7 ||
                                                    Util.isEmpty(this.state.fphm)}>
                                                    <span><Icon type="printer" theme="filled" style={{ color: '#13C2C2', fontSize: '20px' }} /></span>
                                                    <span style={{ marginLeft: 5 }}>原号重打</span>
                                                </Button>
                                            </Card>
                                        </Col>
                                    </Row>
                                </div>
                            </Card>
                        </div>
                    </Col>
                </Row>
                <Modal
                    visible={this.state.visibleMoney}
                    onCancel={this.handleCancel}
                    onOk={this.handleCancel}
                    width='1300px'
                    title={language.DischargeSettlementCostlist && language.DischargeSettlementCostlist.descripts}
                >
                    <ListOfHospitalizationExpenses key={this.state.patBillID} patBillID={this.state.patBillID} userInfo={this.state.userInfo} />
                </Modal>
                <Modal
                    visible={this.state.visibleMoney2}
                    onCancel={this.handleCancel}
                    onOk={this.handleCancel}
                    width='1300px'
                    title={language.DischargeSettlementSplitbill && language.DischargeSettlementSplitbill.descripts}
                >
                    <SplitBills key={this.state.patBillID} paras={this.state.paras} />
                </Modal>
                <Modal
                    visible={this.state.visible}
                    onCancel={this.handleCancelMoney}
                    width='1300px'
                    title={
                        <div>
                            {language.DischargeSettlementSettlement && language.DischargeSettlementSettlement.descripts}
                            <span className='greenSpan'>{' ' + userPayData.patName + ' ( ' + userPayData.patNo + ' ) 结算类型:' + userPayData.payReasonDesc + '  入院日期:' + ' ' + userPayData.admDate + ' ' + userPayData.admTime + '  出院日期:' + userPayData.nurseChargeDate + ' ' + userPayData.nurseChargeTime}</span>
                        </div>
                    }
                    footer={
                        <div>
                            <Button type="danger" onClick={this.handleCancelMoney}>取消</Button>
                            <Button ref={this.refHandleOK} type="primary" onClick={this.handleOK}>结算</Button>
                        </div>
                    }
                >
                    <div>
                        {this.state.paywamtData && this.state.paywamtData.length > 0 ? <Row>
                            已支付方式信息：
                            <Row className="ybpat-row">
                                {this.state.paywamtData.map((item, index) => {
                                    return <Row><Col className="ybpat-col" span={8} key={index} offset={4}>
                                        <p><i className="f1"></i>{item.desc}：</p><p className='p2'>￥<span>{item.value}</span></p>
                                    </Col></Row>
                                })}
                            </Row>
                        </Row> : ""}
                        <Row style={{ borderTop: "1px solid #ccc" }}>
                            <Col span={8} offset={4}>
                                <div className='payBox'>
                                    <p><i className="f1"></i>本次医疗费用</p>
                                    <p className='p2'>￥<span>{this.state.patAmt || '0.00'}</span></p>
                                </div>
                            </Col>
                            <Col span={8} offset={2}>
                                <div className='payBox'>
                                    <p><i className="f1"></i>剩余应收</p>
                                    <p className='p2'>￥<span>{this.state.leftAmt || '0.00'}</span></p>
                                </div>
                            </Col>
                        </Row>
                        <Row className='mT10'>
                            <Col span={12}>
                                <Row className='mT10'>
                                    <Col span={8} className='modalLabel ' style={{ textAlign: 'right' }}>住院账户余额：</Col>
                                    <Col span={16} >
                                        <Input disabled className='input' addonBefore="￥" value={this.state.accAmtBalance} onBlur={(event) => { if (event.target.value === '') { event.target.value = '0.00' } }} />
                                    </Col>
                                </Row>
                            </Col>
                            <Col span={12}>
                                <Row className='mT10'>
                                    <Col span={8} className='modalLabel' style={{ textAlign: 'right' }}>对冲金额：</Col>
                                    <Col span={16} >
                                        <Input disabled={this.state.sysConfigIP.PayAccIPAmtFlag && this.state.sysConfigIP.PayAccIPAmtFlag === 'N' ? false : true} ref={this.myRef6} style={{ width: '50%' }} addonBefore="￥" onChange={(e) => { this.onChangepayAccIPAmt(e); }} value={this.state.payAccIPAmt} onBlur={(event) => { if (event.target.value === '') { event.target.value = '0.00' } this.setState({ payAccIPAmt: parseFloat(event.target.value).toFixed(2) }) }} onFocus={(event) => { if (event.target.value === '0.00') { event.target.value = '' } }} onPressEnter={this.onPressEnter6} />
                                        <Input style={{ width: '50%' }} addonBefore="余" value={this.state.accpayBalance} onBlur={(event) => { if (event.target.value === '') { event.target.value = '0.00' } this.setState({ payAccIPAmt: parseFloat(event.target.value).toFixed(2) }) }} onFocus={(event) => { if (event.target.value === '0.00') { event.target.value = '' } }} />
                                    </Col>
                                </Row>
                            </Col>
                        </Row>
                        <Divider dashed style={{ margin: '12px' }} />
                        <Row>
                            <EditableContext.Provider value={this.props.form}>
                                <Table
                                    dataSource={this.state.payWListData}
                                    columns={filterColumns}
                                    components={components}
                                    pagination={false}
                                    onRow={this.ChangepayWonRow}
                                    bordered
                                    className="table-pay-list"
                                />
                            </EditableContext.Provider>
                            <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'flex-end' }}>
                                <div style={{ textAlign: "right", marginRight: '80px' }}>
                                    <p style={{ color: 'rgba(240,65,52,1)' }}><span>剩余余额：￥{parseFloat(this.state.surplusamt) === 0 ? '' : parseFloat(this.state.surplusamt)}</span></p>
                                </div>
                                <div style={{ textAlign: "right" }}>
                                    <Button icon="plus" onClick={this.handleAddTableData} style={{ background: 'rgba(247,128,93,1)', color: '#fff' }}>新增</Button>
                                </div>
                            </div>
                        </Row>
                        <Row className='mT10' style={{ display: this.state.disXJ ? 'block' : 'none', borderTop: "1px solid #ccc" }} >
                            <Divider dashed={true}>实收现金</Divider>
                            <Col span={24}>
                                <Row className="mT5">
                                    <Col span={5} className='modalLabel '>实收现金：</Col>
                                    <Col span={7} >
                                        <Input ref={this.myRef5} value={this.state.cashInCashVal} onChange={(e) => { this.cashInCash(e.target.value); }} className='input' addonBefore="￥" onBlur={(event) => { if (event.target.value === '') { event.target.value = '0.00' } this.setState({ cashInCashVal: parseFloat(event.target.value).toFixed(2) }) }} onFocus={(event) => { if ((event.target.value === '0.00') || (event.target.value === '0')) { event.target.value = '' } }} onPressEnter={() => { setTimeout(() => { this.refHandleOK.current.focus(); }, 1); }} />
                                    </Col>
                                    <Col span={5} className='modalLabel' ></Col>
                                    <Col span={7} >
                                        <p style={{ color: parseFloat(this.state.zeroPay) < 0 ? 'rgba(240,65,52,1)' : '' }}><span>找零（元）：￥{this.state.zeroPay}</span></p>
                                    </Col>
                                </Row>
                            </Col>
                        </Row>
                    </div>
                </Modal>
                <Modal
                    visible={this.state.modalShow}
                    title='设置发票号'
                    onCancel={this.handleCancel}
                    onOk={this.handleCancel}
                    width='600px'
                    footer={null}
                    destroyOnClose={true}
                >
                    {/* <HistoryModal userInfo={this.state.userInfo} updateParent={this.updateParent}></HistoryModal> */}
                    <HopNumber invTypeCode='I' key={this.state.invoice} handleCancel={this.handleCancel} handelThis={this} />

                </Modal>
                <Modal
                    visible={this.state.InsuIPPayModalvisible}
                    onCancel={this.handleCancelInsuIPPayModal}
                    width='1000px'
                    title='医保病人信息'
                    footer={
                        <div style={{ display: "flex", justifyContent: "center" }}>
                            <Button type="primary" onClick={() => this.InsuIPPrePay()} style={{ display: this.state.InsuIPPayButton === '2' ? 'block' : 'none' }}>医保预结算</Button>
                            <Button type="primary" onClick={() => this.handleCancelInsuIPPayModal()} style={{ display: this.state.InsuIPPayButton === '4' ? 'block' : 'none' }}>取消</Button>
                            <Button type="primary" onClick={() => this.InsuIPPrePay()} style={{ display: this.state.InsuIPPayButton === '4' ? 'block' : 'none' }}>确认结算</Button>
                            <Button type="primary" onClick={this.handleCancelInsuIPPayModal} style={{ display: this.state.InsuIPPayButton === '2' ? 'block' : 'none' }}>关闭</Button>
                        </div>
                    }
                >
                    <div>
                        <Row className="ybpat-row">
                            {this.state.YBPatDivdata.map((item, index) => {
                                return <Col className="ybpat-col" span={8} key={index}>
                                    <span className="ybpat-desc">{item.desc}</span>
                                    <span>：</span>
                                    <span className="ybpat-value">{item.value}</span>
                                </Col>
                            })}
                        </Row>
                        {this.state.ybPayDivdata && this.state.ybPayDivdata.length > 0 ? <Row style={{ borderTop: "1px solid #ccc" }}>
                            病人医保结算信息：
                            <Row className="ybpat-row">
                                {this.state.ybPayDivdata.map((item, index) => {
                                    return <Col className="ybpat-col" span={8} key={index}>
                                        <span className="ybpat-desc">{item.desc}</span>
                                        <span>：</span>
                                        <span className="ybpat-value">{item.value}</span>
                                    </Col>
                                })}
                            </Row>
                        </Row> : ""}
                        <Row style={{ borderTop: "1px solid #ccc" }}>
                            <Col className="ybpat-col" span={8} key={1}>
                                {this.state.recordData.admReasonCode === 'INSUHFXNHY' && this.state.xnhBCTYPEList && this.state.xnhBCTYPEList.length > 0 ? <div><span className="ybpat-desc">农合补偿类型</span>
                                    <span>：</span>
                                    <span className="ybpat-value">
                                        <Select style={{ width: '150px', margin: '12px 15px 0 0' }} value={this.state.xnhBCTYPE} onChange={this.xnhBCTYPEListChange} >
                                            {this.state.xnhBCTYPEList.map((item, index) => <Option title={item.subDesc} key={index} value={item.subCode}  >{item.subDesc}</Option>)}
                                        </Select>
                                    </span></div> : ""}
                                {this.state.recordData.admReasonCode === 'INSUHFYDYB' ? <div><span className="ybpat-desc">报销类别</span>
                                    <span>：</span>
                                    <span className="ybpat-value">
                                        <Select style={{ width: '150px', margin: '12px 15px 0 0' }} value={this.state.ifsubmit} onChange={(event) => { this.ifsubmitonChange(event) }}>
                                            <Option value='0'>正常结算</Option>
                                            <Option value='2'>中途结算</Option>
                                        </Select>
                                    </span></div> : ""}
                                {this.state.comepnCodeList && this.state.comepnCodeList.length > 0 ? <div><span className="ybpat-desc">结算类型</span>
                                    <span>：</span>
                                    <span className="ybpat-value">
                                        <Select style={{ width: '150px', margin: '12px 15px 0 0' }} value={this.state.comepnCode} onChange={this.comepnCodeonChange} >
                                            {this.state.comepnCodeList.map((item, index) => <Option title={item.subDesc} key={index} value={item.subCode}  >{item.subDesc}</Option>)}
                                        </Select></span></div> : ""}
                            </Col>
                            <Col className="ybpat-col" span={8} key={3}>
                                {(this.state.recordData.admReasonCode === 'INSUHFXNHY' || this.state.recordData.admReasonCode === 'INSUHFSYB' || this.state.recordData.admReasonCode === 'INSUHFYDYB') && this.state.xnhtreatCodeist && this.state.xnhtreatCodeist.length > 0 ? <div><span className="ybpat-desc">治疗方式</span>
                                    <span>：</span>
                                    <span className="ybpat-value">
                                        <Select style={{ width: '150px', margin: '12px 15px 0 0' }} value={this.state.treatCode} onChange={this.xnhtreatCodeistChange} showSearch allowClear optionFilterProp="role" >
                                            {this.state.xnhtreatCodeist.map((item, index) => <Option title={item.subDesc} key={index} value={item.subCode} role={item.subCode + '^' + item.subDesc + '^' + item.spDesc} >{item.subDesc}</Option>)}
                                        </Select>
                                    </span></div> : ""}
                            </Col>
                            <Col className="ybpat-col" span={8} key={5}>
                                <div><span className="ybpat-desc">ICD诊断</span>
                                    <span>：</span>
                                    <span className="ybpat-value">
                                        <Input
                                            style={{ width: '200px', margin: '12px 15px 0 0' }}
                                            id='inputDiag-id'
                                            placeholder='输入后回车搜索'
                                            onPressEnter={this.itmOnPressEnter}
                                            value={this.state.searchCode ? this.state.searchCode : this.state.INSUICDDesc}
                                            onChange={this.itmOnChange}
                                            allowClear
                                        />
                                    </span></div>
                            </Col>
                        </Row>
                    </div>
                </Modal>
                <INSURegister
                    size="small"
                    onRef={this.onRef}
                    admID={this.state.admID}
                    admReasonCode={this.state.admReasonCode}
                />
                {/**列input框新表格弹框 */}
                <PublicModalTable
                    onClickRowPublic={this.onClickRowPublic}
                    setRowClassNamePublic={this.setRowClassNamePublic}
                    param={modalParam}
                    onRef={this.modalOnRef}
                    compilePage={this.handleCompilePage}
                />
                <div ref={(ref) => { this.root = ref }} className="contextMenu-wrap" style={{ visibility: this.state.contextMenuvisible ? 'visible' : 'hidden' }}>
                    <div className="contextMenu-option" onClick={this.bill}>账单</div>
                    <div className="contextMenu-option" onClick={this.InsuUPloadItem}>医保费用上传</div>
                    <div className="contextMenu-option" onClick={this.CancleInsuUPloadItem}>撤销上传的医保费用</div>
                    <div className="contextMenu-option" onClick={() => this.InsuIPPayModal('2')}>医保试算</div>
                    <div className="contextMenu-option" onClick={() => this.unbudgetAndSettlement()}>取消预结算</div>

                </div>
            </div >


        )
    }
};

let DischargeSettlementForm = Form.create()(DischargeSettlement);
export default DischargeSettlementForm;
