Compare commits

..

No commits in common. "b9385ebf02282331c4fe92915d364d9d11e771bd" and "d75b8fb8cf9ed78356eddb88c28cba1d05cc9193" have entirely different histories.

9 changed files with 135 additions and 655 deletions

View File

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

View File

@ -121,7 +121,6 @@
:archiveId="archiveId"
:reachBottomTime="reachBottomTime"
:floatingBottom="floatingBottom"
:fromChat="fromChat"
/>
</view>
@ -243,7 +242,6 @@ const tabs = [
const currentTab = ref('visitRecord');
const reachBottomTime = ref(0);
const archiveId = ref('');
const fromChat = ref(false);
const tabsScrollTop = ref(0);
const instanceProxy = getCurrentInstance()?.proxy;
@ -476,7 +474,6 @@ async function updateArchive(patch) {
onLoad((options) => {
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);
if (cached && typeof cached === 'object') {

View File

@ -4,10 +4,7 @@
<view class="top">
<view class="top-row">
<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>
@ -28,81 +25,32 @@
</view>
<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 class="total"
><text class="total-num">{{ total }}</text
></view
>
<view class="total"><text class="total-num">{{ total }}</text></view>
</view>
<view class="list">
<view v-for="i in list" :key="i._id" class="card" @click="toDetail(i)">
<view class="head">
<view class="date"
>计划日期: <text class="date-val">{{ i.planDate }}</text></view
>
<view class="executor truncate"
>{{ i.executorName
}}<text v-if="i.executeTeamName"
>{{ i.executeTeamName }}</text
></view
>
<view class="date">计划日期: <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 class="body">
<view class="title-row">
<view class="type">{{ i.eventTypeLabel }}</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 class="status" :class="`st-${i.status}`">{{ i.eventStatusLabel }}</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 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 class="fab" :style="{ bottom: `${floatingBottom}px` }" @click="add">
@ -151,18 +99,9 @@
<view class="section">
<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-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" />
</view>
</picker>
@ -172,15 +111,11 @@
<view class="section-title">计划日期</view>
<view class="range-row">
<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>
<view class="sep">-</view>
<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>
<view class="clear" @click="clearPlanRange">
<uni-icons type="closeempty" size="16" color="#999" />
@ -198,23 +133,19 @@
</template>
<script setup>
import { computed, onMounted, onUnmounted, reactive, ref, watch } from "vue";
import { storeToRefs } from "pinia";
import dayjs from "dayjs";
import api from "@/utils/api";
import useAccountStore from "@/store/account";
import { toast } from "@/utils/widget";
import {
getTodoEventTypeLabel,
getTodoEventTypeOptions,
} from "@/utils/todo-const";
import { computed, onMounted, onUnmounted, reactive, ref, watch } from 'vue';
import { storeToRefs } from 'pinia';
import dayjs from 'dayjs';
import api from '@/utils/api';
import useAccountStore from '@/store/account';
import { toast } from '@/utils/widget';
import { getTodoEventTypeLabel, getTodoEventTypeOptions } from '@/utils/todo-const';
const props = defineProps({
data: { type: Object, default: () => ({}) },
archiveId: { type: String, default: "" },
reachBottomTime: { type: [String, Number], default: "" },
archiveId: { type: String, default: '' },
reachBottomTime: { type: [String, Number], default: '' },
floatingBottom: { type: Number, default: 16 },
fromChat: { type: Boolean, default: false },
});
const accountStore = useAccountStore();
@ -222,27 +153,24 @@ const { account, doctorInfo } = storeToRefs(accountStore);
const { getDoctorInfo } = accountStore;
const statusTabs = [
{ label: "全部", value: "all" },
{ label: "待处理", value: "processing" },
{ label: "未开始", value: "notStart" },
{ label: "已完成", value: "treated" },
{ label: "已取消", value: "cancelled" },
{ label: "已过期", value: "expired" },
{ label: '全部', value: 'all' },
{ label: '待处理', value: 'processing' },
{ label: '未开始', value: 'notStart' },
{ label: '已完成', value: 'treated' },
{ label: '已取消', value: 'cancelled' },
{ 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({
isMy: false,
status: "all",
status: 'all',
eventTypes: [],
teamId: "ALL",
planRange: ["", ""],
teamId: 'ALL',
planRange: ['', ''],
});
const list = ref([]);
@ -256,20 +184,20 @@ const loading = ref(false);
const userNameMap = ref({});
const moreStatus = computed(() => {
if (loading.value) return "loading";
return page.value <= pages.value ? "more" : "no-more";
if (loading.value) return 'loading';
return page.value <= pages.value ? 'more' : 'no-more';
});
const loadMoreText = {
contentdown: "点击加载更多",
contentrefresh: "加载中...",
contentnomore: "没有更多了",
contentdown: '点击加载更多',
contentrefresh: '加载中...',
contentnomore: '没有更多了',
};
const filtered = ref(false);
const typeSelectedMap = computed(() => {
const s = new Set(query.eventTypes || []);
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);
return acc;
}, {});
@ -278,18 +206,14 @@ const typeSelectedMap = computed(() => {
function getUserId() {
const d = doctorInfo.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() {
const t = uni.getStorageSync("ykt_case_current_team") || {};
const t = uni.getStorageSync('ykt_case_current_team') || {};
const a = account.value || {};
const d = doctorInfo.value || {};
return String(t.corpId || a.corpId || d.corpId || "") || "";
return String(t.corpId || a.corpId || d.corpId || '') || '';
}
async function ensureDoctor() {
@ -304,37 +228,33 @@ async function ensureDoctor() {
function statusLabelFromStatus(status) {
const map = {
processing: "待处理",
notStart: "未开始",
treated: "已完成",
cancelled: "已取消",
expired: "已过期",
processing: '待处理',
notStart: '未开始',
treated: '已完成',
cancelled: '已取消',
expired: '已过期',
};
return map[status] || "未知";
return map[status] || '未知';
}
function getStatus(todo) {
const endOfToday = dayjs().endOf("day").valueOf();
const startOfToday = dayjs().startOf("day").valueOf();
const endOfToday = dayjs().endOf('day').valueOf();
const startOfToday = dayjs().startOf('day').valueOf();
const plannedExecutionTime = Number(todo?.plannedExecutionTime || 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 === "closed") return "cancelled";
if (eventStatus === "expire") return "expired";
if (eventStatus === 'treated') return 'treated';
if (eventStatus === 'closed') return 'cancelled';
if (eventStatus === 'expire') return 'expired';
if (eventStatus === "untreated") {
if (expireTime && expireTime < startOfToday) return "expired";
if (plannedExecutionTime >= endOfToday) return "notStart";
if (
plannedExecutionTime <= startOfToday &&
(!expireTime || expireTime >= endOfToday)
)
return "processing";
return "processing";
if (eventStatus === 'untreated') {
if (expireTime && expireTime < startOfToday) return 'expired';
if (plannedExecutionTime >= endOfToday) return 'notStart';
if (plannedExecutionTime <= startOfToday && (!expireTime || expireTime >= endOfToday)) return 'processing';
return 'processing';
}
return "processing";
return 'processing';
}
function eventTypeLabel(eventType) {
@ -342,10 +262,10 @@ function eventTypeLabel(eventType) {
}
function resolveUserName(userId) {
const id = String(userId || "");
if (!id) return "";
const id = String(userId || '');
if (!id) return '';
const map = userNameMap.value || {};
return String(map[id] || "") || id;
return String(map[id] || '') || id;
}
function formatTodo(todo) {
@ -357,14 +277,8 @@ function formatTodo(todo) {
status,
eventStatusLabel: statusLabelFromStatus(status),
eventTypeLabel: eventTypeLabel(todo?.eventType),
planDate:
plannedExecutionTime && dayjs(plannedExecutionTime).isValid()
? dayjs(plannedExecutionTime).format("YYYY-MM-DD")
: "",
createTimeStr:
createTime && dayjs(createTime).isValid()
? dayjs(createTime).format("YYYY-MM-DD HH:mm")
: "",
planDate: 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),
creatorName: resolveUserName(todo?.creatorUserId),
};
@ -389,7 +303,7 @@ async function getMore() {
const corpId = getCorpId();
const userId = getUserId();
if (!corpId) {
toast("缺少 corpId请先完成登录/团队选择");
toast('缺少 corpId请先完成登录/团队选择');
return;
}
@ -400,23 +314,22 @@ async function getMore() {
pageSize,
};
if (query.status !== "all") params.statusList = [query.status];
if (query.status !== 'all') params.statusList = [query.status];
if (query.isMy) params.executorUserId = userId;
if (Array.isArray(query.eventTypes) && query.eventTypes.length)
params.eventType = query.eventTypes;
if (query.teamId && query.teamId !== "ALL") params.teamId = query.teamId;
if (Array.isArray(query.eventTypes) && query.eventTypes.length) 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?.[1]) params.endDate = query.planRange[1];
const res = await api("getCustomerTodos", params);
const res = await api('getCustomerTodos', params);
if (!res?.success) {
toast(res?.message || "获取回访任务失败");
toast(res?.message || '获取回访任务失败');
return;
}
const arr = Array.isArray(res.data) ? res.data : [];
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;
list.value = page.value === 1 ? next : [...list.value, ...next];
page.value += 1;
@ -439,154 +352,58 @@ async function loadTeams() {
const corpId = getCorpId();
const userId = getUserId();
if (!corpId || !userId) return;
const res = await api("getTeamBymember", { corpId, corpUserId: userId });
const res = await api('getTeamBymember', { corpId, corpUserId: userId });
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
.map((raw) => {
if (!raw || typeof raw !== "object") return null;
const teamId = raw.teamId || raw.id || raw._id || "";
const name = raw.name || raw.teamName || raw.team || "";
if (!raw || typeof raw !== 'object') return null;
const teamId = raw.teamId || raw.id || raw._id || '';
const name = raw.name || raw.teamName || raw.team || '';
if (!teamId || !name) return null;
return { label: String(name), value: String(teamId) };
})
.filter(Boolean);
teamOptions.value = [{ label: "全部", value: "ALL" }, ...normalized];
teamOptions.value = [{ label: '全部', value: 'ALL' }, ...normalized];
}
function add() {
uni.showActionSheet({
itemList: ["+新增任务", "+使用模板", "+回访记录"],
itemList: ['+新增任务', '+使用模板', '+回访记录'],
success: ({ tapIndex }) => {
if (tapIndex === 0) {
uni.setStorageSync("new-followup-customer", {
_id: props.archiveId,
name: props.data?.name || "",
});
uni.navigateTo({
url: `/pages/case/new-followup?archiveId=${encodeURIComponent(
props.archiveId
)}`,
});
uni.setStorageSync('new-followup-customer', { _id: props.archiveId, name: props.data?.name || '' });
uni.navigateTo({ url: `/pages/case/new-followup?archiveId=${encodeURIComponent(props.archiveId)}` });
} else if (tapIndex === 1) {
uni.setStorageSync("new-followup-plan-customer", {
_id: props.archiveId,
name: props.data?.name || "",
});
uni.setStorageSync("select-mamagement-plan", "");
uni.navigateTo({
url: `/pages/case/plan-list?archiveId=${encodeURIComponent(
props.archiveId
)}`,
});
uni.setStorageSync('new-followup-plan-customer', { _id: 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) {
uni.setStorageSync("new-followup-record-customer", {
_id: props.archiveId,
name: props.data?.name || "",
});
uni.navigateTo({
url: `/pages/case/new-followup-record?archiveId=${encodeURIComponent(
props.archiveId
)}`,
});
uni.setStorageSync('new-followup-record-customer', { _id: props.archiveId, name: props.data?.name || '' });
uni.navigateTo({ url: `/pages/case/new-followup-record?archiveId=${encodeURIComponent(props.archiveId)}` });
}
},
});
}
function toDetail(todo) {
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();
uni.navigateTo({ url: `/pages/case/followup-detail?archiveId=${encodeURIComponent(props.archiveId)}&mode=edit&id=${encodeURIComponent(todo._id)}` });
}
// ---- filter popup ----
const filterPopupRef = ref(null);
const state = ref(null);
const teamPicked = ref(teamOptions.value[0]);
const planRange = ref(["", ""]);
const planRange = ref(['', '']);
function openFilter() {
state.value = {
query: {
...query,
eventTypes: [...(query.eventTypes || [])],
planRange: [...(query.planRange || ["", ""])],
},
query: { ...query, eventTypes: [...(query.eventTypes || [])], planRange: [...(query.planRange || ['', ''])] },
team: { ...teamPicked.value },
range: [...planRange.value],
};
planRange.value = [...(query.planRange || ["", ""])];
teamPicked.value =
teamOptions.value.find((i) => i.value === query.teamId) ||
teamOptions.value[0];
planRange.value = [...(query.planRange || ['', ''])];
teamPicked.value = teamOptions.value.find((i) => i.value === query.teamId) || teamOptions.value[0];
filterPopupRef.value?.open?.();
}
function closeFilter(revert) {
@ -599,7 +416,7 @@ function closeFilter(revert) {
}
function toggleType(v) {
if (v === "all") {
if (v === 'all') {
query.eventTypes = [];
return;
}
@ -615,50 +432,42 @@ function pickTeam(e) {
}
function pickStart(e) {
planRange.value = [e.detail.value || "", planRange.value[1] || ""];
planRange.value = [e.detail.value || '', planRange.value[1] || ''];
query.planRange = [...planRange.value];
}
function pickEnd(e) {
planRange.value = [planRange.value[0] || "", e.detail.value || ""];
planRange.value = [planRange.value[0] || '', e.detail.value || ''];
query.planRange = [...planRange.value];
}
function clearPlanRange() {
planRange.value = ["", ""];
query.planRange = ["", ""];
planRange.value = ['', ''];
query.planRange = ['', ''];
}
function resetFilter() {
query.eventTypes = [];
query.teamId = "ALL";
query.teamId = 'ALL';
teamPicked.value = teamOptions.value[0];
clearPlanRange();
}
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);
resetList();
}
onMounted(() => {
const userId = getUserId();
const name = String(
doctorInfo.value?.anotherName || doctorInfo.value?.name || ""
);
if (userId && name)
userNameMap.value = { ...(userNameMap.value || {}), [userId]: name };
const name = String(doctorInfo.value?.anotherName || doctorInfo.value?.name || '');
if (userId && name) userNameMap.value = { ...(userNameMap.value || {}), [userId]: name };
loadTeams();
resetList();
uni.$on("archive-detail:followup-changed", resetList);
uni.$on('archive-detail:followup-changed', resetList);
});
onUnmounted(() => {
uni.$off("archive-detail:followup-changed", resetList);
uni.$off('archive-detail:followup-changed', resetList);
});
watch(
@ -714,7 +523,7 @@ watch(
}
.status-tab.active {
background: #dbe6ff;
color: #0877f1;
color: #0877F1;
}
.filter-btn {
flex-shrink: 0;
@ -794,7 +603,7 @@ watch(
}
.st-notStart {
background: #dbe6ff;
color: #0877f1;
color: #0877F1;
}
.st-treated {
background: #dcfce7;
@ -811,129 +620,15 @@ watch(
color: #666;
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 {
margin-top: 10px;
font-size: 13px;
color: #666;
}
.footer-row {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 10px;
padding-top: 10px;
border-top: 1px solid #f2f2f2;
gap: 10px;
}
.footer {
margin-top: 10px;
font-size: 12px;
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 {
@ -949,7 +644,7 @@ watch(
width: 52px;
height: 52px;
border-radius: 26px;
background: #0877f1;
background: #0877F1;
display: flex;
align-items: center;
justify-content: center;
@ -1009,8 +704,8 @@ watch(
color: #333;
}
.chip.active {
background: #0877f1;
border-color: #0877f1;
background: #0877F1;
border-color: #0877F1;
color: #fff;
}
.select-row {
@ -1074,11 +769,11 @@ watch(
}
.btn.plain {
background: #fff;
color: #0877f1;
border: 1px solid #0877f1;
color: #0877F1;
border: 1px solid #0877F1;
}
.btn.primary {
background: #0877f1;
background: #0877F1;
color: #fff;
}
</style>

View File

@ -1,75 +0,0 @@
<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,8 +315,6 @@ const closePreview = () => {
const sendArticle = async (article) => {
try {
const { doctorInfo } = useAccountStore();
// 1. API
const result = await api("sendArticleMessage", {
groupId: pageParams.value.groupId,
fromAccount: doctorInfo.userid,
@ -325,46 +323,8 @@ const sendArticle = async (article) => {
imgUrl: article.cover || "",
desc: "点击查看详情",
});
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 {
await api("addArticleSendRecord", {
articleId: article._id,

View File

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

View File

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

View File

@ -757,34 +757,8 @@ onShow(() => {
}
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(() => {
stopIMMonitoring();
@ -971,9 +945,6 @@ onUnmounted(() => {
timChatManager.setCallback("onMessageReceived", null);
timChatManager.setCallback("onMessageListLoaded", null);
timChatManager.setCallback("onError", null);
// 访
uni.$off('send-followup-message', handleSendFollowUpMessage);
});
</script>

View File

@ -723,26 +723,14 @@ class TimChatManager {
// 判断是否为当前会话的消息
// 系统消息只要会话ID匹配就显示不要求必须有currentConversationID
// 自定义消息文章等如果currentConversationID已设置则需要匹配如果未设置则暂存等待
// 普通消息必须有currentConversationID且匹配才显示
let isCurrentConversation = false
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
}
const isCurrentConversation = isSystemMsg
? messageConversationID === this.currentConversationID
: (this.currentConversationID && messageConversationID === this.currentConversationID)
console.log('消息会话匹配检查:', {
isCurrentConversation,
isSystemMessage: isSystemMsg,
messageType: convertedMessage.type,
hasCurrentConversationID: !!this.currentConversationID,
conversationIDMatch: messageConversationID === this.currentConversationID
})
@ -2528,66 +2516,32 @@ class TimChatManager {
formatCustomMessage(payload) {
try {
if (!payload || !payload.data) {
console.warn('payload.data 为空:', payload)
return '[自定义消息]'
}
let customData
try {
customData = typeof payload.data === 'string'
const 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
// 使用 switch 语句保持与 getGroupListInternal 中的逻辑一致
let messageText = '[自定义消息]'
switch (messageType) {
case 'system_message':
messageText = '[系统消息]'
break
case 'symptom':
messageText = '[病情描述]'
break
case 'prescription':
messageText = '[处方单]'
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 || '[自定义消息]'
const messageTypeMap = {
system_message: '[系统消息]',
symptom: '[病情描述]',
prescription: '[处方单]',
refill: '[续方申请]',
survey: '[问卷调查]',
article: '[文章]',
consult_pending: '患者向团队发起咨询请在1小时内接诊',
consult_rejected: '咨询已被拒绝',
consult_timeout: '咨询已超时自动关闭',
consult_accepted: '已接诊,会话已开始',
consult_ended: '已结束当前会话',
}
console.log('自定义消息类型:', messageType, '显示文本:', messageText)
return messageText
return messageTypeMap[messageType] || customData.content || '[自定义消息]'
} catch (error) {
console.error('格式化自定义消息失败:', error, payload)
console.error('格式化自定义消息失败:', error)
return '[自定义消息]'
}
}