IncreaseStudentPage.ets 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. import { _YtHeader } from '../components/YtComp/_YtHeader';
  2. import { IncreaseStudentPageViewModel } from '../viewModel/IncreaseStudentPage';
  3. import { cert } from '@kit.DeviceCertificateKit';
  4. import { IncreaseStudentPageModel } from '../model/RouterModel';
  5. // 添加学生信息页面
  6. @ComponentV2
  7. struct IncreaseStudentPage {
  8. @Local vm: IncreaseStudentPageViewModel = new IncreaseStudentPageViewModel();
  9. @Param name: string = ''
  10. @Param gender: string = ''
  11. aboutToAppear(): void {
  12. this.vm.name = this.name
  13. this.vm.gender = this.gender
  14. }
  15. build() {
  16. NavDestination() {
  17. Column({space: 25}) {
  18. _YtHeader({
  19. title: this.vm.title,
  20. _onBackPress: () => { this.vm._onBackPressed() },
  21. _padding: 0
  22. })
  23. Column(){
  24. Column(){
  25. Row(){
  26. Text('姓名')
  27. TextInput({text: $$this.vm.name, placeholder: '请输入姓名'})
  28. .width(100)
  29. .border(null)
  30. .fontSize(14)
  31. .padding({ left: 10 })
  32. .textAlign(TextAlign.End)
  33. .placeholderColor('#BFBFBF')
  34. .placeholderFont({ size: 14 })
  35. .backgroundColor(Color.Transparent)
  36. }
  37. .width("100%")
  38. .padding({top: 20, bottom: 20})
  39. .justifyContent(FlexAlign.SpaceBetween)
  40. Divider()
  41. .height(1)
  42. .width("100%")
  43. .backgroundColor('#F6F6F6')
  44. Row(){
  45. Text('性别')
  46. Row({space:5}){
  47. Text(){
  48. if(this.vm.gender) {
  49. Span(this.vm.gender)
  50. } else {
  51. Span('请选择')
  52. .fontColor('#BFBFBF')
  53. }
  54. }
  55. .fontSize(14)
  56. Image($r('[basic].media.ic_back'))
  57. .width(20)
  58. .rotate({angle: 270})
  59. .aspectRatio(1)
  60. }
  61. .bindMenu(this.genderEnum)
  62. }
  63. .width("100%")
  64. .padding({top: 20, bottom: 20})
  65. .justifyContent(FlexAlign.SpaceBetween)
  66. }
  67. .width('98%')
  68. .borderRadius(15)
  69. .backgroundColor(Color.White)
  70. .padding({left: 18, right: 18})
  71. .shadow({ radius: 6, color: '#1a000000' })
  72. Row({space: 31}){
  73. Text('取消')
  74. .borderRadius(10)
  75. .backgroundColor('#BFBFBF')
  76. .padding({ left: 50, right: 50, top: 15, bottom: 15})
  77. .onClick(() => { this.vm._onBackPressed() })
  78. Text('保存')
  79. .borderRadius(10)
  80. .backgroundColor('#7186F9')
  81. .padding({ left: 50, right: 50, top: 15, bottom: 15})
  82. .onClick(() => { this.vm._onSave() })
  83. }
  84. .width('100%')
  85. .justifyContent(FlexAlign.Center)
  86. }
  87. .width("100%")
  88. .layoutWeight(1)
  89. .justifyContent(FlexAlign.SpaceBetween)
  90. .padding({ bottom: this.vm.safeBottom + 50 })
  91. }
  92. .width('100%')
  93. .height('100%')
  94. .backgroundColor('#F6F6F6')
  95. .padding({ left:16, right:16, top: this.vm.safeTop})
  96. .justifyContent(FlexAlign.Start)
  97. .alignItems(HorizontalAlign.Center)
  98. }
  99. .hideTitleBar(true)
  100. .onBackPressed(() => { return this.vm._onBackPressed() })
  101. }
  102. @Builder
  103. genderEnum(){
  104. Column() {
  105. Row({space:34}){
  106. Text('男')
  107. Radio({group: 'sex', value: '男'})
  108. .checked(this.vm.gender == '男')
  109. .onChange(() => { this.vm._onGenderChange('男') })
  110. }
  111. .padding({ top: 10, bottom: 10})
  112. .onClick(() => { this.vm._onGenderChange('男') })
  113. Divider()
  114. .height(1.5)
  115. .width("100%")
  116. .backgroundColor('#F6F6F6')
  117. Row({space:34}){
  118. Text('女')
  119. Radio({group: 'sex', value: '女'})
  120. .checked(this.vm.gender == '女')
  121. .onChange(() => { this.vm._onGenderChange('女') })
  122. }
  123. .padding({ top: 10, bottom: 10})
  124. .onClick(() => { this.vm._onGenderChange('女') })
  125. }
  126. .width(105)
  127. .padding({left: 11, right: 11, top: 6, bottom: 6})
  128. }
  129. }
  130. @Builder
  131. function IncreaseStudentPageBuilder(_1: string, param: IncreaseStudentPageModel) {
  132. IncreaseStudentPage({ name: param?.name, gender: param?.gender })
  133. }