Переглянути джерело

当前工位的设备列表页面。

jiaxiaoqiang 8 місяців тому
батько
коміт
9ee3c73735

+ 40 - 40
entry/src/main/ets/common/component/BottomOperateComp.ets

@@ -20,37 +20,34 @@ const EXIT: string = 'exit'
 export struct BottomOperateComp {
   // @Link SmartFactoryCardDelete:number
   private isHomePage?: boolean = false
-  @State isClick:boolean = false
+  @State isClick: boolean = false
   //弹窗
-  dialogController1: CustomDialogController= new CustomDialogController({
+  dialogController1: CustomDialogController = new CustomDialogController({
     builder: NoticeDialog({}),
     alignment: DialogAlignment.Center,
-    customStyle:true,
-    cancel:()=>{
-      this.isClick =! this.isClick
+    customStyle: true,
+    cancel: () => {
+      this.isClick = !this.isClick
     }
   })
-  @State Page:number=1
+  @State Page: number = 1
   @State deviceDialogWidth: number = 0
-  @State @Watch('dataChange')  click: number = 0;
-  @State  click1: number = 0;
-  @State @Watch('dataChange')  message: string = 'Hello World';
+  @State @Watch('dataChange') click: number = 0;
+  @State click1: number = 0;
+  @State @Watch('dataChange') message: string = 'Hello World';
   @State inputMsg: string = '';
   @State isDistributed: boolean = false
   @StorageLink('deviceList') deviceList: Array<deviceManager.DeviceBasicInfo> = []
   @State selectedIndex: number | undefined = -1
-
   private remoteDeviceModel: RemoteDeviceModel = new RemoteDeviceModel()
   private kvStoreModel: KvStoreModel = new KvStoreModel()
   private dialogController: CustomDialogController | null = null
-
   onSelectedIndexChange = async (index: number | undefined) => {
     console.info(TAG, `selectedIndexChange`)
     this.selectedIndex = index
     this.selectDevice()
   }
 
-
   // aboutToAppear(){
   //   this.showDeviceDialog()
   // }
@@ -111,7 +108,7 @@ export struct BottomOperateComp {
   async startAbility(deviceId: string | undefined) {
     console.debug(TAG, `startAbility deviceId: ${deviceId}`)
     let context = getContext(this) as common.UIAbilityContext
-    let choicePages:class1={}
+    let choicePages: class1 = {}
     // console.log("获取当前页面"+choicePages.choicePages?.toString())
     let want: Want = {
       bundleName: BUNDLE_NAME,
@@ -185,7 +182,7 @@ export struct BottomOperateComp {
         .backdropBlur(this.isHomePage ? 13 : 0)
 
       Row() {
-        Row () {
+        Row() {
           Image($r('app.media.home_page'))
             .height($r('app.float.robot_image_select_size'))
             .width($r('app.float.robot_image_select_size'))
@@ -193,13 +190,14 @@ export struct BottomOperateComp {
         .height('100%')
         .width('7%')
         .justifyContent(FlexAlign.Center)
-        .onClick(()=>{
-            router.pushUrl({
-              url:'pages/Index'
-            })
-
+        .onClick(() => {
+          router.pushUrl({
+            url: 'pages/Index'
           })
-        Row(){
+
+        })
+
+        Row() {
           Image($r('app.media.notice'))
             .height($r('app.float.robot_image_select_size'))
             .width($r('app.float.robot_image_select_size'))
@@ -207,11 +205,11 @@ export struct BottomOperateComp {
         .height('100%')
         .width('7%')
         .justifyContent(FlexAlign.Center)
-        .onClick(()=>{
+        .onClick(() => {
           this.dialogController1.open()
         })
 
-        Row(){
+        Row() {
           Image($r('app.media.jg_circular_icon'))
             .height($r('app.float.storage_space_set_size'))
             .width($r('app.float.storage_space_set_size'))
@@ -219,9 +217,9 @@ export struct BottomOperateComp {
         .height('100%')
         .width('7%')
         .justifyContent(FlexAlign.Center)
-        .onClick(()=>{
+        .onClick(() => {
           router.pushUrl({
-            url:'pages/SmartFactory'
+            url: 'pages/StationDevicesPage'
           })
         })
         .gesture(
@@ -230,21 +228,22 @@ export struct BottomOperateComp {
             })
         )
 
-        Row(){
+        Row() {
           Image($r('app.media.page_flow'))
             .height($r('app.float.robot_image_select_size'))
             .width($r('app.float.robot_image_select_size'))
-          .onClick(() => {
-            this.showDeviceDialog()
-          //   router.pushUrl({
-          //     url:'pages/DistributedPage'
-          //   })
-           })
+            .onClick(() => {
+              this.showDeviceDialog()
+              //   router.pushUrl({
+              //     url:'pages/DistributedPage'
+              //   })
+            })
         }
         .height('100%')
         .width('7%')
         .justifyContent(FlexAlign.Center)
-        Row(){
+
+        Row() {
           Image($r('app.media.camera'))
             .height($r('app.float.robot_image_select_size'))
             .width($r('app.float.robot_image_select_size'))
@@ -254,7 +253,6 @@ export struct BottomOperateComp {
         .justifyContent(FlexAlign.Center)
 
 
-
         // Image($r('app.media.volume'))
         //   .height($r('app.float.general_icon_size'))
         //   .width($r('app.float.general_icon_size'))
@@ -272,9 +270,10 @@ export struct BottomOperateComp {
 @CustomDialog
 struct NoticeDialog {
   controller: CustomDialogController
-  Notices: NoticeInfo[]=[]
+  Notices: NoticeInfo[] = []
+
   build() {
-    Column({space: 10}) {
+    Column({ space: 10 }) {
       Row() {
         Text('通知')
           .fontSize($r('app.float.fontSize_24'))
@@ -282,11 +281,12 @@ struct NoticeDialog {
           .fontColor($r('app.color.general_font_color'))
           .opacity($r('app.float.general_font_opacity'))
       }
-      Row(){
-        List(){
-          ForEach(this.Notices, (item:NoticeInfo) => {
-            ListItem(){
-              Row(){
+
+      Row() {
+        List() {
+          ForEach(this.Notices, (item: NoticeInfo) => {
+            ListItem() {
+              Row() {
                 Text(item.Notice)
                   .fontSize($r('app.float.fontSize_24'))
                   .fontColor($r('app.color.general_font_color'))

+ 1 - 1
entry/src/main/ets/common/component/TitleStateComp.ets

@@ -112,7 +112,7 @@ export struct TitleStateComp {
               .width(px2vp(48))// .backgroundColor(Color.Green)
               .onClick(() => {
                 router.pushUrl({
-                  url: 'pages/SmartFactory'
+                  url: 'pages/StationDevicesPage'
                 })
               })
           }

+ 209 - 190
entry/src/main/ets/pages/Index.ets

@@ -1,12 +1,12 @@
-import {componentLocation} from  '../model/ComponentLocation'
+import { componentLocation } from '../model/ComponentLocation'
 import { TitleStateComp } from '../common/component/TitleStateComp';
 import { BottomOperateComp } from '../common/component/BottomOperateComp';
 import router from '@ohos.router'
 import { TaskComp } from '../common/component/TaskComp'
-import {  Warehousing}from  '../common/component/Warehousing'
-import { SmartFactoryCard }from  '../common/component/SmartFactoryCard'
+import { Warehousing } from '../common/component/Warehousing'
+import { SmartFactoryCard } from '../common/component/SmartFactoryCard'
 import CommonConstants from '../common/constants/CommonConstants'
-import UniversalCard from  '../model/UniversalCard'
+import UniversalCard from '../model/UniversalCard'
 import UniversalCardModel from '../model/database/UniversalCardModel';
 import JGRequest from '../common/util/request/Request';
 import DictInfo from '../model/DictInfo';
@@ -17,27 +17,30 @@ import deviceManager from '@ohos.distributedDeviceManager';
 import { RemoteDeviceModel, BUNDLE_NAME } from '../model/RemoteDeviceModel'
 import { DeviceDialog } from '../common/DeviceDialog';
 import Want from '@ohos.app.ability.Want';
+
 const TAG: string = 'testTag'
 const DATA_CHANGE: string = 'dataChange'
 const DATA_CHANGE1: number = 0
 const EXIT: string = 'exit'
+
 @CustomDialog
 struct confirmPopup {
-  cardType: number=0
-  private  cardServices?:UniversalCard[]
+  cardType: number = 0
+  private cardServices?: UniversalCard[]
   controller: CustomDialogController
   @Link x: number
-  @Link  y: number
-  @Link cardSorting:number
-  build(){
-    Column(){
-      Column(){
-        Row(){
+  @Link y: number
+  @Link cardSorting: number
+
+  build() {
+    Column() {
+      Column() {
+        Row() {
           Image($r('app.media.card'))
             .width(px2vp(50))
             .height(px2vp(50))
           Text('卡片服务')
-            .padding({left:10})
+            .padding({ left: 10 })
             .margin(px2vp(5))
             .width('100%')
             .height('100%')
@@ -46,12 +49,13 @@ struct confirmPopup {
             .textAlign(TextAlign.Start)
 
 
-        }.width('100%')
+        }
+        .width('100%')
         .height('80%')
-        .padding({left:10})
+        .padding({ left: 10 })
         .borderRadius(px2vp(15))
         .backgroundColor($r('app.color.general_font_white_color'))
-        .onClick(async ()=>{
+        .onClick(async () => {
           // 第一种遍历, const后面的是变量,变量的值就是数组的元素
           // for (const card of this.cardServices) {
           //
@@ -59,19 +63,19 @@ struct confirmPopup {
           // }
           // 第二种遍历,index是数组索引
           // 1.修改变量数组中,此卡片类型的对象(改为打开状态)
-          let temp: UniversalCard={}
-          let deleteIndex: number=0
+          let temp: UniversalCard = {}
+          let deleteIndex: number = 0
           if (!this.cardServices) {
             console.log("TextTag1", this.cardServices)
             return
           }
           console.log("TextTag2", this.cardServices)
-          for (let index=0; index < this.cardServices.length; index++) {
+          for (let index = 0; index < this.cardServices.length; index++) {
             if (this.cardServices[index].cardType === this.cardType) {
-              this.cardServices[index].cardStatus  = 1
+              this.cardServices[index].cardStatus = 1
               temp = this.cardServices[index]
               deleteIndex = index
-              console.log("TextTag3",this.cardServices)
+              console.log("TextTag3", this.cardServices)
               break
             }
           }
@@ -82,10 +86,10 @@ struct confirmPopup {
           this.cardServices.splice(deleteIndex, 1)
           // 3.修改排序号
           let sort: number = 0
-          if (this.cardServices===undefined) {
+          if (this.cardServices === undefined) {
             return
           }
-          for (let index=0; index < this.cardServices.length; index++) {
+          for (let index = 0; index < this.cardServices.length; index++) {
             this.cardServices[index].cardSort = sort
             // 4.更新数据库数据
             await UniversalCardModel.updateUniversalCard(this.cardServices[index])
@@ -93,72 +97,78 @@ struct confirmPopup {
           }
           // 5.变量数组添加元素
           temp.cardSort = this.cardServices.length
-          console.log("TextTag",temp)
+          console.log("TextTag", temp)
           this.cardServices.push(temp)
 
           // 6.修改数据入库
           await UniversalCardModel.updateUniversalCard(temp)
           this.controller.close()
         })
+
         Divider()
           .width('80%')
 
       }
-      .margin({bottom:5})
+      .margin({ bottom: 5 })
       .borderRadius(px2vp(15))
       .height('20%')
       .width('120%')
       .backgroundColor($r('app.color.general_font_white_color'))
-      Image(this.cardSorting===1?$r("app.media.processImages")
-        :this.cardSorting===2?$r('app.media.jg_circular_icon'):$r('app.media.storage'))
-        .width(this.cardSorting===2?px2vp(120):px2vp(280))
-        .height(this.cardSorting===2?px2vp(120):px2vp(280))
+
+      Image(this.cardSorting === 1 ? $r("app.media.processImages")
+        : this.cardSorting === 2 ? $r('app.media.jg_circular_icon') : $r('app.media.storage'))
+        .width(this.cardSorting === 2 ? px2vp(120) : px2vp(280))
+        .height(this.cardSorting === 2 ? px2vp(120) : px2vp(280))
         .borderRadius(15)
     }
     .alignItems(HorizontalAlign.Start)
     .width('350px')
     .height('600px')
-    .offset(this.cardSorting===2?{x:this.x+50+'px', y:this.y-270+'px'}:{x:this.x+5+'px', y:this.y-410+'px'})
+    .offset(this.cardSorting === 2 ? { x: this.x + 50 + 'px', y: this.y - 270 + 'px' } : {
+      x: this.x + 5 + 'px',
+      y: this.y - 410 + 'px'
+    })
   }
 }
+
 @Entry
 @Component
 struct Index {
-
-  private cardType:number=0
-  @State cardSorting:number=0
-  @State x:number=0
-  @State y:number=0
-  @State cardServices: UniversalCard[]=[{}]
-  @State  SmartFactoryCardDelete:number=0
-  @State SmartFactoryDelete:number=0
-  @State  SmartFactoryCarLongPressDelete:number=0
-  @State storageCardDelete:number=0
-  @State smartWarehouseCard:number=0
-  @State avatarFrame:boolean=false
-  @State deleteConfirmation:number=0
-  @State longPressDelete:number=0
+  private cardType: number = 0
+  @State cardSorting: number = 0
+  @State x: number = 0
+  @State y: number = 0
+  @State cardServices: UniversalCard[] = [{}]
+  @State SmartFactoryCardDelete: number = 0
+  @State SmartFactoryDelete: number = 0
+  @State SmartFactoryCarLongPressDelete: number = 0
+  @State storageCardDelete: number = 0
+  @State smartWarehouseCard: number = 0
+  @State avatarFrame: boolean = false
+  @State deleteConfirmation: number = 0
+  @State longPressDelete: number = 0
   scroller: Scroller = new Scroller()
-  @State shutdownTransparency:number=0
+  @State shutdownTransparency: number = 0
   @State YanSe: number = 0
-  @State carswitch:number=0
+  @State carswitch: number = 0
   private isHomePage: boolean = true
   @State textValue: string = ''
   @State inputValue: string = ''
   confirmPopupDialogController: CustomDialogController = new CustomDialogController({
     builder: confirmPopup({
-      cardType:this.cardType,
-      x:this.x,
-      y:this.y,
-      cardSorting:this.cardSorting,
-      cardServices:this.cardServices
+      cardType: this.cardType,
+      x: this.x,
+      y: this.y,
+      cardSorting: this.cardSorting,
+      cardServices: this.cardServices
     }
-      ),
+    ),
     alignment: DialogAlignment.TopStart,
-    autoCancel:true,
-    customStyle:true,
+    autoCancel: true,
+    customStyle: true,
   })
-  async aboutToAppear(){
+
+  async aboutToAppear() {
     // 查询数据字典放到CommonConstants的DICT_DATA变量中
     let res: DictInfo[] = await JGRequest.post('/api/v1/sys/dictData/all',)
     if (res && res.length > 0) {
@@ -168,7 +178,7 @@ struct Index {
     }
 
     // 1.根据当前用户id查询他配置的万能卡片
-    let res1 :UniversalCard[] | undefined = await UniversalCardModel.getListByUserId(CommonConstants.USER_ID as number)
+    let res1: UniversalCard[] | undefined = await UniversalCardModel.getListByUserId(CommonConstants.USER_ID as number)
     if (res1 && res.length > 0) {
       this.cardServices = res1
     }
@@ -176,10 +186,10 @@ struct Index {
     if (!this.cardServices || this.cardServices.length <= 0) {
       // 2.1用户第一次登录,所有的万能卡片都展示
       for (let index = 0; index < CommonConstants.CARD_TYPE_DATA.length; index++) {
-        const card:UniversalCard = {
-          userId:CommonConstants.USER_ID,
+        const card: UniversalCard = {
+          userId: CommonConstants.USER_ID,
           cardType: CommonConstants.CARD_TYPE_DATA[index],
-          cardStatus:1,
+          cardStatus: 1,
           cardSort: index
         };
         // 3.1用户的万能卡片入库,(以后再次打开页面能够查询到)
@@ -206,18 +216,17 @@ struct Index {
 
     })
   }
-  @State @Watch('dataChange')  click: number = 0;
-  @State  click1: number = 0;
-  @State @Watch('dataChange')  message: string = 'Hello World';
+
+  @State @Watch('dataChange') click: number = 0;
+  @State click1: number = 0;
+  @State @Watch('dataChange') message: string = 'Hello World';
   @State inputMsg: string = '';
   @State isDistributed: boolean = false
   @StorageLink('deviceList') deviceList: Array<deviceManager.DeviceBasicInfo> = []
   @State selectedIndex: number | undefined = -1
-
   private remoteDeviceModel: RemoteDeviceModel = new RemoteDeviceModel()
   private kvStoreModel: KvStoreModel = new KvStoreModel()
   private dialogController: CustomDialogController | null = null
-
   onSelectedIndexChange = async (index: number | undefined) => {
     console.info(TAG, `selectedIndexChange`)
     this.selectedIndex = index
@@ -282,15 +291,15 @@ struct Index {
     console.debug(TAG, `startAbility deviceId: ${deviceId}`)
     let context = getContext(this) as common.UIAbilityContext
 
-      let want: Want = {
-        bundleName: BUNDLE_NAME,
-        //abilityName: 'MainAbility',
-        abilityName: 'EntryAbility',
-        deviceId: deviceId,
-        parameters: {
-          isRemote: 'isRemote'
-        }
+    let want: Want = {
+      bundleName: BUNDLE_NAME,
+      //abilityName: 'MainAbility',
+      abilityName: 'EntryAbility',
+      deviceId: deviceId,
+      parameters: {
+        isRemote: 'isRemote'
       }
+    }
 
 
     context.startAbility(want).then((data) => {
@@ -345,27 +354,28 @@ struct Index {
       this.dialogController.open()
     }
   }
+
   build() {
-    Stack(){
+    Stack() {
       Row() {
         Column() {
-          TitleStateComp({ isHomePage: this.isHomePage,})
-            .onClick(()=>{
-              this.avatarFrame=!this.avatarFrame
+          TitleStateComp({ isHomePage: this.isHomePage, })
+            .onClick(() => {
+              this.avatarFrame = !this.avatarFrame
             })
           Row() {
             Column() {
-              Grid(){
-                ForEach(this.cardServices, (item:UniversalCard,index:number)=>{
+              Grid() {
+                ForEach(this.cardServices, (item: UniversalCard, index: number) => {
                   if (item.cardStatus === 1) {
-                    GridItem(){
-                      if (item.cardType===3){
-                        Stack(){
-                          Column(){
-                            TaskComp({isHomePage: this.isHomePage})
+                    GridItem() {
+                      if (item.cardType === 3) {
+                        Stack() {
+                          Column() {
+                            TaskComp({ isHomePage: this.isHomePage })
                             Text('生产操作')
                               .fontSize(px2vp(27))
-                              .margin({top:5})
+                              .margin({ top: 5 })
                               .fontWeight(FontWeight.Medium)
                               .fontColor($r('app.color.robot_set_card_white'))
                           }
@@ -374,11 +384,12 @@ struct Index {
                           .gesture(
                             LongPressGesture({ repeat: false })
                               .onActionEnd(() => {
-                                this.deleteConfirmation=1
+                                this.deleteConfirmation = 1
                               })
                           )
-                          if (this.deleteConfirmation===1){
-                            Row(){
+
+                          if (this.deleteConfirmation === 1) {
+                            Row() {
                               Text('取消')
                                 .fontWeight(FontWeight.Medium)
                                 .fontSize(px2vp(27))
@@ -389,8 +400,8 @@ struct Index {
                                 .borderRadius(px2vp(21))
                                 .fontColor($r('app.color.robot_set_card_blue'))
                                 .backgroundColor($r('app.color.general_font_white_color'))
-                                .onClick(()=>{
-                                  this.deleteConfirmation=0
+                                .onClick(() => {
+                                  this.deleteConfirmation = 0
                                 })
                               Text('删除')
                                 .fontWeight(FontWeight.Medium)
@@ -401,8 +412,8 @@ struct Index {
                                 .borderRadius(px2vp(21))
                                 .height('20%')
                                 .textAlign(TextAlign.Center)
-                                .backgroundColor(  $r('app.color.robot_set_card_blue'))
-                                .onClick(async()=>{
+                                .backgroundColor($r('app.color.robot_set_card_blue'))
+                                .onClick(async () => {
                                   this.deleteConfirmation = 0
                                   // 删除卡片
                                   await this.deleteCard(index);
@@ -413,31 +424,32 @@ struct Index {
                             .width('95%')
                           }
                         }
-                      } else if (item.cardType===1){
-                        Stack(){
-                          Column(){
+                      } else if (item.cardType === 1) {
+                        Stack() {
+                          Column() {
                             Warehousing()
                             Text('智能仓储')
-                              .margin({top:5})
+                              .margin({ top: 5 })
                               .fontSize(px2vp(27))
                               .fontWeight(FontWeight.Medium)
                               .fontColor($r('app.color.robot_set_card_white'))
                           }
                           .height('40%')
                           .width('95%')
-                          .onClick(()=>{
+                          .onClick(() => {
                             router.pushUrl({
-                              url:'pages/Storage'
+                              url: 'pages/Storage'
                             })
                           })
                           .gesture(
                             LongPressGesture({ repeat: false })
                               .onActionEnd(() => {
-                                this.smartWarehouseCard=1
+                                this.smartWarehouseCard = 1
                               })
                           )
-                          if (this.smartWarehouseCard===1){
-                            Row(){
+
+                          if (this.smartWarehouseCard === 1) {
+                            Row() {
                               Text('取消')
                                 .fontWeight(FontWeight.Medium)
                                 .fontSize(px2vp(27))
@@ -448,8 +460,8 @@ struct Index {
                                 .borderRadius(px2vp(21))
                                 .fontColor($r('app.color.robot_set_card_blue'))
                                 .backgroundColor($r('app.color.general_font_white_color'))
-                                .onClick(()=>{
-                                  this.smartWarehouseCard=0
+                                .onClick(() => {
+                                  this.smartWarehouseCard = 0
                                 })
                               Text('删除')
                                 .fontWeight(FontWeight.Medium)
@@ -460,9 +472,9 @@ struct Index {
                                 .borderRadius(px2vp(21))
                                 .height('20%')
                                 .textAlign(TextAlign.Center)
-                                .backgroundColor(  $r('app.color.robot_set_card_blue'))
-                                .onClick(async ()=>{
-                                  this.smartWarehouseCard=0
+                                .backgroundColor($r('app.color.robot_set_card_blue'))
+                                .onClick(async () => {
+                                  this.smartWarehouseCard = 0
                                   // 删除卡片
                                   await this.deleteCard(index);
                                 })
@@ -472,31 +484,32 @@ struct Index {
                             .width('95%')
                           }
                         }
-                      } else if (item.cardType===5){
-                        Stack(){
-                          Column(){
+                      } else if (item.cardType === 5) {
+                        Stack() {
+                          Column() {
                             SmartFactoryCard()
                             Text('智汇工厂')
-                              .margin({top:5})
+                              .margin({ top: 5 })
                               .fontSize(px2vp(27))
                               .fontWeight(FontWeight.Medium)
                               .fontColor($r('app.color.robot_set_card_white'))
                           }
                           .height('40%')
                           .width('95%')
-                          .onClick(()=>{
+                          .onClick(() => {
                             router.pushUrl({
-                              url:'pages/SmartFactory'
+                              url: 'pages/StationDevicesPage'
                             })
                           })
                           .gesture(
                             LongPressGesture({ repeat: false })
                               .onActionEnd(() => {
-                                this.SmartFactoryCarLongPressDelete=1
+                                this.SmartFactoryCarLongPressDelete = 1
                               })
                           )
-                          if (this.SmartFactoryCarLongPressDelete===1){
-                            Row(){
+
+                          if (this.SmartFactoryCarLongPressDelete === 1) {
+                            Row() {
                               Text('取消')
                                 .fontWeight(FontWeight.Medium)
                                 .fontSize(px2vp(27))
@@ -507,8 +520,8 @@ struct Index {
                                 .borderRadius(px2vp(21))
                                 .fontColor($r('app.color.robot_set_card_blue'))
                                 .backgroundColor($r('app.color.general_font_white_color'))
-                                .onClick(()=>{
-                                  this.SmartFactoryCarLongPressDelete=0
+                                .onClick(() => {
+                                  this.SmartFactoryCarLongPressDelete = 0
                                 })
                               Text('删除')
                                 .fontWeight(FontWeight.Medium)
@@ -519,9 +532,9 @@ struct Index {
                                 .borderRadius(px2vp(21))
                                 .height('20%')
                                 .textAlign(TextAlign.Center)
-                                .backgroundColor(  $r('app.color.robot_set_card_blue'))
-                                .onClick(async ()=>{
-                                  this.SmartFactoryCarLongPressDelete=0
+                                .backgroundColor($r('app.color.robot_set_card_blue'))
+                                .onClick(async () => {
+                                  this.SmartFactoryCarLongPressDelete = 0
                                   // 删除卡片
                                   await this.deleteCard(index);
                                 })
@@ -549,13 +562,14 @@ struct Index {
           .justifyContent(FlexAlign.Center)
           .width('100%')
           .height('68%')
+
           Row({ space: 10 }) {
             Text().width('1%')
             Column({ space: 10 }) {
               Image($r("app.media.shezhi"))
                 .width('60%')
                 .height('60%')
-                .margin({top:5})
+                .margin({ top: 5 })
               Text('设置')
                 .width('100%')
                 .textAlign(TextAlign.Center)
@@ -573,11 +587,12 @@ struct Index {
                 url: 'pages/SetPage'
               })
             })
+
             Column({ space: 10 }) {
               Image($r("app.media.storage"))
                 .width('60%')
                 .height('60%')
-                .margin({top:5})
+                .margin({ top: 5 })
               Text('智能仓储')
                 .width('100%')
                 .textAlign(TextAlign.Center)
@@ -593,7 +608,7 @@ struct Index {
             .onClick(() => {
               router.pushUrl({
                 url: 'pages/Warehousing'
-               // url: 'pages/Storage'
+                // url: 'pages/Storage'
               })
             })
             .gesture(
@@ -601,30 +616,31 @@ struct Index {
                 .onActionEnd(() => {
                   let rect = componentLocation.getComponentRect('smartWarehousing')
                   let touchPoint: TouchObject = {
-                    displayX:0,
-                    displayY:0,
-                    windowX:0,
-                    windowY:0,
+                    displayX: 0,
+                    displayY: 0,
+                    windowX: 0,
+                    windowY: 0,
                     id: 1,
                     x: rect.left, // 组件中心点x坐标
-                    y:rect.bottom, // 组件中心点y坐标
+                    y: rect.bottom, // 组件中心点y坐标
                     type: TouchType.Down,
                     screenX: rect.left + (rect.right - rect.left) / 2, // 组件中心点x坐标
                     screenY: rect.left + (rect.right - rect.left) / 2, // 组件中心点y坐标
                   }
-                  this.x=touchPoint.x
-                  this.y=touchPoint.y
-                  this.cardSorting=1
-                  this.cardType=1
+                  this.x = touchPoint.x
+                  this.y = touchPoint.y
+                  this.cardSorting = 1
+                  this.cardType = 1
                   this.confirmPopupDialogController.open()
 
                 })
             )
+
             Column({ space: 10 }) {
               Image($r('app.media.jiqiren'))
                 .width('60%')
                 .height('60%')
-                .margin({top:5})
+                .margin({ top: 5 })
               Text('机器人调试')
                 .width('100%')
                 .textAlign(TextAlign.Center)
@@ -646,7 +662,7 @@ struct Index {
               Image($r("app.media.processImages"))
                 .width('60%')
                 .height('60%')
-                .margin({top:5})
+                .margin({ top: 5 })
               Text('工序操作')
                 .width('100%')
                 .textAlign(TextAlign.Center)
@@ -670,21 +686,21 @@ struct Index {
                 .onActionEnd(() => {
                   let rect = componentLocation.getComponentRect('workingProcedure')
                   let touchPoint: TouchObject = {
-                    displayX:0,
-                    displayY:0,
-                    windowX:0,
-                    windowY:0,
+                    displayX: 0,
+                    displayY: 0,
+                    windowX: 0,
+                    windowY: 0,
                     id: 1,
                     x: rect.left, // 组件中心点x坐标
-                    y:rect.bottom, // 组件中心点y坐标
+                    y: rect.bottom, // 组件中心点y坐标
                     type: TouchType.Down,
                     screenX: rect.left + (rect.right - rect.left) / 2, // 组件中心点x坐标
                     screenY: rect.left + (rect.right - rect.left) / 2, // 组件中心点y坐标
                   }
-                  this.x=touchPoint.x
-                  this.y=touchPoint.y
-                  this.cardSorting=0
-                  this.cardType=3
+                  this.x = touchPoint.x
+                  this.y = touchPoint.y
+                  this.cardSorting = 0
+                  this.cardType = 3
                   this.confirmPopupDialogController.open()
                 })
             )
@@ -693,7 +709,7 @@ struct Index {
               Image($r('app.media.baobiao'))
                 .width('60%')
                 .height('60%')
-                .margin({top:5})
+                .margin({ top: 5 })
               Text('统计报表')
                 .width('100%')
                 .textAlign(TextAlign.Center)
@@ -709,40 +725,43 @@ struct Index {
             .height('90%')
             .borderRadius(15)
             .backgroundColor('#4d000000')
-          //   Column({ space: 10 }) {
-          //     Image($r('app.media.baobiao'))
-          //       .width('60%')
-          //       .height('60%')
-          //       .margin({top:5})
-          //     Text('维修站')
-          //       .width('100%')
-          //       .textAlign(TextAlign.Center)
-          //       .fontSize(16)
-          //       .fontColor('#ffff')
-          //
-          //   }
-          //   .width('10%')
-          //   .justifyContent(FlexAlign.Center)
-          //   .height('90%')
-          //   .borderRadius(15)
-          //   .backgroundColor('#4d000000')
-          //   .onClick(()=>{
-          //     router.pushUrl({
-          //       url:'pages/MaintenanceStation'
-          //     })
-          //   })
-           }
+
+            //   Column({ space: 10 }) {
+            //     Image($r('app.media.baobiao'))
+            //       .width('60%')
+            //       .height('60%')
+            //       .margin({top:5})
+            //     Text('维修站')
+            //       .width('100%')
+            //       .textAlign(TextAlign.Center)
+            //       .fontSize(16)
+            //       .fontColor('#ffff')
+            //
+            //   }
+            //   .width('10%')
+            //   .justifyContent(FlexAlign.Center)
+            //   .height('90%')
+            //   .borderRadius(15)
+            //   .backgroundColor('#4d000000')
+            //   .onClick(()=>{
+            //     router.pushUrl({
+            //       url:'pages/MaintenanceStation'
+            //     })
+            //   })
+          }
           .width('100%')
           .height('16%')
-          Stack(){
-            BottomOperateComp({ isHomePage: this.isHomePage})
-            Row(){
-              Text().width('100%')
+
+          Stack() {
+            BottomOperateComp({ isHomePage: this.isHomePage })
+            Row() {
+              Text()
+                .width('100%')
                 .height('100%')
                 .id('Warehousing')
-                .onClick(()=>{
+                .onClick(() => {
                   router.pushUrl({
-                    url:'pages/SmartFactory',
+                    url: 'pages/StationDevicesPage',
                   })
                 })
                 .gesture(
@@ -750,21 +769,21 @@ struct Index {
                     .onActionEnd(() => {
                       let rect = componentLocation.getComponentRect('Warehousing')
                       let touchPoint: TouchObject = {
-                        displayX:0,
-                        displayY:0,
-                        windowX:0,
-                        windowY:0,
+                        displayX: 0,
+                        displayY: 0,
+                        windowX: 0,
+                        windowY: 0,
                         id: 2,
                         x: rect.left, // 组件中心点x坐标
-                        y:rect.bottom, // 组件中心点y坐标
+                        y: rect.bottom, // 组件中心点y坐标
                         type: TouchType.Down,
                         screenX: rect.left + (rect.right - rect.left) / 2, // 组件中心点x坐标
                         screenY: rect.left + (rect.right - rect.left) / 2, // 组件中心点y坐标
                       }
-                      this.x=touchPoint.x
-                      this.y=touchPoint.y
-                      this.cardSorting=2
-                      this.cardType=5
+                      this.x = touchPoint.x
+                      this.y = touchPoint.y
+                      this.cardSorting = 2
+                      this.cardType = 5
                       this.confirmPopupDialogController.open()
                     })
                 )
@@ -792,16 +811,16 @@ struct Index {
   // 删除卡片
   private async deleteCard(index: number) {
     // 1.修改变量中cardStatus为2,关闭状态
-    if (this.cardServices===undefined) {
-    return
+    if (this.cardServices === undefined) {
+      return
     }
-      this.cardServices[index]  = {
-        id: this.cardServices[index].id,
-        userId: this.cardServices[index].userId,
-        cardType: this.cardServices[index].cardType,
-        cardStatus: 2,
-        cardSort: this.cardServices[index].cardSort,
-      };
+    this.cardServices[index] = {
+      id: this.cardServices[index].id,
+      userId: this.cardServices[index].userId,
+      cardType: this.cardServices[index].cardType,
+      cardStatus: 2,
+      cardSort: this.cardServices[index].cardSort,
+    };
     // 2.更新数据库,当前删除的卡片状态
     await UniversalCardModel.updateUniversalCard(this.cardServices[index]);
     // 3.其他数据的修改排序

+ 140 - 14
entry/src/main/ets/pages/SmartFactory.ets

@@ -55,20 +55,146 @@ struct SmartFactory {
   @State open: number = 0
   //注释掉的是假数据,实际更具请求硬件获取
   @State private items: Array<hardwareList> = [
-  //  {name:'三色灯',state:'关',text:'装配工位001',type:$r('app.media.sansedeng'),open:$r('app.media.open'), colse:$r('app.media.colse'), select:true,temp:1}as hardwareList,
-  //  {name:'扫码枪',state:'开',text:'装配工位001',type:$r('app.media.saomaqiang'),open:$r('app.media.open'),colse:$r('app.media.colse'),select:true,temp:2}as hardwareList,
-  //  {name:'电能表',state:'关',text:'装配工位001',type:$r('app.media.diannengbiao'),open:$r('app.media.open'),colse:$r('app.media.colse'),select:true,temp:3}as hardwareList,
-  //  {name:'万用表',state:'开',text:'装配工位001',type:$r('app.media.multimeter'),open:$r('app.media.open'),colse:$r('app.media.colse'),select:true,temp:6}as hardwareList,
-  //  {name:'RFID工位读卡器',state:'关',text:'装配工位001',type:$r('app.media.dukaqi'),open:$r('app.media.open'),colse:$r('app.media.colse'),select:true,temp:7}as hardwareList,
-  //  {name:'程控电源',state:'开',text:'装配工位001',type:$r('app.media.chengkongdianyuan'),open:$r('app.media.open'),colse:$r('app.media.colse'),select:true,temp:8}as hardwareList,
-  //  {name:'数控电烙铁',state:'开',text:'装配工位001',type:$r('app.media.shukongdian'),open:$r('app.media.open'),colse:$r('app.media.colse'),select:true,temp:9}as hardwareList,
-  //  {name:'电动螺丝刀',state:'开',text:'装配工位001',type:$r('app.media.diandongluosidao'),open:$r('app.media.open'),colse:$r('app.media.colse'),select:true,temp:10}as hardwareList,
-  //  {name:'照明灯',state:'开',text:'装配工位001',type:$r('app.media.zhaomingdeng'),open:$r('app.media.open'),colse:$r('app.media.colse'),select:true,temp:11}as hardwareList,
-  //  {name:'镊子',state:'开',text:'装配工位001',type:$r('app.media.tweezers'),open:$r('app.media.open'),colse:$r('app.media.colse'),select:true,temp:12}as hardwareList,
-  //  {name:'扳手',state:'开',text:'装配工位001',type:$r('app.media.wrench'),open:$r('app.media.open'),colse:$r('app.media.colse'),select:true,temp:13}as hardwareList,
-  // {name:'放大镜',state:'开',text:'装配工位001',type:$r('app.media.magnifier'),open:$r('app.media.open'),colse:$r('app.media.colse'),select:true,temp:14}as hardwareList,
-  //  {name:'焊烟净化器',state:'开',text:'装配工位001',type:$r('app.media.Weldingfumepurifier'),open:$r('app.media.open'),colse:$r('app.media.colse'),select:true,temp:15}as hardwareList,
-  //  {name:'螺丝刀-十字',state:'开',text:'装配工位001',type:$r('app.media.screwdriver'),open:$r('app.media.open'),colse:$r('app.media.colse'),select:true,temp:16}as hardwareList,
+    {
+      name: '三色灯',
+      state: '关',
+      text: '装配工位001',
+      type: $r('app.media.sansedeng'),
+      open: $r('app.media.open'),
+      colse: $r('app.media.colse'),
+      select: true,
+      temp: 1
+    } as hardwareList,
+    {
+      name: '扫码枪',
+      state: '开',
+      text: '装配工位001',
+      type: $r('app.media.saomaqiang'),
+      open: $r('app.media.open'),
+      colse: $r('app.media.colse'),
+      select: true,
+      temp: 2
+    } as hardwareList,
+    {
+      name: '电能表',
+      state: '关',
+      text: '装配工位001',
+      type: $r('app.media.diannengbiao'),
+      open: $r('app.media.open'),
+      colse: $r('app.media.colse'),
+      select: true,
+      temp: 3
+    } as hardwareList,
+    {
+      name: '万用表',
+      state: '开',
+      text: '装配工位001',
+      type: $r('app.media.multimeter'),
+      open: $r('app.media.open'),
+      colse: $r('app.media.colse'),
+      select: true,
+      temp: 6
+    } as hardwareList,
+    {
+      name: 'RFID工位读卡器',
+      state: '关',
+      text: '装配工位001',
+      type: $r('app.media.dukaqi'),
+      open: $r('app.media.open'),
+      colse: $r('app.media.colse'),
+      select: true,
+      temp: 7
+    } as hardwareList,
+    {
+      name: '程控电源',
+      state: '开',
+      text: '装配工位001',
+      type: $r('app.media.chengkongdianyuan'),
+      open: $r('app.media.open'),
+      colse: $r('app.media.colse'),
+      select: true,
+      temp: 8
+    } as hardwareList,
+    {
+      name: '数控电烙铁',
+      state: '开',
+      text: '装配工位001',
+      type: $r('app.media.shukongdian'),
+      open: $r('app.media.open'),
+      colse: $r('app.media.colse'),
+      select: true,
+      temp: 9
+    } as hardwareList,
+    {
+      name: '电动螺丝刀',
+      state: '开',
+      text: '装配工位001',
+      type: $r('app.media.diandongluosidao'),
+      open: $r('app.media.open'),
+      colse: $r('app.media.colse'),
+      select: true,
+      temp: 10
+    } as hardwareList,
+    {
+      name: '照明灯',
+      state: '开',
+      text: '装配工位001',
+      type: $r('app.media.zhaomingdeng'),
+      open: $r('app.media.open'),
+      colse: $r('app.media.colse'),
+      select: true,
+      temp: 11
+    } as hardwareList,
+    {
+      name: '镊子',
+      state: '开',
+      text: '装配工位001',
+      type: $r('app.media.tweezers'),
+      open: $r('app.media.open'),
+      colse: $r('app.media.colse'),
+      select: true,
+      temp: 12
+    } as hardwareList,
+    {
+      name: '扳手',
+      state: '开',
+      text: '装配工位001',
+      type: $r('app.media.wrench'),
+      open: $r('app.media.open'),
+      colse: $r('app.media.colse'),
+      select: true,
+      temp: 13
+    } as hardwareList,
+    {
+      name: '放大镜',
+      state: '开',
+      text: '装配工位001',
+      type: $r('app.media.magnifier'),
+      open: $r('app.media.open'),
+      colse: $r('app.media.colse'),
+      select: true,
+      temp: 14
+    } as hardwareList,
+    {
+      name: '焊烟净化器',
+      state: '开',
+      text: '装配工位001',
+      type: $r('app.media.Weldingfumepurifier'),
+      open: $r('app.media.open'),
+      colse: $r('app.media.colse'),
+      select: true,
+      temp: 15
+    } as hardwareList,
+    {
+      name: '螺丝刀-十字',
+      state: '开',
+      text: '装配工位001',
+      type: $r('app.media.screwdriver'),
+      open: $r('app.media.open'),
+      colse: $r('app.media.colse'),
+      select: true,
+      temp: 16
+    } as hardwareList,
   ]
   private scrollerForList: Scroller = new Scroller()
   scroller: Scroller = new Scroller()

+ 124 - 0
entry/src/main/ets/pages/StationDevicesPage.ets

@@ -0,0 +1,124 @@
+// 工位的设备列表
+import router from '@ohos.router'
+import EquipmentRequest from '../common/util/request/EquipmentRequest'
+import { carPositionClass } from './WarehouseMap'
+
+export class HardwareModel {
+  name?: string
+  text?: string
+  type?: Resource
+  open?: Resource
+  colse?: Resource
+  select?: boolean
+  temp?: number
+  manufacturer?: string //: "厂家",
+  brand?: string //"品牌或型号,比如JBC",
+  deviceName?: string //"设备自定义名称或资产编号",
+  deviceType?: string // "类别,比如电络铁",
+  deviceNo?: string // "设备编号,唯一号",
+  devicePic?: string // "图片",
+  state?: number //"状态:0正常,-1:离线,1故障",
+  workshop?: string //"产线",
+  station?: string //"工站/工位",
+  devicePosition?: string // "空间位置,目前暂时不用",
+  data?: HardwareModel[]
+}
+
+
+@Entry
+@Component
+struct StationDevicesPage {
+  //注释掉的是假数据,实际更具请求硬件获取
+  @State private items: Array<HardwareModel> = []
+  scroller: Scroller = new Scroller()
+  getDeviceList = async () => {
+    let res: HardwareModel = await EquipmentRequest.get('/api/v1/device/list') as HardwareModel
+    this.items = res?.data?.filter((device) => {
+      return device.state! === 0
+    }) ?? []
+  }
+
+  aboutToAppear(): void {
+    this.getDeviceList()
+  }
+
+  build() {
+    Column() {
+      Row() {
+        Image($r('app.media.back_white'))
+          .height(px2vp(48))
+          .width(px2vp(48))
+          .onClick(async () => {
+            router.back()
+          })
+      }
+      .width('100%')
+      .height('8%')
+      .alignItems(VerticalAlign.Center)
+      .justifyContent(FlexAlign.Start)
+
+      Column() {
+
+        //  Scroll(this.scroller){
+        Grid(this.scroller) {
+          ForEach(this.items, (item: HardwareModel, index) => {
+            GridItem() {
+
+              Row() {
+                Column() {
+                  Text(item.deviceName)
+                    .fontColor('#FFFFFF')
+                    .fontWeight(FontWeight.Medium)
+                    .fontSize($r('app.float.fontSize_24'))
+                  Text(item.deviceNo)
+                    .fontColor('#FFFFFF')
+                    .opacity(0.6)
+                    .fontWeight(FontWeight.Regular)
+                    .fontSize($r('app.float.fontSize_20'))
+                  Row() {
+                    Image(item.devicePic)
+                      .width(px2vp(120))
+                      .height(px2vp(120))
+                      .margin({ top: 40 })
+                  }.height('50%')
+                  .width('100%')
+                  .padding({ left: 10 })
+                }
+                .width('100%')
+                .padding(10)
+                .borderRadius(10)
+                .alignItems(HorizontalAlign.Start)
+                .height('100%')
+              }
+              .width('100%')
+              .height('30%')
+              .padding({ left: 10 })
+              .borderRadius(10)
+              .backgroundColor('#66ffffff')
+            }
+          })
+        }
+        .columnsTemplate('1fr 1fr 1fr 1fr 1fr 1fr')
+        .columnsGap(10)
+        .rowsGap(10)
+        .width('100%')
+        .height('100%')
+        .editMode(true) //设置Grid是否进入编辑模式,进入编辑模式可以拖拽Grid组件内部GridItem
+        .supportAnimation(true) //设置Grid是否开启拖拽补位动画
+        .height('80%')
+        .width('100%')
+        .padding({ top: 10 })
+
+      }
+    }
+    .backgroundImage($r('app.media.zhihuigc'))
+    .backgroundImageSize({ width: '100%', height: '100%' })
+    .width('100%')
+    .height('100%')
+    .padding(20)
+
+  }
+}
+
+
+

+ 2 - 1
entry/src/main/resources/base/profile/main_pages.json

@@ -18,6 +18,7 @@
     "pages/Outbound",
     "pages/RfidAllocation",
     "pages/OutboundStation",
-    "pages/WarehouseMap"
+    "pages/WarehouseMap",
+    "pages/StationDevicesPage"
   ]
 }