<template>
  <div class="L-unitInfo" id="L-contacts-main">
    <div id="L-header-list" class="project-info-title">【联络人列表】</div>
    <section>
      <el-table v-loading="loading" class="tabTwo-table" border :data="tableData" :row-class-name="tableRowClassName" >  <!-- :max-height="tabHeader" -->
        <el-table-column label="联络人姓名" prop="llrxm" />
        <el-table-column label="联络人职务" prop="llrzw" />
        <el-table-column label="电子邮箱" prop="dzyx" />
        <el-table-column label="移动电话" prop="yddh" />
        <el-table-column label="固定电话" prop="gddh" />
        <el-table-column label="联络人编号" prop="llrbh" />
        <el-table-column label="入库时间" prop="dwTimestamp" />
        <el-table-column label="来源机构" prop="dwLyjg" />
      </el-table>
    </section>
  </div>
</template>
<script>
import { getjContacts } from "@/api/jin_ji_hu/enterList"
export default {
  name:"tabTwo",
  data() {
    return {
      tableData:[],
      loading:false,
      tabHeader: null,
    }
  },
  props:{
    creditCode:{
      type:String,
      default:""
    }
  },
  mounted() {
    this.cancalDebounce();
    window.addEventListener('resize', this.cancalDebounce);
    this.getList()
  },
  destroyed() {
    window.removeEventListener('resize', this.cancalDebounce);
  },
  methods:{
    // 修改table背景色
    tableRowClassName({row, rowIndex}){
      if (rowIndex % 2 !== 0) {
        return 'evenNumber-row';
      }
      return '';
    },
    // 查询联络人列表
    getList(){
      this.loading = true;
      getjContacts({tyshxydm: this.creditCode || this.$store.state.user.name}).then(res=>{
        this.tableData = res.data
        this.loading = false;
      })
    },
    // 屏幕尺寸变化
    cancalDebounce(){
      const element = document.getElementById('L-contacts-main'); // 通过元素的 ID 获取元素
      const header = document.getElementById('L-header-list'); // 通过元素的 ID 获取元素
      const elementHeight = element.offsetHeight;
      const headerHeight = header.offsetHeight;
      this.tabHeader = elementHeight - headerHeight;
    }
  },
}
</script>
