Compare commits

...

2 Commits

Author SHA1 Message Date
b9385ebf02 回访计划发送 2026-02-04 11:15:17 +08:00
fa01c77830 新增回访计划聊天室 2026-02-04 10:36:36 +08:00
9 changed files with 655 additions and 135 deletions

View File

@ -279,6 +279,12 @@
"style": { "style": {
"navigationBarTitleText": "执行回访计划" "navigationBarTitleText": "执行回访计划"
} }
},
{
"path": "followup-task-list",
"style": {
"navigationBarTitleText": "回访任务"
}
} }
] ]
} }

View File

@ -121,6 +121,7 @@
:archiveId="archiveId" :archiveId="archiveId"
:reachBottomTime="reachBottomTime" :reachBottomTime="reachBottomTime"
:floatingBottom="floatingBottom" :floatingBottom="floatingBottom"
:fromChat="fromChat"
/> />
</view> </view>
@ -242,6 +243,7 @@ const tabs = [
const currentTab = ref('visitRecord'); const currentTab = ref('visitRecord');
const reachBottomTime = ref(0); const reachBottomTime = ref(0);
const archiveId = ref(''); const archiveId = ref('');
const fromChat = ref(false);
const tabsScrollTop = ref(0); const tabsScrollTop = ref(0);
const instanceProxy = getCurrentInstance()?.proxy; const instanceProxy = getCurrentInstance()?.proxy;
@ -474,6 +476,7 @@ async function updateArchive(patch) {
onLoad((options) => { onLoad((options) => {
archiveId.value = options?.id ? String(options.id) : String(archive.value.medicalRecordNo || archive.value.outpatientNo || archive.value.inpatientNo || ''); archiveId.value = options?.id ? String(options.id) : String(archive.value.medicalRecordNo || archive.value.outpatientNo || archive.value.inpatientNo || '');
fromChat.value = options?.fromChat === 'true' || options?.fromChat === true;
const cached = uni.getStorageSync(STORAGE_KEY); const cached = uni.getStorageSync(STORAGE_KEY);
if (cached && typeof cached === 'object') { if (cached && typeof cached === 'object') {

View File

@ -4,7 +4,10 @@
<view class="top"> <view class="top">
<view class="top-row"> <view class="top-row">
<view class="my" @click="toggleMy"> <view class="my" @click="toggleMy">
<image :src="`/static/checkbox${query.isMy ? '-checked' : ''}.svg`" class="checkbox" /> <image
:src="`/static/checkbox${query.isMy ? '-checked' : ''}.svg`"
class="checkbox"
/>
<view class="my-text">我的</view> <view class="my-text">我的</view>
</view> </view>
@ -25,32 +28,81 @@
</view> </view>
<view class="filter-btn" @click="openFilter"> <view class="filter-btn" @click="openFilter">
<image class="filter-icon" :src="`/static/icons/icon-filter${filtered ? '-active' : ''}.svg`" /> <image
class="filter-icon"
:src="`/static/icons/icon-filter${filtered ? '-active' : ''}.svg`"
/>
</view> </view>
</view> </view>
<view class="total"><text class="total-num">{{ total }}</text></view> <view class="total"
><text class="total-num">{{ total }}</text
></view
>
</view> </view>
<view class="list"> <view class="list">
<view v-for="i in list" :key="i._id" class="card" @click="toDetail(i)"> <view v-for="i in list" :key="i._id" class="card" @click="toDetail(i)">
<view class="head"> <view class="head">
<view class="date">计划日期: <text class="date-val">{{ i.planDate }}</text></view> <view class="date"
<view class="executor truncate">{{ i.executorName }}<text v-if="i.executeTeamName">{{ i.executeTeamName }}</text></view> >计划日期: <text class="date-val">{{ i.planDate }}</text></view
>
<view class="executor truncate"
>{{ i.executorName
}}<text v-if="i.executeTeamName"
>{{ i.executeTeamName }}</text
></view
>
</view> </view>
<view class="body"> <view class="body">
<view class="title-row"> <view class="title-row">
<view class="type">{{ i.eventTypeLabel }}</view> <view class="type">{{ i.eventTypeLabel }}</view>
<view class="status" :class="`st-${i.status}`">{{ i.eventStatusLabel }}</view> <view class="status" :class="`st-${i.status}`">{{
i.eventStatusLabel
}}</view>
</view>
<view class="content">{{ i.taskContent || "暂无内容" }}</view>
<view v-if="i.sendContent || (i.fileList && i.fileList.length > 0)" class="send-content-wrapper">
<view class="send-content-section">
<view class="send-content-label">发送内容</view>
<view class="send-content-body">
<view v-if="i.sendContent" class="send-text">{{ i.sendContent }}</view>
<view v-if="i.fileList && i.fileList.length > 0" class="file-list">
<view v-for="(file, idx) in i.fileList" :key="idx" class="file-item" :class="`file-type-${file.type}`">
<view v-if="file.type === 'image'" class="file-icon">🖼</view>
<view v-else-if="file.type === 'article'" class="file-icon">📄</view>
<view v-else-if="file.type === 'questionnaire'" class="file-icon">📋</view>
<view class="file-name">{{ file.file?.name || file.name }}</view>
</view>
</view>
</view>
</view>
<button
v-if="fromChat"
class="action-btn send-btn"
@click.stop="sendFollowUp(i)"
>
发送
</button>
</view>
<view v-if="i.status === 'treated'" class="result"
>处理结果 {{ i.result || "" }}</view
>
<view class="footer-row">
<view class="footer"
>创建: {{ i.createTimeStr }} {{ i.creatorName }}</view
>
</view> </view>
<view class="content">{{ i.taskContent || '暂无内容' }}</view>
<view v-if="i.status === 'treated'" class="result">处理结果 {{ i.result || '' }}</view>
<view class="footer">创建: {{ i.createTimeStr }} {{ i.creatorName }}</view>
</view> </view>
</view> </view>
<view v-if="list.length === 0" class="empty">暂无数据</view> <view v-if="list.length === 0" class="empty">暂无数据</view>
<uni-load-more v-if="list.length" :status="moreStatus" :contentText="loadMoreText" @clickLoadMore="getMore" /> <uni-load-more
v-if="list.length"
:status="moreStatus"
:contentText="loadMoreText"
@clickLoadMore="getMore"
/>
</view> </view>
<view class="fab" :style="{ bottom: `${floatingBottom}px` }" @click="add"> <view class="fab" :style="{ bottom: `${floatingBottom}px` }" @click="add">
@ -99,9 +151,18 @@
<view class="section"> <view class="section">
<view class="section-title">所属团队</view> <view class="section-title">所属团队</view>
<picker mode="selector" :range="teamOptions" range-key="label" @change="pickTeam"> <picker
mode="selector"
:range="teamOptions"
range-key="label"
@change="pickTeam"
>
<view class="select-row"> <view class="select-row">
<view class="select-text" :class="{ muted: teamPicked.value === 'ALL' }">{{ teamPicked.label }}</view> <view
class="select-text"
:class="{ muted: teamPicked.value === 'ALL' }"
>{{ teamPicked.label }}</view
>
<uni-icons type="right" size="16" color="#999" /> <uni-icons type="right" size="16" color="#999" />
</view> </view>
</picker> </picker>
@ -111,11 +172,15 @@
<view class="section-title">计划日期</view> <view class="section-title">计划日期</view>
<view class="range-row"> <view class="range-row">
<picker mode="date" @change="pickStart"> <picker mode="date" @change="pickStart">
<view class="range-pill" :class="{ muted: !planRange[0] }">{{ planRange[0] || '开始日期' }}</view> <view class="range-pill" :class="{ muted: !planRange[0] }">{{
planRange[0] || "开始日期"
}}</view>
</picker> </picker>
<view class="sep">-</view> <view class="sep">-</view>
<picker mode="date" @change="pickEnd"> <picker mode="date" @change="pickEnd">
<view class="range-pill" :class="{ muted: !planRange[1] }">{{ planRange[1] || '结束日期' }}</view> <view class="range-pill" :class="{ muted: !planRange[1] }">{{
planRange[1] || "结束日期"
}}</view>
</picker> </picker>
<view class="clear" @click="clearPlanRange"> <view class="clear" @click="clearPlanRange">
<uni-icons type="closeempty" size="16" color="#999" /> <uni-icons type="closeempty" size="16" color="#999" />
@ -133,19 +198,23 @@
</template> </template>
<script setup> <script setup>
import { computed, onMounted, onUnmounted, reactive, ref, watch } from 'vue'; import { computed, onMounted, onUnmounted, reactive, ref, watch } from "vue";
import { storeToRefs } from 'pinia'; import { storeToRefs } from "pinia";
import dayjs from 'dayjs'; import dayjs from "dayjs";
import api from '@/utils/api'; import api from "@/utils/api";
import useAccountStore from '@/store/account'; import useAccountStore from "@/store/account";
import { toast } from '@/utils/widget'; import { toast } from "@/utils/widget";
import { getTodoEventTypeLabel, getTodoEventTypeOptions } from '@/utils/todo-const'; import {
getTodoEventTypeLabel,
getTodoEventTypeOptions,
} from "@/utils/todo-const";
const props = defineProps({ const props = defineProps({
data: { type: Object, default: () => ({}) }, data: { type: Object, default: () => ({}) },
archiveId: { type: String, default: '' }, archiveId: { type: String, default: "" },
reachBottomTime: { type: [String, Number], default: '' }, reachBottomTime: { type: [String, Number], default: "" },
floatingBottom: { type: Number, default: 16 }, floatingBottom: { type: Number, default: 16 },
fromChat: { type: Boolean, default: false },
}); });
const accountStore = useAccountStore(); const accountStore = useAccountStore();
@ -153,24 +222,27 @@ const { account, doctorInfo } = storeToRefs(accountStore);
const { getDoctorInfo } = accountStore; const { getDoctorInfo } = accountStore;
const statusTabs = [ const statusTabs = [
{ label: '全部', value: 'all' }, { label: "全部", value: "all" },
{ label: '待处理', value: 'processing' }, { label: "待处理", value: "processing" },
{ label: '未开始', value: 'notStart' }, { label: "未开始", value: "notStart" },
{ label: '已完成', value: 'treated' }, { label: "已完成", value: "treated" },
{ label: '已取消', value: 'cancelled' }, { label: "已取消", value: "cancelled" },
{ label: '已过期', value: 'expired' }, { label: "已过期", value: "expired" },
]; ];
const typeOptions = [{ label: '全部', value: 'all' }, ...getTodoEventTypeOptions()]; const typeOptions = [
{ label: "全部", value: "all" },
...getTodoEventTypeOptions(),
];
const teamOptions = ref([{ label: '全部', value: 'ALL' }]); const teamOptions = ref([{ label: "全部", value: "ALL" }]);
const query = reactive({ const query = reactive({
isMy: false, isMy: false,
status: 'all', status: "all",
eventTypes: [], eventTypes: [],
teamId: 'ALL', teamId: "ALL",
planRange: ['', ''], planRange: ["", ""],
}); });
const list = ref([]); const list = ref([]);
@ -184,20 +256,20 @@ const loading = ref(false);
const userNameMap = ref({}); const userNameMap = ref({});
const moreStatus = computed(() => { const moreStatus = computed(() => {
if (loading.value) return 'loading'; if (loading.value) return "loading";
return page.value <= pages.value ? 'more' : 'no-more'; return page.value <= pages.value ? "more" : "no-more";
}); });
const loadMoreText = { const loadMoreText = {
contentdown: '点击加载更多', contentdown: "点击加载更多",
contentrefresh: '加载中...', contentrefresh: "加载中...",
contentnomore: '没有更多了', contentnomore: "没有更多了",
}; };
const filtered = ref(false); const filtered = ref(false);
const typeSelectedMap = computed(() => { const typeSelectedMap = computed(() => {
const s = new Set(query.eventTypes || []); const s = new Set(query.eventTypes || []);
return typeOptions.reduce((acc, cur) => { return typeOptions.reduce((acc, cur) => {
if (cur.value === 'all') acc[cur.value] = s.size === 0; if (cur.value === "all") acc[cur.value] = s.size === 0;
else acc[cur.value] = s.has(cur.value); else acc[cur.value] = s.has(cur.value);
return acc; return acc;
}, {}); }, {});
@ -206,14 +278,18 @@ const typeSelectedMap = computed(() => {
function getUserId() { function getUserId() {
const d = doctorInfo.value || {}; const d = doctorInfo.value || {};
const a = account.value || {}; const a = account.value || {};
return String(d.userid || d.userId || d.corpUserId || a.userid || a.userId || '') || ''; return (
String(
d.userid || d.userId || d.corpUserId || a.userid || a.userId || ""
) || ""
);
} }
function getCorpId() { function getCorpId() {
const t = uni.getStorageSync('ykt_case_current_team') || {}; const t = uni.getStorageSync("ykt_case_current_team") || {};
const a = account.value || {}; const a = account.value || {};
const d = doctorInfo.value || {}; const d = doctorInfo.value || {};
return String(t.corpId || a.corpId || d.corpId || '') || ''; return String(t.corpId || a.corpId || d.corpId || "") || "";
} }
async function ensureDoctor() { async function ensureDoctor() {
@ -228,33 +304,37 @@ async function ensureDoctor() {
function statusLabelFromStatus(status) { function statusLabelFromStatus(status) {
const map = { const map = {
processing: '待处理', processing: "待处理",
notStart: '未开始', notStart: "未开始",
treated: '已完成', treated: "已完成",
cancelled: '已取消', cancelled: "已取消",
expired: '已过期', expired: "已过期",
}; };
return map[status] || '未知'; return map[status] || "未知";
} }
function getStatus(todo) { function getStatus(todo) {
const endOfToday = dayjs().endOf('day').valueOf(); const endOfToday = dayjs().endOf("day").valueOf();
const startOfToday = dayjs().startOf('day').valueOf(); const startOfToday = dayjs().startOf("day").valueOf();
const plannedExecutionTime = Number(todo?.plannedExecutionTime || 0) || 0; const plannedExecutionTime = Number(todo?.plannedExecutionTime || 0) || 0;
const expireTime = Number(todo?.expireTime || 0) || 0; const expireTime = Number(todo?.expireTime || 0) || 0;
const eventStatus = String(todo?.eventStatus || ''); const eventStatus = String(todo?.eventStatus || "");
if (eventStatus === 'treated') return 'treated'; if (eventStatus === "treated") return "treated";
if (eventStatus === 'closed') return 'cancelled'; if (eventStatus === "closed") return "cancelled";
if (eventStatus === 'expire') return 'expired'; if (eventStatus === "expire") return "expired";
if (eventStatus === 'untreated') { if (eventStatus === "untreated") {
if (expireTime && expireTime < startOfToday) return 'expired'; if (expireTime && expireTime < startOfToday) return "expired";
if (plannedExecutionTime >= endOfToday) return 'notStart'; if (plannedExecutionTime >= endOfToday) return "notStart";
if (plannedExecutionTime <= startOfToday && (!expireTime || expireTime >= endOfToday)) return 'processing'; if (
return 'processing'; plannedExecutionTime <= startOfToday &&
(!expireTime || expireTime >= endOfToday)
)
return "processing";
return "processing";
} }
return 'processing'; return "processing";
} }
function eventTypeLabel(eventType) { function eventTypeLabel(eventType) {
@ -262,10 +342,10 @@ function eventTypeLabel(eventType) {
} }
function resolveUserName(userId) { function resolveUserName(userId) {
const id = String(userId || ''); const id = String(userId || "");
if (!id) return ''; if (!id) return "";
const map = userNameMap.value || {}; const map = userNameMap.value || {};
return String(map[id] || '') || id; return String(map[id] || "") || id;
} }
function formatTodo(todo) { function formatTodo(todo) {
@ -277,8 +357,14 @@ function formatTodo(todo) {
status, status,
eventStatusLabel: statusLabelFromStatus(status), eventStatusLabel: statusLabelFromStatus(status),
eventTypeLabel: eventTypeLabel(todo?.eventType), eventTypeLabel: eventTypeLabel(todo?.eventType),
planDate: plannedExecutionTime && dayjs(plannedExecutionTime).isValid() ? dayjs(plannedExecutionTime).format('YYYY-MM-DD') : '', planDate:
createTimeStr: createTime && dayjs(createTime).isValid() ? dayjs(createTime).format('YYYY-MM-DD HH:mm') : '', plannedExecutionTime && dayjs(plannedExecutionTime).isValid()
? dayjs(plannedExecutionTime).format("YYYY-MM-DD")
: "",
createTimeStr:
createTime && dayjs(createTime).isValid()
? dayjs(createTime).format("YYYY-MM-DD HH:mm")
: "",
executorName: resolveUserName(todo?.executorUserId), executorName: resolveUserName(todo?.executorUserId),
creatorName: resolveUserName(todo?.creatorUserId), creatorName: resolveUserName(todo?.creatorUserId),
}; };
@ -303,7 +389,7 @@ async function getMore() {
const corpId = getCorpId(); const corpId = getCorpId();
const userId = getUserId(); const userId = getUserId();
if (!corpId) { if (!corpId) {
toast('缺少 corpId请先完成登录/团队选择'); toast("缺少 corpId请先完成登录/团队选择");
return; return;
} }
@ -314,22 +400,23 @@ async function getMore() {
pageSize, pageSize,
}; };
if (query.status !== 'all') params.statusList = [query.status]; if (query.status !== "all") params.statusList = [query.status];
if (query.isMy) params.executorUserId = userId; if (query.isMy) params.executorUserId = userId;
if (Array.isArray(query.eventTypes) && query.eventTypes.length) params.eventType = query.eventTypes; if (Array.isArray(query.eventTypes) && query.eventTypes.length)
if (query.teamId && query.teamId !== 'ALL') params.teamId = query.teamId; params.eventType = query.eventTypes;
if (query.teamId && query.teamId !== "ALL") params.teamId = query.teamId;
if (query.planRange?.[0]) params.startDate = query.planRange[0]; if (query.planRange?.[0]) params.startDate = query.planRange[0];
if (query.planRange?.[1]) params.endDate = query.planRange[1]; if (query.planRange?.[1]) params.endDate = query.planRange[1];
const res = await api('getCustomerTodos', params); const res = await api("getCustomerTodos", params);
if (!res?.success) { if (!res?.success) {
toast(res?.message || '获取回访任务失败'); toast(res?.message || "获取回访任务失败");
return; return;
} }
const arr = Array.isArray(res.data) ? res.data : []; const arr = Array.isArray(res.data) ? res.data : [];
const next = arr.map(formatTodo); const next = arr.map(formatTodo);
total.value = typeof res.total === 'number' ? res.total : 0; total.value = typeof res.total === "number" ? res.total : 0;
pages.value = Math.ceil(total.value / pageSize) || 0; pages.value = Math.ceil(total.value / pageSize) || 0;
list.value = page.value === 1 ? next : [...list.value, ...next]; list.value = page.value === 1 ? next : [...list.value, ...next];
page.value += 1; page.value += 1;
@ -352,58 +439,154 @@ async function loadTeams() {
const corpId = getCorpId(); const corpId = getCorpId();
const userId = getUserId(); const userId = getUserId();
if (!corpId || !userId) return; if (!corpId || !userId) return;
const res = await api('getTeamBymember', { corpId, corpUserId: userId }); const res = await api("getTeamBymember", { corpId, corpUserId: userId });
if (!res?.success) return; if (!res?.success) return;
const list = Array.isArray(res?.data) ? res.data : Array.isArray(res?.data?.data) ? res.data.data : []; const list = Array.isArray(res?.data)
? res.data
: Array.isArray(res?.data?.data)
? res.data.data
: [];
const normalized = list const normalized = list
.map((raw) => { .map((raw) => {
if (!raw || typeof raw !== 'object') return null; if (!raw || typeof raw !== "object") return null;
const teamId = raw.teamId || raw.id || raw._id || ''; const teamId = raw.teamId || raw.id || raw._id || "";
const name = raw.name || raw.teamName || raw.team || ''; const name = raw.name || raw.teamName || raw.team || "";
if (!teamId || !name) return null; if (!teamId || !name) return null;
return { label: String(name), value: String(teamId) }; return { label: String(name), value: String(teamId) };
}) })
.filter(Boolean); .filter(Boolean);
teamOptions.value = [{ label: '全部', value: 'ALL' }, ...normalized]; teamOptions.value = [{ label: "全部", value: "ALL" }, ...normalized];
} }
function add() { function add() {
uni.showActionSheet({ uni.showActionSheet({
itemList: ['+新增任务', '+使用模板', '+回访记录'], itemList: ["+新增任务", "+使用模板", "+回访记录"],
success: ({ tapIndex }) => { success: ({ tapIndex }) => {
if (tapIndex === 0) { if (tapIndex === 0) {
uni.setStorageSync('new-followup-customer', { _id: props.archiveId, name: props.data?.name || '' }); uni.setStorageSync("new-followup-customer", {
uni.navigateTo({ url: `/pages/case/new-followup?archiveId=${encodeURIComponent(props.archiveId)}` }); _id: props.archiveId,
name: props.data?.name || "",
});
uni.navigateTo({
url: `/pages/case/new-followup?archiveId=${encodeURIComponent(
props.archiveId
)}`,
});
} else if (tapIndex === 1) { } else if (tapIndex === 1) {
uni.setStorageSync('new-followup-plan-customer', { _id: props.archiveId, name: props.data?.name || '' }); uni.setStorageSync("new-followup-plan-customer", {
uni.setStorageSync('select-mamagement-plan', ''); _id: props.archiveId,
uni.navigateTo({ url: `/pages/case/plan-list?archiveId=${encodeURIComponent(props.archiveId)}` }); name: props.data?.name || "",
});
uni.setStorageSync("select-mamagement-plan", "");
uni.navigateTo({
url: `/pages/case/plan-list?archiveId=${encodeURIComponent(
props.archiveId
)}`,
});
} else if (tapIndex === 2) { } else if (tapIndex === 2) {
uni.setStorageSync('new-followup-record-customer', { _id: props.archiveId, name: props.data?.name || '' }); uni.setStorageSync("new-followup-record-customer", {
uni.navigateTo({ url: `/pages/case/new-followup-record?archiveId=${encodeURIComponent(props.archiveId)}` }); _id: props.archiveId,
name: props.data?.name || "",
});
uni.navigateTo({
url: `/pages/case/new-followup-record?archiveId=${encodeURIComponent(
props.archiveId
)}`,
});
} }
}, },
}); });
} }
function toDetail(todo) { function toDetail(todo) {
uni.navigateTo({ url: `/pages/case/followup-detail?archiveId=${encodeURIComponent(props.archiveId)}&mode=edit&id=${encodeURIComponent(todo._id)}` }); uni.navigateTo({
url: `/pages/case/followup-detail?archiveId=${encodeURIComponent(
props.archiveId
)}&mode=edit&id=${encodeURIComponent(todo._id)}`,
});
}
async function sendFollowUp(todo) {
if (!todo.sendContent && (!todo.fileList || todo.fileList.length === 0)) {
toast("没有发送内容");
return;
}
const messages = [];
// 1.
if (todo.sendContent) {
messages.push({
type: "text",
content: todo.sendContent,
});
}
// 2.
if (Array.isArray(todo.fileList)) {
for (const file of todo.fileList) {
if (file.type === "image" && file.URL) {
//
messages.push({
type: "image",
content: file.URL,
name: file.file?.name || file.name || "图片",
});
} else if (file.type === "article" && file.file?.url) {
//
messages.push({
type: "article",
content: {
title: file.file?.name || file.name || "宣教文章",
url: file.file?.url || file.URL,
desc: file.file?.subtitle || "",
},
});
} else if (file.type === "questionnaire" && file.file?.surveryId) {
//
messages.push({
type: "questionnaire",
content: {
title: file.file?.name || file.name || "问卷",
surveryId: file.file?.surveryId || file.surveryId,
url: file.file?.url || file.URL,
},
});
}
}
}
//
uni.$emit("send-followup-message", {
messages,
followupId: todo._id,
followupData: todo,
});
toast("消息已发送");
uni.navigateBack();
} }
// ---- filter popup ---- // ---- filter popup ----
const filterPopupRef = ref(null); const filterPopupRef = ref(null);
const state = ref(null); const state = ref(null);
const teamPicked = ref(teamOptions.value[0]); const teamPicked = ref(teamOptions.value[0]);
const planRange = ref(['', '']); const planRange = ref(["", ""]);
function openFilter() { function openFilter() {
state.value = { state.value = {
query: { ...query, eventTypes: [...(query.eventTypes || [])], planRange: [...(query.planRange || ['', ''])] }, query: {
...query,
eventTypes: [...(query.eventTypes || [])],
planRange: [...(query.planRange || ["", ""])],
},
team: { ...teamPicked.value }, team: { ...teamPicked.value },
range: [...planRange.value], range: [...planRange.value],
}; };
planRange.value = [...(query.planRange || ['', ''])]; planRange.value = [...(query.planRange || ["", ""])];
teamPicked.value = teamOptions.value.find((i) => i.value === query.teamId) || teamOptions.value[0]; teamPicked.value =
teamOptions.value.find((i) => i.value === query.teamId) ||
teamOptions.value[0];
filterPopupRef.value?.open?.(); filterPopupRef.value?.open?.();
} }
function closeFilter(revert) { function closeFilter(revert) {
@ -416,7 +599,7 @@ function closeFilter(revert) {
} }
function toggleType(v) { function toggleType(v) {
if (v === 'all') { if (v === "all") {
query.eventTypes = []; query.eventTypes = [];
return; return;
} }
@ -432,42 +615,50 @@ function pickTeam(e) {
} }
function pickStart(e) { function pickStart(e) {
planRange.value = [e.detail.value || '', planRange.value[1] || '']; planRange.value = [e.detail.value || "", planRange.value[1] || ""];
query.planRange = [...planRange.value]; query.planRange = [...planRange.value];
} }
function pickEnd(e) { function pickEnd(e) {
planRange.value = [planRange.value[0] || '', e.detail.value || '']; planRange.value = [planRange.value[0] || "", e.detail.value || ""];
query.planRange = [...planRange.value]; query.planRange = [...planRange.value];
} }
function clearPlanRange() { function clearPlanRange() {
planRange.value = ['', '']; planRange.value = ["", ""];
query.planRange = ['', '']; query.planRange = ["", ""];
} }
function resetFilter() { function resetFilter() {
query.eventTypes = []; query.eventTypes = [];
query.teamId = 'ALL'; query.teamId = "ALL";
teamPicked.value = teamOptions.value[0]; teamPicked.value = teamOptions.value[0];
clearPlanRange(); clearPlanRange();
} }
function confirmFilter() { function confirmFilter() {
filtered.value = Boolean((query.eventTypes && query.eventTypes.length) || query.teamId !== 'ALL' || query.planRange[0] || query.planRange[1]); filtered.value = Boolean(
(query.eventTypes && query.eventTypes.length) ||
query.teamId !== "ALL" ||
query.planRange[0] ||
query.planRange[1]
);
closeFilter(false); closeFilter(false);
resetList(); resetList();
} }
onMounted(() => { onMounted(() => {
const userId = getUserId(); const userId = getUserId();
const name = String(doctorInfo.value?.anotherName || doctorInfo.value?.name || ''); const name = String(
if (userId && name) userNameMap.value = { ...(userNameMap.value || {}), [userId]: name }; doctorInfo.value?.anotherName || doctorInfo.value?.name || ""
);
if (userId && name)
userNameMap.value = { ...(userNameMap.value || {}), [userId]: name };
loadTeams(); loadTeams();
resetList(); resetList();
uni.$on('archive-detail:followup-changed', resetList); uni.$on("archive-detail:followup-changed", resetList);
}); });
onUnmounted(() => { onUnmounted(() => {
uni.$off('archive-detail:followup-changed', resetList); uni.$off("archive-detail:followup-changed", resetList);
}); });
watch( watch(
@ -523,7 +714,7 @@ watch(
} }
.status-tab.active { .status-tab.active {
background: #dbe6ff; background: #dbe6ff;
color: #0877F1; color: #0877f1;
} }
.filter-btn { .filter-btn {
flex-shrink: 0; flex-shrink: 0;
@ -603,7 +794,7 @@ watch(
} }
.st-notStart { .st-notStart {
background: #dbe6ff; background: #dbe6ff;
color: #0877F1; color: #0877f1;
} }
.st-treated { .st-treated {
background: #dcfce7; background: #dcfce7;
@ -620,15 +811,129 @@ watch(
color: #666; color: #666;
line-height: 18px; line-height: 18px;
} }
.send-content-wrapper {
margin-top: 10px;
display: flex;
align-items: flex-start;
gap: 10px;
}
.send-content-section {
flex: 1;
padding: 10px;
background: #f9f9f9;
border-radius: 6px;
display: flex;
align-items: flex-start;
gap: 10px;
}
.send-content-label {
font-size: 13px;
color: #666;
flex-shrink: 0;
font-weight: 500;
white-space: nowrap;
}
.send-content-body {
flex: 1;
min-width: 0;
}
.send-text {
font-size: 13px;
color: #333;
line-height: 18px;
word-break: break-word;
}
.file-list {
margin-top: 6px;
}
.file-item {
margin-top: 4px;
display: flex;
align-items: center;
gap: 6px;
}
.file-icon {
font-size: 14px;
flex-shrink: 0;
}
.file-name {
font-size: 12px;
color: #0877f1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
flex: 1;
}
.file-type-image .file-name {
color: #0877f1;
}
.file-type-article .file-name {
color: #16a34a;
}
.file-type-questionnaire .file-name {
color: #f59e0b;
}
.result { .result {
margin-top: 10px; margin-top: 10px;
font-size: 13px; font-size: 13px;
color: #666; color: #666;
} }
.footer { .footer-row {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 10px; margin-top: 10px;
padding-top: 10px;
border-top: 1px solid #f2f2f2;
gap: 10px;
}
.footer {
font-size: 12px; font-size: 12px;
color: #999; color: #999;
flex: 1;
}
.footer-row .send-btn {
flex: 0 0 auto;
width: 60px;
height: 28px;
line-height: 28px;
padding: 0;
margin: 0;
}
.card-actions {
display: flex;
gap: 10px;
margin-top: 12px;
padding-top: 12px;
border-top: 1px solid #f2f2f2;
}
.action-btn {
flex: 1;
height: 32px;
line-height: 32px;
border-radius: 6px;
font-size: 12px;
border: none;
background: #f5f6f8;
color: #333;
}
.action-btn::after {
border: none;
}
.detail-btn {
background: #f5f6f8;
color: #333;
}
.send-btn {
flex: 0 0 auto;
width: 60px;
background: #0877f1;
color: #fff;
} }
.empty { .empty {
@ -644,7 +949,7 @@ watch(
width: 52px; width: 52px;
height: 52px; height: 52px;
border-radius: 26px; border-radius: 26px;
background: #0877F1; background: #0877f1;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
@ -704,8 +1009,8 @@ watch(
color: #333; color: #333;
} }
.chip.active { .chip.active {
background: #0877F1; background: #0877f1;
border-color: #0877F1; border-color: #0877f1;
color: #fff; color: #fff;
} }
.select-row { .select-row {
@ -769,11 +1074,11 @@ watch(
} }
.btn.plain { .btn.plain {
background: #fff; background: #fff;
color: #0877F1; color: #0877f1;
border: 1px solid #0877F1; border: 1px solid #0877f1;
} }
.btn.primary { .btn.primary {
background: #0877F1; background: #0877f1;
color: #fff; color: #fff;
} }
</style> </style>

View File

@ -0,0 +1,75 @@
<template>
<view class="followup-task-page">
<!-- 回访任务列表组件 -->
<FollowUpManageTab
:data="patientData"
:archiveId="archiveId"
:reachBottomTime="reachBottomTime"
:floatingBottom="0"
:fromChat="true"
/>
</view>
</template>
<script setup>
import { ref } from "vue";
import { onLoad } from "@dcloudio/uni-app";
import FollowUpManageTab from "./components/archive-detail/follow-up-manage-tab.vue";
const archiveId = ref("");
const patientData = ref({});
const reachBottomTime = ref("");
onLoad((options) => {
archiveId.value = options.archiveId || "";
patientData.value = {
name: options.patientName || "",
};
});
const handleBack = () => {
uni.navigateBack();
};
</script>
<style scoped>
.followup-task-page {
display: flex;
flex-direction: column;
height: 100vh;
background: #f5f6f8;
}
.nav-bar {
display: flex;
align-items: center;
justify-content: space-between;
height: 44px;
background: #0877f1;
padding: 0 14px;
color: #fff;
position: relative;
}
.nav-back {
width: 44px;
height: 44px;
display: flex;
align-items: center;
justify-content: center;
margin-left: -14px;
}
.nav-title {
position: absolute;
left: 50%;
transform: translateX(-50%);
font-size: 16px;
font-weight: 600;
color: #fff;
}
.nav-placeholder {
width: 44px;
}
</style>

View File

@ -315,6 +315,8 @@ const closePreview = () => {
const sendArticle = async (article) => { const sendArticle = async (article) => {
try { try {
const { doctorInfo } = useAccountStore(); const { doctorInfo } = useAccountStore();
// 1. API
const result = await api("sendArticleMessage", { const result = await api("sendArticleMessage", {
groupId: pageParams.value.groupId, groupId: pageParams.value.groupId,
fromAccount: doctorInfo.userid, fromAccount: doctorInfo.userid,
@ -323,8 +325,46 @@ const sendArticle = async (article) => {
imgUrl: article.cover || "", imgUrl: article.cover || "",
desc: "点击查看详情", desc: "点击查看详情",
}); });
if (result.success) { if (result.success) {
// // 2. IM
try {
// IM
const { globalTimChatManager } = await import("@/utils/tim-chat.js");
if (globalTimChatManager && globalTimChatManager.tim && globalTimChatManager.isLoggedIn) {
// ID
const conversationID = `GROUP${pageParams.value.groupId}`;
globalTimChatManager.currentConversationID = conversationID;
console.log("设置当前会话ID:", conversationID);
//
const customMessageData = {
messageType: "article",
title: article.title || "宣教文章",
articleId: article._id,
cover: article.cover || "",
desc: "点击查看详情",
content: article.title || "宣教文章"
};
//
const sendResult = await globalTimChatManager.sendCustomMessage(customMessageData);
if (sendResult && sendResult.success) {
console.log("✓ 文章消息已通过IM系统发送");
} else {
console.warn("⚠️ 文章消息发送失败:", sendResult?.error);
}
} else {
console.warn("⚠️ IM系统未就绪消息可能不会显示在聊天列表");
}
} catch (imError) {
console.error("通过IM系统发送消息失败:", imError);
// IM
}
// 3.
try { try {
await api("addArticleSendRecord", { await api("addArticleSendRecord", {
articleId: article._id, articleId: article._id,

View File

@ -430,6 +430,15 @@ $primary-color: #0877F1;
box-sizing: border-box; box-sizing: border-box;
line-height: 1.5; line-height: 1.5;
color: #333; color: #333;
display: flex;
align-items: center;
justify-content: center;
}
.text-input {
padding: 16rpx 46rpx;
display: block;
line-height: 1.5;
} }
.voice-input-btn { .voice-input-btn {

View File

@ -9,7 +9,7 @@
<textarea v-if="!showVoiceInput" class="text-input" v-model="inputText" placeholder="我来说两句..." <textarea v-if="!showVoiceInput" class="text-input" v-model="inputText" placeholder="我来说两句..."
@confirm="sendTextMessage" @focus="handleInputFocus" @input="handleInput" @confirm="sendTextMessage" @focus="handleInputFocus" @input="handleInput"
:auto-height="true" :show-confirm-bar="false" :adjust-position="true" :auto-height="true" :show-confirm-bar="false" :adjust-position="true"
placeholder-style="line-height: 80rpx;" /> />
<input v-else class="voice-input-btn" :class="{ recording: isRecording }" @touchstart="startRecord" <input v-else class="voice-input-btn" :class="{ recording: isRecording }" @touchstart="startRecord"
@touchmove="onRecordTouchMove" @touchend="stopRecord" @touchcancel="cancelRecord" :placeholder="isRecording ? '松开发送' : '按住说话'" disabled> @touchmove="onRecordTouchMove" @touchend="stopRecord" @touchcancel="cancelRecord" :placeholder="isRecording ? '松开发送' : '按住说话'" disabled>
</input> </input>
@ -365,6 +365,13 @@ const goToCommonPhrases = () => {
}); });
}; };
// 访
const showFollowUpTasks = () => {
uni.navigateTo({
url: `/pages/case/followup-task-list?archiveId=${props.patientId}&patientName=${props.patientInfo.name}`,
});
};
// //
const goToArticleList = () => { const goToArticleList = () => {
uni.navigateTo({ uni.navigateTo({
@ -402,7 +409,7 @@ const morePanelButtons = [
{ {
text: "回访任务", text: "回访任务",
icon: "/static/icon/huifangrenwu.png", icon: "/static/icon/huifangrenwu.png",
action: showImagePicker, action: showFollowUpTasks,
}, },
{ {
text: "常用语", text: "常用语",

View File

@ -757,8 +757,34 @@ onShow(() => {
} }
startIMMonitoring(30000); startIMMonitoring(30000);
// 访
uni.$on('send-followup-message', handleSendFollowUpMessage);
}); });
// 访
const handleSendFollowUpMessage = async (data) => {
try {
if (chatInputRef.value) {
// 访
chatInputRef.value.setInputText(data.content);
//
setTimeout(() => {
if (chatInputRef.value) {
chatInputRef.value.sendTextMessageFromPhrase(data.content);
}
}, 100);
}
} catch (error) {
console.error('发送回访任务消息失败:', error);
uni.showToast({
title: '发送失败,请重试',
icon: 'none',
});
}
};
// //
onHide(() => { onHide(() => {
stopIMMonitoring(); stopIMMonitoring();
@ -945,6 +971,9 @@ onUnmounted(() => {
timChatManager.setCallback("onMessageReceived", null); timChatManager.setCallback("onMessageReceived", null);
timChatManager.setCallback("onMessageListLoaded", null); timChatManager.setCallback("onMessageListLoaded", null);
timChatManager.setCallback("onError", null); timChatManager.setCallback("onError", null);
// 访
uni.$off('send-followup-message', handleSendFollowUpMessage);
}); });
</script> </script>

View File

@ -723,14 +723,26 @@ class TimChatManager {
// 判断是否为当前会话的消息 // 判断是否为当前会话的消息
// 系统消息只要会话ID匹配就显示不要求必须有currentConversationID // 系统消息只要会话ID匹配就显示不要求必须有currentConversationID
// 自定义消息文章等如果currentConversationID已设置则需要匹配如果未设置则暂存等待
// 普通消息必须有currentConversationID且匹配才显示 // 普通消息必须有currentConversationID且匹配才显示
const isCurrentConversation = isSystemMsg let isCurrentConversation = false
? messageConversationID === this.currentConversationID
: (this.currentConversationID && messageConversationID === this.currentConversationID) if (isSystemMsg) {
// 系统消息只要会话ID匹配就显示
isCurrentConversation = messageConversationID === this.currentConversationID
} else if (convertedMessage.type === 'TIMCustomElem') {
// 自定义消息包括文章如果currentConversationID已设置则需要匹配否则也接收
// 这样可以确保消息不会丢失,即使用户还没进入聊天页面
isCurrentConversation = !this.currentConversationID || messageConversationID === this.currentConversationID
} else {
// 普通消息必须有currentConversationID且匹配才显示
isCurrentConversation = this.currentConversationID && messageConversationID === this.currentConversationID
}
console.log('消息会话匹配检查:', { console.log('消息会话匹配检查:', {
isCurrentConversation, isCurrentConversation,
isSystemMessage: isSystemMsg, isSystemMessage: isSystemMsg,
messageType: convertedMessage.type,
hasCurrentConversationID: !!this.currentConversationID, hasCurrentConversationID: !!this.currentConversationID,
conversationIDMatch: messageConversationID === this.currentConversationID conversationIDMatch: messageConversationID === this.currentConversationID
}) })
@ -2516,32 +2528,66 @@ class TimChatManager {
formatCustomMessage(payload) { formatCustomMessage(payload) {
try { try {
if (!payload || !payload.data) { if (!payload || !payload.data) {
console.warn('payload.data 为空:', payload)
return '[自定义消息]' return '[自定义消息]'
} }
const customData = typeof payload.data === 'string' let customData
? JSON.parse(payload.data) try {
: payload.data customData = typeof payload.data === 'string'
? JSON.parse(payload.data)
: payload.data
} catch (parseError) {
console.error('JSON 解析失败:', payload.data, parseError)
return payload.description || '[自定义消息]'
}
const messageType = customData.messageType || customData.type const messageType = customData.messageType || customData.type
const messageTypeMap = { // 使用 switch 语句保持与 getGroupListInternal 中的逻辑一致
system_message: '[系统消息]', let messageText = '[自定义消息]'
symptom: '[病情描述]', switch (messageType) {
prescription: '[处方单]', case 'system_message':
refill: '[续方申请]', messageText = '[系统消息]'
survey: '[问卷调查]', break
article: '[文章]', case 'symptom':
consult_pending: '患者向团队发起咨询请在1小时内接诊', messageText = '[病情描述]'
consult_rejected: '咨询已被拒绝', break
consult_timeout: '咨询已超时自动关闭', case 'prescription':
consult_accepted: '已接诊,会话已开始', messageText = '[处方单]'
consult_ended: '已结束当前会话', break
case 'refill':
messageText = '[续方申请]'
break
case 'survey':
messageText = '[问卷调查]'
break
case 'article':
messageText = '[文章]'
break
case 'consult_pending':
messageText = '患者向团队发起咨询请在1小时内接诊超时将自动关闭会话'
break
case 'consult_rejected':
messageText = '患者向团队发起咨询,由于有紧急事务要处理暂时无法接受咨询.本次会话已关闭'
break
case 'consult_timeout':
messageText = '患者向团队发起咨询,团队成员均未接受咨询,本次会话已自动关闭'
break
case 'consult_accepted':
messageText = '已接诊,会话已开始'
break
case 'consult_ended':
messageText = '已结束当前会话'
break
default:
messageText = customData.content || '[自定义消息]'
} }
return messageTypeMap[messageType] || customData.content || '[自定义消息]' console.log('自定义消息类型:', messageType, '显示文本:', messageText)
return messageText
} catch (error) { } catch (error) {
console.error('格式化自定义消息失败:', error) console.error('格式化自定义消息失败:', error, payload)
return '[自定义消息]' return '[自定义消息]'
} }
} }