<template>
  <div>
    <div class="count-list">
      <h1>发布企业列表</h1>
    </div>
    <div class="content" v-if="publishCompanies && publishCompanies.list">
      <el-table :data="publishCompanies.list" border>
        <el-table-column :className="`clickable`" prop="companyInfo.name" label="企业名称" width="400">
          <template slot-scope="scope">
            <span @click="goRooterUser(scope.row)">{{scope.row.companyInfo.name}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="isNewUser" label="是否新用户" width="120">
          <template slot-scope="scope">
            <span v-if="scope.row.userInfo.isNewUser">是</span>
            <span v-else>否</span>
          </template>
        </el-table-column>
        <el-table-column prop="total" label="发布岗位总数" width="160"></el-table-column>
        <el-table-column prop="totalOpen" label="开放中" width="120"></el-table-column>
        <el-table-column prop="totalOpen" label="企业会员" width="120">
          <template slot-scope="scope">
            <span v-if="scope.row.userInfo.isVip">是</span>
            <span v-else>否</span>
          </template>
        </el-table-column>
        <el-table-column  label="企业认证" width="120">
          <template slot-scope="scope">
            <span v-if="scope.row.companyInfo.status == '2'">是</span>
            <span v-else>否</span>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <el-pagination
      class="order-footer"
      background
      layout="prev, pager, next"
      :page-size="20"
      :total="Number(publishCompanies.total)"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script>
export default {
  data() {
    return {
      page: 1,
      publishCompanies: ""
    };
  },
  mounted() {
    this.getAuditList();
  },
  methods: {
    async getAuditList() {
      const page = this.page;
      const data = {
        page
      };
      let res = await this.$post(
        "/api/admin/recruit/getPublishCompanies",
        data
      );
      if (res && res.status === 1) {
        this.publishCompanies = res.data;
        console.log(this.publishCompanies);
      }
    },
    handleCurrentChange(val) {
      this.page = val;
      this.getAuditList();
    },
    goCompany(row) {
      window.open(
        this.$store.state.domainConfig.siteUrl + `/company/${row.uid}`
      );
    },
    goRooterUser(row) {
      window.open(
        this.$store.state.domainConfig.siteUrl + `/rooter/user/${row.uid}`
      );
    }
  }
};
</script>

<style lang="scss" scoped>
.count-list {
  padding-bottom: 10px;
  display: flex;
  align-items: center;
}

.count-item {
  margin-right: 20px;
  font-size: 16px;
}

.content {
  white-space: nowrap;
  overflow-x: hidden;
}

.btn {
  width: 80px;
}

.order-footer {
  margin-top: 10px;
}
.clickable {
  cursor: pointer;
  color: #409eff;
}
</style>
