LearnAfter.vue 2.79 KB
Newer Older
耿迪迪's avatar
耿迪迪 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
<!--
 * @Author: 纪泽龙 jizelong@qq.com
 * @Date: 2022-09-20 14:17:00
 * @LastEditors: 纪泽龙 jizelong@qq.com
 * @LastEditTime: 2022-09-28 13:05:49
 * @FilePath: /danger-manage-web/src/views/myLessions/components/learnAfter.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="learnbrfore flex">
    <transition name="fade" mode="out-in">
      <div class="top flex" :key="currentPage">
        <div
          v-show="index < 9 * currentPage && index >= 9 * (currentPage - 1)"
          v-for="(item, index) in afterList"
          :key="index + ''"
          class="learn-item"
        >
          <LearnItem
            :state="state"
            :itemData="item"
            @examination="examination"
          />
        </div>
      </div>
    </transition>

    <div class="bottom flex">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page.sync="currentPage"
        :page-size="9"
        :layout="total > 9 ? layout : layout2"
        :total="afterList.length"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
import LearnItem from "./LearnItem";
export default {
  name: "learnbrfore",
  components: {
    LearnItem,
  },
  props: {
    state: {
      type: Object,
    },
    list: {
      type: Array,
      default: () => {
        return [];
      },
    },
  },
  data() {
    return {
      // list: [
      //   { state: 2},
      //   { state: 2},
      //   { state: 2},
      //   { state: 2},
      //   { state: 2},
      //   { state: 2},
      //   { state: 2},
      //   { state: 2},
      //   { state: 2},
      // ],
      currentPage: 1,
      total: 19,
      layout: "prev, pager, next, jumper",
      layout2: "prev, pager, next",
    };
  },
  computed: {
    afterList() {
81
      return this.list.filter((item) => item.state == 2);
耿迪迪's avatar
耿迪迪 committed
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
    },
  },
  created() {
    console.log("after");
  },
  methods: {
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
    examination(e) {
      this.$emit("examination", e);
    },
  },
};
</script>
<style lang="scss" scoped>
.learnbrfore {
  width: 100%;
  height: 100%;
  flex-direction: column;
  .top {
    width: 100%;
    flex: 1;
    padding: 2px;
    box-sizing: border-box;
    // justify-content: space-between;
    flex-wrap: wrap;
    .learn-item {
      width: 32.5%;
      height: 31.5%;
      margin-right: 1.25%;
      &:nth-child(3n) {
        margin-right: 0px;
      }
    }
  }
  .bottom {
    height: 12.7%;
    max-height: 100px;
    justify-content: center;
    align-items: center;
  }
}
</style>