<template>
  <div class="div_main">
    <div ref="div_search"
         class="div_search">
      <el-form :inline="true"
               :model="searchForm"
               ref="ref_searchform"
               :label-width="'110px'">
        <div>
          <el-form-item label="所属网格"
                        prop="gridId">
            <el-cascader class="customer_cascader"
                         ref="myCascader"
                         v-model="agencyIdArray"
                         :options="orgOptions"
                         :props="orgOptionProps"
                         :show-all-levels="false"
                         @change="handleChangeAgency"></el-cascader>
            <!-- <el-select v-model.trim="searchForm.gridId"
                       placeholder="请选择"
                       size="small"
                       clearable
                       class="resi-cell-select"
                       @change="handleChangeGrid">
              <el-option v-for="item in optionsG"
                         :key="item.value"
                         :label="item.label"
                         :value="item.value">
              </el-option>
            </el-select> -->

          </el-form-item>
          <el-form-item label="所属小区"
                        prop="neighborId">
            <el-select v-model.trim="searchForm.neighborId"
                       placeholder="请选择小区"
                       size="small"
                       clearable
                       class="resi-cell-select"
                       @clear="handleClearVillage"
                       @change="handleChangeV">
              <el-option v-for="item in optionsV"
                         :key="item.value"
                         :label="item.label"
                         :value="item.value">
              </el-option>
            </el-select>
            <el-select v-model.trim="searchForm.buildingId"
                       placeholder="楼号"
                       size="small"
                       clearable
                       style="width: 120px;"
                       class="resi-cell-select"
                       @clear="handleClearBuild"
                       @change="handleChangeB">
              <el-option v-for="item in optionsB"
                         :key="item.value"
                         :label="item.label"
                         :value="item.value">
              </el-option>
            </el-select>
            <el-select v-model.trim="searchForm.unitId"
                       placeholder="单元"
                       size="small"
                       clearable
                       style="width: 120px;"
                       class="resi-cell-select"
                       @click="handleClearDan"
                       @change="handleChangeD">
              <el-option v-for="item in optionsD"
                         :key="item.value"
                         :label="item.label"
                         :value="item.value">
              </el-option>
            </el-select>
            <el-select v-model.trim="searchForm.houseId"
                       placeholder="房号"
                       size="small"
                       clearable
                       style="width: 120px;"
                       class="resi-cell-select">
              <el-option v-for="item in optionsH"
                         :key="item.value"
                         :label="item.label"
                         :value="item.value">
              </el-option>
            </el-select>

          </el-form-item>

          <el-form-item label="姓名"
                        prop="name">
            <el-input v-model="searchForm.name"
                      size="small"
                      class="list_item_width_1"
                      clearable
                      placeholder="请输入姓名">
            </el-input>

          </el-form-item>
          <el-form-item label="手机号"
                        prop="mobile">
            <el-input v-model="searchForm.mobile"
                      size="small"
                      class="list_item_width_1"
                      clearable
                      placeholder="请输入手机号">
            </el-input>

          </el-form-item>
          <el-form-item label="证件号"
                        prop="idCard">
            <el-input v-model="searchForm.idCard"
                      size="small"
                      class="list_item_width_1"
                      clearable
                      placeholder="请输入身份证号或护照号">
            </el-input>

          </el-form-item>
          <el-form-item label="年龄"
                        prop="age">
            <inputRange v-model="searchForm.age"
                        type="num"
                        @change="handleAgeChange" />

          </el-form-item>

          <el-form-item label="疫苗接种针次"
                        style="margin-left:20px"
                        prop="vaccineCount">
            <el-input v-model="searchForm.vaccineCount"
                      size="small"
                      class="list_item_width_1"
                      clearable
                      placeholder="请输入接种针次">
            </el-input>

          </el-form-item>
          <el-form-item label="核酸检测次数"
                        prop="natCount">
            <el-input v-model="searchForm.natCount"
                      size="small"
                      class="list_item_width_1"
                      clearable
                      placeholder="请输入检测次数">
            </el-input>

          </el-form-item>

          <el-form-item label="核酸检测时间"
                        label-width="110px"
                        prop="natStartDate">
            <el-date-picker v-model="timeRange"
                            size="small"
                            type="daterange"
                            @change="handleTimeChange"
                            format="yyyy-MM-dd"
                            value-format="yyyy-MM-dd"
                            range-separator="至"
                            start-placeholder="开始时间"
                            end-placeholder="结束时间">
            </el-date-picker>

          </el-form-item>

          <el-button style="margin-left:30px"
                     size="small"
                     class="diy-button--search"
                     @click="handleSearch">查询</el-button>
          <el-button style="margin-left:10px"
                     size="small"
                     class="diy-button--reset"
                     @click="resetSearch">重置</el-button>
        </div>
      </el-form>
    </div>
    <div class="div_table">
      <div class="div_btn">

        <el-button style="float:left;margin-left:10px"
                   class="diy-button--reset"
                   size="small"
                   @click="handleExport">导出</el-button>

      </div>
      <el-table class="table"
                :data="tableData"
                border
                ref="ref_table"
                :height="tableHeight"
                v-loading="tableLoading"
                :header-cell-style="{background:'#2195FE',color:'#FFFFFF'}"
                style="width: 100%">
        <el-table-column label="序号"
                         header-align="center"
                         align="center"
                         type="index"
                         width="50"></el-table-column>

        <el-table-column prop="name"
                         header-align="center"
                         align="center"
                         label="姓名"
                         width="120">
        </el-table-column>
        <el-table-column prop="gridName"
                         header-align="center"
                         align="center"
                         label="所属网格"
                         show-overflow-tooltip
                         min-width="180">
        </el-table-column>
        <el-table-column prop="houseName"
                         header-align="center"
                         align="center"
                         label="所属房屋"
                         show-overflow-tooltip
                         min-width="180">
        </el-table-column>
        <el-table-column prop="mobile"
                         header-align="center"
                         align="center"
                         label="手机号"
                         width="180">
        </el-table-column>
        <el-table-column prop="idCard"
                         header-align="center"
                         align="center"
                         label="证件号"
                         width="180">
        </el-table-column>
        <el-table-column prop="birthDay"
                         header-align="center"
                         align="center"
                         label="出生日期"
                         width="140">
        </el-table-column>
        <el-table-column prop="vaccineCount"
                         header-align="center"
                         align="center"
                         label="疫苗接种针次"
                         width="140">
        </el-table-column>
        <el-table-column prop="natCount"
                         header-align="center"
                         align="center"
                         label="核酸检测次数"
                         width="140">
        </el-table-column>

        <el-table-column label="操作"
                         fixed="right"
                         width="140"
                         header-align="center"
                         align="center"
                         class="operate">
          <template slot-scope="scope">

            <el-button v-if="btnAuths.epidemic_prevention_view"
                       type="text"
                       class="div-table-button--detail"
                       size="small"
                       @click="handleDetail(scope.row)">查看</el-button>
            <!-- <el-button type="text"
                       class="div-table-button--edit"
                       size="small"
                       @click="handleEdit(scope.row)">修改</el-button>

            <el-button type="text"
                       class="div-table-button--delete--noline "
                       size="small"
                       @click="handleDelete(scope.row)">删除</el-button> -->

          </template>
        </el-table-column>
      </el-table>
      <div>
        <el-pagination @size-change="handleSizeChange"
                       @current-change="handleCurrentChange"
                       :current-page.sync="pageNo"
                       :page-sizes="[20, 50, 100, 200]"
                       :page-size="pageSize"
                       layout="sizes, prev, pager, next, total"
                       :total="total">
        </el-pagination>
      </div>
    </div>

    <!-- 修改弹出框 -->
    <el-dialog :visible.sync="formShow"
               :close-on-click-modal="false"
               :close-on-press-escape="false"
               :title="formTitle"
               width="1150px"
               top="5vh"
               class="dialog-h"
               @closed="handleCnalceForm">
      <div class="dialog-h-content scroll-h">

        <div v-if="btnAuths.epidemic_prevention_view_real_data"
             class="div_tuomin">
          <el-button size="mini"
                     class="diy-button--search"
                     @click="handleTuomin">显示脱敏信息</el-button>
        </div>

        <div class="m-row">
          <div class="m-row-info">

            <div class="info-prop">
              <span class="info-title-2">姓名：</span>
              <span>{{ formDetail.name||'--'  }}</span>
            </div>

            <div class="info-prop">
              <span class="info-title-2">所属网格：</span>
              <span>{{ formDetail.gridName||'--' }}</span>
            </div>

            <div class="info-prop">
              <span class="info-title-2">所属房屋：</span>
              <span>{{ formDetail.houseName||'--' }}</span>
            </div>
          </div>
          <div class="m-row-info">
            <div class="info-prop">
              <span class="info-title-2">手机号：</span>
              <span>{{ formDetail.showMobile||'--'  }}</span>
            </div>
            <div class="info-prop">
              <span class="info-title-2">证件号：</span>
              <span>{{ formDetail.showIdCard||'--'  }}</span>
            </div>
            <div class="info-prop">
              <span class="info-title-2">疫苗接种针次：</span>
              <span>{{ formDetail.vaccineCount||'--'  }}</span>
            </div>
          </div>
          <div class="m-row-info">
            <div class="info-prop">
              <span class="info-title-2">核酸检测次数：</span>
              <span>{{ formDetail.natCount||'--'  }}</span>
            </div>

          </div>
        </div>

        <div style="padding: 0 20px;">
          <el-tabs v-model="activeName">
            <el-tab-pane label="疫苗接种信息"
                         name="first">
              <el-table class="table"
                        :data="vaccineList"
                        border
                        height="400"
                        :header-cell-style="{background:'#2195FE',color:'#FFFFFF'}"
                        style="width: 100%">
                <el-table-column label="序号"
                                 header-align="center"
                                 align="center"
                                 type="index"
                                 width="50"></el-table-column>

                <el-table-column prop="vaccinateTime"
                                 header-align="center"
                                 align="center"
                                 label="接种时间"
                                 width="140">
                </el-table-column>
                <el-table-column prop="address"
                                 header-align="center"
                                 align="center"
                                 label="接种地点"
                                 min-width="180">
                </el-table-column>
                <el-table-column prop="manufactor"
                                 header-align="center"
                                 align="center"
                                 label="疫苗厂家"
                                 width="240">
                </el-table-column>
              </el-table>
            </el-tab-pane>
            <el-tab-pane label="核酸检测信息"
                         name="second">
              <el-table class="table"
                        :data="natList"
                        border
                        height="400"
                        :header-cell-style="{background:'#2195FE',color:'#FFFFFF'}"
                        style="width: 100%">
                <el-table-column label="序号"
                                 header-align="center"
                                 align="center"
                                 type="index"
                                 width="50"></el-table-column>

                <el-table-column prop="testTime"
                                 header-align="center"
                                 align="center"
                                 label="检测时间"
                                 width="150">
                </el-table-column>
                <el-table-column prop="address"
                                 header-align="center"
                                 align="center"
                                 label="检测机构"
                                 min-width="180">
                </el-table-column>
                <el-table-column prop="result"
                                 header-align="center"
                                 align="center"
                                 label="检测结果"
                                 width="240">
                </el-table-column>
              </el-table>
            </el-tab-pane>
            <el-tab-pane label="行程信息"
                         name="third">
              <el-table class="table"
                        :data="tripList"
                        border
                        height="400"
                        :header-cell-style="{background:'#2195FE',color:'#FFFFFF'}"
                        style="width: 100%">
                <el-table-column label="序号"
                                 header-align="center"
                                 align="center"
                                 type="index"
                                 width="50"></el-table-column>

                <el-table-column prop="fromRegion"
                                 header-align="center"
                                 align="center"
                                 label="来自地区"
                                 show-overflow-tooltip
                                 min-width="100">
                </el-table-column>
                <el-table-column prop="arrivalTime"
                                 header-align="center"
                                 align="center"
                                 label="来到本地时间"
                                 width="140">
                </el-table-column>
                <el-table-column prop="leaveTime"
                                 header-align="center"
                                 align="center"
                                 label="离开本地时间"
                                 width="140">
                </el-table-column>
                <el-table-column prop="noticeTime"
                                 header-align="center"
                                 align="center"
                                 label="最近一次通知时间"
                                 width="140">
                </el-table-column>
                <el-table-column prop="remark"
                                 header-align="center"
                                 align="center"
                                 label="备注"
                                 show-overflow-tooltip
                                 width="120">
                </el-table-column>
              </el-table>
            </el-tab-pane>
          </el-tabs>
        </div>
      </div>
      <div class="resi-btns">
        <el-button size="small"
                   @click="handleCnalceForm">关 闭</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>

import natForm from './natInfo/natForm'
import inputRange from '@/views/components/rangeInput.vue'

import { requestPost } from "@/js/dai/request";
import { mapGetters } from 'vuex'

let loading // 加载动画
export default {
  data () {
    let orgOptionProps = {
      multiple: false,
      value: 'agencyId',
      label: 'agencyName',
      children: 'subAgencyList',
      checkStrictly: true
    }
    return {
      loading: false,
      total: 0,
      pageSize: 20,
      pageNo: 0,
      tableLoading: false,
      activeName: 'first',
      agencyId: '',
      sHeight: 0,
      timeRange: [],
      agencyIdArray: [],
      orgOptions: [],
      orgOptionProps,

      searchForm: {
        agencyId: '',
        gridId: '',
        neighborId: '',
        buildingId: '',
        unitId: '',
        houseId: '',
        name: '',
        mobile: '',
        idCard: '',
        vaccineCount: '',
        natCount: '',
        age: {},
        startBirthDay: '',
        endBirthDay: '',
        natStartDate: '',
        natEndDate: '',
      },
      formDetail: {
        name: '',
        gridName: '',
        houseName: '',
        mobile: '',
        idCard: '',
        showMobile: '',
        showIdCard: '',
        vaccineCount: '',
        natCount: ''
      },
      vaccineList: [], // 疫苗接种
      natList: [], // 核酸检测
      tripList: [], // 行程信息

      optionsV: [],
      optionsB: [],
      optionsH: [],
      optionsD: [],
      optionsG: [],
      tableData: [],

      //form相关
      formShow: false,
      formTitle: '新增',
      selRowId: '',

      btnAuths: {
        epidemic_prevention_view: false, //查看
        epidemic_prevention_view_real_data: false, //显示脱敏信息

      },

    }
  },
  components: {
    natForm, inputRange
  },
  async created () {

  },
  async mounted () {
    this.updateBtnAuths();

    this.getOrgTreeList()
    // this.getGridList()
    this.getValiheList()
    await this.loadTable()
    this.sHeight = this.$refs.div_search.offsetHeight + 270
  },
  activated () {
    this.$refs['ref_table'].doLayout()
  },

  methods: {
    handleTimeChange (time) {
      if (time) {
        this.searchForm.natStartDate = time[0]
        this.searchForm.natEndDate = time[1]

      } else {
        this.searchForm.natStartDate = ''
        this.searchForm.natEndDate = ''
      }
    },
    // 更新按钮权限
    updateBtnAuths () {
      let rot = this.$route;
      if (Array.isArray(rot.meta.btns)) {
        console.log('btns', rot.meta.btns)
        rot.meta.btns.forEach((item) => {
          this.btnAuths[item.permissions] = true;
        });
      }
    },
    async handleTuomin () {
      const url = "/data/aggregator/epmetuser/detailByType";

      const { data, code, msg } = await requestPost(url, {
        id: this.selRowId,
        type: "JMFYXX",
      });

      if (code === 0) {
        this.$set(this.formDetail, 'showMobile', data.mobile)
        this.$set(this.formDetail, 'showIdCard', data.idCard)
      } else {
        this.$message.error(msg);
      }

    },

    handleAgeChange (val) {
      console.log('val----age---', val)
      if (val.start) {
        const e = this.computedBirth(val.start)
        this.searchForm.endBirthDay = e

      } else {
        this.searchForm.endBirthDay = ''
      }
      if (val.end) {
        const s = this.computedBirth(val.end)
        this.searchForm.startBirthDay = s
      } else {
        this.searchForm.startBirthDay = ''
      }
    },

    computedBirth (age) {
      let now = new Date();
      let nowYear = now.getFullYear();
      let nowMonth = now.getMonth() + 1;
      let nowDay = now.getDate(); // 按照减法原理，先day相减，不够向month借；然后month相减，不够向year借；最后year相减。
      let subYear = nowYear - age
      if (nowMonth < 10) {
        nowMonth = '0' + nowMonth
      }
      if (nowDay < 10) {
        nowDay = '0' + nowDay
      }
      console.log(subYear + '-' + nowMonth + '-' + nowDay);
      return subYear + '-' + nowMonth + '-' + nowDay
    },
    handleCnalceForm () {

      this.vaccineList = []
      this.natList = []
      this.tripList = []
      this.activeName = 'first'
      this.formShow = false

    },
    handleSearch () {
      this.loadTable()
    },
    handleClearVillage () {
      this.searchForm.buildingId = ''
      this.searchForm.unitId = ''
      this.searchForm.houseId = ''
    },
    handleClearBuild () {
      this.searchForm.buildingId = ''
      this.searchForm.unitId = ''
      this.searchForm.houseId = ''
    },
    handleClearDan () {
      this.searchForm.unitId = ''
      this.searchForm.houseId = ''
    },

    handleChangeAgency (val) {
      let obj = this.$refs["myCascader"].getCheckedNodes()[0].data
      if (obj) {
        if (obj.level === 'grid') {
          this.searchForm.gridId = this.agencyIdArray.length > 0 ? this.agencyIdArray[this.agencyIdArray.length - 1] : '';
          this.searchForm.agencyId = ''
        } else {
          this.searchForm.agencyId = this.agencyIdArray.length > 0 ? this.agencyIdArray[this.agencyIdArray.length - 1] : '';
          this.searchForm.gridId = ''
        }

      } else {
        this.searchForm.agencyId = ''
        this.searchForm.gridId = ''
      }

      this.searchForm.neighborId = ''
      this.searchForm.buildingId = ''
      this.searchForm.unitId = ''
      this.searchForm.houseId = ''
      this.getValiheList()
    },

    handleChangeGrid (val) {
      console.log('val', val)
      this.searchForm.neighborId = ''
      this.searchForm.buildingId = ''
      this.searchForm.unitId = ''
      this.searchForm.houseId = ''
      this.getValiheList()
    },
    handleChangeV (val) {
      console.log('val', val)
      this.searchForm.buildingId = ''
      this.searchForm.unitId = ''
      this.searchForm.houseId = ''
      this.getBuildList()
    },
    handleChangeB (val) {
      console.log('val', val)
      this.searchForm.unitId = ''
      this.searchForm.houseId = ''
      this.getUniList()
    },
    handleChangeD (val) {
      console.log('val', val)
      this.searchForm.houseId = ''
      this.getHouseList()
    },
    getOrgTreeList () {
      const { user } = this.$store.state
      this.$http
        .post('/gov/org/customeragency/agencygridtree', {})
        .then(({ data: res }) => {
          if (res.code !== 0) {
            return this.$message.error(res.msg)
          } else {
            console.log('获取组织树成功', res.data)
            this.orgOptions = []
            this.orgOptions.push(res.data)
          }
        })
        .catch(() => {
          return this.$message.error('网络错误')
        })
    },
    getGridList () {
      const { user } = this.$store.state
      this.$http
        .post('/gov/org/customergrid/gridoption', { agencyId: user.agencyId, purpose: 'query' })
        .then(({ data: res }) => {
          if (res.code !== 0) {
            return this.$message.error(res.msg)
          } else {

            this.optionsG = res.data
          }
        })
        .catch(() => {
          return this.$message.error('网络错误')
        })
    },
    getValiheList () {
      const { user } = this.$store.state
      this.$http
        .post('/gov/org/icneighborhood/neighborhood-options', {
          gridId: this.searchForm.gridId,
          agencyId: this.searchForm.agencyId
          // agencyId: user.agencyId
        })
        .then(({ data: res }) => {
          if (res.code !== 0) {
            return this.$message.error(res.msg)
          } else {

            this.optionsV = res.data
          }
        })
        .catch(() => {
          return this.$message.error('网络错误')
        })
    },
    getBuildList () {
      this.$http
        .post('/gov/org/icbuilding/buildingoption', {
          neighborHoodId: this.searchForm.neighborId
        })
        .then(({ data: res }) => {
          if (res.code !== 0) {
            return this.$message.error(res.msg)
          } else {

            this.optionsB = res.data
          }
        })
        .catch(() => {
          return this.$message.error('网络错误')
        })
    },
    getUniList () {
      this.$http
        .post('/gov/org/icbuildingunit/unitoption', {
          buildingId: this.searchForm.buildingId
        })
        .then(({ data: res }) => {
          if (res.code !== 0) {
            return this.$message.error(res.msg)
          } else {

            this.optionsD = res.data
          }
        })
        .catch(() => {
          return this.$message.error('网络错误')
        })
    },
    getHouseList () {
      this.$http
        .post('/gov/org/ichouse/houseoption', { unitId: this.searchForm.unitId })
        .then(({ data: res }) => {
          if (res.code !== 0) {
            return this.$message.error(res.msg)
          } else {

            this.optionsH = res.data
          }
        })
        .catch(() => {
          return this.$message.error('网络错误')
        })
    },

    async loadTable () {
      this.tableLoading = true

      const url = "/epmetuser/epidemicPrevention/page"
      // const url = "http://yapi.elinkservice.cn/mock/245/gov/org/placeorg/getlist"
      let params = {
        pageSize: this.pageSize,
        pageNo: this.pageNo,
        ...this.searchForm
      }

      const { data, code, msg } = await requestPost(url, params)

      if (code === 0) {
        this.total = data.total
        this.tableData = data.list

        this.tableData.forEach(item => {
          if (item.time) {
            let timeArray = item.time.split(' ')
            item.time = timeArray[0]
          }

        });
      } else {
        this.$message.error(msg)
      }
      this.tableLoading = false
    },
    async getDetailInfo (id) {

      const url = "/epmetuser/epidemicPrevention/detail"
      let params = {
        id
      }

      const { data, code, msg } = await requestPost(url, params)

      if (code === 0) {
        this.formDetail = data
      } else {
        this.$message.error(msg)
      }
    },
    async getDetailList (id) {

      const url = "/epmetuser/epidemicPrevention/info"
      let params = {
        id
      }

      const { data, code, msg } = await requestPost(url, params)

      if (code === 0) {
        const { vaccineList, natList, tripList } = data
        this.vaccineList = vaccineList
        this.natList = natList
        this.tripList = tripList
      } else {
        this.$message.error(msg)
      }
    },
    diaClose () {
      // this.$refs.ref_form.resetData()
      this.formShow = false
    },


    async handleDetail (row) {
      this.selRowId = row.id
      await this.getDetailInfo(row.id)
      await this.getDetailList(row.id)
      this.formTitle = '详情'
      this.formShow = true
      // this.$nextTick(() => {
      //   this.$refs.ref_form.initForm('detail', row.natId, this.agencyId)
      // })
    },

    addFormCancle () {
      this.formShow = false
    },
    addFormOk () {
      this.formShow = false
      this.loadTable()

    },

    async handleDelete (row) {

      this.$confirm("确认删除?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.deleteNat(row)
        })
        .catch(err => {
          if (err == "cancel") {

          }

        });
    },

    async deleteNat (row) {
      const url = "/gov/org/placepatrolteam/del"
      // const url = "http://yapi.elinkservice.cn/mock/245/gov/org/placepatrolteam/del"

      let params = {
        natId: row.natId
      }

      const { data, code, msg } = await requestPost(url, params)

      if (code === 0) {
        this.$message({
          type: "success",
          message: "删除成功"
        });

        this.loadTable()
      } else {
        this.$message.error(msg)
      }
    },

    //重置搜索条件
    resetSearch () {
      this.timeRange = []
      this.agencyIdArray = []
      this.$refs.ref_searchform.resetFields()
      this.searchForm.buildingId = ''
      this.searchForm.unitId = ''
      this.searchForm.houseId = ''
      this.searchForm.age = {}
      this.searchForm.startBirthDay = ''
      this.searchForm.endBirthDay = ''
      this.searchForm.natStartDate = ''
      this.searchForm.natEndDate = ''
      this.pageSize = 20
      this.pageNo = 1
      // this.loadTable()
    },


    //导出表格
    async handleExport () {
      let title = '居民防疫信息'

      const url = "/epmetuser/epidemicPrevention/epidemicPreventionExport"
      let params = {
        pageSize: this.pageSize,
        pageNo: this.pageNo,
        ...this.searchForm
      }
      app.ajax.exportFilePost(
        url,
        params,
        (data, rspMsg) => {
          this.download(data, title + '.xlsx')
        },
        (rspMsg, data) => {
          this.$message.error(rspMsg);
        }
      );

    },

    // 下载文件
    download (data, fileName) {
      if (!data) {
        return
      }

      var csvData = new Blob([data])

      if (window.navigator && window.navigator.msSaveOrOpenBlob) {
        window.navigator.msSaveOrOpenBlob(csvData, fileName);
      }
      // for Non-IE (chrome, firefox etc.)
      else {
        var a = document.createElement('a');
        document.body.appendChild(a);
        a.style = 'display: none';
        var url = window.URL.createObjectURL(csvData);
        a.href = url;
        a.download = fileName;
        a.click();
        a.remove();
        window.URL.revokeObjectURL(url);
      }

    },

    handleSizeChange (val) {
      this.pageSize = val
      this.pageNo = 1
      this.loadTable()
    },
    handleCurrentChange (val) {
      this.pageNo = val
      this.loadTable()
    },

  },
  computed: {
    tableHeight () {
      const h = this.clientHeight - this.sHeight + this.iframeHeigh
      const _h = this.clientHeight - this.sHeight
      return this.$store.state.inIframe ? h : _h

    },

    ...mapGetters(['clientHeight', 'iframeHeight'])
  },
  watch: {

  },
  props: {
    view_real_data: {//显示【显示脱敏信息】按钮
      type: Boolean,
      default: false,
    }
  }
}
</script>
<style lang="scss" scoped >
@import "@/assets/scss/modules/management/epidemic.scss";

.resi-cell-select {
  width: 170px;
  box-sizing: border-box;
  margin-right: 10px;
  &-middle {
    width: 130px;
  }
  &-small {
    width: 88px;
  }
}
.resi-cell-select:last-child {
  margin-right: 0;
}
.min-w180 {
  min-width: 170px;
}

.div_tuomin {
  position: absolute;
  top: 0;
  right: 40px;
  z-index: 1000;
}
</style>

<style lang="scss" scoped>
@import "@/assets/scss/modules/management/detail-main.scss";
</style>

