c<template>
    <div class="main-contain incomeStatistics">
        <div class="position">
            <bread-crumb :crumbs='crumbs'></bread-crumb>
        </div>
        <div class="app-container">
            <div style="display: flex;justify-content: space-between;margin-bottom:10px;">
                <div>
                    <el-input size="small" style="width:130px;" v-model="keywords"
                              class="filter-item"/>
                    <el-button size="small" style="margin-left:10px;" class="filter-item" type="primary"
                               @click="searchAction">
                        搜索
                    </el-button>
                    <el-date-picker v-model="query_start_time" prefix-icon="el-icon-date"
                                    @change="handleStartTimeChange" :editable="false" :clearable="false"
                                    style="width: 130px;" type="date" placeholder="选择开始日期"
                                    format="yyyy-MM-dd"
                                    value-format="yyyy-MM-dd"
                                    align="right"></el-date-picker>
                    -

                    <el-date-picker v-model="query_end_time" prefix-icon="el-icon-date"
                                    @change="handleEndTimeChange" :editable="false" :clearable="false"
                                    style="width: 130px;margin-right:10px;" type="date" placeholder="选择结束日期"
                                    format="yyyy-MM-dd"
                                    value-format="yyyy-MM-dd"
                                    align="right"></el-date-picker>


                    <label class="title">险种<span class="name"></span> : </label>
                    <el-select v-model="query_insutype" style="width:140px;margin-right:10px;" placeholder="请选择"
                               @change="changeInsutype">
                        <el-option
                                v-for="item in insutypes"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value">
                        </el-option>
                    </el-select>


                    <label class="title">清算类别<span class="name"></span> : </label>
                    <el-select v-model="query_clr_type" style="width:100px;margin-right:10px;" placeholder="请选择"
                               @change="changeClrType">
                        <el-option
                                v-for="item in clrOptions"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value">
                        </el-option>
                    </el-select>




                </div>

            </div>
            <div style="float: right;margin-bottom: 10px">
                <el-button size="small" type="primary" @click="dialogFormVisible = true">医保对账</el-button>
                <el-button size="small" type="primary" @click="getFormData">下载对账报表</el-button>
            </div>


            <el-table :data="tableData" border style="width: 100%;" :row-style="{ color: '#303133' }"
                      :header-cell-style="{backgroundColor: 'rgb(245, 247, 250)',color: '#606266'}"
                      highlight-current-row
                      @select="selectCostInfo"
                      @selection-change="changeCostInfoTableData"
                      @select-all="changeAllCostInfoTableData"
                      row-key="row_key"
                      ref="multipleTable"
            >
                <el-table-column
                        align="center"
                        type="selection"
                        width="55"
                ></el-table-column>
                <el-table-column
                        prop="date"
                        label="序号"
                        width="60"
                        align="center"
                        type="index"
                >
                </el-table-column>
                <el-table-column align="center" prop="name" label="对账结果">
                    <template slot-scope="scope">{{'平'}}</template>
                </el-table-column>
                <el-table-column align="center" prop="name" label="操作机构">
                    <!--<template slot-scope="scope">{{// this.$store.getters.xt_user.org.org_name}}</template>-->
                </el-table-column>
                <el-table-column align="center" prop="name" label="对账申请人">
                    <template slot-scope="scope">{{getName(scope.row.creator)}}</template>
                </el-table-column>
                <el-table-column align="center" prop="name" label="开始时间">
                    <template slot-scope="scope">{{getTimes(scope.row.start_time)}}</template>
                </el-table-column>
                <el-table-column align="center" prop="name" label="结束时间">
                    <template slot-scope="scope">{{getTimes(scope.row.end_time)}}</template>
                </el-table-column>
                <el-table-column align="center" prop="name" label="险种类型">
                    <template slot-scope="scope">
                        <div v-if="scope.row.insutype == '310'">职工基本医疗保险</div>
                        <div v-if="scope.row.insutype == '320'">公务员医疗补助</div>
                        <div v-if="scope.row.insutype == '330'">大额医疗费用补助</div>
                        <div v-if="scope.row.insutype == '340'">离休人员医疗保障</div>
                        <div v-if="scope.row.insutype == '390'">城乡居民基本医疗保险</div>
                        <div v-if="scope.row.insutype == '392'">城乡居民大病医疗保险</div>
                        <div v-if="scope.row.insutype == '510'">生育保险</div>
                    </template>
                </el-table-column>
                <el-table-column align="center" prop="name" label="对账类型">
                    <template slot-scope="scope">
                        <div v-if="scope.row.check_type == 1">总账</div>
                        <div v-if="scope.row.check_type == 2">明细</div>
                    </template>
                </el-table-column>
                <el-table-column align="center" prop="name" label="清算经办机构">
                    <template slot-scope="scope">{{getName(scope.row.creator)}}</template>
                </el-table-column>
                <el-table-column align="center" prop="name" label="定点医药机构医疗费总额(元)">
                    <template slot-scope="scope">{{scope.row.setl_optins}}</template>
                </el-table-column>
                <el-table-column align="center" prop="name" label="医保中心医疗费总额(元)">
                    <template slot-scope="scope">{{scope.row.cost_total}}</template>
                </el-table-column>
                <el-table-column align="center" prop="name" label="定点医药机构基金总额(元)">
                    <template slot-scope="scope">{{scope.row.cost_total}}</template>
                </el-table-column>
                <el-table-column align="center" prop="name" label="医保中心基金总额(元)">
                    <template slot-scope="scope">{{scope.row.func_total}}</template>
                </el-table-column>
                <el-table-column align="center" prop="name" label="定点医药机构个人账号总额(元)">
                    <template slot-scope="scope">{{scope.row.func_total}}</template>
                </el-table-column>
                <el-table-column align="center" prop="name" label="医保中心个人账号总额(元)">
                    <template slot-scope="scope">{{scope.row.psn_pay}}</template>
                </el-table-column>
                <el-table-column align="center" prop="name" label="定点医药机构结算笔数">
                    <template slot-scope="scope">{{scope.row.psn_pay}}</template>
                </el-table-column>
                <el-table-column align="center" prop="name" label="医保中心结算笔数">
                    <template slot-scope="scope">{{scope.row.num}}</template>
                </el-table-column>

            </el-table>
            <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :page-sizes="[10, 50, 100]"
                    :page-size="10"
                    background
                    style="margin-top:20px;float: right"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="total"
            >
            </el-pagination>
            <el-dialog title="医保对账" :visible.sync="dialogFormVisible">
                <el-form :model="form" label-width="100px">
                    <el-form-item label="时间" label-width="100px">
                        <el-date-picker v-model="start_time" prefix-icon="el-icon-date"
                                        :editable="false" :clearable="false"
                                        style="width: 200px;" type="date" placeholder="选择开始日期"
                                        format="yyyy-MM-dd"
                                        value-format="yyyy-MM-dd"
                                        align="right"></el-date-picker>
                        -

                        <el-date-picker v-model="end_time" prefix-icon="el-icon-date"
                                       :editable="false" :clearable="false"
                                        style="width: 200px;margin-right:10px;" type="date" placeholder="选择结束日期"
                                        format="yyyy-MM-dd"
                                        value-format="yyyy-MM-dd"
                                        align="right"></el-date-picker>
                    </el-form-item>
                    <el-form-item label="险种类型" :label-width="formLabelWidth">
                        <el-select v-model="insutype" placeholder="请选择" style="width: 200px;">
                            <el-option
                                    v-for="item in insutypes"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="对账类型" :label-width="formLabelWidth">
                        <el-select v-model="check_type" placeholder="请选择" style="width: 200px;">
                            <el-option
                                    v-for="item in options"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>


                  <el-form-item label="清算机构" :label-width="formLabelWidth" v-if="this.$store.getters.xt_user.org.id == 10106">
                    <el-select v-model="query_clr_org" placeholder="请选择" style="width: 200px;">
                      <el-option
                          v-for="item in clrOrgOptions"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value">
                      </el-option>
                    </el-select>
                  </el-form-item>

                  <el-form-item label="清算类别" :label-width="formLabelWidth" v-if="this.$store.getters.xt_user.org.id == 9919">
                    <el-select v-model="clr_type" placeholder="请选择" style="width: 200px;">
                      <el-option
                          v-for="item in clrOptions"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value">
                      </el-option>
                    </el-select>
                  </el-form-item>

                </el-form>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="dialogFormVisible = false">取 消</el-button>
                    <el-button type="primary" @click="confirm">确 定</el-button>
                </div>
            </el-dialog>
        </div>


    </div>
</template>


<script>
  import BreadCrumb from '@/xt_pages/components/bread-crumb'
  import {
    getCheckAccountFormData,
    getDoctorList,
    getExportConsumeDetailList,
    getHisOrderList,
    getList,
    getInitData
  } from '@/api/his/his'
  import { uParseTime } from '@/utils/tools'
  import { fetchAllAdminUsers } from '@/api/doctor'
  import axios from 'axios'

  export default {
    components: {
      BreadCrumb
    },
    data() {
      return {
        form: {},
        crumbs: [
          { path: false, name: '门诊收费' },
          { path: false, name: '医保费用对照' }
        ],
        tableData: [],
        diagnoses:[],
        limit: 10,
        page: 1,
        dialogFormVisible: false,
        total: 0,
        adminUserOptions: [],
        start_time: '',
        end_time: '',
        insutype: '',
        check_type: '',
        keywords: '',
        query_start_time: '',
        query_end_time: '',
        selection:[],
        query_insutype: '',
        query_clr_type: '',
        query_clr_org:'',
        clr_type:'',
        fromData: [],
        options: [
          {
            value: 1,
            label: '总账'
          }, {
            value: 2,
            label: '明细'
          }
        ],clrOrgOptions:[
          {
            value: '440781',
            label: '台山'
          }, {
            value: '440783',
            label: '开平'
          },
        ],
        clrOptions: [
          {
            value: '11',
            label: '门诊'
          }, {
            value: '21',
            label: '住院'
          }, {
            value: '41',
            label: '药店购药'
          }, {
            value: '99',
            label: '其他'
          }, {
            value: '9903',
            label: '异地'
          }
        ],
        insutypes: [
          {
            value: '310',
            label: '职工基本医疗保险'
          }, {
            value: '320',
            label: '公务员医疗补助'
          }, {
            value: '330',
            label: '大额医疗费用补助'
          }, {
            value: '340',
            label: '离休人员医疗保障'
          },
          {
            value: '390',
            label: '城乡居民基本医疗保险'
          }, {
            value: '392',
            label: '城乡居民大病医疗保险'
          }, {
            value: '510',
            label: '生育保险'
          }

          // 1617724800

        ]

      }
    },
    methods: {
      changeInsutype() {
        let params = {
          'page': 1,
          'limit': 10,
          'keywords': this.keywords,
          'insutype': this.query_insutype,
          'clr_type': "11",
          'start_time': this.query_start_time,
          'end_time': this.query_end_time,
        }
        this.tableData = []
        getList(params).then(response => {
          if (response.data.state == 0) {
            this.$message.error(response.data.msg)
            return false
          } else {
            this.tableData = response.data.data.list
            this.total = response.data.data.total
          }
        })

      }, changeClrType(val) {
        if (val != "11"){
          this.tableData = []
          this.total = 0
        }else{
          let params = {
            'page': 1,
            'limit': 10,
            'keywords': this.keywords,
            'insutype': this.query_insutype,
            'clr_type': "11",
            'start_time': this.query_start_time,
            'end_time': this.query_end_time,
          }
          this.tableData = []
          getList(params).then(response => {
            if (response.data.state == 0) {
              this.$message.error(response.data.msg)
              return false
            } else {
              this.tableData = response.data.data.list
              this.total = response.data.data.total
            }
          })
        }
      },
      handleStartTimeChange() {

        let params = {
          'page': 1,
          'limit': 10,
          'keywords': this.keywords,
          'insutype': "",
          'clr_type': "11",
          'start_time': this.query_start_time,
          'end_time': this.query_end_time,
        }
        this.tableData = []
        getList(params).then(response => {
          if (response.data.state == 0) {
            this.$message.error(response.data.msg)
            return false
          } else {
            this.tableData = response.data.data.list
            this.total = response.data.data.total
          }
        })

      }, handleEndTimeChange() {

        let params = {
          'page': 1,
          'limit': 10,
          'keywords': this.keywords,
          'insutype': "",
          'clr_type': "11",
          'start_time': this.query_start_time,
          'end_time': this.query_end_time,
        }
        this.tableData = []
        getList(params).then(response => {
          if (response.data.state == 0) {
            this.$message.error(response.data.msg)
            return false
          } else {
            this.tableData = response.data.data.list
            this.total = response.data.data.total
          }
        })

      },

      searchAction() {
        let params = {
          'page': 1,
          'limit': 10,
          'keywords': this.keywords,
          'insutype': "",
          'clr_type': "11",
          'start_time': "",
          'end_time': "",
        }
        this.tableData = []
        getList(params).then(response => {
          if (response.data.state == 0) {
            this.$message.error(response.data.msg)
            return false
          } else {
            this.tableData = response.data.data.list
            this.total = response.data.data.total
          }
        })

      },
      selectCostInfo(selection, row) {
        this.selection = selection

      }, changeCostInfoTableData(val) {
        this.selection = val
      }, changeAllCostInfoTableData(selection) {
        this.selection = selection


      }, confirm() {
        if (this.check_type == 1) {
          let params = {
            start_time: this.start_time,
            end_time: this.end_time,
            insutype: this.insutype,
            clr_type: this.clr_type,
            clr_optins:this.query_clr_org,
            admin_user_id:this.$store.getters.xt_user.user.id,
          }
          var that = this
            axios.get('http://127.0.0.1:9532/api/checkaccount/get', {
              params: params
            })
              .then(function(response) {
                if (response.data.state == 0) {
                  that.$message.error(response.data.msg)
                  return false
                } else {
                  var result_desc = ''

                  if (response.data.data.stmt_rslt == 0) {
                    result_desc = '对账平'
                  } else if (response.data.data.stmt_rslt == 1) {
                    result_desc = '中心多' + '\n' + response.data.data.stmt_rslt_dscr

                  } else if (response.data.data.stmt_rslt == 2) {
                    result_desc = '机构多' + '\n' + response.data.data.stmt_rslt_dscr
                  }

                  that.$alert(result_desc, '对账结果', {
                    confirmButtonText: '确定',
                    callback: action => {
                      that.dialogFormVisible = false
                    }
                  })

                  that.page = 1
                  that.limit = 10
                  that.keywords = ''
                  that.query_start_time = ''
                  that.query_end_time = ''
                  that.query_insutype = ''
                  that.query_clr_type = ''
                  that.getList()
                }
              })
              .catch(function(error) {

              })



        } else {
          let params = {
            start_time: this.start_time,
            end_time: this.end_time
          }
          var that = this
          axios.get('http://127.0.0.1:9532/api/checkdetailaccount/get', {
            params: params
          })
            .then(function(response) {
              if (response.data.state == 0) {
                that.$message.error(response.data.msg)
                return false
              } else {
                this.page = 1
                this.limit = 10
                this.keywords = ''
                this.getList()
              }
            })
            .catch(function(error) {

            })
        }
      },
      getInsutype(type) {

      },
      fetchAllAdminUsers() {
        fetchAllAdminUsers().then(response => {
          if (response.data.state == 1) {
            this.adminUserOptions = response.data.data.users

          }
        })
      },
      getName(admin_user_id) {
        for (let i = 0; i < this.adminUserOptions.length; i++) {
          if (this.adminUserOptions[i].id == admin_user_id) {
            return this.adminUserOptions[i].name
          }
        }

      },
      getTimes(time) {
        return uParseTime(time, '{y}-{m}-{d}')
      },
      getList() {
        let params = {
          'page': this.page,
          'limit': this.limit,
          'keywords': this.keywords,
          'insutype': this.query_insutype,
          'clr_type': this.query_clr_type,
          'start_time': this.query_start_time,
          'end_time': this.query_end_time
        }
        this.tableData = []
        getList(params).then(response => {
          if (response.data.state == 0) {
            this.$message.error(response.data.msg)
            return false
          } else {
            this.tableData = response.data.data.list
            this.total = response.data.data.total
          }
        })

      },
      handleSizeChange(limit) {
        this.limit = limit
        this.getList()
      },
      handleCurrentChange(page) {
        this.page = page
        this.getList()

      }, getFormData() {
        if (this.selection.length == 0) {
          this.$message.error('请选择要下载的对账记录')
          return
        }

        let params = {
          'start_time': this.getTimes(this.selection[0].start_time),
          'end_time': this.getTimes(this.selection[0].end_time),
          'insutype': this.selection[0].insutype,
          'clr_type': this.selection[0].clr_type,

        }
        getCheckAccountFormData(params).then(response => {
          if (response.data.state == 0) {
            this.$message.error(response.data.msg)
            return false
          } else {
            this.fromData = response.data.data.list

            if(this.selection[0].insutype == "310"){

              var list = []
              for (let i = 0; i < this.fromData.length; i++) {
                // var hifmi_pay = 0.00;
                //
                // if(this.fromData[i].setl_detail.length > 0){
                //   var jsonObj = JSON.parse(this.fromData[i].setl_detail);
                //   for (let i = 0; i < jsonObj.length; i++) {
                //     if (order.fund_pay_type == '310300') {
                //       hifmi_pay = jsonObj[i].fund_payamt
                //     }
                //   }
                // }

                var hifes_pays = [];

                if(this.fromData[i].setl_detail.length > 0){
                  var jsonObj = JSON.parse(this.fromData[i].setl_detail);
                  console.log(jsonObj)
                  for (let i = 0; i < jsonObj.length; i++) {
                    if (jsonObj[i].fund_pay_type == '310100') {
                      hifes_pays.push(jsonObj[i].fund_payamt)
                    }
                  }
                }

                let hifes_pay = 0.00
                if(hifes_pays.length == 2){
                  hifes_pay = hifes_pays[1]
                }

                let obj = {
                  '序号': i+1,
                  '姓名': this.fromData[i].psn_name,
                  '单位名称': this.fromData[i].psn_name,
                  '个人编号': this.fromData[i].psn_no,
                  '门诊流水号': this.fromData[i].mdtrt_id,
                  '挂号日期': this.getTimes(this.fromData[i].settle_accounts_date),
                  '科室名称':  "血透室",
                  '门诊费用': this.fromData[i].medfee_sumamt,
                  '医保支付': this.fromData[i].fund_pay_sumamt,
                  '自费': this.fromData[i].psn_cash_pay,
                  '起付线I': this.fromData[i].act_pay_dedc,
                  '按比例自付II': this.fromData[i].psn_cash_pay,
                  '小计I+II': this.fromData[i].act_pay_dedc + this.fromData[i].psn_cash_pay,
                  '基本统筹基金': this.fromData[i].hifp_pay,
                  '公务员补助': this.fromData[i].cvlserv_pay,
                  '单位补充保险': hifes_pay,
                  '煤矿补充保险': "0.00",
                  "超封顶线费用": "0.00",
                  '大额医疗保险应付': this.fromData[i].hifob_pay,
                  '透析补助': "0.00",
                  '大额合计':  "0.00",
                  '实账支付额': "0.00",
                  '诊断': this.GetDiagnosisName(this.fromData[i].diagnosis_id),
                  "血透次数":this.fromData[i].DialysisCount,
                  "置留管数量":0,
                  "备注":"",

                }
                list.push(obj)
              }
              var insutype_name = ''
              if (this.query_insutype == '310') {
                insutype_name = '职工基本医疗保险'
              } else if (this.query_insutype == '390') {
                insutype_name = '城乡居民基本医疗保险'
              }

              import('@/vendor/Export2Excel').then(excel => {
                const tHeader = ['序号', '姓名', '单位名称','个人编号', '门诊流水号', '挂号日期','科室名称','门诊费用','医保支付','自费', '起付线I','按比例自付II','小计I+II','基本统筹基金','公务员补助','单位补充保险','煤矿补充保险','超封顶线费用','大额医疗保险应付', '透析补助', '大额合计', '实账支付额', '诊断', '血透次数', '置留管数量','备注']
                const filterVal = ['序号', '姓名', '单位名称','个人编号', '门诊流水号', '挂号日期','科室名称','门诊费用','医保支付','自费', '起付线I','按比例自付II','小计I+II','基本统筹基金','公务员补助','单位补充保险','煤矿补充保险','超封顶线费用','大额医疗保险应付', '透析补助', '大额合计', '实账支付额', '诊断', '血透次数', '置留管数量','备注']
                // const filterVal = [ '姓名', '身份证', '个人编号', '门诊流水号', '挂号日期', '起付线', '统筹基金', '个人支付', '个账支付', '现金支付', '总费用', '冲销标志']
                const merges = ['A1:A2', 'B1:B2', 'C1:E1', 'F1:H1', 'I1:K1', 'L1:N1', 'O1:Q1', 'R1:T1', 'U1:W1', 'X1:Z1', 'AA1:AC1', 'AD1:AF1', 'AG1:AI1', 'AJ1:AL1', 'AM1:AO1', 'AP1:AR1', 'AS1:AU1', 'AV1:AX1', 'AY1:BA1', 'BB1:BD1', 'BE1:BG1', 'BH1:BJ1', 'BK1:BM1']

                const data = this.formatJson(filterVal, list)
                excel.export_json_to_excel({
                  header: tHeader,
                  data,
                  filename:this.getTimes(this.selection[0].start_time)+ '~' + this.getTimes(this.selection[0].end_time)+ insutype_name + '对账报表'
                })
              })


            }else{

              var list = []
              for (let i = 0; i < this.fromData.length; i++) {

                var hifmi_pay = 0.00;

                if(this.fromData[i].setl_detail.length > 0){
                  var jsonObj = JSON.parse(this.fromData[i].setl_detail);
                  console.log(jsonObj)
                  for (let i = 0; i < jsonObj.length; i++) {
                      if (jsonObj[i].fund_pay_type == '390200') {
                        hifmi_pay = jsonObj[i].fund_payamt
                      }
                  }
                }




                let obj = {
                  '序号': i+1,
                  '姓名': this.fromData[i].psn_name,
                  '个人编号': this.fromData[i].psn_no,
                  '门诊号': this.fromData[i].mdtrt_id,
                  '挂号日期': this.getTimes(this.fromData[i].settle_accounts_date),
                  '诊断': this.GetDiagnosisName(this.fromData[i].diagnosis_id),
                  '挂号科室': "血透室",
                  '门诊费用': this.fromData[i].medfee_sumamt,
                  '医保支付': this.fromData[i].fund_pay_sumamt,
                  '自费': this.fromData[i].psn_cash_pay,
                  '起付线I': this.fromData[i].act_pay_dedc?this.fromData[i].act_pay_dedc:"0.00",
                  '按比例自付II': this.fromData[i].psn_cash_pay?this.fromData[i].psn_cash_pay:"0.00",
                  "超封顶线费用": "0.00",
                  "合计": parseFloat(this.fromData[i].act_pay_dedc)  + parseFloat(this.fromData[i].psn_cash_pay),
                  '基本统筹基金': this.fromData[i].hifp_pay,
                  '大病保险': hifmi_pay,
                  '医疗救助': this.fromData[i].maf_pay,
                  '实账支付额': "0.00",
                  "血透次数":this.fromData[i].DialysisCount,
                  "置留管数量":0,
                  "备注":"",

                }





                list.push(obj)
              }
              var insutype_name = ''
              if (this.query_insutype == '310') {
                insutype_name = '职工基本医疗保险'
              } else if (this.query_insutype == '390') {
                insutype_name = '城乡居民基本医疗保险'
              }

              import('@/vendor/Export2Excel').then(excel => {
                const tHeader = ['序号', '姓名','个人编号', '门诊号', '挂号日期', '诊断','挂号科室','门诊费用','医保支付','自费', '起付线I', '按比例自付II','超封顶线费用','合计','基本统筹基金','大病保险','医疗救助', '实账支付额', '血透次数', '置留管数量','备注']
                const filterVal = ['序号', '姓名','个人编号', '门诊号', '挂号日期','诊断','挂号科室','门诊费用','医保支付','自费', '起付线I', '按比例自付II','超封顶线费用','合计','基本统筹基金','大病保险','医疗救助', '实账支付额', '血透次数', '置留管数量','备注']
                // const filterVal = [ '姓名', '身份证', '个人编号', '门诊流水号', '挂号日期', '起付线', '统筹基金', '个人支付', '个账支付', '现金支付', '总费用', '冲销标志']
                const merges = ['A1:A2', 'B1:B2', 'C1:E1', 'F1:H1', 'I1:K1', 'L1:N1', 'O1:Q1', 'R1:T1', 'U1:W1', 'X1:Z1', 'AA1:AC1', 'AD1:AF1', 'AG1:AI1', 'AJ1:AL1', 'AM1:AO1', 'AP1:AR1', 'AS1:AU1', 'AV1:AX1', 'AY1:BA1', 'BB1:BD1', 'BE1:BG1', 'BH1:BJ1', 'BK1:BM1']

                const data = this.formatJson(filterVal, list)
                excel.export_json_to_excel({
                  header: tHeader,
                  data,
                  filename:this.getTimes(this.selection[0].start_time)+ '~' + this.getTimes(this.selection[0].end_time)+ insutype_name + '对账报表'
                })
              })






            }


          }
        })

      }, formatJson(filterVal, jsonData) {
        return jsonData.map(v => filterVal.map(j => v[j]))
      },GetDiagnosisName(id){
        for(let i = 0;i < this.diagnoses.length; i++){
          if(this.diagnoses[i].id == id){
            return this.diagnoses[i].class_name
          }
        }
        return ""

      },  getInitData() {
        getInitData().then(response => {
          if (response.data.state == 0) {
            this.$message.error(response.data.msg)
            return false
          } else {
            this.diagnoses = response.data.data.diagnose


          }
        })
      },
    },
    created() {
      this.getList()
      this.fetchAllAdminUsers()
      this.getInitData()

    }
  }
</script>
