<template>
  <div class="index">
    <searchContainer
      bannerKey="首页>成果库>成果列表"
      title="成果库"
      @handleQuery="handleQuery"
    >
      <template v-slot>
        <el-row type="flex" style="padding: 20px 0">
          <div style="flex: 1">
            <div style="position: relative">
              <!-- <industrySelect @industryChange="industryChange"></industrySelect> -->
              <div class="total">
                共找到
                <span>{{ total }}</span> 个成果
              </div>
              <div v-loading="loading">
                <section v-for="item in searchResults" :key="item.id">
                  <div style="border: 1px solid #dcdcdc; margin-bottom: 10px">
                    <achievementItem :data="item"></achievementItem>
                  </div>
                </section>
              </div>

              <pagination
                class="pagination"
                :total="total"
                :pageSizes="[10, 10 << 1, 10 << 2, 10 << 3]"
                v-model:page="queryParams.pageNum"
                v-model:limit="queryParams.pageSize"
                :autoScroll="false"
                @pagination="getDataList"
              />
            </div>
          </div>
          <div class="r">
            <webContact />
          </div>
        </el-row>
      </template>
    </searchContainer>
  </div>
</template>

<script setup name="SearchAchievement">
import webContact from "@/components/webContact/index.vue";
import { search } from "@/api/website/home/index";
import searchContainer from "./components/searchContainer.vue";
// import industrySelect from "./components/industrySelect.vue";
import achievementItem from "./components/achievementItem";
import { useRoute } from "vue-router";

const loading = ref(true);
const searchResults = ref([]);
const total = ref(0);
const route = useRoute();

const queryParams = reactive({
  pageNum: 1,
  pageSize: 5,
  searchType: 2,
  queryType: route.query.queryType,
  query: route.query.keyword,
});

function handleQuery(state) {
  // state.keyword = keyword;
  queryParams.query = state.currentKeyword;
  queryParams.queryType = state.queryType;
  getDataList();
}

const getDataList = async () => {
  loading.value = true;
  try {
    const resp = await search(queryParams);
    searchResults.value = resp.list;
    total.value = resp.total;
    loading.value = false;
  } catch (error) {
    loading.value = false;
  }
};
</script>

<style lang="scss" scoped>
.total {
  font-size: 16px;
  font-family: Source Han Sans CN;
  font-weight: 500;
  color: #333333;
  margin-bottom: 20px;
  span {
    font-size: 30px;
    color: #0054ff;
  }
}

.r {
  display: inline-block;
  width: 325px;
  margin-left: 14px;
  min-height: 200px;
  // background-color: #fff;
}

.item {
  height: 200px;
  overflow: hidden;
  background-color: #fff;
  margin-bottom: 16px;

  .img {
    width: 90px;
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    img {
      width: 90px;
      height: 90px;
      border-radius: 50%;
    }
  }
  .content {
    display: inline-block;
    width: 390px;
    .line {
      font-size: 16px;
      font-family: Source Han Sans CN;
      font-weight: 400;
      color: #666666;
      margin: 10px 0;
      span {
        font-size: 16px;
        font-family: Source Han Sans CN;
        font-weight: 500;
        color: #333;
      }
    }
  }
  .keywords {
    flex: 1;
    width: 129px;
    height: 129px;
  }
  .tit {
    width: 100%;
    overflow: hidden;
    cursor: pointer;
    .text {
      margin-right: 200px;
      overflow: hidden;

      text-overflow: ellipsis;
      white-space: nowrap;
      font-size: 20px;
      font-family: Source Han Sans CN;
      font-weight: bold;
      color: #333333;
    }
  }
}
</style>
