2024-12-24 08:28:44 +00:00
|
|
|
|
<template>
|
2025-01-24 03:18:26 +00:00
|
|
|
|
<div class="create-group-chat-page">
|
|
|
|
|
<zPaging ref="zPaging" :show-scrollbar="false">
|
|
|
|
|
<template #top>
|
|
|
|
|
<customNavbar :title="$t('pageTitle.create.group')"></customNavbar>
|
|
|
|
|
</template>
|
|
|
|
|
<div class="create-group-chat flex flex-col">
|
|
|
|
|
<div class="group-avatar flex items-center justify-center">
|
|
|
|
|
<div class="avatar-placeholder" v-if="groupActiveIndex === -1"></div>
|
|
|
|
|
<div v-else>
|
2025-04-11 01:51:06 +00:00
|
|
|
|
<avatarModule :mode="2" :avatar="avatarImg" :groupType="groupType"
|
|
|
|
|
:customStyle="{ width: '192rpx', height: '192rpx' }"></avatarModule>
|
2024-12-24 08:28:44 +00:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-01-22 08:37:28 +00:00
|
|
|
|
<div class="input-group flex items-center justify-between">
|
2024-12-24 08:28:44 +00:00
|
|
|
|
<div class="input-item">
|
|
|
|
|
群名称
|
|
|
|
|
</div>
|
2025-01-22 08:37:28 +00:00
|
|
|
|
<div class="input-box">
|
2025-04-11 01:51:06 +00:00
|
|
|
|
<tm-input v-model="groupName" :followTheme="false" fontColor="#747474" placeholderStyle="color: #B4B4B4"
|
|
|
|
|
focusColor="#FFF" :fontSize="28" :maxlength="20" :height="40" :transprent="true"
|
|
|
|
|
placeholder="请输入群名称(1~20个字)" :padding="[0, 0]" align="right"></tm-input>
|
2024-12-24 08:28:44 +00:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-04-11 01:51:06 +00:00
|
|
|
|
<div class="input-group w-full flex flex-col mt-[20rpx] leading-[40rpx]">
|
2025-01-22 08:37:28 +00:00
|
|
|
|
<div class="flex items-center justify-between">
|
2025-01-08 01:18:41 +00:00
|
|
|
|
<div class="input-item">
|
|
|
|
|
群类型
|
|
|
|
|
</div>
|
2025-01-22 08:37:28 +00:00
|
|
|
|
<div @click="chooseGroupType" class="left-box">
|
|
|
|
|
<div class="text-[#B4B4B4] text-[28rpx] font-bold">
|
|
|
|
|
<span v-if="groupActiveIndex === -1">请选择群类型</span>
|
|
|
|
|
<span v-else-if="groupActiveIndex === 0">普通群</span>
|
|
|
|
|
<span v-else-if="groupActiveIndex === 1">部门群</span>
|
|
|
|
|
<span v-else-if="groupActiveIndex === 2">项目群</span>
|
2025-01-08 01:18:41 +00:00
|
|
|
|
</div>
|
2025-01-22 08:37:28 +00:00
|
|
|
|
<div class="ml-[32rpx]">
|
2025-04-11 01:51:06 +00:00
|
|
|
|
<tm-icon :font-size="22" color="#747474" name="tmicon-angle-right"></tm-icon>
|
2025-01-08 01:18:41 +00:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-12-24 08:28:44 +00:00
|
|
|
|
</div>
|
2025-04-11 01:51:06 +00:00
|
|
|
|
<div v-if="depCheckedKeys.length && groupActiveIndex === 1" class="mt-[32rpx]">
|
|
|
|
|
<div v-for="(item, index) in depCheckedKeys" class="text-[#747474] text-[28rpx] leading-[40rpx] font-bold"
|
2025-01-08 01:18:41 +00:00
|
|
|
|
:class="[
|
2025-01-22 08:37:28 +00:00
|
|
|
|
index !== 0 ? 'mt-[10rpx]' : '',
|
2025-03-24 07:55:54 +00:00
|
|
|
|
depsNoExpanded_1 && index > 4 ? 'hidden' : '',
|
2025-04-11 01:51:06 +00:00
|
|
|
|
]">
|
2025-01-08 01:18:41 +00:00
|
|
|
|
{{ item.name }}
|
2024-12-24 08:28:44 +00:00
|
|
|
|
</div>
|
2025-04-11 01:51:06 +00:00
|
|
|
|
<div class="text-[#46299D] text-[28rpx] mt-[20rpx] font-bold flex justify-center">
|
|
|
|
|
<div v-if="depCheckedKeys.length > 5" @click="depsNoExpanded_1 = !depsNoExpanded_1" class="w-[100rpx]">
|
2025-03-24 07:55:54 +00:00
|
|
|
|
{{ depsNoExpanded_1 ? '展开' : '收起' }}
|
2025-01-08 01:18:41 +00:00
|
|
|
|
</div>
|
2024-12-24 08:28:44 +00:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-01-22 08:37:28 +00:00
|
|
|
|
|
2025-04-11 01:51:06 +00:00
|
|
|
|
<div v-if="groupActiveIndex === 0 || groupActiveIndex === 2"
|
|
|
|
|
class="input-group w-full flex flex-col mt-[20rpx] leading-[40rpx]">
|
2025-01-22 08:37:28 +00:00
|
|
|
|
<div class="flex items-center justify-between">
|
2025-01-13 03:13:51 +00:00
|
|
|
|
<div class="input-item">
|
|
|
|
|
群成员
|
|
|
|
|
</div>
|
2025-01-22 08:37:28 +00:00
|
|
|
|
<div @click="chooseMembers" class="left-box">
|
|
|
|
|
<div class="ml-[32rpx] flex items-center">
|
2025-04-11 01:51:06 +00:00
|
|
|
|
<div class="text-[#B4B4B4] text-[28rpx] font-bold mr-[32rpx]">
|
2025-01-24 09:01:50 +00:00
|
|
|
|
全部({{ allChooseMembers?.length || 0 }})
|
2025-01-22 08:37:28 +00:00
|
|
|
|
</div>
|
2025-04-11 01:51:06 +00:00
|
|
|
|
<tm-icon :font-size="22" color="#747474" name="tmicon-angle-right"></tm-icon>
|
2025-01-13 03:13:51 +00:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-04-11 01:51:06 +00:00
|
|
|
|
<groupMemberList :groupType="3" :is_manager="true" :memberList="allChooseMembers" :memberListsLimit="15"
|
|
|
|
|
:hideAddRemoveBtns="true"></groupMemberList>
|
2025-01-13 03:13:51 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
2025-04-11 01:51:06 +00:00
|
|
|
|
<div v-if="groupActiveIndex === 1" class="input-group w-full flex flex-col mt-[20rpx] leading-[40rpx]">
|
2025-01-22 08:37:28 +00:00
|
|
|
|
<div class="flex items-center justify-between">
|
2025-01-08 01:18:41 +00:00
|
|
|
|
<div class="input-item">
|
|
|
|
|
群管理员
|
|
|
|
|
</div>
|
2025-01-22 08:37:28 +00:00
|
|
|
|
<div @click="chooseGroupAdmin" class="left-box">
|
|
|
|
|
<div class="ml-[32rpx] flex items-center">
|
2025-04-11 01:51:06 +00:00
|
|
|
|
<div v-if="!groupAdmins.length" class="text-[#B4B4B4] text-[28rpx] font-bold mr-[32rpx]">
|
2025-01-22 08:37:28 +00:00
|
|
|
|
请选择群管理员
|
|
|
|
|
</div>
|
2025-04-11 01:51:06 +00:00
|
|
|
|
<tm-icon :font-size="22" color="#747474" name="tmicon-angle-right"></tm-icon>
|
2025-01-08 01:18:41 +00:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-01-22 08:37:28 +00:00
|
|
|
|
<div v-if="groupAdmins.length" class="mt-[32rpx]">
|
2025-04-11 01:51:06 +00:00
|
|
|
|
<div v-for="(item, index) in groupAdmins" class="text-[#747474] text-[28rpx] leading-[40rpx] font-bold"
|
2025-01-08 01:18:41 +00:00
|
|
|
|
:class="[
|
2025-01-22 08:37:28 +00:00
|
|
|
|
index !== 0 ? 'mt-[10rpx]' : '',
|
2025-03-24 07:55:54 +00:00
|
|
|
|
depsNoExpanded_2 && index > 4 ? 'hidden' : '',
|
2025-04-11 01:51:06 +00:00
|
|
|
|
]">
|
2025-01-08 01:18:41 +00:00
|
|
|
|
{{ item.name }}
|
|
|
|
|
</div>
|
2025-04-11 01:51:06 +00:00
|
|
|
|
<div class="text-[#46299D] text-[28rpx] mt-[20rpx] font-bold flex justify-center">
|
|
|
|
|
<div v-if="groupAdmins.length > 5" @click="depsNoExpanded_2 = !depsNoExpanded_2" class="w-[100rpx]">
|
2025-03-24 07:55:54 +00:00
|
|
|
|
{{ depsNoExpanded_2 ? '展开' : '收起' }}
|
2025-01-08 01:18:41 +00:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-12-24 08:28:44 +00:00
|
|
|
|
</div>
|
2025-01-24 03:18:26 +00:00
|
|
|
|
<template #bottom>
|
2025-04-11 01:51:06 +00:00
|
|
|
|
<customBtn :isBottom="true" :btnText="$t('pageTitle.create.group')" @click="handleConfirm"
|
|
|
|
|
:disabled="confirmBtnStatus"></customBtn>
|
2025-01-24 03:18:26 +00:00
|
|
|
|
</template>
|
|
|
|
|
</zPaging>
|
2024-12-24 08:28:44 +00:00
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<script setup>
|
2025-04-11 01:51:06 +00:00
|
|
|
|
import zPaging from '@/uni_modules/z-paging/components/z-paging/z-paging.vue'
|
|
|
|
|
import customBtn from '@/components/custom-btn/custom-btn.vue'
|
|
|
|
|
import groupMemberList from '../chatSettings/components/groupMembersList.vue'
|
|
|
|
|
import avatarModule from '@/components/avatar-module/index.vue'
|
2025-01-24 03:18:26 +00:00
|
|
|
|
|
2025-04-11 01:51:06 +00:00
|
|
|
|
import {
|
|
|
|
|
ref,
|
|
|
|
|
watch,
|
|
|
|
|
computed,
|
|
|
|
|
onMounted
|
|
|
|
|
} from 'vue'
|
|
|
|
|
import {
|
|
|
|
|
onShow,
|
|
|
|
|
onLoad,
|
|
|
|
|
onUnload
|
|
|
|
|
} from '@dcloudio/uni-app'
|
|
|
|
|
import {
|
|
|
|
|
useChatList
|
|
|
|
|
} from '@/store/chatList/index.js'
|
|
|
|
|
import {
|
|
|
|
|
useAuth
|
|
|
|
|
} from '@/store/auth'
|
|
|
|
|
import {
|
|
|
|
|
useTalkStore,
|
|
|
|
|
useUserStore,
|
|
|
|
|
useGroupStore
|
|
|
|
|
} from '@/store'
|
|
|
|
|
import addCircle from '@/static/image/chatList/addCircle.png'
|
|
|
|
|
import cahtPopover from '@/static/image/chatList/cahtPopover.png'
|
|
|
|
|
import {
|
|
|
|
|
ServeCreateGroup
|
|
|
|
|
} from '@/api/group/index'
|
|
|
|
|
import {
|
|
|
|
|
useGroupTypeStore
|
|
|
|
|
} from '@/store/groupType'
|
|
|
|
|
import {
|
|
|
|
|
handleSetWebviewStyle
|
|
|
|
|
} from '@/utils/common'
|
2024-12-24 08:28:44 +00:00
|
|
|
|
|
2025-04-11 01:51:06 +00:00
|
|
|
|
const {
|
|
|
|
|
groupName,
|
|
|
|
|
groupActiveIndex,
|
|
|
|
|
depCheckedKeys,
|
|
|
|
|
groupAdmins,
|
|
|
|
|
createDepGroup,
|
|
|
|
|
resetGroupInfo,
|
|
|
|
|
allChooseMembers,
|
|
|
|
|
} = useGroupTypeStore()
|
|
|
|
|
const talkStore = useTalkStore()
|
|
|
|
|
const userStore = useUserStore()
|
|
|
|
|
const groupStore = useGroupStore()
|
|
|
|
|
const {
|
|
|
|
|
userInfo
|
|
|
|
|
} = useAuth()
|
2024-12-24 08:28:44 +00:00
|
|
|
|
|
2025-04-11 01:51:06 +00:00
|
|
|
|
const groupChatType = ref('')
|
|
|
|
|
const depsNoExpanded_1 = ref(true)
|
|
|
|
|
const depsNoExpanded_2 = ref(true)
|
2024-12-24 08:28:44 +00:00
|
|
|
|
|
2025-03-17 10:45:20 +00:00
|
|
|
|
|
2025-04-11 01:51:06 +00:00
|
|
|
|
onLoad(() => {
|
|
|
|
|
groupStore.$reset()
|
2024-12-24 08:28:44 +00:00
|
|
|
|
})
|
2025-04-11 01:51:06 +00:00
|
|
|
|
onUnload(() => {
|
|
|
|
|
resetGroupInfo();
|
|
|
|
|
})
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
handleSetWebviewStyle()
|
2025-01-08 01:18:41 +00:00
|
|
|
|
})
|
|
|
|
|
|
2025-04-11 01:51:06 +00:00
|
|
|
|
//群类型
|
|
|
|
|
const groupType = computed(() => {
|
|
|
|
|
let group_type = ''
|
|
|
|
|
switch (groupActiveIndex.value) {
|
|
|
|
|
case 0:
|
|
|
|
|
group_type = 1
|
|
|
|
|
break
|
|
|
|
|
case 1:
|
|
|
|
|
group_type = 2
|
|
|
|
|
break
|
|
|
|
|
case 2:
|
|
|
|
|
group_type = 3
|
|
|
|
|
break
|
|
|
|
|
default:
|
|
|
|
|
group_type = ''
|
|
|
|
|
}
|
|
|
|
|
return group_type
|
2025-01-13 03:13:51 +00:00
|
|
|
|
})
|
|
|
|
|
|
2025-04-11 01:51:06 +00:00
|
|
|
|
//点击跳转到选择群类型页面
|
|
|
|
|
const chooseGroupType = () => {
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: '/pages/chooseGroupType/index',
|
2025-01-22 08:37:28 +00:00
|
|
|
|
})
|
|
|
|
|
}
|
2025-04-11 01:51:06 +00:00
|
|
|
|
|
|
|
|
|
const chooseGroupAdmin = () => {
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: '/pages/chatSettings/groupManage/selectMembers?manageType=admin&isCreateDepGroup=1',
|
|
|
|
|
})
|
2025-01-08 01:18:41 +00:00
|
|
|
|
}
|
2025-04-11 01:51:06 +00:00
|
|
|
|
|
|
|
|
|
const chooseMembers = () => {
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: '/pages/chooseByDeps/index?chooseMode=2',
|
|
|
|
|
})
|
2025-01-08 01:18:41 +00:00
|
|
|
|
}
|
2025-04-11 01:51:06 +00:00
|
|
|
|
|
|
|
|
|
//点击发起群聊
|
|
|
|
|
const handleConfirm = async () => {
|
|
|
|
|
// console.log(allChooseMembers.value)
|
|
|
|
|
let erp_ids = ''
|
|
|
|
|
if (allChooseMembers?.value?.length > 0) {
|
|
|
|
|
allChooseMembers?.value?.forEach((ele) => {
|
|
|
|
|
if (!erp_ids) {
|
|
|
|
|
erp_ids = String(ele.ID)
|
|
|
|
|
} else {
|
|
|
|
|
erp_ids += ',' + ele.ID
|
|
|
|
|
}
|
|
|
|
|
})
|
2025-03-24 03:34:13 +00:00
|
|
|
|
}
|
2025-04-11 01:51:06 +00:00
|
|
|
|
if (groupActiveIndex.value === 0) {
|
|
|
|
|
//普通群
|
|
|
|
|
let params = {
|
|
|
|
|
avatar: '',
|
|
|
|
|
name: groupName.value,
|
|
|
|
|
erp_ids: erp_ids,
|
|
|
|
|
type: 1,
|
|
|
|
|
profile: '',
|
|
|
|
|
}
|
|
|
|
|
console.log(params)
|
|
|
|
|
const res = await ServeCreateGroup(params)
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
resetGroupInfo()
|
|
|
|
|
uni.navigateBack()
|
2025-03-12 07:55:27 +00:00
|
|
|
|
}
|
2025-04-11 01:51:06 +00:00
|
|
|
|
} else if (groupActiveIndex.value === 1) {
|
|
|
|
|
//部门群
|
|
|
|
|
const res = await createDepGroup()
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
resetGroupInfo()
|
|
|
|
|
uni.navigateBack()
|
2025-01-08 01:18:41 +00:00
|
|
|
|
}
|
2025-04-11 01:51:06 +00:00
|
|
|
|
} else if (groupActiveIndex.value === 2) {
|
|
|
|
|
//项目群
|
|
|
|
|
let params = {
|
|
|
|
|
avatar: '',
|
|
|
|
|
name: groupName.value,
|
|
|
|
|
erp_ids: erp_ids,
|
|
|
|
|
type: 3,
|
|
|
|
|
profile: '',
|
2025-01-08 01:18:41 +00:00
|
|
|
|
}
|
2025-04-11 01:51:06 +00:00
|
|
|
|
console.log(params)
|
|
|
|
|
const res = await ServeCreateGroup(params)
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
resetGroupInfo()
|
|
|
|
|
uni.navigateBack()
|
2025-03-12 07:55:27 +00:00
|
|
|
|
}
|
2025-04-11 01:51:06 +00:00
|
|
|
|
} else {}
|
2025-01-08 01:18:41 +00:00
|
|
|
|
}
|
2025-04-11 01:51:06 +00:00
|
|
|
|
//发起群聊按钮可点击状态
|
|
|
|
|
const confirmBtnStatus = computed(() => {
|
|
|
|
|
// 基础检查:群名称为空或未选择群类型
|
|
|
|
|
if (
|
|
|
|
|
groupName.value === '' ||
|
|
|
|
|
(groupActiveIndex.value && groupActiveIndex.value === -1) ||
|
|
|
|
|
(!groupActiveIndex.value && groupActiveIndex.value !== 0)
|
|
|
|
|
) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 检查是否包含自己
|
|
|
|
|
const includesSelf = allChooseMembers.value?.some(member => member.ID === userInfo.value.ID);
|
|
|
|
|
const memberCount = allChooseMembers.value?.length || 0;
|
2025-01-08 01:18:41 +00:00
|
|
|
|
|
2025-04-11 01:51:06 +00:00
|
|
|
|
// 新逻辑:人数检查
|
|
|
|
|
if (includesSelf && memberCount < 3) {
|
|
|
|
|
return true; // 包含自己但总人数<3 → 禁用
|
|
|
|
|
}
|
|
|
|
|
if (!includesSelf && memberCount < 2) {
|
|
|
|
|
return true; // 不包含自己且人数<2 → 禁用
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 原有群类型特定检查
|
|
|
|
|
let disabledT = false;
|
|
|
|
|
switch (groupActiveIndex.value) {
|
|
|
|
|
case 0: // 第一种群类型
|
|
|
|
|
// 人数检查已在上方处理,这里不需要重复
|
|
|
|
|
break;
|
|
|
|
|
case 1: // 第二种群类型
|
|
|
|
|
if (!depCheckedKeys.value.length || !groupAdmins.value.length) {
|
|
|
|
|
disabledT = true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 2: // 第三种群类型
|
|
|
|
|
// 人数检查已在上方处理,这里不需要重复
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return disabledT;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
onShow(() => {
|
|
|
|
|
depsNoExpanded_1.value = true;
|
|
|
|
|
depsNoExpanded_2.value = true;
|
|
|
|
|
})
|
2024-12-24 08:28:44 +00:00
|
|
|
|
</script>
|
|
|
|
|
<style scoped lang="scss">
|
2025-04-11 01:51:06 +00:00
|
|
|
|
::v-deep .zp-paging-container-content {
|
|
|
|
|
height: 100%;
|
|
|
|
|
display: flex;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.create-group-chat {
|
|
|
|
|
background-image: url('@/static/image/clockIn/z3280@3x.png');
|
|
|
|
|
background-size: cover;
|
|
|
|
|
background-position: center bottom;
|
|
|
|
|
width: 100%;
|
|
|
|
|
padding: 0 32rpx 20rpx;
|
|
|
|
|
|
|
|
|
|
.group-avatar {
|
|
|
|
|
padding: 60rpx 0;
|
2025-01-24 03:18:26 +00:00
|
|
|
|
|
2025-04-11 01:51:06 +00:00
|
|
|
|
.avatar-placeholder {
|
|
|
|
|
width: 192rpx;
|
|
|
|
|
height: 192rpx;
|
|
|
|
|
background-color: #e0e0e0;
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
}
|
2025-01-24 03:18:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-11 01:51:06 +00:00
|
|
|
|
.divider {
|
|
|
|
|
height: 1rpx;
|
|
|
|
|
background-color: #7c7c7c;
|
|
|
|
|
opacity: 0.6;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.input-group {
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
padding: 38rpx 40rpx 32rpx 32rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.input-item {
|
|
|
|
|
line-height: 40rpx;
|
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
color: #000;
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.input-box {
|
|
|
|
|
margin-left: 84rpx;
|
|
|
|
|
line-height: 40rpx;
|
|
|
|
|
width: 404rpx;
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.left-box {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
2024-12-24 08:28:44 +00:00
|
|
|
|
</style>
|