From 292a5b0118173b3e92ee7ebe659b56d6c77f2ce4 Mon Sep 17 00:00:00 2001
From: Jafeng <2998840497@qq.com>
Date: Thu, 12 Feb 2026 11:01:48 +0800
Subject: [PATCH 1/2] =?UTF-8?q?fix=EF=BC=9A=E4=BC=98=E5=8C=96=E6=98=BE?=
=?UTF-8?q?=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/case/search.vue | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pages/case/search.vue b/pages/case/search.vue
index b974c83..8a3e4f9 100644
--- a/pages/case/search.vue
+++ b/pages/case/search.vue
@@ -55,7 +55,7 @@
- 输入患者名称、手机号或病案号进行搜索
+
From 6a6b8abf9fe169cca698c0ddd1f55bb89ca2608d Mon Sep 17 00:00:00 2001
From: Jafeng <2998840497@qq.com>
Date: Fri, 27 Feb 2026 17:17:34 +0800
Subject: [PATCH 2/2] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E7=97=85=E5=8E=86?=
=?UTF-8?q?=E8=AF=A6=E6=83=85=E5=8A=A0=E8=BD=BD=E9=94=99=E8=AF=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/case/visit-record-view.vue | 187 +++++++++++++++++++++++++++----
pages/home/case-home.vue | 37 +++---
2 files changed, 182 insertions(+), 42 deletions(-)
diff --git a/pages/case/visit-record-view.vue b/pages/case/visit-record-view.vue
index b17dc0b..d1e7f72 100644
--- a/pages/case/visit-record-view.vue
+++ b/pages/case/visit-record-view.vue
@@ -56,7 +56,9 @@
import { computed, onMounted, onUnmounted, ref } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import dayjs from 'dayjs';
+import { storeToRefs } from 'pinia';
import api from '@/utils/api';
+import useAccountStore from '@/store/account';
import { loading, hideLoading, toast } from '@/utils/widget';
import { getVisitRecordTemplate } from './components/archive-detail/templates';
import { normalizeVisitRecordFormData } from './utils/visit-record';
@@ -65,6 +67,10 @@ import { normalizeFileUrl } from '@/utils/file';
const scrollHeight = ref(0);
+const accountStore = useAccountStore();
+const { account, doctorInfo } = storeToRefs(accountStore);
+const { getDoctorInfo } = accountStore;
+
const archiveId = ref('');
const id = ref('');
const medicalType = ref('');
@@ -76,6 +82,8 @@ let recordChangedHandler = null;
const userNameMap = ref({});
const loadedMembersTeamId = ref('');
+const corpMemberNameInflight = new Map(); // userId -> Promise
+const corpMemberNameTried = new Set(); // avoid retry storms on failures
const files = computed(() => {
const arr = record.value?.files;
@@ -155,9 +163,48 @@ function formatPositiveFind(v, { withOpinion = false } = {}) {
return normalizeText(v);
}
-function getCorpId() {
+async function ensureDoctor() {
+ if (doctorInfo.value) return;
+ if (!account.value?.openid) return;
+ try {
+ await getDoctorInfo();
+ } catch {
+ // ignore
+ }
+}
+
+function extractDisplayNameFromAny(raw) {
+ const obj = raw && typeof raw === 'object' ? raw : {};
+ const candidate =
+ obj.anotherName ??
+ obj.name ??
+ obj.username ??
+ obj.userName ??
+ obj.nickname ??
+ obj.nickName ??
+ obj.realName ??
+ obj.memberName ??
+ obj.doctorName ??
+ obj.title ??
+ '';
+ return candidate ? String(candidate).trim() : '';
+}
+
+function extractDisplayNameFromCorpMember(row) {
+ const m = row && typeof row === 'object' ? row : {};
+ return String(m.anotherName || m.name || '').trim();
+}
+
+function getCorpIdForQuery() {
+ // 优先使用已拉取到的企业信息,其次用本地当前团队(最后兜底)
+ const d = doctorInfo.value || {};
+ const a = account.value || {};
const team = uni.getStorageSync('ykt_case_current_team') || {};
- return team?.corpId ? String(team.corpId) : '';
+ return String(d.corpId || a.corpId || team.corpId || '') || '';
+}
+
+function getCorpId() {
+ return getCorpIdForQuery();
}
function getTeamId() {
@@ -220,11 +267,107 @@ async function loadTeamMembers() {
}
}
+async function prefetchCorpMemberName(userId) {
+ const id = normalizeUserId(userId);
+ if (!id || !isLikelyUserId(id)) return '';
+
+ const map = userNameMap.value || {};
+ const existing = String(map[id] || map[id.toLowerCase()] || '').trim();
+ if (existing && existing !== id) return existing;
+
+ if (corpMemberNameInflight.has(id)) return corpMemberNameInflight.get(id);
+ if (corpMemberNameTried.has(id)) return '';
+
+ const p = (async () => {
+ corpMemberNameTried.add(id);
+
+ await ensureDoctor();
+ const corpId = getCorpIdForQuery();
+
+ // 1) 首选:成员主页信息(更可能支持 userid 查询)
+ try {
+ const res = await api('getCorpMemberHomepageInfo', { corpId, corpUserId: id }, false);
+ if (res?.success) {
+ const name =
+ extractDisplayNameFromAny(res?.data) ||
+ extractDisplayNameFromAny(res?.data?.data) ||
+ extractDisplayNameFromAny(res?.data?.member) ||
+ '';
+ if (name) return name;
+ }
+ } catch {
+ // ignore
+ }
+
+ // 1.1) 部分环境参数名是 userId
+ try {
+ const res = await api('getCorpMemberHomepageInfo', { corpId, userId: id }, false);
+ if (res?.success) {
+ const name =
+ extractDisplayNameFromAny(res?.data) ||
+ extractDisplayNameFromAny(res?.data?.data) ||
+ extractDisplayNameFromAny(res?.data?.member) ||
+ '';
+ if (name) return name;
+ }
+ } catch {
+ // ignore
+ }
+
+ // 2) 兜底:成员数据接口
+ try {
+ const res = await api(
+ 'getCorpMember',
+ {
+ corpId,
+ page: 1,
+ pageSize: 10,
+ params: {
+ corpId,
+ memberList: [id],
+ },
+ },
+ false
+ );
+ if (res?.success) {
+ const rows = Array.isArray(res?.data) ? res.data : Array.isArray(res?.data?.data) ? res.data.data : [];
+ const row = rows.find((m) => normalizeUserId(m?.userid || m?.userId || m?.corpUserId || '') === id) || rows[0] || null;
+ const name = extractDisplayNameFromCorpMember(row) || '';
+ if (name) return name;
+ }
+ } catch {
+ // ignore
+ }
+
+ return '';
+ })()
+ .then((name) => {
+ const display = String(name || '').trim();
+ if (display) {
+ const next = { ...(userNameMap.value || {}) };
+ next[id] = display;
+ next[id.toLowerCase()] = display;
+ userNameMap.value = next;
+ }
+ return display;
+ })
+ .finally(() => {
+ corpMemberNameInflight.delete(id);
+ });
+
+ corpMemberNameInflight.set(id, p);
+ return p;
+}
+
function resolveUserName(userId) {
const id = normalizeUserId(userId);
if (!id) return '';
const map = userNameMap.value || {};
- return String(map[id] || map[id.toLowerCase()] || id);
+ const resolved = String(map[id] || map[id.toLowerCase()] || '').trim();
+ if (resolved) return resolved;
+ // 无 teamId/未初始化 localStorage 时,尝试用企业成员接口补齐
+ void prefetchCorpMemberName(id);
+ return id;
}
function parseAnyTimeMs(v) {
@@ -350,8 +493,8 @@ const sections = computed(() => {
});
async function loadTemplate(t) {
+ if (!t) return null;
const corpId = getCorpId();
- if (!corpId || !t) return null;
try {
const res = await api('getCurrentTemplate', { corpId, templateType: t });
if (!res?.success) return null;
@@ -388,12 +531,9 @@ const topText = computed(() => {
});
async function fetchRecord({ silent = false } = {}) {
- if (!archiveId.value || !id.value || !medicalType.value) return false;
+ if (!archiveId.value || !id.value || !medicalType.value) return { ok: false, reason: 'request_failed' };
+ await ensureDoctor();
const corpId = getCorpId();
- if (!corpId) {
- if (!silent) toast('缺少 corpId');
- return false;
- }
if (!silent) loading('加载中...');
try {
@@ -404,19 +544,22 @@ async function fetchRecord({ silent = false } = {}) {
medicalType: medicalType.value,
});
const r = res?.record || res?.data?.record || null;
- if (!res?.success || !r) return false;
+ if (res?.success && r) {
+ const raw = String(r?.templateType || r?.medicalType || medicalType.value || '');
+ rawType.value = raw;
+ const ui = normalizeMedicalType(raw);
+ record.value = normalizeVisitRecordFormData(ui, r);
+ temp.value = await loadTemplate(raw);
+ uni.setNavigationBarTitle({ title: String(typeLabel.value || '病历详情') });
+ return { ok: true, reason: '' };
+ }
- const raw = String(r?.templateType || r?.medicalType || medicalType.value || '');
- rawType.value = raw;
- const ui = normalizeMedicalType(raw);
- record.value = normalizeVisitRecordFormData(ui, r);
- temp.value = await loadTemplate(raw);
- uni.setNavigationBarTitle({ title: String(typeLabel.value || '病历详情') });
- return true;
+ const msg = String(res?.message || res?.msg || '').trim();
+ const isNotFound = (res?.success && !r) || /不存在|not\s*found|not\s*exist/i.test(msg);
+ return { ok: false, reason: isNotFound ? 'not_found' : 'request_failed' };
} catch (error) {
console.error('获取病历记录失败:', error);
- if (!silent) toast('加载失败');
- return false;
+ return { ok: false, reason: 'request_failed' };
} finally {
if (!silent) hideLoading();
}
@@ -442,9 +585,9 @@ onLoad(async (opt) => {
// 异步加载团队成员映射,用于展示“xx代建”的真实姓名
void loadTeamMembers();
- const ok = await fetchRecord();
- if (!ok) {
- toast('记录不存在');
+ const result = await fetchRecord();
+ if (!result?.ok) {
+ toast(result?.reason === 'not_found' ? '记录不存在' : '请求失败');
setTimeout(() => uni.navigateBack(), 300);
}
});
diff --git a/pages/home/case-home.vue b/pages/home/case-home.vue
index 8153566..93d521d 100644
--- a/pages/home/case-home.vue
+++ b/pages/home/case-home.vue
@@ -485,28 +485,25 @@ async function fetchCorpMemberDisplayName(userId) {
// ignore
}
- // 2) 兜底:成员数据接口(部分环境可能支持 corpUserId)
+ // 2) 兜底:成员列表接口(支持 memberList)
try {
- const res = await api('getCorpMemberData', { corpId, corpUserId: id }, false);
+ const res = await api(
+ 'getCorpMember',
+ {
+ page: 1,
+ pageSize: 10,
+ params: {
+ corpId,
+ memberList: [id],
+ },
+ },
+ false
+ );
if (res?.success) {
- const name =
- extractDisplayNameFromAny(res?.data) ||
- extractDisplayNameFromAny(res?.data?.data) ||
- '';
- if (name) return name;
- }
- } catch {
- // ignore
- }
-
- // 2.1) 同样尝试 userId
- try {
- const res = await api('getCorpMemberData', { corpId, userId: id }, false);
- if (res?.success) {
- const name =
- extractDisplayNameFromAny(res?.data) ||
- extractDisplayNameFromAny(res?.data?.data) ||
- '';
+ const rows = Array.isArray(res?.data) ? res.data : Array.isArray(res?.data?.data) ? res.data.data : [];
+ const row =
+ rows.find((m) => normalizeUserId(m?.userid || m?.userId || m?.corpUserId || '') === id) || rows[0] || null;
+ const name = extractDisplayNameFromCorpMember(row) || '';
if (name) return name;
}
} catch {