9.4上午提交

This commit is contained in:
zoujiandong
2025-09-04 10:22:51 +08:00
parent b068fb00cc
commit e86f8e77a7
17 changed files with 1364 additions and 155 deletions
+113 -42
View File
@@ -2,7 +2,7 @@
<view class="group-edit-page">
<uni-nav-bar
left-icon="left"
title="编辑分组"
:title="groupUuid ? '编辑分组' : '新建分组'"
@clickLeft="goBack"
fixed
color="#8B2316"
@@ -11,7 +11,7 @@
backgroundColor="#eee"
>
<template #right>
<text class="save-text" @click="saveGroup">保存</text>
<view class="save-text" @click="saveGroup">保存</view>
</template>
</uni-nav-bar>
@@ -26,30 +26,35 @@
<!-- 分组成员 -->
<view class="section-header">分组成员</view>
<view class="add-member" @click="addMember">
<view class="add-circle">
<up-icon name="plus" size="34" color="#bfbfbf" />
</view>
<text class="add-text">添加组患者</text>
</view>
<view class="member-list">
<view class="member-item" v-for="(m, idx) in members" :key="m.uuid || idx">
<image class="avatar" :src="docUrl + (m.photo || '')" mode="aspectFill" />
<text class="member-name">{{ m.realName || '未知' }}</text>
<view class="remove-btn" @click="removeMember(idx)">
<view class="remove-circle">
<up-icon name="minus" color="#fff" size="28rpx" bold></up-icon>
</view>
<!-- 已选中的成员 -->
<view class="selected-members" v-if="members.length > 0">
<view class="selected-item" v-for="(m, idx) in members" :key="m.uuid || idx">
<image class="selected-avatar" :src="docUrl + (m.photo || '')" mode="aspectFill" />
<text class="selected-name">{{ m.realName || '未知' }}</text>
<view class="remove-selected" @click="removeMember(idx)">
<text class="remove-text">——</text>
<!-- <up-icon name="minus" size="43rpx" color="#fff" bold /> -->
</view>
</view>
</view>
<!-- 底部删除按钮 -->
<view class="bottom-danger">
<button class="danger-btn" @click="deleteGroup">删除分组</button>
<button class="danger-btn" @click="visible=true">删除分组</button>
</view>
<unidialog :visible="visible" :content="'删除分析组?'" @close="visible=false" @confirm="confirmDelete"></unidialog>
</view>
</template>
<script setup>
@@ -58,19 +63,24 @@
import navTo from '@/utils/navTo.js'
import docUrl from '@/utils/docUrl.js'
import delImg from "@/static/iv_delete.png"
import api from '@/api/api.js'
import unidialog from '@/components/dialog/dialog.vue'
const groupUuid = ref('')
const groupName = ref('')
const members = ref([])
const visible = ref(false)
const confirmDelete = () => {
deleteGroup();
}
onLoad((query) => {
groupUuid.value = query?.uuid || ''
console.log(query)
groupUuid.value = query?.uuid || '';
if(groupUuid.value){
patientListByGroup()
}
// TODO: 根据 uuid 拉取分组详情
// 预置示例
groupName.value = '看看'
members.value = [
{ uuid: 'u1', realName: '测试', photo: '' }
]
})
onShow(() => {
@@ -89,9 +99,17 @@
const saveGroup = () => {
// TODO: 调用保存接口: { uuid: groupUuid, name: groupName, members }
uni.showToast({ title: '已保存', icon: 'success' })
if(groupUuid.value){
groupUpdate()
}else{
groupAdd()
}
}
const addMember = () => {
// 传递已选中的成员ID到选择页面,让选择页面知道哪些已经选中
const selectedIds = members.value.map(m => m.uuid)
uni.setStorageSync('preSelectedIds', selectedIds)
// 跳转选择患者页并监听事件通道返回
uni.navigateTo({
url: '/pages_app/selectPatient/selectPatient',
@@ -106,15 +124,49 @@
members.value.splice(idx, 1)
}
const deleteGroup = () => {
uni.showModal({
title: '删除分组',
content: '确定要删除该分组吗?',
success: (res) => {
if (res.confirm) {
// TODO: 调用删除接口
uni.showToast({ title: '已删除', icon: 'success' })
setTimeout(() => goBack(), 700)
}
api.groupDelete({
group_uuid: groupUuid.value
}).then(res => {
if(res.code == 200){
uni.showToast({ title: '删除成功', icon: 'none' })
setTimeout(() => goBack(), 700)
}
})
}
const groupAdd = () => {
if(!groupName.value){
uni.showToast({
title: '请输入分组名称',
icon: 'none'
})
return
}
api.groupAdd({
name: groupName.value,
patient_uuid: members.value.map(m => m.uuid).join(','),
}).then(res => {
if(res.code == 200){
uni.showToast({ title: '保存成功', icon: 'none' })
setTimeout(() => goBack(), 700)
}
})
}
const groupUpdate = () => {
if(!groupName.value){
uni.showToast({
title: '请输入分组名称',
icon: 'none'
})
return
}
api.groupUpdate({
uuid: groupUuid.value,
name: groupName.value,
patient_uuid: members.value.map(m => m.uuid).join(','),
}).then(res => {
if(res.code == 200){
uni.showToast({ title: '保存成功', icon: 'none' })
setTimeout(() => goBack(), 700)
}
})
}
@@ -129,6 +181,16 @@
}
})
}
const patientListByGroup = async () => {
const res = await api.patientListByGroup({
group_uuid: groupUuid.value,
list_sort:0
})
if(res.code == 200){
members.value = res.data.patient_list
groupName.value = res.data.group.name
}
}
</script>
<style lang="scss" scoped>
@@ -137,7 +199,16 @@
background: #f5f5f5;
padding-bottom: 160rpx;
}
.save-text{ color:#8B2316; font-size: 30rpx; }
.save-text{
background:#8B2316;
font-size: 30rpx;
display: flex;
align-items: center;
justify-content: center;
padding: 15rpx 25rpx;
color:#fff;
border-radius: 12rpx;
}
.section-header{
background:#d9d9d9;
@@ -160,6 +231,18 @@
.icon-btn{ padding-left: 20rpx; }
}
.selected-members{
background:#fff;
.selected-item{
display:flex; align-items:center; justify-content:space-between;
padding: 20rpx 30rpx; border-bottom: 1rpx solid #eee;
.selected-avatar{ width: 80rpx; height: 80rpx; border-radius: 12rpx; background:#ffe; }
.selected-name{ flex:1; margin-left: 20rpx; font-size: 30rpx; color:#333; }
.remove-selected{ width: 48rpx; height: 48rpx; border-radius: 50%; background:#8B2316; display:flex; align-items:center; justify-content:center; }
}
.remove-text{ font-size: 14rpx; color:#fff;font-weight: bold; }
}
.add-member{
background:#fff;
display:flex;
@@ -176,18 +259,6 @@
.add-text{ font-size: 32rpx; color:#666; }
}
.member-list{
background:#fff;
.member-item{
display:flex; align-items:center; justify-content:space-between;
padding: 26rpx 30rpx; border-bottom: 1rpx solid #eee;
.avatar{ width: 100rpx; height: 100rpx; border-radius: 16rpx; background:#ffe; }
.member-name{ flex:1; margin-left: 20rpx; font-size: 32rpx; color:#333; }
.remove-btn{ padding-left: 20rpx; }
.remove-circle{ width: 48rpx; height:48rpx; background:#8B2316; border-radius:50%; display:flex; align-items:center; justify-content:center; }
}
}
.bottom-danger{
position: fixed; left:30rpx; right:30rpx; bottom: 30rpx;
background:#fff; border-top: 1rpx solid #eee;