<template>
  <div class="museum">
    <!-- <NavBar /> -->
    <div style="height: 100px; background-color: #2069c4; width: 100%"></div>
    <div class="main">
      <div class="content">
        <el-row :gutter="20">
          <el-col :span="24" class="rclist">
            <div class="search">
              <SearchBar @search="search" />
            </div>
            <div class="display-group">
              <el-row :gutter="60">
                <el-col
                  :span="6"
                  class="display-item"
                  @click.native="handleClick(item)"
                  v-for="(item, index) in list.records"
                  :key="index"
                >
                  <div class="img" v-if="item.faceImageUrl">
                    <img
                      :src="item.faceImageUrl"
                      alt=""
                      srcset=""
                      v-if="item.faceImageUrl"
                      width="100%"
                      @error="defImg"
                      class="cr-img"
                    />
                    <img
                      v-else
                      src="@/assets/404_images/no-pic.png"
                      alt=""
                      width="100%"
                      height="100%"
                    />
                    <div class="desc">
                      <span class="name">{{ item.name }}</span>
                      <!-- <span class="deptName">{{ item.deptName }}</span> -->
                    </div>
                  </div>
                </el-col>
              </el-row>
            </div>
          </el-col>
        </el-row>
      </div>
      <div class="pagination">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="Number(list.current)"
          :page-sizes="[10, 20, 40, 50]"
          :page-size="Number(list.size)"
          layout="total, sizes, prev, pager, next, jumper"
          :total="Number(list.total)"
          class="pagination"
        >
        </el-pagination>
      </div>
    </div>
    <!-- <Footer /> -->
  </div>
</template>

<script>
import SearchBar from "@/components/SearchBar";
// import NavBar from "@/components/NavBar";
// import Footer from "@/components/Footer";
import { getMuseumListPage } from "@/api/org";
export default {
  name: "Museum",
  // components: { SearchBar, NavBar, Footer },
  components: { SearchBar },
  data() {
    return {
      selectValue: "",
      keyword: "",
      currentType: "all",
      list: {
        current: 1,
        size: 10,
        records: [],
        total: 0,
      },
    };
  },
  created() {
    setTimeout(() => {
      // console.log(this.dicts);
    });
  },
  mounted() {
    this.loadData();
  },
  methods: {
    async loadData() {
      var params = {
        // dept: "",
        page: this.list.current,
        limit: this.list.size,
      };
      let res = await getMuseumListPage(params);
      if (res.code == 0) {
        this.list = res.data;
      }
    },

    async search(keyword) {
      var params = {
        page: this.list.current,
        limit: this.list.size,
        title: keyword,
      };
      let res = await getList(params);
      if (res.code == 0) {
        this.list = res.data;
      }
    },
    // 改变页容量
    handleSizeChange(value) {
      this.list.size = value;
      this.loadData();
    },

    // 改变当前显示页
    handleCurrentChange(value) {
      this.list.current = value;
      this.loadData();
    },

    handleClick(item) {
      const { id } = item;
      this.$router.push({
        path: "museum/" + id,
      });
    },

    defImg(e) {
      e.target.src = require("@/assets/404_images/no-pic.png");
    },
  },
};
</script>

<style lang="scss" scoped>
$blue: #1e5fbb;
$text-indent: 16px;
.museum {
  width: 100%;
  // background-color: #2069c4;
  // color: #fff;
  .main {
    display: flex;
    align-items: center;
    flex-direction: column;
    padding: 60px;
    .search {
      display: flex;
      justify-content: center;
      align-items: center;
      margin-bottom: 40px;
      // margin-top: 20px;
    }
    .search-bar {
      width: 1200px;
      margin-right: 10px;
      // border-radius: 48px !important;
    }

    .total {
      margin-bottom: 40px;
    }
    .divider {
      width: 100%;
      height: 1px;
      background-color: $blue;
      margin-bottom: 20px;
    }

    .content {
      width: 100%;
      .selectors {
        margin-top: 80px;

        .select-card {
          width: 100%;
          box-shadow: 0 2px 10px 6px rgba(0, 0, 0, 0.12);
          border-radius: 8px;
          margin-bottom: 16px;
          .title {
            padding: 10px 20px;
            background-color: #1e5fbb;
            border-radius: 8px 8px 0 0;
            color: #fff;
            font-weight: bold;
          }
          .body {
            padding: 10px 20px;
            background-color: #fff;
            border-radius: 0 0 8px 8px;
            .select-items {
              display: flex;
              margin-bottom: 20px;
              cursor: pointer;
              margin-top: 24px;
              .check-box {
                border: 2px solid #563f17;
                width: 20px;
                height: 20px;
                margin-right: 15px;
                i {
                  color: $blue;
                  width: 2px;
                  font-weight: bold;
                }
              }
              .check-value {
                color: #563f17;
                font-size: 14px;
                font-weight: bold;
              }
            }
          }
        }
      }
      .rclist {
        .img {
          width: 100%;
          margin-bottom: 10px;
          position: relative;
          .cr-img {
            width: 100%;
          }
          .showIcon {
            position: absolute;
            opacity: 0.7;
            top: 10px;
            right: 10px;
            width: 24px;
            height: 24px;
            background-color: #fff;
            opacity: 0.2;
            border-radius: 4px;
            padding: 2px;
            .icon {
              width: 100%;
              height: 100%;
            }
          }
          .desc {
            position: absolute;
            width: 100%;
            padding: 10px;
            background-color: #fff;
            opacity: 0.7;
            bottom: 0;
            left: 0;
          }

          .collect {
            position: absolute;
            right: 20px;
            bottom: 20px;
            .collect-box {
              width: 40px;
              height: 40px;
              display: flex;
              justify-content: center;
              align-items: center;
              background-color: rgba(0, 0, 0, 0.15);
              border-radius: 8px;
              cursor: pointer;
              img {
                width: 20px;
                height: 20px;
                opacity: 0.5;
              }
            }
          }
        }

        .display-item {
          cursor: pointer;
          .img {
            img {
              width: 100%;
              height: 250px;
            }
          }
        }
      }
    }
  }

  .pagination {
    margin-top: 24px;
    display: flex;
    justify-content: center;
  }
}
</style>