<template>
    <div class="app-container">
        <el-card class="userInfo_box">
            <div class="boxmain">
                <div class="btslist" v-if="!cardNoShow">
                    <el-button @click="cardtype('1')" style="color: #3d7ff5; width: 97px; font-size: 17px; font-weight: 600; border-radius: 8px">读卡</el-button>
                </div>
                <div class="userInfo_div">
                    <div class="userInfo_div_1">
                        <div class="userInfo_name">{{ patientData.name || '' }}</div>
                        <div class="userInfo_sex">{{ patientData.sex ? patientData.sex.name : '' }}</div>
                        <div class="userInfo_age">{{ patientData.age }}岁</div>
                        <div class="yibaoInfo_div">
                            <div class="yibaoInfo_div_1">{{ patientData.type ? patientData.type.name : '' }}</div>
                        </div>
                        <div class="yibaoInfo_div_2">就诊卡：{{ patientData.patient_id }}</div>
                        <div class="yibaoInfo_div_2">身份证号：{{ patientData.id_card }}</div>
                        <div class="yibaoInfo_div_2">手机号：{{ patientData.phone }}</div>
                        <div class="yibaoInfo_div_2">余额：{{ patientData.balance }}</div>
                    </div>
                </div>
            </div>
        </el-card>
        <div style="display: flex; justify-content: space-around; margin-top: 10px">
            <div class="box-card" style="width: 49%">
                <div class="box_card_title">
                    <div>自费转医保结算清单</div>
                </div>

                <div class="content-left-type" style="height: 30px; line-height: 30px; padding: 0 10px">
                    <el-radio-group v-model="patientInfo.yblx" size="medium" @input="seletei">
                        <el-radio :label="item.settle_type.name" v-for="(item, index) in typeList" :key="index">{{ item.settle_type.name }}</el-radio>
                    </el-radio-group>
                </div>

                <el-table
                    ref="multipleTableClinicRoom"
                    @selection-change="handleSelectionChange"
                    :data="tableDataList"
                    tooltip-effect="dark"
                    style="width: 100%; height: calc(100vh - 320px)"
                    :header-cell-style="{ background: '#E7EEFF', color: '#333333' }"
                    v-loading="loading"
                    element-loading-text="拼命加载中"
                >
                    <template slot="empty">
                        <el-empty :image="tempsrc" :image-size="300" description="暂无数据"></el-empty>
                    </template>
                    <el-table-column align="center" type="selection" width="45"> </el-table-column>
                    <el-table-column prop="occurrence_dept_name" label="开单科室"> </el-table-column>
                    <el-table-column prop="doct_name" label="医生姓名" width="80"> </el-table-column>

                    <el-table-column prop="occurrence_time" label="费用发生日期" width="120" :show-overflow-tooltip="true"> </el-table-column>
                    <el-table-column prop="clinic_no" label="就诊序号" :show-overflow-tooltip="true"> </el-table-column>
                    <el-table-column prop="rcpt_no" label="流水号" width="120" :show-overflow-tooltip="true"> </el-table-column>
                    <el-table-column prop="total" align="center" label="总金额" width="110"> </el-table-column>
                </el-table>
            </div>
            <div class="box-card" style="width: 49%">
                <div class="box_card_title">
                    <div>费用明细</div>
                    <div>
                        <el-button type="primary" size="mini" round @click="jshistory">结算历史</el-button>
                    </div>
                </div>

                <div class="content-left-type" style="height: 30px; line-height: 30px"></div>

                <el-table :data="costlist" tooltip-effect="dark" style="height: calc(100vh - 320px)" :cell-style="styleBack" v-loading="loading2" element-loading-text="拼命加载中">
                    <template slot="empty">
                        <el-empty :image="tempsrc" :image-size="300" description="暂无数据"></el-empty>
                    </template>
                    <el-table-column prop="item_name" label="费用名称" width="130" :show-overflow-tooltip="true"> </el-table-column>
                    <el-table-column prop="amount" align="center" label="单价"> </el-table-column>
                    <el-table-column prop="qty" align="center" label="数量"> </el-table-column>
                    <el-table-column prop="total" align="center" label="金额"> </el-table-column>
                    <el-table-column prop="zfbl" align="center" label="自付比例" width="100">
                        <template slot-scope="scope">
                            <div>
                                <!-- <el-input v-model="scope.row.zfbl" type="text" ref="zifu" @focus="savefocus(scope.row)"></el-input> -->
                                <el-select v-model="scope.row.zfbl" placeholder="请选择" @change="savebtn(scope.row)">
                                    <el-option v-for="item of scope.row.zfbl_multi" :key="item" :label="item" :value="item"> </el-option>
                                </el-select>
                                <el-button size="mini" type="primary" v-if="seemodel == scope.row.id" @click.stop="savebtn(scope.row)">保存</el-button>
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column prop="self2yb_remark" align="center" label="备注" :show-overflow-tooltip="true" width="130"> </el-table-column>
                    <el-table-column align="center" label="操作">
                        <template slot-scope="scope">
                            <el-button type="primary" @click="getProp(scope.row)" size="small">最新比例</el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </div>
        </div>
        <div class="footer_div" style="display: flex; margin-top: 15px">
            <div class="footer_total">
                <span>合计：</span>
                <span>￥{{ total }}</span>
            </div>
            <el-button class="jiesuan_btn" type="primary" @click="jiesuan" style="margin-left: 100px; width: 80px; z-index: 99" v-loading="yujiesuanload">确认结算</el-button>
            <!-- <el-button type="primary" @click="selectCardYiboPre('1')"
                style="position: absolute; right: 21px; bottom: 8px">确认结算</el-button> -->
        </div>

        <el-dialog title="提示" :visible.sync="dialogVisible" width="80%" :close-on-click-modal="false">
            <div slot="title" class="" style="border-bottom: 1px solid #e6e6e6; margin-bottom: 10px">
                <span class="titles" style="color: #484848">结算确认</span
                ><span style="color: #666666"
                    >（ 姓名：{{ patientData.name }} <span style="margin: 0px 10px"> 门诊号码: {{ patientData.patient_id }} </span>病人ID：{{ patientData.id_card }}

                    ）<span style="color: red">{{ selectTableArr[0] ? selectTableArr[0].settle_type.name : '' }}</span></span
                >
                <span style="margin-left: 10px">{{ this.channels }}</span>
            </div>
            <div>
                <div style="" class="abc">
                    <el-form ref="form2" size="mini" :model="form" v-loading="loadingapplyList" element-loading-text="结算中，请稍后..." element-loading-spinner="el-icon-loading">
                        <el-card style="width: 100%; overflow-x: auto" class="fullbox">
                            <div>
                                <div>
                                    <el-divider content-position="left">医保卡信息</el-divider>
                                    <div class="boxmain">
                                        <el-form-item>
                                            <div class="form_item">
                                                <el-tag class="label" color="#E7EEFF">病人姓名</el-tag>
                                                <el-input v-model="patientData.name" readonly></el-input>
                                            </div>
                                        </el-form-item>

                                        <el-form-item>
                                            <div class="form_item">
                                                <el-tag class="label" color="#E7EEFF">人员类别</el-tag>
                                                <el-input v-if="patientData.type" v-model="patientData.type.name" readonly></el-input>
                                            </div>
                                        </el-form-item>
                                        <el-form-item>
                                            <div class="form_item">
                                                <el-tag class="label" color="#E7EEFF">单位名称</el-tag>
                                                <el-input v-model="form.dwmc" readonly></el-input>
                                            </div>
                                        </el-form-item>
                                    </div>
                                    <div class="boxmain">
                                        <el-form-item>
                                            <div class="form_item">
                                                <el-tag class="label" color="#E7EEFF">经办机构</el-tag>
                                                <el-input v-model="form.jbjg" readonly></el-input>
                                            </div>
                                        </el-form-item>
                                        <el-form-item>
                                            <div class="form_item">
                                                <el-tag class="label" color="#E7EEFF">身份证号</el-tag>
                                                <el-input v-model="patientData.id_card" readonly></el-input>
                                            </div>
                                        </el-form-item>
                                        <el-form-item>
                                            <div class="form_item">
                                                <el-tag class="label" color="#E7EEFF">医保卡号/电子</el-tag>
                                                <el-input v-model="form.ybkh" readonly></el-input>
                                            </div>
                                        </el-form-item>
                                    </div>
                                    <div class="boxmain">
                                        <el-form-item>
                                            <div class="form_item">
                                                <el-tag class="label" color="#E7EEFF">共济账户余额</el-tag>
                                                <el-input v-model="bxxxinfo.family_balance" readonly></el-input>
                                            </div>
                                        </el-form-item>
                                        <el-form-item>
                                            <div class="form_item">
                                                <el-tag class="label" color="#E7EEFF">院内账户余额</el-tag>
                                                <el-input v-model="bxxxinfo.cash_balance" readonly></el-input>
                                            </div>
                                        </el-form-item>
                                        <el-form-item>
                                            <div class="form_item">
                                                <el-tag class="label" color="#E7EEFF">医保账户余额</el-tag>
                                                <el-input v-model="bxxxinfo.personal_balance" readonly></el-input>
                                            </div>
                                        </el-form-item>
                                    </div>

                                    <el-divider content-position="left">报销综合信息</el-divider>
                                    <div class="boxmain">
                                        <el-form-item>
                                            <div class="form_item">
                                                <el-tag class="label" color="#E7EEFF">结算类型</el-tag>
                                                <el-input v-if="bxxxinfo.settle_type" v-model="bxxxinfo.settle_type.name" readonly></el-input>
                                            </div>
                                        </el-form-item>

                                        <el-form-item>
                                            <div class="form_item">
                                                <el-tag class="label" color="#E7EEFF">本次病人负担</el-tag>
                                                <el-input v-model="bxxxinfo.patient_burden" readonly></el-input>
                                            </div>
                                        </el-form-item>
                                        <el-form-item>
                                            <div class="form_item">
                                                <el-tag class="label" color="#E7EEFF">医保负担</el-tag>
                                                <el-input v-model="bxxxinfo.insurance_burden" readonly></el-input>
                                            </div>
                                        </el-form-item>
                                    </div>
                                    <div class="boxmain">
                                        <el-form-item>
                                            <div class="form_item">
                                                <el-tag class="label" color="#E7EEFF">其他费用</el-tag>
                                                <el-input v-model="bxxxinfo.other_expense" readonly></el-input>
                                            </div>
                                        </el-form-item>
                                        <el-form-item>
                                            <div class="form_item">
                                                <el-tag class="label" color="#E7EEFF">医院负担</el-tag>
                                                <el-input v-model="bxxxinfo.yyfdje" readonly></el-input>
                                            </div>
                                        </el-form-item>
                                        <el-form-item>
                                            <div class="form_item">
                                                <el-tag class="label" color="#E7EEFF">本次个人账户</el-tag>
                                                <el-input v-model="bxxxinfo.grzhzf" readonly></el-input>
                                            </div>
                                        </el-form-item>
                                    </div>
                                    <div class="boxmain">
                                        <el-form-item>
                                            <div class="form_item">
                                                <el-tag class="label" color="#E7EEFF">本次起付线</el-tag>
                                                <el-input v-model="bxxxinfo.other_expense" readonly></el-input>
                                            </div>
                                        </el-form-item>
                                        <el-form-item>
                                            <div class="form_item">
                                                <el-tag class="label" color="#E7EEFF">本次进入统筹额度</el-tag>
                                                <el-input v-model="bxxxinfo.bcyyfd" readonly></el-input>
                                            </div>
                                        </el-form-item>
                                        <el-form-item>
                                            <div class="form_item">
                                                <el-tag class="label" color="#E7EEFF">本年进入统筹额度</el-tag>
                                                <el-input v-model="bxxxinfo.bnynrtcfw" readonly></el-input>
                                            </div>
                                        </el-form-item>
                                    </div>
                                    <div class="boxmain">
                                        <el-form-item>
                                            <div class="form_item">
                                                <el-tag class="label" color="#E7EEFF">统筹支付</el-tag>
                                                <el-input v-model="bxxxinfo.tczf" readonly></el-input>
                                            </div>
                                        </el-form-item>
                                        <el-form-item>
                                            <div class="form_item">
                                                <el-tag class="label" color="#E7EEFF">大额支付</el-tag>
                                                <el-input v-model="bxxxinfo.dezf" readonly></el-input>
                                            </div>
                                        </el-form-item>
                                        <el-form-item>
                                            <div class="form_item">
                                                <el-tag class="label" color="#E7EEFF">医疗补助金额</el-tag>
                                                <el-input v-model="bxxxinfo.ylbzje" readonly></el-input>
                                            </div>
                                        </el-form-item>
                                    </div>
                                    <div class="boxmain">
                                        <el-form-item>
                                            <div class="form_item">
                                                <el-tag class="label" color="#E7EEFF">医疗减免金额</el-tag>
                                                <el-input v-model="bxxxinfo.yljmje" readonly></el-input>
                                            </div>
                                        </el-form-item>
                                        <el-form-item>
                                            <div class="form_item">
                                                <el-tag class="label" color="#E7EEFF">其他统筹支付</el-tag>
                                                <el-input v-model="bxxxinfo.qttczf" readonly></el-input>
                                            </div>
                                        </el-form-item>
                                        <el-form-item>
                                            <div class="form_item">
                                                <el-tag class="label" color="#E7EEFF">暂缓(灰名单)支付</el-tag>
                                                <el-input v-model="bxxxinfo.zhzf" readonly></el-input>
                                            </div>
                                        </el-form-item>
                                    </div>

                                    <div class="boxmain"></div>
                                    <el-divider content-position="left">结算信息</el-divider>
                                </div>

                                <div class="boxmain">
                                    <el-form-item>
                                        <div class="form_item">
                                            <el-tag class="label" color="#E7EEFF">金额总计</el-tag>
                                            <el-input v-model="bxxxinfo.total" readonly></el-input>
                                        </div>
                                    </el-form-item>
                                    <el-form-item>
                                        <div class="form_item">
                                            <el-tag class="label" color="#E7EEFF">医保负担金额</el-tag>
                                            <el-input v-model="bxxxinfo.insurance_burden" readonly></el-input>
                                        </div>
                                    </el-form-item>
                                    <el-form-item>
                                        <div class="form_item">
                                            <el-tag class="label" color="#E7EEFF">异地个账支付</el-tag>
                                            <el-input v-model="bxxxinfo.personal_pay_syd" readonly></el-input>
                                        </div>
                                    </el-form-item>
                                </div>
                                <div class="boxmain">
                                    <el-form-item>
                                        <div class="form_item">
                                            <el-tag class="label" color="#E7EEFF">病人负担金额</el-tag>
                                            <el-input v-model="bxxxinfo.patient_burden" readonly></el-input>
                                        </div>
                                    </el-form-item>
                                    <el-form-item>
                                        <div class="form_item">
                                            <el-tag class="label" color="#E7EEFF">共济账户支付</el-tag>
                                            <el-input v-model="bxxxinfo.gjzhzf" type="number" disabled :max="bxxxinfo.family_balance" min="0" @input="gjzhifu()"></el-input>
                                        </div>
                                    </el-form-item>
                                    <el-form-item>
                                        <div class="form_item">
                                            <el-tag class="label" color="#E7EEFF">院内账户支付</el-tag>
                                            <el-input v-model="bxxxinfo.his_deduct_amount" type="number" :max="bxxxinfo.cash_balance" min="0" @input="gjzhifu"></el-input>
                                        </div>
                                    </el-form-item>
                                </div>
                                <div class="boxmain">
                                    <el-form-item>
                                        <div class="form_item">
                                            <el-tag class="label" color="#E7EEFF">医保个账支付</el-tag>
                                            <el-input
                                                v-model="bxxxinfo.grzhzf"
                                                @input="gjzhifu()"
                                                @blur="grzhzfBlur()"
                                                :max="bxxxinfo.personal_balance"
                                                min="0"
                                                type="number"
                                                :disabled="form.insurance_type == 'LONGDISTANCE'"
                                            ></el-input>
                                        </div>
                                    </el-form-item>
                                    <el-form-item>
                                        <div class="form_item">
                                            <el-tag class="label" color="#E7EEFF">待缴费</el-tag>
                                            <el-input v-model="form.djf"></el-input>
                                        </div>
                                    </el-form-item>
                                </div>
                            </div>
                        </el-card>
                        <div style="display: flex">
                            <el-form-item>
                                <div style="display: flex; margin-top: 10px">
                                    <!-- <el-button style="margin-left: 5px" type="success" @click="zhifu('1')"
                                        :disabled="form.djf <= 0">微信</el-button>
                                    <el-button type="primary" @click="zhifu('2')" :disabled="form.djf <= 0">支付宝</el-button>
                                    <el-button style="margin-left: 5px" type="warning" @click="zhifu('3')"
                                        :disabled="form.djf <= 0"> 银行卡</el-button>
                                    <el-button type="info" @click="zhifu('5')" :disabled="form.djf <= 0">现金</el-button> -->
                                    <el-checkbox v-model="gjzhzfje" :disabled="bxxxinfo.gjzhye <= 0" style="margin-left: 50px">共济账户支付</el-checkbox>
                                </div>
                            </el-form-item>
                            <div>
                                <el-button type="primary" @click="qrjsmiss('1')" style="position: absolute; right: 21px; bottom: 8px">确认结算</el-button>

                                <!-- :disabled="sureshow" -->
                            </div>
                        </div>
                    </el-form>
                </div>
            </div>
        </el-dialog>
        <!--
                            TODO: 输入框
                            FIXME: 要修改的东西
                         -->
        <el-dialog title="选择就诊介质" :visible.sync="jeizhishow" width="489px" :close-on-click-modal="false">
            <img :src="logo" style="display: block; margin: 0px auto 0px; width: 100%" alt="logo" />
            <el-form :model="yibaoinfo" :inline="true" @submit.native.prevent v-loading="jiezhiLoading" element-loading-text="结算中...">
                <div style="text-align: center">
                    <el-form-item label="介质类型">
                        <el-radio-group v-model="jiezhi">
                            <el-radio label="A">医保电子凭证</el-radio>
                        </el-radio-group>
                    </el-form-item>
                </div>
                <div style="text-align: center; padding-bottom: 36px">
                    <el-input
                        v-if="jiezhi == 'A'"
                        v-model="pingzhengma"
                        type="text"
                        placeholder="请输入患者卡号"
                        @blur="handleSetFocus()"
                        @keyup.enter.native="cardjiesuan"
                        ref="input"
                        style="width: 300px"
                    ></el-input>
                </div>
            </el-form>
        </el-dialog>
        <Cardlist :cardlist="cardlist" @cardcolsein="cardcolsein" :cardlistdata="patientData.patient_id" />
        <!-- 读卡 -->
        <Readcards :isOpenCarded="carddialogFormVisible" @getyibaoinfo="getyibaoinfo" @closeReadcard="closeReadcard" />
        <!-- 确认结算-新-不选择卡类型 -->
        <ReadcardsNew :isOpenCarded="yibaoshowNew" :patientcard="form" :patientData="patientData" :selectTableArr="selectTableArr" @getyibaoinfo="selectCardYiboPreselect" @close="closeSelectCard" />
        <!-- loaidng 动画 -->
        <div v-if="false" class="grey-cloth" id="loading">
            <div id="img">
                <div class="wrapper">
                    <div class="rect one"></div>
                    <div class="rect two"></div>
                    <div class="rect three"></div>
                    <div class="rect four"></div>
                    <div class="rect five"></div>
                </div>
            </div>
        </div>
        <el-dialog title="提示" :visible.sync="moreshow" width="30%" v-loading="moreLoading">
            <span>请选择诊断</span>
            <el-radio-group v-model="zhenduan">
                <el-radio :label="item.code" v-for="item in moreshowdata.data.mzdbjbs_arr" :key="item.value">{{ item.name }}</el-radio>
            </el-radio-group>
            <span slot="footer" class="dialog-footer">
                <el-button @click="moreshow = false">取 消</el-button>
                <el-button type="primary" @click="selectCardYiboPre(moreshowdata.data, moreshowdata.x, moreshowdata.y, zhenduan)">确 定</el-button>
            </span>
        </el-dialog>
    </div>
</template>
<script>
import Cardlist from '@/components/SFCCardlist'
import Readcards from '@/components/ReadcardsSFC'
import editProp1 from './components/editProp' //修改自付比例
import { pdxx, mzxx, mzxxs, mzxxs_ewm, settle_fee_self2yb, settle_fee2yb, bxxx, jsxx, hiscard, printmis, queryReadRard } from '@/api/mzSFC'
import { get_serial_number, editProp, zfbl, freemoney, familybalanceinfor, settlementPre, patient, settleSelfPre, selfPre, yundaMis, familyBalance, get_zfbl } from '@/api/jiesuanSFC'
import printProof from '../../utils/print_proofZF'
import getLodop from '../../assets/js/LodopFuncs'
import SelectCard from '@/components/SelectCardSFC'
import ReadcardsNew from '@/components/ReadcardsNewSFC'
export default {
    components: {
        Cardlist,
        Readcards,
        editProp1,
        SelectCard,
        ReadcardsNew,
    },
    name: 'Outpatient',
    data() {
        return {
            checked: false,
            moreLoading: false,
            moreshowdata: {
                data: {},
            },
            zhenduan: '',
            moreshow: false,
            familyType: '',
            oldewmpingzheng: '',
            ztvalue: '',
            cardNo: '', // 卡号
            cardType: '', // 卡类型
            patientData: {},
            tableDataList: [],
            only_qq: 0,
            misInfor: '',
            yujiesuanload: false,
            sureshow: false,
            adminloading: false,
            options: [
                {
                    value: '0',
                    label: '门诊统筹',
                },
                {
                    value: '1',
                    label: '普通医保',
                },
            ],
            channels: '',
            man_name: '0',
            card_typeinfor: '',
            sdsdzjkk: '',
            infor: [],
            seemodel: '',
            jiezhiLoading: false,
            gjzhzfje: false,
            yibaoka: '',
            shenfenzheng: '',
            resorderID: '',
            src: require('@/assets/images/1.png'),
            typelistno: '',
            freedetal: [],
            yibaoshow: false,
            yibaoshowNew: false,
            cardlist: false,
            fee: {
                weixin: '',
                zhifubao: '',
            },
            feelist: {
                channel: '',
            },
            uploadfeeshow: false,
            ceshiID: '',
            patientCard: {},
            jiuzhencard: '',
            adminpingzhengma: '',
            fullscreenLoading: false,
            jiezhi: 'A',
            pingzhengma: '',
            jeizhishow: false,
            input: '',
            tylist: [],
            select_type: '',
            settle_type: [],
            costlist: [],
            loadingapplyList: false,
            cost_id: [],
            tempsrc: require('@/assets/images/暂无记录.png'),
            logo: require('@/assets/logo/CardReader.gif'),
            loading: false,
            loading2: false,
            yibaoinfo: {
                sfzhm: '',
                idcard: '',
                cardtype: '',
                cardno: '',
                channel: 'local',
            },
            bxxxinfo: {
                djf: 0,
                zhye: 0,
                brxm: '',
                brxb: '',
                ynzhye: '',
                ybzhye: '',
                gjzhye: 0,
                jezj: '',
                ydgzzf: '',
                ybfdje: '',
                brfdje: '',
                gjzhzf: 0,
                gzzf: '',
                ynzhzf: '',
                xjzf: '',
            },
            carddialogFormVisible: false,
            form: {
                djf: '',
                admin_djf: '',
                ybkh: '',
                sfzh: '',
                jbjg: '',
                dwmc: '',
                djf: 0,
                zhye: '',
                brxm: '',
                brxb: '',
                ynzhye: '',
                ybzhye: '',
                gjzhye: '',
                jezj: '',
                ydgzzf: '',
                ybfdje: '',
                brfdje: '',
                gzzf: '',
                ynzhzf: '',
                xjzf: '',
            },
            dialogVisible: false,
            patientInfo: {
                channel: '',
                yblx: '',
                name: '',
                patient_id: '',
                id: '',
                sign: [],
            },
            total: '0.00',
            tableData2: [],
            tableData: {
                cost: [],
                costs: [],
                patient: { p_xm: '', id: '' },
            },
            activeName: 'first',
            type: '1',
            typeList: [],
            orders: [],
            param: { grbh: '410702198703301023', p_xzbz: 'C', yltclb: '0', channel: 'local', card_type: '' },
            ckh: '',
            wj: '',
            ws: '',
            misdata: {},
            tuiconst: 0,
            personType: '', //人员列表
            personTypeArr: [
                {
                    name: '自费',
                    value: '1',
                },
                {
                    name: '普通医保',
                    value: '2',
                },
                {
                    name: '慢性病',
                    value: '8',
                },
                {
                    name: '门诊统筹',
                    value: '10',
                },
            ], //
            showEditProp: false, //详情蒙层
            currentData: {}, //当前选中行数据-右侧
            ybewmsfid: '',
            misdataYB: {},
            titleshow: '',
            selectTableArr: [],
            cardNoShow: false,
        }
    },
    mounted() {
        this.socketInit()
    },
    created() {
        this.titleshow = this.$route.query?.layoutShow || ''
        this.cardNo = this.$route.query?.cardNo || ''
        this.cardType = this.$route.query?.cardType || ''

        this.cardNoShow = this.$route.query?.cardNo || false
        if (!window.WebSocket) {
            alert('该版本浏览器不支持WebSocket')
        } else {
            console.log('支持websocket')
        }
        if (this.cardNo) {
            // this.szyb()
            // this.getWaiting()
            this.selectCardYiboInfo()
        }
    },
    watch: {
        gjzhzfje: {
            handler: function (nv, ov) {
                if (nv) {
                    this.getFamilyBalance()
                }
            },
            immediate: true,
            deep: true,
        },
    },
    methods: {
        // 当不关闭刷卡弹窗的时候需要对input框失去焦点的时候继续聚焦
        handleSetFocus() {
            this.$nextTick(() => {
                this.$refs.cardInput.focus()
            })
        },
        //根据条件每行变色
        styleBack({ row, column, rowIndex, columnIndex }) {
            if (row.many == '1') {
                return { backgroundColor: '#ffb700' }
            }
        },
        //保存按钮方法
        savebtn(e) {
            this.resave(e.settle_fee_id, e.zfbl)
            this.seemodel = ''
        },
        //保存显示按钮
        savefocus(e) {
            this.seemodel = e.id
        },
        //保存自付比例
        resave(e, x) {
            editProp({
                // is_zy: '0',
                // his_patient_id: this.tableData.patient.id,
                // column: 'sxzfbl',
                new_patient_ratio: x * 1,
                settle_fee_id: e,
                // med_cost_id: e,
            })
                .then(response => {
                    this.$message({
                        message: '保存成功',
                        type: 'success',
                    })
                })
                .catch(() => {
                    this.$message({
                        message: '保存失败',
                        type: 'error',
                    })
                })
                .finally(() => {
                    this.loading = false
                })
        },
        resave_pation(x) {
            editProp({
                is_zy: '0',
                his_patient_id: this.tableData.patient.id,
                column: 'his_patient_type',
                // value: String(x),
                value: '1', //医保改自费
                his_pay_fee_no: this.cost_id,
            })
                .then(response => {
                    this.$message({
                        message: '保存成功',
                        type: 'success',
                    })
                    this.getWaiting('1')
                })
                .catch(() => {
                    this.$message({
                        message: '保存失败',
                        type: 'error',
                    })
                })
                .finally(() => {
                    this.loading = false
                })
        },
        //轮巡匹配自付比例
        Match() {
            if (this.patientCard.rqlb != 'A' && this.patientCard.rqlb != 'B') {
                this.$message.error('该患者未登记人群类别，请先进行登记！')
                return false
            }
            this.costlist.forEach(element => {
                zfbl({
                    is_self: this.patientInfo.yblx == '自费' ? '1' : '0',
                    yyxmbm: element.yyxmbm,
                    rqlb: this.patientCard.rqlb,
                    id: element.id,
                    fyfssj: element.fysfsj,
                    channel: this.patientCard.channel,
                })
                    .then(response => {
                        if (response.data.length == 1) {
                            element.sxzfbl = response.data[0].zfbl
                        }
                        if (response.data.length > 1) {
                            element.many = '1'
                            var min = response.data[0].zfbl
                            for (let i = 0; i < response.data.length; i++) {
                                if (min > response.data[i].zfbl) {
                                    min = response.data[i].zfbl
                                }
                            }
                            element.sxzfbl = min
                        }
                        this.resave(element.id, element.sxzfbl)
                    })

                    .finally(() => {
                        this.loading = false
                    })
            })
        },
        //当共济支付开关打开时，其他额度根据共济变动
        gjzhifu(e) {
            this.$forceUpdate()
            // let djsold = this.round(this.bxxxinfo.brfdje * 1 - this.bxxxinfo.grzhzf * 1, 2)
            // this.form.djf = this.round(this.round(djsold * 1 - this.bxxxinfo.his_deduct_amount * 1, 2) - this.bxxxinfo.gjzhzf * 1, 2)
            this.form.djf = this.round(this.round(this.round(this.bxxxinfo.patient_burden - this.bxxxinfo.gjzhzf, 2) - this.bxxxinfo.his_deduct_amount, 2) - this.bxxxinfo.grzhzf, 2)
        },
        //医保个人账户支付输入值blur
        grzhzfBlur() {
            if (this.bxxxinfo.grzhzf * 1 > this.bxxxinfo.zhye * 1) {
                //医保个账支付输入值 不能 大于 医保账户余额
                this.$message({
                    message: '医保个账支付金额不能大于医保账户余额',
                    type: 'warning',
                })
                this.bxxxinfo.grzhzf = 0
                this.gjzhifu()
                return false
            }
        },
        // 当不关闭刷卡弹窗的时候需要对input框失去焦点的时候继续聚焦
        handleSetFocusWX() {
            this.$nextTick(() => {
                this.$refs.inputWX.focus()
            })
        },
        // 当不关闭刷卡弹窗的时候需要对input框失去焦点的时候继续聚焦
        handleSetFocusXJ() {
            this.$nextTick(() => {
                this.$refs.inputxj.focus()
            })
        },
        // 当不关闭刷卡弹窗的时候需要对input框失去焦点的时候继续聚焦
        handleSetFocusZFB() {
            this.$nextTick(() => {
                this.$refs.inputZFB.focus()
            })
        },
        //读卡器方法
        socketInit() {
            this.wj = new WebSocket('ws://127.0.0.1:6932/')
            this.wj.onopen = function () {}
            this.wj.onmessage = this.onmessagecard
            this.wj.onclose = function () {}
        },
        //退款结果
        reimResult(evt) {
            const ret = JSON.parse(evt.data)
            if (ret && ret.TrandeCode == '00') {
                this.$message({
                    message: ret.TrandeMsg,
                    type: 'success',
                })
            } else {
                this.$message({
                    message: ret.TrandeMsg,
                    type: 'error',
                })
                //关闭弹窗
                this.fullscreenLoading = false
                this.dialogVisible = false
                this.sureshow = false
                this.loadingapplyList = false
                this.jeizhishow = false
                this.jiezhiLoading = false
            }
        },
        //结算历史关闭
        cardcolsein() {
            this.cardlist = false
        },
        //刷卡界面关闭
        closeReadcard() {
            this.carddialogFormVisible = false
        },
        //首次进页面第一次刷卡返回的信息
        getyibaoinfo(e, x) {
            this.only_qq = 0
            //第一次读二维码不需要from_web
            if (x) {
                this.card_typeinfor = x
                let param = {
                    p_ewm: x.value,
                }
                mzxxs_ewm(param)
                    .then(response => {
                        this.ybewmsfid = response.data.sfzhm
                        this.cardNo = response.data.sfzhm
                        this.cardType = 'ID_CARD'
                        this.selectCardYiboInfo()
                        //       let xxx = {
                        //           card_no: response.data.sfzhm,
                        //           card_type: 'ID_CARD',
                        //       }
                        //       hiscard(xxx)
                        //           .then(response => {
                        //               this.carddialogFormVisible = false
                        //               this.dialogFormVisible = false
                        //               this.patientInfo = response.data
                        //               this.form.brxm = response.data.name
                        //               this.getpdxx(this.patientInfo)
                        //           })
                        //           .finally(() => {
                        //               this.carddialogFormVisible = false
                        //               this.dialogFormVisible = false
                        //               this.loading = false
                        //           })
                    })
                    .finally(res => {
                        this.carddialogFormVisible = false
                        this.dialogFormVisible = false
                    })
            } else {
                this.carddialogFormVisible = false
                this.cardNo = e.physicalCard
                this.cardType = e.physicalCardType
                // this.getmzxxs(e)
                if (e.physicalCardType == 'SOCIAL_CARD') {
                    this.selectCardYiboInfo(e)
                } else {
                    this.selectCardYiboInfo()
                }
            }
        },
        // 结算历史展示
        jshistory() {
            this.cardlist = true
        },
        //微信支付宝银行卡现金充值接口
        feesure(e) {
            this.fullscreenLoading = true
            if (e == '1') {
                // return false
                freemoney({
                    payment_type: 'WX_BAR',
                    amount: this.form.djf,
                    auth_code: this.fee.weixin,
                    his_patient_id: this.tableData.patient.id,
                    patient_type: 'mz',
                    settlement_no: this.bxxxinfo.settlement_no,
                })
                    .then(response => {
                        this.$message({
                            message: response.message,
                            type: 'success',
                        })
                        if (this.bxxxinfo.brfdje * 1 > response.data.his_balance * 1) {
                            this.bxxxinfo.his_deduct_amount = response.data.his_balance * 1
                        } else {
                            this.bxxxinfo.his_deduct_amount = this.bxxxinfo.brfdje * 1
                        }
                        // let balancenew = response.data.his_balance * 1
                        // this.bxxxinfo.his_deduct_amount = this.bxxxinfo.his_deduct_amount * 1 + (balancenew * 100 - this.bxxxinfo.his_balance * 100) / 100
                        //接口返回新的院内账户余额
                        this.bxxxinfo.his_balance = response.data.his_balance * 1
                        let djsold = this.round(this.bxxxinfo.brfdje - this.bxxxinfo.grzhzf, 2)
                        //充值成功后的代缴费金额
                        this.form.djf = this.round(this.round(djsold - this.bxxxinfo.his_deduct_amount, 2) - this.bxxxinfo.gjzhzf, 2)

                        //微信支付宝弹窗
                        this.uploadfeeshow = false
                        // 总的大弹窗
                        this.fullscreenLoading = false
                        //结算
                        // this.qrjs()
                        this.qrjsmiss('1')
                    })
                    .finally(() => {
                        this.fee.weixin = ''
                        //微信支付宝弹窗
                        this.uploadfeeshow = false
                        // 总的大弹窗
                        this.fullscreenLoading = false
                    })
            }

            if (e == '5') {
                freemoney({
                    payment_type: 'CASH',
                    amount: this.form.admin_djf,
                    auth_code: 'not',
                    his_patient_id: this.tableData.patient.id,
                    patient_type: 'mz',
                    settlement_no: this.bxxxinfo.settlement_no,
                })
                    .then(response => {
                        this.$message({
                            message: response.message,
                            type: 'success',
                        })
                        if (this.bxxxinfo.brfdje * 1 > response.data.his_balance * 1) {
                            this.bxxxinfo.his_deduct_amount = response.data.his_balance * 1
                        } else {
                            this.bxxxinfo.his_deduct_amount = this.bxxxinfo.brfdje * 1
                        }
                        // let balancenew = response.data.his_balance * 1
                        // this.bxxxinfo.his_deduct_amount = this.bxxxinfo.his_deduct_amount * 1 + this.round(balancenew - this.bxxxinfo.his_balance * 1, 2)
                        this.bxxxinfo.his_balance = response.data.his_balance * 1
                        let djsold = this.round(this.bxxxinfo.brfdje - this.bxxxinfo.grzhzf, 2)
                        this.form.djf = this.round(this.round(djsold - this.bxxxinfo.his_deduct_amount, 2) - this.bxxxinfo.gjzhzf, 2)
                        // this.qrjs()
                        this.qrjsmiss('1')
                        //微信支付宝弹窗
                        this.uploadfeeshow = false
                        // 总的大弹窗
                        this.fullscreenLoading = false
                    })
                    .finally(() => {
                        //微信支付宝弹窗
                        this.uploadfeeshow = false
                        // 总的大弹窗
                        this.fullscreenLoading = false
                    })
            }
            if (this.feelist.channel == '3') {
                this.get_serial_number('3')
            }
        },
        //银行卡mis交易、获取参考号
        get_serial_number(e) {
            get_serial_number({
                type: 'MIS',
            })
                .then(response => {
                    const _this = this
                    // var wsImpl = window.WebSocket || window.MozWebSocket
                    // _this.ws = new wsImpl('ws://127.0.0.1:50000/')
                    var input = this.form.djf
                    let x =
                        'Trans&00|00|' +
                        input +
                        '|||||{"patientInfo":{"patientId":"' +
                        this.patientCard.patientId +
                        '","patientName":"' +
                        this.patientCard.name +
                        '","cardNo":"' +
                        this.patientCard.idCard +
                        '","accountType":"01","visitId":"","ywlx":"SUCCESS","transType":"bank","cardType":"01","source":"窗口门诊银行卡充值","operatorId":"' +
                        localStorage.getItem('userbh') +
                        '","operatorName":"' +
                        localStorage.getItem('usernames') +
                        '","orderId":"' +
                        response.data.value +
                        '","id_card_no":"' +
                        this.patientCard.idCard +
                        '"}}'
                    get_serial_number({
                        type: 'MIS',
                        value: x,
                        valtp: 'mz_ylmiss',
                    }).then(response => {})
                    this.resorderID = response.data.value
                    // if (_this.ws.readyState === _this.ws.OPEN) {
                    //     _this.ws.send(x)
                    // }
                    // // 若是 正在开启状态，则等待300毫秒
                    // else if (_this.ws.readyState === _this.ws.CONNECTING) {
                    //     setTimeout(function () {
                    //         _this.ws.send(x)
                    //     }, 1000)
                    // }
                    // // 若未开启 ，则等待500毫秒
                    // else {
                    //     setTimeout(function () {
                    //         _this.ws.send(x)
                    //     }, 1000)
                    // }
                    var wsImpl = window.WebSocket || window.MozWebSocket
                    _this.ws = new wsImpl('ws://127.0.0.1:50000/')
                    _this.ws.onopen = function () {
                        _this.ws.send(x)
                    }
                    _this.ws.onmessage = this.BanksetOnmessageMessage
                    _this.ws.onclose = function () {}
                })
                .finally(() => {
                    this.uploadfeeshow = false
                })
        },
        //银行卡返回方法
        BanksetOnmessageMessage(evt) {
            const ret = JSON.parse(evt.data)
            if (ret && ret.TrandeCode == '00') {
                this.$message({
                    message: ret.TrandeMsg,
                    type: 'success',
                })
                this.misdata = ret
                this.ckh = ret.TradeRef
                freemoney({
                    bank_card: ret.BankNo,
                    payment_type: 'MIS_BANK',
                    amount: this.form.djf,
                    auth_code: 'null',
                    his_patient_id: this.tableData.patient.id,
                    patient_type: 'mz',
                    mis_no: this.resorderID,
                    mis_rs_no: ret.TradeRef,
                    mis_flow_no: ret.TraceNo,
                    settlement_no: this.bxxxinfo.settlement_no,
                })
                    .then(response => {
                        this.$message({
                            message: response.message,
                            type: 'success',
                        })
                        this.loadingapplyList = false
                        this.sureshow = false
                        this.jeizhishow = false
                        this.fullscreenLoading = false
                        this.jiezhiLoading = false
                        if (this.bxxxinfo.brfdje * 1 > response.data.his_balance * 1) {
                            this.bxxxinfo.his_deduct_amount = response.data.his_balance * 1
                        } else {
                            this.bxxxinfo.his_deduct_amount = this.bxxxinfo.brfdje * 1
                        }
                        this.bxxxinfo.his_balance = response.data.his_balance * 1
                        let djsold = this.round(this.bxxxinfo.brfdje - this.bxxxinfo.grzhzf, 2)
                        this.form.djf = this.round(this.round(djsold - this.bxxxinfo.his_deduct_amount, 2) - this.bxxxinfo.gjzhzf, 2)
                        this.fullscreenLoading = false
                        this.yibaoshow = false
                        this.qrjsmiss('1')
                    })
                    .finally(res => {
                        this.uploadfeeshow = false
                    })
            } else {
                this.$message({
                    message: ret.TrandeMsg,
                    type: 'error',
                })
                this.fullscreenLoading = false
                this.dialogVisible = false
                this.sureshow = false
            }
        },
        //本地刷医保卡和电子医保凭证方法
        cardjiesuan() {
            this.jeizhishow = false
            this.qrjs('1')
        },
        //医保卡返回方法
        YBKsetOnmessageMessage(evt) {
            const ret = JSON.parse(evt.data)
            if (ret && ret.TrandeCode == '00') {
                this.$message({
                    message: ret.TrandeMsg,
                    type: 'success',
                })
                this.ckh = ret.TradeRef
                this.misdataYB = ret
                this.qrjs(ret)
                this.fullscreenLoading = false
                this.jeizhishow = false
            } else {
                this.$message({
                    message: ret.TrandeMsg,
                    type: 'error',
                })
                this.fullscreenLoading = false
                this.dialogVisible = false
                this.sureshow = false
                this.jeizhishow = false
            }
        },
        //选中左边处方，展示右边方法
        seletei(e) {
            let searchByFind = this.tableData.cost.filter(item => item.settle_type.name === e)
            let arr = []
            for (let index = 0; index < searchByFind.length; index++) {
                if (searchByFind[index].settle_type.name == e) {
                    arr.push(searchByFind[index])
                }
            }
            this.tableDataList = arr
            this.typeList.forEach(element => {
                if (element.settle_type.name == e) {
                    this.typelistno = element.settle_type.value
                    this.ztvalue = element.settle_type
                }
            })
        },
        //点击支付弹窗并且进页面聚焦输入框
        zhifu(e) {
            const that = this
            setTimeout(function () {
                that.handleSetFocusWX()
                that.handleSetFocusZFB()
                that.handleSetFocusXJ()
            }, 300)

            that.feelist.channel = e
            that.uploadfeeshow = true
        },
        //刷卡回调方法
        onmessagecard(evt) {
            let res = JSON.parse(evt.data)
            // 赋值调接口
            if (res.MethodName == 'ReadIDCard' && res.RespCode == 0) {
                // 身份证读取
                this.yibaoinfo.cardno = res.RespData.CardId
                this.getmzxx('1')
                this.closedevice()
            } else if (res.MethodName == 'ReadSSSECard' && res.RespCode == 0) {
                // 社保卡读取
                if (this.yibaoinfo.channel == 'offsite') {
                    this.yibaoinfo.cardno = res.RespData.sfzh
                } else {
                    this.yibaoinfo.idcard = res.RespData.CardNo
                }
                this.yibaoinfo.xm = res.RespData.xm
                this.yibaoinfo.p_sbm = res.RespData.ksbm
                this.yibaoinfo.sfzhm = res.RespData.sfzh
                this.getmzxx('2')
                this.closedevice()
            } else {
                return false
            }
        },
        // 关闭设备
        closedevice() {
            this.wj.send('{ "MethodName": "CloseDevice" }')
        },
        //刷卡后获取患者信息
        getmzxx(e) {
            if (e == '1') {
                if (this.shenfenzheng != '') {
                    this.yibaoinfo.cardno = this.shenfenzheng
                }
                this.param = {
                    grbh: this.yibaoinfo.cardno,
                    p_xzbz: this.typelistno == '4' ? 'D' : 'C',
                    yltclb: '0',
                    channel: this.patientInfo.channel,
                    card_type: this.yibaoinfo.cardtype,
                    from_web: '1',
                }
                mzxx(this.param)
                    .then(response => {
                        this.yibaoshow = false
                        this.loading = false
                        this.patientInfo = response.data
                        this.form.sfzh = response.data.grbh
                        this.form.dwmc = response.data.cbjgmc
                        this.form.ybkh = response.data.ybbh
                        this.form.brxm = response.data.xm
                        this.form.brxb = response.data.xb == '2' ? '女' : '男'
                        this.jiesuanadmin(this.patientInfo.cache_uuid)
                    })
                    .catch(e => {
                        this.loading = false
                    })
            }
            if (e == '2' && this.yibaoinfo.channel == 'offsite') {
                // if (this.shenfenzheng != '') {
                //     this.yibaoinfo.cardno = this.yibaoka
                // }
                this.param = {
                    grbh: this.yibaoinfo.cardno,
                    p_xzbz: this.typelistno == '4' ? 'D' : 'C',
                    yltclb: '0',
                    channel: this.patientInfo.channel,
                    card_type: '02',
                    from_web: '1',
                }
                mzxx(this.param)
                    .then(response => {
                        this.yibaoshow = false
                        this.patientInfo = response.data
                        this.form.sfzh = response.data.grbh
                        this.form.brxm = response.data.xm
                        this.form.dwmc = response.data.cbjgmc
                        this.form.ybkh = response.data.ybbh
                        this.form.brxb = response.data.xb == '2' ? '女' : '男'
                        this.tableData.patient.rqlb = response.data.rqlb

                        this.jiesuanadmin(this.patientInfo.cache_uuid)
                    })
                    .finally(() => {
                        this.dialogFormVisible = false
                    })
            }
            //不是跨省异地的身份证
            if (e == '2' && this.yibaoinfo.channel != 'offsite') {
                // if (this.shenfenzheng != '') {
                //     this.yibaoinfo.idcard = this.yibaoka
                // }
                this.param = {
                    p_xm: this.yibaoinfo.xm,
                    p_sbm: this.yibaoinfo.p_sbm,
                    p_gfbb: '03',
                    p_shbzhm: this.yibaoinfo.sfzhm,
                    p_kh: this.yibaoinfo.idcard,
                    channel: this.patientInfo.channel,
                    p_dzpzywm: '301',
                    card_type: this.yibaoinfo.cardtype,
                    from_web: '1',
                }
                mzxxs(this.param)
                    .then(response => {
                        this.yibaoshow = false
                        this.patientInfo = response.data
                        this.form.sfzh = response.data.grbh
                        this.form.brxm = response.data.xm
                        this.form.brxb = response.data.xb == '2' ? '女' : '男'
                        this.form.dwmc = response.data.cbjgmc
                        this.form.ybkh = response.data.ybbh
                        this.tableData.patient.rqlb = response.data.rqlb

                        this.jiesuanadmin(this.patientInfo.cache_uuid)
                    })
                    .finally(() => {
                        this.dialogFormVisible = false
                    })
            }
            //第二次读医保二维码
            if (e == '3') {
                this.param = {
                    p_ewm: this.adminpingzhengma,
                    p_dzpzywm: '301',
                    channel: this.patientInfo.channel,
                    card_type: '01',
                    from_web: '1',
                }
                mzxxs(this.param)
                    .then(response => {
                        this.yibaoshow = false
                        this.patientInfo = response.data
                        this.form.sfzh = response.data.grbh
                        this.form.brxm = response.data.xm
                        this.form.brxb = response.data.xb == '2' ? '女' : '男'
                        this.form.dwmc = response.data.cbjgmc
                        this.form.ybkh = response.data.ybbh
                        this.jiesuanadmin(this.patientInfo.cache_uuid)
                    })
                    .finally(() => {
                        this.loading = false
                    })
            }
            //就诊卡
            if (e == '4') {
                this.param = {
                    card_no: this.jiuzhencard,
                    card_type: 'HOSPITAL_CARD',
                }
                hiscard(this.param)
                    .then(response => {
                        this.param = {
                            grbh: response.data.idCard,
                            p_xzbz: this.typelistno == '4' ? 'D' : 'C',
                            yltclb: '0',
                            channel: this.patientInfo.channel,
                            card_type: this.yibaoinfo.cardtype,
                            from_web: '1',
                        }
                        mzxx(this.param)
                            .then(response => {
                                this.yibaoshow = false
                                this.patientInfo = response.data
                                this.form.sfzh = response.data.grbh
                                this.form.brxm = response.data.xm
                                this.form.brxb = response.data.xb == '2' ? '女' : '男'
                                this.form.dwmc = response.data.cbjgmc
                                this.form.ybkh = response.data.ybbh
                                this.jiesuanadmin(this.patientInfo.cache_uuid)
                            })
                            .finally(() => {
                                this.loading = false
                            })
                    })
                    .finally(() => {
                        this.loading = false
                    })
            }
            //电子健康卡
            if (e == '5') {
                this.param = {
                    card_no: this.jiuzhencard.toString().substring(0, 64),
                    card_type: 'ELECTRONIC_HEALTH_CARD',
                }
                hiscard(this.param)
                    .then(response => {
                        this.param = {
                            grbh: response.data.idCard,
                            p_xzbz: this.typelistno == '4' ? 'D' : 'C',
                            yltclb: '0',
                            channel: this.patientInfo.channel,
                            card_type: this.yibaoinfo.cardtype,
                            from_web: '1',
                        }
                        mzxx(this.param)
                            .then(response => {
                                this.patientInfo = response.data
                                this.form.sfzh = response.data.grbh
                                this.form.brxm = response.data.xm
                                this.form.brxb = response.data.xb == '2' ? '女' : '男'
                                this.form.dwmc = response.data.cbjgmc
                                this.form.ybkh = response.data.ybbh
                                this.jiesuanadmin(this.patientInfo.cache_uuid)
                            })
                            .finally(() => {
                                this.loading = false
                            })
                    })
                    .finally(() => {
                        this.loading = false
                    })
            }
        },
        //首次获取患者基本信息
        getmzxxs(e) {
            this.card_typeinfor = e
            this.param = {
                name: e.xm,
                idcard: e.sfzhm,
                card_no: e.physicalCard,
                card_type: e.physicalCardType,
            }
            hiscard(this.param)
                .then(response => {
                    this.patientInfo = response.data
                    this.form.brxm = response.data.name
                    this.getpdxx(this.patientInfo)
                })
                .finally(() => {
                    this.loading = false
                })
        },

        tiles(e) {
            let sele_one = []
            let result = []
            let res = []
            let manres = []
            let obj = {}
            let objs = {}
            for (let i = 0; i < e.length; i++) {
                if (!obj[e[i].settle_type.value] && e[i].settle_type.value != 8) {
                    result.push(e[i])
                    obj[e[i].settle_type.value] = true
                }
                if (e[i].settle_type.value == 8) {
                    res.push(e[i])
                }
            }
            for (let i = 0; i < res.length; i++) {
                if (!objs[res[i].disease_code]) {
                    res[i].settle_type.man = res[i].disease_code
                    result.push(res[i])
                    objs[res[i].disease_code] = true
                }
            }
            this.typeList = result
            this.patientInfo.yblx = this.typeList[0] ? this.typeList[0].settle_type.name : ''
            sele_one.push(e[0])
            this.setPersonType(this.typeList[0] ? this.typeList[0].settle_type.value : '')
            this.seletei(this.typeList[0] ? this.typeList[0].settle_type.name : '')
        },

        getpdxx(e) {
            this.loading = true
            pdxx({
                id: e.med_id,
            })
                .then(response => {
                    this.tableData.patient.p_xm = response.data.name
                    this.tableData.patient.id = response.data.patientId
                    this.tableData.patient.idCard = response.data.idCard
                    this.patientCard = response.data
                    this.ybewmsfid = response.data.idCard
                    this.getWaiting()
                    // this.tableData = response.data
                })
                .finally(() => {
                    this.loading = false
                })
        },
        //调取待结算清单
        getWaiting(e) {
            var that = this
            var obj = {
                patient_id: this.patientData.patient_id, //this.cardNo,
                // zfbl: 'auto',
                // rqlb: this.patientCard.rqlb,
                // channel: this.patientCard.channel,
            }
            // if (e) {
            //     obj.refresh = '1'
            // }
            settle_fee_self2yb(obj)
                .then(response => {
                    this.tableData.cost = response.data
                    this.tableDataList = response.data
                    this.tylist = response.data
                    this.tiles(this.tylist)

                    this.setPersonType() //结算类型赋默认值
                })
                .finally(() => {
                    this.loading = false
                })
        },
        jiesuan() {
            this.shenfenzheng = this.tableData.patient.idCard
            this.adminpingzhengma = ''
            this.bxxxinfo = {}
            for (let index = 0; index < this.selectTableArr.length; index++) {
                const element = this.selectTableArr[index].clinic_no
                if (element != this.selectTableArr[0].clinic_no) {
                    this.$message.error('就诊号不同，不允许同时结算！')
                    return false
                }
            }
            if (this.orders.length > 0) {
                this.ybjs()
            } else {
                this.$message.error('请勾选结算类型和待结算的费用清单')
                this.yujiesuanload = false
            }
        },

        cardtype(type) {
            this.tableDataList = []
            this.patientData = {}
            this.costlist = []
            this.yibaoinfo.cardtype = type
            this.carddialogFormVisible = true
        },
        ybjs() {
            if (this.checktipes()) {
                // this.yibaoshow = true
                this.yibaoshowNew = true
                this.yujiesuanload = false
            } else {
                // this.jiesuanadmin()
                this.zfBeforePre()
            }
        },
        checktipes() {
            //自费
            if (this.patientInfo.yblx == '自费') {
                return false
            }
            // //离休
            // if (this.typelistno == '9') {
            //     return false
            // }
            // //伤残
            // if (this.typelistno == '7') {
            //     return false
            // }
            return true
        },
        round(num, decimals) {
            const factor = Math.pow(10, decimals)
            return Math.round(num * factor) / factor
        },
        //#####################预结算###################
        jiesuanadmin(e) {
            this.yujiesuanload = false
            bxxx({
                is_yb: this.man_name,
                cache_uuid: e == undefined ? 'not' : e,
                his_pay_fee_nos: this.cost_id,
                patient_id: this.tableData.patient.id,
                p_xzbz: this.typelistno == '4' ? 'D' : 'C',
                is_pre: 1,
                pre_id: '1',
                p_ewm: this.adminpingzhengma,
            })
                .then(response => {
                    this.dialogVisible = true
                    this.yujiesuanload = false
                    this.bxxxinfo = response.data
                    let frees = this.round(this.bxxxinfo.brfdje * 1 - this.bxxxinfo.his_deduct_amount * 1, 2)
                    let djf = this.round(this.round(frees - this.bxxxinfo.grzhzf * 1, 2) - this.bxxxinfo.gjzhzf * 1, 2)
                    if (this.bxxxinfo.personal_balance > djf) {
                        this.bxxxinfo.grzhzf = djf
                    }
                    if (this.bxxxinfo.personal_balance < djf) {
                        this.bxxxinfo.grzhzf = this.bxxxinfo.personal_balance
                    }
                    let free = this.round(this.bxxxinfo.brfdje * 1 - this.bxxxinfo.his_deduct_amount * 1, 2)
                    this.form.djf = this.round(this.round(free - this.bxxxinfo.grzhzf * 1, 2) - this.bxxxinfo.gjzhzf * 1, 2)
                })
                .finally(() => {})
        },
        //确认结算判断是否东营本地弹窗
        qrjsmiss(e) {
            if (this.typelistno == 'UNKNOWN') {
                this.$message({
                    message: '请到15号医保审核窗口，审核后缴费！',
                    type: 'error',
                })
            }
            this.sureshow = true
            if (this.form.djf > 0) {
                this.$message({
                    message: '待缴费不为0，请先充值缴费',
                    type: 'warning',
                })
                this.sureshow = false
                return false
            }
            if (this.select_type == '01') {
                if (this.form.insurance_type == 'LOCAL') {
                    this.pingzhengma = ''
                    this.jeizhishow = true
                } else {
                    this.qrjs()
                }
                // this.jeizhishow = true
                // this.yibaoshowNew=true
            } else if (this.ztvalue.value == 'SELF_PAY') {
                this.selfPre()
            } else {
                this.qrjs()
            }
        },
        szyb() {
            let x = {}
            yundaMis(x)
                .then(res => {})
                .catch(err => {})
        },
        //结算按钮预结算按钮
        queren() {
            if (this.yibaoinfo.cardtype == '02') {
                // TODO: 输入框
                // FIXME: 要修改的东西ASDASDAS
                //读身份证
                if (this.shenfenzheng != '') {
                    this.getmzxx('1')
                } else {
                    this.wj.send('{ "MethodName": "OpenDevice" }')
                    this.wj.send('{ "MethodName": "ReadIDCard"}')
                }
                //没卡就手写传卡号
            } else if (this.yibaoinfo.cardtype == '03') {
                //读医保卡
                this.wj.send('{ "MethodName": "OpenDevice" }')
                this.wj.send('{ "MethodName": "ReadSSSECard" }')
                // TODO:
                // FIXME: 要修改的东西ASDASDAS
                //电子医保凭证
            } else if (this.yibaoinfo.cardtype == '01') {
                this.getmzxx('3')
            } else if (this.yibaoinfo.cardtype == '00') {
                //就诊卡
                this.getmzxx('4')
            } else if (this.yibaoinfo.cardtype == '04') {
                //就健康卡
                this.getmzxx('5')
            }
            this.carddialogFormVisible = false
        },
        // 复制文本内容方法一
        copy(content) {
            var copyCon = document.getElementById('IDcard').innerHTML
            // 复制结果
            let copyResult = true
            // 设置想要复制的文本内容
            const text = copyCon
            // 判断是否支持clipboard方式
            if (!!window.navigator.clipboard) {
                // 利用clipboard将文本写入剪贴板（这是一个异步promise）
                window.navigator.clipboard
                    .writeText(text)
                    .then(res => {
                        this.$message({
                            message: '复制成功！',
                            type: 'success',
                        })
                        // 返回复制操作的最终结果
                        return copyResult
                    })
                    .catch(err => {
                        // clipboard方式复制失败 则采用document.execCommand()方式进行尝试
                        copyContent2(text)
                    })
            } else {
                // 不支持clipboard方式 则采用document.execCommand()方式
                copyContent2(text)
            }
        },
        // 复制文本内容方法二
        copyContent2(content) {
            // 复制结果
            let copyResult = true
            // 创建一个input元素
            let inputDom = document.createElement('textarea')
            // 设置为只读 防止移动端手机上弹出软键盘
            inputDom.setAttribute('readonly', 'readonly')
            // 给input元素赋值
            inputDom.value = text
            // 将创建的input添加到body
            document.body.appendChild(inputDom)
            // 选中input元素的内容
            inputDom.select()
            // 执行浏览器复制命令
            // 复制命令会将当前选中的内容复制到剪切板中（这里就是创建的input标签中的内容）
            // Input要在正常的编辑状态下原生复制方法才会生效
            const result = document.execCommand('copy')
            // 判断是否复制成功
            if (result) {
                this.$message({
                    message: '复制成功！',
                    type: 'success',
                })
            } else {
                copyResult = false
            }
            // 复制操作后再将构造的标签 移除
            document.body.removeChild(inputDom)
            // 返回复制操作的最终结果
            return copyResult
        },
        //#########################正是结算#################
        qrjs(e) {
            if (this.bxxxinfo.his_deduct_amount > this.bxxxinfo.cash_balance) {
                this.$message({
                    message: '院内账户支付金额不能大于院内账户余额',
                    type: 'warning',
                })
                return false
            }
            if (this.bxxxinfo.grzhzf > this.bxxxinfo.personal_balance) {
                this.$message({
                    message: '医保个账支付金额不能大于医保账户余额',
                    type: 'warning',
                })
                return false
            }
            if (this.bxxxinfo.gjzhzf > this.bxxxinfo.family_balance) {
                this.$message({
                    message: '共济账户支付金额不能大于共济账户余额',
                    type: 'warning',
                })
                return false
            }
            this.loadingapplyList = true
            this.sureshow = true
            let y = {
                family_type: this.familyType,
                self2yb: true,
                patient_id: this.patientData.patient_id,
                personal_pay: this.bxxxinfo.grzhzf,
                family_pay: this.bxxxinfo.gjzhzf,
                cash_pay: this.bxxxinfo.his_deduct_amount,
                pre_key: this.bxxxinfo.pre_key,
                cache_key: this.form.cache_key,
                is_mt: this.selectTableArr[0].settle_type.is_mt,
            }
            if (e) {
                y.qr_code = this.pingzhengma
            }
            jsxx(y)
                .then(response => {
                    const _this = this
                    _this.channels = response.data.settle_type.name
                    this.$message.success('结算成功')
                    this.dialogVisible = false
                    this.sureshow = false
                    this.loadingapplyList = false
                    this.yibaoshow = false
                    this.fullscreenLoading = false
                    this.jeizhishow = false
                    const jshidprint = response.data
                    // setTimeout(function () {
                    _this.printcard(jshidprint)
                    // }, 5000)

                    //刷新列表
                    var obj = {
                        patient_id: this.patientData.patient_id, //this.cardNo,
                    }
                    settle_fee_self2yb(obj)
                        .then(response => {
                            this.tableData.cost = response.data
                            this.tableDataList = response.data
                            this.tylist = response.data
                            this.tiles(this.tylist)
                        })
                        .finally(res => {
                            this.loading = false
                        })
                })
                .finally(res => {
                    this.loadingapplyList = false
                    this.dialogVisible = false
                    this.sureshow = false
                    this.fullscreenLoading = false
                    this.yibaoshow = false
                    this.jeizhishow = false
                })
        },
        //选中昨天列表请求右边选中方法
        handleSelectionChange(array) {
            let that = this
            let x = array
            if (array.length > 1) {
                var set = new Set()
                for (var i = 0; i < array.length; i++) {
                    set.add(array[i].clinic_no)
                }
                if (set.size != 1) {
                    that.$message({
                        message: '不同的“就诊序号”不可以同时进行结算',
                        type: 'error',
                    })
                    this.$refs.multipleTableClinicRoom.clearSelection()
                    const selectionArr = x.slice(0, x.length - 1)
                    selectionArr.forEach((item, index, arr) => {
                        this.$refs.multipleTableClinicRoom.toggleRowSelection(item, true)
                    })
                    this.selectTableArr = x.slice(0, x.length - 1)
                    this.only_qq = 0
                    this.loading2 = true
                    var total = 0
                    var orders = []
                    var costint = []
                    var cost_ids = []
                    x.slice(0, x.length - 1).forEach(function (element) {
                        total += element.total * 1 * 1
                        orders.push(element.group_id)
                        cost_ids.push(element.rcpt_no)
                        costint.push(element)
                    })

                    this.cost_id = cost_ids
                    this.orders = orders
                    this.total = total.toFixed(2)

                    if (array.length != 0) {
                        settle_fee2yb({
                            rcpt_no: cost_ids.toString(),
                            patient_id: this.patientData.patient_id,
                        })
                            .then(response => {
                                this.costlist = response.data
                                this.loading2 = false
                            })
                            .finally(() => {
                                this.loading = false
                            })
                    } else {
                        this.costlist = []
                        this.loading2 = false
                    }
                    if (this.tylist.length == 1) {
                        this.jiesuan()
                    }
                    // })
                } else {
                    this.selectTableArr = array
                    this.only_qq = 0
                    this.loading2 = true
                    var total = 0
                    var orders = []
                    var costint = []
                    var cost_ids = []
                    array.forEach(function (element) {
                        total += element.total * 1 * 1
                        orders.push(element.group_id)
                        cost_ids.push(element.rcpt_no)
                        costint.push(element)
                    })

                    this.cost_id = cost_ids
                    this.orders = orders
                    this.total = total.toFixed(2)

                    if (array.length != 0) {
                        settle_fee2yb({
                            rcpt_no: cost_ids.toString(),
                            patient_id: this.patientData.patient_id,
                        })
                            .then(response => {
                                this.costlist = response.data
                                this.loading2 = false
                            })
                            .finally(() => {
                                this.loading = false
                            })
                    } else {
                        this.costlist = []
                        this.loading2 = false
                    }
                    if (this.tylist.length == 1) {
                        this.jiesuan()
                    }
                }
            } else {
                this.selectTableArr = array
                this.only_qq = 0
                this.loading2 = true
                var total = 0
                var orders = []
                var costint = []
                var cost_ids = []
                array.forEach(function (element) {
                    total += element.total * 1 * 1
                    orders.push(element.group_id)
                    cost_ids.push(element.rcpt_no)
                    costint.push(element)
                })

                this.cost_id = cost_ids
                this.orders = orders
                this.total = total.toFixed(2)

                if (array.length != 0) {
                    settle_fee2yb({
                        rcpt_no: cost_ids.toString(),
                        patient_id: this.patientData.patient_id,
                    })
                        .then(response => {
                            this.costlist = response.data
                            this.loading2 = false
                        })
                        .finally(() => {
                            this.loading = false
                        })
                } else {
                    this.costlist = []
                    this.loading2 = false
                }
                if (this.tylist.length == 1) {
                    this.jiesuan()
                }
            }
        },
        // 结算类型赋默认值
        setPersonType(e) {
            this.personTypeArr.forEach(element => {
                if (element.value == e) {
                    this.personType = e
                }
            })
        },
        // 切换结算类型
        changePersonType(x) {
            if (x == '2') {
                try {
                    var array = ['first', 'second', 'third', 'fourth']
                    // 执行到第3次,结束循环
                    this.tableData.cost.forEach(function (item, index) {
                        if (item.settle_type.value == '1') {
                            throw new Error('EndIterative')
                        }
                    })
                } catch (e) {
                    this.$message({
                        message: '当前有剩余自费处方，请先结算自费处方',
                        type: 'error',
                    })
                    return false
                }

                var that = this
                if (!that.cost_id || that.cost_id.length == 0) {
                    that.$message({
                        message: '请先选择待结算的处方',
                        type: 'error',
                    })
                    return false
                }
                this.resave_pation(this.personType)
                that.tableData.patient.rqlb = that.personType
            }
        },
        //获取自付比例
        getProp(row) {
            get_zfbl({
                item_code: row.item_code,
                //yltclb:row.settle_type.is_mb==true?'4':'6',
                rqlb: this.patientData.crowd_type,
                //xzbz:row.settle_type.is_gs==true?'D':'C',
                settle_type: row.settle_type.code,
            })
                .then(response => {
                    this.$message({
                        message: '获取成功,请重新选择比例',
                        type: 'success',
                    })
                    this.costlist.forEach(element => {
                        if (row.item_code == element.item_code) {
                            response.data.zfbl_desc.forEach(elements => {
                                element.zfbl_desc == response.data.zfbl_desc //[elements.key]=elements.value
                            })
                        }
                    })
                    row.zfbl = ''
                })
                .finally(() => {
                    this.loading = false
                })
        },

        //修改自付比例
        proportion(id, e) {
            this.showEditProp = false
            this.costlist.forEach(element => {
                if (element.id == id) {
                    element.sxzfbl = e
                    this.$forceUpdate()
                    return false
                }
            })
        },
        selectCardYiboInfo(e) {
            let x = {
                card_no: this.cardNo,
                card_type: this.cardType,
                id_card: e ? e.sfzh : '',
            }
            patient(x)
                .then(response => {
                    this.patientData = response.data
                    this.getWaiting()
                })
                .catch(() => {
                    this.$message({
                        message: '获取患者信息失败',
                        type: 'error',
                    })
                })
                .finally(() => {
                    this.loading = false
                })
        },
        selectCardYiboPreselect(data, x, y) {
             // 判断慢病
          if (this.selectTableArr[0]?.settle_type.is_mb) {
                // 判断多病种慢病
                if (data?.mzdbjbs_arr.length > 1) {
                    this.moreshow = true
                    this.moreshowdata = {
                        data: data,
                        x: x,
                        y: y,
                    }
                } else {
                    this.selectCardYiboPre(data, x, y, data?.mzdbjbs_arr[0]?.code)
                }
            } else {
                this.selectCardYiboPre(data, x, y,data?.mzdbjbs_arr[0]?.code)
            }

            // if (data?.mzdbjbs_arr.length > 1 && this.selectTableArr[0]?.settle_type.is_mb) {
            //     this.moreshow = true
            //     this.moreshowdata = {
            //         data: data,
            //         x: x,
            //         y: y,
            //     }
            // } else if (data?.mzdbjbs_arr.length == 1 && this.selectTableArr[0]?.settle_type.is_mb) {
            //     this.selectCardYiboPre(data, x, y, data?.mzdbjbs_arr[0].code)
            // } else {
            //     this.selectCardYiboPre(data, x, y)
            // }
        },
        // 医保预结算
        selectCardYiboPre(data, x, y, zhenduan) {
            this.moreshow = false
            this.oldewmpingzheng = y
            this.select_type = x
            this.form = {}
            this.form = data
            settlementPre({
                p_jbbm: this.selectTableArr[0]?.settle_type.is_mb?zhenduan:'',
                self2yb: true,
                patient_id: this.patientData.patient_id,
                cache_key: data.cache_key,
                prescription_nos: this.cost_id,
                is_mt: this.selectTableArr[0] ? this.selectTableArr[0].settle_type.is_mt : '',
                family_pay: false,
            })
                .then(res => {
                    this.bxxxinfo = res.data
                    this.bxxxinfo.his_deduct_amount = 0
                    familybalanceinfor({
                        patient_id: this.patientData.patient_id,
                        pre_key: res.data.pre_key,
                        cache_key: this.form.cache_key,
                    }).then(res2 => {
                        this.familyType = res2.data.family_type
                        this.dialogVisible = true
                        this.bxxxinfo.family_balance = res2.data.gjzhye
                        if (res2.data.family_type == '1') {
                            this.bxxxinfo.gjzhzf = res2.data.gjzhxfje
                            this.bxxxinfo.grzhzf = this.round(res2.data.grzhzf - res2.data.gjzhxfje, 2)
                        } else {
                            this.bxxxinfo.gjzhzf = 0
                        }

                        this.bxxxinfo.family_balance = res2.data.gjzhye
                        this.dialogVisible = true

                        this.bxxxinfo.his_deduct_amount = 0
                        this.bxxxinfo.grzhzf = 0
                        let djf = this.round(this.round(this.round(this.bxxxinfo.patient_burden - this.bxxxinfo.gjzhzf, 2) - this.bxxxinfo.his_deduct_amount, 2) - this.bxxxinfo.grzhzf, 2)
                        if (this.bxxxinfo.personal_balance >= djf) {
                            this.bxxxinfo.grzhzf = djf
                        }
                        if (this.bxxxinfo.personal_balance < djf) {
                            this.bxxxinfo.grzhzf = this.bxxxinfo.personal_balance
                            if (res2.data.family_type != '1') {
                                if (res2.data.gjzhye > this.round(djf - this.bxxxinfo.grzhzf, 2)) {
                                    this.bxxxinfo.gjzhzf = this.round(djf - this.bxxxinfo.grzhzf, 2)
                                } else {
                                    this.bxxxinfo.gjzhzf = res2.data.gjzhye
                                    if (this.bxxxinfo.cash_balance <= this.round(this.round(djf - this.bxxxinfo.grzhzf, 2) - res2.data.gjzhye, 2)) {
                                        this.bxxxinfo.his_deduct_amount = this.bxxxinfo.cash_balance
                                    } else {
                                        this.bxxxinfo.his_deduct_amount = this.round(this.round(djf - this.bxxxinfo.grzhzf, 2) - res2.data.gjzhye, 2)
                                    }
                                }
                            } else {
                                if (this.bxxxinfo.cash_balance <= this.round(djf - this.bxxxinfo.grzhzf, 2)) {
                                    this.bxxxinfo.his_deduct_amount = this.bxxxinfo.cash_balance
                                } else {
                                    this.bxxxinfo.his_deduct_amount = this.round(djf - this.bxxxinfo.grzhzf, 2)
                                }
                            }
                        }

                        this.form.djf = this.round(this.round(this.round(this.bxxxinfo.patient_burden - this.bxxxinfo.gjzhzf, 2) - this.bxxxinfo.his_deduct_amount, 2) - this.bxxxinfo.grzhzf, 2)
                    })
                })

                .catch(err => {})
                .finally(() => {
                    this.closeSelectCard()
                })
        },
        closeSelectCard() {
            this.yibaoshowNew = false
        },
        // 自费预结算
        zfBeforePre() {
            this.form = {}
            settleSelfPre({ patient_id: this.patientData.patient_id, prescription_nos: this.cost_id })
                .then(res => {
                    this.dialogVisible = true
                    this.bxxxinfo = res.data
                    this.bxxxinfo.gjzhzf = 0
                    this.bxxxinfo.his_deduct_amount = 0
                    this.bxxxinfo.grzhzf = 0
                    this.form.djf = this.round(this.round(this.round(this.bxxxinfo.patient_burden - this.bxxxinfo.gjzhzf, 2) - this.bxxxinfo.his_deduct_amount, 2) - this.bxxxinfo.grzhzf, 2)
                })
                .catch(err => {})
        },
        //打印小票方法
        printcard(e) {
            const _this = this
            let time = new Date()
            let nowTime = time.toLocaleString('sv-SE')
            let text = ''
            let textend = ''
            let texttitle = ''

            for (let index = 0; index < e.settle_fees.length; index++) {
                texttitle =
                    `<span style="color: black;font-weight: 700;margin-top:20px">` +
                    e.settle_fees[index].address +
                    `(` +
                    e.settle_fees[index].site +
                    `)</span>
                           `
                let textList = ''
                for (let indexs = 0; indexs < e.settle_fees[index].list.length; indexs++) {
                    const element = e.settle_fees[index].list[indexs]
                    var noteList = ''
                    if (element.administration_note != '') {
                        noteList = '(' + element.administration_note + ')'
                    } else {
                        noteList = ''
                    }
                    textList =
                        textList +
                        `<div style='font-size: 13px;position: relative'>
							        <div class="conline" style='width:60%;'>` +
                        element.item_name +
                        noteList +
                        `</div>
							        <div class="conline" style=' position: absolute;right: 60px;top: 0px;'>` +
                        element.qty +
                        `</div>
							        <div class="conline" style=' position: absolute;right: 0px;top: 0px;'>` +
                        element.total +
                        `元</div>
						            </div>`
                }

                text = text + texttitle + `<div style="margin-bottom:10px">` + textList + `</div>`
            }

            textend = `<div class="btnborder">` + text + `</div>`
            let user =
                `
                 <!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<style>
		* {
			padding: 0px;
			margin: 0px;
		}

		.feiyong {
			font-size: 18px;
			display: flex;
			justify-content: space-between;
		}

		.zhong {
			text-align: center;
			width: 100%
		}
		.money{
			position:absolute;right: 0px;
		}
		.btnborder{
			border-bottom: 1px gray solid;
			padding-bottom: 10px;
			margin-bottom: 10px;
		}
		.conline{
			line-height: 25px;
		}
	</style>
	<body>
		<div style="margin-left:5px; width: 250px;margin-bottom: 10px;">
				<div class="zhong"><span style="font-size: 20px;font-weight: 600;">山东省第二人民医院</span>
				</div>
				<div class="zhong btnborder"><span style="font-size: 20px;font-weight: 600;">缴费成功凭条<span>
				</div>
				<div style="margin:-5px 0px 0px 18px;position: relative">
					<div class="conline"><span>姓名:</span><span class="money">${this.patientData.name}</span></div>
                      <div class="conline"><span>性别:</span><span class="money">${this.patientData.sex}</span></div>
                    <div class="conline"><span>年龄:</span><span class="money">${this.patientData.age}</span></div>
					<div class="conline"><span>就诊卡号：</span><span class="money">${e.id_card}</span></div>
					<div class="conline"><span>交易方式:</span><span class="money">${e.trade_type}</span></div>
                    <div class="conline"><span>开单医师:</span><span class="money">${e.doctor_name}</span></div>
                    <div class="conline" style="${
                        this.bxxxinfo.patient_burden != 0 && (this.bxxxinfo.patient_burden != '0.00') == false ? 'display:none' : 'display:block'
                    }"><span>个人负担金额：</span><span class="money"  >${this.bxxxinfo.patient_burden}元</span></div>
					<div class="conline" style="${
                        (this.bxxxinfo.insurance_burden != 0 && this.bxxxinfo.insurance_burden != '0.00') == false ? 'display:none' : 'display:block'
                    }"><span>医保负担金额：</span><span class="money"  >${this.bxxxinfo.insurance_burden}元</span></div>
                    <div class="conline" style="${
                        (this.bxxxinfo.personal_pay_syd != 0 && this.bxxxinfo.personal_pay_syd != '0.00') == false ? 'display:none' : 'display:block'
                    }"><span>省异地个帐支付：</span><span class="money" >${this.bxxxinfo.personal_pay_syd}元</span></div>
                    <div class="conline" style="${
                        (this.bxxxinfo.his_deduct_amount != 0 && this.bxxxinfo.his_deduct_amount != '0.00') == false ? 'display:none' : 'display:block'
                    }"><span>院内账户支付：</span><span class="money"  >${this.bxxxinfo.his_deduct_amount}元</span></div>
                    <div class="conline" style="${
                        (this.bxxxinfo.grzhzf != 0 && this.bxxxinfo.grzhzf != '0.00') == false ? 'display:none' : 'display:block'
                    }"><span>医保账户支付：</span><span class="money"  >${this.bxxxinfo.grzhzf}元 </span></div>
                    <div class="conline" style="${
                        (this.bxxxinfo.gjzhzf != 0 && this.bxxxinfo.gjzhzf != '0.00') == false ? 'display:none' : 'display:block'
                    }"><span>共济账户支付：</span><span class="money">${this.bxxxinfo.gjzhzf}元</span></div>
				
					<div class="btnborder conline"><span>费用合计：</span><span class="money">${this.bxxxinfo.total}元</span></div>
			` +
                textend +
                `
					<div><span>打印时间：</span><span>${nowTime}</span>
                    
					</div>
                    <div style='height:50px'>
                        <span>结算时间：</span><span>${e.js_date}</span> </div>
				</div>
			</div>
	</body>
</html>
                 `
            var LODOP = getLodop()
            if (LODOP) {
                printProof(user)
                this.$message({
                    message: '打印成功',
                    type: 'success',
                })
            } else {
                this.$message({
                    message: '结算成功！打印驱动异常！',
                    type: 'warning',
                })
            }
            // })
            // .finally(() => {})
        },
        // 自费正式结算
        selfPre() {
            if (this.bxxxinfo.his_deduct_amount > this.bxxxinfo.cash_balance) {
                this.$message({
                    message: '院内账户支付金额不能大于院内账户余额',
                    type: 'warning',
                })
                return false
            }
            if (this.bxxxinfo.grzhzf > this.bxxxinfo.personal_balance) {
                this.$message({
                    message: '医保个账支付金额不能大于医保账户余额',
                    type: 'warning',
                })
                return false
            }
            if (this.bxxxinfo.gjzhzf > this.bxxxinfo.family_balance) {
                this.$message({
                    message: '共济账户支付金额不能大于共济账户余额',
                    type: 'warning',
                })
                return false
            }
            let y = {
                patient_id: this.patientData.patient_id,
                personal_pay: this.bxxxinfo.grzhzf,
                family_pay: this.bxxxinfo.gjzhzf,
                cash_pay: this.bxxxinfo.his_deduct_amount,
                pre_key: this.bxxxinfo.pre_key,
                cache_key: this.form.cache_key,
            }
            selfPre(y)
                .then(response => {
                    const _this = this
                    this.$message.success('结算成功')
                    this.dialogVisible = false
                    this.sureshow = false
                    this.loadingapplyList = false
                    this.yibaoshow = false
                    this.fullscreenLoading = false
                    this.jeizhishow = false
                    const jshidprint = response.data
                    // setTimeout(function () {
                    _this.printcard(jshidprint)
                    // }, 5000)

                    //刷新列表
                })
                .catch(err => {})
                .finally(res => {
                    this.loadingapplyList = false
                    this.dialogVisible = false
                    this.sureshow = false
                    this.fullscreenLoading = false
                    this.yibaoshow = false
                    this.jeizhishow = false

                    this.getWaiting()

                    // var obj = {
                    //     patient_id: this.cardNo,
                    // }
                    // pdxq(obj)
                    //     .then(response => {
                    //         this.tableData.cost = response.data
                    //         this.tableDataList = response.data
                    //         this.tylist = response.data
                    //         this.tiles(this.tylist)
                    //     })
                    //     .finally(res => {
                    //         this.loading = false
                    //     })
                })
        },
        // 获取共济余额
        getFamilyBalance() {
            this.loadingapplyList = true
            familyBalance({
                pre_key: this.bxxxinfo.pre_key,
                cache_key: this.form.cache_key,
            })
                .then(res => {
                    this.bxxxinfo.gjzhzf = res.data
                })
                .catch(err => {
                    this.gjzhzfje = false
                })
                .finally(() => {
                    this.loadingapplyList = false
                })
        },
    },
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
::v-deep .el-table__body-wrapper {
    height: calc(100vh - 360px);
    overflow-y: auto;
}
::v-deep.el-input--mini .el-input__inner {
    width: 220px;
}
.abc {
    .el-form-item--mini.el-form-item {
        margin-bottom: 10px;
    }
    ::v-deep .el-loading-mask {
        background-color: #999999 !important;
    }
    ::v-deep .el-loading-spinner {
        /*这个是自己想设置的 gif 加载动图*/
        background-image: url('../../assets/images/jiazai1.gif');
        background-repeat: no-repeat;
        background-size: 225px 236px;
        height: 229px;
        width: 100%;
        /* margin-top: -124px; */
        background-position: center;
        top: 32%;
    }

    ::v-deep .el-loading-spinner .circular {
        /*隐藏 之前  element-ui  默认的 loading 动画*/
        display: none;
    }
    ::v-deep .el-loading-spinner i {
        display: none;
    }

    ::v-deep .el-loading-spinner .el-loading-text {
        /*为了让文字在loading图下面*/
        margin-top: 160px;
        color: #f8f8f8;
    }
    padding-bottom: 5px;
}

.safsac {
    .el-input__inner {
        border: 1px solid #1890ff !important;
    }
}

.asdn {
    padding: 0px 15px 15px;
    font-size: 14px;
    color: #666666;
}

.contnssddf {
    height: 500px;
    width: 96%;
    margin-left: 4%;
    background: #eef5fd;
    position: relative;

    .sds {
        display: flex;
        flex-wrap: wrap;

        .contnssddf-item {
            width: 50%;
            padding-left: 20px;
            padding-top: 12px;
            // padding:4px  16px;
            color: #999999;
            font-size: 14px;
        }
    }

    .fapiao {
        position: absolute;
        bottom: 20px;
        left: 20px;
        right: 0;
        color: #18518b;
        font-size: 14px;
    }
}

.titles {
    padding-left: 10px;
}

.titles::before {
    content: '';
    display: block;
    position: absolute;
    margin-top: 4px;
    width: 5px;
    height: 15px;
    background: #4991fd;
    border-radius: 10px;
}

.toubu {
    // height: 50px;
    padding: 10px 0;
    display: flex;
    // line-height: 50px;
    color: #666666;
    font-size: 14px;
    padding-left: 20px;

    .toubuitem {
        flex: 1;
        display: flex;
        line-height: 24px;

        // justify-content: space-between;
        .topone_right {
            width: 120px;
            padding-left: 10px;
            border-bottom: 1px solid #666666;
        }
    }

    .jian {
        flex: 0;
        text-align: right;
        padding-right: 20px;
        color: #0a2cd6;
        font-weight: 600;
        font-family: Source Han Sans CN;
        font-size: 16px;
    }
}

.content-right {
    background: white;
    // padding: 10px;
    min-height: calc(100vh - 150px);
    position: relative;

    .content-right-content {
        width: 100%;
        background: #eef5fd;
        height: 610px;

        .toubu {
            // height: 50px;
            padding: 10px 0;
            display: flex;
            // line-height: 50px;
            color: #666666;
            font-size: 14px;
            padding-left: 20px;

            .toubuitem {
                flex: 1;
                display: flex;
                line-height: 24px;

                // justify-content: space-between;
                .topone_right {
                    width: 120px;
                    padding-left: 10px;
                    border-bottom: 1px solid #666666;
                }
            }

            .jian {
                flex: 0;
                text-align: right;
                padding-right: 20px;
                color: #0a2cd6;
                font-weight: 600;
                font-family: Source Han Sans CN;
                font-size: 16px;
            }
        }

        .bidu {
            display: flex;

            div {
                font-size: 14px;
                flex: 1;
                height: 50px;
                line-height: 50px;

                padding-left: 20px;

                span {
                    font-size: 14px;
                    color: #18518b;
                }
            }
        }
    }

    .ksmzjzzzbs {
        color: #666666;
        font-size: 14px;
        padding-right: 5px;
    }

    .xinxi {
        display: flex;
        // margin: 10px 0;
    }

    .btslist {
        width: 50%;
        margin-top: 5px;

        .btns {
            float: left;
            flex: 1;
            // padding: 100px;
            width: 108px;
            height: 30px;
            background: #ffffff;
            border: 1px solid #4991fd;
            border-radius: 4px;
            color: #4991fd;
            line-height: 28px;
            font-size: 14px;
            text-align: center;
            margin: 5px 15px;
            cursor: pointer;
            // margin-right: 10px;
        }

        .btns:hover {
            background-color: #4991fd;
            color: white;
        }
    }

    .sign {
        padding: 10px 0;
    }
}

.content-left {
    background: white;
    // padding: 10px;
    min-height: calc(100vh - 150px);
    position: relative;

    .content-left-type {
        width: 480px;

        .el-radio {
            width: 120px;
            margin: 8px 0;
        }
    }

    .content-left-heji {
        position: absolute;
        // bottom: 20px;
        left: 20px;
        right: 0;
        display: flex;

        .heji {
            width: 100px;
            height: 40px;
            line-height: 38px;
            text-align: center;
            font-size: 14px;
            color: #18518b;
            background: #eef5fd;
        }

        .money {
            width: 160px;
            height: 40px;
            background: #ffffff;
            line-height: 38px;
            border: 1px solid #dddddd;
            border-radius: 2px;
            font-size: 14px;
            font-family: Source Han Sans CN;
            font-weight: 400;
            color: #000000;
            text-align: right;
            padding-right: 10px;
        }
    }
}

.content-left-heji {
    position: absolute;
    // bottom: 20px;
    left: 20px;
    right: 0;
    display: flex;

    .heji {
        width: 100px;
        height: 40px;
        line-height: 38px;
        text-align: center;
        font-size: 14px;
        color: #18518b;
        background: #eef5fd;
    }

    .money {
        width: 160px;
        height: 40px;
        background: #ffffff;
        line-height: 38px;
        border: 1px solid #dddddd;
        border-radius: 2px;
        font-size: 14px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #000000;
        text-align: right;
        padding-right: 10px;
    }
}

::v-deep .el-dialog__body {
    padding: 0px 20px !important;
}

.edit-person {
    .el-form-item--medium {
        ::v-deep.el-form-item__content {
            line-height: 30px;
        }

        ::v-deep.el-input--medium .el-input__inner {
            height: 20px;
            line-height: 30px;
        }
    }
}

.selectinput {
    ::v-deep.el-input--medium .el-input__inner {
        height: 30px;
        // margin-top: 5px;
        line-height: 30px;
        width: 150px;
    }
}

.boxmain {
    display: flex;
    align-items: center;
}

.app-container {
}

::v-deep .el-card__body {
    padding: 15px 9px;
}

::v-deep .fullbox {
    // background-color: #f2f8ff;
    box-shadow: 0px 2px 16.5px 0px #dce9fe;
}

::v-deep.el-dialog:not(.is-fullscreen) {
    margin-top: 1vh !important;
}

::v-deep .el-divider__text {
    font-weight: 550;
    color: #1890ff;
    font-size: 18px;
    background-color: #f2f8ff;
}

::v-deep .el-divider {
    background-color: #1890ff;
}

::v-deep .el-table__empty-block {
    // background-color: #e7f1fd !important;
}

::v-deep .el-empty__description {
    display: none;
}

.userInfo_box {
    width: 99%;
    margin: 0 auto;
    background: linear-gradient(180deg, #a9c2ff 0%, #ffffff 100%);
    box-shadow: 0px 3px 4.7px 0px #004aff26;
    border-radius: 4px;

    .userInfo_div {
        margin: 0 20px 0 15px;
        padding-left: 15px;
        border-left: 2px solid #f1f1f1;
        font-size: 16px;
        color: #333333;
        font-weight: 500;

        .userInfo_div_1 {
            display: flex;
            align-items: center;

            .userInfo_name {
                margin-right: 20px;
                font-size: 18px;
                font-weight: 700;
            }

            .userInfo_age {
                margin-right: 20px;
            }

            .userInfo_sex {
                margin-right: 20px;
                margin: 0 25px;
            }
        }

        .userInfo_div_2 {
            margin-top: 8px;
        }
    }

    .yibaoInfo_div {
        margin-right: 20px;
        display: flex;
        // flex-direction: column;

        .yibaoInfo_div_1 {
            width: max-content;
            border-radius: 3px;
            border: 1px solid #004aff;
            padding: 3px 5px;
            font-size: 12px;
            color: #004aff;
        }
    }

    .yibaoInfo_div_2 {
        margin-right: 20px;
        font-size: 16px;
        font-weight: 500;
        color: #333;
        // margin-top: 8px;
    }
}

.footer_div {
    width: 100%;
    height: 56px;
    background: #fff;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    padding-left: 40px;

    .footer_total {
        font-size: 20px;
        font-weight: 700;
    }

    .jiesuan_btn {
        width: 80px;
        height: 32px;
        margin-left: 100px;
        font-size: 14px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #004aff;
    }
}

.form_item {
    display: flex;
    margin-right: 20px;

    .label {
        width: 170px;
        color: #333333;
        text-align: center;
    }
}

.box-card {
    background: #fff;
    border-radius: 5px;

    .box_card_title {
        box-sizing: border-box;
        padding: 10px;
        font-size: 16px;
        font-weight: bold;
        display: flex;
        justify-content: space-between;
    }
}

/*遮挡层样式*/
.grey-cloth {
    /* min-width: 1920px; */
    /* min-height: 1024px; */
    top: 0px;
    left: 0px;
    right: 0px;
    bottom: 0px;
    position: fixed;
    z-index: 99;
    background-color: rgba(255, 255, 255, 0.6);
}

/* loading css */

.wrapper {
    margin: 40vh auto;
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 100px;
    width: 100px;
    padding: 0px 6px;
    border: 5px solid rgb(30, 144, 255);
    border-radius: 12px;
}

.rect {
    border-radius: 5px;
    height: 34px;
    width: 4px;
    background-color: rgb(30, 144, 255);
    animation: move 0.6s linear infinite;
}

.one,
.five {
    animation-delay: 0.1s;
}

.two,
.four {
    animation-delay: 0.2s;
}

.three {
    animation-delay: 0.3s;
}

@keyframes move {
    from {
        height: 34px;
    }

    50% {
        height: 5px;
    }

    to {
        height: 34px;
    }
}

button:active {
    --press: 1;
}
</style>
