DeviceCheckView.ets 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. import ProcessRequest from '../../common/util/request/ProcessRequest'
  2. import ProcessCheck from '../../viewmodel/process/ProcessCheck'
  3. import ProcessInfo from '../../viewmodel/process/ProcessInfo'
  4. import RequestParamModel from '../../viewmodel/RequestParamModel'
  5. import promptAction from '@ohos.promptAction'
  6. import PageInfo from '../../viewmodel/PageInfo'
  7. import DictValue from '../../viewmodel/DictValue'
  8. import ProcessDeviceDailyCheck from '../../viewmodel/process/ProcessDeviceDailyCheck'
  9. import HashMap from '@ohos.util.HashMap'
  10. import TimeUtil from '../../common/util/TimeUtil'
  11. import CommonConstants from '../../common/constants/CommonConstants'
  12. // 设备点检工序
  13. @Component
  14. export struct DeviceCheckView {
  15. // 设备每日点检
  16. @State deviceChecks: ProcessDeviceDailyCheck[] = [
  17. {
  18. id: '1',
  19. stationIp: '192.168.1.100',
  20. deviceNo: 'DEV001',
  21. deviceName: '数控机床A型',
  22. deviceType: '001',
  23. meteringDate: '2024-12-31',
  24. meteringState: 1,
  25. warrantyPeriod: '2025-06-30',
  26. warrantyState: 1,
  27. created: Date.now()
  28. },
  29. {
  30. id: '2',
  31. stationIp: '192.168.1.101',
  32. deviceNo: 'DEV002',
  33. deviceName: '激光切割机B型',
  34. deviceType: '002',
  35. meteringDate: '2024-10-15',
  36. meteringState: 0,
  37. warrantyPeriod: '2024-12-31',
  38. warrantyState: 0,
  39. created: Date.now()
  40. },
  41. {
  42. id: '3',
  43. stationIp: '192.168.1.102',
  44. deviceNo: 'DEV003',
  45. deviceName: '注塑机C型',
  46. deviceType: '003',
  47. meteringDate: '2025-03-20',
  48. meteringState: 1,
  49. warrantyPeriod: '2025-09-15',
  50. warrantyState: 1,
  51. created: Date.now()
  52. },
  53. {
  54. id: '4',
  55. stationIp: '192.168.1.103',
  56. deviceNo: 'DEV004',
  57. deviceName: '冲压机D型',
  58. deviceType: '001',
  59. meteringDate: '2024-08-10',
  60. meteringState: 0,
  61. warrantyPeriod: '长期有效',
  62. warrantyState: 1,
  63. created: Date.now()
  64. },
  65. {
  66. id: '5',
  67. stationIp: '192.168.1.104',
  68. deviceNo: 'DEV005',
  69. deviceName: '磨床E型',
  70. deviceType: '002',
  71. meteringDate: '长期有效',
  72. meteringState: 1,
  73. warrantyPeriod: '2024-11-30',
  74. warrantyState: 0,
  75. created: Date.now()
  76. }
  77. ]
  78. //查找设备编码
  79. @State queryDeviceNo: string = 'test000'
  80. // 设备类型(key为数据字典值,value为数据字典标签)
  81. @State deviceTypes: HashMap<string, string> = new HashMap()
  82. // 当前工位IP
  83. @Consume('stationIp') stationIp: string
  84. deviceTypeDictCode: string = 'device_type'
  85. private scrollerDevice: Scroller = new Scroller()
  86. build() {
  87. Column() {
  88. Text("扫描设备 ")
  89. .fontColor($r('app.color.FFFFFF'))
  90. .fontSize($r('app.float.fontSize_24'))
  91. .height('7.9%')
  92. .width('97.2%')
  93. Row(){
  94. Row() {
  95. // 左侧二维码图标
  96. Image($r('app.media.material_qr_code'))
  97. .width($r('app.float.virtualSize_32'))
  98. .height($r('app.float.virtualSize_32'))
  99. .fillColor($r('app.color.FFFFFF'))
  100. .objectFit(ImageFit.Contain)
  101. .margin({left:'0.7%'})
  102. // 扫码输入框
  103. }
  104. .height('100%')
  105. .width('27.2%')
  106. .borderRadius($r('app.float.virtualSize_16'))
  107. .backgroundColor($r('app.color.000000'))
  108. Text(TimeUtil.getCurrentDate())
  109. .fontColor($r('app.color.FFFFFF'))
  110. .fontSize($r('app.float.fontSize_16'))
  111. .margin({left:'3%'})
  112. }
  113. .height('7.1%')
  114. .width('97.2%')
  115. Column() {
  116. List({scroller: this.scrollerDevice }) {
  117. ForEach(this.deviceChecks, (item: ProcessDeviceDailyCheck) => {
  118. ListItem() {
  119. Row() {
  120. Column(){
  121. Text(this.deviceTypes && item.deviceType && this.deviceTypes.hasKey(item.deviceType) ? this.deviceTypes.get(item.deviceType) : '')
  122. .fontSize($r('app.float.fontSize_24'))
  123. .fontColor($r('app.color.FFFFFF'))
  124. Text('名称:' + item.deviceNo && item.deviceName ? item.deviceName : '')
  125. .fontSize($r('app.float.fontSize_16'))
  126. .fontColor($r('app.color.FFFFFF'))
  127. .fontWeight(FontWeight.Lighter)
  128. .margin({top:'2%',bottom:'1%'})
  129. Text('编码:' + item.deviceNo ? item.deviceNo : '')
  130. .fontSize($r('app.float.fontSize_16'))
  131. .fontColor($r('app.color.FFFFFF'))
  132. .fontWeight(FontWeight.Lighter)
  133. }
  134. .width('30%')
  135. .height('100%')
  136. .justifyContent(FlexAlign.Center)
  137. .alignItems(HorizontalAlign.Start)
  138. .margin({right:'16%'})
  139. Column({space:5}){
  140. Text(`计量有效期:`)
  141. .fontSize($r('app.float.fontSize_16'))
  142. .fontColor($r('app.color.FFFFFF'))
  143. .fontWeight(FontWeight.Lighter)
  144. if ( item.deviceNo) {
  145. Row(){
  146. Image(item.meteringState! === 1 ? $r('app.media.device_normal') : $r('app.media.device_expire'))
  147. .width($r('app.float.virtualSize_24'))
  148. .height($r('app.float.virtualSize_24'))
  149. .margin({left:'2%'})
  150. Text(item.meteringDate ? `${item.meteringDate}` : '长期有效')
  151. .fontSize($r('app.float.fontSize_16'))
  152. .fontColor(item.meteringState! === 1 ? $r('app.color.30D158') : $r('app.color.FF453A'))
  153. .margin({left:'2%'})
  154. }
  155. .width('65%')
  156. .borderRadius($r('app.float.virtualSize_16'))
  157. .backgroundColor($r('app.color.000000'))
  158. .height('25%')
  159. .alignItems(VerticalAlign.Center)
  160. }
  161. }
  162. .width('22%')
  163. .height('100%')
  164. .justifyContent(FlexAlign.Center)
  165. .alignItems(HorizontalAlign.Start)
  166. Column({space:5}){
  167. Text(`维保有效期:`)
  168. .fontSize($r('app.float.fontSize_16'))
  169. .fontColor($r('app.color.FFFFFF'))
  170. .fontWeight(FontWeight.Lighter)
  171. if ( item.deviceNo) {
  172. Row() {
  173. Image(item.warrantyState! === 1 ? $r('app.media.device_normal') : $r('app.media.device_expire'))
  174. .width($r('app.float.virtualSize_24'))
  175. .height($r('app.float.virtualSize_24'))
  176. .margin({ left: '2%' })
  177. Text(item.warrantyPeriod ? `${item.warrantyPeriod}` : '长期有效')
  178. .fontSize($r('app.float.fontSize_16'))
  179. .fontColor(item.warrantyState! === 1 ? $r('app.color.30D158') : $r('app.color.FF453A'))
  180. .margin({ left: '2%' })
  181. }
  182. .width('65%')
  183. .borderRadius($r('app.float.virtualSize_16'))
  184. .backgroundColor($r('app.color.000000'))
  185. .height('25%')
  186. .alignItems(VerticalAlign.Center)
  187. }
  188. }
  189. .width('22%')
  190. .height('100%')
  191. .justifyContent(FlexAlign.Center)
  192. .alignItems(HorizontalAlign.Start)
  193. }
  194. .height('90%')
  195. .width('97%')
  196. .justifyContent(FlexAlign.Start)
  197. }
  198. .height('17%')
  199. .width('100%')
  200. .margin({ bottom: 8})
  201. .borderRadius($r('app.float.virtualSize_16'))
  202. .backgroundColor($r('app.color.10FFFFFF'))
  203. })
  204. }
  205. .height('94%')
  206. .width('100%')
  207. }
  208. .justifyContent(FlexAlign.Center)
  209. .height('85%')
  210. .width('97.2%')
  211. }
  212. .width('100%')
  213. .height('100%')
  214. }
  215. }