Browse Source

硬件列表数据。

jiaxiaoqiang 10 months ago
parent
commit
553a0b39bc

+ 57 - 65
entry/src/main/ets/pages/Index.ets

@@ -71,74 +71,66 @@ struct Index {
 
   build() {
     Column() {
-      Stack() {
-        // 这个webview调用相机不知道为什么只能执行一次,选择文件的回到还行,但是为了统一写法还是用registerJavaScriptProxy,但是有时候注册的方法也只能执行一次,不知道为什么。
-        // Web({ src: $rawfile('doc_old.html'), controller: this.controller })//测试官方文档 这个是好使的
-
-        // Web({
-        //   src: "http://192.168.101.90:3005/login",
-        //   controller: this.controller
-        // })
-        // Web({
-        //   src: "http://10.88.20.88:3005",
-        //   controller: this.controller
-        // })
-        Web({
-          src: webUrl,
-          controller: this.controller
+
+      // 这个webview调用相机不知道为什么只能执行一次,选择文件的回到还行,但是为了统一写法还是用registerJavaScriptProxy,但是有时候注册的方法也只能执行一次,不知道为什么。
+      // Web({ src: $rawfile('doc_old.html'), controller: this.controller })//测试官方文档 这个是好使的
+
+      // Web({
+      //   src: "http://192.168.101.118:3005/login",
+      //   controller: this.controller
+      // })
+      Web({
+        src: webUrl,
+        controller: this.controller
+      })
+        .mixedMode(MixedMode.All)
+        .onlineImageAccess(true)
+        .javaScriptAccess(true)
+        .overviewModeAccess(true)
+        .databaseAccess(true)
+        .domStorageAccess(true)
+        .onShowFileSelector((event) => {
+          console.log(TAG, "onShowFileSelector", JSON.stringify(event))
+          // this.openGallery()
+          // setTimeout(() => {
+          //   // 这个会触发addEventListener('change')的事件,但是每次的值都要不同。
+          //   event?.result.handleFileList([Date.now() + '.jpg']);
+          // }, 1300)
+          return true;
+        })
+        .onProgressChange((e) => {
+          if (e && e.newProgress == 100) {
+            this.registerJS()
+          }
         })
-          .mixedMode(MixedMode.All)
-          .onlineImageAccess(true)
-          .javaScriptAccess(true)
-          .overviewModeAccess(true)
-          .databaseAccess(true)
-          .domStorageAccess(true)
-          .onShowFileSelector((event) => {
-            console.log(TAG, "onShowFileSelector", JSON.stringify(event))
-            // this.openGallery()
-            // setTimeout(() => {
-            //   // 这个会触发addEventListener('change')的事件,但是每次的值都要不同。
-            //   event?.result.handleFileList([Date.now() + '.jpg']);
-            // }, 1300)
-            return true;
-          })
-          .onProgressChange((e) => {
-            if (e && e.newProgress == 100) {
-              this.registerJS()
-            }
-          })
-
-          .onPermissionRequest((event) => {
-            console.log(TAG, "onPermissionRequest")
-
-            // event.request.grant([""])
-          })
-        // .onConsole((e) => {
-        //   console.log(TAG, "onConsole", JSON.stringify(e))
-        //   return true
-        // })
-
-
-        // 退出程序
-        // Row() {
-        //   Image($r('app.media.shutdown'))
-        //     .width(px2vp(80))
-        //     .height(px2vp(80))
-        //     .onClick(() => {
-        //       let pro = new process.ProcessManager();
-        //       pro.exit(0);
-        //     })
-        //
-        // }.width(px2vp(1920))
-        // .height(px2vp(80))
-        // .justifyContent(FlexAlign.End)
-      }.width(px2vp(1920))
-      .height(px2vp(1080))
-      .align(Alignment.BottomEnd)
 
+        .onPermissionRequest((event) => {
+          console.log(TAG, "onPermissionRequest")
+
+          // event.request.grant([""])
+        })
+      // .onConsole((e) => {
+      //   console.log(TAG, "onConsole", JSON.stringify(e))
+      //   return true
+      // })
+
+
+      // 退出程序
+      // Row() {
+      //   Image($r('app.media.shutdown'))
+      //     .width(px2vp(80))
+      //     .height(px2vp(80))
+      //     .onClick(() => {
+      //       let pro = new process.ProcessManager();
+      //       pro.exit(0);
+      //     })
+      //
+      // }.width(px2vp(1920))
+      // .height(px2vp(80))
+      // .justifyContent(FlexAlign.End)
     }
-    .width(px2vp(1920))
-    .height(px2vp(1080))
+    .width("100%")
+    .height("100%")
 
   }
 }

+ 46 - 3
entry/src/main/ets/pages/StationDevicesPage.ets

@@ -24,6 +24,9 @@ export class HardwareModel {
   data?: HardwareModel[]
   enable?: boolean | string //是否启用了设备
   imageSource?: ResourceStr
+  length?: string
+  height?: string
+  value?: string //硬件设备的一个数据
 }
 
 interface ImageDictModel {
@@ -68,11 +71,36 @@ struct StationDevicesPage {
   }
   scroller: Scroller = new Scroller()
   getDeviceList = async () => {
+    console.log("==========")
     let res: HardwareModel = await EquipmentRequest.get('/api/v1/device/list') as HardwareModel
-    this.items = res?.data?.filter((device) => {
+
+    let deviceValues: HardwareModel = await EquipmentRequest.get('/api/v1/station/data') as HardwareModel
+
+    let ybkc: HardwareModel = new HardwareModel()
+    let gaoduchi: HardwareModel = new HardwareModel()
+    deviceValues?.data?.forEach((item) => {
+      if (item.deviceNo == "1106-50100") {
+        ybkc.value = item.length
+      }
+      if (item.deviceNo == "1150-300C00") {
+        gaoduchi.value = item.height
+      }
+    })
+
+    console.log("==========", JSON.stringify(res), JSON.stringify(deviceValues))
+    let array: HardwareModel[] | undefined = res?.data?.filter((device) => {
       device.imageSource = Reflect.get(this.imageDict, device.devicePic!)
       return device.enable! === true || device.enable! === "true"
-    }) ?? []
+    })
+    array?.forEach((item) => {
+      if (item.deviceNo == "1106-50100") {
+        item.value = ybkc.value
+      }
+      if (item.deviceNo == "1150-300C00") {
+        item.value = gaoduchi.value
+      }
+    })
+    this.items = array ?? []
   }
   // 点击选择了设备之后
   @State currentDevice: HardwareModel = {}
@@ -105,6 +133,16 @@ struct StationDevicesPage {
           .onClick(async () => {
             router.back()
           })
+
+        Text("刷新")
+          .fontColor('#FFFFFF')
+          .fontWeight(FontWeight.Medium)
+          .fontSize(24)
+          .margin({ left: 20 })
+          .onClick(() => {
+            this.getDeviceList()
+          })
+
       }
       .width('100%')
       .height('8%')
@@ -129,11 +167,16 @@ struct StationDevicesPage {
                     .opacity(0.6)
                     .fontWeight(FontWeight.Regular)
                     .fontSize(20)
+                  Text(item.value)
+                    .fontColor('#ffffff')
+                    .opacity(0.8)
+                    .fontWeight(FontWeight.Regular)
+                    .fontSize(18)
                   Row() {
                     Image(item.imageSource)
                       .width(px2vp(120))
                       .height(px2vp(120))
-                      .margin({ top: 40 })
+
                   }.height('50%')
                   .width('100%')
                   .padding({ left: 10 })

+ 1 - 1
entry/src/main/ets/utils/EquipmentRequest.ets

@@ -7,7 +7,7 @@ import uploadInstance from './UploadUtil';
 // 创建实例
 const JGRequest = axios.create(
   {
-    baseURL: uploadInstance.uploadParams.stationIP + ':8000',
+    baseURL: uploadInstance.uploadParams.stationIP + ':8000', //"http://192.168.101.150:8000", //
     headers: {
       'Content-Type': 'application/json;charset=UTF-8'
     },