|
@@ -8,6 +8,9 @@ import { SmartFactoryCard }from '../common/component/SmartFactoryCard'
|
|
|
import CommonConstants from '../common/constants/CommonConstants'
|
|
|
import UniversalCard from '../model/UniversalCard'
|
|
|
import UniversalCardModel from '../model/database/UniversalCardModel';
|
|
|
+import formProvider from '@ohos.app.form.formProvider';
|
|
|
+import UserInfo from '../model/UserInfo';
|
|
|
+
|
|
|
//登录退出
|
|
|
@CustomDialog
|
|
|
struct login {
|
|
@@ -16,6 +19,7 @@ struct login {
|
|
|
controller: CustomDialogController
|
|
|
cancel: () => void
|
|
|
confirm: () => void
|
|
|
+
|
|
|
build() {
|
|
|
Column() {
|
|
|
Text('退出登录')
|
|
@@ -65,13 +69,14 @@ struct login {
|
|
|
//卡片服务
|
|
|
@CustomDialog
|
|
|
struct confirmPopup {
|
|
|
+ cardType: number
|
|
|
@Link cardServices:UniversalCard[]
|
|
|
controller: CustomDialogController
|
|
|
cancel: () => void
|
|
|
confirm: () => void
|
|
|
@Link x: number
|
|
|
@Link y: number
|
|
|
- @Link index:number
|
|
|
+ @Link cardSorting:number
|
|
|
build(){
|
|
|
Column(){
|
|
|
Column(){
|
|
@@ -86,15 +91,41 @@ struct confirmPopup {
|
|
|
.fontWeight(FontWeight.Medium)
|
|
|
.fontSize(px2vp(38))
|
|
|
.textAlign(TextAlign.Start)
|
|
|
- .onClick(()=>{
|
|
|
- this.controller.close()
|
|
|
- this.cardServices[this.index]= {
|
|
|
- id:this.cardServices[this.index].id,
|
|
|
- userId:this.cardServices[this.index].userId,
|
|
|
- cardType:this.cardServices[this.index].cardType,
|
|
|
- cardStatus:1,
|
|
|
- cardSort:this.cardServices[this.index].cardSort,
|
|
|
+ .onClick(async ()=>{
|
|
|
+ // 第一种遍历, const后面的是变量,变量的值就是数组的元素
|
|
|
+ // for (const card of this.cardServices) {
|
|
|
+ //
|
|
|
+ // card.cardStatus
|
|
|
+ // }
|
|
|
+
|
|
|
+ // 第二种遍历,index是数组索引
|
|
|
+ // 1.修改变量数组中,此卡片类型的对象(改为打开状态)
|
|
|
+ let temp: UniversalCard
|
|
|
+ let deleteIndex: number
|
|
|
+ for (let index=0; index < this.cardServices.length; index++) {
|
|
|
+ if (this.cardServices[index].cardType === this.cardType) {
|
|
|
+ this.cardServices[index].cardStatus = 1
|
|
|
+ temp = this.cardServices[index]
|
|
|
+ deleteIndex = index
|
|
|
+ break
|
|
|
+ }
|
|
|
}
|
|
|
+ // 2.删除变量数组中
|
|
|
+ this.cardServices.splice(deleteIndex, 1)
|
|
|
+ // 3.修改排序号
|
|
|
+ let sort: number = 0
|
|
|
+ for (let index=0; index < this.cardServices.length; index++) {
|
|
|
+ this.cardServices[index].cardSort = sort
|
|
|
+ // 4.更新数据库数据
|
|
|
+ await UniversalCardModel.updateUniversalCard(this.cardServices[index])
|
|
|
+ sort++
|
|
|
+ }
|
|
|
+ // 5.变量数组添加元素
|
|
|
+ temp.cardSort = this.cardServices.length
|
|
|
+ this.cardServices.push(temp)
|
|
|
+ // 6.修改数据入库
|
|
|
+ await UniversalCardModel.updateUniversalCard(temp)
|
|
|
+ this.controller.close()
|
|
|
})
|
|
|
|
|
|
}.width('100%')
|
|
@@ -111,17 +142,16 @@ struct confirmPopup {
|
|
|
.height('20%')
|
|
|
.width('120%')
|
|
|
.backgroundColor($r('app.color.general_font_white_color'))
|
|
|
-
|
|
|
- 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))
|
|
|
+ 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({x:this.x+'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'})
|
|
|
}
|
|
|
}
|
|
|
//开关重启
|
|
@@ -185,7 +215,8 @@ struct shutdown {
|
|
|
@Entry
|
|
|
@Component
|
|
|
struct Index {
|
|
|
- @State index:number=0
|
|
|
+ private cardType:number=0
|
|
|
+ @State cardSorting:number=0
|
|
|
@State x:number=0
|
|
|
@State y:number=0
|
|
|
@State cardServices:UniversalCard[] =[]
|
|
@@ -225,9 +256,10 @@ struct Index {
|
|
|
})
|
|
|
confirmPopupDialogController: CustomDialogController = new CustomDialogController({
|
|
|
builder: confirmPopup({
|
|
|
+ cardType:this.cardType,
|
|
|
x:this.x,
|
|
|
y:this.y,
|
|
|
- index:this.index,
|
|
|
+ cardSorting:this.cardSorting,
|
|
|
cardServices:this.cardServices
|
|
|
}
|
|
|
),
|
|
@@ -235,9 +267,12 @@ struct Index {
|
|
|
autoCancel:true,
|
|
|
customStyle:true,
|
|
|
})
|
|
|
+
|
|
|
async aboutToAppear(){
|
|
|
- this.cardServices= await UniversalCardModel.getListByUserId(CommonConstants.USER_ID)
|
|
|
- if (!this.cardServices||this.cardServices.length<=0) {
|
|
|
+ // 1.根据当前用户id查询他配置的万能卡片
|
|
|
+ this.cardServices = await UniversalCardModel.getListByUserId(CommonConstants.USER_ID)
|
|
|
+ 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,
|
|
@@ -245,15 +280,13 @@ struct Index {
|
|
|
cardStatus:1,
|
|
|
cardSort: index
|
|
|
};
|
|
|
- UniversalCardModel.addUniversalCard(card)
|
|
|
+ // 3.1用户的万能卡片入库,(以后再次打开页面能够查询到)
|
|
|
+ card.id = await UniversalCardModel.addUniversalCard(card)
|
|
|
+ // 3.2保存到数组变量,用于展示(避免再次查询,多于的开销)
|
|
|
this.cardServices.push(card)
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
- console.log("查询结果"+ JSON.stringify(this.cardServices))
|
|
|
-
|
|
|
+ // 2.2查询到有万能卡片数据,就直接展示,不做任何操作
|
|
|
}
|
|
|
build() {
|
|
|
Stack(){
|
|
@@ -266,69 +299,65 @@ struct Index {
|
|
|
Row() {
|
|
|
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)
|
|
|
+ ForEach(this.cardServices, (item:UniversalCard,index)=>{
|
|
|
+ if (item.cardStatus === 1) {
|
|
|
+ ListItem(){
|
|
|
+ if (item.cardType===3){
|
|
|
+ Stack(){
|
|
|
+ Column(){
|
|
|
+ TaskComp({isHomePage: this.isHomePage})
|
|
|
+ Text('生产操作')
|
|
|
.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('删除')
|
|
|
+ .margin({top:5})
|
|
|
.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,
|
|
|
- }
|
|
|
- })
|
|
|
+ .fontColor($r('app.color.robot_set_card_white'))
|
|
|
}
|
|
|
- .justifyContent(FlexAlign.Center)
|
|
|
.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(async()=>{
|
|
|
+ this.deleteConfirmation = 0
|
|
|
+ // 删除卡片
|
|
|
+ await this.deleteCard(index);
|
|
|
+ })
|
|
|
+ }
|
|
|
+ .justifyContent(FlexAlign.Center)
|
|
|
+ .height('40%')
|
|
|
+ .width('95%')
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- } else if (item.cardType===1 && item.cardStatus === 1){
|
|
|
- Stack(){
|
|
|
+ } else if (item.cardType===1){
|
|
|
+ Stack(){
|
|
|
Column(){
|
|
|
Warehousing()
|
|
|
Text('智能仓储')
|
|
@@ -375,15 +404,10 @@ struct Index {
|
|
|
.height('20%')
|
|
|
.textAlign(TextAlign.Center)
|
|
|
.backgroundColor( $r('app.color.robot_set_card_blue'))
|
|
|
- .onClick(()=>{
|
|
|
+ .onClick(async ()=>{
|
|
|
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,
|
|
|
- }
|
|
|
+ // 删除卡片
|
|
|
+ await this.deleteCard(index);
|
|
|
})
|
|
|
}
|
|
|
.justifyContent(FlexAlign.Center)
|
|
@@ -391,8 +415,8 @@ struct Index {
|
|
|
.width('95%')
|
|
|
}
|
|
|
}
|
|
|
- } else if (item.cardType===5 && item.cardStatus === 1){
|
|
|
- Stack(){
|
|
|
+ } else if (item.cardType===5){
|
|
|
+ Stack(){
|
|
|
Column(){
|
|
|
SmartFactoryCard()
|
|
|
Text('智汇工厂')
|
|
@@ -439,15 +463,10 @@ struct Index {
|
|
|
.height('20%')
|
|
|
.textAlign(TextAlign.Center)
|
|
|
.backgroundColor( $r('app.color.robot_set_card_blue'))
|
|
|
- .onClick(()=>{
|
|
|
+ .onClick(async ()=>{
|
|
|
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,
|
|
|
- }
|
|
|
+ // 删除卡片
|
|
|
+ await this.deleteCard(index);
|
|
|
})
|
|
|
}
|
|
|
.justifyContent(FlexAlign.Center)
|
|
@@ -455,11 +474,11 @@ struct Index {
|
|
|
.width('95%')
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
}.lanes(3)
|
|
|
-
|
|
|
}
|
|
|
.width('100%')
|
|
|
.height('100%')
|
|
@@ -528,7 +547,8 @@ struct Index {
|
|
|
}
|
|
|
this.x=touchPoint.x
|
|
|
this.y=touchPoint.y
|
|
|
- this.index=1
|
|
|
+ this.cardSorting=1
|
|
|
+ this.cardType=1
|
|
|
this.confirmPopupDialogController.open()
|
|
|
|
|
|
})
|
|
@@ -581,6 +601,7 @@ struct Index {
|
|
|
.gesture(
|
|
|
LongPressGesture({ repeat: false })
|
|
|
.onActionEnd(() => {
|
|
|
+
|
|
|
let rect = componentLocation.getComponentRect('workingProcedure')
|
|
|
let touchPoint: TouchObject = {
|
|
|
id: 1,
|
|
@@ -592,7 +613,8 @@ struct Index {
|
|
|
}
|
|
|
this.x=touchPoint.x
|
|
|
this.y=touchPoint.y
|
|
|
- this.index=0
|
|
|
+ this.cardSorting=0
|
|
|
+ this.cardType=3
|
|
|
this.confirmPopupDialogController.open()
|
|
|
})
|
|
|
)
|
|
@@ -641,7 +663,8 @@ struct Index {
|
|
|
}
|
|
|
this.x=touchPoint.x
|
|
|
this.y=touchPoint.y
|
|
|
- this.index=2
|
|
|
+ this.cardSorting=2
|
|
|
+ this.cardType=5
|
|
|
this.confirmPopupDialogController.open()
|
|
|
})
|
|
|
)
|
|
@@ -705,6 +728,31 @@ struct Index {
|
|
|
.width('100%')
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ // 删除卡片
|
|
|
+ private async deleteCard(index: number) {
|
|
|
+ // 1.修改变量中cardStatus为2,关闭状态
|
|
|
+ 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.其他数据的修改排序
|
|
|
+ let sort: number = 0;
|
|
|
+ for (let a = 0; a < this.cardServices.length; a++) {
|
|
|
+ if (this.cardServices[a].cardStatus === 1) {
|
|
|
+ this.cardServices[a].cardSort = sort;
|
|
|
+ // 4.更新数据库
|
|
|
+ await UniversalCardModel.updateUniversalCard(this.cardServices[a]);
|
|
|
+ sort++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 动画效果
|
|
|
pageTransition() {
|
|
|
// 设置1ms是为了使延时生效
|