harmony/features/netease/src/main/ets/view/TabBarOutComp.ets
2025-07-25 13:23:43 +08:00

175 lines
4.4 KiB
Plaintext

import { TabBarCompModel } from '../model/TabBarCompModel'
import { BasicConstant, hdHttp,HdNav, HdResponse } from '@itcast/basic'
import { ListCompPublic } from '../components/ListCompPublic'
import { ListCompMany } from '../components/ListCompMany'
import { StopNoticeComp } from './StopNoticeComp'
import { HMRouterMgr } from '@hadss/hmrouter'
import { HashMap } from '@kit.ArkTS'
import { BusinessError } from '@kit.BasicServicesKit'
import { PatientNoticeModel } from '../model/PatientNoticeModel'
import { promptAction } from '@kit.ArkUI'
import { ArrangementsComp } from './ArrangementsComp'
@Component
export struct TabBarOutComp {
@StorageProp('bottomHeight')
bottomHeight: number = 0
@Link activeIndex: number
@State note:string=''
@State uuid:string=''
@State textInfo:string='发布新的停诊'
@State stopnum: number = 0
aboutToAppear() {
this.mailanNoticeGet()
}
@Builder
TabBarBuilder(item: TabBarCompModel, index: number) {
Row() {
Text(item.label)
.fontSize(16)
.fontColor(this.activeIndex === index ? $r('app.color.top_title'):$r('app.color.common_gray_03') )
.animation({ duration: 300 })
.textAlign(TextAlign.Center)
.layoutWeight(1)
if (index < TabBarItems.length - 1) {
// 竖线
Text('|').fontColor($r('app.color.common_gray_02')) // 可选:左右留点间距
}
}
}
build() {
RelativeContainer()
{
Column()
{
HdNav({ title: '出/停诊公告', showLeftIcon: true, showRightIcon: false})
Tabs({
index: this.activeIndex
}) {
ForEach(TabBarItems, (item: TabBarCompModel, index: number) => {
TabContent() {
if (index==0)
{
StopNoticeComp({stopnum:this.stopnum})
}
else if(index==1)
{
ArrangementsComp()
}
}
.tabBar(this.TabBarBuilder(item, index))
})
}
.layoutWeight(1)
.divider({ strokeWidth: $r('app.float.common_border_width'), color: $r('app.color.common_gray_border') })
.barPosition(BarPosition.Start)
.barHeight(50)
.scrollable(false)
.onTabBarClick((index) => {
this.activeIndex = index
if (index==0)
{
this.textInfo='发布新的停诊'
}
else if(index==1)
{
this.textInfo='增加门诊安排'
}
})
Column()
{
Text(this.textInfo).height(42).width(168).fontSize(17)
.backgroundColor($r('app.color.top_title'))
.fontColor($r('app.color.white'))
.textAlign(TextAlign.Center)
.borderRadius(4)
.margin({top:8})
}
.width('100%')
.height(57)
.backgroundColor(Color.White)
.onClick(() => {
if (this.activeIndex==0)
{
if(this.stopnum==2)
{
promptAction.showToast({ message: "有效停诊公告最多只能两个", duration: 1000 })
}
else
{
HMRouterMgr.push({ pageUrl: 'ReleaseOutpatient' })
}
}
else if(this.activeIndex==1)
{
HMRouterMgr.push({ pageUrl: 'AddOutpatient' })
}
})
}
Image($r('app.media.send_feed')).width(50).height(50)
.alignRules({
right: { anchor: "__container__", align: HorizontalAlign.End },
bottom:{ anchor: "__container__", align:VerticalAlign.Bottom}
})
.margin({bottom:100,right:30})
.onClick(() => {
HMRouterMgr.push({ pageUrl: 'OutpatientInformation' , param: {
note:this.note,
uuid:this.uuid
} })
})
}
}
mailanNoticeGet() {
const hashMap: HashMap<string, string> = new HashMap();
hdHttp.httpReq<string>(BasicConstant.mailanNoticeGet,hashMap).then(async (res: HdResponse<string>) => {
let json:PatientNoticeModel = JSON.parse(res+'') as PatientNoticeModel;
if(json.code == '200') {
this.uuid=json.data.uuid
this.note=json.data.notice
} else {
}
}).catch((err: BusinessError) => {
console.info(`Response fails: ${err}`);
})
}
}
export const TabBarItems: TabBarCompModel[] = [
{
label: '停诊公告'
},
{
label: '门诊安排'
}
]