<template>
  <!-- 调查项目：结构/样式与智库报告一致，但组件独立，避免互相影响 -->
  <div class="home-main-footer-main">
    <div class="left">
      <div class="select-box">
        <div class="header">
          <div class="icon"></div>
          <div class="title">{{ "科技领域" }}</div>
        </div>
        <div class="select-main">
          <div class="checkbox-group">
            <el-checkbox v-model="checkAllModel" :indeterminate="isIndeterminate" class="all-checkbox"
              @change="emit('check-all-change', $event)">
              全部领域
            </el-checkbox>
            <el-checkbox v-for="research in areaList" :key="research.id" v-model="selectedAreaListModel"
              :label="research.id" @change="emit('checked-area-change')" class="filter-checkbox">
              {{ research.name }}
            </el-checkbox>
          </div>
        </div>
      </div>

      <div class="select-box">
        <div class="header">
          <div class="icon"></div>
          <div class="title">{{ "发布时间" }}</div>
        </div>
        <div class="select-main">
          <div class="checkbox-group">
            <el-checkbox v-model="checkAllTimeModel" class="all-checkbox" :indeterminate="isIndeterminateTime"
              @change="emit('check-all-time-change', $event)">
              全部时间
            </el-checkbox>
            <el-checkbox-group v-model="selectedPubTimeListModel">
              <el-checkbox v-for="time in pubTimeList" :key="time.id" :label="time.id" class="filter-checkbox"
                @change="emit('checked-area-time-change')">
                {{ time.name }}
              </el-checkbox>
            </el-checkbox-group>
          </div>
        </div>
      </div>
    </div>

    <div class="right">
      <div class="card-box">
        <div class="footer-card" v-for="(item, index) in curFooterList" :key="index"
          @click="emit('report-click', item)">
          <div class="footer-card-top">
            <img :src="item.imageUrl" alt="" />
          </div>
          <div class="footer-card-title">
            {{ item.name }}
          </div>
          <div class="footer-card-footer">
            <div class="time">{{ item.times }}</div>
            <div class="from">{{ item.thinkTankName }}</div>
          </div>
        </div>
      </div>
      <div class="right-footer">
        <div class="info">共 {{ total }} 篇调查项目</div>
        <div class="page-box">
          <el-pagination :page-size="12" background layout="prev, pager, next" :total="total"
            @current-change="emit('page-change', $event)" :current-page="currentPage" />
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { computed } from "vue";

const props = defineProps({
  checkAll: { type: Boolean, default: false },
  isIndeterminate: { type: Boolean, default: false },
  areaList: { type: Array, default: () => [] },
  selectedAreaList: { type: Array, default: () => [] },

  checkAllTime: { type: Boolean, default: false },
  isIndeterminateTime: { type: Boolean, default: false },
  pubTimeList: { type: Array, default: () => [] },
  selectedPubTimeList: { type: Array, default: () => [] },

  curFooterList: { type: Array, default: () => [] },
  total: { type: Number, default: 0 },
  currentPage: { type: Number, default: 1 }
});

const emit = defineEmits([
  "update:checkAll",
  "update:selectedAreaList",
  "check-all-change",
  "checked-area-change",
  "update:checkAllTime",
  "update:selectedPubTimeList",
  "check-all-time-change",
  "checked-area-time-change",
  "report-click",
  "page-change"
]);

const checkAllModel = computed({
  get: () => props.checkAll,
  set: val => emit("update:checkAll", val)
});

const selectedAreaListModel = computed({
  get: () => props.selectedAreaList,
  set: val => emit("update:selectedAreaList", val)
});

const checkAllTimeModel = computed({
  get: () => props.checkAllTime,
  set: val => emit("update:checkAllTime", val)
});

const selectedPubTimeListModel = computed({
  get: () => props.selectedPubTimeList,
  set: val => emit("update:selectedPubTimeList", val)
});
</script>

<style lang="scss" scoped>
/* 复制 HomeMainFooterMain 的样式，保证完全不影响外观 */
.home-main-footer-main {
  margin: 0 auto;
  margin-top: 36px;
  width: 1600px;
  display: flex;
  gap: 16px;

  .left {
    width: 360px;
    height: 100%;
    padding-bottom: 36px;
    box-sizing: border-box;
    border: 1px solid rgba(234, 236, 238, 1);
    border-radius: 10px;
    box-shadow: 0px 0px 20px 0px rgba(94, 95, 95, 0.1);
    background: rgba(255, 255, 255, 1);
    position: relative;

    .select-box {
      margin-top: 21px;

      .header {
        display: flex;
        gap: 17px;

        .icon {
          margin-top: 4px;
          width: 8px;
          height: 16px;
          background: var(--color-main-active);
          border-radius: 0 4px 4px 0;
        }

        .title {
          height: 24px;
          color: var(--color-main-active);
          font-family: Microsoft YaHei;
          font-size: 16px;
          font-weight: 700;
          line-height: 24px;
          letter-spacing: 1px;
          text-align: left;
        }
      }

      .select-main {
        margin-left: 25px;
      }

      .select-main1 {
        width: 100px;
      }
    }
  }

  .right {
    width: 1284px;
    max-height: 1377px;

    .card-box {
      width: 1226px;
      max-height: 1248px;
      min-height: 616px;
      display: flex;
      flex-wrap: wrap;
      gap: 16px 16px;

      .footer-card {
        width: 398px;
        height: 300px;
        border-radius: 10px;
        box-shadow: 0px 0px 20px 0px rgba(25, 69, 130, 0.1);
        background: rgba(255, 255, 255, 1);

        .footer-card-top {
          width: 364px;
          height: 180px;
          margin: 0 auto;
          margin-top: 15px;

          img {
            width: 100%;
            height: 100%;
          }
        }

        .footer-card-title {
          margin: 0 auto;
          margin-top: 13px;
          width: 376px;
          height: 48px;
          color: rgba(59, 65, 75, 1);
          font-family: Microsoft YaHei;
          font-size: 18px;
          font-weight: 700;
          line-height: 24px;
          overflow: hidden;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-line-clamp: 2;
          -webkit-box-orient: vertical;
        }

        .footer-card-footer {
          margin: 0 auto;
          margin-top: 5px;
          width: 376px;
          height: 22px;
          display: flex;
          justify-content: space-between;
          color: rgba(95, 101, 108, 1);
          font-family: Microsoft YaHei;
          font-size: 14px;
          font-weight: 400;
          line-height: 22px;
        }
      }
    }

    .right-footer {
      height: 50px;
      margin-top: 43px;
      display: flex;
      justify-content: space-between;

      .info {
        height: 19px;
        color: rgba(132, 136, 142, 1);
        font-family: Microsoft YaHei;
        font-size: 14px;
        font-weight: 400;
        line-height: 18px;
        letter-spacing: 0px;
        text-align: left;
      }
    }
  }
}

.all-checkbox {
  width: 220px;
}

.filter-checkbox {
  width: 105px;
}
</style>
