|
|
|
@ -11,13 +11,14 @@ |
|
|
|
<span>常用联系人</span> |
|
|
|
<span>常用联系人</span> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="latest-contacts"> |
|
|
|
<div class="latest-contacts"> |
|
|
|
|
|
|
|
<i class="el-icon-office-building" /> |
|
|
|
<span>组织架构</span> |
|
|
|
<span>组织架构</span> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<el-tree |
|
|
|
<el-tree |
|
|
|
ref="orgTree" |
|
|
|
ref="orgTree" |
|
|
|
:data="treeData" |
|
|
|
:data="treeData" |
|
|
|
:props="treeProps" |
|
|
|
:props="treeProps" |
|
|
|
:default-expanded-keys="expandedKeys" |
|
|
|
default-expand-all |
|
|
|
:highlight-current="true" |
|
|
|
:highlight-current="true" |
|
|
|
node-key="id" |
|
|
|
node-key="id" |
|
|
|
@node-click="handleNodeClick" |
|
|
|
@node-click="handleNodeClick" |
|
|
|
@ -127,7 +128,7 @@ |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="action-section"> |
|
|
|
<div class="action-section"> |
|
|
|
<el-button |
|
|
|
<el-button |
|
|
|
type="success" |
|
|
|
type="primary" |
|
|
|
icon="el-icon-chat-dot-round" |
|
|
|
icon="el-icon-chat-dot-round" |
|
|
|
@click="sendMessage" |
|
|
|
@click="sendMessage" |
|
|
|
> |
|
|
|
> |
|
|
|
@ -144,10 +145,14 @@ |
|
|
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
<script> |
|
|
|
import EventBus from "@/utils/eventBus"; |
|
|
|
import EventBus from "@/utils/eventBus"; |
|
|
|
import { getAddrBook, listUsers } from "@/api/addressBook/index.js"; |
|
|
|
import { |
|
|
|
import { getLatestContacts, searchUsers } from "@/api/message/index.js"; |
|
|
|
getMessagesLatestContacts, |
|
|
|
|
|
|
|
getGroupsList, |
|
|
|
|
|
|
|
getGroupsListUser, |
|
|
|
|
|
|
|
searchUsers, |
|
|
|
|
|
|
|
} from "@/api/contacts/index.js"; |
|
|
|
export default { |
|
|
|
export default { |
|
|
|
name: "AddressBook", |
|
|
|
name: "Contacts", |
|
|
|
filters: { |
|
|
|
filters: { |
|
|
|
avatarFilter(avatar) { |
|
|
|
avatarFilter(avatar) { |
|
|
|
if (!avatar) return ""; |
|
|
|
if (!avatar) return ""; |
|
|
|
@ -187,34 +192,15 @@ export default { |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
mounted() { |
|
|
|
mounted() { |
|
|
|
this.initUserInfo(); |
|
|
|
// 默认显示常用联系人 |
|
|
|
|
|
|
|
this.showLatestContacts(); |
|
|
|
this.fetchOrgTree(); |
|
|
|
this.fetchOrgTree(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
methods: { |
|
|
|
// 初始化当前用户信息,与 Qt SetCurDetailInfo 对应 |
|
|
|
|
|
|
|
initUserInfo() { |
|
|
|
|
|
|
|
const info = this.currentUserInfo; |
|
|
|
|
|
|
|
if (info) { |
|
|
|
|
|
|
|
this.currentUser = { |
|
|
|
|
|
|
|
id: info.id, |
|
|
|
|
|
|
|
name: info.name, |
|
|
|
|
|
|
|
role: info.role, |
|
|
|
|
|
|
|
phone: info.phone, |
|
|
|
|
|
|
|
status: info.status, |
|
|
|
|
|
|
|
email: info.email, |
|
|
|
|
|
|
|
group: info.group, |
|
|
|
|
|
|
|
full_group: info.full_group || info.group, |
|
|
|
|
|
|
|
avatar: info.avatar, |
|
|
|
|
|
|
|
online: info.status === 0, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
this.userGroupId = info.group_id || info.grp_id; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取组织架构树,与 Qt Cmd_addr_book_addr 对应,POST 空 body |
|
|
|
// 获取组织架构树,与 Qt Cmd_addr_book_addr 对应,POST 空 body |
|
|
|
async fetchOrgTree() { |
|
|
|
async fetchOrgTree() { |
|
|
|
try { |
|
|
|
try { |
|
|
|
const res = await getAddrBook(); |
|
|
|
const res = await getGroupsList(); |
|
|
|
const list = res.data?.list || []; |
|
|
|
const list = res.data?.list || []; |
|
|
|
this.treeData = this.buildTree(list); |
|
|
|
this.treeData = this.buildTree(list); |
|
|
|
// 自动展开当前用户所在组 |
|
|
|
// 自动展开当前用户所在组 |
|
|
|
@ -294,9 +280,7 @@ export default { |
|
|
|
async fetchMembers(groupId) { |
|
|
|
async fetchMembers(groupId) { |
|
|
|
this.loading = true; |
|
|
|
this.loading = true; |
|
|
|
try { |
|
|
|
try { |
|
|
|
const res = await listUsers({ |
|
|
|
const res = await getGroupsListUser({ group_id: groupId }); |
|
|
|
group_id: groupId, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
const list = res.data?.list || []; |
|
|
|
const list = res.data?.list || []; |
|
|
|
// 与 Qt 代码一致:区分在线离线,但这里统一存入 memberList,由 computed 排序 |
|
|
|
// 与 Qt 代码一致:区分在线离线,但这里统一存入 memberList,由 computed 排序 |
|
|
|
this.memberList = list.map((item) => ({ |
|
|
|
this.memberList = list.map((item) => ({ |
|
|
|
@ -311,6 +295,11 @@ export default { |
|
|
|
avatar: item.avatar, |
|
|
|
avatar: item.avatar, |
|
|
|
online: item.online === 1 || item.online === true, |
|
|
|
online: item.online === 1 || item.online === true, |
|
|
|
})); |
|
|
|
})); |
|
|
|
|
|
|
|
// 默认选择第一个联系人 |
|
|
|
|
|
|
|
if (this.memberList.length > 0) { |
|
|
|
|
|
|
|
this.handleMemberClick(this.memberList[0]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
console.log(this.memberList, "组成员"); |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
console.error("获取成员列表失败", e); |
|
|
|
console.error("获取成员列表失败", e); |
|
|
|
this.memberList = []; |
|
|
|
this.memberList = []; |
|
|
|
@ -334,10 +323,10 @@ export default { |
|
|
|
async fetchLatestContacts() { |
|
|
|
async fetchLatestContacts() { |
|
|
|
this.loading = true; |
|
|
|
this.loading = true; |
|
|
|
try { |
|
|
|
try { |
|
|
|
const res = await getLatestContacts({ |
|
|
|
const res = await getMessagesLatestContacts({ |
|
|
|
scene: 1, |
|
|
|
scene: 1, |
|
|
|
page: 1, |
|
|
|
page: 1, |
|
|
|
// size: 65535, |
|
|
|
size: 65535, |
|
|
|
}); |
|
|
|
}); |
|
|
|
const list = res.data?.list || []; |
|
|
|
const list = res.data?.list || []; |
|
|
|
this.memberList = list.map((item) => ({ |
|
|
|
this.memberList = list.map((item) => ({ |
|
|
|
@ -352,6 +341,10 @@ export default { |
|
|
|
avatar: item.avatar, |
|
|
|
avatar: item.avatar, |
|
|
|
online: item.online === 1 || item.online === true, |
|
|
|
online: item.online === 1 || item.online === true, |
|
|
|
})); |
|
|
|
})); |
|
|
|
|
|
|
|
// 默认选择第一个联系人 |
|
|
|
|
|
|
|
if (this.memberList.length > 0) { |
|
|
|
|
|
|
|
this.handleMemberClick(this.memberList[0]); |
|
|
|
|
|
|
|
} |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
console.error("获取最近联系人失败", e); |
|
|
|
console.error("获取最近联系人失败", e); |
|
|
|
this.memberList = []; |
|
|
|
this.memberList = []; |
|
|
|
|