From c46d9848f08ce4d01c8a149eadc3d05f1825216f Mon Sep 17 00:00:00 2001 From: xiaoxiao Date: Mon, 14 Jul 2025 17:38:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=82=A3=E8=80=85=E5=88=86=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/ets/Views/InputPopWindow.ets | 25 ++-- .../src/main/ets/constants/BasicConstant.ets | 1 + .../ets/components/GroupManagementComp.ets | 120 ++++++++++++------ .../ets/components/PatientDetailsComp.ets | 64 +++++----- .../main/ets/components/PatientSetMsgPage.ets | 4 +- .../pages/PatientsPage/PatientMsgSetPage.ets | 1 - 6 files changed, 133 insertions(+), 82 deletions(-) diff --git a/commons/basic/src/main/ets/Views/InputPopWindow.ets b/commons/basic/src/main/ets/Views/InputPopWindow.ets index 779aa61..c47befb 100644 --- a/commons/basic/src/main/ets/Views/InputPopWindow.ets +++ b/commons/basic/src/main/ets/Views/InputPopWindow.ets @@ -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) // 圆角弹窗 } } diff --git a/commons/basic/src/main/ets/constants/BasicConstant.ets b/commons/basic/src/main/ets/constants/BasicConstant.ets index 2bfa09a..9836cdf 100644 --- a/commons/basic/src/main/ets/constants/BasicConstant.ets +++ b/commons/basic/src/main/ets/constants/BasicConstant.ets @@ -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' diff --git a/features/patient/src/main/ets/components/GroupManagementComp.ets b/features/patient/src/main/ets/components/GroupManagementComp.ets index 39d6191..e429b7f 100644 --- a/features/patient/src/main/ets/components/GroupManagementComp.ets +++ b/features/patient/src/main/ets/components/GroupManagementComp.ets @@ -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 = router.getParams() as Record private hintWindowDialog!: CustomDialogController - @State dialogInputValue: string = ''; // 绑定输入框的值 - // InputPopWindow: CustomDialogController; // 控制器实例 + @State dialogInputValue: string = ''; + private inputPopWindow!: CustomDialogController; @State groupList: Array> = [] @State selectedGroups: Array> = [] @@ -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>> = JSON.parse(res+'') as Record>> if(json.code == '1') { console.info('上一层传过来的group:',this.params.groupNames) - // groupUuids this.groupList = json.data as Array> } 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(BasicConstant.addGroup, params).then(async (res: HdResponse) => { - // 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(BasicConstant.addGroup, { + "expert_uuid": authStore.getUser().uuid, + "name":value, + "patient_uuid":"" + } as Record).then(async (res: HdResponse) => { + this.dialog.close(); + let json:Record>> = JSON.parse(res+'') as Record>> + if(json.code == '1') { + this.fetchGroups() + this.groupList = json.data as Array> + 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 = new HashMap() + hashMap.set('group_uuid',uuidString) + hashMap.set('patient_uuid',this.params.patientUuid) + hdHttp.httpReq(BasicConstant.patientCardUpdateGroup,hashMap).then(async (res: HdResponse) => { + this.dialog.close(); + logger.info('Response patientCardUpdateGroup'+res); + let json:Record = JSON.parse(res+'') as Record; + 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 }) { diff --git a/features/patient/src/main/ets/components/PatientDetailsComp.ets b/features/patient/src/main/ets/components/PatientDetailsComp.ets index 909113b..b0e8fae 100644 --- a/features/patient/src/main/ets/components/PatientDetailsComp.ets +++ b/features/patient/src/main/ets/components/PatientDetailsComp.ets @@ -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 diff --git a/features/patient/src/main/ets/components/PatientSetMsgPage.ets b/features/patient/src/main/ets/components/PatientSetMsgPage.ets index 473666d..0598d9e 100644 --- a/features/patient/src/main/ets/components/PatientSetMsgPage.ets +++ b/features/patient/src/main/ets/components/PatientSetMsgPage.ets @@ -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} }) }) diff --git a/products/expert/src/main/ets/pages/PatientsPage/PatientMsgSetPage.ets b/products/expert/src/main/ets/pages/PatientsPage/PatientMsgSetPage.ets index 6b0df7b..68ac7fd 100644 --- a/products/expert/src/main/ets/pages/PatientsPage/PatientMsgSetPage.ets +++ b/products/expert/src/main/ets/pages/PatientsPage/PatientMsgSetPage.ets @@ -1,6 +1,5 @@ import { PatientSetMsgPage } from 'patient' - @Entry @Component struct PatientMsgSetPage {