StationDevicesPage.ets 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. // 工位的设备列表
  2. import router from '@ohos.router'
  3. import EquipmentRequest from '../common/util/request/EquipmentRequest'
  4. import { carPositionClass } from './WarehouseMap'
  5. export class HardwareModel {
  6. name?: string
  7. text?: string
  8. type?: Resource
  9. open?: Resource
  10. colse?: Resource
  11. select?: boolean
  12. temp?: number
  13. manufacturer?: string //: "厂家",
  14. brand?: string //"品牌或型号,比如JBC",
  15. deviceName?: string //"设备自定义名称或资产编号",
  16. deviceType?: string // "类别,比如电络铁",
  17. deviceNo?: string // "设备编号,唯一号",
  18. devicePic?: string // "图片",
  19. state?: number //"状态:0正常,-1:离线,1故障",
  20. workshop?: string //"产线",
  21. station?: string //"工站/工位",
  22. devicePosition?: string // "空间位置,目前暂时不用",
  23. data?: HardwareModel[]
  24. }
  25. @Entry
  26. @Component
  27. struct StationDevicesPage {
  28. //注释掉的是假数据,实际更具请求硬件获取
  29. @State private items: Array<HardwareModel> = []
  30. scroller: Scroller = new Scroller()
  31. getDeviceList = async () => {
  32. let res: HardwareModel = await EquipmentRequest.get('/api/v1/device/list') as HardwareModel
  33. this.items = res?.data?.filter((device) => {
  34. return device.state! === 0
  35. }) ?? []
  36. }
  37. aboutToAppear(): void {
  38. this.getDeviceList()
  39. }
  40. build() {
  41. Column() {
  42. Row() {
  43. Image($r('app.media.back_white'))
  44. .height(px2vp(48))
  45. .width(px2vp(48))
  46. .onClick(async () => {
  47. router.back()
  48. })
  49. }
  50. .width('100%')
  51. .height('8%')
  52. .alignItems(VerticalAlign.Center)
  53. .justifyContent(FlexAlign.Start)
  54. Column() {
  55. // Scroll(this.scroller){
  56. Grid(this.scroller) {
  57. ForEach(this.items, (item: HardwareModel, index) => {
  58. GridItem() {
  59. Row() {
  60. Column() {
  61. Text(item.deviceName)
  62. .fontColor('#FFFFFF')
  63. .fontWeight(FontWeight.Medium)
  64. .fontSize($r('app.float.fontSize_24'))
  65. Text(item.deviceNo)
  66. .fontColor('#FFFFFF')
  67. .opacity(0.6)
  68. .fontWeight(FontWeight.Regular)
  69. .fontSize($r('app.float.fontSize_20'))
  70. Row() {
  71. Image(item.devicePic)
  72. .width(px2vp(120))
  73. .height(px2vp(120))
  74. .margin({ top: 40 })
  75. }.height('50%')
  76. .width('100%')
  77. .padding({ left: 10 })
  78. }
  79. .width('100%')
  80. .padding(10)
  81. .borderRadius(10)
  82. .alignItems(HorizontalAlign.Start)
  83. .height('100%')
  84. }
  85. .width('100%')
  86. .height('30%')
  87. .padding({ left: 10 })
  88. .borderRadius(10)
  89. .backgroundColor('#66ffffff')
  90. }
  91. })
  92. }
  93. .columnsTemplate('1fr 1fr 1fr 1fr 1fr 1fr')
  94. .columnsGap(10)
  95. .rowsGap(10)
  96. .width('100%')
  97. .height('100%')
  98. .editMode(true) //设置Grid是否进入编辑模式,进入编辑模式可以拖拽Grid组件内部GridItem
  99. .supportAnimation(true) //设置Grid是否开启拖拽补位动画
  100. .height('80%')
  101. .width('100%')
  102. .padding({ top: 10 })
  103. }
  104. }
  105. .backgroundImage($r('app.media.zhihuigc'))
  106. .backgroundImageSize({ width: '100%', height: '100%' })
  107. .width('100%')
  108. .height('100%')
  109. .padding(20)
  110. }
  111. }