<template>
    <div class="app-container">
        <el-form ref="loginref" :model="form" label-width="110px" :inline="true">
            <div class="search">
                <div class="search_left" style="display: flex; margin-top: 10px">
                    <el-form-item label="结算时间" prop="brjsrq">
                        <el-date-picker v-model="settleTime" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" @change="fysfsjChange" style="">
                        </el-date-picker>
                    </el-form-item>
                    <el-form-item label="是否开启自费" prop="brjsrq">
                        <el-switch v-model="valueinstall" active-color="#13ce66" inactive-color="#ff4949"> </el-switch>
                    </el-form-item>
                    <div class="search_middle_1 search_middle_1_top" style="width: 200px; margin-left: 50px">
                        <el-button type="primary" @click="getList" style="margin-right: 10px">查询</el-button>
                        <el-button type="primary" @click="resetForm('loginref')" style="margin-left: 0; margin-top: 10px">重置</el-button>
                    </div>
                </div>
            </div>
        </el-form>
        <div style="display: flex; justify-content: space-around">
            <div style="width: 31%">
                <div style="text-align: center; padding: 20px; background-color: #e3f2ff"><span style="font-size: 20px; font-weight: 600">门诊统计</span></div>
                <el-table :data="mz_items" border style="width: 100%" v-loading="loadingone">
                    <el-table-column prop="day" label="结算日期" width="100"> </el-table-column>
                    <el-table-column prop="total" label="结算人次"> </el-table-column>
                    <el-table-column prop="total_zj" label="诊间结算人次"> </el-table-column>
                    <el-table-column prop="bili" label="诊间结算率"> </el-table-column>
                </el-table>
                <div style="display: flex; justify-content: space-around; border: 1px rgb(218, 218, 218) solid; margin-bottom: 10px">
                    <div>
                        <div><span>总人次</span></div>
                        <div style="text-align: center">
                            {{ mzzong }}
                        </div>
                    </div>
                    <div>
                        <div><span>诊间结算总人次</span></div>
                        <div style="text-align: center">
                            {{ mzzhzong }}
                        </div>
                    </div>
                    <div>
                        <div><span>总结算率</span></div>
                        <div style="text-align: center">
                            {{ mzlv }}
                        </div>
                    </div>
                </div>
            </div>

            <div style="width: 31%">
                <div style="text-align: center; padding: 20px; background-color: #e3f2ff"><span style="font-size: 20px; font-weight: 600">出院结算统计</span></div>
                <el-table :data="zy_items" border style="width: 100%" v-loading="loadingone">
                    <el-table-column prop="day" label="结算日期" width="100"> </el-table-column>
                    <el-table-column prop="total" label="结算人次"> </el-table-column>
                    <el-table-column prop="total_cp" label="床旁结算人次"> </el-table-column>
                    <el-table-column prop="bili" label="床旁结算率"> </el-table-column>
                </el-table>
                <div style="display: flex; justify-content: space-around; border: 1px rgb(218, 218, 218) solid; margin-bottom: 10px">
                    <div>
                        <div><span>总人次</span></div>
                        <div style="text-align: center">
                            {{ zyzong }}
                        </div>
                    </div>
                    <div>
                        <div><span>床旁结算总人次</span></div>
                        <div style="text-align: center">
                            {{ zyzhzong }}
                        </div>
                    </div>
                    <div>
                        <div><span>总结算率</span></div>
                        <div style="text-align: center">
                            {{ zylv }}
                        </div>
                    </div>
                </div>
            </div>
            <div style="width: 31%">
                <div style="text-align: center; padding: 20px; background-color: #e3f2ff"><span style="font-size: 20px; font-weight: 600">床旁登记统计</span></div>
                <el-table :data="zy_items_cp" border style="width: 100%" v-loading="loadingone">
                    <el-table-column prop="day" label="登记日期" width="100"> </el-table-column>
                    <el-table-column prop="total" label="登记人次"> </el-table-column>
                    <el-table-column prop="total_cp" label="床旁登记人次"> </el-table-column>
                    <el-table-column prop="bili" label="床旁登记率"> </el-table-column>
                </el-table>
                <div style="display: flex; justify-content: space-around; border: 1px rgb(218, 218, 218) solid; margin-bottom: 10px">
                    <div>
                        <div><span>总人次</span></div>
                        <div style="text-align: center">
                            {{ djzong }}
                        </div>
                    </div>
                    <div>
                        <div><span>床旁登记总人次</span></div>
                        <div style="text-align: center">
                            {{ djzhzong }}
                        </div>
                    </div>
                    <div>
                        <div><span>总结算率</span></div>
                        <div style="text-align: center">
                            {{ djlv }}
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div style="display: flex"></div>

        <div style="display: flex; justify-content: space-around">
            <div style="width: 45%">
                <div style="text-align: center; padding: 20px; background-color: #e3f2ff"><span style="font-size: 20px; font-weight: 600">床旁登记科室统计</span></div>
                <div style="display: flex; justify-content: space-around">
                    <div>
                        <span>总人次：{{ cjzzong }}</span>
                    </div>
                    <div>
                        <span>床旁登记总人次：{{ cjzzhzong }}</span>
                    </div>
                    <div>
                        <span>总登记率：{{ cjzzlv }}</span>
                    </div>
                </div>
                <el-table :data="zy_cp" border style="width: 100%" v-loading="loadingone">
                    <el-table-column prop="p_ksbm" label="病区编码" width="170"> </el-table-column>
                    <el-table-column prop="p_ksmc" label="病区名称"> </el-table-column>
                    <el-table-column prop="total_cp" label="床旁登记数量"> </el-table-column>
                    <el-table-column prop="total" label="总登记数量"> </el-table-column>
                    <el-table-column prop="bili" label="床旁登记率"> </el-table-column>
                </el-table>
            </div>
            <div style="width: 45%">
                <div style="text-align: center; padding: 20px; background-color: #e3f2ff"><span style="font-size: 20px; font-weight: 600">床旁结算科室统计</span></div>
                <div style="display: flex; justify-content: space-around">
                    <div>
                        <span>总人次：{{ cdjzong }}</span>
                    </div>
                    <div>
                        <span>床旁结算总人次：{{ cdjzhzong }}</span>
                    </div>
                    <div>
                        <span>总结算率：{{ cdjlv }}</span>
                    </div>
                </div>
                <el-table :data="zy_ks" border style="width: 100%" v-loading="loadingone">
                    <el-table-column prop="dept_code" label="病区编码" width="170"> </el-table-column>
                    <el-table-column prop="ksmc" label="病区名称"> </el-table-column>
                    <el-table-column prop="total_cp" label="床旁结算数量"> </el-table-column>
                    <el-table-column prop="total" label="总结算数量"> </el-table-column>
                    <el-table-column prop="bili" label="床旁结算率"> </el-table-column>
                </el-table>
            </div>
        </div>
    </div>
</template>
<script>
import { formatDate, getDay } from '@/utils/utils'
import { basic } from '@/api/mz'
export default {
    name: 'Outpatient',
    data() {
        return {
            loadingone: false,
            valueinstall: true,
            form: {
                brjsrq: '',
            },
            settleTime: '',
            mz_items: [],
            mz_items_zjjs: [],
            zy_items: [],
            zy_items_cp: [],
            zy_cp: [],
            zy_ks: [],
            alldata: '',
            mzzong: 0,
            mzzhzong: 0,
            mzlv: 0,
            zyzong: 0,
            zyzhzong: 0,
            zylv: 0,
            djzong: 0,
            djzhzong: 0,
            djlv: 0,
            cdjzong: 0,
            cdjzhzong: 0,
            cdjlv: 0,
            cjzzong: 0,
            cjzzhzong: 0,
            cjzzlv: 0,
        }
    },
    mounted() {},
    created() {},
    methods: {
        fysfsjChange(e) {
            if (e.length > 1) {
                var arr = []
                for (var i = 0; i < e.length; i++) {
                    arr.push(formatDate(e[i], 'yyyy-MM-dd'))
                }
                this.form.brjsrq = arr
            }
        },
        //查询
        getList() {
            this.mzzong = 0
            this.mzzhzong = 0
            this.zyzong = 0
            this.zyzhzong = 0
            this.djzong = 0
            this.djzhzong = 0
            this.cjzzong = 0
            this.cdjzong = 0
            this.cdjzhzong = 0
            this.cjzzhzong = 0
            // this.djlv='0%'
            // this.mzlv='0%'
            // this.zylv='0%'
            this.loadingone = true
            basic({
                start_date: this.form.brjsrq[0],
                end_date: this.form.brjsrq[1],
                zf: this.valueinstall == true ? '1' : '0',
            }).then(response => {
                this.mz_items = response.data.mz
                this.zy_ks = response.data.zy_ks
                this.zy_cp = response.data.dj_ks
                for (let index = 0; index < response.data.mz.length; index++) {
                    const element = response.data.mz[index]
                    let x = Math.round((response.data.mz[index].total_zj / response.data.mz[index].total) * 10000) / 100 + '%'
                    this.mzzong += response.data.mz[index].total
                    this.mzzhzong += response.data.mz[index].total_zj
                    element.bili = x
                }
                this.mzlv = Math.round((this.mzzhzong / this.mzzong) * 10000) / 100 + '%'
                this.loadingone = false
                this.mz_items_zjjs = response.data.mz_items_zjjs
                this.zy_items = response.data.zy
                for (let index = 0; index < response.data.zy.length; index++) {
                    const element = response.data.zy[index]
                    let x = Math.round((response.data.zy[index].total_cp / response.data.zy[index].total) * 10000) / 100 + '%'
                    this.zyzong += response.data.zy[index].total
                    this.zyzhzong += response.data.zy[index].total_cp
                    element.bili = x
                }
                this.zylv = Math.round((this.zyzhzong / this.zyzong) * 10000) / 100 + '%'
                this.zy_items_cp = response.data.dj
                for (let index = 0; index < response.data.dj.length; index++) {
                    const element = response.data.dj[index]
                    let x = Math.round((response.data.dj[index].total_cp / response.data.dj[index].total) * 10000) / 100 + '%'
                    this.djzong += response.data.dj[index].total
                    this.djzhzong += response.data.dj[index].total_cp
                    element.bili = x
                }
                this.djlv = Math.round((this.djzhzong / this.djzong) * 10000) / 100 + '%'
                for (let index = 0; index < response.data.zy_ks.length; index++) {
                    const element = response.data.zy_ks[index]
                    let x = Math.round((response.data.zy_ks[index].total_cp / response.data.zy_ks[index].total) * 10000) / 100 + '%'
                    this.cdjzong += response.data.zy_ks[index].total
                    this.cdjzhzong += response.data.zy_ks[index].total_cp
                    element.bili = x
                }
                this.cdjlv = Math.round((this.cdjzhzong / this.cdjzong) * 10000) / 100 + '%'
                for (let index = 0; index < response.data.dj_ks.length; index++) {
                    const element = response.data.dj_ks[index]
                    let x = Math.round((response.data.dj_ks[index].total_cp / response.data.dj_ks[index].total) * 10000) / 100 + '%'
                    this.cjzzong += response.data.dj_ks[index].total
                    this.cjzzhzong += response.data.dj_ks[index].total_cp
                    element.bili = x
                }
                this.cjzzlv = Math.round((this.cjzzhzong / this.cjzzong) * 10000) / 100 + '%'
                this.alldata = response.data
            })
        },
        //撤销结算按钮操作
        jiesuan() {
            this.cxjsshow = true
            //医保二维码退款
            if (this.ybewm()) {
                this.uploadfeeshow = true
            }
            //mis社保卡退款
            else if (this.socialMIS()) {
                this.socialfUNCTION()
            }
            //银行卡、微信、支付宝、现金退款
            else {
                this.moneyFUNCTION()
            }
        },
    },
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.el-form-item {
    margin-top: 10px;
}
</style>
