<template>
  <div class="app-container rela-container">
    <div class="common-title">高管</div>
    <div class="table-item">
      <el-table
        :data="tableData"
        border
        style="width: 100%"
        :default-sort = "{prop: 'date', order: 'descending'}"
      >
        <el-table-column label="序号" width="55" align="left">
          <template slot-scope="scope">{{ scope.row.serial }}</template>
        </el-table-column>
        <el-table-column
          prop="userName"
          label="姓名"></el-table-column>
        <el-table-column
          prop="userJob"
          label="职务"></el-table-column>
        <el-table-column label="序号" width="55" align="left">
          <template slot-scope="scope">{{ scope.row.userNames?scope.row.serials:'' }}</template>
        </el-table-column>
        <el-table-column
          prop="userNames"
          label="姓名"></el-table-column>
        <el-table-column
          prop="userJobs"
          label="职务"></el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import {keymembers} from "@/api/detail/party-a/overview"

export default {
  name: 'Senior',
  props: ['companyId'],
  data() {
    return {
      queryParams: {
        cid: this.companyId,
        pageNum: 1,
        pageSize: 100
      },
      //表格数据
      tableData:[]
    }
  },
  created() {
    this.handleQuery()
  },
  mounted() {
  },
  methods: {
    async handleQuery(){
      let res = await keymembers(this.queryParams)
      if(res.code==200){
        let tempRows = []
        if(res.rows&&res.rows.length>0){
          let arrLength = res.rows.length%2==0?(res.rows.length/2):(Math.floor(res.rows.length/2)+1)
          for(let i=0; i<arrLength; i++){
            let obj = {
              serial: 2*i+1,
              userName:res.rows[2*i]?res.rows[2*i].name:'',
              userJob:res.rows[2*i]?res.rows[2*i].jobTitle:'',
              serials: 2*i+2,
              userNames:res.rows[2*i+1]?res.rows[2*i+1].name:'',
              userJobs:res.rows[2*i+1]?res.rows[2*i+1].jobTitle:''
            }
            tempRows.push(obj)
          }
        }
        this.tableData = tempRows
      }
    }
  }
}
</script>

<style lang="scss" scoped>
  .rela-container{
    margin: 0;
    padding: 24px 16px;
    background: #FFFFFF;
    border-radius: 4px;
    .table-item{
      margin-top: 16px;
      ::v-deep .el-table--border .el-table__cell{
        border-bottom: 0;
      }
    }
  }
</style>
