通讯录-常用联系人分页

病例库-审批人默认为空不为0
main
ysn 6 days ago
parent 015855f7d0
commit b90aadb7e0
  1. 4
      src/views/cases/detail.vue
  2. 214
      src/views/contacts/index.vue

@ -1014,6 +1014,10 @@ export default {
this.form.attachment = Array.isArray(res.data.attachment)
? res.data.attachment
: [];
// reviewer_id0
if (this.form.reviewer_id === 0) {
this.form.reviewer_id = "";
}
//
this.originalForm = JSON.parse(JSON.stringify(this.form));
this.getReviewers();

@ -42,7 +42,12 @@
@click="handleRefresh"
/>
</div>
<div v-loading="loading" class="member-list">
<!-- 滚动事件只在常用联系人场景生效 -->
<div
v-loading="loading"
class="member-list"
@scroll="handleScroll"
>
<div
v-for="member in memberList"
:key="member.id"
@ -65,6 +70,11 @@
v-if="!loading && !memberList.length"
description="暂无成员"
/>
<!-- 分页底部提示仅常用联系人展示 -->
<div v-if="isLatestContacts && memberList.length > 0" class="load-more-tip">
<span v-if="loadMoreLoading">加载更多...</span>
<span v-if="noMore && !loadMoreLoading">没有更多数据了</span>
</div>
</div>
</div>
@ -152,6 +162,11 @@ export default {
loading: false,
isLatestContacts: false,
userGroupId: null,
// /使
pageNum: 1,
pageSize: 15,
noMore: false,
loadMoreLoading: false,
//
leftTabList: [
{
@ -197,13 +212,107 @@ export default {
setSelectUser(user) {
this.currentUser = { ...user };
},
//
resetPage() {
this.pageNum = 1;
this.noMore = false;
this.memberList = [];
},
//
handleScroll(e) {
//
if (!this.isLatestContacts) return;
const el = e.target;
const scrollTop = el.scrollTop;
const scrollHeight = el.scrollHeight;
const clientHeight = el.clientHeight;
// 50px
if (scrollTop + clientHeight >= scrollHeight - 50) {
this.loadNextPage();
}
},
//
loadNextPage() {
// /
if (this.loadMoreLoading || this.noMore || this.loading) return;
this.pageNum++;
this.loadMemberList(false);
},
//
// isRefresh: true= false=
async loadMemberList(isRefresh = true) {
if (isRefresh) {
this.loading = true;
this.resetPage();
} else {
this.loadMoreLoading = true;
}
try {
const keyword = this.searchText.trim();
let resList = [];
//
if (keyword) {
const { data } = await searchUsers({
search_key: keyword,
user_ids: [],
page: this.pageNum,
size: this.pageSize,
});
resList = data.list || [];
this.isLatestContacts = true;
this.currentStructureName = "搜索结果";
this.currentGroupId = null;
this.$refs.orgTree.setCurrentKey(null);
} else if (this.isLatestContacts) {
//
const { data } = await getMessagesLatestContacts({
scene: 1,
page: this.pageNum,
size: this.pageSize,
});
resList = data.list || [];
} else {
//
const { data } = await getGroupsListUser({ group_id: this.currentGroupId });
resList = data.list || [];
}
const formatList = resList.map(item => ({
...item,
online: [1, true].includes(item.online)
}));
if (isRefresh) {
this.memberList = formatList;
} else {
this.memberList.push(...formatList);
}
// /
if (this.isLatestContacts) {
this.noMore = formatList.length < this.pageSize;
} else {
this.noMore = true; //
}
//
if (isRefresh && this.memberList.length) {
this.setSelectUser(this.memberList[0]);
}
} catch (err) {
console.error("加载列表失败", err);
if (isRefresh) this.memberList = [];
} finally {
this.loading = false;
this.loadMoreLoading = false;
}
},
//
async fetchOrgTree() {
try {
const { data } = await getGroupsList();
this.treeData = data.list;
//
this.defaultExpandedKeys = this.treeData.map((node) => node.id);
this.defaultExpandedKeys = this.treeData.map(node => node.id);
if (!this.userGroupId) return;
const parentKeys = this.findParentKeys(this.treeData, this.userGroupId);
this.$nextTick(() => {
@ -211,7 +320,8 @@ export default {
const node = this.findNodeById(this.treeData, this.userGroupId);
if (node) {
this.currentStructureName = node.name;
this.fetchMembers(this.userGroupId);
this.currentGroupId = node.id;
this.loadMemberList(true);
}
});
} catch (err) {
@ -221,11 +331,8 @@ export default {
findParentKeys(tree, targetId, parents = []) {
for (const node of tree) {
if (node.id === targetId) return [...parents, node.id];
if (node.children.length) {
const res = this.findParentKeys(node.children, targetId, [
...parents,
node.id,
]);
if (node.child && node.child.length) {
const res = this.findParentKeys(node.child, targetId, [...parents, node.id]);
if (res.length) return res;
}
}
@ -234,97 +341,56 @@ export default {
findNodeById(tree, id) {
for (const node of tree) {
if (node.id === id) return node;
if (node.children) {
const res = this.findNodeById(node.children, id);
if (node.child) {
const res = this.findNodeById(node.child, id);
if (res) return res;
}
}
return null;
},
//
//
handleNodeClick(data) {
this.isLatestContacts = false;
this.currentStructureName = data.name;
this.currentGroupId = data.id;
this.currentUser = null;
this.fetchMembers(data.id);
this.loadMemberList(true);
},
//
async fetchMembers(groupId) {
this.loading = true;
try {
const { data } = await getGroupsListUser({ group_id: groupId });
this.memberList = data.list || [];
this.memberList.length && this.setSelectUser(this.memberList[0]);
} catch (err) {
console.error("获取成员失败", err);
this.memberList = [];
} finally {
this.loading = false;
}
//
fetchMembers(groupId) {
this.currentGroupId = groupId;
this.loadMemberList(true);
},
//
async showLatestContacts() {
//
showLatestContacts() {
this.isLatestContacts = true;
this.currentStructureName = "最近联系人";
this.currentGroupId = null;
this.currentUser = null;
this.$refs.orgTree.setCurrentKey(null);
this.loading = true;
try {
const { data } = await getMessagesLatestContacts({
scene: 1,
page: 1,
size: 65535,
});
this.memberList = data.list || [];
this.memberList.length && this.setSelectUser(this.memberList[0]);
} catch (err) {
console.error("常用联系人异常", err);
this.memberList = [];
} finally {
this.loading = false;
}
this.loadMemberList(true);
},
//
async handleSearch() {
handleSearch() {
const keyword = this.searchText.trim();
if (!keyword) return this.handleClearSearch();
this.loading = true;
try {
const { data } = await searchUsers({
search_key: keyword,
user_ids: [],
page: 1,
size: 10000,
});
this.isLatestContacts = true;
this.currentStructureName = "搜索结果";
this.currentGroupId = null;
this.$refs.orgTree.setCurrentKey(null);
this.memberList = (data.list || []).map((item) => ({
...item,
online: [1, true].includes(item.online),
}));
this.memberList.length && this.setSelectUser(this.memberList[0]);
} catch (err) {
console.error("搜索失败", err);
} finally {
this.loading = false;
}
this.loadMemberList(true);
},
//
handleClearSearch() {
this.searchText = "";
if (this.isLatestContacts) this.showLatestContacts();
else if (this.currentGroupId) this.fetchMembers(this.currentGroupId);
else if (this.userGroupId) this.fetchMembers(this.userGroupId);
if (this.isLatestContacts) {
this.showLatestContacts();
} else if (this.currentGroupId) {
this.loadMemberList(true);
} else if (this.userGroupId) {
this.currentGroupId = this.userGroupId;
this.loadMemberList(true);
}
},
//
handleRefresh() {
this.isLatestContacts
? this.showLatestContacts()
: this.fetchMembers(this.currentGroupId);
this.loadMemberList(true);
},
//
sendMessage() {
@ -450,15 +516,13 @@ export default {
flex-shrink: 0;
}
}
.load-more {
.load-more-tip {
padding: 12px;
text-align: center;
.loading-text {
font-size: 12px;
color: #909399;
}
}
}
}
//
.addrbook-right {

Loading…
Cancel
Save