zhongshujie
10 小时以前 8bffcbb7f5fca4e1e7a308f6f786b63d0773704c
src/views/achievements/index.vue
@@ -39,9 +39,10 @@
              </li>
              <li class="left-main" v-if="category.isDisplay">
                <div class="category-main" v-for="(item, index) in category.list" :key="index">
                  <el-checkbox class="el-checkbox" style="display: inline-block; vertical-align: middle;"
                    v-model="item.checked" :title="item.name">{{ item.name }}</el-checkbox>
                  <span class="" style="display: inline-block; vertical-align: middle;">{{ item.num }}</span>
                  <el-checkbox class="el-checkbox" v-model="item.checked" :title="item.name"
                    @change="categoryChange(item)" style="display: inline-block; vertical-align: middle">{{ item.name
                    }}</el-checkbox>
                  <span class="" style="display: inline-block; vertical-align: middle">{{ item.num }}</span>
                </div>
              </li>
            </ul>
@@ -113,8 +114,8 @@
              </li>
              <li class="left-main" v-if="subject.isDisplay">
                <div class="category-main" v-for="(item, index) in subject.list" :key="index">
                  <el-checkbox class="el-checkbox" v-model="item.checked" :title="item.name">{{ item.name
                  }}</el-checkbox>
                  <el-checkbox class="el-checkbox" v-model="item.checked" :title="item.name"
                    @change="subjectChange(item)">{{ item.name }}</el-checkbox>
                  <span class="">{{ item.num }}</span>
                </div>
              </li>
@@ -136,7 +137,7 @@
              </ul>
              <ul class="number-time">
                发表时间
                <span><img :src="sortBottom" alt="" /></span>
                <span @click="sortChange()"><img :src="!postedSortInfo ? sortBottom : sortTop" alt="" /></span>
              </ul>
            </ul>
            <!-- 结果展示 -->
@@ -144,12 +145,12 @@
              <li class="main-name">
                <p>{{ item.name }}</p>
                <p>
                  <el-button @click="goPage(item)">详情</el-button>
                  <el-button @click="goPage(item.id)">详情</el-button>
                  <el-button>AI智能阅读</el-button>
                </p>
              </li>
              <li class="main-sources">
                <span>{{ item.resourceTypeName }}</span>
                <span :class="getResourceTypeClass(item.cmsItemType)">{{ item.resourceTypeName }}</span>
                <span>{{ item.source }}</span>
                <span>{{ item.year }}</span>
                <span v-if="item.DOI">doi:{{ item.DOI }}</span>
@@ -157,13 +158,20 @@
              <li class="main-author">
                {{ item.author }}
              </li>
              <li class="main-title" :title="item.abstract">
              <li class="main-title" :title="item.cleanAbstract" v-if="item.abstract">
                <span>摘要: </span>
                <span class="page-main-abstract" v-html="item.abstract"></span>
                <span class="page-main-abstract" v-html="item.cleanAbstract"></span>
              </li>
              <li class="main-keyword">
              <li class="main-keyword" v-if="item.keyWords && item.keyWords.length > 0">
                <span>关键词:</span>
                <span class="keyWord" v-for="(citem, cindex) in item.keyWords" :key="cindex">
                <span class="keyWord" v-for="(citem, cindex) in item.keyWords" :key="cindex" @click="
                  () =>
                    handleSearch({
                      text: citem,
                      type: 'keyWords',
                      label: '关键词',
                    })
                ">
                  {{ citem }}
                </span>
              </li>
@@ -171,9 +179,10 @@
            <!-- 分页 -->
            <div class="pagination" v-if="total > 6">
              <el-pagination @current-change="handleCurrentChange" class="msg-pagination-container"
                :background="isBackground" layout="prev, pager, next" :total="total" :page-size="6">
                :background="isBackground" layout="prev, pager, next" :total="total" :page-size="10">
              </el-pagination>
            </div>
            <el-empty v-if="!loading && !resultList.length"></el-empty>
          </div>
        </div>
      </div>
@@ -195,6 +204,7 @@
  },
  data() {
    return {
      relatedList: [],
      // 输入框的内容
      inputValue: "",
      // 选择的类型
@@ -313,6 +323,10 @@
          },
        ],
      },
      categoryChecList: [],
      subjectCheckList: [],
      postedSortInfo: true,
      // 年度
      annual: {
        title: "年度",
@@ -442,25 +456,75 @@
      resultList: [],
      total: 0,
      paginationPage: 1,
      loading: false,
      loading: true,
      labelList: {
        abstract: "摘要",
        author: "作者",
        keyword: "关键词",
        source: "来源",
        title: "标题",
        year: "年份",
      },
    };
  },
  mounted() {
    this.getSelectContent();
    this.getLeftCheckbox()
    this.getSelectData();
  },
  methods: {
    async onSubmit(val) { },
    categoryChange(val) {
      if (val.checked) {
        this.categoryChecList.push(val.value);
        this.associationList.push({
          type: "类型",
          content: val.name,
        });
      } else {
        const index = this.categoryChecList.findIndex(
          (item) => item === val.value
        );
        const index2 = this.associationList.findIndex(
          (item) => item.name === val.name
        );
        this.categoryChecList.splice(index, 1);
        this.associationList.splice(index2, 1);
      }
      this.getItemList();
    },
    subjectChange(val) {
      console.log(val, "val");
      if (val.checked) {
        this.subjectCheckList.push(val.value);
      } else {
        const index = this.subjectCheckList.findIndex(
          (item) => item === val.value
        );
        this.subjectCheckList.splice(index, 1);
      }
      this.getItemList();
    },
    async onSubmit(val) {
      for (let key in val) {
        if (val[key] != "") {
          this.associationList.push({
            type: this.labelList[key],
            content: val[key],
            value: key,
          });
        }
      }
      console.log(this.associationList, "this.associationList");
      this.getItemList();
    },
    //重置搜索结果
    resetForm() {
      // this.onSearch("");
    },
    // 页面跳转
    goPage(key) {
      console.log(key, "key");
      this.$router.push({ name: "details", params: { key: key } });
    goPage(id) {
      this.$router.push({ name: "details", query: { id } });
    },
    // 收起和展示
    shrinkClick(key, name) {
@@ -480,29 +544,24 @@
        this.activeBox = this.activeBox === "b" ? null : "b";
      }
    },
    // 获取左侧checkbox数据
    getLeftCheckbox() {
    },
    //获取下拉选择框的内容
    async getSelectData() {
      this.loading = true;
      try {
        // 同时发起两个异步请求,并等待它们的结果
        const [subjectListResult, resourceListResult] = await Promise.all([
          this.getSelectContent(this.subjectAffiliationRefCode),
          this.getSelectContent(this.resourceTypeRefCode),
        ]);
        this.subject.list = subjectListResult.option
        console.log(subjectListResult.option);
        this.subject.list = subjectListResult.option;
        this.category.list = resourceListResult.option;
        if (this.category.list && this.category.list.length) {
          this.category.list.forEach((item) => {
            this.resourceTypeValueList.push(item.value)
            this.resourceTypeValueList.push(item.value);
          });
        }
        this.getItemList()
        this.getItemList();
      } catch (error) {
        console.error("获取下拉框数据失败:", error);
      }
@@ -515,7 +574,6 @@
        .getProductTypeField(requestData)
        .then((res) => {
          const selestList = JSON.parse(res[0].config);
          console.log(selestList, "下拉框数据");
          return selestList;
        })
        .catch((error) => {
@@ -530,59 +588,89 @@
        (item) => item.content !== value
      );
      this.inputValue = "";
      this.getItemList()
      // 通知父组件数据已改变
      this.getItemList();
    },
    // 搜索
    handleSearch(isText) {
      console.log(1234);
      console.log(isText, "搜索123");
      this.associationList = [];
      console.log(isText, "isText");
      if (isText.text != "") {
        this.inputValue = isText.text
        this.inputType = isText.type
        this.inputValue = isText.text;
        this.inputType = isText.type;
        this.associationList.push({
          type: isText.label,
          content: isText.text,
          value: isText.type,
        });
        this.getItemList()
        this.getItemList();
      }
    },
    // getTtem
    // 请求数据
    getItemList() {
      let searchData = {};
      this.loading = true;
      let searchData = {}; // 初始化一个空对象来存储搜索数据
      if (this.inputValue) {
        // 如果输入值存在
        if (this.inputType != "all") {
          // 如果输入类型不是"all"
          // 将输入值与输入类型关联,并添加一个星号(*)作为后缀
          searchData[this.inputType + "*"] = this.inputValue;
        } else {
          // 如果输入类型是"all"
          // 遍历输入选项
          for (let index = 0; index < this.inputOptions.length; index++) {
            const item = this.inputOptions[index];
            if (item.value !== "all" ) {
              console.log(item.value, "987");
            const item = this.inputOptions[index]; // 获取当前选项
            if (item.value !== "all") {
              // 如果当前选项的值不是"all"
              if (!Object.keys(searchData).length) {
                searchData[item.value + "*"] = this.inputValue
                // 如果searchData是空的
                // 将第一个选项的值与输入值关联,并添加一个星号(*)作为后缀
                searchData[item.value + "*"] = this.inputValue;
              } else {
                searchData["||" + item.value + "*"] = this.inputValue
                // 如果searchData不是空的
                // 使用"||"作为前缀,将后续选项的值与输入值关联,并添加一个星号(*)作为后缀
                // 这通常用于构建一个逻辑或(OR)查询
                searchData["||" + item.value + "*"] = this.inputValue;
              }
            }
          }
        }
        console.log(searchData, "搜索数据123");
      }
      debugger
      // if (this.associationList && this.associationList.length) {
      //   this.associationList.forEach((item) => {
      //     if (item.value == "year") {
      //       const endDate = item.content.split("/")[0] + "/12/31 23:59:59";
      //       const startDate = item.content.split("/")[0] + "/01/01 00:00:00";
      //       searchData[item.value + ">="] = startDate;
      //       searchData[item.value + "<="] = endDate;
      //     } else {
      //       searchData["||" + item.value + "*"] = item.content;
      //     }
      //   });
      // }
      console.log(searchData, "searchData");
      MG.resource
        .getItem({
          path: "*",
          queryType: "*",
          paging: {
            start: (this.paginationPage - 1) * 6,
            size: 6
            start: (this.paginationPage - 1) * 10,
            size: 10,
          },
          sort: {
            year: this.postedSortInfo ? "Desc" : "Asc",
          },
          fields: {
            cmsType: ["cmsItem"],
            "resourceType*": this.resourceTypeValueList,
            "resourceType*":
              this.categoryChecList.length > 0
                ? this.categoryChecList
                : this.resourceTypeValueList,
            source: [],
            isbn: [],
            year: [],
            abstract: [],
            keyWords: [],
@@ -591,33 +679,84 @@
            AIReading: [],
            file: [],
            IssueNumber: [],
            "subjectAffiliation*": this.subjectCheckList,
            ...searchData,
          },
        })
        .then((res) => {
          console.log(res, "全部数据");
          console.log(res, "全部内容");
          res.datas.forEach((item) => {
            item.year = moment(item.year).format("YYYY-MM-DD")
            if (typeof item.keyWords === 'string') {
            item.year = moment(item.year).format("YYYY-MM-DD");
            if (typeof item.keyWords === "string") {
              item.keyWords = item.keyWords.split(";;");
            } else {
              // 设置一个默认值或者进行其他错误处理
              item.keyWords = [];
            }
            item.resourceTypeName = this.category.list.find((citem) => citem.value == item.cmsItemType).name
          })
          this.resultList = res.datas
            if (item.abstract) {
              item.cleanAbstract = item.abstract.replace(/<[^>]+>/g, "");
            }
            const foundItem = this.category.list.find(
              (citem) => citem.value == item.cmsItemType
            );
            item.resourceTypeName = foundItem ? foundItem.name : "";
          });
          this.resultList = res.datas;
          this.total = res.total;
          this.loading = false;
        })
    },
        }).catch((error) => {
          // 打印错误信息
          console.error("获取数据失败:", error);
        });
      // 滚动到页面顶部
      this.$nextTick(() => {
        const pageMain = document.querySelector('.page-main-father');
        if (pageMain) {
          pageMain.scrollTo({
            top: 0,
            behavior: 'smooth'
          });
        }
      });
    },
    // 处理页码变化
    handleCurrentChange(newPage) {
      this.paginationPage = newPage;
      this.getItemList(); // 重新获取数据
      // 滚动到页面顶部
      this.$nextTick(() => {
        const pageMain = document.querySelector(".page-main-father");
        if (pageMain) {
          pageMain.scrollTo({
            top: 0,
            behavior: "smooth",
          });
        }
      });
    },
    sortChange() {
      this.postedSortInfo = !this.postedSortInfo;
      this.getItemList();
    },
    getResourceTypeClass(typeName) {
      switch (typeName) {
        case 'journal':
          return 'journal-color';
        case 'books':
          return 'books-color';
        case 'video':
          return 'video-color';
        case 'audio':
          return 'audio-color';
        case 'newspaper':
          return 'newspaper-color';
        default:
          return 'other-color';
      }
    }
  },
};
</script>
@@ -656,11 +795,23 @@
  }
}
::v-deep .el-loading-spinner {
  .el-loading-text {
    font-size: 14px;
    color: #937950;
  }
  .el-icon-loading {
    font-size: 14px;
    color: #937950;
  }
}
.page-main-father {
  flex: 1;
  width: 100%;
  height: 100%;
  min-width: 1292px;
  min-width: 1200px;
  overflow: auto;
  padding-top: 1%;
  padding-bottom: 2%;
@@ -679,15 +830,40 @@
  background-color: #fefbf5;
  border: 1px solid #e4dace;
  .input-main {
  ::v-deep(.input-main) {
    padding: 15px 0;
    display: flex;
    justify-content: center;
    width: 90%;
    border-right: 2px solid #e4dace;
    font-weight: bold;
    .input-with-select {
      width: 50%;
      font-weight: bold;
    }
    .el-select .el-input.is-focus .el-input__inner {
      color: #937950 !important;
      border-color: #937950 !important;
      font-weight: bold;
    }
    .el-select-dropdown__item.selected {
      color: #937950 !important;
      font-weight: bold;
    }
    .el-select .el-input__inner:focus {
      border-color: #937950;
      font-weight: bold;
    }
    .el-select .el-input__inner {
      font-family: Source Han Sans;
      font-size: 14px;
      font-weight: bold;
      color: #2c2c2c;
    }
  }
@@ -740,10 +916,11 @@
        font-size: 14px;
        background-color: transparent;
        color: #937950;
        border: 1px solid #6f5a3a;
        border: 1px solid #937950;
        cursor: pointer;
        &:hover {
          background-color: #6f5a3a;
          background-color: #937950;
          color: #fffdf8;
        }
      }
@@ -906,6 +1083,7 @@
    .right-header {
      display: flex;
      flex-wrap: wrap;
      li {
        background: #ffffff;
@@ -917,6 +1095,8 @@
        font-family: Poppins;
        font-size: 13px;
        color: #937950;
        line-height: 20px;
        margin-bottom: 10px;
        img {
          cursor: pointer;
@@ -976,28 +1156,53 @@
        font-size: 16px;
        font-weight: bold;
        color: #937950;
        margin-bottom: 5px;
        p {
          overflow: hidden;
        }
        ::v-deep .el-button {
          font-size: 14px;
          background-color: transparent;
          color: #937950;
          border: 1px solid #6f5a3a;
          border: 1px solid #937950;
          border-radius: 0;
          &:hover {
            background-color: #6f5a3a;
            background-color: #937950;
            color: #fffdf8;
          }
        }
      }
      .journal-color {
        background-color: #87a8b9;
      }
      .books-color {
        background-color: #C48787;
      }
      .video-color {
        background-color: #6F8F5A;
      }
      .audio-color {
        background-color: #937950;
      }
      .newspaper-color {
        background-color: #8D77B3;
      }
      .other-color {
        background-color: #009F9F;
      }
      .main-sources {
        span:nth-child(1) {
          padding: 3px 5px;
          background-color: #87a8b9;
          color: #fff;
          margin-right: 10px;
        }
        span:nth-child(2) {
@@ -1006,7 +1211,6 @@
          font-weight: 350;
          padding-right: 10px;
          color: #333;
        }
        span:nth-child(3) {
@@ -1028,9 +1232,7 @@
          border-left: 1px solid #2c2c2c;
        }
        margin-bottom: 10px;
        margin-bottom: 15px;
      }
      .main-author {
@@ -1051,7 +1253,7 @@
        overflow: hidden;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 4;
        -webkit-line-clamp: 3;
        span {
          font-family: Source Han Sans;
@@ -1132,4 +1334,26 @@
  border-radius: 5px;
  border: 1px solid #cccccc;
}
:deep.el-pagination.is-background .el-pager li:not(.disabled):hover {
  color: #937950
}
</style>
<style>
.el-input.is-focus .el-input__inner {
  color: #937950 !important;
  border-color: #937950 !important;
  font-weight: bold;
}
.el-select-dropdown__item.selected {
  color: #937950 !important;
  font-weight: bold;
}
.el-select .el-input__inner:focus {
  border-color: #937950;
  font-weight: bold;
}
</style>