fix:优化显示
This commit is contained in:
parent
fdf2ca6136
commit
a6002134c2
@ -74,6 +74,9 @@ const temp = ref(null);
|
|||||||
const needReload = ref(false);
|
const needReload = ref(false);
|
||||||
let recordChangedHandler = null;
|
let recordChangedHandler = null;
|
||||||
|
|
||||||
|
const userNameMap = ref({});
|
||||||
|
const loadedMembersTeamId = ref('');
|
||||||
|
|
||||||
const files = computed(() => {
|
const files = computed(() => {
|
||||||
const arr = record.value?.files;
|
const arr = record.value?.files;
|
||||||
return Array.isArray(arr)
|
return Array.isArray(arr)
|
||||||
@ -157,6 +160,73 @@ function getCorpId() {
|
|||||||
return team?.corpId ? String(team.corpId) : '';
|
return team?.corpId ? String(team.corpId) : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getTeamId() {
|
||||||
|
const team = uni.getStorageSync('ykt_case_current_team') || {};
|
||||||
|
return team?.teamId ? String(team.teamId) : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeUserId(value) {
|
||||||
|
if (value === null || value === undefined) return '';
|
||||||
|
if (typeof value === 'object') {
|
||||||
|
const obj = value;
|
||||||
|
const picked =
|
||||||
|
obj.userid ||
|
||||||
|
obj.userId ||
|
||||||
|
obj.userID ||
|
||||||
|
obj.corpUserId ||
|
||||||
|
obj.corpUserID ||
|
||||||
|
obj._id ||
|
||||||
|
obj.id ||
|
||||||
|
'';
|
||||||
|
return String(picked || '').trim();
|
||||||
|
}
|
||||||
|
return String(value || '').trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
function isLikelyUserId(value) {
|
||||||
|
const id = normalizeUserId(value);
|
||||||
|
if (!id) return false;
|
||||||
|
if (/[-—]{1,2}/.test(id) && ['-', '—', '--'].includes(id.trim())) return false;
|
||||||
|
if (/\s/.test(id)) return false;
|
||||||
|
if (/[\u4e00-\u9fa5]/.test(id)) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadTeamMembers() {
|
||||||
|
const corpId = getCorpId();
|
||||||
|
const teamId = getTeamId();
|
||||||
|
if (!corpId || !teamId) return;
|
||||||
|
if (loadedMembersTeamId.value === teamId && Object.keys(userNameMap.value || {}).length > 0) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await api('getTeamData', { corpId, teamId });
|
||||||
|
if (!res?.success) return;
|
||||||
|
const t = res?.data && typeof res.data === 'object' ? res.data : {};
|
||||||
|
const members = Array.isArray(t.memberList) ? t.memberList : [];
|
||||||
|
const nextMap = {};
|
||||||
|
members.forEach((m) => {
|
||||||
|
if (!m || typeof m !== 'object') return;
|
||||||
|
const display = String(m?.anotherName || m?.name || m?.userid || m?.userId || m?.corpUserId || '').trim();
|
||||||
|
const keys = [m?.userid, m?.userId, m?.corpUserId].map(normalizeUserId).filter(Boolean);
|
||||||
|
keys.forEach((k) => {
|
||||||
|
nextMap[k] = display || nextMap[k] || k;
|
||||||
|
nextMap[String(k).toLowerCase()] = display || nextMap[String(k).toLowerCase()] || k;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
userNameMap.value = nextMap;
|
||||||
|
loadedMembersTeamId.value = teamId;
|
||||||
|
} catch {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveUserName(userId) {
|
||||||
|
const id = normalizeUserId(userId);
|
||||||
|
if (!id) return '';
|
||||||
|
const map = userNameMap.value || {};
|
||||||
|
return String(map[id] || map[id.toLowerCase()] || id);
|
||||||
|
}
|
||||||
|
|
||||||
function parseAnyTimeMs(v) {
|
function parseAnyTimeMs(v) {
|
||||||
if (v === null || v === undefined) return 0;
|
if (v === null || v === undefined) return 0;
|
||||||
if (typeof v === 'number') {
|
if (typeof v === 'number') {
|
||||||
@ -294,10 +364,26 @@ async function loadTemplate(t) {
|
|||||||
|
|
||||||
const topText = computed(() => {
|
const topText = computed(() => {
|
||||||
const time = record.value?.createTime ? dayjs(record.value.createTime).format('YYYY-MM-DD HH:mm') : '';
|
const time = record.value?.createTime ? dayjs(record.value.createTime).format('YYYY-MM-DD HH:mm') : '';
|
||||||
const rawName = record.value?.creatorName ? String(record.value.creatorName) : '';
|
|
||||||
const cleanName = ['-', '—', '--'].includes(rawName.trim()) ? '' : rawName.trim();
|
|
||||||
const byCustomer = record.value?.ignore === 'checkIn';
|
const byCustomer = record.value?.ignore === 'checkIn';
|
||||||
const suffix = byCustomer ? '患者自建' : cleanName ? `${cleanName}代建` : record.value?.creator ? '员工代建' : '';
|
if (byCustomer) return `${time || '--'} 患者自建`;
|
||||||
|
|
||||||
|
const nameFromApiRaw = record.value?.creatorName ? String(record.value.creatorName).trim() : '';
|
||||||
|
const nameFromApi = ['-', '—', '--'].includes(nameFromApiRaw) ? '' : nameFromApiRaw;
|
||||||
|
if (nameFromApi && !isLikelyUserId(nameFromApi)) {
|
||||||
|
return `${time || '--'} ${nameFromApi}代建`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const creatorId = normalizeUserId(
|
||||||
|
record.value?.creator ||
|
||||||
|
record.value?.creatorUserId ||
|
||||||
|
record.value?.createUserId ||
|
||||||
|
record.value?.executor ||
|
||||||
|
record.value?.executorUserId ||
|
||||||
|
''
|
||||||
|
);
|
||||||
|
const fallbackId = !creatorId && nameFromApi && isLikelyUserId(nameFromApi) ? nameFromApi : '';
|
||||||
|
const display = (creatorId || fallbackId) ? resolveUserName(creatorId || fallbackId) : '';
|
||||||
|
const suffix = display ? `${display}代建` : '';
|
||||||
return suffix ? `${time || '--'} ${suffix}` : `${time || '--'}`;
|
return suffix ? `${time || '--'} ${suffix}` : `${time || '--'}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -352,6 +438,10 @@ onLoad(async (opt) => {
|
|||||||
setTimeout(() => uni.navigateBack(), 300);
|
setTimeout(() => uni.navigateBack(), 300);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 异步加载团队成员映射,用于展示“xx代建”的真实姓名
|
||||||
|
void loadTeamMembers();
|
||||||
|
|
||||||
const ok = await fetchRecord();
|
const ok = await fetchRecord();
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
toast('记录不存在');
|
toast('记录不存在');
|
||||||
@ -470,6 +560,8 @@ function remove() {
|
|||||||
color: #111827;
|
color: #111827;
|
||||||
line-height: 40rpx;
|
line-height: 40rpx;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
|
word-break: break-all;
|
||||||
|
word-wrap: break-word;
|
||||||
}
|
}
|
||||||
.files {
|
.files {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user