<template>
  <div class="container">
    <el-row class="sort-box" :gutter="20">
      <el-col class="sort-item" :span="4" @click.native="handleClick('')">
        <div class="sort-item-box">
          <div class="sort-item-box-top">
            <!-- <p>{{ $t('module.report.reportSort.all') }}</p> -->
            <!-- <p>{{ $t('all') }}</p> -->
            <p>所有报表</p>
          </div>
          <div class="sort-item-box-bottom">{{ allNum }} {{ allNum === 0 || allNum > 1 ? "Reports" : "Report" }}</div>
        </div>
      </el-col>
      <el-col v-for="item in dataList" :key="item.id" class="sort-item" @click.native="handleClick(item.id)">
        <div class="sort-item-box">
          <div class="sort-item-box-top">
            <p>{{ item.name }}</p>
          </div>
          <div class="sort-item-box-bottom">{{ item.quantity }} {{ item.quantity || item.quantity > 1 ? "Reports" : "Report" }}</div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  data() {
    return { dataList: [], pageIndex: 1, pageSize: 10, totalPage: 0, allNum: 0 };
  },
  created() {
    this.getDataList();
  },
  methods: {
    // get list
    getDataList() {
      this.$http({
        url: "/pms/reportSheetCategory/list",
        method: "get",
        params: {},
      }).then(({ data: res }) => {
        this.allNum = 0;
        //console.log("报表", res);

        if (res.code === 0 && res.data) {
          if (Array.isArray(res.data)) {
            this.dataList = res.data;
            this.dataList.forEach((i) => {
              this.allNum += i.quantity;
            });
          }
        } else {
          this.dataList.splice(0);
          this.$message({
            message: `${res.code}: ${res.msg}`,
            type: "error",
            duration: 1500,
          });
        }
      });
    },

    handleClick(id) {
      this.$router.push({
        name: "pms-reportSheet",
        query: {
          category: id,
        },
      });
    },
  },
};
</script>

<style lang="scss">
.container {
  background: white;
  /* height: 100%; */
  min-height: inherit;
  border-radius: 6px;
  padding: 16px;
  box-shadow: 0 0 1.125px 0.125px rgba(0, 0, 0, 0.125);
  .sort-box {
    .sort-item {
      height: 400px;
      width: 280px;
      margin-bottom: 20px;
      .sort-item-box {
        width: 100%;
        height: 400px;
        background: #faefc2;
        border-radius: 10px;
        box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);
        cursor: pointer;
        position: relative;
        overflow: hidden;
        .sort-item-box-top {
          margin: 0 10%;
          width: 80%;
          height: 199px;
          border-bottom: 1px solid #e3d47d;
          color: #b3a995;
          position: relative;
          p {
            width: 100%;
            position: absolute;
            bottom: 0px;
            line-height: 50px;
            font-size: 24px;
            letter-spacing: 5px;
            text-align: center;
          }
        }
        .sort-item-box-bottom {
          width: 100%;
          height: 200px;
          line-height: 200px;
          font-size: 24px;
          font-weight: bold;
          text-align: center;
          letter-spacing: 5px;
          color: #6e7680;
        }
      }
      .sort-item-box::before {
        content: "";
        position: absolute;
        right: 0;
        width: 4px;
        height: 400px;
        background: #f8e69b;
      }
      .sort-item-box::after {
        content: "";
        position: absolute;
        right: 0;
        top: 70px;
        width: 18px;
        height: 60px;
        background: #f8e69b;
        border-radius: 5px;
      }
      .sort-item-box:hover {
        transition: border linear 0.2s, box-shadow linear 0.2s;
        box-shadow: 0 0 5px rgba($color: #000000, $alpha: 0.5);
      }
    }
  }
}
</style>
