9.4上午提交
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
|
||||
<!-- 列表 -->
|
||||
<scroll-view class="list" scroll-y>
|
||||
<view class="item" @click="toggle(p.uuid)" v-for="p in patientList" :key="p.uuid">
|
||||
<view class="item" @click="toggle(p.uuid)" v-for="p in availablePatientList" :key="p.uuid">
|
||||
<image class="avatar" :src="docUrl + (p.photo || '')" mode="aspectFill" />
|
||||
<view class="name">{{ p.realName || '-' }}</view>
|
||||
<view class="check" >
|
||||
@@ -50,6 +50,11 @@
|
||||
const selectedIds = ref([])
|
||||
const patientList = ref([])
|
||||
const selectedDetail = ref([])
|
||||
|
||||
// 计算属性:显示所有患者,但标记已选中的状态
|
||||
const availablePatientList = computed(() => {
|
||||
return patientList.value
|
||||
})
|
||||
const patientListByGBK = async () => {
|
||||
|
||||
const res = await api.patientListByGBK();
|
||||
@@ -61,27 +66,47 @@
|
||||
|
||||
};
|
||||
onLoad(() => {
|
||||
|
||||
// 读取已选中的成员ID
|
||||
try {
|
||||
const preSelected = uni.getStorageSync('preSelectedIds')
|
||||
if (Array.isArray(preSelected)) {
|
||||
selectedIds.value = [...preSelected]
|
||||
// 清理缓存
|
||||
uni.removeStorageSync('preSelectedIds')
|
||||
}
|
||||
} catch (e) {}
|
||||
})
|
||||
onShow(() => {
|
||||
patientListByGBK();
|
||||
// 根据已选中的ID更新selectedDetail
|
||||
updateSelectedDetail();
|
||||
});
|
||||
|
||||
|
||||
|
||||
// 根据已选中的ID更新selectedDetail
|
||||
const updateSelectedDetail = () => {
|
||||
selectedDetail.value = selectedIds.value.map(id => {
|
||||
const p = patientList.value.find(x => x.uuid === id)
|
||||
return { uuid: id, realName: p?.realName || '', photo: p?.photo || '' }
|
||||
})
|
||||
}
|
||||
|
||||
const toggle = (id) => {
|
||||
const i = selectedIds.value.indexOf(id)
|
||||
if (i > -1) {
|
||||
// 如果已选中,则取消选中
|
||||
selectedIds.value.splice(i, 1)
|
||||
const di = selectedDetail.value.findIndex(it => it.uuid === id)
|
||||
if (di > -1) selectedDetail.value.splice(di, 1)
|
||||
} else {
|
||||
// 如果未选中,则选中
|
||||
selectedIds.value.push(id)
|
||||
const p = patientList.value.find(x => x.uuid === id)
|
||||
selectedDetail.value.push({ uuid: id, realName: p?.realName || '', photo: p?.photo || '' })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const onSearch = () => {}
|
||||
const goBack = () => uni.navigateBack()
|
||||
const confirmSelect = () => {
|
||||
|
||||
Reference in New Issue
Block a user