Compare commits
No commits in common. "92cf6113958787fc93c1bbed549ae0d49a487667" and "6b740bda78606b97a04fa031a0f89cc17119554c" have entirely different histories.
92cf611395
...
6b740bda78
@ -55,7 +55,7 @@
|
|||||||
|
|
||||||
<!-- History or Suggestions (when no search) -->
|
<!-- History or Suggestions (when no search) -->
|
||||||
<view v-else class="search-tips">
|
<view v-else class="search-tips">
|
||||||
<!-- <text class="tips-text">输入患者名称、手机号或病案号进行搜索</text> -->
|
<text class="tips-text">输入患者名称、手机号或病案号进行搜索</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@ -56,9 +56,7 @@
|
|||||||
import { computed, onMounted, onUnmounted, ref } from 'vue';
|
import { computed, onMounted, onUnmounted, ref } from 'vue';
|
||||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { storeToRefs } from 'pinia';
|
|
||||||
import api from '@/utils/api';
|
import api from '@/utils/api';
|
||||||
import useAccountStore from '@/store/account';
|
|
||||||
import { loading, hideLoading, toast } from '@/utils/widget';
|
import { loading, hideLoading, toast } from '@/utils/widget';
|
||||||
import { getVisitRecordTemplate } from './components/archive-detail/templates';
|
import { getVisitRecordTemplate } from './components/archive-detail/templates';
|
||||||
import { normalizeVisitRecordFormData } from './utils/visit-record';
|
import { normalizeVisitRecordFormData } from './utils/visit-record';
|
||||||
@ -67,10 +65,6 @@ import { normalizeFileUrl } from '@/utils/file';
|
|||||||
|
|
||||||
const scrollHeight = ref(0);
|
const scrollHeight = ref(0);
|
||||||
|
|
||||||
const accountStore = useAccountStore();
|
|
||||||
const { account, doctorInfo } = storeToRefs(accountStore);
|
|
||||||
const { getDoctorInfo } = accountStore;
|
|
||||||
|
|
||||||
const archiveId = ref('');
|
const archiveId = ref('');
|
||||||
const id = ref('');
|
const id = ref('');
|
||||||
const medicalType = ref('');
|
const medicalType = ref('');
|
||||||
@ -82,8 +76,6 @@ let recordChangedHandler = null;
|
|||||||
|
|
||||||
const userNameMap = ref({});
|
const userNameMap = ref({});
|
||||||
const loadedMembersTeamId = ref('');
|
const loadedMembersTeamId = ref('');
|
||||||
const corpMemberNameInflight = new Map(); // userId -> Promise<string>
|
|
||||||
const corpMemberNameTried = new Set(); // avoid retry storms on failures
|
|
||||||
|
|
||||||
const files = computed(() => {
|
const files = computed(() => {
|
||||||
const arr = record.value?.files;
|
const arr = record.value?.files;
|
||||||
@ -163,48 +155,9 @@ function formatPositiveFind(v, { withOpinion = false } = {}) {
|
|||||||
return normalizeText(v);
|
return normalizeText(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
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 String(d.corpId || a.corpId || team.corpId || '') || '';
|
|
||||||
}
|
|
||||||
|
|
||||||
function getCorpId() {
|
function getCorpId() {
|
||||||
return getCorpIdForQuery();
|
const team = uni.getStorageSync('ykt_case_current_team') || {};
|
||||||
|
return team?.corpId ? String(team.corpId) : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTeamId() {
|
function getTeamId() {
|
||||||
@ -267,107 +220,11 @@ 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) {
|
function resolveUserName(userId) {
|
||||||
const id = normalizeUserId(userId);
|
const id = normalizeUserId(userId);
|
||||||
if (!id) return '';
|
if (!id) return '';
|
||||||
const map = userNameMap.value || {};
|
const map = userNameMap.value || {};
|
||||||
const resolved = String(map[id] || map[id.toLowerCase()] || '').trim();
|
return String(map[id] || map[id.toLowerCase()] || id);
|
||||||
if (resolved) return resolved;
|
|
||||||
// 无 teamId/未初始化 localStorage 时,尝试用企业成员接口补齐
|
|
||||||
void prefetchCorpMemberName(id);
|
|
||||||
return id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseAnyTimeMs(v) {
|
function parseAnyTimeMs(v) {
|
||||||
@ -493,8 +350,8 @@ const sections = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
async function loadTemplate(t) {
|
async function loadTemplate(t) {
|
||||||
if (!t) return null;
|
|
||||||
const corpId = getCorpId();
|
const corpId = getCorpId();
|
||||||
|
if (!corpId || !t) return null;
|
||||||
try {
|
try {
|
||||||
const res = await api('getCurrentTemplate', { corpId, templateType: t });
|
const res = await api('getCurrentTemplate', { corpId, templateType: t });
|
||||||
if (!res?.success) return null;
|
if (!res?.success) return null;
|
||||||
@ -531,9 +388,12 @@ const topText = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
async function fetchRecord({ silent = false } = {}) {
|
async function fetchRecord({ silent = false } = {}) {
|
||||||
if (!archiveId.value || !id.value || !medicalType.value) return { ok: false, reason: 'request_failed' };
|
if (!archiveId.value || !id.value || !medicalType.value) return false;
|
||||||
await ensureDoctor();
|
|
||||||
const corpId = getCorpId();
|
const corpId = getCorpId();
|
||||||
|
if (!corpId) {
|
||||||
|
if (!silent) toast('缺少 corpId');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!silent) loading('加载中...');
|
if (!silent) loading('加载中...');
|
||||||
try {
|
try {
|
||||||
@ -544,22 +404,19 @@ async function fetchRecord({ silent = false } = {}) {
|
|||||||
medicalType: medicalType.value,
|
medicalType: medicalType.value,
|
||||||
});
|
});
|
||||||
const r = res?.record || res?.data?.record || null;
|
const r = res?.record || res?.data?.record || null;
|
||||||
if (res?.success && r) {
|
if (!res?.success || !r) return false;
|
||||||
|
|
||||||
const raw = String(r?.templateType || r?.medicalType || medicalType.value || '');
|
const raw = String(r?.templateType || r?.medicalType || medicalType.value || '');
|
||||||
rawType.value = raw;
|
rawType.value = raw;
|
||||||
const ui = normalizeMedicalType(raw);
|
const ui = normalizeMedicalType(raw);
|
||||||
record.value = normalizeVisitRecordFormData(ui, r);
|
record.value = normalizeVisitRecordFormData(ui, r);
|
||||||
temp.value = await loadTemplate(raw);
|
temp.value = await loadTemplate(raw);
|
||||||
uni.setNavigationBarTitle({ title: String(typeLabel.value || '病历详情') });
|
uni.setNavigationBarTitle({ title: String(typeLabel.value || '病历详情') });
|
||||||
return { ok: true, reason: '' };
|
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) {
|
} catch (error) {
|
||||||
console.error('获取病历记录失败:', error);
|
console.error('获取病历记录失败:', error);
|
||||||
return { ok: false, reason: 'request_failed' };
|
if (!silent) toast('加载失败');
|
||||||
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
if (!silent) hideLoading();
|
if (!silent) hideLoading();
|
||||||
}
|
}
|
||||||
@ -585,9 +442,9 @@ onLoad(async (opt) => {
|
|||||||
// 异步加载团队成员映射,用于展示“xx代建”的真实姓名
|
// 异步加载团队成员映射,用于展示“xx代建”的真实姓名
|
||||||
void loadTeamMembers();
|
void loadTeamMembers();
|
||||||
|
|
||||||
const result = await fetchRecord();
|
const ok = await fetchRecord();
|
||||||
if (!result?.ok) {
|
if (!ok) {
|
||||||
toast(result?.reason === 'not_found' ? '记录不存在' : '请求失败');
|
toast('记录不存在');
|
||||||
setTimeout(() => uni.navigateBack(), 300);
|
setTimeout(() => uni.navigateBack(), 300);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -485,25 +485,28 @@ async function fetchCorpMemberDisplayName(userId) {
|
|||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2) 兜底:成员列表接口(支持 memberList)
|
// 2) 兜底:成员数据接口(部分环境可能支持 corpUserId)
|
||||||
try {
|
try {
|
||||||
const res = await api(
|
const res = await api('getCorpMemberData', { corpId, corpUserId: id }, false);
|
||||||
'getCorpMember',
|
|
||||||
{
|
|
||||||
page: 1,
|
|
||||||
pageSize: 10,
|
|
||||||
params: {
|
|
||||||
corpId,
|
|
||||||
memberList: [id],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
false
|
|
||||||
);
|
|
||||||
if (res?.success) {
|
if (res?.success) {
|
||||||
const rows = Array.isArray(res?.data) ? res.data : Array.isArray(res?.data?.data) ? res.data.data : [];
|
const name =
|
||||||
const row =
|
extractDisplayNameFromAny(res?.data) ||
|
||||||
rows.find((m) => normalizeUserId(m?.userid || m?.userId || m?.corpUserId || '') === id) || rows[0] || null;
|
extractDisplayNameFromAny(res?.data?.data) ||
|
||||||
const name = extractDisplayNameFromCorpMember(row) || '';
|
'';
|
||||||
|
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) ||
|
||||||
|
'';
|
||||||
if (name) return name;
|
if (name) return name;
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user