<template>
  <div>
    <div class="op">
      <div class="nam">
        <el-input v-model="personName" size="mini" placeholder="请输入姓名"></el-input>
      </div>
      <div class="idc">
        <el-input v-model="idcard" size="mini" placeholder="请输入身份证号"></el-input>
      </div>
      <el-button type="primary" size="mini" style="background:#148A9B;margin-left:10px" icon="el-icon-search" @click="serch">搜索</el-button>
    </div>

  <el-table
    :data="tableData"
    style="width: 100%"
   >
    <el-table-column
      prop="personNum"
      label="个人编号" width="90">
    </el-table-column>
    <el-table-column
      prop="idcard"
      label="身份证" width="170">
    </el-table-column>
     <el-table-column
      prop="name"
      label="姓名">
    </el-table-column>
     <el-table-column
      prop="townName"
      label="镇">
    </el-table-column>
     <el-table-column
      prop="villageName"
      label="村">
    </el-table-column>
    <el-table-column
      prop="personType"
      label="人员类别">
    </el-table-column>
    <el-table-column
      prop="grade"
      label="缴费档次">
    </el-table-column>
    <el-table-column
      prop="gradeType"
      label="应缴类型">
    </el-table-column>
    <el-table-column
      prop="personGrade"
      label="个人应缴">
    </el-table-column>
    <el-table-column
      prop="subsidy"
      label="个级财政补助"  width="70">
    </el-table-column>
    <el-table-column
      prop="otherPay"
      label="代缴金额">
    </el-table-column>
    <el-table-column
      prop="payDate"
      label="对应费款所属期" width="80">
    </el-table-column>
    <el-table-column
      prop="insuranceType"
      label="险种类型">
    </el-table-column>
    <el-table-column
      prop="chargWay"
      label="收缴方式">
    </el-table-column>
    <el-table-column
      prop="arrivalFlag"
      label="足额到账标志" width="110">
    </el-table-column>
    <el-table-column
      prop="arrivalTime"
      label="足额到账年月" width="110">
    </el-table-column>
    <el-table-column
      prop="collectWay"
      label="征收方式">
    </el-table-column>

    <el-table-column
      prop="bankNo"
      label="银行编号">
    </el-table-column>
    <el-table-column
      prop="bankAccount"
      label="银行账号">
    </el-table-column>
  </el-table>
    <el-pagination
      class="pone"
      :page-size='10'
      layout="total, prev, pager, next, jumper"
      :total="totals"
      :current-page.sync="Page"
      @current-change="current_change">
    </el-pagination>


  </div>
</template>



<style>
  .op{
    display: flex;
    align-items: center;

  }
  .idc{

    width: 200px
  }
  .nam{
    margin-right: 20px
  }
  .el-table .warning-row {
    background: oldlace;
  }

  .el-table .success-row {
    background: #f0f9eb;
  }
</style>
<script>
  import CryptoJS from 'crypto-js'
  import { Loading } from 'element-ui';
  import {formatDate} from '../../utils/datetime'
  export default {
    data() {
      return {
        Page: 1,
        totals: 0,
        idcard:"",
        personName:"",
        formLabelWidth:10,
        dialogFormVisible:false,
        form:{},
        tableData: [],
      }
    },
    methods: {
      serch(){
        var data={
          idcard:this.idcard?this.Encrypt(this.idcard):"",
          personName:this.personName?this.Encrypt(this.personName):"",
        }
        Loading.service();
        this.$api.getlist.listPayInfo(data).then((res) => {
          let loadingInstance = Loading.service();
          this.$nextTick(() => { // 以服务的方式调用的 Loading 需要异步关闭
            loadingInstance.close();
          });
          for(var i in  res.data.list){
            res.data.list[i].idcard=this.decrypt(res.data.list[i].idcard)
            res.data.list[i].name=this.decrypt(res.data.list[i].name)
            res.data.list[i].arrivalTime = formatDate(res.data.list[i].arrivalTime)

          }
          this.tableData=res.data.list
          this.totals=res.data.total
          this.page=res.data.total.pageNum
        }).catch((res) => {
          let loadingInstance = Loading.service();
          this.$nextTick(() => { // 以服务的方式调用的 Loading 需要异步关闭
            loadingInstance.close();
          });
        });
      },
      current_change(ss){
        var data={
          pageNum:ss,
          pageSize:10,
          idcard:this.idcard?this.Encrypt(this.idcard):"",
          personName:this.personName?this.Encrypt(this.personName):"",
        }
        Loading.service();
        this.$api.getlist.listPayInfo(data).then((res) => {
          let loadingInstance = Loading.service();
          this.$nextTick(() => { // 以服务的方式调用的 Loading 需要异步关闭
            loadingInstance.close();
          });
          for(var i in  res.data.list){
            res.data.list[i].idcard=this.decrypt(res.data.list[i].idcard)
            res.data.list[i].name=this.decrypt(res.data.list[i].name)
            res.data.list[i].arrivalTime = formatDate(res.data.list[i].arrivalTime);

          }
          this.tableData=res.data.list
          this.totals=res.data.total
          this.page=res.data.total.pageNum
        }).catch((res) => {
          let loadingInstance = Loading.service();
          this.$nextTick(() => { // 以服务的方式调用的 Loading 需要异步关闭
            loadingInstance.close();
         });
        });
      },
    decrypt(word){
      var key = CryptoJS.enc.Utf8.parse("KkweInfo23255625");
      var decrypt = CryptoJS.AES.decrypt(word, key, {mode:CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7});
      return CryptoJS.enc.Utf8.stringify(decrypt).toString();
    },
    Encrypt(word) { //aes加密
      var key = CryptoJS.enc.Utf8.parse("KkweInfo23255625");
      let srcs = CryptoJS.enc.Utf8.parse(word);
      let encrypted = CryptoJS.AES.encrypt(srcs, key, {
        mode: CryptoJS.mode.ECB,
        padding: CryptoJS.pad.Pkcs7
      });
      return encrypted.toString();
    }
    },
    created() {
          this.$api.getlist.listPayInfo().then((res) => {
          var list = res.data.list;
          for(var i in list){
            res.data.list[i].idcard=this.decrypt(res.data.list[i].idcard)
            res.data.list[i].name=this.decrypt(res.data.list[i].name)
            res.data.list[i].arrivalTime = formatDate(res.data.list[i].arrivalTime);

          }
          this.tableData=res.data.list
          this.totals=res.data.total
          this.page=res.data.total.pageNum
        }).catch((res) => {
            let loadingInstance = Loading.service();
            this.$nextTick(() => { // 以服务的方式调用的 Loading 需要异步关闭
             loadingInstance.close();
          });
        });
    }

  }

</script>
