LoginPage.ets 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. import router from '@ohos.router'
  2. import JGRequest from '../common/util/request/Request'
  3. import {getToken} from '../common/util/request/RequestInstance'
  4. @Entry
  5. @Component
  6. struct LoginPage {
  7. @State loginName: string = ''
  8. @State password: string = ''
  9. @State dept: DeptInfo = null
  10. @State workstation: WorkstationInfo = null
  11. // 部门选择弹框
  12. selectDeptController: CustomDialogController = new CustomDialogController({
  13. builder: SelectDeptDialog({
  14. dept: this.dept
  15. }),
  16. autoCancel: true,
  17. alignment: DialogAlignment.Center,
  18. // gridCount: 3,
  19. customStyle: true,
  20. })
  21. // 工位选择弹框
  22. selectWorkstationController: CustomDialogController = new CustomDialogController({
  23. builder: SelectWorkstationDialog({
  24. workstation: this.workstation
  25. }),
  26. autoCancel: true,
  27. alignment: DialogAlignment.Center,
  28. // gridCount: 3,
  29. customStyle: true,
  30. })
  31. build() {
  32. Column() {
  33. Column() {
  34. Row() {
  35. Image($r('app.media.login_title'))
  36. .width(216.8)
  37. .height(16)
  38. }
  39. .height('21%')
  40. .width('88.5%')
  41. .alignItems(VerticalAlign.Center)
  42. .justifyContent(FlexAlign.Start)
  43. TextInput({placeholder: '账号', text: this.loginName })
  44. .placeholderColor($r('app.color.login_text_input_placeholder_color'))
  45. .placeholderFont({ size: $r('app.float.set_card_font_size'), weight: FontWeight.Medium})
  46. .fontColor($r('app.color.login_text_input_font_color'))
  47. .width('90.4%')
  48. .height('12%')
  49. .opacity($r('app.float.general_font_opacity'))
  50. .borderRadius($r('app.float.general_border_radius'))
  51. .backgroundColor('#BCC2C9')
  52. .onChange((value: string) => {
  53. this.loginName = value
  54. })
  55. Row() {}.height('4.5%')
  56. TextInput({placeholder: '密码', text: this.password })
  57. .placeholderColor($r('app.color.login_text_input_placeholder_color'))
  58. .placeholderFont({ size: $r('app.float.set_card_font_size'), weight: FontWeight.Medium})
  59. .fontColor($r('app.color.login_text_input_font_color'))
  60. .width('90.4%')
  61. .height('12%')
  62. .type(InputType.Password)
  63. .borderRadius($r('app.float.general_border_radius'))
  64. .backgroundColor('#BCC2C9')
  65. .onChange((value: string) => {
  66. this.password = value
  67. })
  68. Row() {}.height('3%')
  69. // 部门、工位选择
  70. Row() {
  71. Row() {
  72. Text('部门')
  73. .fontColor($r('app.color.general_font_white_color'))
  74. .fontSize($r('app.float.card_info_font_size'))
  75. }
  76. .width('47.8%')
  77. .height('100%')
  78. .alignItems(VerticalAlign.Top)
  79. Blank()
  80. Row() {
  81. Text('工位')
  82. .fontColor($r('app.color.general_font_white_color'))
  83. .fontSize($r('app.float.card_info_font_size'))
  84. }
  85. .alignItems(VerticalAlign.Top)
  86. .width('47.8%')
  87. .height('100%')
  88. }
  89. .height('5%')
  90. .width('90.4%')
  91. Row() {
  92. Row() {
  93. Text(this.dept ? this.dept.deptName : '')
  94. .fontWeight(FontWeight.Medium)
  95. .fontSize($r('app.float.process_card_middle_font_size'))
  96. .fontColor($r('app.color.general_font_color'))
  97. .opacity($r('app.float.general_font_opacity'))
  98. Blank()
  99. Row() {
  100. Image($r('app.media.subscript_space'))
  101. .height($r('app.float.card_subscript_new_size'))
  102. .width($r('app.float.card_subscript_new_size'))
  103. }
  104. .alignItems(VerticalAlign.Bottom)
  105. .justifyContent(FlexAlign.End)
  106. .width('20%')
  107. .height('100%')
  108. }
  109. .width('47.8%')
  110. .height('100%')
  111. .padding({left: 10})
  112. .backgroundColor($r('app.color.general_card_background_color'))
  113. .borderRadius($r('app.float.general_border_radius'))
  114. .onClick(()=>{
  115. this.selectDeptController.open()
  116. })
  117. Blank()
  118. Row() {
  119. Text(this.workstation ? this.workstation.name : '')
  120. .fontWeight(FontWeight.Medium)
  121. .fontSize($r('app.float.process_card_middle_font_size'))
  122. .fontColor($r('app.color.general_font_color'))
  123. .opacity($r('app.float.general_font_opacity'))
  124. Blank()
  125. Row() {
  126. Image($r('app.media.subscript_space'))
  127. .height($r('app.float.card_subscript_new_size'))
  128. .width($r('app.float.card_subscript_new_size'))
  129. }
  130. .alignItems(VerticalAlign.Bottom)
  131. .justifyContent(FlexAlign.End)
  132. .width('20%')
  133. .height('100%')
  134. }
  135. .width('47.8%')
  136. .height('100%')
  137. .padding({left: 10})
  138. .backgroundColor($r('app.color.general_card_background_color'))
  139. .borderRadius($r('app.float.general_border_radius'))
  140. .onClick(()=>{
  141. this.selectWorkstationController.open()
  142. })
  143. }
  144. .width('90.4%')
  145. .height('12%')
  146. Row() {
  147. Text('登录')
  148. .fontWeight(FontWeight.Medium)
  149. .fontSize($r('app.float.process_card_middle_font_size'))
  150. .fontColor($r('app.color.general_font_white_color'))
  151. .textAlign(TextAlign.Center)
  152. .width('100%')
  153. .height('38.6%')
  154. .backgroundColor($r('app.color.robot_set_card_blue'))
  155. .borderRadius($r('app.float.robot_set_radius'))
  156. .opacity(this.loginName && this.loginName.length > 0 && this.password && this.password.length > 0 ? 1 : $r('app.float.card_font_default_opacity'))
  157. }
  158. .onClick(()=>{
  159. if (this.loginName && this.loginName.length > 0 && this.password && this.password.length > 0) {
  160. getToken().then(token =>{
  161. if (token && token.length > 0) {
  162. router.pushUrl({
  163. url:'pages/Index'
  164. })
  165. }
  166. })
  167. }
  168. })
  169. .width('90.4%')
  170. .height('30.5%')
  171. .alignItems(VerticalAlign.Center)
  172. .justifyContent(FlexAlign.Center)
  173. }
  174. .width('35%')
  175. .height('62%')
  176. .backgroundColor($r('app.color.login_background_color'))
  177. .borderRadius($r('app.float.general_border_radius'))
  178. .margin({right: '8.25%'})
  179. }
  180. .width('100%')
  181. .height('100%')
  182. .backgroundImage($r('app.media.login_background'))
  183. .backgroundImageSize({width: '100%', height: '100%'})
  184. .alignItems(HorizontalAlign.End)
  185. .justifyContent(FlexAlign.Center)
  186. }
  187. }
  188. // 部门选择弹框
  189. @CustomDialog
  190. struct SelectDeptDialog {
  191. @Link dept: DeptInfo
  192. @State deptArray: DeptInfo[] = []
  193. controller?: CustomDialogController
  194. cancel: () => void = () => {}
  195. confirm: () => void = () => {}
  196. async aboutToAppear() {
  197. this.deptArray = await JGRequest.get("/api/v1/sys/dept/orgList", {}) as DeptInfo[]
  198. }
  199. build() {
  200. Column() {
  201. Row() {
  202. Text('选择部门')
  203. .fontSize($r('app.float.process_card_large_font_size'))
  204. .fontWeight(FontWeight.Medium)
  205. .fontColor($r('app.color.general_font_color'))
  206. .opacity($r('app.float.general_font_opacity'))
  207. }
  208. .height('20%')
  209. .justifyContent(FlexAlign.Center)
  210. Column() {
  211. List({space: 10}) {
  212. ForEach(this.deptArray, (item: DeptInfo)=>{
  213. ListItem() {
  214. Row() {
  215. Text(item.deptName)
  216. .fontSize($r('app.float.process_card_small_font_size'))
  217. .fontWeight(FontWeight.Medium)
  218. .fontColor(this.dept && this.dept.id === item.id ? $r('app.color.general_font_white_color') : $r('app.color.general_font_color'))
  219. .opacity($r('app.float.general_font_opacity'))
  220. }
  221. .height('15%')
  222. .width('80%')
  223. .backgroundColor(this.dept && this.dept === item.id ? $r('app.color.order_select_background') : $r('app.color.general_card_background_color'))
  224. .borderRadius($r('app.float.general_border_radius'))
  225. .padding({left: 10})
  226. .onClick(()=>{
  227. this.dept = item
  228. if (this.controller != undefined) {
  229. this.controller.close()
  230. }
  231. })
  232. }
  233. })
  234. }
  235. .alignListItem(ListItemAlign.Center)
  236. }
  237. .height('70%')
  238. .width('80%')
  239. .justifyContent(FlexAlign.Start)
  240. }
  241. .width('48%')
  242. .height('63%')
  243. .backgroundColor($r('app.color.page_general_background'))
  244. .justifyContent(FlexAlign.Start)
  245. .borderRadius($r('app.float.general_border_radius'))
  246. }
  247. }
  248. // 工位选择弹框
  249. @CustomDialog
  250. struct SelectWorkstationDialog {
  251. @Link workstation: WorkstationInfo
  252. @State workstationArray: WorkstationInfo[] = []
  253. controller?: CustomDialogController
  254. cancel: () => void = () => {}
  255. confirm: () => void = () => {}
  256. async aboutToAppear() {
  257. this.workstationArray = await JGRequest.get("/api/v1/base/station/queryStationList", {}) as WorkstationInfo[]
  258. }
  259. build() {
  260. Column() {
  261. Row() {
  262. Text('选择工位')
  263. .fontSize($r('app.float.process_card_middle_font_size'))
  264. .fontWeight(FontWeight.Medium)
  265. .fontColor($r('app.color.general_font_color'))
  266. .opacity($r('app.float.general_font_opacity'))
  267. }
  268. .height('20%')
  269. .justifyContent(FlexAlign.Center)
  270. Column() {
  271. List({space: 10}) {
  272. ForEach(this.workstationArray, (item: WorkstationInfo)=>{
  273. ListItem() {
  274. Row() {
  275. Text(item.name)
  276. .fontSize($r('app.float.process_card_small_font_size'))
  277. .fontWeight(FontWeight.Medium)
  278. .fontColor($r('app.color.general_font_color'))
  279. .opacity($r('app.float.general_font_opacity'))
  280. }
  281. .height('15%')
  282. .width('80%')
  283. .backgroundColor($r('app.color.general_card_background_color'))
  284. .borderRadius($r('app.float.general_border_radius'))
  285. .padding({left: 10})
  286. .onClick(()=>{
  287. this.workstation = item
  288. if (this.controller != undefined) {
  289. this.controller.close()
  290. }
  291. })
  292. }
  293. })
  294. }
  295. .alignListItem(ListItemAlign.Center)
  296. }
  297. .height('70%')
  298. .width('80%')
  299. .justifyContent(FlexAlign.SpaceAround)
  300. }
  301. .width('48%')
  302. .height('63%')
  303. .backgroundColor($r('app.color.page_general_background'))
  304. .justifyContent(FlexAlign.Start)
  305. .borderRadius($r('app.float.general_border_radius'))
  306. }
  307. }
  308. class DeptInfo {
  309. id?: number
  310. // 部门名称
  311. deptName?: string
  312. // 组织id
  313. orgId?: number
  314. }
  315. class WorkstationInfo {
  316. id?: number
  317. // 工位名称
  318. name?: string
  319. }