// 主菜单维护
import React from 'react';
import '../../assets/css/system.css';
import '../../assets/css/App.css';
import PropTypes from 'prop-types';
import { $http } from '../../containers/config/https';
import {
    Modal,
    Form,
    notification,
    Input,
    Icon,
    message,
    Select,
    Table,
    DatePicker,
    Button,
    Spin,
    Row,
    Col,
    Tabs,
    InputNumber,
    Tooltip,
    Pagination,
    Cascader,
    Radio
} from 'antd';
import moment from 'moment';
import './charges/style/style.less'
import { INSUYBUtil, Keup } from '../../tools/index';
import PublicModalTable from 'pages/common/PublicModalTable';
const Option = Select.Option;
const TabPane = Tabs.TabPane
const FormItem = Form.Item;
const confirm = Modal.confirm;
const FormHandel = Form.create()(

    // eslint-disable-next-line
    class extends React.Component {
        constructor(props) {
            super(props);
            this.state = {
                userInfo:'',
                Buttondisabled: true,
                visible: false,
                cardShow: false,
                cardNumber: '',
                qrCode: '',
                areaType:"本地",
                admID: '',
                personalData: '',
                insuAdmID: '',
                reasonCode: '',
                admReasomID: '',
                Divdata: [],
                xnhjgList: [],
                medicalTypeList:[],
                medicalType:'',
                xnhtreatCodeist: [],
                admissionType: '001',
                treatCode: '',
                inHosId: '',
                xnhjgCode: '',
                modalPageSize: 10,
                modalPage: 1,
                modalData: [],
                INSUICDCode: '',    // 医保诊断code
                INSUICDDesc: '',    // 医保诊断描述
                searchCode: '',
                insuReasonShow: false,  // 修改费别用
                admReasonID: '',    // 需要修改的费别类型
                admReasonArr: [],   // 费别下拉数据
                ipInsuType:'',
                insustatus:'',
                readCardType:'read'
            }
            this.modalColumns = [{
                title: 'ICD诊断代码',
                dataIndex: 'code',
                key: 'code'
            },{
                title: 'ICD诊断描述',
                dataIndex: 'descripts',
                key: 'descripts'
            }]
        }

        componentDidMount() {
            //this.props.onRef(this);
            this.props && this.props.onRef && this.props.onRef(this)
            this.GetInsuReason();
        }
        clearsubdata = () => {
            this.setState({
                Buttondisabled: true,
                visible: false,
                cardShow: false,
                cardNumber: '',
                qrCode: '',
                areaType:"本地",
                admID: '',
                personalData: '',
                insuAdmID: '',
                reasonCode: '',
                admReasomID: '',
                Divdata: [],
                xnhjgList: [],
                medicalTypeList:[],
                medicalType:'',
                xnhtreatCodeist: [],
                admissionType: '001',
                treatCode: '',
                inHosId: '',
                xnhjgCode: '',
                INSUICDCode: '',
                INSUICDDesc: '',
                searchCode: '',
                ipInsuType:'',
                insustatus:'',
                readCardType:'read'
            })
        }
        // 重置表单
        resetFields() {
            this.props.form.resetFields(); //清空所有
            this.clearsubdata()
        }
        // 显示弹出层
        showModal = () => {
            this.setState({
                insuReasonShow: false,
                visible: true,
                cardShow: false
            });
        }
        ybPatDivdata = async (YBPatData) => {
            let YBPatDivdata = await INSUYBUtil.GetYBPatDivdata(YBPatData, this.state.admReasomID);    //组织医保病人信息
            if (YBPatDivdata.errorCode == '0') {
                let Divdata = YBPatDivdata.result;
                this.setState({
                    Divdata,
                });
            }
            var TMPdata2 = await this.xnhtreatment()
            this.medicalTypeList()
        }
        admissionType = (e) => {
            this.setState({ admissionType: e });
        }
        adminHosId = (e) => {
            this.setState({ inHosId: e });
        }
        changereadCardType = (e) => {
            this.setState({ readCardType: e });
        }
        readYBPatdata = async (admID,userInfo) => {
            if (admID == "") {
                message.error('请先选择就诊信息')
                this.setState({
                    visible: false,
                });
                return false
            }
            this.setState({
                admID: admID,
                userInfo :{...userInfo},
                xnhjgCode: '',
                treatCode: '',
                xnhtreatCodeist: [],
                medicalTypeList:[],
                medicalType:'',
                INSUICDCode: '',    // 医保诊断code
                INSUICDDesc: '',    // 医保诊断描述
                insustatus:'',
                readCardType:'read'
            });
            //查询有没记录医保病人信息
            var paramsdata = {
                params: [{
                    "admID": 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接口

            if (YBPatDataobj.errorCode != '0') {
                message.warn(res.errorMessage);
                return
            }
            this.setState({
                insuAdmID: YBPatDataobj.insuAdmID,
                admReasomID: YBPatDataobj.admReasomID,
                reasonCode: YBPatDataobj.reasonCode,
                xnhjgCode: YBPatDataobj.xnhjgCode,
                treatCode: YBPatDataobj.treatCode,
                INSUICDCode: YBPatDataobj.icdAllNo,
                INSUICDDesc: YBPatDataobj.icdAllDesc,
                inHosId: YBPatDataobj.inHosId,
                ipInsuType:YBPatDataobj.ipInsuType,
                insustatus:YBPatDataobj.status

            });
            if (YBPatDataobj.ipInsuType!='Y')
            {
                this.setState({
                    insuReasonShow: true,
                    visible: false,
                    cardShow: false
                });
            }

            var TMPdata = await this.xnhjgListonList()
            if (YBPatDataobj.result === "") {
                //查询没医保病人信息 进行医保读卡
                this.setState({ insuReasonShow: true, cardNumber: "", qrCode: "",areaType:"本地" });
                return
            }
            else {
                this.setState({ personalData: YBPatDataobj.result });
                this.ybPatDivdata(YBPatDataobj.result)    //展示医保病人信息

            }


        }

        // 新版医保
        readYBPatdataNew = async (admID,userInfo,billID) => {
            if (admID == "") {
                message.error('请先选择就诊信息')
                this.setState({
                    visible: false,
                });
                return false
            }let { userData } = window.sessionStorage;
            try {
                let insupaydata = {
                    params: [{
                        "admID": admID,
                        "billID": billID,
                        "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 || '',
                        ...{userInfo}
                    }],
                    "businessType": "Z1",
                    "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                    session: [(JSON.parse(userData))]
                }
                let patientInfo = await INSUYBUtil.insuNew("GetPatientInfo", insupaydata);
                let patientInfoRet = JSON.parse(patientInfo);
                console.log(patientInfoRet);
                if (patientInfoRet.errorCode == '0') {
                    this.setState({ insuAdmID: patientInfoRet.insuAdmID });
                }
                else {
                    message.warn(patientInfoRet.errorMessage);
                    return;
                }
                //组织登记信息
                let regInpar = {
                    params: [{
                        "admID": admID,
                        "billID": billID,
                        "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 || '',
                        "patientInfo":patientInfoRet.result.patientInfo,
                        "interfaceInfo":patientInfoRet.result.interfaceInfo
                    }],
                    "businessType": "Z2",
                    "interfaceDr":patientInfoRet.result.interfaceInfo.result.ID,//接口ID
                    "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id
                    session: [JSON.parse(userData)]
                }
                console.log(regInpar)
                let regRtn = await INSUYBUtil.insuNew("Register", regInpar);
                let res = JSON.parse(regRtn);
                if (res.errorCode == '0') {
                    this.setState({ insuAdmID: res.insuAdmID });
                    Keup.ModalMessage(3, this, '医保登记成功!', '自动关闭', 'destroy', '确定', 'success')
                }
                else {
                    message.warn(res.errorMessage);
                }
            } catch (error) {
                message.warning("异常:" + error)
                console.error(error);
            }
        }
        medicalTypeChange = (e) => {
            this.setState({ medicalType: e });
        }
        xnhjgListonChange = (e) => {
            this.setState({ xnhjgCode: e }
                , () =>
                {
                    this.xnhtreatment()
                    this.medicalTypeList()
                });
        }
        ///机构中心
        xnhjgListonList = async () => {
            try {
                var paramsdata = {
                    params: [{
                        "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
                        "reasonCode":this.state.reasonCode,
                    }]
                }
                let YBPatDataobj = await INSUYBUtil.GoTOHISHttp(paramsdata, "05210067");    //调用his接口
                if (YBPatDataobj.errorCode == '0') {
                    let xnhjgList = YBPatDataobj.xnhjgList;
                    this.setState({
                        xnhjgList: xnhjgList,
                    });
                }
                else {
                    message.warn(res.errorMessage);
                }
            } catch (error) {
                message.warning("异常:" + error)
            }
        }
         ///医疗类别
         medicalTypeList = async () => {
            try {
                if (this.state.reasonCode!='INSUHFYDYB')
                {
                    //不是异地医保
                    return
                }
                var paramsdata = {
                    params: [{
                        "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
                        "reasonCode":this.state.reasonCode,
                        "xnhjgCode": (this.state.xnhjgCode),
                    }]
                }
                let YBPatDataobj = await INSUYBUtil.GoTOHISHttp(paramsdata, "05210074");    //调用his接口
                if (YBPatDataobj.errorCode == '0') {
                    let medicalTypeList = YBPatDataobj.medicalTypeList;
                    this.setState({
                        medicalTypeList: medicalTypeList,
                    });
                }
                else {
                    message.warn(res.errorMessage);
                }
            } catch (error) {
                message.warning("异常:" + error)
            }
        }
        xnhtreatment = async () => {
            try {
                if ((this.state.xnhjgCode !== '')||(this.state.reasonCode=='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.reasonCode),
                        }]
                    }
                    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)
            }
        }
        InsuRegist = async () => {
            if (this.state.reasonCode === "INSUHFXNHY") {
                if (this.state.xnhjgCode === '') {
                    message.warning("请选择新农合机构中心")
                    return
                }
                if (this.state.inHosId === '') {
                    //入院状态
                    message.warn("请选择入院状态");
                    return
                }

            }
            //进入医保登记
            let openModal = Modal.info({
                title: "正在医保登记，请稍后......",
                content: <Spin size="large" />,
                okText: "OK",
                onOk() { },
            });
            if ((this.state.reasonCode === "INSUHFXNHY")||(this.state.reasonCode === "INSUHFYDYB"))
            {
                if (this.state.xnhjgCode==''){
                    message.warning("请先选择机构中心")
                    returnS
                }
            }
            try {
                let dllInputdata = {
                    "params": [{
                        "reasonCode": this.state.reasonCode,
                        "xnhjgCode": this.state.xnhjgCode,
                        "userID": JSON.parse(window.sessionStorage.userData).userID,
                        "qrCode": this.state.qrCode,
                        "icCardNum": this.state.cardNumber,
                        "areaType":this.state.areaType,
                        "hospID": JSON.parse(window.sessionStorage.userData).hospID,
                        "patName": this.state.userInfo.patName || '',  //病人
                        "patID": this.state.userInfo.patID || '',  //病人id
                    }],
                    "code": "05210036"
                }
                let newdllPath=""
                if (this.state.readCardType=="numble"){
                    newdllPath="ReadYBSFZCard/INSUYBPAY.dll"
                }
                let data = await INSUYBUtil.insuYBAHSYB("ReadYBCard", dllInputdata,newdllPath);         //读医保病人信息
                let res2 = JSON.parse(data);
                if (res2.errorCode == '0') {
                }
                else {
                    message.warn(res2.errorMessage);
                    return
                }
                let insupaydata = {
                    params: [{
                        "admID": this.state.admID,
                        "reasonCode": this.state.reasonCode,
                        "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
                        "readCard": this.state.personalData,
                        "xnhjgCode": (this.state.xnhjgCode),			//
                        "admissionType": this.state.admissionType,                        //入院类型 001	正常入院,002 转院入院
                        "inHosId": this.state.inHosId,
                        "treatCode": this.state.treatCode,                    //治疗方式
                        "icdAllNo": this.state.INSUICDCode,                     // 医保ICD代码
                        "icdAllDesc": this.state.INSUICDDesc,                     // 医保ICD描述
                        "medicalType":this.state.medicalType
                    }],
                    "code": "05210049"
                }
                let YBPatDivdata = await INSUYBUtil.insuYBAHSYB("InsuIPREG", insupaydata,newdllPath);
                let res = JSON.parse(YBPatDivdata);
                if (res.errorCode == '0') {
                    this.setState({ insuAdmID: res.insuAdmID });
                    Keup.ModalMessage(3, this, '医保登记成功!', '自动关闭', 'destroy', '确定', 'success')
                }
                else {
                    message.warn(res.errorMessage);
                }
                openModal.destroy();
            } catch (error) {
                message.warning("异常")
                openModal.destroy();
                console.error(error);
            }

        }
        InsuUpdataRegist = async () => {
            if (this.state.reasonCode === "INSUHFXNHY") {
                if (this.state.xnhjgCode === '') {
                    message.warning("请选择新农合机构中心")
                    return
                }

            }
            //更新医保登记
            let openModal = Modal.info({
                title: "正在更新医保登记，请稍后......",
                content: <Spin size="large" />,
                okText: "OK",
                onOk() { },
            });
            try {
                let insupaydata = {
                    params: [{
                        "admID": this.state.admID,
                        "reasonCode": this.state.reasonCode,
                        "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
                        "readCard": this.state.personalData,
                        "xnhjgCode": (this.state.xnhjgCode),			//
                        "admissionType": this.state.admissionType,                        //入院类型 001	正常入院,002 转院入院
                        "inHosId": this.state.inHosId,
                        "treatCode": this.state.treatCode,                    //治疗方式
                        "icdAllNo": this.state.INSUICDCode,                     // 医保ICD代码
                        "icdAllDesc": this.state.INSUICDDesc,                     // 医保ICD描述
                        "medicalType":this.state.medicalType
                    }],
                    "code": "05210062"
                }
                let YBPatDivdata = await INSUYBUtil.insuYBAHSYB("InsuUpDataIPREG", insupaydata);
                let res = JSON.parse(YBPatDivdata);
                if (res.errorCode == '0') {
                    //this.setState({ insuAdmID:res.insuAdmID });
                    Keup.ModalMessage(3, this, '医保更新登记成功!', '自动关闭', 'destroy', '确定', 'success')
                }
                else {
                    message.warn(res.errorMessage);
                }
                openModal.destroy();
            } catch (error) {
                message.warning("异常")
                openModal.destroy();
                console.error(error);
            }

        }

        // 取消登记
        CancelInsuRegist = async () => {
            if (this.state.insuAdmID === "") {
                message.error('还没进行医保登记，不能医保登记冲销！！！！')
                return false
            }
            let openModal = Modal.info({
                title: "正在医保登记取消，请稍后......",
                content: <Spin size="large" />,
                okText: "OK",
                onOk() { },
            });
            try {
                let insupaydata = {
                    params: [{
                        "admID": this.state.admID,
                        "insuAdmID": this.state.insuAdmID,
                        "reasonCode": this.state.reasonCode,
                        "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
                        "opType": '3',        //登记类型: 1:住院登记,2:住院修改,3:取消登记,4:出院登记,5:转出登记,6:转入登记,7:取消出院登记8:取消结算
                        "xnhjgCode": (this.state.xnhjgCode),			//
                        "readCardType":this.state.readCardType
                    }],
                    "code": "05210050"
                }
                let newdllPath=""
                if (this.state.readCardType=="numble"){
                    newdllPath="ReadYBSFZCard/INSUYBPAY.dll"
                }
                let YBPatDivdata = await INSUYBUtil.insuYBAHSYB("CancleInsuIPREG", insupaydata,newdllPath);
                let res = JSON.parse(YBPatDivdata);
                if (res.errorCode == '0') {
                    this.setState({ insuAdmID: "" });
                    Keup.ModalMessage(3, this, '住院医保登记冲销成功!', '自动关闭', 'destroy', '确定', 'success')
                }
                else {
                    message.warn(res.errorMessage);
                }
                openModal.destroy();
            } catch (error) {
                message.warning("异常")
                openModal.destroy();
                console.error(error);
            }
        }
        // 取消出院登记
        cancelLeaveInpatientRegister = async () => {
            if (this.state.insustatus != "D") {
                message.error('不是出院登记状态，不能进行出院登记冲销！！！！')
                return false
            }
            let openModal = Modal.info({
                title: "正在进行出院登记冲销，请稍后......",
                content: <Spin size="large" />,
                okText: "OK",
                onOk() { },
            });
            try {
                let insupaydata = {
                    params: [{
                        "admID": this.state.admID,
                        "insuAdmID": this.state.insuAdmID,
                        "reasonCode": this.state.reasonCode,
                        "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
                        "xnhjgCode": (this.state.xnhjgCode),			//
                    }],
                    "code": "05210066"
                }
                let YBPatDivdata = await INSUYBUtil.insuYBAHSYB("InsuCancelLeaveReg", insupaydata);
                let res = JSON.parse(YBPatDivdata);
                if (res.errorCode == '0') {
                    this.setState({ insuAdmID: "" });
                    Keup.ModalMessage(3, this, '住院出院登记冲销成功!', '自动关闭', 'destroy', '确定', 'success')
                }
                else {
                    message.warn(res.errorMessage);
                }
                openModal.destroy();
            } catch (error) {
                message.warning("异常")
                openModal.destroy();
                console.error(error);
            }
        }

        handleCancel = () => {
            this.setState({
                visible: false,
            }, () => {
            });
        }
        onCardChange = (e) => {
            this.setState({ cardNumber: e.target.value });
        }
        onqrCodeChange = (e) => {
            this.setState({ qrCode: e.target.value });
        }
        onAreaTypeChange = (e) => {
            this.setState({ areaType:e.target.value });
        }
        xnhtreatCodeistChange = (e) => {
            this.setState({ treatCode: e });
        }
        YBInputSure = () => {
            this.setState({
                cardShow: false,
                visible: true,
            }, () => {
                this.syLoading("请等待");
            });
        }
        syLoading = async (title) => {
            let openModal = Modal.info({
                title: title,
                content: <Spin size="large" />,
                okText: "",
                onOk() { },
            });
            try {
                let dllInputdata = {
                    "params": [{
                        "reasonCode": this.state.reasonCode,
                        "xnhjgCode": this.state.xnhjgCode,
                        "userID": JSON.parse(window.sessionStorage.userData).userID,
                        "qrCode": this.state.qrCode,
                        "icCardNum": this.state.cardNumber,
                        "areaType":this.state.areaType,
                        "hospID": JSON.parse(window.sessionStorage.userData).hospID,
                        "patName": this.state.userInfo.patName || '',  //病人
                        "patID": this.state.userInfo.patID || '',  //病人id
                    }],
                    "code": "05210036"
                }
                let newdllPath=""
                if (this.state.readCardType=="numble"){
                    newdllPath="ReadYBSFZCard/INSUYBPAY.dll"
                }
                let data = await INSUYBUtil.insuYBAHSYB("ReadYBCard", dllInputdata,newdllPath);         //读医保病人信息
                let res = JSON.parse(data);
                if (res.errorCode == '0') {
                    this.setState({ personalData: res.result });
                    this.ybPatDivdata(res.result)       ////展示医保病人信息
                }
                else {
                    message.warn(res.errorMessage);
                }

                openModal.destroy();
            } catch (error) {
                message.warning("异常")
                openModal.destroy();
                console.error(error);
            }
        }
        modalOnRef = (ref) => {
            this.modalChild = ref
        }
        // 诊断回车事件
        itmOnPressEnter = () => {
            let top = document.getElementById('input-id').getBoundingClientRect().top + 30 + 'px';
            let left = document.getElementById('input-id').getBoundingClientRect().left + 'px';
            this.setState({
                top,
                left,
                modalPage: 1
            });
            this.getModalListData(this.state.searchCode, 'Y');
            //
        }
        itmOnChange = (e) => {
            if (!e.target.value) {
                this.setState({
                    searchCode: '',
                    INSUICDDesc: '',
                    INSUICDCode: ''
                })
            } else {
                this.setState({ searchCode: e.target.value })
            }
        }
        handleCompilePage = (page, pageSize) => {
            this.setState({ modalPageSize: pageSize, modalPage: page }, () => {
                this.getModalListData(this.state.searchCode);
            })
        }

        // 获取描述列表数据
        getModalListData(searchCode, isShowModal) {
            let { modalPageSize, modalPage, pageSize, page } = this.state;
            let data = {
                params: [
                    {
                        xnhjgCode: (this.state.xnhjgCode),			//
                        treatCode: (this.state.treatCode),			//
                        searchCode: searchCode,
                        reasonCode: (this.state.reasonCode)
                    }
                ],
                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({ modalData: source, modalTotal: res.result.totalCount }, () => {
                            if (isShowModal === 'Y') {
                                this.modalChild.showModal();
                            }
                        })
                    } else {
                        this.setState({ modalData: [], modalTotal: 0 })
                    }
                }
            })
        }
        // 下拉table双击
        onClickRowPublic = (record) => {
            return {
                onDoubleClick: () => {
                    this.setState({
                        INSUICDCode: record.code,
                        INSUICDDesc: record.descripts,
                        searchCode: ''
                    },() => this.modalChild.handleCancel())
                }
            }

        }

        setRowClassNamePublic = () => {
            // return (record.id) === this.state.diagID ? 'clickRowStyle' : '';
        }
        // 获取费别下拉数据
        GetInsuReason = () => {
            let data = {
                params: [{ }]
            }
            $http.post('urlADS', this, {
                code: "05100094",
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        this.setState({
                            admReasonArr: res.dataArr
                        })
                    }
                }
            })
        }

        // 修改费别
        insuReasonUpdate = () => {
            let { updReasonID,admID } = this.state
            let data = {
                params: [{
                    admID,
                    admReasonID: updReasonID
                }]
            }
            $http.post('urlADS', this, {
                code: "05100350",
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        message.success('修改成功');
                        this.setState({
                            updReasonID: '',
                            insuReasonShow: false,
                            cardShow: true,
                        })
                    }
                }
            })
        }

        render() {
            let {modalTotal,modalPage,top,left,modalData} = this.state
            const { getFieldDecorator } = this.props.form;
            var disabledflag = this.props.ListData ? this.props.ListData.ID ? true : false : false
            let nameplaceholder = "请输入医保卡号回车"
            let inputname = "医保卡号:"
            if (this.state.reasonCode === "INSUHFXNHY") {
                inputname = "医疗证号:"
                nameplaceholder = "请输入医疗证号回车"
            }
            const modalParam = {
                width: '600px',
                total: modalTotal,
                page: modalPage,
                top: top,
                left: left,
                columns: this.modalColumns,
                data: modalData,
                isOnRow: true,
                showPagination: true,
            }
            return (
                <div>
                    {/**列input框新表格弹框 */}
                    <PublicModalTable
                        onClickRowPublic={this.onClickRowPublic}
                        setRowClassNamePublic={this.setRowClassNamePublic}
                        param={modalParam}
                        onRef={this.modalOnRef}
                        compilePage={this.handleCompilePage}
                    />
                    <Modal
                        visible={this.state.visible}
                        title={"医保登记"}
                        onCancel={this.handleCancel}
                        width="100vh"
                        footer={
                            <div>
                                {this.state.insuAdmID === "" ?<Button type="primary" onClick={this.InsuRegist}>登    记</Button>:<Button type="danger" onClick={this.CancelInsuRegist}>取消登记</Button>}
                                {((this.state.reasonCode != "INSUHFSYB")&&(this.state.insuAdmID != "")&&(this.state.insustatus != "D")) ? <Button type="primary" onClick={this.InsuUpdataRegist}>更新登记信息</Button> : ""}
                                {this.state.insustatus === "D" ? <Button type="primary" onClick={this.cancelLeaveInpatientRegister}>取消出院登记</Button> : ""}

                            </div>
                        }
                    >
                        <div>
                            <Row className="ybpat-row">
                                {this.state.Divdata.map((item, index) => {
                                    return <Col className="ybpat-col" span={6} key={index}>
                                        <span className="ybpat-desc">{item.desc}</span>
                                        <span>：</span>
                                        <span className="ybpat-value">{item.value}</span>
                                    </Col>
                                })}
                            </Row>
                            <Row style={{ borderTop: "1px solid #ccc" }}>
                                {this.state.reasonCode === "INSUHFSYB" ?<Col className="ybpat-col" span={8} key={1}>
                                    <div><span className="ybpat-desc">入院类型</span>
                                    <span>：</span>
                                        <span className="ybpat-value">
                                        <Select style={{ width: '150px', margin: '12px 15px 0 0' }} value={this.state.admissionType} onChange={(event) => { this.admissionType(event) }}>
                                            <Option value='001'>正常入院</Option>
                                            <Option value='002'>转院入院</Option>
                                        </Select></span></div>
                                </Col>:""}
                                {((this.state.reasonCode === "INSUHFXNHY")||(this.state.reasonCode === "INSUHFYDYB")) ?<Col className="ybpat-col" span={8} key={1}>
                                    {this.state.xnhjgList && this.state.xnhjgList.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.xnhjgCode} onChange={this.xnhjgListonChange} >
                                                {this.state.xnhjgList.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={2}>
                                    {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={3}>
                                    <div><span className="ybpat-desc">ICD诊断</span>
                                        <span>：</span>
                                        <span className="ybpat-value">
                                        <Input
                                            style={{ width: '200px', margin: '12px 15px 0 0' }}
                                            id='input-id'
                                            placeholder='输入后回车搜索'
                                            onPressEnter={this.itmOnPressEnter}
                                            value={this.state.searchCode ? this.state.searchCode : this.state.INSUICDDesc}
                                            onChange={this.itmOnChange}
                                            allowClear
                                        />
                                        </span></div>
                                </Col>
                            </Row>
                            <Row style={{ borderTop: "1px solid #ccc" }}>
                                {this.state.reasonCode === "INSUHFXNHY" ?<Col className="ybpat-col" span={8} key={2}>
                                    <span className="ybpat-desc">入院状态</span>
                                    <span>：</span>
                                    <span className="ybpat-value">
                                        <Select style={{ width: '150px', margin: '12px 15px 0 0' }} value={this.state.inHosId} onChange={(event) => { this.adminHosId(event) }}>
                                            <Option value='1'>危</Option>
                                            <Option value='2'>急</Option>
                                            <Option value='3'>一般</Option>
                                            <Option value='9'>其他</Option>
                                        </Select>
                                    </span>
                                </Col>:""}
                                {this.state.reasonCode === "INSUHFYDYB" ?<Col className="ybpat-col" span={8} key={2}>
                                    <span className="ybpat-desc">医疗类别</span>
                                    <span>：</span>
                                    <span className="ybpat-value">
                                        <Select style={{ width: '150px', margin: '12px 15px 0 0' }} value={this.state.medicalType} onChange={this.medicalTypeChange} >
                                                {this.state.medicalTypeList.map((item, index) => <Option title={item.subDesc} key={index} value={item.subCode}  >{item.subDesc}</Option>)}
                                            </Select>
                                    </span>
                                    {this.state.reasonCode === "INSUHFYDYB"?<span className="ybpat-value">
                                        <Select style={{ width: '150px', margin: '12px 15px 0 0' }} value={this.state.readCardType} onChange={(event) => { this.changereadCardType(event) }}>
                                            <Option value='read'>读医保卡</Option>
                                            <Option value='numble'>身份证号</Option>
                                        </Select>
                                    </span>:""}
                                </Col>:""}
                            </Row>
                        </div>
                    </Modal>
                    <Modal
                        title="请输入医保卡号或扫描电子凭证医保码"
                        visible={this.state.cardShow}
                        onOk={this.YBInputSure}
                        onCancel={() => this.setState({
                            cardShow: false,
                            visible: true,
                            insuReasonShow: false
                        })}
                    >
                        {((this.state.reasonCode === "INSUHFXNHY")||(this.state.reasonCode === "INSUHFYDYB")) ? <Row style={{ borderTop: "1px solid #ccc" }}>
                            {this.state.xnhjgList && this.state.xnhjgList.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.xnhjgCode} onChange={this.xnhjgListonChange} >
                                        {this.state.xnhjgList.map((item, index) => <Option title={item.subDesc} key={index} value={item.subCode}  >{item.subDesc}</Option>)}
                                    </Select></span>
                                    {this.state.reasonCode === "INSUHFYDYB"?<span className="ybpat-value">
                                        <Select style={{ width: '150px', margin: '12px 15px 0 0' }} value={this.state.readCardType} onChange={(event) => { this.changereadCardType(event) }}>
                                            <Option value='read'>读医保卡</Option>
                                            <Option value='numble'>身份证号</Option>
                                        </Select>
                                    </span>:""}
                                    </div> : ""}
                        </Row> : ""}
                        {inputname}<Input placeholder={nameplaceholder} value={this.state.cardNumber} onChange={(e) => this.onCardChange(e)} onPressEnter={this.YBInputSure}></Input>
                        {inputname === "医保卡号:" ? <div>
                            电子凭证:<Input placeholder="请扫描电子凭证医保码回车" value={this.state.qrCode} onChange={(e) => this.onqrCodeChange(e)} onPressEnter={this.YBInputSure}></Input>
                        </div> : ""}
                        {/*/***/}
                        {/** @ByYQL: 根据济南医保要求新增区域类型*/}
                        {/** Create 2021-12-6*/}
                        {/*/*/}
                        {inputname === "医保卡号:" ? <div>
                            区域类型:
                            <Radio.Group style={{ marginLeft: '15px'}} onChange={(e) => {this.onAreaTypeChange(e)}} value={this.state.areaType}>
                                <Radio value='本地'>本地</Radio>
                                <Radio value='省内'>省内</Radio>
                                <Radio value='跨省'>跨省</Radio>
                                <Radio value='省直'>省直</Radio>
                            </Radio.Group>
                        </div> : ""}
                    </Modal>

                        <Modal
                            visible={this.state.insuReasonShow}
                            title={"修改费别"}
                            onCancel={() => this.setState({
                                insuReasonShow: false,
                                updReasonID: '',
                                cardShow: true,
                            })}
                            onOk={this.insuReasonUpdate}
                        >
                            结算费别：<Select
                                style={{ width: '150px', margin: '12px 15px 0 0' }}
                                value={this.state.updReasonID}
                                onChange={(val) => {
                                    if (val){
                                        this.setState({updReasonID: val})
                                    }
                                }}
                                placeholder = '请选择费别'
                            >
                                {this.state.admReasonArr.map((item, index) => <Option title={item.descripts} key={index} value={item.id} >{item.descripts}</Option>)}
                            </Select>
                        </Modal>
                </div>
            );
        }
    }
);
export default FormHandel;

FormHandel.propTypes = {
    // 验证userInfo的属性
    userInfo: PropTypes.object
}
