杨磊
14 小时以前 87c87f989dcc3027407eccde48a6b35f0f999570
src/views/achievements/index.vue
@@ -251,16 +251,31 @@
              <li class="main-author">
                {{ item.author }}
              </li>
              <li class="main-title" :title="item.cleanAbstract" v-if="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>
              </li>
              <li class="main-keyword" v-if="item.keyWords && item.keyWords.length > 0">
              <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"
                  @click="
                    () =>
                      handleSearch({
                        text: citem,
                        type: 'keyWords',
                        label: '关键词',
                      })
                  "
                >
                  {{ citem }}
                </span>
@@ -278,8 +293,8 @@
              >
              </el-pagination>
            </div>
            <el-empty v-if="!loading && !resultList.length"></el-empty>
          </div>
          <el-empty v-if="!loading && !resultList.length"></el-empty>
        </div>
      </div>
    </div>
@@ -569,14 +584,21 @@
  methods: {
    categoryChange(val) {
      console.log(val, "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();
    },
@@ -679,12 +701,12 @@
      );
      this.inputValue = "";
      // 通知父组件数据已改变
      this.getItemList()
      this.getItemList();
    },
    // 搜索
    handleSearch(isText) {
      this.associationList = []
      this.associationList = [];
      if (isText.text != "") {
        this.inputValue = isText.text;
        this.inputType = isText.type;
@@ -699,19 +721,25 @@
    // 请求数据
    getItemList() {
      let searchData = {}; // 初始化一个空对象来存储搜索数据
      if (this.inputValue) { // 如果输入值存在
        if (this.inputType != "all") { // 如果输入类型不是"all"
      if (this.inputValue) {
        // 如果输入值存在
        if (this.inputType != "all") {
          // 如果输入类型不是"all"
          // 将输入值与输入类型关联,并添加一个星号(*)作为后缀
          searchData[this.inputType + "*"] = this.inputValue;
        } else { // 如果输入类型是"all"
        } else {
          // 如果输入类型是"all"
          // 遍历输入选项
          for (let index = 0; index < this.inputOptions.length; index++) {
            const item = this.inputOptions[index]; // 获取当前选项
            if (item.value !== "all") { // 如果当前选项的值不是"all"
              if (!Object.keys(searchData).length) { // 如果searchData是空的
            if (item.value !== "all") {
              // 如果当前选项的值不是"all"
              if (!Object.keys(searchData).length) {
                // 如果searchData是空的
                // 将第一个选项的值与输入值关联,并添加一个星号(*)作为后缀
                searchData[item.value + "*"] = this.inputValue;
              } else { // 如果searchData不是空的
              } else {
                // 如果searchData不是空的
                // 使用"||"作为前缀,将后续选项的值与输入值关联,并添加一个星号(*)作为后缀
                // 这通常用于构建一个逻辑或(OR)查询
                searchData["||" + item.value + "*"] = this.inputValue;
@@ -720,6 +748,19 @@
          }
        }
      }
      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: "*",
@@ -761,11 +802,16 @@
              // 设置一个默认值或者进行其他错误处理
              item.keyWords = [];
            }
            // 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
            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;
        });
@@ -776,11 +822,11 @@
      this.getItemList(); // 重新获取数据
      // 滚动到页面顶部
      this.$nextTick(() => {
        const pageMain = document.querySelector('.page-main-father');
        const pageMain = document.querySelector(".page-main-father");
        if (pageMain) {
          pageMain.scrollTo({
            top: 0,
            behavior: 'smooth'
            behavior: "smooth",
          });
        }
      });
@@ -827,6 +873,18 @@
  }
}
::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%;
@@ -850,15 +908,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;
    }
  }
@@ -911,11 +994,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;
        }
      }
@@ -1081,6 +1164,7 @@
    .right-header {
      display: flex;
      flex-wrap: wrap;
      li {
        background: #ffffff;
@@ -1092,6 +1176,8 @@
        font-family: Poppins;
        font-size: 13px;
        color: #937950;
        line-height: 20px;
        margin-bottom: 10px;
        img {
          cursor: pointer;
@@ -1151,16 +1237,17 @@
        font-size: 16px;
        font-weight: bold;
        color: #937950;
        margin-bottom: 5px;
        ::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;
          }
        }
@@ -1305,4 +1392,22 @@
  border-radius: 5px;
  border: 1px solid #cccccc;
}
</style>
</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>