/*
 * Creator:     HLH
 * CreatDate:   2020-07-13
 * descripts：  诊疗记录打印
 * */
import React from 'react';
import {
    Card, Table, Input, Form, Select, Row, Col, Checkbox, Tabs, Spin,
    DatePicker, Button, Steps, Icon, Divider, message, Modal, Tooltip
} from 'antd';
import { $http } from '../../../containers/config/https';
import store from 'store';
import moment from 'moment';
import 'assets/css/common.css';
const { Option } = Select;
const { Search } = Input;
import ReadCard from 'components/readcard/ReadCard';
import RangeDatePicker from 'components/rangePicker/index.jsx';
// import DecoctingOrderModal from "../../orderdiatemplet/component/DecoctingOrderModal"
import CommonPagination from 'components/pagination';
import { Util, dayFormat } from 'tools/index';
import { $loadTemplate } from '../../lodop/Common/Print.js';
import ColumnAuthoritysModel from 'pages/columnAuthority/ColumnAuthoritysModel';
import { $PrintPresc } from '../../pharmacy/outpha/common/Print';
const FormItem = Form.Item;
const paddRightCol = {
    paddingRight: "0px"
}
const formItemLayout = {
    labelCol: { span: 8 },
    wrapperCol: { span: 16 },
}
// 组件const
let user = window.sessionStorage.userData ? JSON.parse(window.sessionStorage.userData) : {};
const MedicalRecordPrinting = Form.create()(
    class MedicalRecordPrinting extends React.Component {
        constructor(props) {
            var userData = JSON.parse(sessionStorage.getItem('userData'));
            super(props);
            this.state = {
                userData: userData,
                //所属医院
                hospID: '',
                //就诊类型id
                admTypeID: undefined,
                ID: undefined,
                // 表格数据
                tableData: [],
                // 表格数据总条数
                total: 0,
                page: 1,
                pageSize: 10,
                size: "small",
                search: "",
                visible: false,
                num: -1,
                params: {},
                columns: [],
                localeProvider: [],
                medValue: "",
                patNo: '',
                patName: '',
                cardNo: '', // 卡号
                cardType: '',
                startDate: moment(new Date()).subtract(3, 'days').format(dayFormat),
                endDate: moment(new Date()).format(dayFormat),
                printStatus: '',
                appStatus: '',
                patContent: '',
                userID: JSON.parse(window.sessionStorage.userData).userID,
                cardTypeData: [], // 卡类型
                languageTable1: {}, // 国际化Table1
                languageTable2: {}, // 国际化Table2
                languageData: {}, // 国际化语言包
                language: {},   // 国际化语言
                languageCode: JSON.parse(window.sessionStorage.userData).language, // 国际化语言标识
                butdisabled: true, //打印按钮
                rowId: '',
                invIDSt: '',
                selectedRowsArr: [],
                IDs: '',
                printFlag: 'N',
                prescNoData: [],
                IEMRTemplateID: '',
                printID: '',
                printData: ''
            };

        }
        componentDidMount() {
            this.cardTypeList() //卡类型
            // 初始化列表数据
            this.handleQuery();
            // this.loadCardType();
            this.getOrderCatSelect();
            this.getOrderSubCatSelect();
            this.getMedicalRecordSelect();
            document.querySelector(".table-body-height .ant-table-body").style.height = store.getState().tableHeight.y + 'px';
            document.querySelector(".table-body-height .ant-table-body").style.maxHeight = store.getState().tableHeight.y + 'px';
            this.getMainTableColumns();
        }
        // 查询
        handleQuery = () => {
            this.setState({ page: 1, pageSize: this.state.pageSize }, () => {
                let { startDate, hospID, endDate, printStatus, appStatus, patContent } = this.state;
                this.getTableData(startDate, hospID, endDate, printStatus, appStatus, patContent)
            })
        }
        // 请求列表数据
        getTableData(startDate, hospID, endDate, printStatus, appStatus, patContent) {
            let { page, pageSize } = this.state
            let data = {
                params: [{
                    startDate: patContent ? '' : startDate,
                    stopDate: patContent ? '' : endDate,
                    printStatus: printStatus,
                    appStatus: appStatus,
                    patContent: patContent,
                    hospID: sessionStorage.userData ? JSON.parse(sessionStorage.userData).hospID : "",
                }],
                pagination: [{
                    pageSize: pageSize,
                    currentPage: page
                }]
            }
            $http.post('urlS', this, {
                code: "03050238",
                data: data,
                success: function (res) {
                    if (res.errorCode == 0) {
                        this.setState({ tableData: res.result.data, total: res.result.totalCount })
                    } else {
                        this.setState({ tableData: [], total: 0 })
                    }
                },
                error: function (error) {
                    this.setState({
                        tableData: [], total: 0
                    })
                }
            })
        }
        LanCNEN = (code) => {
            let { languageData } = this.state
            this.setState({
                language: languageData[code]
            })
        }
        // 查询条件 --- 类型·
        cardType = (e) => {
            this.setState({ cardType: e }, () => {
                this.CardTypeChange(e)
            });
        }
        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;
            }

        }
        // 查询条件 --- 卡号
        cardNo = (e) => {
            this.setState({ cardNo: e.target.value });
        }
        // 查询条件 --- 登记号
        patNo = (e) => {
            this.setState({
                patContent: e.target.value,
            });
        }
        // 读卡 --- 根据卡号取病人信息
        handleReadCard = (value, event) => {
            if (event.keyCode) {
                this.searchUser('cardNo'); // 重新调用查询接口
                return false
            }
            this.readCard.PayByCard('', (json) => {
                if (json.errorCode === '0') {
                    let patNo = json && json.patInfo ? json.patInfo.patNo : ''
                    this.setState({ patNo , cardNo: json.cardNo, personalData: json.value }, () => {
                        this.setState({ visible: true, userInfo: this.state.personalData });
                    })
                } else {
                    console.log(this.state.personalData)
                }

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

                if (cardNo === '') {
                    return false
                }
                if (cardType === '') {
                    message.error('请选择卡类型')
                    return false
                }
                let cardTypeFilter = cardTypeData.filter(function (item) {
                    return item.id == cardType;
                })
                let zeroLength = cardTypeFilter[0].cardLength

                if (zeroLength && zeroLength != '' && parseFloat(zeroLength) != 0) {
                    this.setState({
                        cardNo: ArraySome.addPreZero(cardNo, zeroLength)
                    })
                    data = {
                        params: [{
                            "number": '', // 登记号/身份证号
                            "cardTypeID": cardType || '',     //卡类型id
                            "cardNo": ArraySome.addPreZero(cardNo, zeroLength) || '', //卡号
                        }]
                    }
                }
            }
            $http.post('urlS', this, {
                code: "03040004",
                data: data,
                success: function (res) {
                    let errorCode = res.errorCode;
                    if (errorCode === '0') {

                        this.setState({
                            patNo: res.data.patNo || '',  // ID
                        });
                    } else {
                        this.clearnFile()  // 清空 
                    }
                }
            });
        }
        //卡类型
        cardTypeList = () => {
            var data = {
                params: [{
                    cardTypeFlag: 1,
                }]
            }
            $http.post('urlS', this, {
                code: "03030005",
                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)
                        });
                    }
                }
            });
        }
        //控制模态框显示
        closeModal = (bool) => {
            this.setState({ visible: bool, });
        }
        //清空
        clearnFile = () => {
            this.setState({
                patID: '',
                dataAdmReason: [], // 费用类型table数据
                orderAdmReason: [
                    { ordReasonID: '0', ordReasonDesc: `${this.state.language.CentralizedPrintingpayrecord && this.state.language.CentralizedPrintingpayrecord.descripts}` } // 默认费用类型
                ], // tab费用类型
                userInfo: {}, // 用户数据
                cardNo: '',
                patNo: '',
                // invoice: '',
                dataPatChar: [],  // 挂号table数据
                settlementTypeData: [], // 结算类型
                allPrice: '0', // 发票数
                isListCheckload: [], // //是否加载过
                selectedRowKeys: [], //  清除选中
                selectedRowKeys2: [], //  清除选中
                admID: '', // 就诊id
                OPInsuType: '', // 
                selecteId: '', // 
                oldSelectedRowKeysArr: [],// 上一个选择数据
                activeKey: '0', //tab当前key
                findCondition: 'Y',
                StartDate: undefined,  // //开始日期
                EndDate: undefined,  // //结束日期
                userInfoModal: {},
                // selectedRowsArr: [],
                invIDSt: '',
                dateValue: new Date(),
                readModeI: true,
                readModeR: true,
                invNum: '0',
            });
        }
        //更新
        handleCompile = (num, record) => {
            this.props.form.resetFields();
            this.setState({
                num: num,
                params: num == "1" ? record : "",
                visible: true
            })
        }
        //获取申请状态下拉框
        getOrderCatSelect = () => {
            let data = [
                { "id": "Y", "descripts": "已申请" },
                { "id": "N", "descripts": "未申请" },
                { "id": "", "descripts": "全部" }
            ]
            this.setState({
                orderCatArr: data
            })
        }
        //获取打印内容下拉框
        getOrderSubCatSelect = (e) => {
            let data = [
                { "id": "Y", "descripts": "已打印" },
                { "id": "N", "descripts": "未打印" },
                { "id": "", "descripts": "全部" }
            ]
            this.setState({
                orderSubCatArr: data
            })
        }
        //获取诊疗记录下拉框
        getMedicalRecordSelect = (e) => {
            let data = {}
            $http.post('urlS', this, {
                code: '03050237',
                data: data,
                success: function (res) {
                    if (res.errorCode == 0) {
                        this.setState({
                            medicalRecordArr: res.result
                        })
                    }
                }
            })
        }
        ///当前多模板打印
        currentPrint = (e) => {
            this.addPrintInfo();
            console.log(this.state.printID, '3333')
            //this.save();
            this.handleQuery();
            let IDs = this.state.IDs
            for (var i = 0; i < IDs.length; i++) {
                if (IDs[i] == '1') {    //病历打印
                    this.handlePrintEMR();
                }
                if (IDs[i] == '2') {    //处方打印
                    this.handlePrit();
                }
                if (IDs[i] == '3') {    //诊断证明打印
                    this.handlePrintDistribution();
                }
                if (IDs[i] == '4') {    //发票打印
                    this.handlePrintInvoicen();
                }
            }
            if (this.state.printFlag == "Y") {
                this.updatePrintStatus();
                message.success('打印成功！')
            }
            this.handleQuery();
            this.closeModal(false)
        }
        // //打印处方
        // handlePrintPresc = () => {
        //     let { prescNoData } = this.state;
        //     for (var i = 0; i < prescNoData.length; i++) {
        //         let params;
        //         params = {
        //             prescno: prescNoData[i],
        //             phFlag: 1,
        //         }
        //         $PrintPresc(params);
        //     }
        // }
        //处方点击打印
        handlePrit = () => {
            let data = {}
            data = {
                params: [{
                    admID: this.state.rowId ? this.state.rowId : "",
                    userID: sessionStorage.userData ? JSON.parse(sessionStorage.userData).hospID : "",
                    hospID: sessionStorage.userData ? JSON.parse(sessionStorage.userData).hospID : "",
                    groupID: sessionStorage.userData ? JSON.parse(sessionStorage.userData).groupID : "",
                    ordPrescNo: this.state.prescNoData || "",
                }],
            }
            $http.post('urlS', this, {
                code: '03050091',
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        if (res.result && res.result.length > 0) {
                            res.result.map((item, i) => {
                                $loadTemplate(item.template, item.printStr);
                            })
                        }
                    }
                },
            })
        }
        //打印发票 
        handlePrintInvoicen = () => {
            var params = {
                params: [{
                    admID: this.state.rowId
                    // expressOrderID: this.state.expressOrderID
                }]
            }
            $http.post('urlDeault', this, {
                code: "03050242",
                data: params,
                success: function (res) {
                    if (res.errorCode == '0') {
                        var print = res.result;
                        if (!Util.isEmpty(print)) {
                            for (var i = 0; i < print.length; i++) {
                                $loadTemplate(print[i].template, print[i].printStr);
                            }
                            //message.success('打印成功！')
                            this.setState({
                                printFlag: "Y"
                            })
                        }
                    }
                }
            });
        }
        //打印诊断证明
        handlePrintDistribution() {
            var params = {
                params: [{
                    hospID: this.state.userData.hospID,
                    locID: this.state.userData.locID,
                    userID: this.state.userData.userID,
                    admID: this.state.rowId
                    // expressOrderID: this.state.expressOrderID
                }]
            }
            $http.post('urlDeault', this, {
                code: "03050232",
                data: params,
                success: function (res) {
                    if (res.errorCode == '0') {
                        var print = res.result;
                        if (!Util.isEmpty(print)) {
                            for (var i = 0; i < print.length; i++) {
                                $loadTemplate(print[i].template, print[i].printStr);
                            }
                            //message.success('打印成功！')
                            this.setState({
                                printFlag: "Y"
                            })
                        }
                    }
                }
            });
        }
        //打印病历
        handlePrintEMR() {
            var params = {
                params: [{
                    hospID: this.state.userData.hospID,
                    // locID: this.state.userData.locID,
                    // userID: this.state.userData.userID,
                    // admID: this.state.patientData && this.state.patientData.admID,
                    IEMRTemplateID: this.state.IEMRTemplateID,
                    admID: this.state.rowId,
                }]
            }
            if (this.state.IEMRTemplateID) {
                $http.post('urlDeault', this, {
                    code: "10020005",
                    data: params,
                    success: function (res) {
                        if (res.errorCode == '0') {
                            let templateCode = 'HLWMZBL';
                            $loadTemplate(templateCode, res.result);
                            this.setState({
                                printFlag: "Y"
                            })
                        }
                    }
                }
                )
            } else {
                message.success('没有病历')
            }
        }
        // // 打印发票
        // printButtont = () => {
        //     let { selectedRowsArr } = this.state
        //     console.log(selectedRowsArr, '1231242')
        //     if (selectedRowsArr && selectedRowsArr.length < 1) {
        //         return false
        //     }
        //     var data = {
        //         recordIDArr: selectedRowsArr,
        //         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 || '', 				//IP
        //         }]
        //     }
        //     console.log(data)
        //     //打印发票
        //     $http.post('urlADS', this, {
        //         code: "05210034",
        //         data: data,
        //         success: function (res) {
        //             let errorCode = res.errorCode;
        //             if (errorCode === '0') {
        //                 this.setState({
        //                     invIDSt: res.invIDStr
        //                 }, () => {
        //                     this.print()   // 打印
        //                     this.clearnFile()//清空
        //                 })
        //             }
        //         }
        //     });
        // }
        // // 公共打印方法
        // print = () => {
        //     var data = {
        //         params: [{
        //             "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id 
        //             "groupID": JSON.parse(window.sessionStorage.userData).groupID,  //角色id
        //             "printType": "",
        //             "printTemplateCode": "OutInvoice",
        //             "recordIDStr": '',
        //             "invIDStr": this.state.invIDSt || '',
        //         }]
        //     }
        //     $http.post('urlADS', this, {
        //         code: "05100153",
        //         data: data,
        //         success: function (res) {
        //             let errorCode = res.errorCode;
        //             if (errorCode === '0') {
        //                 this.setState({
        //                     printFlag: "Y"
        //                 })
        //                 let dataArr = res.data
        //                 let template = res.template
        //                 dataArr.map((item, i) => {
        //                     $loadTemplate(template[i], item.toString());
        //                 })
        //                 this.clearnFile()
        //             }
        //         }
        //     });
        // }
        rowSelectionOnChange1 = (selectedRowKeys1, selectedRows) => {
            let { selectedRowsArr } = this.state
            selectedRowsArr = []
            selectedRows.map((item, i) => {
                selectedRowsArr.push(item.recordIDStr)
            })
            let l = selectedRowKeys1.length
            this.setState({
                selectedRowKeys1: selectedRowKeys1,
                allPrice: l,
                selectedRowsArr: selectedRowsArr
            })
        }
        rowSelectionOnChange2 = (selectedRowKeys2, selectedRows) => {
            let str = ''
            selectedRows.map((item, i) => {
                str += item.recordID + '^'
            })
            str = str.substring(0, str.length - 1);
            var data = {
                params: [{
                    "hospID": JSON.parse(window.sessionStorage.userData).hospID, //医院id 
                    "recordIDStr": str
                }]
            }
            $http.post('urlADS', this, {
                code: "05210026",
                data: data,
                success: function (res) {
                    let errorCode = res.errorCode;
                    let InvingInfo = res.InvingInfo;
                    if (!InvingInfo) {
                        this.setState({ dataPatChar: [], allPrice: '0', })
                    }
                    if (errorCode === '0') {
                        for (var i = 0; i < InvingInfo.length; i++) {
                            InvingInfo[i].key = i;
                        }
                        this.setState({
                            dataPatChar: InvingInfo || []
                        }, () => {
                            let key = []
                            let { dataPatChar } = this.state
                            dataPatChar.map((item, i) => {
                                let index = i + 1
                                key.push(index)
                            })
                            this.rowSelectionOnChange1(key, dataPatChar)
                        })
                    }
                }
            });
        }
        startChange = (date) => {
            console.log(date)
            this.setState({
                startDate: date,
            })
        }
        endChange = (date) => {
            this.setState({
                endDate: date,
            })
        }
        // 申请状态
        hospDrChange = (e) => {
            this.setState({
                appStatus: e,
            })
        }
        // 打印状态
        locIdChange = (e) => {
            this.setState({
                printStatus: e,

            })
        }
        save = () => {
            this.props.form.validateFields((err, values) => {
                const { params } = this.state
                if (!err) {
                    let data = {
                        params: [{
                            printID: this.state.printID,
                            printData: this.state.IDs,
                            userID: sessionStorage.userData ? JSON.parse(sessionStorage.userData).userID : ""
                        }]
                    }
                    $http.post("urlS", this, {
                        code: "03050239",
                        data: data,
                        success: function (res) {
                            if (res.errorCode == 0) {
                                // console.log(params)  
                                this.handleQuery();
                            } else {
                                message.error('失败：' + res.errorMessage);
                            }
                        },
                        error: function (error) {
                            message.error('失败：' + error);
                        }
                    })
                } else {
                }
            })
        }
        updatePrintStatus = () => {
            this.props.form.validateFields((err, values) => {
                if (!err) {
                    let data = {
                        params: [{
                            printID: this.state.printID,
                            userID: sessionStorage.userData ? JSON.parse(sessionStorage.userData).userID : ""
                        }]
                    }
                    $http.post("urlS", this, {
                        code: "03050240",
                        data: data,
                        success: function (res) {
                            if (res.errorCode == 0) {
                                // console.log(params)   
                            } else {
                                message.error('失败：' + res.errorMessage);
                            }
                        },
                        error: function (error) {
                            message.error('失败：' + error);
                        }
                    })
                } else {
                }
            })
        }
        addPrintInfo = () => {
            this.props.form.validateFields((err, values) => {
                if (!err) {
                    let data = {
                        params: [{
                            ID: this.state.printID ? this.state.printID : '',
                            hospID: JSON.parse(window.sessionStorage.userData).hospID, //医院id 
                            userID: sessionStorage.userData ? JSON.parse(sessionStorage.userData).userID : "",
                            admID: this.state.rowId
                        }]
                    }
                    $http.post("urlS", this, {
                        code: "03050241",
                        data: data,
                        success: function (res) {
                            console.log(res, 'res')
                            if (res.errorCode == '0') {
                                this.setState({
                                    printID: this.state.printID == "" ? res.result.ID : this.state.printID
                                }, () => { this.save(); })
                                console.log(this.state.printID, '999999')

                            } else {
                                message.error('失败：' + res.errorMessage);
                            }
                        },
                        error: function (error) {
                            message.error('失败：' + error);
                        }
                    })
                } else {
                }
            })
        }
        // 修改page和pageSize 跳转至---
        onChange = (e) => {
            this.setState({ page: e, pageSize: this.state.pageSize, }, () => {
                // 重新调用查询方法
                let { startDate, hospID, endDate, printStatus, appStatus, patContent } = this.state;
                this.getTableData(startDate, hospID, endDate, printStatus, appStatus, patContent);
            })
        }
        //下拉选择页数
        onShowSizeChange = (page, pageSize) => {
            // console.log("page",page,"pagesize",pageSize)
            this.setState({ page: 1, pageSize: pageSize, search: "search" }, () => {
                // 重新调用查询方法
                let { startDate, hospID, endDate, printStatus, appStatus, patContent } = this.state;
                this.getTableData(startDate, hospID, endDate, printStatus, appStatus, patContent);
            })
        }
        // 显示分页总条数
        showTotal(total) {
            return `共 ${total} 条`
        }
        handleSelectChange = (e) => {
            this.setState({
                hospID: e
            })
        }
        handleSelectAdmTypeChange = (e) => {
            this.setState({
                admTypeID: e
            })
        }
        handleSelectPriorityChange = (e) => {
            this.setState({
                priorityID: e,
            })
        }
        //动态表头
        onColumnRef = (ref) => {
            this.columnRef = ref;
        }
        //国际化
        setMessage(name, message) {
            return this.state.localeProvider ? this.state.localeProvider[name][message] : ''
        }
        // 获取主列表columns
        getMainTableColumns = () => {
            let data = {
                params: [{
                    compontName: "MedicalRecords",
                    reactCode: ['MedicalRecords'],
                    type: 'C',
                }]
            }
            $http.post('urlS', this, {
                code: '01040073',
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        let resC = res.result.C
                        let { languageCode } = this.state
                        for (var i = 0; i < resC.length; i++) {
                            resC[i].key = i;
                        }
                        if (languageCode === "EN") {
                            resC.map((item, i) => {
                                item.title = item.enDescripts
                            })
                        }

                        if (languageCode === "CN") {
                            resC.map((item, i) => {
                                item.title = item.descripts
                            })
                        }
                        let arr = res.result && resC.length > 0 ? JSON.parse(JSON.stringify(resC)).map(item => {
                            return {
                                align: item.align,
                                widthNum: parseInt(item.width),
                                width: item.width,
                                dataIndex: item.dataIndex,
                                title: <div onDoubleClick={() => this.columnRef.onOpenModel()}>{item.title}</div>,
                                display: item.display,
                                key: item.seqNo
                            }
                        }) : '';
                        let filterArr = arr.filter(function (item) { return item.display === 'Y' });
                        this.setState({
                            columns: filterArr,
                            languageTable1: res.result.B || {},  // 国际化Table1
                            languageTable2: res.result.C || {},  // 国际化Table2
                            languageData: res.result.language || {},  // 国际化语言包
                        }, () => {
                            this.LanCNEN(this.state.languageCode)
                        })
                    }
                }
            })
        }
        //复选框
        onChangeBox = (e) => {
            this.setState({
                IDs: e
            })
        }
        //点击查询后 表格行
        setRowClassNames = (record) => {
            return record.admID === this.state.rowId ? 'clickRowStyle' : '';
        }
        //点击Row ---
        onClickRow = (record) => {
            return {
                onClick: () => {
                    this.setState({
                        rowId: record.admID,
                        butdisabled: false,
                        IEMRTemplateID: record.iEMRTemplateID,
                        printID: record.printID,
                        printData: record.printData,
                        IDs: record.printData,
                        prescNoData: record.prescNoData,
                    });
                }
            };

        }
        render() {
            // 组件所需参数
            const param = {
                // 表格数据
                data: this.state.tableData,
                // 数据总条数
                total: this.state.total,
                // 当前页数
                page: this.state.page,
            }
            const { getFieldDecorator } = this.props.form;
            const { params, columns } = this.state
            var date = new Date();
            //诊疗记录下拉
            let optionsWithDisabled = []
            this.state.medicalRecordArr && this.state.medicalRecordArr.map((item) => {
                optionsWithDisabled.push({ label: item.descripts, value: item.id })
            })
            let { selectedRowKeys2, selectedRowKeys1, language } = this.state
            let rowSelection1 = {
                selectedRowKeys1,
                onChange: this.rowSelectionOnChange1,
            };
            let rowSelection2 = {
                selectedRowKeys2,
                onChange: this.rowSelectionOnChange2,
            };
            return (
                <div>
                    <div className="department-header">
                        <Row style={{ minHeight: '64px', padding: '0 24px' }}>
                            <Col span={24}>
                                <Select allowClear style={{ width: '100px', margin: '12px 15px 0 0' }} placeholder="请选择卡类型" value={this.state.cardType} onChange={(event) => { this.cardType(event) }}  >
                                    <Option value=''>请选择</Option>
                                    {this.state.cardTypeData.map(item => <Option title={item.descripts + '^' + item.descriptsSPCode} key={item.id} value={item.id}  >{item.descripts}</Option>)}
                                </Select>
                                <span style={{ display: 'inline-block', margin: '10px 15px 0 0' }}>
                                    <Search maxLength={50} ref={(input) => { this.cardNoInput = input; }} style={{ width: '200px', }} allowClear placeholder="请输入卡号" disabled={this.state.disabledInput} value={this.state.cardNo} enterButton="读卡" onChange={(event) => { this.cardNo(event) }} onSearch={this.handleReadCard} /> {/* onKeyUp={(e) => { this.handleReadCarddownE(e, 'cardNo'); }}*/}
                                </span>
                                {/* {language.FindDepositpatientinformation && language.FindDepositpatientinformation.descripts} */}
                                 人员标识：<Input placeholder="病人ID/姓名/身份证号/手机号" style={{ width: '170px', margin: '12px 15px 0 0' }} onChange={(event) => { this.patNo(event) }} onKeyUp={(e) => { this.patNodownE(e) }} />
                                <span style={{ display: 'inline-block', margin: '12px 15px 0 0' }}>
                                    <RangeDatePicker label='就诊日期：' format='YYYY-MM-DD' width={300}
                                        startDate={moment(date).subtract(3, 'days').format(dayFormat)} endDate={moment(date).format(dayFormat)}
                                        startChange={this.startChange} endChange={this.endChange} />
                                </span>
                                {this.state.localeProvider && this.state.localeProvider.TreatmentConfigurationInformatHospital ? this.setMessage('TreatmentConfigurationInformat', 'descripts') : "申请状态："}
                                <Select showSearch optionFilterProp="title1" onChange={(event) => { this.hospDrChange(event) }} style={{ width: '100px', margin: '23px 8px 0 5px' }}  >
                                    {this.state.orderCatArr && this.state.orderCatArr.map((item) => <Option title={item.descripts} title1={item.descripts} key={item.id} value={item.id}  >{item.descripts}</Option>)}
                                </Select>
                                {this.state.localeProvider && this.state.localeProvider.TreatmentConfigurationInformatHospital ? this.setMessage('TreatmentConfigurationInformat', 'descripts') : "打印状态："}
                                <Select showSearch onChange={(event) => { this.locIdChange(event) }} style={{ width: '100px', margin: '23px 8px 0 5px' }} optionFilterProp="title1" >
                                    {this.state.orderSubCatArr && this.state.orderSubCatArr.map((item) => <Option title={item.descripts} title1={item.descripts} key={item.id} value={item.id}  >{item.descripts}</Option>)}
                                </Select>
                                <Button onClick={this.handleQuery} style={{ margin: '23px 15px 20px 0', background: 'rgba(255,255,255,1)' }}>{this.state.localeProvider && this.state.localeProvider.MaintenanceOfTreatmentItemInquire ? this.setMessage('MaintenanceOfTreatmentItemInquire', 'descripts') : "查询"}</Button>
                                <Button
                                    onClick={() => this.closeModal(true)}
                                    //disabled={!this.state.printID}
                                    style={{ margin: '23px 15px 0 0', border: 'none', background: !this.state.rowId ? "#BEBEBE" : "#0080FF", color: '#fff' }} disabled={this.state.butdisabled}>{this.state.localeProvider && this.state.localeProvider.MaintenanceOfTreatmentItemAdd ? this.setMessage('MaintenanceOfTreatmentItemAdd', 'descripts') : "打印"}</Button>
                                {/* <Button
                                    // onClick={() => this.handleCompile()}
                                    style={{ background: 'rgba(247,128,93,1)', color: '#fff', margin: '23px 15px 0 0' }}>{this.state.localeProvider && this.state.localeProvider.MaintenanceOfTreatmentItemAdd ? this.setMessage('MaintenanceOfTreatmentItemAdd', 'descripts') : "预览"}</Button> */}
                            </Col>
                        </Row>
                    </div>
                    <div style={{ widht: '100%', height: '10px', background: '#f0f2f5' }}></div>
                    <div style={{ padding: 24 }} className="table-body-height">
                        <Table
                            columns={columns}
                            dataSource={param.data}
                            pagination={false}
                            bordered
                            style={{ height: store.getState().tableHeight.y + 'px', overflow: "auto" }}
                            onRow={this.onClickRow}
                            rowClassName={this.setRowClassNames}
                        />
                        <CommonPagination size={this.state.size} page={this.state.page} current={this.state.page} total={this.state.total} search={this.state.search}
                            onShowSizeChange={this.onShowSizeChange.bind(this)} complete={true} dataSource={param.data}
                            onChange={this.onChange.bind(this)} />
                        <ColumnAuthoritysModel
                            clientWidth='800px'
                            compontName='MaintenanceOfTreatmentItem'
                            configType="C"
                            onRef={this.onColumnRef}
                            reloadData={this.getMainTableColumns}
                        />
                        <Modal
                            title="打印内容"
                            visible={this.state.visible}
                            onOk={() => this.closeModal(false)}
                            onCancel={() => this.closeModal(false)}
                            width={400}
                            footer={[
                                <Button key="submit" type="primary" loading={this.setState.loading} disabled={this.state.rowId == ""}
                                    //onClick={this.printButtont}   // 打印发票
                                    // disabled={!this.state.expressOrderID}
                                    //  onClick={this.handlePrintEMR.bind(this)}  // 打印病历
                                    onClick={this.currentPrint}
                                >{this.state.localeProvider && this.state.localeProvider.MaintenanceOfTreatmentItemDetermine ? this.setMessage('MaintenanceOfTreatmentItemDetermine', 'descripts') : "确定"}</Button>
                            ]}
                        >
                            <Checkbox.Group
                                options={optionsWithDisabled}
                                // defaultValue={this.state.printData}
                                value={this.state.IDs}
                                onChange={this.onChangeBox}
                            />
                        </Modal>
                    </div>
                </div>
            );
        }
    })
export default MedicalRecordPrinting;
