<template>
  <div id="recruit">
    <el-row v-loading="loading">
      <el-col :span="24" class="recruit">
        <el-col :span="24" class="newsTop">
          <el-col :span="18" class="text">
            {{ title }}
          </el-col>
          <el-col :span="6" class="link">
            <el-link :underline="false">MORE<i class="el-icon-circle-plus-outline" style="color:#f8b024;font-weight:bold;margin:0 5px;"></i> </el-link>
          </el-col>
        </el-col>
        <el-col :span="24" class="info">
          <el-col :span="24" class="list">
            <el-col :span="24" class="listTop">
              <el-col :span="6" class="title">标题</el-col>
              <el-col :span="6" class="jobs">职位</el-col>
              <el-col :span="6" class="kong">功能</el-col>
              <el-col :span="6" class="date">发布时间</el-col>
            </el-col>
          </el-col>
          <el-col :span="24" class="listinfo" v-for="(item, index) in recruitList" :key="index">
            <el-col :span="6" class="title">
              <p class="textOver"><span class="dian"></span>{{ item.title }}todo:跳转至公司详情</p>
            </el-col>
            <el-col :span="6" class="jobs">
              <p class="textOver">{{ item.jobs | getJobs }}</p>
            </el-col>
            <el-col :span="6" class="link"><el-link :underline="false">[点击查看详情]todo:跳转至详情</el-link></el-col>
            <el-col :span="6" class="date">{{ item.meta | getDate }}</el-col>
          </el-col>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import _ from 'lodash';
export default {
  name: 'recruit',
  props: {
    recruitList: null,
  },
  components: {},
  data: () => ({
    title: '最新招聘信息',
    loading: true,
    path: undefined,
  }),
  created() {},
  computed: {},
  watch: {
    recruitList: {
      handler(val) {
        if (val) this.loading = false;
      },
    },
  },
  methods: {},
  filters: {
    getJobs(jobs) {
      let returns = null;
      if (jobs.length > 0) {
        for (const item of jobs) {
          returns = returns === null ? `${item.job_name}` : `${returns};${item.job_name}`;
        }
      } else {
        returns = '无招聘职位';
      }
      return returns;
    },
    getDate(meta) {
      let createdAt = _.get(meta, `createdAt`);
      let date = new Date(createdAt)
        .toLocaleDateString()
        .replace('/', '-')
        .replace('/', '-');
      return date;
    },
  },
};
</script>

<style lang="less" scoped>
p {
  padding: 0;
  margin: 0;
}
.textOver {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.newsTop {
  height: 35px;
  line-height: 35px;
  border-bottom: 2px solid #0656d1;
}
.newsTop .text {
  font-size: 20px;
  color: #0874ee;
  font-weight: 600;
  padding: 0 10px;
}
.newsTop .link {
  text-align: right;
  padding: 0 5px;
}
.list {
  margin: 10px 0 0 0;
}
.listTop {
  height: 35px;
  line-height: 35px;
}
.listTop .title {
  width: 215px;
  margin: 0 35px 0 0;
  font-size: 16px;
  color: #181818;
  text-align: center;
  border-bottom: 1px solid #a3c1f1;
}
.listTop .jobs {
  width: 162px;
  margin: 0 35px 0 0;
  font-size: 16px;
  color: #181818;
  text-align: center;
  border-bottom: 1px solid #a3c1f1;
}
.listTop .kong {
  width: 178px;
  margin: 0 35px 0 0;
  text-align: center;
  border-bottom: 1px solid #a3c1f1;
}
.listTop .date {
  width: 140px;
  font-size: 16px;
  color: #181818;
  text-align: center;
  border-bottom: 1px solid #a3c1f1;
}
.listinfo {
  height: 44px;
  line-height: 44px;
  border-bottom: 1px dashed #ccc;
}
.dian {
  display: inline-block;
  width: 4px;
  height: 4px;
  margin: 5px;
  background-color: red;
  border-radius: 90px;
}
.listinfo .title {
  width: 215px;
  margin: 0 35px 0 0;
  font-size: 14px;
  color: #181818;
  text-align: left;
}
.listinfo .jobs {
  width: 162px;
  margin: 0 35px 0 0;
  font-size: 14px;
  color: #181818;
  text-align: center;
}
.listinfo .link {
  width: 178px;
  margin: 0 35px 0 0;
  text-align: center;
}
.listinfo .date {
  width: 140px;
  font-size: 14px;
  color: #181818;
  text-align: center;
}
</style>
