<template>
  <div class="previewContain">
    <!-- {{ previewData }} -->
    <!-- {{ previewData.name }}______{{ previewData.id }} -->
    <div class="pictureBox">
      <el-row
        v-for="i in rowNum"
        :key="'row-' + i"
        :style="{ height: 100 / rowNum + '%' }"
      >
        <el-col
          :span="24 / colNum"
          v-for="(item, index) in picList"
          :key="'col-' + index"
          v-if="index < colNum * i && index >= colNum * (i - 1)"
        >
          <div class="imgcloum">
            <!-- <img
              src="http://180.166.218.222:40080/photos/2023/07/17/03/XYIGQ10C221000003_1_FF_20230717134007.jpg!1366x768"
            /> -->
            <img :src="item.path + '!1366x768'" />
          </div>
        </el-col>
      </el-row>
    </div>

    <div class="pageNation">
      <!-- <el-pagination
        @current-change="handleCurrentChange"
        :current-page="page"
        layout=" prev, pager, next, jumper,total"
        :total="total"
      >
      </el-pagination> -->
      <el-pagination
        @current-change="handleCurrentChange"
        :current-page="page"
        :page-size="pageSize"
        layout=" prev, pager, next, jumper,total"
        :total="total"
      >
      </el-pagination>
    </div>
  </div>
</template>
<script>
import { getTowerAndPhotoList } from "@/utils/api/index";
export default {
  props: ["previewData"],
  data() {
    return {
      rowNum: 4,
      colNum: 4,
      page: 1, // 当前页数
      pageSize: 16, // 每页数量
      totalPage: 0, //总页数
      total: 0, //总条数
      picList: [], //图片列表数据
      id: "",
      type: "",
    };
  },
  mounted: function () {},
  methods: {
    //获取所有杆塔图片列表
    getPicList(id, type) {
      this.id = id;
      this.type = type;
      console.log(id, type);
      getTowerAndPhotoList({
        id: id,
        type: type,
        pageindex: this.page,
        pagesize: this.rowNum * this.colNum,
      })
        .then((res) => {
          console.log(res);
          this.picList = res.data.list;
          this.totalPage = res.data.totalpage;
          this.total = res.data.total;
        })
        .catch((err) => {
          console.log(err); //代码错误、请求失败捕获
        });
    },
    //点击分页
    handleCurrentChange(val) {
      this.page = val;
      this.picList = [];
      this.getPicList(this.id, this.type);
    },
  },
};
</script>

<style lang="less">
.previewContain {
  width: 100%;
  padding: 16px;
  height: auto;
  //background: #fcc;
  .pictureBox {
    height: calc(100% - 38px);
    //background-color: aquamarine;
    .el-col {
      height: 100%;
      padding-right: 0.1%;
      padding-left: 0.1%;
      padding-top: 0.1%;
      padding-bottom: 0.1%;
    }
    .imgcloum {
      width: 100%;
      height: 100%;
      //   background: #f00;
      img {
        width: 100%;
        height: 100%;
      }
    }
  }
}
</style>
