<template>
  <div id="index">
    <el-row>
      <el-col :span="24" class="topMenu">
        <el-col :span="24">
          <el-breadcrumb separator=">">
            <el-breadcrumb-item :to="{ path: '/' }"><i class="el-icon-s-home"></i><span>网站首页</span></el-breadcrumb-item>
            <el-breadcrumb-item>
              <a href="/"><span>招聘信息</span></a>
            </el-breadcrumb-item>
            <el-breadcrumb-item><span>双选会</span></el-breadcrumb-item>
          </el-breadcrumb>
        </el-col>
      </el-col>
      <!-- <el-col :span="24" class="search">
        <el-col :span="12">
          <el-input size="mini" placeholder="请输入企业名称" v-model="searchInfo.corpname" @keyup.enter.native="search()">
            <el-button slot="append" icon="el-icon-search" @click="search()"></el-button>
          </el-input>
        </el-col>
        <el-col :span="12">
          &nbsp;
        </el-col>
      </el-col> -->
      <el-col :span="24" class="list" v-for="(item, index) in list" :key="index">
        <el-col :span="24">
          <el-col :span="20" class="title">
            <el-link :underline="false" @click="$router.push({ path: '/jobfair/detail', query: { id: item.id } })">{{ item.title }}</el-link>
          </el-col>
          <el-col :span="4" class="time">
            {{ item.time }}
          </el-col>
        </el-col>
        <el-col :span="24">
          <el-col :span="18" class="common schname">
            <i class="el-icon-school"></i>
            主办学校：<span>{{ item.organizer }}</span>
          </el-col>
          <el-col :span="6" class="time">
            报名截止日期：<span>{{ item.end_date }}</span>
          </el-col>
        </el-col>
        <el-col :span="24" class="common address">
          <i class="el-icon-location"></i>
          举办地址：<span>{{ item.address }}</span>
        </el-col>
      </el-col>
      <el-col :span="24" class="page">
        <el-pagination @current-change="search" :current-page="currentPage" :page-size="$limit" layout="total, prev, pager, next, jumper" :total="totalRow">
        </el-pagination>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { mapActions, mapState } from 'vuex';
import _ from 'lodash';
export default {
  name: 'JobfairIndex',
  props: {},
  components: {},
  data: () => ({
    searchInfo: {},
    squareUrl: '',
    currentPage: 1,
    list: [],
    totalRow: 0,
  }),
  created() {
    this.search();
  },
  mounted() {},
  computed: {
    type() {
      return this.$route.params.type;
    },
  },
  watch: {
    type: 'search',
  },
  methods: {
    ...mapActions(['jobfairOperation']),
    async search(page) {
      let skip = 0;
      if (page && _.isNumber(page)) {
        skip = (page - 1) * this.$limit;
      }
      let newData = { skip: skip, limit: this.$limit, ...this.searchInfo };
      this.type === 'in' ? (newData['schid'] = this.$site) : '';
      let result = await this.jobfairOperation({ type: 'list', data: newData });
      if (`${result.errcode}` === '0') {
        //给this=>vue的实例下在中的list属性，赋予result。data的值
        this.$set(this, 'list', result.data);
        this.$set(this, `totalRow`, result.total);
      } else {
        this.$message.error(result.errmsg ? result.errmsg : 'error');
      }
    },
  },
};
</script>

<style lang="less" scoped>
.topMenu {
  margin: 0 0 10px 0;
}
.search {
  margin: 15px 0;
}
/deep/.search .el-input__inner {
  border: 2px solid #850000;
  border-radius: 0;
}
/deep/.search .el-input-group__append {
  background: #850000;
  border: 2px solid #850000;
  color: #fff;
  border-radius: 0;
}
.list {
  padding: 5px 0;
  border-bottom: 1px dashed #ccc;
}
.list .title .el-link {
  font-size: 20px;
  color: #000;
}
.list .title .el-link:hover {
  color: #850000;
}
.list .time {
  color: #ff0000;
  text-align: right;
}
.list .common {
  padding: 2px 0;
}
.page {
  margin: 10px 0;
  text-align: right;
}
</style>
