HMRouter集成

This commit is contained in:
xiaoxiao 2025-07-15 17:00:01 +08:00
parent c43fb1905e
commit 1bee90d673
10 changed files with 179 additions and 121 deletions

View File

@ -8,31 +8,28 @@ export struct InputPopWindow {
build() {
Column() {
// 提示语标题
Text(this.title)
.fontSize(18)
.margin({ top: 20, bottom: 15 });
// 输入框
TextInput({ placeholder: '分组名' })
.width('90%')
.height(50)
.onChange((value: string) => {
this.inputValue = value; // 双向绑定更新值
this.inputValue = value
})
.border({ width: 1, color: '#CCCCCC' })
.backgroundColor(Color.White)
.borderRadius(4)
// 按钮行(取消 + 确定)
Flex({ justifyContent: FlexAlign.SpaceAround }) {
Text('取消')
.fontColor('#666666')
.textAlign(TextAlign.Center)
.width('30%')
.onClick(() => {
this.cancel?.(); // 触发取消回调
this.controller.close(); // 关闭弹窗
this.cancel?.()
this.controller.close()
})
Text('确定')
@ -40,8 +37,7 @@ export struct InputPopWindow {
.textAlign(TextAlign.Center)
.width('30%')
.onClick(() => {
this.confirm?.(this.inputValue); // 传递输入值给父组件
this.controller.close();
this.confirm?.(this.inputValue)
})
}
.margin({ top: 20, bottom: 10 })

View File

@ -1,5 +1,3 @@
export { MainPage } from './src/main/ets/components/MainPage';
export { PatientApplyPage } from './src/main/ets/components/PatientApplyPage'
export { PatientSetMsgPage } from './src/main/ets/components/PatientSetMsgPage'

View File

@ -1,18 +1,20 @@
import { authStore, HdNav, PositionSelectedSheet } from '@itcast/basic';
import { promptAction, router } from '@kit.ArkUI'
import { authStore, HdNav } from '@itcast/basic';
import { promptAction } from '@kit.ArkUI'
import { HdLoadingDialog,DefaultHintProWindows } from '@itcast/basic'
import { BasicConstant,hdHttp, HdResponse ,logger} from '@itcast/basic/Index'
import { BusinessError } from '@kit.BasicServicesKit';
import { patientListModel } from '../models/PatientsGroupModel'
import { HMRouter, HMRouterMgr,HMRouterPathInfo,HMRouterPathCallback } from "@hadss/hmrouter"
@HMRouter({ pageUrl: 'BuildOrEditGroupPage' })
@Component
export struct BuildOrEditGroupPage {
@State params:Record<string, string> = router.getParams() as Record<string, string>
private params: ESObject = HMRouterMgr.getCurrentParam();
// @State params:Record<string, string> = router.getParams() as Record<string, string>
scrollerCon:Scroller = new Scroller()
@State groupPatientList:patientListModel[] = []
@State groupName:string = ''
private hintWindowDialog!: CustomDialogController
@Consume@Watch('onRefreshAction') refreshFlag: boolean;
dialog: CustomDialogController = new CustomDialogController({
builder: HdLoadingDialog({ message: '加载中...' }),
@ -40,18 +42,6 @@ export struct BuildOrEditGroupPage {
})
}
onRefreshAction(flag: boolean) {
const returnParams = this.getUIContext().getRouter().getParams() as Record<string, string | patientListModel[]>;
const patients = returnParams?.selectedPatients as patientListModel[] | undefined;
if (patients?.length) {
for (const model of returnParams.selectedPatients as patientListModel[]) {
if (model.isSelected) {
this.groupPatientList.push(model)
}
}
}
}
aboutToAppear(): void {
if (this.params.title != '新建分组') {
this.getGroupPatientsData()
@ -91,7 +81,8 @@ export struct BuildOrEditGroupPage {
let json:Record<string,string> = JSON.parse(res+'') as Record<string,string>;
if(json.code == '1') {
promptAction.showToast({ message: '删除分组成功', duration: 1000 })
router.back();
// router.back();
HMRouterMgr.pop()
} else {
console.error('删除患者分组列表失败:'+json.message)
promptAction.showToast({ message: json.message, duration: 1000 })
@ -123,7 +114,8 @@ export struct BuildOrEditGroupPage {
let json:Record<string,string> = JSON.parse(res+'') as Record<string,string>;
if(json.code == '1') {
promptAction.showToast({ message:'分组成功', duration: 1000 })
router.back();
// router.back();
HMRouterMgr.pop()
} else if (json.code == '2') {
promptAction.showToast({ message:'该分组已存在', duration: 1000 })
} else {
@ -134,33 +126,6 @@ export struct BuildOrEditGroupPage {
this.dialog.close();
console.error(`Response fails: ${err}`);
})
// const postContent = new rcp.MultipartForm({
// "uuid": this.params.group_uuid,
// "name":this.groupName,
// "patient_uuid":uuidString
// })
// const session = rcp.createSession();
// session.post(BasicConstant.updateGroup, postContent)
// .then((response) => {
// this.dialog.close();
// logger.info('Response patientListByGroup'+response);
// let json:Record<string,string> = JSON.parse(response+'') as Record<string,string>;
// if(json.code == '1') {
// promptAction.showToast({ message:'分组成功', duration: 1000 })
// router.back();
// } else if (json.code == '2') {
// promptAction.showToast({ message:'该分组已存在', duration: 1000 })
// } else {
// console.error('删除患者分组列表失败:'+json.message)
// promptAction.showToast({ message: json.message, duration: 1000 })
// }
// })
// .catch((err: BusinessError) => {
// this.dialog.close();
// console.error(`Response err: Code is ${JSON.stringify(err.code)}, message is ${JSON.stringify(err)}`);
// })
}
build() {
@ -172,6 +137,10 @@ export struct BuildOrEditGroupPage {
hasBorder: true,
rightText: '保存',
showRightText: true,
isLeftAction:true,
leftItemAction:()=>{
HMRouterMgr.pop()
},
rightItemAction: () => {
if (this.params.title == '新建分组') {
this.setCreatOrEditGroup(0);
@ -219,10 +188,28 @@ export struct BuildOrEditGroupPage {
.height(80)
.backgroundColor(Color.White)
.onClick(()=>{
router.pushUrl({
url:'pages/PatientsPage/PatientsListPage',
params:{group_uuid:this.params.group_uuid,selectedPatients:this.groupPatientList}
})
const pathInfo1: HMRouterPathInfo = {
pageUrl: 'PatientsListComp',
param:{group_uuid:this.params.group_uuid,selectedPatients:this.groupPatientList}
};
const callback: HMRouterPathCallback = {
onResult: (popInfo: PopInfo) => {
const result = popInfo.result as Record<string,string | patientListModel[]>
const patients = result?.selectedPatients as patientListModel[] | undefined;
if (patients?.length) {
for (const model of result.selectedPatients as patientListModel[]) {
if (model.isSelected) {
this.groupPatientList.push(model)
}
}
}
}
};
HMRouterMgr.push(pathInfo1,callback)
// router.pushUrl({
// url:'pages/PatientsPage/PatientsListPage',
// params:{group_uuid:this.params.group_uuid,selectedPatients:this.groupPatientList}
// })
})
List(){

View File

@ -1,12 +1,13 @@
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 { promptAction } from '@kit.ArkUI'
import HashMap from '@ohos.util.HashMap';
import { BusinessError } from '@kit.BasicServicesKit'
import { HMRouter, HMRouterMgr } from "@hadss/hmrouter"
@HMRouter({ pageUrl: 'GroupManagementComp' })
@Component
export struct GroupManagementComp {
@State params:Record<string, string> = router.getParams() as Record<string, string>
private params: ESObject = HMRouterMgr.getCurrentParam();
private hintWindowDialog!: CustomDialogController
@State dialogInputValue: string = '';
private inputPopWindow!: CustomDialogController;
@ -40,7 +41,9 @@ export struct GroupManagementComp {
builder: InputPopWindow({
title: '添加分组',
controller:this.inputPopWindow,
confirm: this.onConfirm
confirm: (value: string)=>{
this.confirmAddGroup(value)
}
}),
alignment: DialogAlignment.Center,
cornerRadius:24,
@ -70,6 +73,7 @@ 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)
this.groupList = []
this.groupList = json.data as Array<Record<string,string>>
} else {
console.error('获取分组列表信息失败:'+json.message)
@ -109,10 +113,6 @@ export struct GroupManagementComp {
this.inputPopWindow.open()
}
private onConfirm(value: string) {
this.confirmAddGroup(value)
}
confirmAddGroup(value:string) {
if (!value.trim()) {
promptAction.showToast({ message: '请输入分组名', duration: 1000 })
@ -123,6 +123,7 @@ export struct GroupManagementComp {
return
}
this.dialog.open()
this.inputPopWindow.close()
hdHttp.post<string>(BasicConstant.addGroup, {
"expert_uuid": authStore.getUser().uuid,
"name":value,
@ -153,7 +154,7 @@ export struct GroupManagementComp {
}
this.dialog.open()
const uuidString = this.selectedGroups.map(item => item.uuid).join(',');
const nameString = this.selectedGroups.map(item => item.uuid).join(',');
const nameString = this.selectedGroups.map(item => item.name).join(',');
const hashMap: HashMap<string, string> = new HashMap()
hashMap.set('group_uuid',uuidString)
hashMap.set('patient_uuid',this.params.patientUuid)
@ -162,7 +163,7 @@ export struct GroupManagementComp {
logger.info('Response patientCardUpdateGroup'+res);
let json:Record<string,string> = JSON.parse(res+'') as Record<string,string>;
if(json.code == '200') {
router.back()
HMRouterMgr.pop({param:{'nameString':nameString,"uuidString":uuidString}})
} else {
console.error('保存患者分组信息失败:'+json.message)
promptAction.showToast({ message: json.message, duration: 1000 })
@ -177,6 +178,10 @@ export struct GroupManagementComp {
Column() {
HdNav({ title: '分组管理', showRightIcon: false, hasBorder: true, rightText: '保存', showRightText: true, rightItemAction:()=>{
this.saveGroupNameAction()
},
isLeftAction:true,
leftItemAction:()=>{
HMRouterMgr.pop()
} })
// 已选分组
Row() {

View File

@ -1,5 +1,5 @@
import { authStore, ChangeUtil, HdNav } from '@itcast/basic';
import { LevelMode, promptAction, router } from '@kit.ArkUI'
import { promptAction } from '@kit.ArkUI'
import { HdLoadingDialog } from '@itcast/basic'
import { BasicConstant,hdHttp, HdResponse ,logger} from '@itcast/basic/Index'
import { BusinessError } from '@kit.BasicServicesKit';
@ -8,12 +8,15 @@ import { TextSectionAttribute,LastSpanAttribute } from '../utils/Models'
import { applyListModel } from '../models/ApplyModel'
import { TextExpandView } from '../views/TextExpandView'
import call from '@ohos.telephony.call'
import { HMRouter, HMRouterMgr } from "@hadss/hmrouter"
@HMRouter({ pageUrl: 'PatientDetailsComp' })
@Component
export struct PatientDetailsComp {
scroller:Scroller = new Scroller()
@Consume@Watch('onRefreshAction') refreshFlag: boolean
@State params:Record<string, string> = router.getParams() as Record<string, string>
private params: ESObject = HMRouterMgr.getCurrentParam()
// @State params:Record<string, string> = router.getParams() as Record<string, string>
@State groupArray:Array<Record<string,string>> = []
@State footerArray:Array<Record<string,string | ResourceStr>> = []
@State patientCase:Array<Record<string,string>> = []
@ -52,7 +55,8 @@ export struct PatientDetailsComp {
const isFriend = String(json.isFriend)
if (isFriend == '0') {
promptAction.showToast({ message: '随访关系已解除', duration: 1000 })
router.back()
// router.back()
HMRouterMgr.pop()
} else {
if(json.code == '200') {
this.patientGroupData = json
@ -157,11 +161,16 @@ export struct PatientDetailsComp {
hasBorder: true,
rightIcon: $r("app.media.patient_details_navigation_right"),
showRightText: false,
isLeftAction:true,
leftItemAction:()=>{
HMRouterMgr.pop()
},
rightItemAction: () => {
router.pushUrl({
url: 'pages/PatientsPage/BuildOrEditGroupPage',
params: { "title": "新建分组" }
})
HMRouterMgr.push({pageUrl: 'BuildOrEditGroupPage',param:{"title": "新建分组"}})
// router.pushUrl({
// url: 'pages/PatientsPage/BuildOrEditGroupPage',
// params: { "title": "新建分组" }
// })
}
})
Scroll(this.scroller) {
@ -225,7 +234,7 @@ export struct PatientDetailsComp {
.margin({top:8,bottom:30})
}
.margin({left:15})
.justifyContent(FlexAlign.Start)
.width('calc(100% - 105vp)')
.alignItems(HorizontalAlign.Start)
}
.width('100%')
@ -271,10 +280,11 @@ export struct PatientDetailsComp {
});
}
} else {
router.pushUrl({
url:'pages/PatientsPage/PatientMsgSetPage',
params:{"model":this.patientData2}
})
HMRouterMgr.push({pageUrl: 'PatientSetMsgPage',param:{"model":this.patientData2}})
// router.pushUrl({
// url:'pages/PatientsPage/PatientMsgSetPage',
// params:{"model":this.patientData2}
// })
}
})
}.width('100%').height(50)

View File

@ -4,8 +4,9 @@ import HashMap from '@ohos.util.HashMap';
import { HdLoadingDialog } from '@itcast/basic'
import { BasicConstant,hdHttp, HdResponse ,logger} from '@itcast/basic/Index'
import { BusinessError } from '@kit.BasicServicesKit';
import { Font, promptAction, router } from '@kit.ArkUI'
import { promptAction } from '@kit.ArkUI'
import { patientDbManager, PatientData } from '@itcast/basic';
import { HMRouter, HMRouterMgr, HMRouterPathCallback, HMRouterPathInfo } from "@hadss/hmrouter"
interface callBackData {
code: string,
@ -18,10 +19,10 @@ interface paramsCallData {
model:applyListModel;
}
@HMRouter({ pageUrl: 'PatientSetMsgPage' })
@Component
export struct PatientSetMsgPage {
pageStack:NavPathStack = new NavPathStack()
@State params:paramsCallData = router.getParams() as paramsCallData
private params: ESObject = HMRouterMgr.getCurrentParam()
@State noteName: string | undefined = ChangeUtil.stringIsUndefinedAndNull(this.params.model.nickname)?'':String(this.params.model.nickname)
@State contentFrist:string | undefined = ''
@State groupName: string = ChangeUtil.stringIsUndefinedAndNull(this.params.model.groupType)?'通过分组给患者分类':String(this.params.model.groupType)
@ -37,7 +38,6 @@ export struct PatientSetMsgPage {
})
aboutToAppear(): void {
this.pageStack.getParamByName('PatientSetMsgPage')
this.contentFrist = getFirstSegment(this.params.model.content)
}
@ -73,7 +73,8 @@ export struct PatientSetMsgPage {
console.info('添加失败');
}
promptAction.showToast({ message: '设置成功', duration: 1000 })
router.back()
// router.back()
HMRouterMgr.pop()
} else {
console.error('患者申请记录列表失败:'+json.message)
promptAction.showToast({ message: json.message, duration: 1000 })
@ -86,7 +87,11 @@ export struct PatientSetMsgPage {
build() {
Column() {
HdNav({ title: '设置备注和分组', showRightIcon: false, hasBorder: true })
HdNav({ title: '设置备注和分组', showRightIcon: false, hasBorder: true,
isLeftAction:true,
leftItemAction:()=>{
HMRouterMgr.pop()
} })
Text('备注')
.margin({left:15,top:15})
@ -141,10 +146,21 @@ export struct PatientSetMsgPage {
.borderRadius(4)
.margin({left:15,top:10})
.onClick(()=>{
router.pushUrl({
url:'pages/PatientsPage/GroupManagementPage',
params:{groupNames:this.params.model.groupType,groupUuids:this.params.model.groupUuid,patientUuid:this.params.model.patientUuid}
})
const pathInfo1: HMRouterPathInfo = {
pageUrl: 'GroupManagementComp',
param:{groupNames:this.params.model.groupType,groupUuids:this.params.model.groupUuid,patientUuid:this.params.model.patientUuid}
};
const callback: HMRouterPathCallback = {
onResult: (popInfo: PopInfo) => {
const result = popInfo.result as Record<string,string>
this.groupName = String(result.nameString)
}
};
HMRouterMgr.push(pathInfo1,callback)
// router.pushUrl({
// url:'pages/PatientsPage/GroupManagementPage',
// params:{groupNames:this.params.model.groupType,groupUuids:this.params.model.groupUuid,patientUuid:this.params.model.patientUuid}
// })
})
Text('描述')

View File

@ -1,10 +1,11 @@
import { authStore, HdNav, PositionSelectedSheet } from '@itcast/basic';
import { promptAction, router } from '@kit.ArkUI'
import { promptAction } from '@kit.ArkUI'
import { HdLoadingDialog } from '@itcast/basic'
import { BasicConstant,hdHttp, HdResponse ,logger} from '@itcast/basic/Index'
import { BusinessError } from '@kit.BasicServicesKit';
import HashMap from '@ohos.util.HashMap';
import { groupRequest,groupRequestCall,groupModel,patientListModel } from '../models/PatientsGroupModel'
import { HMRouterMgr, HMRouterPathInfo, HMRouterPathCallback } from "@hadss/hmrouter"
@Component
export struct PatientsGroup {
@ -20,11 +21,6 @@ export struct PatientsGroup {
@State group_sort:string = '0'
@State list_sort:string = '0'
@State groupListArray: groupModel[] = [];
@Consume@Watch('onRefreshAction') refreshFlag: boolean;
onRefreshAction(flag: boolean) {
this.getGroupData();
}
dialog: CustomDialogController = new CustomDialogController({
builder: HdLoadingDialog({ message: '加载中...' }),
@ -92,10 +88,11 @@ export struct PatientsGroup {
rightText: '新建',
showRightText: true,
rightItemAction: () => {
router.pushUrl({
url: 'pages/PatientsPage/BuildOrEditGroupPage',
params:{"title":"新建分组"}
})
HMRouterMgr.push({pageUrl:'BuildOrEditGroupPage',param:{"title":"新建分组"}})
// router.pushUrl({
// url: 'pages/PatientsPage/BuildOrEditGroupPage',
// params:{"title":"新建分组"}
// })
}
})
Stack() {
@ -164,10 +161,11 @@ export struct PatientsGroup {
.backgroundColor('#999999')
}.width('100%').height(80).alignContent(Alignment.BottomEnd)
.onClick(()=>{
router.pushUrl({
url:'pages/PatientsPage/PatientDetailsPage',
params:{"patient_uuid":rowModel.uuid}
})
HMRouterMgr.push({pageUrl:'PatientDetailsComp',param:{"patient_uuid":rowModel.uuid}})
// router.pushUrl({
// url:'pages/PatientsPage/PatientDetailsPage',
// params:{"patient_uuid":rowModel.uuid}
// })
})
}.width('100%')
})
@ -289,10 +287,24 @@ export struct PatientsGroup {
.textAlign(TextAlign.End)
.visibility(model.name != '待分组患者'?Visibility.Visible:Visibility.Hidden)
.onClick(()=>{
router.pushUrl({
url: 'pages/PatientsPage/BuildOrEditGroupPage',
params:{"title":"编辑分组","group_uuid":model.uuid,"group_name":model.name}
})
const pathInfo1: HMRouterPathInfo = {
pageUrl: 'BuildOrEditGroupPage',
param:{"title":"编辑分组","group_uuid":model.uuid,"group_name":model.name}
};
const callback: HMRouterPathCallback = {
onResult: (popInfo: PopInfo) => {
const result = popInfo.result as Record<string,string>
const isFreash = Boolean(result.nameString)
if (isFreash) {
this.getGroupData()
}
}
};
HMRouterMgr.push(pathInfo1,callback)
// router.pushUrl({
// url: 'pages/PatientsPage/BuildOrEditGroupPage',
// params:{"title":"编辑分组","group_uuid":model.uuid,"group_name":model.name}
// })
})
}
.width('100%')

View File

@ -1,13 +1,16 @@
import { authStore, ChangeUtil, HdNav, PositionSelectedSheet, EmptyViewComp,HdLoadingDialog } from '@itcast/basic';
import { promptAction, router } from '@kit.ArkUI'
import { HdNav, EmptyViewComp,HdLoadingDialog } from '@itcast/basic';
import { promptAction } from '@kit.ArkUI'
import { BasicConstant,hdHttp, HdResponse ,logger} from '@itcast/basic/Index'
import { BusinessError } from '@kit.BasicServicesKit';
import HashMap from '@ohos.util.HashMap';
import HashMap from '@ohos.util.HashMap'
import { patientListModel } from '../models/PatientsGroupModel'
import { HMRouter, HMRouterMgr } from "@hadss/hmrouter"
@HMRouter({ pageUrl: 'PatientsListComp' })
@Component
export struct PatientsListComp {
@State params:Record<string, string | patientListModel[]> = router.getParams() as Record<string, string | patientListModel[]>
private params: ESObject = HMRouterMgr.getCurrentParam()
// @State params:Record<string, string | patientListModel[]> = router.getParams() as Record<string, string | patientListModel[]>
@State patientsArray:patientListModel[] = []
@State patientsList:patientListModel[] = []
@State inputString:string = ''
@ -74,11 +77,16 @@ export struct PatientsListComp {
build() {
Column() {
HdNav({showLeftIcon:true,title:'选择患者',rightText:this.naviRightTitle,showRightText:true,rightTextColor:Color.White,rightBackColor:$r('app.color.main_color'),showRightIcon:false,rightItemAction:()=>{
router.back({
url:'pages/PatientsPage/BuildOrEditGroupPage',
params:{'selectedPatients':this.patientsList}
})
HdNav({showLeftIcon:true,title:'选择患者',rightText:this.naviRightTitle,showRightText:true,rightTextColor:Color.White,rightBackColor:$r('app.color.main_color'),showRightIcon:false,
isLeftAction:true,
leftItemAction:()=>{
HMRouterMgr.pop()
},rightItemAction:()=>{
HMRouterMgr.pop({param:{'selectedPatients':this.patientsList}})
// router.back({
// url:'pages/PatientsPage/BuildOrEditGroupPage',
// params:{'selectedPatients':this.patientsList}
// })
}})
Row(){

View File

@ -10,7 +10,7 @@ struct PatientDetailsPage {
}
build() {
RelativeContainer() {
Column() {
PatientDetailsComp()
}
.height('100%')

View File

@ -1,17 +1,43 @@
import { PatientsGroup } from 'patient'
import { HMDefaultGlobalAnimator, HMNavigation } from '@hadss/hmrouter'
import { AttributeUpdater } from '@kit.ArkUI'
import { TabBarComp } from 'netease'
class NavModifier extends AttributeUpdater<NavigationAttribute> {
initializeModifier(instance: NavigationAttribute): void {
instance.mode(NavigationMode.Stack);
instance.navBarWidth('100%');
instance.hideTitleBar(true);
instance.hideToolBar(true);
}
}
@Entry
@Component
struct PatientsGroupPage {
@Provide refreshFlag:boolean = false;
modifier: NavModifier = new NavModifier()
@State
activeIndex: number = 0
onPageShow(): void {
this.refreshFlag = !this.refreshFlag;
}
build() {
RelativeContainer() {
PatientsGroup();
Column() {
HMNavigation({
navigationId:"PatientsGroupPageNavigation",
homePageUrl:'PatientsGroup',
options:{
standardAnimator:HMDefaultGlobalAnimator.STANDARD_ANIMATOR,
dialogAnimator:HMDefaultGlobalAnimator.DIALOG_ANIMATOR,
modifier:this.modifier
}
}) {
// PatientsGroup()
TabBarComp({ activeIndex: this.activeIndex})
}
}
.height('100%')
.width('100%')