ReportWorkHourRateDialog.ets 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. //报工用户用时占比
  2. import { Font } from '@ohos.arkui.UIContext'
  3. @CustomDialog
  4. export struct ReportWorkHourRateDialog {
  5. controller: CustomDialogController
  6. onConfirm: (rate: number)=> void = () => {}
  7. //选择的占比
  8. @State selectIndex: number = 4
  9. // 占比数字(eg: 50%的50)
  10. rateNum: number = 50
  11. private rateList: string[] = ['10%', '20%', '30%', '40%', '50%', '60%', '70%', '80%', '90%', '100%']
  12. aboutToAppear(): void {
  13. this.rateNum = Number.parseFloat(this.rateList[this.selectIndex].slice(0, -1) as string)
  14. }
  15. build() {
  16. Column(){
  17. Column() {
  18. Text('用时占比')
  19. .fontColor($r('app.color.FFFFFF'))
  20. .fontSize($r('app.float.fontSize_30'))
  21. .fontWeight(FontWeight.Medium)
  22. }
  23. .height('20%')
  24. .width('100%')
  25. .justifyContent(FlexAlign.End)
  26. TextPicker({ range: this.rateList, selected: this.selectIndex })
  27. .onChange((value: string | string[], index: number| number[]) => {
  28. this.rateNum = Number.parseFloat(value.slice(0, -1) as string)
  29. this.selectIndex = index as number
  30. })
  31. .selectedTextStyle({color: $r('app.color.FFFFFF'), font: {size: $r('app.float.fontSize_30'), weight: FontWeight.Medium }})
  32. .textStyle({color: $r('app.color.FFFFFF'), font: {size: $r('app.float.fontSize_24'), weight: FontWeight.Medium }})
  33. .disappearTextStyle({color: $r('app.color.FFFFFF'), font: {size: $r('app.float.fontSize_16'), weight: FontWeight.Lighter}})
  34. .backgroundColor($r('app.color.2A2A2A'))
  35. .width('85%')
  36. .height('65%')
  37. // 确认/取消栏
  38. Column() {
  39. Divider()
  40. .vertical(false)
  41. .strokeWidth(1)
  42. .color($r('app.color.15FFFFFF'))
  43. Row() {
  44. Row() {
  45. Text('取消')
  46. .fontColor($r('app.color.60FFFFFF'))
  47. .fontSize($r('app.float.fontSize_30'))
  48. }
  49. .justifyContent(FlexAlign.Center)
  50. .width('50%')
  51. .onClick(() => this.controller.close())
  52. Divider()
  53. .vertical(true)
  54. .strokeWidth(1)
  55. .color($r('app.color.15FFFFFF'))
  56. Row() {
  57. Text('确定')
  58. .fontColor($r('app.color.007AFF'))
  59. .fontSize($r('app.float.fontSize_30'))
  60. }
  61. .justifyContent(FlexAlign.Center)
  62. .width('50%')
  63. .onClick(() => {
  64. this.onConfirm(this.rateNum);
  65. this.controller.close()
  66. })
  67. }
  68. }
  69. .width('100%')
  70. .height('15%')
  71. }
  72. .height('34%')
  73. .width('28%')
  74. .backgroundColor($r('app.color.2A2A2A'))
  75. .justifyContent(FlexAlign.End)
  76. .alignItems(HorizontalAlign.Center)
  77. .borderRadius($r('app.float.virtualSize_16'))
  78. }
  79. }