Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
911 views
in Technique[技术] by (71.8m points)

vue查询全表数据,现在只能查一页,我该怎么改成查全部呢?

这是现在table表格的在计算属性的实现方法。
dataSource是放接口返回的table表数据,然后再经计算属性在我搜table数据时,实时改变table表的数据,但是现在只能搜索当前页的,我该怎么换成全部的,然后刚开始进入的分页接口那部分还不会改变。

table:
![image.png](/img/bVcHHYR)
搜索后:
![image.png](/img/bVcHHYY)

这个接口可以搜索全表,我给他传了值然后返回的数据是有的,但是我无法把他加入table表中,然后最开始的接口还管用。

this.$api.generator.exportExcel({

   st_name: this.st_name
  }).then((data)=>{
    console.log(data)

})

  computed: {
    // table数据处理
    datas() {
        const st_name = XEUtils.toString(this.st_name).trim().toLowerCase();
        if (st_name) {
          const filterRE = new RegExp(st_name, "gi");
          const searchProps = ["st_name"];
          const rest = this.dataSource.filter((item) =>
            searchProps.some(
              (key) =>
                XEUtils.toString(item[key])
                  .toLowerCase()
                  .indexOf(st_name) > -1
            )
          );
          return rest.map((row) => {
            const item = Object.assign({}, row);
            searchProps.forEach((key) => { // 改变字体颜色
              item[key] = XEUtils.toString(item[key]).replace(
                filterRE,
                (match) => `<span class="keyword-lighten">${match}</span>`
              );
            });
            return item;
          });
        }
      // })
      return this.dataSource;
    },
  },

接口:

    // 获取数据
    findList() {
      this.$api.generator.findAll({
        page: this.tablePage.currentPage,
        rows: this.tablePage.pageSize
      }).then((data)=>{
        console.log(data.content)
        this.dataSource = data.content;
        this.tablePage.totalResult = data.totalElements;
      })
    },

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

难道不是带着搜索关键字去查接口返回列表吗,每次搜索重置页数为1,重置列表内容为接口返回数组


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...