<!--
 * @Description: 学历提升
 * @Author: 空白格
 * @Date: 2022-08-12 13:47:26
 * @LastEditors: 空白格
 * @LastEditTime: 2022-08-29 09:41:28
 * @FilePath: \veterans_client_web\src\views\EducationPromote\EducationPromoteIndex.vue
 * @Copyright: Copyright (c) 2016~2022 by 空白格, All Rights Reserved.
-->
<template>
  <div class="app-main education-promote">
    <BannerBreadcrumb title="学历提升" />
    <div class="app-main-box">
      <!-- banner图 -->
      <div class="education-promote-banner">
        <el-image
          class="image"
          :src="require('@/assets/images/education-promote-banner.png')"
          fit="cover"
        ></el-image>
      </div>
      <!-- 特点 -->
      <div
        class="education-promote-effect"
        @click="jumpPage('/educationpromote/details')"
      >
        <div class="education-promote-effect-item">
          <p>提升作用</p>
          <p>学历提升</p>
        </div>
        <div class="education-promote-effect-item">
          <p>提升流程</p>
          <p>学历提升</p>
        </div>
        <div class="education-promote-effect-item">
          <p>提升方式</p>
          <p>学历提升</p>
        </div>
      </div>
      <!-- 热门活动 -->
      <div class="app-main-box-content education-promote-activity">
        <div class="education-promote-activity-header">
          <el-row :gutter="80">
            <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
              <div class="epah-left">
                <div class="epah-left-select">
                  <el-select
                    v-model="queryParams.schoolId"
                    placeholder="请选择学院"
                    style="width: 100%"
                    filterable
                    @change="schoolChange"
                  >
                    <el-option
                      v-for="(item, index) in schoolList"
                      :key="index"
                      :label="item.school_name"
                      :value="item.id"
                    >
                    </el-option>
                  </el-select>
                </div>
                <div
                  class="epah-left-btn"
                  @click="
                    jumpPage('/collegesdetails', {
                      schoolId: queryParams.schoolId,
                    })
                  "
                >
                  学院详情
                </div>
              </div>
            </el-col>
            <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
              <div
                class="epah-right"
                @click="
                  jumpPage('/educationpromote/recruitstudents', {
                    id: currentSchool.id,
                    name: currentSchool.school_name,
                  })
                "
              >
                <div class="epah-right-text">招生简章</div>
                <div class="epah-right-btn">立即查看</div>
              </div>
            </el-col>
          </el-row>
        </div>
        <div
          class="education-promote-activity-list"
          v-if="activityList.length"
          v-loading="loading"
        >
          <el-row :gutter="24">
            <el-col
              :xs="24"
              :sm="12"
              :md="12"
              :lg="6"
              :xl="6"
              v-for="(item, index) in activityList"
              :key="index"
            >
              <div class="epal-item">
                <div class="epal-item-image">
                  <el-image :src="item.img" class="image" fit="cover">
                    <div slot="placeholder" class="image-slot">
                      加载中<span class="dot">...</span>
                    </div>
                  </el-image>
                </div>
                <p>{{ item.name || "-" }}</p>
                <p>{{ item.schoolName || "-" }}</p>
              </div>
            </el-col>
          </el-row>
          <div class="pagination" v-if="total">
            <el-pagination
              background
              layout="prev, pager, next"
              :page-size="queryParams.pageSize"
              :total="total"
              @current-change="currentChange"
            />
          </div>
        </div>
        <el-empty description="列表数据为空" v-else></el-empty>
      </div>
    </div>
  </div>
</template>

<script>
import BannerBreadcrumb from "@/components/BannerBreadcrumb";
import { getSchoolListData, getActivityBySchool } from "@/api/EducationPromote";
export default {
  name: "EducationPromoteIndex",
  components: {
    BannerBreadcrumb,
  },
  data() {
    return {
      schoolList: [],
      queryParams: {
        schoolId: undefined,
        pageNum: 1,
        pageSize: 8,
      },
      activityList: [],
      total: 0,
      loading: false,
      currentSchool: {},
    };
  },
  created() {
    this.getSchoolList();
  },
  methods: {
    /**
     * 获取学院列表
     * @date 2022-08-12
     * @returns {any}
     */
    getSchoolList() {
      getSchoolListData().then((res) => {
        this.schoolList = res.data;
        this.queryParams.schoolId = res.data[0].id;
        this.currentSchool = res.data[0];
        this.getACtivityList();
      });
    },
    /**
     * 获取学院活动列表
     * @date 2022-08-12
     * @returns {any}
     */
    getACtivityList() {
      this.loading = true;
      getActivityBySchool(this.queryParams).then((res) => {
        this.activityList = res.rows;
        this.total = Number(res.total);
        this.loading = false;
      });
    },
    /**
     * 分页切换触发
     * @date 2022-08-12
     * @param {any} page
     * @returns {any}
     */
    currentChange(page) {
      this.queryParams.pageNum = page;
      this.getACtivityList();
    },
    /**
     * 学院切换
     * @date 2022-08-12
     * @param {any} val
     * @returns {any}
     */
    schoolChange(val) {
      this.schoolList.forEach((item) => {
        if (val === item.id) {
          this.currentSchool = item;
        }
      });
      this.queryParams.schoolId = val;
      this.queryParams.pageNum = 1;
      this.getACtivityList();
    },
    /**
     * 跳转到指定页面
     * @date 2022-08-11
     * @param {any} path
     * @returns {any}
     */
    jumpPage(path, query) {
      if (path) {
        this.$router.push({ path, query });
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.education-promote {
  padding-bottom: 30px;
  &-banner {
    width: 100%;
    height: 295px;
    .image {
      width: 100%;
      height: 100%;
    }
  }
  &-effect {
    width: 100%;
    height: 160px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    &-item {
      width: 33%;
      text-align: center;
      p {
        color: #3d5d4c;
        font-size: 34px;
        &:last-child {
          background-color: #8ead9c;
          color: #fff;
          font-size: 24px;
          width: 140px;
          height: 40px;
          line-height: 40px;
          text-align: center;
          margin: 10px auto 0;
          border-radius: 20px;
          font-weight: normal;
        }
      }
    }
  }
  &-activity {
    margin-top: 10px;
    &-header {
      margin-bottom: 40px;
      .epah-left {
        display: flex;
        &-select {
          width: calc(100% - 171px);
          :deep(.el-input__inner) {
            height: 50px;
            line-height: 50px;
            border-top-right-radius: 0;
            border-bottom-right-radius: 0;
          }
        }
        &-btn {
          width: 171px;
          height: 50px;
          line-height: 50px;
          text-align: center;
          background-color: #a4c5df;
          color: #fff;
          border-radius: 0 5px 5px 0;
          cursor: pointer;
        }
      }
      .epah-right {
        background-color: #678f7a;
        height: 50px;
        line-height: 50px;
        border-radius: 5px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0 27px;
        &-text {
          color: #fff;
          font-size: 20px;
          font-weight: 700;
        }
        &-btn {
          background-color: #fff;
          border-radius: 19px;
          width: 100px;
          height: 30px;
          line-height: 30px;
          text-align: center;
          font-size: 14px;
          color: #678f7a;
          cursor: pointer;
        }
      }
    }
    &-list {
      .epal-item {
        margin-bottom: 20px;
        cursor: pointer;
        &-image {
          height: 180px;
          width: 100%;
          margin-bottom: 5px;
          .image {
            width: 100%;
            height: 100%;
            border: solid 1px #e0e0e0;
            border-radius: 2px;
          }
        }
        p {
          font-size: 20px;
          color: #3f3f3f;
          margin-bottom: 5px;
          &:last-child {
            color: #a2a2a2;
            font-size: 16px;
          }
        }
      }
      .pagination {
        text-align: center;
        margin-top: 20px;
        :deep(.el-pager .active) {
          background-color: #ff3939;
        }
        :deep(.el-pagination.is-background .el-pager li:not(.disabled).active) {
          background-color: #ff3939;
        }
      }
    }
  }
}
</style>
