<template>
  <div>
    <el-button size="small" type="primary" @click="listData" class="inline-16 normal-btn-width">查 重</el-button>
    <el-dialog title="重复的客户" :visible.sync="dialogTableVisible" append-to-body>
      <el-table :data="duplicateData" :header-cell-style="{background:'#EEEEEE',color:'#333'}" size="mini">
        <el-table-column property="enterprisename" label="客户名称" width="150"></el-table-column>
        <el-table-column property="address" label="客户地址" ></el-table-column>
        <el-table-column property="taxno" label="企业税号" width="150"></el-table-column>
      </el-table>
      <div  class="container normal-panel" style="text-align:right">
        <el-pagination
            background
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-sizes="[10, 20]"
            layout="total,sizes, prev, pager, next, jumper"
            :total="total">
        </el-pagination>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" class="normal-btn-width" size="mini" @click="dialogTableVisible = false" >确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "duplicateCheck",
  props:["data"],
  data(){
    return {
      dialogTableVisible:false,
      duplicateData:[],
      total:0,
      currentPage:0,
      param:{
        "id": 20221208172002,
        "content": {
          "sa_customersid":'',
          "enterprisename":'',
          "taxno":'',
          "address":''
        },
      }
    }
  },
  methods:{
    async listData(){
      console.log(this.data,"数据")
      this.param.content.sa_customersid = this.data.sa_customersid || 0
      this.param.content.enterprisename = this.data.enterprisename
      this.param.content.taxno = this.data.taxno
      this.param.content.address = this.data.address
      const res = await this.$api.requested(this.param)
      if (res.data.length > 0){
        this.dialogTableVisible = true
        this.duplicateData = res.data
        this.total = res.total
        this.currentPage = res.pageNumber
      }else {
        this.$message({
          message: '无重复数据',
          type: 'success'
        });
      }
      this.$emit('checkSuccess',res.data.length)
    },
    handleSizeChange(val) {
      // console.log(`每页 ${val} 条`);
      this.param.content.pageSize = val
      this.listData()
    },
    handleCurrentChange(val) {
      // console.log(`当前页: ${val}`);
      this.param.content.pageNumber = val
      this.listData()
    },
  }
}
</script>

<style scoped>

</style>