fix:显示错误
This commit is contained in:
parent
2fc385f994
commit
173b3ceb2e
@ -45,7 +45,7 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="body">
|
<view class="body">
|
||||||
<view class="content" :class="{ clamp: !expandMap[i._id] }">
|
<view class="content" :class="{ clamp: !expandMap[i._id] }">
|
||||||
{{ i.taskContentDisplay || '暂无内容' }}
|
{{ displayTaskContent(i) || '暂无内容' }}
|
||||||
</view>
|
</view>
|
||||||
<image class="pen" src="/static/icons/icon-pen.svg" @click.stop="edit(i)" />
|
<image class="pen" src="/static/icons/icon-pen.svg" @click.stop="edit(i)" />
|
||||||
</view>
|
</view>
|
||||||
@ -152,9 +152,33 @@ function resolveUserName(userId) {
|
|||||||
return String(map[id] || '') || id;
|
return String(map[id] || '') || id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function escapeRegExp(str) {
|
||||||
|
return String(str).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||||
|
}
|
||||||
|
|
||||||
|
function replaceKnownUserIds(text) {
|
||||||
|
const map = userNameMap.value || {};
|
||||||
|
const ids = Object.keys(map);
|
||||||
|
if (!ids.length) return text;
|
||||||
|
|
||||||
|
let out = text;
|
||||||
|
ids.forEach((id) => {
|
||||||
|
const name = String(map[id] || '');
|
||||||
|
if (!id || !name || name === id) return;
|
||||||
|
const re = new RegExp(`(^|[^0-9A-Za-z_])(${escapeRegExp(id)})(?=[^0-9A-Za-z_]|$)`, 'g');
|
||||||
|
out = out.replace(re, (_, p1) => `${p1}${name}`);
|
||||||
|
});
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
function formatTaskContent(text) {
|
function formatTaskContent(text) {
|
||||||
if (typeof text !== 'string') return '';
|
if (typeof text !== 'string') return '';
|
||||||
return text.replace(/&&&([^&]+)&&&/g, (_, id) => resolveUserName(id)).trim();
|
const withPlaceholders = text.replace(/&&&([^&]+)&&&/g, (_, id) => resolveUserName(id));
|
||||||
|
return replaceKnownUserIds(withPlaceholders).trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
function displayTaskContent(r) {
|
||||||
|
return formatTaskContent(String(r?.taskContent || ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadTeamMembers(teamId) {
|
async function loadTeamMembers(teamId) {
|
||||||
@ -196,7 +220,6 @@ function mapRow(i) {
|
|||||||
fileType,
|
fileType,
|
||||||
timeStr: i.executionTime ? dayjs(i.executionTime).format('YYYY-MM-DD HH:mm') : '--',
|
timeStr: i.executionTime ? dayjs(i.executionTime).format('YYYY-MM-DD HH:mm') : '--',
|
||||||
typeStr: getServiceTypeLabel(i.eventType),
|
typeStr: getServiceTypeLabel(i.eventType),
|
||||||
taskContentDisplay: formatTaskContent(String(i?.taskContent || '')),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -217,9 +217,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, getCurrentInstance, ref } from 'vue';
|
import { computed, getCurrentInstance, nextTick, ref } from 'vue';
|
||||||
import { onLoad, onPullDownRefresh, onReachBottom, onReady, onShow } from '@dcloudio/uni-app';
|
import { onLoad, onPullDownRefresh, onReachBottom, onReady, onShow } from '@dcloudio/uni-app';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
import HealthProfileTab from '@/components/archive-detail/health-profile-tab.vue';
|
import HealthProfileTab from '@/components/archive-detail/health-profile-tab.vue';
|
||||||
import ServiceInfoTab from '@/components/archive-detail/service-info-tab.vue';
|
import ServiceInfoTab from '@/components/archive-detail/service-info-tab.vue';
|
||||||
@ -246,8 +247,14 @@ const instanceProxy = getCurrentInstance()?.proxy;
|
|||||||
|
|
||||||
function switchTab(key) {
|
function switchTab(key) {
|
||||||
currentTab.value = key;
|
currentTab.value = key;
|
||||||
// 切换 tab 后,将页面滚动到顶部,确保 tab 吸顶可见
|
// 切换 tab 后,将 tab 滚动到页面顶部(隐藏头部信息区域)
|
||||||
uni.pageScrollTo({ scrollTop: 0, duration: 0 });
|
nextTick(() => {
|
||||||
|
// tabs 高度可能随数据变化,先测量一次再滚动
|
||||||
|
measureTabsTop();
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.pageScrollTo({ scrollTop: tabsScrollTop.value || 0, duration: 0 });
|
||||||
|
}, 0);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const archive = ref({
|
const archive = ref({
|
||||||
@ -326,7 +333,10 @@ async function fetchArchive() {
|
|||||||
}
|
}
|
||||||
archive.value = { ...archive.value, ...normalizeArchiveFromApi(res.data) };
|
archive.value = { ...archive.value, ...normalizeArchiveFromApi(res.data) };
|
||||||
saveToStorage();
|
saveToStorage();
|
||||||
|
loadTeamMembers();
|
||||||
await fetchTeamGroups(true);
|
await fetchTeamGroups(true);
|
||||||
|
// 档案信息刷新后,tabs 的位置可能变化,重新测量
|
||||||
|
nextTick(() => setTimeout(measureTabsTop, 30));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toast('获取档案失败');
|
toast('获取档案失败');
|
||||||
} finally {
|
} finally {
|
||||||
@ -334,6 +344,46 @@ async function fetchArchive() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const userNameMap = ref({});
|
||||||
|
async function loadTeamMembers() {
|
||||||
|
const corpId = getCorpId();
|
||||||
|
const team = uni.getStorageSync(CURRENT_TEAM_STORAGE_KEY) || {};
|
||||||
|
const teamId = team?.teamId ? String(team.teamId) : '';
|
||||||
|
if (!corpId || !teamId) return;
|
||||||
|
if (Object.keys(userNameMap.value || {}).length > 0) return;
|
||||||
|
|
||||||
|
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 : [];
|
||||||
|
userNameMap.value = members.reduce((acc, m) => {
|
||||||
|
const uid = String(m?.userid || '');
|
||||||
|
if (!uid) return acc;
|
||||||
|
acc[uid] = String(m?.anotherName || m?.name || m?.userid || '') || uid;
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveUserName(userId) {
|
||||||
|
const id = String(userId || '');
|
||||||
|
if (!id) return '';
|
||||||
|
const map = userNameMap.value || {};
|
||||||
|
return String(map[id] || '') || '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatCreateTime(v) {
|
||||||
|
if (v === null || v === undefined) return '';
|
||||||
|
const raw = typeof v === 'number' ? v : typeof v === 'string' ? v.trim() : '';
|
||||||
|
const ms =
|
||||||
|
typeof raw === 'number'
|
||||||
|
? raw
|
||||||
|
: raw && /^\d{10,13}$/.test(raw)
|
||||||
|
? Number(raw.length === 10 ? `${raw}000` : raw)
|
||||||
|
: null;
|
||||||
|
const d = ms !== null ? dayjs(ms) : dayjs(raw);
|
||||||
|
return d.isValid() ? d.format('YYYY-MM-DD HH:mm') : '';
|
||||||
|
}
|
||||||
|
|
||||||
const teamGroups = ref([]);
|
const teamGroups = ref([]);
|
||||||
const groupNameMap = computed(() => {
|
const groupNameMap = computed(() => {
|
||||||
const map = new Map();
|
const map = new Map();
|
||||||
@ -505,10 +555,11 @@ const idRows = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const createText = computed(() => {
|
const createText = computed(() => {
|
||||||
const time = archive.value.createTime ? String(archive.value.createTime) : '';
|
const time = formatCreateTime(archive.value.createTime);
|
||||||
const rawCreator = archive.value.creator ? String(archive.value.creator) : '';
|
const rawCreator = archive.value.creator ? String(archive.value.creator) : '';
|
||||||
const creator = ['-', '—', '--'].includes(rawCreator.trim()) ? '' : rawCreator.trim();
|
const creatorId = ['-', '—', '--'].includes(rawCreator.trim()) ? '' : rawCreator.trim();
|
||||||
if (time && creator) return `${time} ${creator}创建`;
|
const creatorName = creatorId ? resolveUserName(creatorId) : '';
|
||||||
|
if (time && creatorName) return `${time} ${creatorName}创建`;
|
||||||
if (time) return `${time} 创建`;
|
if (time) return `${time} 创建`;
|
||||||
return '';
|
return '';
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user