harmony/features/register/src/main/ets/view/PerfectUserDataComp.ets
2025-05-20 14:04:04 +08:00

362 lines
13 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 { BasicConstant,ExpertData, authStore,perfactAuth } from '@itcast/basic'
import { promptAction, router } from '@kit.ArkUI'
import { EditUserDataItem } from 'mypage/src/main/ets/view/EditUserDataItem'
import { PerfactInputSheet } from '@itcast/basic/src/main/ets/Views/PerfactInputSheet'
import { PhotoActionSheet } from '@itcast/basic/src/main/ets/Views/PhotoActionSheet'
import { SexSelectedSheet } from '@itcast/basic/src/main/ets/Views/SexSelectedSheet'
import { OfficeSelectedSheet } from '@itcast/basic/src/main/ets/Views/OfficeSelectedSheet'
import { PositionSelectedSheet } from '@itcast/basic/src/main/ets/Views/PositionSelectedSheet'
import { SpecialitySelectedSheet } from '@itcast/basic/src/main/ets/Views/SpecialitySelectedSheet'
import { emitter } from '@kit.BasicServicesKit'
interface extraData {
uuid: string
}
interface updateExtraData {
uuid: string,
userName: string,
birthDate: string,
type: string,
photo: string,
certificateImg: string,
positionUuid: string,
officeUuid: string,
officeName: string,
diseaseUuids: string
}
interface callBackData {
expert:ExpertData,
code:number,
message:string,
specialy:[],
data:ExpertData,
special:[]
}
@Component
export struct PerfectUserDataComp {
scroller: Scroller = new Scroller();
@Prop loginPhone:string = '13419527489';
@State photoPath:string = BasicConstant.urlImage+authStore.getUser().photo;
@State name:string = perfactAuth.getUser('13419527489').realName?perfactAuth.getUser('13419527489').realName:'请输入姓名';
@State sex:string = perfactAuth.getUser('13419527489').sex?perfactAuth.getUser('13419527489').sex == 0 ? '男' : '女':'请选择性别';
@State sexnum:number = perfactAuth.getUser('13419527489').sex;
@State hospatilName:string = perfactAuth.getUser('13419527489').hospitalName?'':'请选择所在医院';
@State officeName:string = perfactAuth.getUser('13419527489').officeName?perfactAuth.getUser('13419527489').officeName.length>0?perfactAuth.getUser('13419527489').officeName:'请选择科室':'请选择科室';
@State officeUuid:string = perfactAuth.getUser('13419527489').officeUuid;
@State officePhone:string = authStore.getUser().officePhone?perfactAuth.getUser('13419527489').officePhone.length?perfactAuth.getUser('13419527489').officePhone:'请输入所在科室的电话':'请输入所在科室的电话';
@State positionName:string = authStore.getUser().positionName?perfactAuth.getUser('13419527489').positionName.length>0?perfactAuth.getUser('13419527489').positionName:'请选择职称':'请选择职称';
@State positionUuid:string = authStore.getUser().positionUuid;
@State certificate:string = authStore.getUser().certificate?perfactAuth.getUser('13419527489').certificate.length>0?perfactAuth.getUser('13419527489').certificate:'请输入执业医师证号码':'请输入执业医师证号码';
@State certificatePhoto:string = BasicConstant.urlImage+perfactAuth.getUser('13419527489').certificateImg;
// @State diseaseName:string = authStore.getUser().diseaseName?authStore.getUser().diseaseName.length>0?authStore.getUser().diseaseName:'请选择专长':'请选择专长';
// @State diswaseUuid:string = authStore.getUser().diseaseName;
@State diseaseName:string = '请选择专长';
@State diswaseUuid:string = '';
@State inputTitle:string = '';
@State inputPlaceholder:string = '';
private photoSheetDialog!: CustomDialogController;
private officePickerDialog!: CustomDialogController;
private positionPickerDialog!: CustomDialogController;
private certificatePhotoSheetDialog!: CustomDialogController;
private diseaseSheetDialog!:CustomDialogController;
private sexSheetDilog!:CustomDialogController;
private perfactInputSheet!:CustomDialogController;
aboutToAppear() {
this.initSexDialog();
this.initPhotoDialog();
this.initPerfactInputDialog();
this.initOfficePickerDialog();
this.initPositionPickerDialog();
this.initCerficatePhotoDialog();
this.initDiseaseSheetDIalog();
authStore.initUser()
emitter.on({ eventId: 250516 }, () => {
this.handleSave()
})
}
aboutToDisappear() {
emitter.off(250516)
}
private handleSave() {
promptAction.showToast({ message: '您输入的个人资料已经保存,请完善所有信息后提交审核', duration: 1000 })
const userData:ExpertData = {
positionName: this.positionName='请选择职称'?'':this.positionName,
userName: this.loginPhone,
createDate: '',
password: '',
officeName: this.officeName='请选择科室'?'':this.officeName,
certificateImg: this.certificatePhoto,
birthDate: '',
isStar: 0,
countyId: 0,
cityId: 0,
email: '',
photo: this.photoPath,
qrcode: '',
mobile: this.loginPhone,
hospitalName: '',
officeUuid: this.officeUuid,
checkInfo: '',
hospitalUuid: '',
officePhone: this.officePhone='请输入所在科室的电话'?'':this.officePhone,
positionUuid: this.positionUuid,
sex: this.sexnum,
provId: 0,
certificate: this.certificate='请输入执业医师证号码'?'':this.certificate,
realName: this.name,
isEnable: 0,
isVisit: 0,
modifyDate: '',
currentSpec: '',
deviceType: 0,
currentType: 0,
deviceSpec: '',
nation: 0,
wechat_qrcode: '',
uuid: '',
intro: '',
state: 0,
specialy: [],
diseaseName:this.diseaseName='请选择专长'?'':this.diseaseName,
diseaseUuid:this.diswaseUuid
};
perfactAuth.setUser('13419527489',userData);
console.info('个人资料=name',perfactAuth.getUser('13419527489').realName,'\n科室:',perfactAuth.getUser('13419527489').positionName);
}
initSexDialog(){
this.sexSheetDilog = new CustomDialogController({
builder:SexSelectedSheet({
controller:this.sexSheetDilog,
sexSelected:(index: number)=>{
this.sex = index == 0 ? '男' : '女';
this.sexnum = index;
}
}),
alignment: DialogAlignment.Bottom,
customStyle: true,
autoCancel: false,
backgroundColor: ('rgba(0,0,0,0.5)'),
height: '100%'
})
}
initPerfactInputDialog() {
this.perfactInputSheet = new CustomDialogController({
builder:PerfactInputSheet({
controller:this.perfactInputSheet,
inputTitle:this.inputTitle,
inputPlaceholder:this.inputPlaceholder,
inputCallBack:(input: string,title:string)=>{
if (title == '请输入姓名') {
this.name = input;
} else if (title == '请输入所在科室电话') {
this.officePhone = input;
} else if (title == '请输入执业医师资格证号码') {
this.certificate = input;
}
}
}),
keyboardAvoidDistance: {value:-2000} as LengthMetrics, // 设置弹窗底部与键盘顶部间距单位vp
alignment: DialogAlignment.Bottom,
customStyle: true,
autoCancel: false,
backgroundColor: ('rgba(0,0,0,0.5)'),
height: '100%'
})
}
private initPhotoDialog() {
this.photoSheetDialog = new CustomDialogController({
builder: PhotoActionSheet({
controller: this.photoSheetDialog,
onPhotoSelected: async (uri: string) => {
this.photoPath = uri;
}
}),
alignment: DialogAlignment.Bottom,
customStyle: true,
autoCancel: false,
backgroundColor: ('rgba(0,0,0,0.5)'),
height: '100%'
});
}
private initOfficePickerDialog() {
this.officePickerDialog = new CustomDialogController({
builder:OfficeSelectedSheet({
controller:this.officePickerDialog,
officeSelected: (name:string , uuid:string) => {
this.officeName = name;
this.officeUuid = uuid;
}
}),
alignment: DialogAlignment.Bottom,
customStyle: true,
autoCancel: false,
backgroundColor: ('rgba(0,0,0,0.5)'),
height: '100%'
})
}
private initPositionPickerDialog() {
this.positionPickerDialog = new CustomDialogController({
builder:PositionSelectedSheet({
controller:this.officePickerDialog,
officeSelected: (name:string , uuid:string) => {
this.positionName = name;
this.positionUuid = uuid;
}
}),
alignment: DialogAlignment.Bottom,
customStyle: true,
autoCancel: false,
backgroundColor: ('rgba(0,0,0,0.5)'),
height: '100%'
})
}
private initCerficatePhotoDialog() {
this.certificatePhotoSheetDialog = new CustomDialogController({
builder: PhotoActionSheet({
controller: this.certificatePhotoSheetDialog,
onPhotoSelected: (url: string) => {
this.certificatePhoto = url;
console.log('Selected image URI:', url);
}
}),
alignment: DialogAlignment.Bottom,
customStyle: true,
autoCancel: false,
backgroundColor: ('rgba(0,0,0,0.5)'),
height: '100%'
});
}
private initDiseaseSheetDIalog() {
this.diseaseSheetDialog = new CustomDialogController({
builder: SpecialitySelectedSheet({
controller:this.diseaseSheetDialog,
specialitySelected: (diseaseUuids:string,diseaseName:string)=>{
this.diseaseName = diseaseName;
this.diswaseUuid = diseaseUuids;
}
}),
alignment: DialogAlignment.Bottom,
customStyle: true,
autoCancel: false,
backgroundColor: ('rgba(0,0,0,0.5)'),
height: '100%'
})
}
build() {
Scroll(this.scroller) {
Column() {
// 基本信息字段
EditUserDataItem({ label: '头像', required: false, content: this.photoPath, hasArrow: true, isLine:false })
.backgroundColor(Color.White)
.onClick(()=>this.photoSheetDialog.open())
EditUserDataItem({ label: '姓名', required: false, content: this.name, hasArrow:true, isLine:false })
.backgroundColor(Color.White)
.margin({top:8})
.onClick(()=>{
this.inputTitle = '请输入姓名';
this.inputPlaceholder = this.name;
this.perfactInputSheet.open()
})
EditUserDataItem({ label: '性别', required: false, content: this.sex, hasArrow:true, isLine:false })
.backgroundColor(Color.White)
.margin({top:8})
.onClick(()=>this.sexSheetDilog.open())
EditUserDataItem({ label: '医院', required: false, content: this.hospatilName, hasArrow: true, isLine:false })
.backgroundColor(Color.White)
.margin({top:8})
.onClick(()=> {
router.pushUrl({
url: 'pages/LoginPage/SelectedHospitalPage'
})
})
EditUserDataItem({ label: '科室', required: false, content: this.officeName, hasArrow: true, isLine:false })
.backgroundColor(Color.White)
.margin({top:8})
.onClick(()=>this.officePickerDialog.open())
EditUserDataItem({ label: '科室电话', required: false, content: this.officePhone, hasArrow: true, isLine:false })
.backgroundColor(Color.White)
.margin({top:8})
.onClick(()=>{
this.inputTitle = '请输入所在科室电话';
this.inputPlaceholder = this.officePhone;
this.perfactInputSheet.open()
})
EditUserDataItem({ label: '职称', required: false, content: this.positionName, hasArrow: true, isLine:false })
.backgroundColor(Color.White)
.margin({top:8})
.onClick(()=>this.positionPickerDialog.open())
EditUserDataItem({ label: '执业医师证编号', required: false, content: this.certificate ,hasArrow: true, isLine:false })
.backgroundColor(Color.White)
.margin({top:8})
.onClick(()=>{
this.inputTitle = '请输入执业医师资格证号码';
this.inputPlaceholder = this.certificate;
this.perfactInputSheet.open()}
)
EditUserDataItem({ label: '执业医师证图片或胸牌', required: false, content: this.certificatePhoto, hasArrow: true, isLine:false })
.backgroundColor(Color.White)
.margin({top:8})
.onClick(()=>this.certificatePhotoSheetDialog.open())
EditUserDataItem({ label: '专长(可选一到十项)', required: false, content: this.diseaseName , hasArrow: true, isLine:false })
.backgroundColor(Color.White)
.margin({top:8})
.onClick(()=>this.diseaseSheetDialog.open())
Column() {
// 登录按钮
Button({type:ButtonType.Normal}){
Text('提交')
}
.width('95%')
.height(48)
.borderRadius(8)
.backgroundColor($r('app.color.main_color'))
.fontColor('#FFFFFF')
.fontSize(18)
.position({x:'2.5%'})
.onClick(() => {
// 提交逻辑
router.pushUrl({
url: 'pages/LoginPage/SelectedHospitalPage'
})
})
}
.width('100%')
.height(48)
.margin({top:50})
}
.width('100%')
.height('100%')
.padding(8)
.backgroundImage($r('app.media.bg_reg'))
.backgroundImageSize(ImageSize.FILL)
}
.height('auto')
.scrollable(ScrollDirection.Vertical)
.scrollBar(BarState.Off)
.backgroundColor('#ffffff')
}
}
function handleSave() {
}