feat: 新增团队ID支持,更新相关组件以传递团队信息

This commit is contained in:
Jafeng 2026-02-04 18:39:53 +08:00
parent 959da07a05
commit 4cd0953b0f
4 changed files with 86 additions and 36 deletions

View File

@ -122,8 +122,24 @@ const pageParams = ref({
groupId: "", groupId: "",
patientId: "", patientId: "",
corpId: "", corpId: "",
teamId: "",
}); });
const ensureTeamId = async () => {
if (pageParams.value.teamId) return pageParams.value.teamId;
if (!pageParams.value.groupId) return "";
try {
const res = await api("getGroupListByGroupId", { groupId: pageParams.value.groupId }, false);
const team = res?.data?.team || {};
const resolved = res?.data?.teamId || team.teamId || team._id || "";
if (resolved) pageParams.value.teamId = resolved;
return pageParams.value.teamId;
} catch (err) {
console.error("ensureTeamId failed:", err);
return "";
}
};
const isSelectMode = ref(false); const isSelectMode = ref(false);
const selectEventName = ref(""); const selectEventName = ref("");
@ -383,11 +399,13 @@ const sendArticle = async (article) => {
// 3. // 3.
try { try {
await ensureTeamId();
await api("addArticleSendRecord", { await api("addArticleSendRecord", {
articleId: article._id, articleId: article._id,
userId: doctorInfo.userid, userId: doctorInfo.userid,
customerId: pageParams.value.patientId, customerId: pageParams.value.patientId,
corpId: corpId, corpId: corpId,
teamId: pageParams.value.teamId,
}); });
} catch (recordError) { } catch (recordError) {
console.error("记录文章发送失败:", recordError); console.error("记录文章发送失败:", recordError);
@ -426,6 +444,10 @@ onLoad((options) => {
if (options.corpId) { if (options.corpId) {
pageParams.value.corpId = options.corpId; pageParams.value.corpId = options.corpId;
} }
if (options.teamId) {
pageParams.value.teamId = options.teamId;
}
ensureTeamId();
}); });
onMounted(() => { onMounted(() => {

View File

@ -76,6 +76,7 @@ const props = defineProps({
formatTime: { type: Function, required: true }, formatTime: { type: Function, required: true },
groupId: { type: String, default: "" }, groupId: { type: String, default: "" },
userId: { type: String, default: "" }, userId: { type: String, default: "" },
teamId: { type: String, default: "" },
patientId: { type: String, default: "" }, patientId: { type: String, default: "" },
corpId: { type: String, default: "" }, corpId: { type: String, default: "" },
}); });
@ -375,14 +376,14 @@ const showFollowUpTasks = () => {
// //
const goToArticleList = () => { const goToArticleList = () => {
uni.navigateTo({ uni.navigateTo({
url: `/pages/message/article-list?groupId=${props.groupId}&patientId=${props.patientId}&corpId=${props.corpId}`, url: `/pages/message/article-list?groupId=${props.groupId}&patientId=${props.patientId}&corpId=${props.corpId}&teamId=${props.teamId}`,
}); });
}; };
// //
const goToSurveyList = () => { const goToSurveyList = () => {
uni.navigateTo({ uni.navigateTo({
url: `/pages/message/survey-list?groupId=${props.groupId}&patientId=${props.patientId}&corpId=${props.corpId}&customerName=${props.patientInfo.name}`, url: `/pages/message/survey-list?groupId=${props.groupId}&patientId=${props.patientId}&corpId=${props.corpId}&teamId=${props.teamId}&customerName=${props.patientInfo.name}`,
}); });
}; };
@ -466,4 +467,4 @@ onUnmounted(() => {
<style scoped lang="scss"> <style scoped lang="scss">
@import "../chat.scss"; @import "../chat.scss";
</style> </style>

View File

@ -149,24 +149,25 @@
/> />
<!-- 聊天输入组件 --> <!-- 聊天输入组件 -->
<ChatInput <ChatInput
v-if="!isEvaluationPopupOpen && !showConsultAccept" v-if="!isEvaluationPopupOpen && !showConsultAccept"
ref="chatInputRef" ref="chatInputRef"
:timChatManager="timChatManager" :timChatManager="timChatManager"
:formatTime="formatTime" :formatTime="formatTime"
:groupId=" :groupId="
chatInfo.conversationID chatInfo.conversationID
? chatInfo.conversationID.replace('GROUP', '') ? chatInfo.conversationID.replace('GROUP', '')
: '' : ''
" "
:userId="openid" :userId="openid"
:patientId="patientId" :teamId="teamId"
:corpId="corpId" :patientId="patientId"
:patientInfo="patientInfo" :corpId="corpId"
@scrollToBottom="() => scrollToBottom(true)" :patientInfo="patientInfo"
@messageSent="() => scrollToBottom(true)" @scrollToBottom="() => scrollToBottom(true)"
@endConsult="handleEndConsult" @messageSent="() => scrollToBottom(true)"
/> @endConsult="handleEndConsult"
/>
</view> </view>
</template> </template>
@ -246,7 +247,8 @@ const patientInfo = ref({
}); });
// ID // ID
const patientId = ref(""); const patientId = ref("");
const teamId = ref("");
// - pending // - pending
const showConsultAccept = computed(() => orderStatus.value === "pending"); const showConsultAccept = computed(() => orderStatus.value === "pending");
@ -299,18 +301,20 @@ function isSystemMessage(message) {
} }
// //
const fetchGroupOrderStatus = async () => { const fetchGroupOrderStatus = async () => {
try { try {
const result = await api("getGroupListByGroupId", { const result = await api("getGroupListByGroupId", {
groupId: groupId.value, groupId: groupId.value,
}); });
if (result.success && result.data) { if (result.success && result.data) {
orderStatus.value = result.data.orderStatus || ""; orderStatus.value = result.data.orderStatus || "";
// //
const teamName = result.data.team?.name || "群聊"; const teamName = result.data.team?.name || "群聊";
updateNavigationTitle(teamName); updateNavigationTitle(teamName);
teamId.value = result.data.teamId || result.data.team?.teamId || result.data.team?._id || "";
// //
if (result.data.patient) { if (result.data.patient) {
@ -326,12 +330,12 @@ const fetchGroupOrderStatus = async () => {
patientId.value = result.data.patientId.toString(); patientId.value = result.data.patientId.toString();
} }
console.log("获取群组订单状态:", { console.log("获取群组订单状态:", {
orderStatus: orderStatus.value, orderStatus: orderStatus.value,
teamName: teamName, teamName: teamName,
patientInfo: patientInfo.value, patientInfo: patientInfo.value,
groupId: groupId.value, groupId: groupId.value,
}); });
} else { } else {
console.error("获取群组订单状态失败:", result.message); console.error("获取群组订单状态失败:", result.message);
} }
@ -979,4 +983,4 @@ onUnmounted(() => {
<style scoped lang="scss"> <style scoped lang="scss">
@import "./chat.scss"; @import "./chat.scss";
</style> </style>

View File

@ -101,6 +101,23 @@ const timChatManager = globalTimChatManager;
// //
const customerId = ref(""); const customerId = ref("");
const customerName = ref(""); const customerName = ref("");
const teamId = ref("");
const groupId = ref("");
const ensureTeamId = async () => {
if (teamId.value) return teamId.value;
if (!groupId.value) return "";
try {
const res = await api("getGroupListByGroupId", { groupId: groupId.value }, false);
const team = res?.data?.team || {};
const resolved = res?.data?.teamId || team.teamId || team._id || "";
if (resolved) teamId.value = resolved;
return teamId.value;
} catch (err) {
console.error("ensureTeamId failed:", err);
return "";
}
};
// //
const searchName = ref(""); const searchName = ref("");
@ -125,8 +142,11 @@ const selectEventName = ref("");
onLoad((options) => { onLoad((options) => {
isSelectMode.value = String(options?.select || '') === '1'; isSelectMode.value = String(options?.select || '') === '1';
selectEventName.value = String(options?.eventName || ''); selectEventName.value = String(options?.eventName || '');
groupId.value = options?.groupId || "";
customerId.value = options?.patientId || ""; customerId.value = options?.patientId || "";
customerName.value = options?.customerName || ""; customerName.value = options?.customerName || "";
teamId.value = options?.teamId || "";
ensureTeamId();
getCategoryList(); getCategoryList();
loadSurveyList(); loadSurveyList();
}); });
@ -337,6 +357,8 @@ const sendSurvey = async (survey) => {
// ID // ID
const sendSurveyId = generateRandomString(10); const sendSurveyId = generateRandomString(10);
await ensureTeamId();
// //
const createRecordRes = await api("createSurveyRecord", { const createRecordRes = await api("createSurveyRecord", {
corpId: corpId, corpId: corpId,
@ -345,6 +367,7 @@ const sendSurvey = async (survey) => {
memberId: customerId.value, memberId: customerId.value,
customer: customerName.value, customer: customerName.value,
sendSurveyId: sendSurveyId, sendSurveyId: sendSurveyId,
teamId: teamId.value,
}); });
if (!createRecordRes.success) { if (!createRecordRes.success) {