PickerDateTimeHelper.ets 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { DatePickerView } from './compose/DatePickerView'
  2. import { ToolsHelper } from './ToolsHelper'
  3. export interface DateDialogOptions {
  4. // 'YYYY-MM-DD'年月日对应的标识,随意组合,默认YYYY-MM-DD
  5. type?: string
  6. // 可选择的开始日期,默认1970-1-1
  7. startDate?: string
  8. // 可选择的结束日期,默认当前月最后一天
  9. endDate?: string
  10. // 当前选中的日期,默认当前日期
  11. currentDate?: string
  12. // 选择器确定按钮点击事件
  13. onConfirm: (date: string) => void
  14. // 选择器取消按钮点击事件
  15. onCancel?: () => void
  16. }
  17. @Builder
  18. function dateDialogBuilder(option: DateDialogOptions, dialogTag: string) {
  19. DatePickerView({
  20. option: option,
  21. dialogTag: dialogTag,
  22. })
  23. }
  24. /**
  25. * 时间选择相关工具
  26. */
  27. export class PickerDateTimeHelper {
  28. private constructor() {
  29. }
  30. /**
  31. * 显示日期选择器
  32. * @param options
  33. * @param p 调用页面直接this
  34. */
  35. static showDateDialog(options: DateDialogOptions, p: object) {
  36. const dialogTag = ToolsHelper.getUuid()
  37. ToolsHelper.showCustomDialog(dialogTag, dateDialogBuilder.bind(p, options, dialogTag),
  38. DialogAlignment.Bottom)
  39. }
  40. }