import { HMPopInfo, HMRouter, HMRouterMgr } from "@hadss/hmrouter"; import { authStore, BasicConstant, ChangeUtil, hdHttp, HdLoadingDialog, HdNav, HdResponse, logger, TimestampUtil } from "@itcast/basic"; import { promptAction } from "@kit.ArkUI"; import { BusinessError } from "@kit.BasicServicesKit"; @HMRouter({ pageUrl:'AddScheduleFollowComp' }) @Component export struct AddScheduleFollowComp { scroller:Scroller = new Scroller() controller:TextAreaController = new TextAreaController() private params: ESObject = HMRouterMgr.getCurrentParam() @State name:string = ChangeUtil.stringIsUndefinedAndNull(this.params.nickname)?String(this.params.realName):String(this.params.nickname) @State note:string = '请于近日来院复诊、复查' @State date:string = '' @State time:string = '请选择日期' @State isNotiMe:boolean = false @State isNotiPa:boolean = false dialog: CustomDialogController = new CustomDialogController({ builder: HdLoadingDialog({ message: '加载中...' }), customStyle: true, alignment: DialogAlignment.Center }) submitFollowListAction() { if (this.time == '请选择日期') { promptAction.showToast({ message:'请选择日期', duration: 1000 }) return } if (this.note.length <= 0) { promptAction.showToast({ message:'请编辑随访计划', duration: 1000 }) return } const entity = { "expert_uuid": authStore.getUser().uuid, "patient_uuid": this.params.patientUuid, "datetime":this.date, "note":this.note, "type":"1", "isremindme":this.isNotiMe?"1":"0", "isremindpatient":this.isNotiPa?"1":"0" } as Record this.dialog.open() hdHttp.post(BasicConstant.addFollowUp, entity).then(async (res: HdResponse) => { this.dialog.close(); logger.info('Response caseUuid'+res); let json:Record | Array>> = JSON.parse(res+'') as Record | Array>>; if(json.code == '1') { HMRouterMgr.pop({param:{"isRefresh":"1"}}) 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}`); }) } build() { Column() { HdNav({title:'添加日程',isLeftAction:true,showRightIcon:false,showRightText:true,rightText:'提交',leftItemAction:()=>{ HMRouterMgr.pop() },rightItemAction:()=>{ this.submitFollowListAction() }}) Scroll(this.scroller){ Column() { Row() { Text('患者') .fontSize(15) .fontColor($r('app.color.main_color')) .margin({ left: 10 }) .layoutWeight(1) Text(this.name) .fontSize(15) .margin({ right: 10 }) } .width('100%') .height(40) .margin({top:10}) .backgroundColor(Color.White) Row(){ Text('日期') .fontSize(15) .fontColor($r('app.color.main_color')) .margin({ left: 10 }) .layoutWeight(1) Text(this.time) .fontSize(15) .margin({ right: 10 }) .onClick(()=>this.selectedData()) } .width('100%') .height(40) .margin({top:10}) .backgroundColor(Color.White) Text('随访内容') .height(40) .width('100%') .fontSize(15) .fontColor($r('app.color.main_color')) .padding({ left: 10 }) .margin({top:10}) .backgroundColor(Color.White) TextArea({ placeholder:'在这里输入内容...(200字以内)', controller:this.controller, text:this.note }) .onChange((value: string) => { this.note = value }) .placeholderFont({size:15}) .placeholderColor('#999999') .width('100%') .padding({left:10,top:10,right:10,bottom:50}) .fontSize(15) .maxLength(200) .backgroundColor(Color.White) .border({ radius: 0 }) this.selectedNotification() } } .width('100%') .scrollBar(BarState.Off) .height('calc(100% - 120vp)') .align(Alignment.TopStart) .backgroundColor('#f4f4f4') } .width('100%') } @Builder selectedNotification() { Column(){ Row(){ Text('提醒我') .fontSize(15) .margin({left:10}) .fontColor($r('app.color.main_color')) .layoutWeight(1) Image(this.isNotiMe?$r('app.media.patiemts_list_selected'):$r('app.media.patients_no_selected')) .width(20) .height(20) .margin({right:10}) } .height(50) .width('100%') .margin({bottom:1}) .backgroundColor(Color.White) .onClick(()=>{ this.isNotiMe = !this.isNotiMe }) Row(){ Text('提醒患者') .fontSize(15) .margin({left:10}) .fontColor($r('app.color.main_color')) .layoutWeight(1) Image(this.isNotiPa?$r('app.media.patiemts_list_selected'):$r('app.media.patients_no_selected')) .width(20) .height(20) .margin({right:10}) } .height(50) .width('100%') .backgroundColor(Color.White) .onClick(()=>{ this.isNotiPa = !this.isNotiPa }) } .width('100%') .margin({top:10}) } selectedData(){ CalendarPickerDialog.show({ selected: new Date(), backgroundColor: Color.White, backgroundBlurStyle: BlurStyle.NONE, shadow: ShadowStyle.OUTER_FLOATING_SM, onAccept: (value) => { const today = new Date(); today.setHours(0, 0, 0, 0); const selected = new Date(value); selected.setHours(0, 0, 0, 0); if (selected < today) { promptAction.showToast({ message: '只能选择今天及以后的日期', duration: 1500 }) return } this.time = TimestampUtil.format(value,'YYYY-MM-DD')+'('+TimestampUtil.getWeekday(value)+')' this.date = TimestampUtil.format(value,'YYYY-MM-DD') } }); } }