<template>
  <div class="app-container rela-container">
    <div class="common-title">高管</div>
    <skeleton style="margin-left:16px;" v-if="isSkeleton"></skeleton>
    <div class="table-item" v-else>
      <el-table
        v-if="tableData.length>0"
        :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>
      <no-data v-else/>
    </div>
  </div>
</template>

<script>
import {keymembers} from "@/api/detail/party-a/overview"
import NoData from '../../component/noData'
import skeleton from '@/views/project/projectList/component/skeleton'
export default {
  name: 'Senior',
  props: ['companyId'],
  data() {
    return {
      isSkeleton:true,
      queryParams: {
        cid: this.companyId,
        pageNum: 1,
        pageSize: 100
      },
      //表格数据
      tableData:[]
    }
  },
  components: {
    NoData,skeleton
  },
  created() {
    this.handleQuery()
  },
  mounted() {
  },
  methods: {
    async handleQuery(){
      this.isSkeleton = true;
      let res = await keymembers(this.queryParams)
      if(res.code==200){
        this.isSkeleton = false;
        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>
