分组数据较多时
This commit is contained in:
parent
1e99b3a082
commit
e8e9c84cdf
@ -2,8 +2,8 @@
|
||||
"name" : "肝胆相照专家版",
|
||||
"appid" : "__UNI__89F511F",
|
||||
"description" : "",
|
||||
"versionName" : "4.2.4",
|
||||
"versionCode" : 424,
|
||||
"versionName" : "4.2.5",
|
||||
"versionCode" : 425,
|
||||
"transformPx" : false,
|
||||
"app-plus" : {
|
||||
/* 5+App特有相关 */
|
||||
|
||||
@ -1686,7 +1686,7 @@
|
||||
"list": [
|
||||
{
|
||||
"name": "",
|
||||
"path": "/pages_app/idcardAuth/bankCardList",
|
||||
"path": "pages_app/patientMsg/patientMsg",
|
||||
"query": ""
|
||||
}
|
||||
]
|
||||
|
||||
@ -99,7 +99,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
import { ref, computed, onMounted,nextTick } from 'vue';
|
||||
import { onShow,onBackPress,onLoad } from "@dcloudio/uni-app";
|
||||
import upImg from "@/static/triangle_green_theme.png"
|
||||
import downImg from "@/static/triangle_normal.png"
|
||||
@ -166,8 +166,9 @@ const fetchGroupList = async () => {
|
||||
openGroups.value = {};
|
||||
groupRenderCount.value = {};
|
||||
groups.value.forEach((_, idx) => openGroups.value[idx] = false);
|
||||
|
||||
uni.hideLoading();
|
||||
nextTick(() => {
|
||||
uni.hideLoading();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -100,7 +100,7 @@
|
||||
|
||||
<view class="listbox">
|
||||
<!-- 使用 up-index-list 索引组件,数据动态渲染 -->
|
||||
<up-index-list :index-list="indexList" v-if="loadFinish" >
|
||||
<up-index-list :index-list="indexList" v-show="loadFinish" >
|
||||
|
||||
<!-- 特殊操作项 -->
|
||||
<template #header>
|
||||
@ -140,7 +140,7 @@
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
<image class="patient-avatar" :src="docUrl+item.photo" mode="aspectFill" @click="goPatientDetail(item.uuid)"></image>
|
||||
<image class="patient-avatar" :src="item.avatarUrl" mode="aspectFill" @click="goPatientDetail(item.uuid)"></image>
|
||||
</template>
|
||||
<view class="patient-info" @click="goPatientDetail(item.uuid)">
|
||||
<text class="patient-name">{{ item.realName }}</text>
|
||||
@ -150,7 +150,7 @@
|
||||
</view>
|
||||
<view class="patient-status">
|
||||
<uni-icons type="compose" size="20" color="#8B2316" @click.stop="editPatient(item.uuid)"></uni-icons>
|
||||
<text class="follow-date">随访于{{ formatYMD(item.join_date) }}</text>
|
||||
<text class="follow-date">随访于{{ item.joinDateYMD }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -248,14 +248,17 @@
|
||||
|
||||
|
||||
<script setup>
|
||||
import { ref, getCurrentInstance, computed } from 'vue';
|
||||
import { ref, getCurrentInstance, computed, nextTick, shallowRef } from 'vue';
|
||||
import { onShow,onLoad,onBackPress} from "@dcloudio/uni-app";
|
||||
import dayImg from "@/static/visit_data11.png"
|
||||
import planImg from "@/static/visitplan.png"
|
||||
import api from '@/api/api.js';
|
||||
import navTo from '@/utils/navTo.js';
|
||||
import docUrl from '@/utils/docUrl.js';
|
||||
const patientList = ref([]);
|
||||
const patientList = ref([]);
|
||||
const patientDataLoaded = ref(false);
|
||||
const patientDataLoading = ref(false);
|
||||
const firstLetterCache = new Map();
|
||||
const navHeight = ref(40);
|
||||
onBackPress(() => {
|
||||
plus.runtime.quit();
|
||||
@ -302,7 +305,7 @@
|
||||
const d = dayjs(input);
|
||||
return d.isValid() ? d.format('YYYY年MM月') : '';
|
||||
}
|
||||
// 格式化显示日(如:03)
|
||||
// 格式化显示日(如:03)
|
||||
const formatDay = (input) => {
|
||||
if (!input) return '';
|
||||
const d = dayjs(input);
|
||||
@ -348,7 +351,7 @@
|
||||
};
|
||||
|
||||
// 分组数据(可从接口返回后赋值)
|
||||
const patientGroups = ref([]);
|
||||
const patientGroups = shallowRef([]);
|
||||
|
||||
// 重建索引时保持固定 A-Z
|
||||
const rebuildIndexList = () => {
|
||||
@ -359,36 +362,48 @@
|
||||
// 生成模拟数据
|
||||
// 工具:获取首字母
|
||||
const generateMockDate = () => '';
|
||||
const getFirstLetter = (chineseName) => {
|
||||
// 假设名字由一个或多个汉字组成,我们取第一个汉字的首字母
|
||||
const firstChar = chineseName.charAt(0); // 获取第一个汉字
|
||||
const pinyinArray = pinyin(firstChar, { style: pinyin.STYLE_NORMAL }); // 获取拼音数组
|
||||
return pinyinArray[0][0].charAt(0); // 返回拼音的第一个字母
|
||||
}
|
||||
const getFirstLetter = (name = '') => {
|
||||
const firstChar = String(name).trim().charAt(0);
|
||||
if (!firstChar) return '#';
|
||||
if (/^[A-Za-z]$/.test(firstChar)) return firstChar.toUpperCase();
|
||||
if (firstLetterCache.has(firstChar)) {
|
||||
return firstLetterCache.get(firstChar);
|
||||
}
|
||||
try {
|
||||
const pinyinArray = pinyin(firstChar, { style: pinyin.STYLE_NORMAL });
|
||||
const py = pinyinArray?.[0]?.[0] || '';
|
||||
const letter = py ? py.charAt(0).toUpperCase() : '#';
|
||||
firstLetterCache.set(firstChar, letter);
|
||||
return letter;
|
||||
} catch (error) {
|
||||
return '#';
|
||||
}
|
||||
}
|
||||
// 根据 patientList 构建按拼音首字母的分组
|
||||
const buildGroupsFromPatients = () => {
|
||||
|
||||
const map = new Map();
|
||||
patientList.value.forEach((p) => {
|
||||
const name = p.realName;
|
||||
const first = name?getFirstLetter(name).toUpperCase():'#';
|
||||
|
||||
const source = patientList.value || [];
|
||||
for (let i = 0; i < source.length; i++) {
|
||||
const p = source[i] || {};
|
||||
const normalized = {
|
||||
...p,
|
||||
avatarUrl: p.photo ? `${docUrl}${p.photo}` : '',
|
||||
joinDateYMD: formatYMD(p.join_date)
|
||||
};
|
||||
const first = getFirstLetter(normalized.realName || '');
|
||||
const letter = /^[A-Z]$/.test(first) ? first : '#';
|
||||
if (!map.has(letter)) map.set(letter, []);
|
||||
map.get(letter).push(p);
|
||||
});
|
||||
map.get(letter).push(normalized);
|
||||
}
|
||||
const letters = Array.from(map.keys()).sort((a,b) => a.localeCompare(b));
|
||||
patientGroups.value = letters.map(l => ({ letter: l, items: map.get(l) }));
|
||||
rebuildIndexList();
|
||||
if(patientList.value.length > 4000){
|
||||
loadFinish.value = true;
|
||||
nextTick(() => {
|
||||
setTimeout(() => {
|
||||
uni.hideLoading();
|
||||
|
||||
}, 10000);
|
||||
}else{
|
||||
uni.hideLoading();
|
||||
loadFinish.value = true;
|
||||
}
|
||||
},1000);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@ -469,14 +484,21 @@
|
||||
}
|
||||
};
|
||||
const patientListByGBK = async () => {
|
||||
|
||||
const res = await api.patientListByGBK();
|
||||
if(res.code == 1){
|
||||
patientList.value = res.data;
|
||||
|
||||
buildGroupsFromPatients()
|
||||
if (patientDataLoading.value) return;
|
||||
patientDataLoading.value = true;
|
||||
try {
|
||||
const res = await api.patientListByGBK();
|
||||
if(res.code == 1){
|
||||
loadFinish.value = true;
|
||||
patientList.value = res.data || [];
|
||||
buildGroupsFromPatients();
|
||||
patientDataLoaded.value = true;
|
||||
} else {
|
||||
uni.hideLoading();
|
||||
}
|
||||
} finally {
|
||||
patientDataLoading.value = false;
|
||||
}
|
||||
|
||||
};
|
||||
const page=ref(1)
|
||||
const followUpList = ref([]);
|
||||
@ -594,12 +616,16 @@
|
||||
// title.value = '患者消息';
|
||||
break;
|
||||
case 'list':
|
||||
uni.showLoading({
|
||||
title: '加载中...',
|
||||
mask: true
|
||||
});
|
||||
patientListByGBK();
|
||||
title.value = '患者列表';
|
||||
title.value = '患者列表';
|
||||
if (patientDataLoaded.value) {
|
||||
loadFinish.value = true;
|
||||
break;
|
||||
}
|
||||
uni.showLoading({
|
||||
title: '加载中...',
|
||||
mask: true
|
||||
});
|
||||
patientListByGBK();
|
||||
// 显示患者列表
|
||||
break;
|
||||
case 'plan':
|
||||
@ -1232,4 +1258,4 @@
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
</style>
|
||||
@ -42,7 +42,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import { ref, computed,nextTick} from 'vue'
|
||||
import docUrl from '@/utils/docUrl.js'
|
||||
import { onShow,onLoad} from "@dcloudio/uni-app";
|
||||
import api from '@/api/api.js'
|
||||
@ -63,13 +63,16 @@
|
||||
if(res.code == 1){
|
||||
patientList.value = res.data;
|
||||
availablePatientList.value = res.data;
|
||||
if(res.data.length > 1000){
|
||||
setTimeout(() => {
|
||||
uni.hideLoading();
|
||||
}, 5000);
|
||||
}else{
|
||||
nextTick(() => {
|
||||
uni.hideLoading();
|
||||
}
|
||||
});
|
||||
// if(res.data.length > 1000){
|
||||
// setTimeout(() => {
|
||||
// uni.hideLoading();
|
||||
// }, 5000);
|
||||
// }else{
|
||||
// uni.hideLoading();
|
||||
// }
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@ -42,7 +42,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import { ref, computed,nextTick } from 'vue'
|
||||
import docUrl from '@/utils/docUrl.js'
|
||||
import { onShow,onLoad} from "@dcloudio/uni-app";
|
||||
import api from '@/api/api.js'
|
||||
@ -62,13 +62,16 @@
|
||||
if(res.code == 1){
|
||||
patientList.value = res.data;
|
||||
availablePatientList.value = res.data;
|
||||
if(res.data.length > 1000){
|
||||
setTimeout(() => {
|
||||
uni.hideLoading();
|
||||
}, 5000);
|
||||
}else{
|
||||
nextTick(() => {
|
||||
uni.hideLoading();
|
||||
}
|
||||
});
|
||||
// if(res.data.length > 1000){
|
||||
// setTimeout(() => {
|
||||
// uni.hideLoading();
|
||||
// }, 5000);
|
||||
// }else{
|
||||
// uni.hideLoading();
|
||||
// }
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user