mirror of
https://github.com/kuaifan/dootask.git
synced 2026-03-17 11:13:26 +00:00
perf: 优化通讯录数量
This commit is contained in:
parent
83190d0f61
commit
70a4d3aab2
@ -126,7 +126,10 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li class="loaded">{{$L('共' + contactsFilter.length + '位联系人')}}</li>
|
<li class="loaded">
|
||||||
|
<template v-if="contactsKey">{{$L('搜索到' + contactsFilter.length + '位联系人')}}</template>
|
||||||
|
<template v-else>{{$L('共' + contactsTotal + '位联系人')}}</template>
|
||||||
|
</li>
|
||||||
</template>
|
</template>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="operate-position" :style="operateStyles">
|
<div class="operate-position" :style="operateStyles">
|
||||||
@ -137,7 +140,7 @@
|
|||||||
@on-clickoutside="operateVisible = false"
|
@on-clickoutside="operateVisible = false"
|
||||||
transfer>
|
transfer>
|
||||||
<div :style="{userSelect:operateVisible ? 'none' : 'auto', height: operateStyles.height}"></div>
|
<div :style="{userSelect:operateVisible ? 'none' : 'auto', height: operateStyles.height}"></div>
|
||||||
<DropdownMenu slot="list">
|
<DropdownMenu v-slot="list">
|
||||||
<DropdownItem @click.native="handleTopClick">
|
<DropdownItem @click.native="handleTopClick">
|
||||||
{{ $L(operateItem.top_at ? '取消置顶' : '置顶') }}
|
{{ $L(operateItem.top_at ? '取消置顶' : '置顶') }}
|
||||||
</DropdownItem>
|
</DropdownItem>
|
||||||
@ -208,6 +211,7 @@ export default {
|
|||||||
contactsKey: '',
|
contactsKey: '',
|
||||||
contactsLoad: 0,
|
contactsLoad: 0,
|
||||||
contactsData: null,
|
contactsData: null,
|
||||||
|
contactsTotal: 0,
|
||||||
contactsCurrentPage: 1,
|
contactsCurrentPage: 1,
|
||||||
contactsHasMorePages: false,
|
contactsHasMorePages: false,
|
||||||
contactsLastTime: 0,
|
contactsLastTime: 0,
|
||||||
@ -532,11 +536,7 @@ export default {
|
|||||||
switch (res.directionreal) {
|
switch (res.directionreal) {
|
||||||
case 'up':
|
case 'up':
|
||||||
if (res.scrollE < 10) {
|
if (res.scrollE < 10) {
|
||||||
if (this.tabActive === 'contacts'
|
this.getContactsNextPage()
|
||||||
&& this.contactsLoad == 0
|
|
||||||
&& this.contactsHasMorePages) {
|
|
||||||
this.getContactsList(this.contactsCurrentPage + 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -704,12 +704,11 @@ export default {
|
|||||||
|
|
||||||
getContactsList(page) {
|
getContactsList(page) {
|
||||||
this.contactsLoad++;
|
this.contactsLoad++;
|
||||||
|
const key = this.contactsKey
|
||||||
this.$store.dispatch("call", {
|
this.$store.dispatch("call", {
|
||||||
url: 'users/search',
|
url: 'users/search',
|
||||||
data: {
|
data: {
|
||||||
keys: {
|
keys: {key},
|
||||||
key: this.contactsKey
|
|
||||||
},
|
|
||||||
sorts: {
|
sorts: {
|
||||||
az: 'asc'
|
az: 'asc'
|
||||||
},
|
},
|
||||||
@ -717,6 +716,9 @@ export default {
|
|||||||
pagesize: 50
|
pagesize: 50
|
||||||
},
|
},
|
||||||
}).then(({data}) => {
|
}).then(({data}) => {
|
||||||
|
if (key == '') {
|
||||||
|
this.contactsTotal = data.total;
|
||||||
|
}
|
||||||
if (this.contactsData === null) {
|
if (this.contactsData === null) {
|
||||||
this.contactsData = [];
|
this.contactsData = [];
|
||||||
}
|
}
|
||||||
@ -727,7 +729,11 @@ export default {
|
|||||||
});
|
});
|
||||||
this.contactsCurrentPage = data.current_page;
|
this.contactsCurrentPage = data.current_page;
|
||||||
this.contactsHasMorePages = data.current_page < data.last_page;
|
this.contactsHasMorePages = data.current_page < data.last_page;
|
||||||
|
this.$nextTick(this.getContactsNextPage);
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
|
if (key == '') {
|
||||||
|
this.contactsTotal = 0;
|
||||||
|
}
|
||||||
this.contactsHasMorePages = false;
|
this.contactsHasMorePages = false;
|
||||||
}).finally(_ => {
|
}).finally(_ => {
|
||||||
this.contactsLoad--;
|
this.contactsLoad--;
|
||||||
@ -735,6 +741,16 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getContactsNextPage() {
|
||||||
|
const {scrollE} = this.$refs.list.scrollInfo();
|
||||||
|
if (scrollE < 10
|
||||||
|
&& this.tabActive === 'contacts'
|
||||||
|
&& this.contactsLoad === 0
|
||||||
|
&& this.contactsHasMorePages) {
|
||||||
|
this.getContactsList(this.contactsCurrentPage + 1);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
updateContactsList(timeout) {
|
updateContactsList(timeout) {
|
||||||
this.__updateContactsList && clearTimeout(this.__updateContactsList)
|
this.__updateContactsList && clearTimeout(this.__updateContactsList)
|
||||||
if (timeout > -1) {
|
if (timeout > -1) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user