feat: 更新患者创建时间和操作信息显示逻辑
This commit is contained in:
parent
6b31ad9067
commit
f00383034d
@ -592,7 +592,9 @@ const createText = computed(() => {
|
|||||||
const creatorId = ['-', '—', '--'].includes(rawCreator.trim()) ? '' : rawCreator.trim();
|
const creatorId = ['-', '—', '--'].includes(rawCreator.trim()) ? '' : rawCreator.trim();
|
||||||
const creatorName = creatorId ? resolveUserName(creatorId) : '';
|
const creatorName = creatorId ? resolveUserName(creatorId) : '';
|
||||||
if (time && creatorName) return `${time} ${creatorName}创建`;
|
if (time && creatorName) return `${time} ${creatorName}创建`;
|
||||||
|
if (time && !rawCreator.trim()) return `${time} 患者创建`;
|
||||||
if (time) return `${time} 创建`;
|
if (time) return `${time} 创建`;
|
||||||
|
if (!rawCreator.trim()) return '患者创建';
|
||||||
return '';
|
return '';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
<view class="manage-container">
|
<view class="manage-container">
|
||||||
<view class="group-list">
|
<view class="group-list">
|
||||||
<scroll-view scroll-y class="sort-scroll">
|
<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
|
<movable-view
|
||||||
v-for="(item, index) in groups"
|
v-for="(item, index) in groups"
|
||||||
:key="item._id"
|
:key="item._id"
|
||||||
@ -81,7 +81,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from 'vue';
|
import { ref, computed, nextTick } from 'vue';
|
||||||
import { onLoad } from '@dcloudio/uni-app';
|
import { onLoad } from '@dcloudio/uni-app';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import api from '@/utils/api';
|
import api from '@/utils/api';
|
||||||
@ -91,6 +91,8 @@ import { hideLoading, loading, toast } from '@/utils/widget';
|
|||||||
// State
|
// State
|
||||||
const groups = ref([]);
|
const groups = ref([]);
|
||||||
const originalGroups = ref([]);
|
const originalGroups = ref([]);
|
||||||
|
const areaKey = ref(0);
|
||||||
|
const loadSeq = ref(0);
|
||||||
|
|
||||||
const ITEM_HEIGHT = 74; // px,需与样式保持一致
|
const ITEM_HEIGHT = 74; // px,需与样式保持一致
|
||||||
const draggingId = ref('');
|
const draggingId = ref('');
|
||||||
@ -151,6 +153,7 @@ async function ensureDoctor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function loadGroups() {
|
async function loadGroups() {
|
||||||
|
const seq = (loadSeq.value += 1);
|
||||||
await ensureDoctor();
|
await ensureDoctor();
|
||||||
const corpId = getCorpId();
|
const corpId = getCorpId();
|
||||||
const teamId = getTeamId();
|
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 list = Array.isArray(res.data) ? res.data : Array.isArray(res.data?.data) ? res.data.data : [];
|
||||||
const sorted = sortGroupList(list);
|
const sorted = sortGroupList(list);
|
||||||
groups.value = sorted.map((i, idx) => ({ ...i, _y: idx * ITEM_HEIGHT }));
|
if (seq !== loadSeq.value) return;
|
||||||
originalGroups.value = sorted.map((i, idx) => ({ ...i, _y: idx * ITEM_HEIGHT }));
|
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);
|
lastSavedOrderKey.value = getOrderKey(groups.value);
|
||||||
|
areaKey.value += 1;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toast('获取分组失败');
|
toast('获取分组失败');
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@ -80,8 +80,7 @@
|
|||||||
<view class="card-row-bottom">
|
<view class="card-row-bottom">
|
||||||
<template v-if="currentTabKey === 'new'"> <!-- New Patient Tab -->
|
<template v-if="currentTabKey === 'new'"> <!-- New Patient Tab -->
|
||||||
<text class="record-text">
|
<text class="record-text">
|
||||||
{{ patient.createTime || '-' }} {{ resolveCreatorName(patient) ? resolveCreatorName(patient) +
|
{{ resolveRecentAddTime(patient) }} {{ resolveRecentAddMeta(patient) }}
|
||||||
'创建' : '-' }}
|
|
||||||
</text>
|
</text>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
@ -264,6 +263,32 @@ function resolveCreatorName(patient) {
|
|||||||
return userNameMap.value[val] || val;
|
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) {
|
function applyVerifyStatus(status, reason) {
|
||||||
verifyStatus.value = status || '';
|
verifyStatus.value = status || '';
|
||||||
@ -382,6 +407,14 @@ function formatPatient(raw) {
|
|||||||
const createTimeStr = createTime ? createTime.format('YYYY-MM-DD HH:mm') : '';
|
const createTimeStr = createTime ? createTime.format('YYYY-MM-DD HH:mm') : '';
|
||||||
const createTimeTs = createTime ? createTime.valueOf() : 0;
|
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(标签名称数组)
|
// 优先使用后端返回的 tagNames(标签名称数组)
|
||||||
const rawTagNames = asArray(raw?.tagNames).filter((i) => typeof i === 'string' && i.trim());
|
const rawTagNames = asArray(raw?.tagNames).filter((i) => typeof i === 'string' && i.trim());
|
||||||
// 其次使用 tags(如果是字符串数组)
|
// 其次使用 tags(如果是字符串数组)
|
||||||
@ -420,6 +453,10 @@ function formatPatient(raw) {
|
|||||||
mobile,
|
mobile,
|
||||||
createTime: createTimeStr,
|
createTime: createTimeStr,
|
||||||
createTimeTs,
|
createTimeTs,
|
||||||
|
recentAddTime: recentAddTimeStr,
|
||||||
|
recentAddTimeTs,
|
||||||
|
recentAddType,
|
||||||
|
recentAddOperatorUserId,
|
||||||
creator: raw?.creatorName || raw?.creator || '',
|
creator: raw?.creatorName || raw?.creator || '',
|
||||||
hospitalId: raw?.customerNumber || raw?.hospitalId || '',
|
hospitalId: raw?.customerNumber || raw?.hospitalId || '',
|
||||||
record,
|
record,
|
||||||
@ -510,8 +547,10 @@ async function reload(reset = true) {
|
|||||||
} else if (currentTab.value.kind === 'new') {
|
} else if (currentTab.value.kind === 'new') {
|
||||||
const start = dayjs().subtract(7, 'day').startOf('day').valueOf();
|
const start = dayjs().subtract(7, 'day').startOf('day').valueOf();
|
||||||
const end = dayjs().endOf('day').valueOf();
|
const end = dayjs().endOf('day').valueOf();
|
||||||
query.startCreateTime = start;
|
// “新患者”= 最近7天新增到当前团队:创建 + 转移/共享(时间来自服务记录)
|
||||||
query.endCreateTime = end;
|
query.startRecentTime = start;
|
||||||
|
query.endRecentTime = end;
|
||||||
|
query.includeRecentAddTime = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
@ -578,9 +617,13 @@ const patientList = computed(() => {
|
|||||||
if (currentTab.value.kind === 'new') {
|
if (currentTab.value.kind === 'new') {
|
||||||
const sevenDaysAgo = dayjs().subtract(7, 'day').startOf('day').valueOf();
|
const sevenDaysAgo = dayjs().subtract(7, 'day').startOf('day').valueOf();
|
||||||
const flatList = all
|
const flatList = all
|
||||||
.filter((p) => Number(p?.createTimeTs || 0) >= sevenDaysAgo)
|
.filter((p) => Number(p?.recentAddTimeTs || p?.createTimeTs || 0) >= sevenDaysAgo)
|
||||||
.slice()
|
.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 }];
|
return [{ letter: '最近7天新增', data: flatList }];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -596,6 +639,7 @@ const indexList = computed(() => {
|
|||||||
const totalPatients = computed(() => {
|
const totalPatients = computed(() => {
|
||||||
let count = 0;
|
let count = 0;
|
||||||
patientList.value.forEach(g => count += g.data.length);
|
patientList.value.forEach(g => count += g.data.length);
|
||||||
|
if (currentTab.value.kind === 'new') return count;
|
||||||
return totalFromApi.value || count;
|
return totalFromApi.value || count;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user