feat: 更新患者创建时间和操作信息显示逻辑

This commit is contained in:
Jafeng 2026-02-09 14:20:42 +08:00
parent 6b31ad9067
commit f00383034d
3 changed files with 67 additions and 10 deletions

View File

@ -592,7 +592,9 @@ const createText = computed(() => {
const creatorId = ['-', '—', '--'].includes(rawCreator.trim()) ? '' : rawCreator.trim();
const creatorName = creatorId ? resolveUserName(creatorId) : '';
if (time && creatorName) return `${time} ${creatorName}创建`;
if (time && !rawCreator.trim()) return `${time} 患者创建`;
if (time) return `${time} 创建`;
if (!rawCreator.trim()) return '患者创建';
return '';
});

View File

@ -2,7 +2,7 @@
<view class="manage-container">
<view class="group-list">
<scroll-view scroll-y class="sort-scroll">
<movable-area class="drag-area" :style="{ height: dragAreaHeight + 'px' }">
<movable-area :key="areaKey" class="drag-area" :style="{ height: dragAreaHeight + 'px' }">
<movable-view
v-for="(item, index) in groups"
:key="item._id"
@ -81,7 +81,7 @@
</template>
<script setup>
import { ref, computed } from 'vue';
import { ref, computed, nextTick } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import { storeToRefs } from 'pinia';
import api from '@/utils/api';
@ -91,6 +91,8 @@ import { hideLoading, loading, toast } from '@/utils/widget';
// State
const groups = ref([]);
const originalGroups = ref([]);
const areaKey = ref(0);
const loadSeq = ref(0);
const ITEM_HEIGHT = 74; // px
const draggingId = ref('');
@ -151,6 +153,7 @@ async function ensureDoctor() {
}
async function loadGroups() {
const seq = (loadSeq.value += 1);
await ensureDoctor();
const corpId = getCorpId();
const teamId = getTeamId();
@ -166,9 +169,17 @@ async function loadGroups() {
}
const list = Array.isArray(res.data) ? res.data : Array.isArray(res.data?.data) ? res.data.data : [];
const sorted = sortGroupList(list);
groups.value = sorted.map((i, idx) => ({ ...i, _y: idx * ITEM_HEIGHT }));
originalGroups.value = sorted.map((i, idx) => ({ ...i, _y: idx * ITEM_HEIGHT }));
if (seq !== loadSeq.value) return;
const next = sorted.map((i, idx) => ({ ...i, _y: idx * ITEM_HEIGHT }));
// movable-view key movable-area
groups.value = [];
await nextTick();
if (seq !== loadSeq.value) return;
groups.value = next;
originalGroups.value = next.map((i) => ({ ...i }));
lastSavedOrderKey.value = getOrderKey(groups.value);
areaKey.value += 1;
} catch (e) {
toast('获取分组失败');
} finally {

View File

@ -80,8 +80,7 @@
<view class="card-row-bottom">
<template v-if="currentTabKey === 'new'"> <!-- New Patient Tab -->
<text class="record-text">
{{ patient.createTime || '-' }} {{ resolveCreatorName(patient) ? resolveCreatorName(patient) +
'创建' : '-' }}
{{ resolveRecentAddTime(patient) }} {{ resolveRecentAddMeta(patient) }}
</text>
</template>
<template v-else>
@ -264,6 +263,32 @@ function resolveCreatorName(patient) {
return userNameMap.value[val] || val;
}
function resolveRecentAddTime(patient) {
return patient?.recentAddTime || patient?.createTime || '-';
}
function resolveRecentAddOperatorName(patient) {
const uid = patient?.recentAddOperatorUserId || patient?.creator || '';
if (!uid) return '';
return userNameMap.value[uid] || uid;
}
function resolveRecentAddAction(patient) {
const t = String(patient?.recentAddType || '').trim();
if (!t || t === 'create') return '创建';
if (t === 'share') return '共享';
if (t.startsWith('transfer')) return '转移';
return '创建';
}
function resolveRecentAddMeta(patient) {
const name = resolveRecentAddOperatorName(patient);
const action = resolveRecentAddAction(patient);
if (name) return `${name}${action}`;
if (action === '创建') return '患者创建';
return '-';
}
function applyVerifyStatus(status, reason) {
verifyStatus.value = status || '';
@ -382,6 +407,14 @@ function formatPatient(raw) {
const createTimeStr = createTime ? createTime.format('YYYY-MM-DD HH:mm') : '';
const createTimeTs = createTime ? createTime.valueOf() : 0;
// //退 createTime
const recentAddTimeRaw = raw?.recentAddTime ?? raw?.recentAddAt ?? raw?.recentTime;
const recentAddTime = parseCreateTime(recentAddTimeRaw) || createTime;
const recentAddTimeStr = recentAddTime ? recentAddTime.format('YYYY-MM-DD HH:mm') : '';
const recentAddTimeTs = recentAddTime ? recentAddTime.valueOf() : 0;
const recentAddType = String(raw?.recentAddType || (recentAddTimeRaw ? '' : 'create') || '');
const recentAddOperatorUserId = String(raw?.recentAddOperatorUserId || raw?.recentAddOperator || raw?.creator || '');
// 使 tagNames
const rawTagNames = asArray(raw?.tagNames).filter((i) => typeof i === 'string' && i.trim());
// 使 tags
@ -420,6 +453,10 @@ function formatPatient(raw) {
mobile,
createTime: createTimeStr,
createTimeTs,
recentAddTime: recentAddTimeStr,
recentAddTimeTs,
recentAddType,
recentAddOperatorUserId,
creator: raw?.creatorName || raw?.creator || '',
hospitalId: raw?.customerNumber || raw?.hospitalId || '',
record,
@ -510,8 +547,10 @@ async function reload(reset = true) {
} else if (currentTab.value.kind === 'new') {
const start = dayjs().subtract(7, 'day').startOf('day').valueOf();
const end = dayjs().endOf('day').valueOf();
query.startCreateTime = start;
query.endCreateTime = end;
// = 7 + /
query.startRecentTime = start;
query.endRecentTime = end;
query.includeRecentAddTime = true;
}
loading.value = true;
@ -578,9 +617,13 @@ const patientList = computed(() => {
if (currentTab.value.kind === 'new') {
const sevenDaysAgo = dayjs().subtract(7, 'day').startOf('day').valueOf();
const flatList = all
.filter((p) => Number(p?.createTimeTs || 0) >= sevenDaysAgo)
.filter((p) => Number(p?.recentAddTimeTs || p?.createTimeTs || 0) >= sevenDaysAgo)
.slice()
.sort((a, b) => Number(b?.createTimeTs || 0) - Number(a?.createTimeTs || 0));
.sort(
(a, b) =>
Number(b?.recentAddTimeTs || b?.createTimeTs || 0) -
Number(a?.recentAddTimeTs || a?.createTimeTs || 0)
);
return [{ letter: '最近7天新增', data: flatList }];
}
@ -596,6 +639,7 @@ const indexList = computed(() => {
const totalPatients = computed(() => {
let count = 0;
patientList.value.forEach(g => count += g.data.length);
if (currentTab.value.kind === 'new') return count;
return totalFromApi.value || count;
});