患者分组

This commit is contained in:
xiaoxiao 2025-07-14 17:38:11 +08:00
parent 1121cc3f20
commit c46d9848f0
6 changed files with 133 additions and 82 deletions

View File

@ -1,10 +1,8 @@
@CustomDialog
export struct InputPopWindow {
controller: CustomDialogController; // 控制器(必须)
@Prop title: string; // 提示语(从父组件传入)
@Link inputValue: string; // 输入框值(双向绑定)
// 按钮回调函数(通过构造函数传入)
controller: CustomDialogController;
@Prop title: string;
@State inputValue:string = ''
private cancel?: () => void;
private confirm?: (value: string) => void;
@ -16,28 +14,31 @@ export struct InputPopWindow {
.margin({ top: 20, bottom: 15 });
// 输入框
TextInput({ placeholder: '请输入内容', text: this.inputValue })
TextInput({ placeholder: '分组名' })
.width('90%')
.height(50)
.onChange((value: string) => {
this.inputValue = value; // 双向绑定更新值
})
.border({ width: 1, color: '#CCCCCC' })
.backgroundColor(Color.White)
.borderRadius(4)
// 按钮行(取消 + 确定)
Flex({ justifyContent: FlexAlign.SpaceAround }) {
Button('取消')
.backgroundColor('#FFFFFF')
Text('取消')
.fontColor('#666666')
.textAlign(TextAlign.Center)
.width('30%')
.onClick(() => {
this.cancel?.(); // 触发取消回调
this.controller.close(); // 关闭弹窗
})
Button('确定')
.backgroundColor('#317AFF')
.fontColor('#FFFFFF')
Text('确定')
.fontColor('#317AFF')
.textAlign(TextAlign.Center)
.width('30%')
.onClick(() => {
this.confirm?.(this.inputValue); // 传递输入值给父组件
this.controller.close();
@ -46,8 +47,8 @@ export struct InputPopWindow {
.margin({ top: 20, bottom: 10 })
.width('100%')
}
.backgroundColor('#f4f4f4')
.width('100%')
.padding(10)
.borderRadius(16) // 圆角弹窗
}
}

View File

@ -32,6 +32,7 @@ export class BasicConstant {
static readonly patientListByGroup = BasicConstant.urlExpertApp+'patientListByGroup'
static readonly deleteGroup = BasicConstant.urlExpertApp+'deleteGroup'
static readonly addGroup = BasicConstant.urlExpertApp+'addGroup'
static readonly patientCardUpdateGroup = BasicConstant.urlExpertAPI+'patientCardUpdateGroup'
static readonly updateGroup = BasicConstant.urlExpertApp+'updateGroup'
static readonly relationRecordLately = BasicConstant.urlExpertAPI+'relationRecordLately'
static readonly updateNicknameNote = BasicConstant.urlExpertAPI+'updateNicknameNote'

View File

@ -1,15 +1,15 @@
import { BasicConstant, hdHttp, HdResponse, authStore, HdNav , HdLoadingDialog, ChangeUtil,DefaultHintProWindows,InputPopWindow } from '@itcast/basic/Index'
import { BasicConstant, hdHttp, HdResponse, logger , authStore, HdNav , HdLoadingDialog, ChangeUtil,DefaultHintProWindows,InputPopWindow } from '@itcast/basic/Index'
import { promptAction, router } from '@kit.ArkUI'
import { groupModel } from '../models/PatientsGroupModel'
import HashMap from '@ohos.util.HashMap';
import { BusinessError } from '@kit.BasicServicesKit';
import { BusinessError } from '@kit.BasicServicesKit'
@Component
export struct GroupManagementComp {
@State params:Record<string, string> = router.getParams() as Record<string, string>
private hintWindowDialog!: CustomDialogController
@State dialogInputValue: string = ''; // 绑定输入框的值
// InputPopWindow: CustomDialogController; // 控制器实例
@State dialogInputValue: string = '';
private inputPopWindow!: CustomDialogController;
@State groupList: Array<Record<string,string>> = []
@State selectedGroups: Array<Record<string,string>> = []
@ -35,8 +35,22 @@ export struct GroupManagementComp {
})
}
private inputPopWindowInit() {
this.inputPopWindow = new CustomDialogController({
builder: InputPopWindow({
title: '添加分组',
controller:this.inputPopWindow,
confirm: this.onConfirm
}),
alignment: DialogAlignment.Center,
cornerRadius:24,
backgroundColor: ('rgba(0,0,0,0.5)'),
});
}
aboutToAppear() {
this.hintPopWindowDialog()
this.inputPopWindowInit()
this.addShowTagAction()
this.fetchGroups()
}
@ -56,7 +70,6 @@ export struct GroupManagementComp {
let json:Record<string,string | Array<Record<string,string>>> = JSON.parse(res+'') as Record<string,string | Array<Record<string,string>>>
if(json.code == '1') {
console.info('上一层传过来的group:',this.params.groupNames)
// groupUuids
this.groupList = json.data as Array<Record<string,string>>
} else {
console.error('获取分组列表信息失败:'+json.message)
@ -93,43 +106,78 @@ export struct GroupManagementComp {
}
onAddGroup() {
this.inputPopWindow.open()
}
confirmAddGroup() {
// if (!this.newGroupName.trim()) {
// promptAction.showToast({ message: '请输入分组名', duration: 1000 })
// return
// }
// if (this.newGroupName.length > 10) {
// promptAction.showToast({ message: '最多10个字符', duration: 1000 })
// return
// }
// this.addLoading = true
// const params = {
// expert_uuid: authStore.getUser().uuid,
// name: this.newGroupName.trim(),
// patient_uuid: ''
// }
// hdHttp.post<string>(BasicConstant.addGroup, params).then(async (res: HdResponse<string>) => {
// this.addLoading = false
// let json = JSON.parse(res + '') as { code: number, message: string }
// if (json.code === 1) {
// this.showAddDialog = false
// this.addDialog.close()
// this.fetchGroups()
// promptAction.showToast({ message: '添加成功', duration: 1000 })
// } else {
// promptAction.showToast({ message: json.message, duration: 1000 })
// }
// }).catch(() => {
// this.addLoading = false
// })
private onConfirm(value: string) {
this.confirmAddGroup(value)
}
confirmAddGroup(value:string) {
if (!value.trim()) {
promptAction.showToast({ message: '请输入分组名', duration: 1000 })
return
}
if (value.length > 10) {
promptAction.showToast({ message: '最多10个字符', duration: 1000 })
return
}
this.dialog.open()
hdHttp.post<string>(BasicConstant.addGroup, {
"expert_uuid": authStore.getUser().uuid,
"name":value,
"patient_uuid":""
} as Record<string,string>).then(async (res: HdResponse<string>) => {
this.dialog.close();
let json:Record<string,string | Array<Record<string,string>>> = JSON.parse(res+'') as Record<string,string | Array<Record<string,string>>>
if(json.code == '1') {
this.fetchGroups()
this.groupList = json.data as Array<Record<string,string>>
promptAction.showToast({ message: "添加分组成功", duration: 1000 })
} else if (json.code == '2') {
promptAction.showToast({ message: "该分组已存在", duration: 1000 })
} else {
console.error('创建分组失败:'+json.message)
promptAction.showToast({ message: String(json.message), duration: 1000 })
}
}).catch((err: BusinessError) => {
this.dialog.close();
console.error(`Response fails: ${err}`);
})
}
saveGroupNameAction(){
if (this.selectedGroups.length <= 0) {
promptAction.showToast({ message: "请选择或者创建分组", duration: 1000 })
return
}
this.dialog.open()
const uuidString = this.selectedGroups.map(item => item.uuid).join(',');
const nameString = this.selectedGroups.map(item => item.uuid).join(',');
const hashMap: HashMap<string, string> = new HashMap()
hashMap.set('group_uuid',uuidString)
hashMap.set('patient_uuid',this.params.patientUuid)
hdHttp.httpReq<string>(BasicConstant.patientCardUpdateGroup,hashMap).then(async (res: HdResponse<string>) => {
this.dialog.close();
logger.info('Response patientCardUpdateGroup'+res);
let json:Record<string,string> = JSON.parse(res+'') as Record<string,string>;
if(json.code == '200') {
router.back()
} else {
console.error('保存患者分组信息失败:'+json.message)
promptAction.showToast({ message: json.message, duration: 1000 })
}
}).catch((err: BusinessError) => {
this.dialog.close();
console.info(`Response fails: ${err}`);
})
}
build() {
Column() {
HdNav({ title: '分组管理', showRightIcon: false, hasBorder: true, rightText: '保存', showRightText: true })
HdNav({ title: '分组管理', showRightIcon: false, hasBorder: true, rightText: '保存', showRightText: true, rightItemAction:()=>{
this.saveGroupNameAction()
} })
// 已选分组
Row() {
Flex({ justifyContent: FlexAlign.Start, wrap: FlexWrap.Wrap }) {

View File

@ -149,43 +149,43 @@ export struct PatientDetailsComp {
}
build() {
Row() {
Column() {
HdNav({
title: '患者详情',
showRightIcon: true,
hasBorder: true,
rightIcon:$r("app.media.patient_details_navigation_right"),
showRightText: false,
rightItemAction: () => {
router.pushUrl({
url: 'pages/PatientsPage/BuildOrEditGroupPage',
params:{"title":"新建分组"}
})
}
})
Scroll(this.scroller){
Column(){
this.patientsView()
this.otherMsgView()
this.historyView()
if (this.patientCase.length > 0) {
this.patientCaseView()
Row() {
Column() {
HdNav({
title: '患者详情',
showRightIcon: true,
hasBorder: true,
rightIcon: $r("app.media.patient_details_navigation_right"),
showRightText: false,
rightItemAction: () => {
router.pushUrl({
url: 'pages/PatientsPage/BuildOrEditGroupPage',
params: { "title": "新建分组" }
})
}
this.footerView()
})
Scroll(this.scroller) {
Column() {
this.patientsView()
this.otherMsgView()
this.historyView()
if (this.patientCase.length > 0) {
this.patientCaseView()
}
this.footerView()
}
.width('100%')
.justifyContent(FlexAlign.Start)
}
.width('100%')
.justifyContent(FlexAlign.Start)
.height('calc(100% - 56vp)')
.backgroundColor('#f4f4f4')
.scrollBar(BarState.Off)
.align(Alignment.TopStart)
}
.width('100%')
.height('calc(100% - 56vp)')
.backgroundColor('#f4f4f4')
.scrollBar(BarState.Off)
.align(Alignment.TopStart)
.width('100%').height('100%')
}
.width('100%').height('100%')
}
.height('100%')
.height('100%')
}
@Builder

View File

@ -20,6 +20,7 @@ interface paramsCallData {
@Component
export struct PatientSetMsgPage {
pageStack:NavPathStack = new NavPathStack()
@State params:paramsCallData = router.getParams() as paramsCallData
@State noteName: string | undefined = ChangeUtil.stringIsUndefinedAndNull(this.params.model.nickname)?'':String(this.params.model.nickname)
@State contentFrist:string | undefined = ''
@ -36,6 +37,7 @@ export struct PatientSetMsgPage {
})
aboutToAppear(): void {
this.pageStack.getParamByName('PatientSetMsgPage')
this.contentFrist = getFirstSegment(this.params.model.content)
}
@ -141,7 +143,7 @@ export struct PatientSetMsgPage {
.onClick(()=>{
router.pushUrl({
url:'pages/PatientsPage/GroupManagementPage',
params:{groupNames:this.params.model.groupType,groupUuids:this.params.model.groupUuid}
params:{groupNames:this.params.model.groupType,groupUuids:this.params.model.groupUuid,patientUuid:this.params.model.patientUuid}
})
})

View File

@ -1,6 +1,5 @@
import { PatientSetMsgPage } from 'patient'
@Entry
@Component
struct PatientMsgSetPage {