<template>
  <!-- 我参与的组 -->
  <el-card>
    <div class="myAttention">
      <div class="searchDiv" style="display: flex; justify-content: flex-end">
        <el-button type="primary" @click="addData()">创建</el-button>
        <div class="searchValue">
          <input type="text" placeholder="搜索关键字" v-model="keyword" />
          <div class="searchBtn" @click="getListData">
            <img src="/kczy/searchIcon.png" alt="" />
          </div>
        </div>
      </div>

      <div class="teacher-list">
        <div v-for="(item, index) in listData" :key="index" class="item-list">
          <div class="content-top">
            <span>{{ item.grade_name }}</span>
            <span>{{ item.subject_name }}</span>
          </div>
          <div class="content-middle">{{ item.ug_name }}</div>
          <div class="content-bottom">
            {{ item.ug_brief }}
          </div>
          <div style="display: flex; position: absolute; bottom: 30px; left: 30px">
            <img class="yh-avatar" v-for="(value, i) in item.users" :key="i" v-show="item.users.length!=0?true:false" :src="getAvatarUrl(value)" alt="" />
            <img class="yh-avatar" v-for=" i in 3" :key='i' v-show="item.users.length!=0?false:true" src="@/assets/images/header/Avatar.png" alt="" />
          </div>

        </div>
      </div>
    </div>
    <div class="footer">
      <div style="width: 1400px; height: 50px; position: relative; margin: 0 auto">
        <el-pagination background layout="total,prev, pager, next" :total="total" style="position: absolute; top: 0; right: 0" @current-change="handleCurrentChange" :page-size="limit">
        </el-pagination>
      </div>
    </div>
  </el-card>
</template>

<script>
import { wcydz_list } from "./api";
import { getAvatarUrl } from "@/utils/helper";
export default {
  data() {
    return {
      limit: "10",
      keyword: "",
      page: "",
      total: 0,
      cur_page: 1,
    };
  },
  methods: {
    getListData() {
      let data = {
        page: this.cur_page,
        limit: this.limit,
        keyword: this.keyword,
      };

      wcydz_list(data).then((res) => {
        console.log(res);
        this.listData = res.data.page_data;
        console.log(this.listData);
        this.cur_page = Number(res.data.page_now);
        this.total = Number(res.data.total_rows);
      });
    },

    handleCurrentChange(val) {
      this.cur_page = val;
      this.listData();
    },
    addData() {
      this.$router.push({ name: "wxydz_add" });
    },
  },
  mounted() {
    this.getListData();
  },
};
</script>

<style lang="scss" scoped>
.searchDiv {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 80px;
  margin-bottom: 30px;
  .menuDiv {
    display: flex;
    margin-bottom: -10px;
    .list {
      margin: 0 20px;
      padding: 0 10px;
      color: #949494;
      position: relative;
      line-height: 40px;
      font-size: 14px;
      &::after {
        content: "";
        width: 0;
        height: 2px;
        background: rgba(0, 131, 197, 0.8);
        position: absolute;
        bottom: -10px;
        left: 50%;
        transform: translateX(-50%);
        transition: width linear 0.1s;
      }
      &:hover {
        color: rgba(0, 131, 197, 0.8);
      }
      &.active {
        color: rgba(0, 131, 197, 0.8);
        font-size: 16px;
        &::after {
          width: 100%;
        }
      }
    }
  }
  .el-button {
    width: 100px;
    height: 40px;
    margin-right: 40px;
  }
  .searchValue {
    width: 350px;
    height: 50px;

    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    input {
      width: 100%;
      height: 100%;
      outline: 0;
      box-sizing: border-box;
      padding-left: 10px;
      background: #f6f8fa;
    }
    .searchBtn {
      width: 26px;
      height: 26px;
      background: #00a3ff;
      border-radius: 6px;
      position: absolute;
      right: 5px;
      top: 50%;
      transform: translate(-50%, -50%);
      text-align: center;
      vertical-align: middle;
      cursor: pointer;
      img {
        display: block;
        text-align: center;
        margin: 6px auto 0;
      }
    }
  }
}
.myAttention {
  .switch {
    display: inline-block;
    margin-bottom: 35px;
    border: 1px solid #dbe7ec;
    padding: 3px;
    border-radius: 12px;
    margin-left: 20px;
    .switchDiv {
      display: flex;
      flex-wrap: wrap;
      .list {
        cursor: pointer;
        color: #666;
        line-height: 36px;
        padding: 0 20px;
        &.active {
          background: #e8f3fa;
          color: #000;
          border-radius: 12px;
        }
      }
    }
  }
  .el-col {
    margin-bottom: 25px;
  }
  .teacher-list {
    padding: 0px 100px;
    display: flex;
    flex-wrap: wrap;
  }
  .item-list {
    width: 360px;
    height: 320px;
    border-radius: 8px;
    padding: 30px;

    // border: 1px solid red;
    cursor: pointer;
    margin: 15px;
    background: #fcfeff;
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.08),
      0 6px 20px 0 rgba(0, 0, 0, 0.08);
    position: relative;
    .content-top {
      display: flex;
      justify-content: space-between;
      span {
        display: inline-block;
        // border: 1px solid red;
        background: #f5f8fa;
        border-radius: 9px;
        padding: 2px 6px;
        // width: 90px;
        // height: 30px;
        // line-height: 30px;
        font-size: 16px;

        text-align: center;
        color: #a1a5b7;
      }
    }
    .content-middle {
      color: #181c32;
      font-size: 18px;
      font-weight: 800;
      text-align: left;
      margin: 23px 0;
    }
    .content-bottom {
      color: #7e8299;
      font-size: 16px;
      text-align: left;
    }
  }

  .yh-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
  }
  .yh-avatar + .yh-avatar {
    margin-left: -10px;
  }
}
</style>