Browse Source

Merge remote-tracking branch 'origin/master'

hh 1 year ago
parent
commit
76d691d015

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

@@ -54,7 +54,7 @@ export struct SmartFactoryCard{
     }
     .padding(10)
     .width('100%')
-    .height('100%')
+    .height('90%')
     .margin({left:10})
     .borderRadius(15)
     .backgroundImage($r('app.media.smartFactoryCard'))

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

@@ -207,7 +207,7 @@ export struct TaskComp {
     }
     .padding(10)
     .width('100%')
-    .height('100%')
+    .height('90%')
     .backgroundColor('#F1F3F5')
     .borderRadius(15)
     .margin({left:10})

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

@@ -254,7 +254,7 @@ export struct Warehousing {
 
     }.padding(10)
     .width('100%')
-    .height('100%')
+    .height('90%')
     .margin({left:10})
     .borderRadius(15)
     .border({ width: 1, color: '#ffeae6e6' })

+ 3 - 6
entry/src/main/ets/common/constants/CommonConstants.ets

@@ -96,10 +96,7 @@ export default class CommonConstants {
     {step: 2, momentMin: 1.4, momentMax: 1.5, momentUnit: 'N.m', rotateMin: 4500, rotateMax: 5500, rotateUnit: '°'},
     {step: 3, momentMin: 1.2, momentMax: 1.3, momentUnit: 'N.m', rotateMin: 2600, rotateMax: 3500, rotateUnit: '°'},
   ];
-  //卡片服务
-  static  readonly Card_DATA:Array<UniversalCard>=[
-    {id:0, userId:0, cardType:1,cardStatus:1,cardSort:0},
-    {id:0, userId:0, cardType:3,cardStatus:1,cardSort:0},
-    {id:0, userId:0, cardType:5,cardStatus:1,cardSort:0},
-  ];
+
+  //万能卡片
+  static readonly CARD_TYPE_DATA: number[] = [3,1,5];
 }

+ 11 - 9
entry/src/main/ets/model/database/UniversalCardModel.ets

@@ -49,6 +49,7 @@ class UniversalCardModel {
     // 1.构建查询条件
     let predicates = new relationalStore.RdbPredicates(this.tableName)
     predicates.equalTo('USER_ID', userId)
+    predicates.orderByAsc('CARD_SORT')
     // 2.查询
     let result = await this.rdbStore.query(predicates, ['ID', 'USER_ID', 'CARD_TYPE', 'CARD_STATUS', 'CARD_SORT'])
     let cards: UniversalCard[] = []
@@ -96,23 +97,24 @@ class UniversalCardModel {
 
   /**
    * 添加万能卡片
-   * @param set 万能卡片配置信息
+   * @param card 万能卡片配置信息
    * @returns 万能卡片id
    */
-  addUniversalCard(set: UniversalCard): Promise<number>{
-    return this.rdbStore.insert(this.tableName, {USER_ID: set.userId, CARD_TYPE: set.cardType, CARD_STATUS: set.cardStatus, CARD_SORT: set.cardSort})
+  addUniversalCard(card: UniversalCard): Promise<number>{
+    return this.rdbStore.insert(this.tableName, {USER_ID: card.userId,
+      CARD_TYPE: card.cardType, CARD_STATUS: card.cardStatus, CARD_SORT: card.cardSort})
   }
 
   /**
    * 根据id更新万能卡片状态
-   * @param set 万能卡片配置信息
+   * @param card 万能卡片配置信息
    */
-  updateUniversalCard(set: UniversalCard) {
+  updateUniversalCard(card: UniversalCard) {
     // 1.要更新的数据
-    let data = {CARD_TYPE: set.cardType, CARD_STATUS: set.cardStatus, CARD_SORT: set.cardSort}
+    let data = {CARD_TYPE: card.cardType, CARD_STATUS: card.cardStatus, CARD_SORT: card.cardSort}
     // 2.更新的条件
     let predicates = new relationalStore.RdbPredicates(this.tableName)
-    predicates.equalTo('ID', set.id)
+    predicates.equalTo('ID', card.id)
     // 3.更新操作
     return this.rdbStore.update(data, predicates)
   }
@@ -130,6 +132,6 @@ class UniversalCardModel {
   }
 }
 
-let assistantSetModel = new UniversalCardModel();
+let universalCardModel = new UniversalCardModel();
 
-export default assistantSetModel as UniversalCardModel;
+export default universalCardModel as UniversalCardModel;

+ 253 - 196
entry/src/main/ets/pages/Index.ets

@@ -7,6 +7,8 @@ import {  Warehousing}from  '../common/component/Warehousing'
 import { SmartFactoryCard }from  '../common/component/SmartFactoryCard'
 import CommonConstants from '../common/constants/CommonConstants'
 import UniversalCard from  '../model/UniversalCard'
+import UniversalCardModel from '../model/database/UniversalCardModel';
+//登录退出
 @CustomDialog
 struct login {
   @Link textValue: string
@@ -60,6 +62,7 @@ struct login {
     .backgroundColor('#ffff')
   }
 }
+//卡片服务
 @CustomDialog
 struct confirmPopup {
   @Link cardServices:UniversalCard[]
@@ -109,18 +112,19 @@ struct confirmPopup {
       .width('120%')
       .backgroundColor($r('app.color.general_font_white_color'))
 
-
-      Image(this.index===1?$r("app.media.processImages"):$r('app.media.storage'))
-        .width(px2vp(220))
-        .height(px2vp(220))
+      Image(this.index===1?$r("app.media.processImages")
+        :this.index===2?$r('app.media.jg_circular_icon'):$r('app.media.storage'))
+        .width(px2vp(280))
+        .height(px2vp(280))
         .borderRadius(15)
     }
     .alignItems(HorizontalAlign.Start)
     .width('350px')
     .height('600px')
-    .offset({x:this.x+20+'px', y:this.y-340+'px'})
+    .offset({x:this.x+'px', y:this.y-410+'px'})
   }
 }
+//开关重启
 @CustomDialog
 struct shutdown {
   @Link shutdownTransparency:number
@@ -184,7 +188,7 @@ struct Index {
   @State index:number=0
   @State x:number=0
   @State y:number=0
-  @State cardServices:UniversalCard[] = CommonConstants.Card_DATA
+  @State cardServices:UniversalCard[] =[]
   @State  SmartFactoryCardDelete:number=0
   @State SmartFactoryDelete:number=0
   @State  SmartFactoryCarLongPressDelete:number=0
@@ -231,6 +235,26 @@ struct Index {
     autoCancel:true,
     customStyle:true,
   })
+  async aboutToAppear(){
+    this.cardServices= await  UniversalCardModel.getListByUserId(CommonConstants.USER_ID)
+    if (!this.cardServices||this.cardServices.length<=0) {
+      for (let index = 0; index < CommonConstants.CARD_TYPE_DATA.length; index++) {
+        const card:UniversalCard = {
+          userId:CommonConstants.USER_ID,
+          cardType: CommonConstants.CARD_TYPE_DATA[index],
+          cardStatus:1,
+          cardSort: index
+        };
+        UniversalCardModel.addUniversalCard(card)
+        this.cardServices.push(card)
+      }
+
+
+      
+    }
+    console.log("查询结果"+ JSON.stringify(this.cardServices))
+
+  }
   build() {
     Stack(){
       Row() {
@@ -240,196 +264,201 @@ struct Index {
               this.avatarFrame=!this.avatarFrame
             })
           Row() {
-
-            Flex({ wrap: FlexWrap.Wrap }) {
-              if (this.cardServices[1].cardStatus===1){
-                Stack(){
-                  Column(){
-                    TaskComp({isHomePage: this.isHomePage})
-                    Text('生产操作')
-                      .fontSize(px2vp(27))
-                      .margin({top:5})
-                      .fontWeight(FontWeight.Medium)
-                      .fontColor($r('app.color.robot_set_card_white'))
-                  }
-                  .height('40%')
-                  .width('32%')
-                  .gesture(
-                    LongPressGesture({ repeat: false })
-                      .onActionEnd(() => {
-                        this.deleteConfirmation=1
-                      })
-                  )
-                  if (this.deleteConfirmation===1){
-                    Row(){
-                      Text('取消')
-                        .fontWeight(FontWeight.Medium)
-                        .fontSize(px2vp(27))
-                        .textAlign(TextAlign.Center)
-                        .width('20%')
-                        .height('20%')
-                        .margin(10)
-                        .borderRadius(px2vp(21))
-                        .fontColor($r('app.color.robot_set_card_blue'))
-                        .backgroundColor($r('app.color.general_font_white_color'))
-                        .onClick(()=>{
-                          this.deleteConfirmation=0
-                        })
-                      Text('删除')
-                        .fontWeight(FontWeight.Medium)
-                        .fontSize(px2vp(27))
-                        .width('20%')
-                        .margin(10)
-                        .fontColor($r('app.color.general_font_white_color'))
-                        .borderRadius(px2vp(21))
-                        .height('20%')
-                        .textAlign(TextAlign.Center)
-                        .backgroundColor(  $r('app.color.robot_set_card_blue'))
-                        .onClick(()=>{
-                          this.deleteConfirmation=0
-                          this.cardServices[1]= {
-                            id:this.cardServices[1].id,
-                            userId:this.cardServices[1].userId,
-                            cardType:this.cardServices[1].cardType,
-                            cardStatus:2,
-                            cardSort:this.cardServices[1].cardSort,
+            Column() {
+              List(){
+                ForEach(this.cardServices,(item:UniversalCard,index)=>{
+                  ListItem(){
+                    if (item.cardType===3 && item.cardStatus === 1){
+                      Stack(){
+                        Column(){
+                          TaskComp({isHomePage: this.isHomePage})
+                          Text('生产操作')
+                            .fontSize(px2vp(27))
+                            .margin({top:5})
+                            .fontWeight(FontWeight.Medium)
+                            .fontColor($r('app.color.robot_set_card_white'))
+                        }
+                        .height('40%')
+                        .width('95%')
+                        .gesture(
+                          LongPressGesture({ repeat: false })
+                            .onActionEnd(() => {
+                              this.deleteConfirmation=1
+                            })
+                        )
+                        if (this.deleteConfirmation===1){
+                          Row(){
+                            Text('取消')
+                              .fontWeight(FontWeight.Medium)
+                              .fontSize(px2vp(27))
+                              .textAlign(TextAlign.Center)
+                              .width('20%')
+                              .height('20%')
+                              .margin(10)
+                              .borderRadius(px2vp(21))
+                              .fontColor($r('app.color.robot_set_card_blue'))
+                              .backgroundColor($r('app.color.general_font_white_color'))
+                              .onClick(()=>{
+                                this.deleteConfirmation=0
+                              })
+                            Text('删除')
+                              .fontWeight(FontWeight.Medium)
+                              .fontSize(px2vp(27))
+                              .width('20%')
+                              .margin(10)
+                              .fontColor($r('app.color.general_font_white_color'))
+                              .borderRadius(px2vp(21))
+                              .height('20%')
+                              .textAlign(TextAlign.Center)
+                              .backgroundColor(  $r('app.color.robot_set_card_blue'))
+                              .onClick(()=>{
+                                this.deleteConfirmation=0
+                                this.cardServices[0]= {
+                                  id:this.cardServices[0].id,
+                                  userId:this.cardServices[0].userId,
+                                  cardType:this.cardServices[0].cardType,
+                                  cardStatus:2,
+                                  cardSort:this.cardServices[0].cardSort,
+                                }
+                              })
                           }
-                        })
-                    }
-                    .justifyContent(FlexAlign.Center)
-                    .height('40%')
-                    .width('32%')
-                  }
-
-                }
-
-              }
-              if (this.cardServices[0].cardStatus===1){
-                Stack(){
-                  Column(){
-                    Warehousing()
-                    Text('智能仓储')
-                      .margin({top:5})
-                      .fontSize(px2vp(27))
-                      .fontWeight(FontWeight.Medium)
-                      .fontColor($r('app.color.robot_set_card_white'))
-                  }
-                  .height('40%')
-                  .width('32%')
-                  .margin({left:10})
-                  .onClick(()=>{
-                    router.pushUrl({
-                      url:'pages/Storage'
-                    })
-                  })
-                  .gesture(
-                    LongPressGesture({ repeat: false })
-                      .onActionEnd(() => {
-                        this.smartWarehouseCard=1
-                      })
-                  )
-                  if (this.smartWarehouseCard===1){
-                    Row(){
-                      Text('取消')
-                        .fontWeight(FontWeight.Medium)
-                        .fontSize(px2vp(27))
-                        .textAlign(TextAlign.Center)
-                        .width('20%')
-                        .height('20%')
-                        .margin(10)
-                        .borderRadius(px2vp(21))
-                        .fontColor($r('app.color.robot_set_card_blue'))
-                        .backgroundColor($r('app.color.general_font_white_color'))
-                        .onClick(()=>{
-                          this.smartWarehouseCard=0
-                        })
-                      Text('删除')
-                        .fontWeight(FontWeight.Medium)
-                        .fontSize(px2vp(27))
-                        .width('20%')
-                        .margin(10)
-                        .fontColor($r('app.color.general_font_white_color'))
-                        .borderRadius(px2vp(21))
-                        .height('20%')
-                        .textAlign(TextAlign.Center)
-                        .backgroundColor(  $r('app.color.robot_set_card_blue'))
-                        .onClick(()=>{
-                          this.smartWarehouseCard=0
-                          this.cardServices[0]= {
-                            id:this.cardServices[0].id,
-                            userId:this.cardServices[0].userId,
-                            cardType:this.cardServices[0].cardType,
-                            cardStatus:2,
-                            cardSort:this.cardServices[0].cardSort,
+                          .justifyContent(FlexAlign.Center)
+                          .height('40%')
+                          .width('95%')
+                        }
+                      }
+                    } else if (item.cardType===1 && item.cardStatus === 1){
+                      Stack(){
+                          Column(){
+                            Warehousing()
+                            Text('智能仓储')
+                              .margin({top:5})
+                              .fontSize(px2vp(27))
+                              .fontWeight(FontWeight.Medium)
+                              .fontColor($r('app.color.robot_set_card_white'))
                           }
-                        })
-                    }
-                    .justifyContent(FlexAlign.Center)
-                    .height('40%')
-                    .width('32%')
-                  }
-                }
-              }
-              if (this.SmartFactoryCardDelete===0){
-                Stack(){
-                  Column(){
-                    SmartFactoryCard()
-                    Text('智汇工厂')
-                      .margin({top:5})
-                      .fontSize(px2vp(27))
-                      .fontWeight(FontWeight.Medium)
-                      .fontColor($r('app.color.robot_set_card_white'))
-                  }
-                  .height('40%')
-                  .width('32%')
-                  .margin({left:10})
-                  .onClick(()=>{
-                    router.pushUrl({
-                      url:'pages/SmartFactory'
-                    })
-                  })
-                  .gesture(
-                    LongPressGesture({ repeat: false })
-                      .onActionEnd(() => {
-                        this.SmartFactoryCarLongPressDelete=1
-                      })
-                  )
-                  if (this.SmartFactoryCarLongPressDelete===1){
-                    Row(){
-                      Text('取消')
-                        .fontWeight(FontWeight.Medium)
-                        .fontSize(px2vp(27))
-                        .textAlign(TextAlign.Center)
-                        .width('20%')
-                        .height('20%')
-                        .margin(10)
-                        .borderRadius(px2vp(21))
-                        .fontColor($r('app.color.robot_set_card_blue'))
-                        .backgroundColor($r('app.color.general_font_white_color'))
-                        .onClick(()=>{
-                          this.SmartFactoryCarLongPressDelete=0
-                        })
-                      Text('删除')
-                        .fontWeight(FontWeight.Medium)
-                        .fontSize(px2vp(27))
-                        .width('20%')
-                        .margin(10)
-                        .fontColor($r('app.color.general_font_white_color'))
-                        .borderRadius(px2vp(21))
-                        .height('20%')
-                        .textAlign(TextAlign.Center)
-                        .backgroundColor(  $r('app.color.robot_set_card_blue'))
-                        .onClick(()=>{
-                          this.SmartFactoryCarLongPressDelete=0
-                          this.SmartFactoryCardDelete=1
-                        })
+                          .height('40%')
+                          .width('95%')
+                          .onClick(()=>{
+                            router.pushUrl({
+                              url:'pages/Storage'
+                            })
+                          })
+                          .gesture(
+                            LongPressGesture({ repeat: false })
+                              .onActionEnd(() => {
+                                this.smartWarehouseCard=1
+                              })
+                          )
+                          if (this.smartWarehouseCard===1){
+                            Row(){
+                              Text('取消')
+                                .fontWeight(FontWeight.Medium)
+                                .fontSize(px2vp(27))
+                                .textAlign(TextAlign.Center)
+                                .width('20%')
+                                .height('20%')
+                                .margin(10)
+                                .borderRadius(px2vp(21))
+                                .fontColor($r('app.color.robot_set_card_blue'))
+                                .backgroundColor($r('app.color.general_font_white_color'))
+                                .onClick(()=>{
+                                  this.smartWarehouseCard=0
+                                })
+                              Text('删除')
+                                .fontWeight(FontWeight.Medium)
+                                .fontSize(px2vp(27))
+                                .width('20%')
+                                .margin(10)
+                                .fontColor($r('app.color.general_font_white_color'))
+                                .borderRadius(px2vp(21))
+                                .height('20%')
+                                .textAlign(TextAlign.Center)
+                                .backgroundColor(  $r('app.color.robot_set_card_blue'))
+                                .onClick(()=>{
+                                  this.smartWarehouseCard=0
+                                  this.cardServices[1]= {
+                                    id:this.cardServices[1].id,
+                                    userId:this.cardServices[1].userId,
+                                    cardType:this.cardServices[1].cardType,
+                                    cardStatus:2,
+                                    cardSort:this.cardServices[1].cardSort,
+                                  }
+                                })
+                            }
+                            .justifyContent(FlexAlign.Center)
+                            .height('40%')
+                            .width('95%')
+                          }
+                        }
+                    } else if (item.cardType===5 && item.cardStatus === 1){
+                      Stack(){
+                          Column(){
+                            SmartFactoryCard()
+                            Text('智汇工厂')
+                              .margin({top:5})
+                              .fontSize(px2vp(27))
+                              .fontWeight(FontWeight.Medium)
+                              .fontColor($r('app.color.robot_set_card_white'))
+                          }
+                          .height('40%')
+                          .width('95%')
+                          .onClick(()=>{
+                            router.pushUrl({
+                              url:'pages/SmartFactory'
+                            })
+                          })
+                          .gesture(
+                            LongPressGesture({ repeat: false })
+                              .onActionEnd(() => {
+                                this.SmartFactoryCarLongPressDelete=1
+                              })
+                          )
+                          if (this.SmartFactoryCarLongPressDelete===1){
+                            Row(){
+                              Text('取消')
+                                .fontWeight(FontWeight.Medium)
+                                .fontSize(px2vp(27))
+                                .textAlign(TextAlign.Center)
+                                .width('20%')
+                                .height('20%')
+                                .margin(10)
+                                .borderRadius(px2vp(21))
+                                .fontColor($r('app.color.robot_set_card_blue'))
+                                .backgroundColor($r('app.color.general_font_white_color'))
+                                .onClick(()=>{
+                                  this.SmartFactoryCarLongPressDelete=0
+                                })
+                              Text('删除')
+                                .fontWeight(FontWeight.Medium)
+                                .fontSize(px2vp(27))
+                                .width('20%')
+                                .margin(10)
+                                .fontColor($r('app.color.general_font_white_color'))
+                                .borderRadius(px2vp(21))
+                                .height('20%')
+                                .textAlign(TextAlign.Center)
+                                .backgroundColor(  $r('app.color.robot_set_card_blue'))
+                                .onClick(()=>{
+                                  this.SmartFactoryCarLongPressDelete=0
+                                  this.cardServices[2]= {
+                                    id:this.cardServices[2].id,
+                                    userId:this.cardServices[2].userId,
+                                    cardType:this.cardServices[2].cardType,
+                                    cardStatus:2,
+                                    cardSort:this.cardServices[2].cardSort,
+                                  }
+                                })
+                            }
+                            .justifyContent(FlexAlign.Center)
+                            .height('40%')
+                            .width('95%')
+                          }
+                        }
                     }
-                    .justifyContent(FlexAlign.Center)
-                    .height('40%')
-                    .width('32%')
                   }
-                }
-              }
+                })
+              }.lanes(3)
 
             }
             .width('100%')
@@ -499,7 +528,7 @@ struct Index {
                   }
                   this.x=touchPoint.x
                   this.y=touchPoint.y
-                  this.index=0
+                  this.index=1
                   this.confirmPopupDialogController.open()
 
                 })
@@ -563,7 +592,7 @@ struct Index {
                   }
                   this.x=touchPoint.x
                   this.y=touchPoint.y
-                  this.index=1
+                  this.index=0
                   this.confirmPopupDialogController.open()
                 })
             )
@@ -588,9 +617,37 @@ struct Index {
           }
           .width('100%')
           .height('16%')
-          BottomOperateComp({ isHomePage: this.isHomePage,
+          Stack(){
+            BottomOperateComp({ isHomePage: this.isHomePage})
+            Text().width('8%')
+              .height('8%')
+              .id('Warehousing')
+              .onClick(()=>{
+                router.pushUrl({
+                  url:'pages/SmartFactory'
+                })
+              })
+              .gesture(
+                LongPressGesture({ repeat: false })
+                  .onActionEnd(() => {
+                    let rect = componentLocation.getComponentRect('Warehousing')
+                    let touchPoint: TouchObject = {
+                      id: 2,
+                      x: rect.left, // 组件中心点x坐标
+                      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.index=2
+                    this.confirmPopupDialogController.open()
+                  })
+              )
           }
-          )
+
+
         }
         .backgroundImage($r('app.media.BG'))
         .backgroundImageSize({ width: '100%', height: '100%' })

+ 0 - 1
entry/src/main/ets/view/OtherStorageOutbound.ets

@@ -266,7 +266,6 @@ struct bufferf {
     // dialog默认的borderRadius为24vp,如果需要使用border属性,请和borderRadius属性一起使用。
   }
 }
-@Entry
 @Component
 export struct OtherStorageOutbound{
   @State itemCode:string='132451234'