import { HMLifecycleState, HMPopInfo, HMRouter, HMRouterMgr } from "@hadss/hmrouter" import { BasicConstant, hdHttp, HdNav, HdLoadingDialog, logger, HdResponse, ChangeUtil, DefaultHintProWindows, authStore, PatientData, patientDbManager} from "@itcast/basic" import { HashMap } from "@kit.ArkTS"; import { promptAction, router } from "@kit.ArkUI"; import { BusinessError } from "@kit.BasicServicesKit"; @HMRouter({ pageUrl: 'PatientCommonSettingComp' }) @Component export struct PatientCommonSettingComp { private params: ESObject = HMRouterMgr.getCurrentParam() private lifecycleOwner = HMRouterMgr.getCurrentLifecycleOwner() private handleCallback = () => { this.getPatientsInfo() } @State itemList:Record = {} scroller:Scroller = new Scroller() private hintWindowDialog!: CustomDialogController dialog: CustomDialogController = new CustomDialogController({ builder: HdLoadingDialog({ message: '加载中...' }), customStyle: true, alignment: DialogAlignment.Center }) private hintPopWindowDialog() { this.hintWindowDialog = new CustomDialogController({ builder:DefaultHintProWindows({ controller:this.hintWindowDialog, message:'解除患者随访关系', cancleTitleColor: '#333333', confirmTitleColor: '#333333', selectedButton: (index:number)=>{ if (index === 1) { this.deletePatientAction() } this.hintWindowDialog.close(); } }), alignment: DialogAlignment.Center, cornerRadius:24, backgroundColor: ('rgba(0,0,0,0.5)'), }) } aboutToAppear(): void { this.getPatientsInfo() this.hintPopWindowDialog() this.lifecycleOwner?.addObserver(HMLifecycleState.onShown,this.handleCallback) } aboutToDisappear(): void { this.lifecycleOwner?.removeObserver(HMLifecycleState.onShown,this.handleCallback) } getPatientsInfo() { const hashMap: HashMap = new HashMap(); hashMap.set('patient_uuid',String(this.params.patient_uuid)); this.dialog.open() hdHttp.httpReq(BasicConstant.patientCard,hashMap).then(async (res: HdResponse) => { this.dialog.close(); logger.info('Response patientCard'+res); let json:Record = JSON.parse(res+'') as Record const isFriend = String(json.isFriend) if (isFriend == '0') { promptAction.showToast({ message: '随访关系已解除', duration: 1000 }) HMRouterMgr.pop() } else { if(json.code == '200') { this.itemList = {"photo":String(json.patient["photo"]), "realName":String(json.patient["realname"]), "nickname":String(json.group["nickname"]), "groupType":String(json.group["name"]), "is_star":String(json.group["is_star"]), "group_type":String(json.group["group_type"]), "groupUuid":String(json.group["uuid"]), "FollowUpDate":String(json.FollowUpDate), "FollowUpUuid":String(json.FollowUpUuid), "note":String(json.group["note"]), "patientUuid":String(this.params.patient_uuid)} } else { console.error('患者详情请求失败:'+json.message) } } }).catch((err: BusinessError) => { this.dialog.close(); console.info(`Response fails: ${err}`); }) } deletePatientAction() { this.dialog.open() hdHttp.post(BasicConstant.cancelRes, { "expertUuid": authStore.getUser().uuid, "patientUuid":String(this.params.patient_uuid) } as Record).then(async (res: HdResponse) => { this.dialog.close(); logger.info('Response toAddNickname'+res); let json:Record> = JSON.parse(res+'') as Record> promptAction.showToast({ message: String(json.message), duration: 1000 }) if(json.code == '1') { const singlePatient: PatientData = { uuid:this.params.patient_uuid as string, nickname: '', mobile: '', realName: '', nation: '', sex: 0, type: 2, photo: '', expertUuid: authStore.getUser().uuid } const success = await patientDbManager.updatePatientByData(singlePatient) if (success) { console.info('修改成功') } else { console.info('修改失败') } HMRouterMgr.removeAll() HMRouterMgr.pop() } else { console.error('获取患者信息失败:'+json.message) } }).catch((err: BusinessError) => { this.dialog.close(); console.error(`Response fails: ${err}`); }) } build() { Column() { HdNav({ title: '常用设置', showRightIcon: false, hasBorder: true, showRightText: false, isLeftAction:true, leftItemAction:()=>{ HMRouterMgr.pop() } }) Scroll(this.scroller) { Column() { Row() { Image(BasicConstant.urlImage + this.itemList.photo) .alt($r('app.media.userPhoto_default')) .width(60) .height(60) .borderRadius(6) .margin({ left: 15 }) Text(ChangeUtil.stringIsUndefinedAndNull(this.itemList.nickname) ? this.itemList.realName : this.itemList.nickname) .fontSize(15) .fontColor('#333333') .margin({ left: 15 }) .layoutWeight(1) Image($r('app.media.course_invoice_to_details')) .width(11) .height(20) .margin({ right: 15 }) } .width('100%') .height(80) .margin({ bottom: 10 }) .backgroundColor(Color.White) .visibility(this.params.title == '患者详情' ? Visibility.None : Visibility.Visible) .onClick(()=> HMRouterMgr.push({pageUrl:'PatientDetailsComp',param:{"patient_uuid":String(this.params.patient_uuid)}})) Row() { Text('设置备注') .fontSize(15) .fontColor('#333333') .margin({ left: 15 }) .layoutWeight(1) Text(ChangeUtil.stringIsUndefinedAndNull(this.itemList.nickname) ? '给患者添加备注名' : this.itemList.nickname) .textAlign(TextAlign.End) .width('50%') .margin({ right: 10 }) .fontSize(15) .fontColor('#666666') Image($r('app.media.course_invoice_to_details')) .width(11) .height(20) .margin({ right: 15 }) } .width('100%') .height(50) .backgroundColor(Color.White) .margin({ bottom: 1 }) .onClick(()=> HMRouterMgr.push({pageUrl: 'PatientSetMsgPage',param:{"model":this.itemList}})) Row() { Text('设置分组') .fontSize(15) .fontColor('#333333') .margin({ left: 15 }) .layoutWeight(1) Text(ChangeUtil.stringIsUndefinedAndNull(this.itemList.groupType) ? '通过分组给患者分类' : this.itemList.groupType) .width('60%') .textAlign(TextAlign.End) .maxLines(1) .margin({ right: 10 }) .fontSize(15) .fontColor('#666666') Image($r('app.media.course_invoice_to_details')) .width(11) .height(20) .margin({ right: 15 }) } .width('100%') .height(50) .backgroundColor(Color.White) .margin({ bottom: 10 }) .onClick(()=> HMRouterMgr.push({pageUrl: 'PatientSetMsgPage',param:{"model":this.itemList}})) Row() { Text('患者描述') .fontSize(15) .fontColor('#333333') .margin({ left: 15 }) .layoutWeight(1) Text(ChangeUtil.stringIsUndefinedAndNull(this.itemList.note) ? '补充患者关键信息,方便随访患者' : this.itemList.note) .textOverflow({overflow:TextOverflow.Ellipsis}) .maxLines(1) .textAlign(TextAlign.End) .width('60%') .margin({ right: 10 }) .fontSize(15) .fontColor('#666666') Image($r('app.media.course_invoice_to_details')) .width(11) .height(20) .margin({ right: 15 }) } .width('100%') .height(50) .backgroundColor(Color.White) .margin({ bottom: 10 }) .onClick(()=> HMRouterMgr.push({pageUrl: 'PatientSetMsgPage',param:{"model":this.itemList}})) Row() { Text('下次随访时间') .fontSize(15) .fontColor('#333333') .margin({ left: 15 }) .layoutWeight(1) Text(ChangeUtil.stringIsUndefinedAndNull(this.itemList.FollowUpDate) ? '添加随访提醒' : this.itemList.FollowUpDate) .textAlign(TextAlign.End) .width('50%') .margin({ right: 10 }) .fontSize(15) .fontColor('#666666') Image($r('app.media.course_invoice_to_details')) .width(11) .height(20) .margin({ right: 15 }) } .width('100%') .height(50) .backgroundColor(Color.White) .margin({ bottom: 10 }) .onClick(()=>{ if (ChangeUtil.stringIsUndefinedAndNull(this.itemList.FollowUpDate)) { HMRouterMgr.push({ pageUrl:'AddFollowPlanComp', param:{ "uuid":this.itemList.FollowUpUuid, "patientUuid":this.itemList.patientUuid, "nickname":this.itemList.nickname, "realName":this.itemList.realName}},{ onResult:(popInfo:HMPopInfo)=>{ this.getPatientsInfo() } }) } else { HMRouterMgr.push({ pageUrl:'FollowDetailsComp', param:{ "uuid":this.itemList.FollowUpUuid, "nickname":this.itemList.nickname, "realName":this.itemList.realName}},{ onResult: (popInfo: HMPopInfo) => { this.getPatientsInfo() } }) } }) Row() { Text('投诉反馈') .fontSize(15) .fontColor('#333333') .margin({ left: 15 }) .layoutWeight(1) Image($r('app.media.course_invoice_to_details')) .width(11) .height(20) .margin({ right: 15 }) } .width('100%') .height(50) .backgroundColor(Color.White) .margin({ bottom: 10 }) .onClick(()=>{ router.pushUrl({url:'pages/MinePage/FeedbackPage',params:{"title":"投诉反馈"}}) }) Row() { Text('解除随访') .width('100%') .fontSize(15) .fontColor($r('app.color.main_color')) .textAlign(TextAlign.Center) .onClick(() => this.hintWindowDialog.open()) } .width('100%') .height(50) .alignItems(VerticalAlign.Center) .backgroundColor(Color.White) } .width('100%') } .width('100%') .align(Alignment.TopStart) .height('calc(100% - 56vp)') .scrollBar(BarState.Off) .backgroundColor('#f4f4f4') } .height('100%') } }