Skip to content

Commit

Permalink
Merge pull request #877 from vusion/hotfix-test/tableviewcache
Browse files Browse the repository at this point in the history
fix(TableView): 分页不用cache
  • Loading branch information
myronliu347 authored Jul 3, 2024
2 parents 100fd22 + a446593 commit d5ae950
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/components/u-table-view.vue/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,7 @@ export default {
getExtraParams: this.getExtraParams,
process: this.processData,
filterMultiple: this.filterMultiple,
useCache: !this.usePagination, // fix:2879747503294464 大数据分页使用cache性能问题
};
if (this.treeDisplay && this.valueField && this.parentField && this.childrenField) {
Expand Down
19 changes: 13 additions & 6 deletions src/utils/DataSource/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ const VueDataSource = Vue.extend({
queryChanged: false,

treeDisplay: false,
useCache: true,
};
},
computed: {
Expand Down Expand Up @@ -161,8 +162,10 @@ const VueDataSource = Vue.extend({
if (this.paging) {
if (this.viewMode === 'more')
return this.arrangedData.slice(0, this.offset + this.limit);
else
return this.arrangedData.slice(this.offset, this.offset + this.limit);
else {
const data = this.arrangedData.slice(this.offset, this.offset + this.limit);
return data.length === 0 ? this.arrangedData : data;
}
} else
return this.arrangedData;
},
Expand Down Expand Up @@ -415,11 +418,15 @@ const VueDataSource = Vue.extend({
if (!this.remotePaging || limit === Infinity) {
this.data = finalResult.data;
} else {
for (let i = 0; i < limit; i++) {
const item = finalResult.data[i];
if (item) {
this.data[offset + i] = item;
if (this.useCache) {
for (let i = 0; i < limit; i++) {
const item = finalResult.data[i];
if (item) {
this.data[offset + i] = item;
}
}
} else {
this.data = finalResult.data;
}
}

Expand Down

0 comments on commit d5ae950

Please sign in to comment.