<template>
  <div>

    <el-table
      :data="tableData"
      style="width: 100%"
    >
      <el-table-column
        prop="idcard"
        label="身份证号码">
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名">
      </el-table-column>
      <el-table-column
        prop="socialSecurityNumber"
        label="领取方式">
      </el-table-column>
      <el-table-column
        prop="nation"
        label="缴费年限">
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="primary"
            @click="toPdf(scope.$index, scope.row)">导出pdf
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      class="pone"
      :page-size='10'
      layout="total, prev, pager, next, jumper"
      :total="totals"
      :current-page.sync="PageNum"
      @current-change="current_change"
    >
    </el-pagination>
<!--    <el-button type="success" @click="toexcel" style="margin:50px">导出</el-button>-->
  </div>
</template>
<script>
  import {Loading} from 'element-ui';
  import {baseUrl} from "../../utils/global"
  import axios from "axios"
  import Cookies from "js-cookie";

  export default {
    data() {
      return {
        PageNum: 1,
        totals: 0,
        tableData: []
      }
    },
    methods: {
      toPdf(s, d) {
        console.log(d)
        axios.get(baseUrl + '/exportPdf/specialAudit?id=' + d.eventId, {
          headers: {
            "token": Cookies.get("token")
          },
          responseType: 'blob'      //告诉服务器我们需要的响应格式
        })
          .then(res => {
            let a = document.createElement("a");
            let blob = new Blob([res.data], {
              type: 'application/vnd.ms-excel'      //将会被放入到blob中的数组内容的MIME类型
            });
            a.href = URL.createObjectURL(blob);  //生成一个url
            a.download = "西充县城乡居民社会养老保险待遇领取审核表.pdf";
            a.click();
            // let objectUrl = URL.createObjectURL(blob);  //生成一个url
            // window.location.href = objectUrl;   //浏览器打开这个url
          })
          .catch(err => {
            console.log(err);
          });

      },
      current_change(s) {
        var data = {
          "pageNum": s,
          "pageSize": 10
        }
        Loading.service();
        this.$api.getlist.seledysqdc(data).then((res) => {
          let loadingInstance = Loading.service();
          this.$nextTick(() => { // 以服务的方式调用的 Loading 需要异步关闭
            loadingInstance.close();
          });
          if (res.code == 200) {
            this.tableData = res.data.content
            this.totals = res.data.totalSize
            this.pageNum = res.data.pageNum

          }

        }).catch((res) => {

        });
      },
      // toexcel() {
      //   axios.get(baseUrl + '/exportExcel/insuredRegistration', {
      //     headers: {
      //       "token": Cookies.get("token")
      //     },
      //     responseType: 'blob'      //告诉服务器我们需要的响应格式
      //   })
      //     .then(res => {
      //       let a = document.createElement("a");
      //       let blob = new Blob([res.data], {
      //         type: 'application/vnd.ms-excel'      //将会被放入到blob中的数组内容的MIME类型
      //       });
      //       a.href = URL.createObjectURL(blob);  //生成一个url
      //       a.download = "居民养老保险表.xlsx";
      //       a.click();
      //       // let objectUrl = URL.createObjectURL(blob);  //生成一个url
      //       // window.location.href = objectUrl;   //浏览器打开这个url
      //     })
      //     .catch(err => {
      //       console.log(err);
      //     });
      //   //   this.$api.getlist.dccc().then((res) => {
      //   //     let loadingInstance = Loading.service();
      //   //       this.$nextTick(() => { // 以服务的方式调用的 Loading 需要异步关闭
      //   //       loadingInstance.close();
      //   //     });
      //   //    if(res.code==200){
      //   //         this.tableData=res.data.result
      //   //         this.totals=res.data.total
      //   //         }
      //
      //   // }).catch((res) => {
      //
      //   // });
      // }
    },
    created() {
      var data = {
        "pageNum": 1,
        "pageSize": 10
      }
      Loading.service();
      this.$api.getlist.seledysqdc(data).then((res) => {
        let loadingInstance = Loading.service();
        this.$nextTick(() => { // 以服务的方式调用的 Loading 需要异步关闭
          loadingInstance.close();
        });
        if (res.code == 200) {
          this.tableData = res.data.content
          this.totals = res.data.totalSize
        }

      }).catch((res) => {

      });
    },
  }

</script>

