refactor(ckchat): 优化联系人列表创建逻辑并移除调试日志

- 将重复的kfSelected过滤逻辑提取到公共位置
- 为groupType=2的情况添加未分组联系人查询支持
- 移除不必要的console.log调试输出
This commit is contained in:
超级老白兔
2025-09-18 15:06:25 +08:00
parent d110c97424
commit f58b95cd95

View File

@@ -21,7 +21,6 @@ export const createContractList = async (
for (const label of countLables) {
let data;
if (label.groupType === 1) {
console.log(label.groupName);
if (label.id == 0) {
data = await contractService.findWhereMultiple([
{
@@ -30,22 +29,28 @@ export const createContractList = async (
value: realGroup,
},
]);
// 过滤出 kfSelected 对应的联系人
if (kfSelected && kfSelected != 0) {
data = data.filter(contact => contact.wechatAccountId === kfSelected);
}
} else {
data = await contractService.findWhere("groupId", label.id);
// 过滤出 kfSelected 对应的联系人
if (kfSelected && kfSelected != 0) {
data = data.filter(contact => contact.wechatAccountId === kfSelected);
}
}
// 过滤出 kfSelected 对应的联系人
if (kfSelected && kfSelected != 0) {
data = data.filter(contact => contact.wechatAccountId === kfSelected);
}
// console.log(`标签 ${label.groupName} 对应的联系人数据:`, data);
} else if (label.groupType === 2) {
// groupType: 2, 查询 weChatGroupService
data = await weChatGroupService.findWhere("groupId", label.id);
if (label.id == 0) {
data = await weChatGroupService.findWhereMultiple([
{
field: "groupId",
operator: "notIn",
value: realGroup,
},
]);
} else {
data = await weChatGroupService.findWhere("groupId", label.id);
// 过滤出 kfSelected 对应的联系人
}
if (kfSelected && kfSelected != 0) {
data = data.filter(contact => contact.wechatAccountId === kfSelected);
}