注册资料
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
type DateFormat = 'YYYY-MM-DD' | 'MM/DD/YYYY' | 'DD-MMM-YYYY' | 'YYYY年MM月DD日' | 'YYYYMMDD';
|
||||
|
||||
export function formatDate(date: Date,pattern:DateFormat = 'YYYY-MM-DD'): string {
|
||||
const padZero = (num: number): string => num.toString().padStart(2, '0');
|
||||
const year = date.getFullYear();
|
||||
const month = padZero(date.getMonth() + 1); // 月份修正[7,8](@ref)
|
||||
const day = padZero(date.getDate());
|
||||
|
||||
// 模式映射逻辑(核心补全部分)
|
||||
switch (pattern) {
|
||||
case 'YYYY-MM-DD':
|
||||
return `${year}-${month}-${day}`;
|
||||
case 'MM/DD/YYYY':
|
||||
return `${month}/${day}/${year}`;
|
||||
case 'DD-MMM-YYYY':
|
||||
const months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
|
||||
return `${day}-${months[date.getMonth()]}-${year}`; // 月份缩写处理[4](@ref)
|
||||
case 'YYYY年MM月DD日':
|
||||
return `${year}年${month}月${day}日`; // 中文格式[5](@ref)
|
||||
case 'YYYYMMDD':
|
||||
return `${year}${month}${day}`; // 紧凑格式
|
||||
default:
|
||||
throw new Error(`Unsupported format pattern: ${pattern}`);
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
import { formatDate } from '../util/DateUtils'
|
||||
import { authStore } from '@itcast/basic'
|
||||
|
||||
@CustomDialog
|
||||
export struct DatePickerDialog {
|
||||
@Prop selectedDateString:string = formatDate(new Date(),'YYYY-MM-DD');
|
||||
controller: CustomDialogController;
|
||||
|
||||
// 添加回调函数属性
|
||||
private dateSelected: (date: string) => void = () => {};
|
||||
|
||||
// 修改构造函数
|
||||
constructor(controller: CustomDialogController, dateSelected: (date: string) => void) {
|
||||
super();
|
||||
this.controller = controller;
|
||||
this.dateSelected = dateSelected;
|
||||
}
|
||||
|
||||
// 初始化日期范围(示例为1930-至今)
|
||||
private dateOptions: DatePickerOptions = {
|
||||
start: new Date('1930-01-01'),
|
||||
end: new Date(this.selectedDateString),
|
||||
selected: new Date(authStore.getUser().birthDate?authStore.getUser().birthDate:'1930-01-01'),
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
// 操作按钮区域
|
||||
Row({space:70}) {
|
||||
Button('取消')
|
||||
.layoutWeight(1)
|
||||
.backgroundColor(Color.Transparent)
|
||||
.fontColor($r('app.color.main_color'))
|
||||
.backgroundColor(Color.White)
|
||||
.width(80)
|
||||
.onClick(() => {
|
||||
this.controller.close()
|
||||
})
|
||||
|
||||
Text('请选择出生日期')
|
||||
.fontSize(15)
|
||||
.fontColor('#666666')
|
||||
|
||||
Button('确定')
|
||||
.layoutWeight(1)
|
||||
.backgroundColor(Color.Transparent)
|
||||
.fontColor($r('app.color.main_color'))
|
||||
.backgroundColor(Color.White)
|
||||
.width(80)
|
||||
.onClick(() => {
|
||||
this.controller.close()
|
||||
this.dateSelected(this.selectedDateString)
|
||||
})
|
||||
}
|
||||
.height(40)
|
||||
|
||||
// 日期选择器主体
|
||||
DatePicker(this.dateOptions)
|
||||
.lunar(false) // 禁用农历显示[1](@ref)
|
||||
.selectedTextStyle({
|
||||
color: '#007AFF',
|
||||
font: { size: 20, weight: FontWeight.Medium }
|
||||
})
|
||||
.onDateChange((selected:Date)=>{
|
||||
this.selectedDateString = formatDate(selected,'YYYY-MM-DD');
|
||||
console.info('select current date is: ' + formatDate(selected,'YYYY-MM-DD'));
|
||||
})
|
||||
}
|
||||
.width('100%')
|
||||
.height(240)
|
||||
.backgroundColor(Color.White)
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,12 @@ import { hdHttp, HdResponse,BasicConstant,ExpertData, authStore, ChangeUtil } f
|
||||
import HashMap from '@ohos.util.HashMap'
|
||||
import { BusinessError } from '@kit.BasicServicesKit';
|
||||
import { promptAction, router } from '@kit.ArkUI'
|
||||
import { EditUserDataItem } from './EditUserDataItem'
|
||||
import { PhotoActionSheet } from './PhotoActionSheet'
|
||||
import { DatePickerDialog } from './DatePickerDialog'
|
||||
import { OfficeSelectedSheet } from './OfficeSelectedSheet'
|
||||
import { PositionSelectedSheet } from './PositionSelectedSheet'
|
||||
import { SpecialitySelectedSheet } from './SpecialitySelectedSheet'
|
||||
import { EditUserDataItem } from '@itcast/basic/src/main/ets/Views/EditUserDataItem'
|
||||
import { PhotoActionSheet } from '@itcast/basic/src/main/ets/Views/PhotoActionSheet'
|
||||
import { DatePickerDialog } from '@itcast/basic/src/main/ets/Views//DatePickerDialog'
|
||||
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 { http } from '@kit.NetworkKit';
|
||||
import { rcp } from '@kit.RemoteCommunicationKit';
|
||||
interface extraData {
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
@Component
|
||||
export struct EditUserDataItem {
|
||||
private label: string = ''
|
||||
private required: boolean = false
|
||||
@Prop content: string = ''
|
||||
private hasArrow: boolean = false
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
Row() {
|
||||
Row() {
|
||||
Text(this.label)
|
||||
.fontSize(16)
|
||||
.fontColor('#333333')
|
||||
.margin({ left: 15 })
|
||||
if (this.required) {
|
||||
Text('*')
|
||||
.margin({ left: 0 })
|
||||
.fontSize(16)
|
||||
.fontColor($r('app.color.main_color'))
|
||||
}
|
||||
}
|
||||
.layoutWeight(1)//权重自定义
|
||||
.justifyContent(FlexAlign.Start)
|
||||
|
||||
Row({space:5}) {
|
||||
if (this.label == '头像') {
|
||||
Image(this.content)
|
||||
.alt($r('app.media.userPhoto_default'))
|
||||
.onComplete(() => console.log('图片加载完成'))
|
||||
.onError(() => console.error('图片加载失败'+this.content))
|
||||
.width(40)
|
||||
.height(40)
|
||||
.margin({ right: this.hasArrow?0:10 })
|
||||
.borderRadius(8)
|
||||
} else if (this.label == '执业医师证图片或胸牌') {
|
||||
Image(this.content)
|
||||
.onComplete(() => console.log('图片加载完成'))
|
||||
.onError(() => console.error('图片加载失败'+this.content))
|
||||
.width(60)
|
||||
.height(40)
|
||||
.margin({ right: this.hasArrow?0:10 })
|
||||
} else {
|
||||
Text(this.content)
|
||||
.fontSize(14)
|
||||
.fontColor('#333333')
|
||||
.width('60%')
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
.maxLines(1)
|
||||
.margin({right: this.hasArrow?0:10 })
|
||||
.textAlign(TextAlign.End)
|
||||
}
|
||||
if (this.hasArrow) {
|
||||
Image($r('sys.media.ohos_ic_public_arrow_right'))
|
||||
.width(15)
|
||||
.height(15)
|
||||
.margin({ right: 10 })
|
||||
}
|
||||
}
|
||||
.justifyContent(FlexAlign.End)
|
||||
}
|
||||
.height(50)
|
||||
.alignItems(VerticalAlign.Center)
|
||||
|
||||
Divider()
|
||||
.color('#F4F4F4')
|
||||
.strokeWidth(1)
|
||||
.height(1)
|
||||
.margin({ left: 10, top: 0 })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { hdHttp, HdResponse,BasicConstant,ExpertData, authStore,RequestDefaultModel } from '@itcast/basic'
|
||||
import { BusinessError } from '@kit.BasicServicesKit';
|
||||
import { HeroPopWindow } from '../view/HeroPopWindow'
|
||||
import { HeroPopWindow } from '@itcast/basic/src/main/ets/Views/HeroPopWindow'
|
||||
import HashMap from '@ohos.util.HashMap'
|
||||
import { router } from '@kit.ArkUI'
|
||||
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
import { hdHttp, HdResponse,BasicConstant, logger,RequestDefaultModel, Data } from '@itcast/basic'
|
||||
import { promptAction } from '@kit.ArkUI'
|
||||
import HashMap from '@ohos.util.HashMap';
|
||||
import { BusinessError } from '@kit.BasicServicesKit';
|
||||
import { authStore } from '@itcast/basic'
|
||||
|
||||
interface DefaultData {
|
||||
|
||||
}
|
||||
|
||||
@CustomDialog
|
||||
export struct HeroPopWindow {
|
||||
@Prop heroId:string = '';
|
||||
@State detailsData:object = new Object;
|
||||
private years: string[] = ['2019年英雄榜','2018年英雄榜','2017年英雄榜','2016年英雄榜','2015年英雄榜'];
|
||||
controller: CustomDialogController;
|
||||
|
||||
heroDetailsRequestUrl:string = BasicConstant.urlExpertAPI+'gethonorDetail'
|
||||
hashMap: HashMap<string, string> = new HashMap();
|
||||
|
||||
updateHeroDetailsAction(){
|
||||
this.hashMap.set('id',this.heroId);
|
||||
hdHttp.httpReq<string>(this.heroDetailsRequestUrl,this.hashMap).then(async (res: HdResponse<string>) => {
|
||||
let json:RequestDefaultModel = JSON.parse(res+'') as RequestDefaultModel;
|
||||
if(json.code=='1') {
|
||||
this.detailsData = json.data;
|
||||
} else {
|
||||
console.error('英雄榜失败:'+json.message)
|
||||
promptAction.showToast({ message: json.message, duration: 1000 })
|
||||
}
|
||||
}).catch((err: BusinessError) => {
|
||||
console.info(`Response fail: ${err}`);
|
||||
})
|
||||
}
|
||||
|
||||
build() {
|
||||
Stack() {
|
||||
//半透明黑色背景
|
||||
Column().width('100%').height('100%').backgroundColor('#50000000')
|
||||
|
||||
//弹窗主体
|
||||
Column() {
|
||||
//头部图标
|
||||
Image($r('app.media.heroPop_headericon'))
|
||||
.width(80)
|
||||
.height(80)
|
||||
.margin({top:-25})
|
||||
.zIndex(2)
|
||||
//标题和正文范围
|
||||
Column() {
|
||||
Text('肝胆英雄榜')
|
||||
.fontSize(20)
|
||||
.fontColor('#673986')
|
||||
.margin({top:20})
|
||||
Grid() {
|
||||
ForEach(this.years,(item:string)=>{
|
||||
GridItem({style:GridItemStyle.PLAIN}) {
|
||||
Text(item)
|
||||
.fontSize(10)
|
||||
.fontColor(Color.Black)
|
||||
.backgroundColor(Color.White) // 添加背景色确保可见
|
||||
.textAlign(TextAlign.Center)
|
||||
.width('100%') // 确保文本容器宽度
|
||||
}
|
||||
.height(20)
|
||||
.width('48%')
|
||||
.padding(5)
|
||||
.borderRadius(10)
|
||||
.borderWidth(1)
|
||||
.borderColor(Color.Red)
|
||||
})
|
||||
}
|
||||
.columnsGap(10)
|
||||
.rowsGap(10)
|
||||
.padding(10)
|
||||
.width('100%')
|
||||
.height('auto')
|
||||
Text('感谢有您,一路相伴。"肝胆英雄榜"是由国内最具影响力的肝胆病互联网线上服务平台-\n' +
|
||||
'肝胆相照依据肝胆病医生在各自领域年度所做工作,综合评选出来的最认可的"肝胆好医生",授予证书并赠送精美感恩好礼。\n' +
|
||||
'目前"肝胆英雄榜"荣誉包括:"护肝大使"护肝新量""公益之星""科普达入"、"视频之星"、"人气科室"及"宣传之星"等。')
|
||||
.fontSize(12)
|
||||
.fontColor('#666666')
|
||||
.textAlign(TextAlign.Start)
|
||||
.lineHeight(20)
|
||||
.width('90%')
|
||||
.margin({bottom:10})
|
||||
}
|
||||
.zIndex(1)
|
||||
.margin({top:-10,bottom:10})
|
||||
.justifyContent(FlexAlign.Center)
|
||||
.backgroundColor(Color.White)
|
||||
.borderRadius(16)
|
||||
.height('auto')
|
||||
.width('90%')
|
||||
|
||||
//删除按钮
|
||||
Button() {
|
||||
Image($r('app.media.heropop_delete'))
|
||||
.width(30)
|
||||
.height(30)
|
||||
}
|
||||
.zIndex(3)
|
||||
.position({ x: '88%', y: 10 })
|
||||
.onClick(() => this.controller.close())
|
||||
}
|
||||
.width('90%')
|
||||
.backgroundImage($r('app.media.heroPop_bg'))
|
||||
.backgroundImageSize(ImageSize.Cover)
|
||||
.borderRadius(16)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
import { hdHttp, HdResponse,BasicConstant, logger,RequestDefaultModel, Data } from '@itcast/basic'
|
||||
import { promptAction } from '@kit.ArkUI'
|
||||
import HashMap from '@ohos.util.HashMap';
|
||||
import { BusinessError } from '@kit.BasicServicesKit';
|
||||
import { authStore } from '@itcast/basic'
|
||||
|
||||
interface DefaultData {
|
||||
'officeName':string;
|
||||
'officeUuid':string;
|
||||
}
|
||||
|
||||
@CustomDialog
|
||||
export struct OfficeSelectedSheet {
|
||||
controller: CustomDialogController;
|
||||
@State officeNameArr:Array<string> = [];
|
||||
private officeArr:Array<DefaultData> = [];
|
||||
@State selectedModel:DefaultData = { officeName: '', officeUuid: '' };
|
||||
|
||||
@State selectedIndex:number = 0;
|
||||
|
||||
// 添加回调函数属性
|
||||
private officeSelected: (name:string , uuid:string) => void = () => {};
|
||||
|
||||
// 修改构造函数
|
||||
constructor(controller: CustomDialogController, officeSelected: (name: string,uuid:string) => void) {
|
||||
super();
|
||||
this.controller = controller;
|
||||
this.officeSelected = officeSelected;
|
||||
}
|
||||
|
||||
officeRequestUrl:string = BasicConstant.urlExpert+'officeList'
|
||||
hashMap: HashMap<string, string> = new HashMap();
|
||||
|
||||
aboutToAppear(): void {
|
||||
this.uploadOffice();
|
||||
}
|
||||
|
||||
uploadOffice() {
|
||||
hdHttp.httpReq<string>(this.officeRequestUrl,this.hashMap).then(async (res: HdResponse<string>) => {
|
||||
let json:RequestDefaultModel = JSON.parse(res+'') as RequestDefaultModel;
|
||||
if(json.code=='1') {
|
||||
this.officeArr = json.data as DefaultData[];
|
||||
this.officeNameArr = json.data.map(item => item.officeName);
|
||||
console.log('科室名称数组:', this.officeNameArr);
|
||||
for (let index = 0; index < this.officeNameArr.length; index++) {
|
||||
const officeObject = this.officeArr[index] as DefaultData;
|
||||
const name = this.officeNameArr[index];
|
||||
if (name == authStore.getUser().officeName) {
|
||||
this.selectedIndex = index;
|
||||
this.selectedModel = {officeName:name,officeUuid:officeObject.officeUuid}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.error('科室数据失败:'+json.message)
|
||||
promptAction.showToast({ message: json.message, duration: 1000 })
|
||||
}
|
||||
}).catch((err: BusinessError) => {
|
||||
console.info(`Response fail: ${err}`);
|
||||
})
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
// 操作按钮区域
|
||||
Row({space:70}) {
|
||||
Button('取消')
|
||||
.layoutWeight(1)
|
||||
// .backgroundColor(Color.Transparent)
|
||||
.fontColor($r('app.color.main_color'))
|
||||
.backgroundColor(Color.White)
|
||||
.width(80)
|
||||
.onClick(() => {
|
||||
this.controller.close()
|
||||
})
|
||||
|
||||
Text('请选择科室')
|
||||
.fontSize(15)
|
||||
.fontColor('#666666')
|
||||
|
||||
Button('确定')
|
||||
.layoutWeight(1)
|
||||
.fontColor($r('app.color.main_color'))
|
||||
.backgroundColor(Color.White)
|
||||
.width(80)
|
||||
.onClick(() => {
|
||||
this.controller.close()
|
||||
this.officeSelected(this.selectedModel.officeName, this.selectedModel.officeUuid);
|
||||
})
|
||||
}
|
||||
.height(40)
|
||||
|
||||
TextPicker({
|
||||
range:this.officeNameArr,
|
||||
selected:this.selectedIndex
|
||||
})
|
||||
.selectedTextStyle({
|
||||
color: '#007AFF',
|
||||
font: { size: 20, weight: FontWeight.Medium }
|
||||
})
|
||||
.onChange((name: string | string[], index: number | number[]) => {
|
||||
// 处理单列选择场景
|
||||
if (typeof index === "number" && this.officeArr[index]) {
|
||||
this.selectedModel = this.officeArr[index];
|
||||
}
|
||||
})
|
||||
}
|
||||
.width('100%')
|
||||
.height(240)
|
||||
.backgroundColor(Color.White)
|
||||
}
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
import picker from '@ohos.file.picker';
|
||||
import { BusinessError } from '@ohos.base';
|
||||
import photoAccessHelper from '@ohos.file.photoAccessHelper';
|
||||
import common from '@ohos.app.ability.common';
|
||||
import { cameraPicker, camera } from '@kit.CameraKit'
|
||||
import { abilityAccessCtrl } from '@kit.AbilityKit';
|
||||
|
||||
@CustomDialog
|
||||
export struct PhotoActionSheet {
|
||||
controller: CustomDialogController;
|
||||
|
||||
// 添加回调函数属性
|
||||
private onPhotoSelected: (uri: string) => void = () => {};
|
||||
|
||||
// 修改构造函数
|
||||
constructor(controller: CustomDialogController, onPhotoSelected: (uri: string) => void) {
|
||||
super();
|
||||
this.controller = controller;
|
||||
this.onPhotoSelected = onPhotoSelected;
|
||||
}
|
||||
|
||||
async checkCameraPermission(): Promise<boolean> {
|
||||
const atManager = abilityAccessCtrl.createAtManager();
|
||||
const grantStatus = await atManager.checkAccessToken(
|
||||
globalThis.abilityContext.applicationInfo.accessTokenId,
|
||||
'ohos.permission.CAMERA'
|
||||
);
|
||||
return grantStatus === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED;
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
// 操作按钮区域
|
||||
Column() {
|
||||
Row() {
|
||||
// 拍摄照片按钮
|
||||
Column() {
|
||||
Image($r('app.media.icon_camera'))
|
||||
.width(40)
|
||||
.height(40)
|
||||
Text('拍摄照片')
|
||||
.fontSize(15)
|
||||
.margin({top:10})
|
||||
.fontColor($r('app.color.main_color'))
|
||||
}
|
||||
.width('50%')
|
||||
.height(80)
|
||||
.onClick(() => {
|
||||
const context = getContext() as common.UIAbilityContext;
|
||||
const cameras = camera.getCameraManager(context).getSupportedCameras();
|
||||
cameras.forEach(device => {
|
||||
console.log('Camera type:', device.cameraPosition);
|
||||
});
|
||||
this.openSystemCamera();
|
||||
this.animateHide();
|
||||
})
|
||||
.padding(20)
|
||||
|
||||
// 相册照片按钮
|
||||
Column() {
|
||||
Image($r('app.media.ixon_album'))
|
||||
.width(40)
|
||||
.height(40)
|
||||
Text('相册照片')
|
||||
.fontSize(15)
|
||||
.margin({top:10})
|
||||
.fontColor($r('app.color.main_color'))
|
||||
}
|
||||
.width('50%')
|
||||
.height(80)
|
||||
.onClick(() => {
|
||||
this.selectPhoto();
|
||||
this.animateHide()
|
||||
})
|
||||
.padding(20)
|
||||
}
|
||||
}
|
||||
.backgroundColor(Color.White)
|
||||
|
||||
Divider()
|
||||
.color('#999999')
|
||||
.strokeWidth(5)
|
||||
.height(5)
|
||||
.margin({top:20})
|
||||
|
||||
// 取消按钮
|
||||
Button('取消')
|
||||
.width('100%')
|
||||
.height(50)
|
||||
.fontColor('#999999')
|
||||
.backgroundColor(Color.White)
|
||||
.onClick(() => this.animateHide())
|
||||
}
|
||||
.width('100%')
|
||||
.height(150)
|
||||
.backgroundColor(Color.White)
|
||||
}
|
||||
|
||||
animateHide() {
|
||||
this.controller.close();
|
||||
}
|
||||
|
||||
// 打开相机
|
||||
private async openSystemCamera() {
|
||||
try {
|
||||
const pickerProfile: cameraPicker.PickerProfile = {
|
||||
cameraPosition: camera.CameraPosition.CAMERA_POSITION_BACK,
|
||||
videoDuration: 15 // 录像时设置最大时长(秒)
|
||||
};
|
||||
|
||||
const result = await cameraPicker.pick(
|
||||
getContext(),
|
||||
[cameraPicker.PickerMediaType.PHOTO], // 可替换为VIDEO
|
||||
pickerProfile
|
||||
);
|
||||
|
||||
if (result.resultCode === 0) {
|
||||
console.log('Photo URI:', result.resultUri);
|
||||
// 处理拍摄结果
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Camera error:', error.code);
|
||||
}
|
||||
}
|
||||
|
||||
// 资源被选中回调,返回资源的信息,以及选中方式
|
||||
private selectPhoto() {
|
||||
let photoSelectOptions = new picker.PhotoSelectOptions();
|
||||
photoSelectOptions.MIMEType = picker.PhotoViewMIMETypes.IMAGE_TYPE;
|
||||
photoSelectOptions.maxSelectNumber = 1;
|
||||
|
||||
let photoViewPicker = new picker.PhotoViewPicker();
|
||||
photoViewPicker.select(photoSelectOptions)
|
||||
.then((photoSelectResult) => {
|
||||
console.info('PhotoViewPicker.select successfully, photoSelectResult uri: ' +
|
||||
JSON.stringify(photoSelectResult));
|
||||
if (photoSelectResult.photoUris && photoSelectResult.photoUris.length > 0) {
|
||||
this.onPhotoSelected(photoSelectResult.photoUris[0]);
|
||||
}
|
||||
})
|
||||
.catch((err: BusinessError) => {
|
||||
console.error('PhotoViewPicker.select failed with err: ' + err);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
import { hdHttp, HdResponse,BasicConstant,RequestDefaultModel } from '@itcast/basic'
|
||||
import { promptAction } from '@kit.ArkUI'
|
||||
import HashMap from '@ohos.util.HashMap';
|
||||
import { BusinessError } from '@kit.BasicServicesKit';
|
||||
import { authStore } from '@itcast/basic'
|
||||
|
||||
interface DefaultData {
|
||||
'name':string;
|
||||
'uuid':string;
|
||||
}
|
||||
|
||||
@CustomDialog
|
||||
export struct PositionSelectedSheet {
|
||||
controller: CustomDialogController;
|
||||
@State officeNameArr:Array<string> = [];
|
||||
private officeArr:Array<DefaultData> = [];
|
||||
@Prop selectedOffice:object = new Object;
|
||||
@State selectedModel:DefaultData = { name: '', uuid: '' };
|
||||
|
||||
@State selectedIndex:number = 0;
|
||||
|
||||
// 添加回调函数属性
|
||||
private officeSelected: (name:string , uuid:string) => void = () => {};
|
||||
|
||||
// 修改构造函数
|
||||
constructor(controller: CustomDialogController, officeSelected: (name: string,uuid:string) => void) {
|
||||
super();
|
||||
this.controller = controller;
|
||||
this.officeSelected = officeSelected;
|
||||
}
|
||||
|
||||
officeRequestUrl:string = BasicConstant.urlExpert+'positionList'
|
||||
hashMap: HashMap<string, string> = new HashMap();
|
||||
|
||||
aboutToAppear(): void {
|
||||
this.uploadOffice();
|
||||
}
|
||||
|
||||
uploadOffice() {
|
||||
hdHttp.httpReq<string>(this.officeRequestUrl,this.hashMap).then(async (res: HdResponse<string>) => {
|
||||
let json:RequestDefaultModel = JSON.parse(res+'') as RequestDefaultModel;
|
||||
if(json.code=='1') {
|
||||
this.officeArr = json.data as DefaultData[];
|
||||
this.officeNameArr = json.data.map(item => item.name);
|
||||
for (let index = 0; index < this.officeNameArr.length; index++) {
|
||||
const object = this.officeArr[index] as DefaultData;
|
||||
const nameIndex = this.officeNameArr[index];
|
||||
if (nameIndex == authStore.getUser().positionName) {
|
||||
this.selectedIndex = index;
|
||||
this.selectedModel = {name:nameIndex,uuid:object.uuid}
|
||||
}
|
||||
}
|
||||
console.log('职称名称数组:', this.officeNameArr);
|
||||
} else {
|
||||
console.error('职称数据失败:'+json.message)
|
||||
promptAction.showToast({ message: json.message, duration: 1000 })
|
||||
}
|
||||
}).catch((err: BusinessError) => {
|
||||
console.info(`Response fail: ${err}`);
|
||||
})
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
// 操作按钮区域
|
||||
Row({space:70}) {
|
||||
Button('取消')
|
||||
.layoutWeight(1)
|
||||
.backgroundColor(Color.Transparent)
|
||||
.fontColor($r('app.color.main_color'))
|
||||
.backgroundColor(Color.White)
|
||||
.width(80)
|
||||
.onClick(() => {
|
||||
this.controller.close()
|
||||
})
|
||||
|
||||
Text('请选择职称')
|
||||
.fontSize(15)
|
||||
.fontColor('#666666')
|
||||
|
||||
Button('确定')
|
||||
.layoutWeight(1)
|
||||
.backgroundColor(Color.Transparent)
|
||||
.fontColor($r('app.color.main_color'))
|
||||
.backgroundColor(Color.White)
|
||||
.width(80)
|
||||
.onClick(() => {
|
||||
this.controller.close()
|
||||
this.officeSelected(this.selectedModel.name, this.selectedModel.uuid);
|
||||
})
|
||||
}
|
||||
.height(40)
|
||||
|
||||
TextPicker({
|
||||
range:this.officeNameArr,
|
||||
selected:this.selectedIndex
|
||||
})
|
||||
.selectedTextStyle({
|
||||
color: '#007AFF',
|
||||
font: { size: 20, weight: FontWeight.Medium }
|
||||
})
|
||||
.onChange((name: string | string[], index: number | number[]) => {
|
||||
// 处理单列选择场景
|
||||
if (typeof index === "number" && this.officeArr[index]) {
|
||||
this.selectedModel = this.officeArr[index];
|
||||
}
|
||||
})
|
||||
}
|
||||
.width('100%')
|
||||
.height(240)
|
||||
.backgroundColor(Color.White)
|
||||
}
|
||||
}
|
||||
@@ -1,132 +0,0 @@
|
||||
import { hdHttp, HdResponse,BasicConstant,RequestDefaultModel } from '@itcast/basic'
|
||||
import HashMap from '@ohos.util.HashMap';
|
||||
import { promptAction } from '@kit.ArkUI'
|
||||
import { BusinessError } from '@kit.BasicServicesKit';
|
||||
|
||||
interface DefaultData {
|
||||
'name':string;
|
||||
'uuid':string;
|
||||
}
|
||||
|
||||
@CustomDialog
|
||||
export struct SpecialitySelectedSheet {
|
||||
controller: CustomDialogController;
|
||||
|
||||
@State specialityArr:Array<DefaultData> = [];
|
||||
@State specialityNameArr:Array<string> = [];
|
||||
@State selectedTags: Array<string> = [];
|
||||
|
||||
// 添加回调函数属性
|
||||
private specialitySelected: (seletedTags:string) => void = () => {};
|
||||
// 修改构造函数
|
||||
constructor(controller: CustomDialogController, specialitySelected: (seletedTags:string) => void) {
|
||||
super();
|
||||
this.controller = controller;
|
||||
this.specialitySelected = specialitySelected;
|
||||
}
|
||||
|
||||
aboutToAppear(): void {
|
||||
this.uploadSpeciality();
|
||||
}
|
||||
|
||||
uploadSpeciality() {
|
||||
const officeRequestUrl:string = BasicConstant.urlExpert+'disease'
|
||||
const hashMap: HashMap<string, string> = new HashMap();
|
||||
hdHttp.httpReq<string>(officeRequestUrl,hashMap).then(async (res: HdResponse<string>) => {
|
||||
let json:RequestDefaultModel = JSON.parse(res+'') as RequestDefaultModel;
|
||||
if(json.code=='1') {
|
||||
this.specialityArr = json.data as DefaultData[];
|
||||
this.specialityNameArr = json.data.map(item => item.name);
|
||||
console.log('请求专长接口成功,信息:', this.specialityArr);
|
||||
} else {
|
||||
console.error('请求专长接口失败:'+json.message)
|
||||
promptAction.showToast({ message: json.message, duration: 1000 })
|
||||
}
|
||||
}).catch((err: BusinessError) => {
|
||||
console.info(`Response fail: ${err}`);
|
||||
})
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
// 操作按钮区域
|
||||
Row({space:70}) {
|
||||
Button('取消')
|
||||
.layoutWeight(1)
|
||||
.backgroundColor(Color.Transparent)
|
||||
.fontColor($r('app.color.main_color'))
|
||||
.backgroundColor(Color.White)
|
||||
.width(80)
|
||||
.onClick(() => {
|
||||
this.controller.close()
|
||||
})
|
||||
|
||||
Text('请选择专长')
|
||||
.fontSize(15)
|
||||
.fontColor('#666666')
|
||||
|
||||
Button('确定')
|
||||
.layoutWeight(1)
|
||||
.backgroundColor(Color.Transparent)
|
||||
.fontColor($r('app.color.main_color'))
|
||||
.backgroundColor(Color.White)
|
||||
.width(80)
|
||||
.onClick(() => {
|
||||
this.controller.close()
|
||||
// 拼接为逗号分隔字符串
|
||||
const diseaseName = this.selectedTags.join(',');
|
||||
console.log('当前选中标签的uuid字符串:', diseaseName);
|
||||
this.specialitySelected(diseaseName);
|
||||
})
|
||||
}
|
||||
.height(40)
|
||||
|
||||
Grid() {
|
||||
ForEach(this.specialityArr, (data: DefaultData) => {
|
||||
GridItem() {
|
||||
// 单个标签组件
|
||||
Text(data.name)
|
||||
.fontSize(12)
|
||||
.width('100%')
|
||||
.height(30)
|
||||
.textAlign(TextAlign.Center)
|
||||
.backgroundColor(this.isSelected(data.uuid) ? '#b58078' : '#FFFFFF')
|
||||
.onClick(() => {
|
||||
this.handleTagClick(data.uuid)
|
||||
})
|
||||
}
|
||||
.height(30)
|
||||
.width('25%') // 四等分宽度
|
||||
.borderWidth(1)
|
||||
.borderColor(Color.Gray)
|
||||
})
|
||||
}
|
||||
}
|
||||
.width('100%')
|
||||
.height(240)
|
||||
.backgroundColor(Color.White)
|
||||
}
|
||||
|
||||
// 判断是否选中
|
||||
private isSelected(uuid: string): boolean {
|
||||
return this.selectedTags.includes(uuid)
|
||||
}
|
||||
|
||||
private handleTagClick(uuid: string) {
|
||||
const index = this.selectedTags.indexOf(uuid);
|
||||
if (index === -1) {
|
||||
// 添加选中(限制最多10个)
|
||||
if (this.selectedTags.length >= 10) {
|
||||
promptAction.showToast({ message: '最多可选择十项!', duration: 1000 });
|
||||
return;
|
||||
}
|
||||
this.selectedTags = [...this.selectedTags, uuid];
|
||||
} else {
|
||||
// 取消选中
|
||||
const newSelected = [...this.selectedTags];
|
||||
newSelected.splice(index, 1);
|
||||
this.selectedTags = newSelected;
|
||||
}
|
||||
console.log('当前选中标签:', this.selectedTags)
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 49 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 97 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 2.6 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 6.5 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 6.6 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 3.7 KiB |
Reference in New Issue
Block a user