harmony/features/netease/src/main/ets/components/ItemCompArrange.ets
2025-08-01 17:18:36 +08:00

262 lines
6.8 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { HMRouterMgr } from '@hadss/hmrouter';
import { BasicConstant, TimestampUtil } from '@itcast/basic';
import { formatDate } from '@itcast/basic/src/main/ets/utils/DateUtils';
import { PerfactInputSheet } from '@itcast/basic/src/main/ets/Views/PerfactInputSheet';
import { LengthMetrics, router } from '@kit.ArkUI'
import { StringIsEmpty } from '@nimkit/common';
import { ListOut } from '../model/ListOutPatientModel';
@Preview
@Component
export struct ItemCompArrange {
@Prop item:ListOut;
@State week:string=''
@State outpatientType:string=''
@State daytime:string=''
@Link deleteUuid:string
@Link delete: boolean
deleteCallBack: (uuid:string) => void = () => {};
onChangeEvent?: (change: boolean) => void; // 声明回调函数
@State lineHeight:Length=10;
aboutToAppear(): void {
this.initDialog()
this.getWeek()
this. getoutpatientType()
this.getdayTime()
}
private dialog!:CustomDialogController;
@State inputPlaceholder:string='您确定删除此条信息吗'
initDialog() {
this.dialog = new CustomDialogController({
builder:PerfactInputSheet({
controller:this.dialog,
inputTitle:'删除提示',
inputPlaceholder:this.inputPlaceholder,
style:'2',
okText:'确定',
okColor:$r('app.color.top_title'),
inputCallBack:(input: string,title:string)=>{
if(this.inputPlaceholder=='您确定修改此条信息吗')
{
HMRouterMgr.push({
pageUrl: 'AddOutpatient',
param: {
item: this.item, isHistory: 'true'
}
},
{
onResult: (popInfo: PopInfo) => {
const result = JSON.parse(String(popInfo.result)) as boolean
this.onChangeEvent?.(result); // 触发回调并传参
}
}
)
}
else
{
this.deleteUuid=this.item.uuid
this.delete=!this.delete
}
}
}),
keyboardAvoidDistance: LengthMetrics.vp(0), // 设置弹窗底部与键盘顶部间距单位vp
alignment: DialogAlignment.Center,
customStyle: true,
autoCancel: false,
backgroundColor: ('rgba(0,0,0,0.5)'),
height: '100%'
})
}
build() {
Column()
{
Row()
{
Column() {
Text(this.week)
.fontColor($r('app.color.top_title'))
.fontSize(15)
.width(100)
.textAlign(TextAlign.Center)
Text(this.daytime)
.width(100)
.fontColor($r('app.color.common_gray_03')).padding({ top: 10 })
.fontSize(15)
.textAlign(TextAlign.Center)
}
.width(100)
.backgroundColor(Color.White)
.borderRadius({
topLeft: 4,
topRight: 0,
bottomRight: 0,
bottomLeft: 4
})
.justifyContent(FlexAlign.Center) // 垂直居中
.alignItems(HorizontalAlign.Center) // 子组件水平居中
.height(this.lineHeight)
Column() {
Text(this.item.hospital_name)
.fontColor($r('app.color.common_gray_01'))
.fontSize(18)
.margin({top:10})
Text(this.item.office_name)
.fontColor($r('app.color.common_gray_03'))
.fontSize(14)
.margin({top:10})
Flex({ direction: FlexDirection.Row, wrap: FlexWrap.Wrap, space: { cross: LengthMetrics.vp(10) } })
{
Text(this.item.location) .fontColor($r('app.color.common_gray_03')).fontSize(14).maxLines(1).textOverflow({ overflow: TextOverflow.Ellipsis })
.ellipsisMode(EllipsisMode.END)
.padding({right:3})
Text(this.outpatientType)
.fontSize(12)
.borderColor($r('app.color.top_title'))
.fontColor($r('app.color.top_title'))
.borderRadius(8)
.borderWidth(1)
.padding({ left: 4,right:4,top:2,bottom:2 })
}
.margin({top:10})
}
.padding({left:10,right:10,bottom:10})
.alignItems(HorizontalAlign.Start)
.layoutWeight(1)
.borderRadius({
topLeft: 0,
topRight: 4,
bottomRight: 0,
bottomLeft: 4
})
.margin({left:2})
.backgroundColor(Color.White)
.onAreaChange((oldVal, newVal) => {
this.lineHeight = newVal.height
})
}
.width('95%')
// .padding(10)
.alignSelf(ItemAlign.Center)
// .backgroundColor(Color.White)
.borderRadius(4)
.margin({left:10,right:10})
Row()
{
Blank()
Row()
{
Image($r('app.media.edit_icon')).width(15).height(15).margin({right:5})
Text('编辑')
.fontColor($r('app.color.common_gray_01'))
.fontSize(14)
}
.margin({right:30})
.onClick(()=>{
this.inputPlaceholder='您确定修改此条信息吗'
this.dialog.open()
})
Row()
{
Image($r('app.media.delete_icon')).width(15).height(15).margin({right:5})
Text('删除')
.fontColor($r('app.color.common_gray_01'))
.fontSize(14)
}
.onClick(()=>{
this.inputPlaceholder='您确定删除此条信息吗'
this.dialog.open()
})
}.width('95%')
.padding(10)
.backgroundColor(Color.White)
.margin({top:2})
.borderRadius(4)
}
}
getWeek() {
switch (this.item.week) {
case 1:
this.week = '周一'
break
case 2:
this.week = '周二'
break
case 3:
this.week = '周三'
break
case 4:
this.week = '周四'
break
case 5:
this.week = '周五'
break
case 6:
this.week = '周六'
break
case 7:
this.week = '周日'
break
}
}
getoutpatientType()
{
switch (this.item.type)
{
case 1:
this.outpatientType='普通门诊'
break
case 2:
this.outpatientType='专家门诊'
break
case 3:
this.outpatientType='特需门诊'
break
case 4:
this.outpatientType='专科/专病门诊'
break
}
}
getdayTime()
{
switch (this.item.day)
{
case "a":
this.daytime='上午'
break
case "b":
this.daytime='下午'
break
case "c":
this.daytime='晚上'
break
case "d":
this.daytime='全天'
break
}
}
}