HarmonyOS Next 办公应用:业务页面核心功能实现(一)

HarmonyOS Next 办公应用:业务页面核心功能实现

概述

在 HarmonyOS Next 办公类应用开发中,业务页面的构建是关键环节,它需集成多种办公功能,为用户提供便捷的操作体验。下面将介绍如何构建一个包含日历、打卡、待办审批等功能的业务页面。

核心代码功能及对应代码段

1. 打卡功能

该功能用于记录用户的打卡时间,并在界面上显示首次和末次打卡时间。

typescript 复制代码
ClockIn(){
  setTimeout(()=>{
    this.getCurrentTime()
    promptAction.showToast({
      message:'打卡成功',
      duration:500
    })
  },500)
}

getCurrentTime(){
  let currentDateTime = new Date();
  let currentHour = currentDateTime.getHours();
  let currentMinute = currentDateTime.getMinutes();
  let currentSecond = currentDateTime.getSeconds();
  let currentTime = ``
  if(currentHour<=9){
    currentTime = `0${currentHour}`
  }else{
    currentTime = `${currentHour}`
  }
  if(currentMinute<=9){
    currentTime = `${currentTime}:0${currentMinute}`
  }else{
    currentTime = `${currentTime}:${currentMinute}`
  }
  if(currentSecond<=9){
    currentTime = `${currentTime}:0${currentSecond}`
  }else{
    currentTime = `${currentTime}:${currentSecond}`
  }
  let obj:ClockTimeInfo = new ClockTimeInfo(currentTime,currentHour,currentMinute,currentSecond)
  if(this.clockArr.length <=1){
    this.clockArr.push(obj)
  }else{
    this.clockArr[1] = obj
  }
}

ClockIn 方法中,通过 setTimeout 模拟打卡延迟,调用 getCurrentTime 方法获取当前时间并存储打卡记录,同时使用 promptAction.showToast 提示用户打卡成功。getCurrentTime 方法负责格式化当前时间,并将其存储在 clockArr 数组中。

2. 应用功能跳转

该功能实现了点击不同的应用模块,跳转到相应的页面。

typescript 复制代码
goToPage(type:number){
  let url = ''
  if(type===1){ //日历
    url = 'CalendarPage'
    this.pageInfos.pushPathByName(url,'')
    this.reminderService.addReminder({id: 1, hour: 10, minute: 30});
  }else if(type===2){ //手机打卡
    url = 'ClockInPage'
    let params = new NavInfo('手机打卡',JSON.stringify(this.clockArr))
    this.pageInfos.pushPathByName(url,params)
  }else if(type===3){ //待办审批
    url = 'ToDoPage'
    this.pageInfos.pushPathByName(url,'')
  }
}

goToPage 方法根据传入的 type 参数,判断用户点击的应用模块,然后使用 pageInfos.pushPathByName 方法跳转到相应的页面,并在跳转日历页面时添加提醒。

相关推荐
程序猿追4 分钟前
给手机做一次“体检”——我在 HarmonyOS 上写了个存储空间与内存查看器
华为·智能手机·harmonyos
nashane11 分钟前
HarmonyOS 6学习:HAR包跨平台编译陷阱与架构优化实战
学习·华为·harmonyos
坚果的博客14 分钟前
ycium_plusplus 项目全景解读:OpenHarmony 三方库构建的“大管家“
华为·harmonyos
李二。1 小时前
鸿蒙原生ArkTS-系外行星百科AI
人工智能·华为·harmonyos
想你依然心痛1 小时前
HarmonyOS 6(API 23)实战:构建“光愈冥想舱“——智能情绪疗愈系统
华为·ar·harmonyos·智能体
坚果的博客1 小时前
鸿蒙PC三方库适配OAT.xml 与 SHA512SUM 解读:开源合规与源码校验
xml·开源·harmonyos
不爱吃糖的程序媛3 小时前
鸿蒙应用内添加服务卡片到桌面:formProvider.openFormManager 实战
华为·harmonyos
不爱吃糖的程序媛3 小时前
hionic框架设备信息获取:@ionic-native/device 插件在鸿蒙PC平台的适配实践
华为·harmonyos
坚果的博客4 小时前
【鸿蒙 PC三方库构建系统】README.OpenSource 文件深度解读
华为·开源·harmonyos
川石课堂软件测试4 小时前
什么是埋点测试,app埋点测试怎么做?
功能测试·测试工具·华为·小程序·单元测试·appium·harmonyos