import CommonConstants from '../common/constants/CommonConstants' import StorageModel from '../model/database/StorageModel' import StorageSpaceModel from '../model/database/StorageSpaceModel' import StorageInfo from '../model/StorageInfo' import StorageSpace from '../model/StorageSpace' import StorageSpaceGrid from '../common/component/StorageSpaceGrid' import SpaceStateList from '../model/SpaceStateList' import JGRequest from '../common/util/request/Request' import StorageConfig from '../viewmodel/StorageConfig' let storageTypeArray: string[] = CommonConstants.STORAGE_TYPE let parkTypeArray: string[] = CommonConstants.PARK_TYPE @Component export struct StorageSetView { storages: StorageInfo[] = [] @State currentStorage: StorageInfo = null // key为storageSpace的y值 @State spaceArray: StorageSpace[][] = [] // 储位状态(1:禁用 2:未设置类型 3:正常 4:禁用+选中 5:未设置类型+选中 6:正常+选中) @State stateArray: Array = []; @State selectSpace: StorageSpace = null @State storageTypeStr: string = '' @State parkTypeStr: string = '' // 仓储图效(1:2D 2:3D) @State imageEffect: number = 1 // @State yNum: NumberDataSource = new NumberDataSource @State yNum: number[] = [] // 编辑机仓储类型的弹窗控制器 editStorageTypeController: CustomDialogController = new CustomDialogController({ builder: EditStorageTypeDialog({ selectSpace: this.selectSpace, storageTypeStr: this.storageTypeStr, confirm: ()=> { if (this.selectSpace.storageType && this.selectSpace.storageType.length > 0 && this.selectSpace.enableState === 1) { this.stateArray[this.selectSpace.y-1][this.selectSpace.x-1] += 1 } } }), autoCancel: true, alignment: DialogAlignment.Center, // gridCount: 3, customStyle: true, }) // 编辑机储位容量的弹窗控制器 editCapacityController: CustomDialogController = new CustomDialogController({ builder: EditCapacityDialog({ selectSpace: this.selectSpace, maxCapacity: this.currentStorage.defaultLayer }), autoCancel: true, alignment: DialogAlignment.Center, // gridCount: 3, customStyle: true, }) // 编辑储位能否途经的弹窗控制器 editCanWayController: CustomDialogController = new CustomDialogController({ builder: EditCanWayDialog({ selectSpace: this.selectSpace, }), autoCancel: true, alignment: DialogAlignment.Center, // gridCount: 3, customStyle: true, }) // 编辑机仓储类型的弹窗控制器 editParkTypeController: CustomDialogController = new CustomDialogController({ builder: EditParkTypeDialog({ selectSpace: this.selectSpace, parkTypeStr: this.parkTypeStr }), autoCancel: true, alignment: DialogAlignment.Center, // gridCount: 3, customStyle: true, }) // 编辑仓储名称的弹窗控制器 editStorageNameController: CustomDialogController = new CustomDialogController({ builder: EditStorageNameDialog({ currentStorage: $currentStorage }), autoCancel: true, alignment: DialogAlignment.Center, // gridCount: 3, customStyle: true, }) // 编辑仓储尺寸的弹窗控制器 editStorageSizeController: CustomDialogController = new CustomDialogController({ builder: EditStorageSizeDialog({ currentStorage: $currentStorage, confirm: ()=> { this.updateStorageSpaceData(true) } }), autoCancel: true, alignment: DialogAlignment.Center, // gridCount: 3, customStyle: true, }) // 编辑仓储默认层数的弹窗控制器 editDefaultLayerController: CustomDialogController = new CustomDialogController({ builder: EditDefaultLayerDialog({ currentStorage: $currentStorage }), autoCancel: true, alignment: DialogAlignment.Center, // gridCount: 3, customStyle: true, }) async aboutToAppear() { // 查询后台数据库的线边库 let config: StorageConfig = await JGRequest.get("/api/v1/wms/position/houseConfigInfo/" + 1, {}) // 查询本地数据库,没有则添加数据(仓储和储位数据) this.storages = await StorageModel.getStorageList() if (!config && (!this.storages || this.storages.length <= 0)) { return } if ((!this.storages || this.storages.length <= 0) && config) { this.storages.push({storageName: config.houseName, xSize: config.xNum, ySize: config.yNum, defaultLayer: config.layer} as StorageInfo) let storageId = await StorageModel.addStorage(config.houseName, config.xNum, config.yNum, config.layer) this.storages[0].id = storageId if (config.xNum && config.xNum > 0 && config.yNum && config.yNum > 0) { for (let y = 1; y <= config.yNum; y++) { for (let x = 1; x <= config.xNum; x++) { let space: StorageSpace = {storageId: storageId, x: x, y: y, enableState: 1, storageType: '', capacity: config.layer, canWay: 1, canPark: 0} await StorageSpaceModel.addStorageSpace(space) } } } } else if ((this.storages[0].xSize != config.xNum || this.storages[0].ySize != config.yNum) && config) { // 如果本地数据保存数据和后台不匹配,后台数据库为主 this.currentStorage = this.storages[0] StorageModel.updateStorage(this.storages[0].id, this.storages[0].storageName, config.xNum, config.yNum, config.layer) this.updateStorageSpaceData(false) } // 渲染封装数据 this.currentStorage = this.storages[0] let x: number = 0 if (this.currentStorage.xSize && this.currentStorage.xSize > 0) { x = this.currentStorage.xSize } else { return } // 生成需要遍历的行 (y倒序) if (this.currentStorage.ySize && this.currentStorage.ySize > 0) { if (this.currentStorage.ySize && this.currentStorage.ySize > 0) { for (let index = this.currentStorage.ySize - 1; index >= 0; index--) { this.yNum.push(index) } } } else { return } StorageSpaceModel.getListByStorageId(this.currentStorage.id).then(spaces => { if (spaces && spaces.length > 0) { let tempArray: StorageSpace[] = [] let stateList = new SpaceStateList() for (const space of spaces) { tempArray.push(space) // 储位状态创建 if (space.enableState === 2) { stateList.push(1) } else if (!space.storageType || space.storageType.length === 0) { stateList.push(2) } else { stateList.push(3) } if (tempArray.length === x) { this.spaceArray.push(tempArray) this.stateArray.push(stateList) tempArray = [] stateList = new SpaceStateList() } } } }) } /* * updateArray * */ /** * 更新本地数据库的仓储储位 * @param updateArray 是否更新spaceArray(aboutToAppear调用时不更新) */ async updateStorageSpaceData(updateArray: boolean) { this.spaceArray = [] this.stateArray = [] let y = 1 this.yNum = [] // let oldSize = this.spaceArray.length for (let index = this.currentStorage.ySize - 1; index >= 0; index--) { let tempArray: StorageSpace[] = [] let stateList = new SpaceStateList() for (let x = 1; x <= this.currentStorage.xSize; x++) { tempArray.push({"id":1,"storageId":this.currentStorage.id,"x":x,"y":y,"enableState":1,"storageType":"","capacity":this.currentStorage.defaultLayer,"canWay":1,"canPark":2,"parkType":0}) stateList.push(2) } this.spaceArray.push(tempArray) this.stateArray.push(stateList) this.yNum.push(index) y++ } await StorageSpaceModel.initDataByStorage(this.currentStorage) if (updateArray) { StorageSpaceModel.getListByStorageId(this.currentStorage.id).then(spaces => { if (spaces && spaces.length > 0) { for (const space of spaces) { this.spaceArray[space.y - 1][space.x - 1].id = space.id } } }) } } build() { Column() { Row() { Column() { Column() { StorageSpaceGrid({ stateArray: $stateArray, spaceArray: $spaceArray, yNum:$yNum, selectSpace: $selectSpace, storageTypeStr: $storageTypeStr, parkTypeStr: $parkTypeStr, }) // 2D/3D切换按钮 Row() { Row() { Row() { Stack() { if (this.imageEffect === 1) { Text() .backgroundColor($r('app.color.general_card_background_color')) .width('100%') .height('100%') .borderRadius($r('app.float.general_border_radius')) } Text('2D') .fontSize($r('app.float.set_card_font_size')) .fontColor($r('app.color.general_font_color')) .opacity(this.imageEffect === 1 ? $r('app.float.card_font_select_opacity') : $r('app.float.card_font_default_opacity')) } .width('100%') .height('100%') } .onClick(() => { if (this.selectSpace) { this.stateArray[this.selectSpace.y-1][this.selectSpace.x-1] -= 3 } this.imageEffect = 1 }) .width('50%') Row() { Stack() { if (this.imageEffect === 2) { Text() .backgroundColor($r('app.color.general_card_background_color')) .width('100%') .height('100%') .borderRadius($r('app.float.general_border_radius')) } Text('3D') .fontSize($r('app.float.set_card_font_size')) .fontColor($r('app.color.general_font_color')) .opacity(this.imageEffect === 2 ? $r('app.float.card_font_select_opacity') : $r('app.float.card_font_default_opacity')) } .width('100%') .height('100%') } .width('50%') .onClick(() => { if (this.selectSpace) { this.stateArray[this.selectSpace.y-1][this.selectSpace.x-1] -= 3 } this.imageEffect = 2 }) } .width($r('app.float.storage_set_image_effect_width')) .height($r('app.float.storage_set_image_effect_height')) .borderRadius($r('app.float.general_border_radius')) .backgroundColor($r('app.color.robot_toward_set_card_background')) } .height('16%') .width('100%') .alignItems(VerticalAlign.Center) .justifyContent(FlexAlign.Start) } .height('100%') .layoutWeight(1) } .height('100%') .layoutWeight(1) .justifyContent(FlexAlign.Center) .alignItems(HorizontalAlign.Center) .onClick(() => { if (this.selectSpace) { this.stateArray[this.selectSpace.y-1][this.selectSpace.x-1] -= 3 } this.selectSpace = null this.storageTypeStr = null this.parkTypeStr = null }) // 储位设置 if (this.selectSpace) { Column() { Row() { Column() { Text(this.selectSpace && this.selectSpace.x && this.selectSpace.y ? 'X:' + this.selectSpace.x + ' Y:' + this.selectSpace.y : '') .fontSize($r('app.float.card_title_font_size')) .fontColor($r('app.color.general_font_color')) .fontWeight(FontWeight.Medium) .opacity($r('app.float.general_font_opacity')) Text(this.selectSpace && this.selectSpace.enableState === 1 ? '启用' : '禁用') .fontSize($r('app.float.card_info_font_size')) .fontColor($r('app.color.general_font_color')) .fontWeight(FontWeight.Regular) .opacity($r('app.float.card_font_default_opacity')) } .alignItems(HorizontalAlign.Start) .padding({ left: '10%' }) Blank() Column() { Toggle({ type: ToggleType.Switch, isOn: this.selectSpace && this.selectSpace.enableState === 1 ? true : false }) .height('33%') .width('60%') .onChange((isOn: boolean) => { let enableState = isOn ? 1 : 2 this.selectSpace.enableState = enableState this.spaceArray[this.selectSpace.y - 1][this.selectSpace.x - 1].enableState = enableState if (isOn) { if (!this.spaceArray[this.selectSpace.y - 1][this.selectSpace.x - 1].storageType || this.spaceArray[this.selectSpace.y - 1][this.selectSpace.x - 1].storageType.length < 1) { this.stateArray[this.selectSpace.y - 1][this.selectSpace.x - 1] = 5 } else { this.stateArray[this.selectSpace.y - 1][this.selectSpace.x - 1] = 6 } } else { this.stateArray[this.selectSpace.y - 1][this.selectSpace.x - 1] = 4 } StorageSpaceModel.updateStorageSpace(this.selectSpace.id, enableState, this.selectSpace.storageType, this.selectSpace.capacity, this.selectSpace.canWay, this.selectSpace.canPark, this.selectSpace.parkType) }) } .width('41%') .height('100%') .justifyContent(FlexAlign.Center) } .width('100%') .height('16%') .backgroundColor($r('app.color.robot_set_card_white')) .borderRadius($r('app.float.general_border_radius')) Row() { this.displayCard({ cardName: '仓储类型', displayInfo: this.storageTypeStr ? this.storageTypeStr : '', clickEvent: ()=>{ this.editStorageTypeController.open() }}) } .width('100%') .height('16%') .backgroundColor($r('app.color.robot_set_card_white')) .borderRadius($r('app.float.general_border_radius')) Row() { this.displayCard({ cardName: '容量', displayInfo: this.selectSpace && this.selectSpace.capacity ? this.selectSpace.capacity + '层' : '', clickEvent: ()=>{ this.editCapacityController.open() }}) } .width('100%') .height('16%') .backgroundColor($r('app.color.robot_set_card_white')) .borderRadius($r('app.float.general_border_radius')) Row() { this.displayCard({ cardName: '能否途经', displayInfo: !this.selectSpace || !this.selectSpace.canWay ? '' : (this.selectSpace.canWay === 1 ? '能' : '否'), clickEvent: ()=>{ this.editCanWayController.open() } }) } .width('100%') .height('16%') .backgroundColor($r('app.color.robot_set_card_white')) .borderRadius($r('app.float.general_border_radius')) Row() { this.displayCard({ cardName: '是否为出入库停靠点', displayInfo: !this.selectSpace || !this.selectSpace.canPark ? '' : (this.selectSpace.canPark === 2 ? '否' : this.parkTypeStr), clickEvent: ()=>{ this.editParkTypeController.open() } }) } .width('100%') .height('16%') .backgroundColor($r('app.color.robot_set_card_white')) .borderRadius($r('app.float.general_border_radius')) } .height('100%') .width('20%') .justifyContent(FlexAlign.SpaceEvenly) } } .width('100%') .height('82%') // 仓储设置 Row() { Column() { this.displayCard({ cardName: '仓储名称', displayInfo: this.currentStorage && this.currentStorage.storageName ? this.currentStorage.storageName : '', clickEvent: ()=>{ this.editStorageNameController.open() } }) } .height('90%') .width('32%') Column() { this.displayCard({ cardName: '总尺寸', displayInfo: this.currentStorage && this.currentStorage.xSize && this.currentStorage.ySize ? this.currentStorage.xSize + '*' + this.currentStorage.ySize : '', clickEvent: ()=>{ this.editStorageSizeController.open() }, }) } .height('90%') .width('32%') Column() { this.displayCard({ cardName: '层数设置', displayInfo: this.currentStorage && this.currentStorage.defaultLayer ? this.currentStorage.defaultLayer.toString() + '层' : '', clickEvent: ()=>{ this.editDefaultLayerController.open() }, }) } .height('90%') .width('32%') } .width('100%') .height('18%') .justifyContent(FlexAlign.SpaceBetween) } .width('100%') .height('100%') } @Builder displayCard($$: { cardName: string, displayInfo: string, clickEvent?: Function }) { Column() { Row() { Text($$.cardName) .height('30%') .fontSize($r('app.float.card_title_font_size')) .fontColor($r('app.color.general_font_color')) .fontWeight(FontWeight.Medium) .opacity($r('app.float.general_font_opacity')) } .alignItems(VerticalAlign.Center) .justifyContent(FlexAlign.Start) .padding({ left: '6.6%', right: '4.5%' }) .width('100%') Row() { Text($$.displayInfo) .fontSize($r('app.float.card_info_font_size')) .fontColor($r('app.color.general_font_color')) .fontWeight(FontWeight.Regular) .opacity($r('app.float.card_font_default_opacity')) } .alignItems(VerticalAlign.Center) .justifyContent(FlexAlign.Start) .padding({ left: '6.6%', right: '4.5%' }) .width('100%') Row() { Image($r('app.media.subscript')) .height($r('app.float.card_subscript_size')) .width($r('app.float.card_subscript_size')) } .alignItems(VerticalAlign.Center) .justifyContent(FlexAlign.End) .padding({ right: '4.5%' }) .width('100%') } .height('100%') .width('100%') .justifyContent(FlexAlign.Center) .borderRadius($r('app.float.general_border_radius')) .backgroundColor($r('app.color.general_card_background_color')) .onClick(() => { try { $$.clickEvent() } catch (err) { console.log('testTag', '---------err' + JSON.stringify(err)) } }) } } // 编辑仓储类型弹窗 @CustomDialog struct EditStorageTypeDialog { @Link selectSpace: StorageSpace @Link storageTypeStr: string controller?: CustomDialogController cancel: () => void = () => {} confirm: () => void = () => {} build() { Column() { Row() { Text('仓储类型') .fontSize($r('app.float.title_font_size')) .fontWeight(FontWeight.Medium) .fontColor($r('app.color.general_font_color')) .opacity($r('app.float.general_font_opacity')) } .height('15%') .alignItems(VerticalAlign.Center) List({ space: 20, initialIndex: 0 }) { ForEach(storageTypeArray, (item: string, index: number) => { ListItem() { Text(item) .fontSize($r('app.float.robot_set_font_size')) .fontWeight(FontWeight.Medium) .fontColor(this.storageTypeStr && item === this.storageTypeStr ? $r('app.color.general_font_white_color') : $r('app.color.general_font_color')) .textAlign(TextAlign.Center) .width('71%') .height('12.5%') .borderRadius($r('app.float.general_border_radius')) .backgroundColor(this.storageTypeStr && item === this.storageTypeStr ? $r('app.color.robot_set_card_blue') : $r('app.color.robot_set_card_white')) .onClick(()=>{ this.selectSpace.storageType = (index + 1).toString() this.storageTypeStr = getStorageTypeStr(this.selectSpace.storageType, storageTypeArray) StorageSpaceModel.updateStorageSpace(this.selectSpace.id, this.selectSpace.enableState, this.selectSpace.storageType, this.selectSpace.capacity, this.selectSpace.canWay, this.selectSpace.canPark, this.selectSpace.parkType) this.controller.close() this.confirm() }) } }) } .listDirection(Axis.Vertical) // 排列方向 // .edgeEffect(EdgeEffect.Spring) // 滑动到边缘无效果 .height('80%') .width('100%') .alignListItem(ListItemAlign.Center) } .width('48%') .height('74%') .backgroundColor($r('app.color.page_general_background')) .justifyContent(FlexAlign.SpaceEvenly) .borderRadius($r('app.float.general_border_radius')) } } // 编辑储位容量弹窗 @CustomDialog struct EditCapacityDialog { @Link selectSpace: StorageSpace // 最大容量(仓储默认层数) maxCapacity: number private capacityArray: string[] = [] // 选择的容量 private selectCapacity: string controller?: CustomDialogController cancel: () => void = () => {} confirm: () => void = () => {} aboutToAppear() { for (let index = 1; index <= this.maxCapacity; index++) { this.capacityArray.push(index.toString()); } this.selectCapacity = this.selectSpace.capacity.toString() } build() { Column() { Row() { Text('容量') .fontSize($r('app.float.title_font_size')) .fontWeight(FontWeight.Medium) .fontColor($r('app.color.general_font_color')) .opacity($r('app.float.general_font_opacity')) } .height('16%') .alignItems(VerticalAlign.Center) Row() { TextPicker({ range: this.capacityArray, selected: this.selectSpace && this.selectSpace.capacity > 0 ? this.selectSpace.capacity - 1 : 0}) .onChange((value: string) => { this.selectCapacity = value }) .width('80%') .backgroundColor($r('app.color.bottom_bar_background')) .borderImage({source:$r('app.media.text_picker_frame'), fill:true}) } .width('100%') .layoutWeight(1) .justifyContent(FlexAlign.Center) Row() { Button('取消') .fontSize($r('app.float.robot_set_font_size')) .fontWeight(FontWeight.Medium) .fontColor($r('app.color.robot_set_card_blue')) .width('32%') .height('50%') .borderRadius($r('app.float.robot_set_radius')) .backgroundColor($r('app.color.robot_set_coord_card_grey')) .onClick(() => { this.controller.close() this.cancel() }) Row() .width('2.5%') Button('确认') .fontSize($r('app.float.robot_set_font_size')) .fontWeight(FontWeight.Medium) .fontColor($r('app.color.general_font_white_color')) .width('32%') .height('50%') .borderRadius($r('app.float.robot_set_radius')) .backgroundColor($r('app.color.robot_set_card_blue')) .onClick(() => { if (this.controller != undefined) { this.controller.close() this.selectSpace.capacity = Number.parseInt(this.selectCapacity) StorageSpaceModel.updateStorageSpace(this.selectSpace.id, this.selectSpace.enableState, this.selectSpace.storageType, this.selectSpace.capacity, this.selectSpace.canWay, this.selectSpace.canPark, this.selectSpace.parkType) // this.confirm() } }) } .justifyContent(FlexAlign.Center) .height('20%') .width('100%') } .width('48%') .height('62%') .backgroundColor($r('app.color.page_general_background')) .justifyContent(FlexAlign.SpaceEvenly) .borderRadius($r('app.float.general_border_radius')) } } // 编辑能否途径弹窗 @CustomDialog struct EditCanWayDialog { @Link selectSpace: StorageSpace @State canWay: number = 1 controller?: CustomDialogController cancel: () => void = () => {} confirm: () => void = () => {} aboutToAppear() { this.canWay = this.selectSpace.canWay } build() { Column() { Row() { Text('能否途经') .fontSize($r('app.float.title_font_size')) .fontWeight(FontWeight.Medium) .fontColor($r('app.color.general_font_color')) .opacity($r('app.float.general_font_opacity')) } .height('30%') .alignItems(VerticalAlign.Center) Row() { Row() { Row() { Stack() { if (this.canWay === 1) { Text() .backgroundColor($r('app.color.general_card_background_color')) .width('100%') .height('100%') .borderRadius($r('app.float.general_border_radius')) } Text('能') .fontSize($r('app.float.set_card_font_size')) .fontColor($r('app.color.general_font_color')) .opacity(this.canWay === 1 ? $r('app.float.card_font_select_opacity') : $r('app.float.card_font_default_opacity')) } .width('100%') .height('100%') } .height('100%') .width('50%') .onClick(() => { this.selectSpace.canWay = 1 this.canWay = 1 StorageSpaceModel.updateStorageSpace(this.selectSpace.id, this.selectSpace.enableState, this.selectSpace.storageType, this.selectSpace.capacity, this.selectSpace.canWay, this.selectSpace.canPark, this.selectSpace.parkType) }) Row() { Stack() { if (this.canWay === 2) { Text() .backgroundColor($r('app.color.general_card_background_color')) .width('100%') .height('100%') .borderRadius($r('app.float.general_border_radius')) } Text('否') .fontSize($r('app.float.set_card_font_size')) .fontColor($r('app.color.general_font_color')) .opacity(this.canWay === 2 ? $r('app.float.card_font_select_opacity') : $r('app.float.card_font_default_opacity')) } .width('100%') .height('100%') } .height('100%') .width('50%') .onClick(() => { this.selectSpace.canWay = 2 this.canWay = 2 StorageSpaceModel.updateStorageSpace(this.selectSpace.id, this.selectSpace.enableState, this.selectSpace.storageType, this.selectSpace.capacity, this.selectSpace.canWay, this.selectSpace.canPark, this.selectSpace.parkType) }) } .height('50%') .width('100%') .borderRadius($r('app.float.general_border_radius')) .backgroundColor($r('app.color.robot_toward_set_card_background')) } .width('60%') .height('60%') Blank() } .width('48%') .height('48%') .backgroundColor($r('app.color.page_general_background')) .borderRadius($r('app.float.general_border_radius')) } } // 编辑停靠点弹窗 @CustomDialog struct EditParkTypeDialog { @Link selectSpace: StorageSpace @Link parkTypeStr: string typeArray: string[] = [] controller?: CustomDialogController cancel: () => void = () => {} confirm: () => void = () => {} aboutToAppear() { this.typeArray.push('非停靠点') this.typeArray = this.typeArray.concat(parkTypeArray) } build() { Column() { Row() { Text('停靠点类型') .fontSize($r('app.float.title_font_size')) .fontWeight(FontWeight.Medium) .fontColor($r('app.color.general_font_color')) .opacity($r('app.float.general_font_opacity')) } .height('15%') .alignItems(VerticalAlign.Center) List({ space: 20, initialIndex: 0 }) { ForEach(this.typeArray, (item: string, index: number) => { ListItem() { Text(item) .fontSize($r('app.float.robot_set_font_size')) .fontWeight(FontWeight.Medium) .fontColor(this.selectSpace && index === this.selectSpace.parkType ? $r('app.color.general_font_white_color') : $r('app.color.general_font_color')) .textAlign(TextAlign.Center) .width('71%') .height('12.5%') .borderRadius($r('app.float.general_border_radius')) .backgroundColor(this.selectSpace && index === this.selectSpace.parkType ? $r('app.color.robot_set_card_blue') : $r('app.color.robot_set_card_white')) .onClick(()=>{ this.selectSpace.parkType = index if (index === 0) { this.selectSpace.canPark = 2 } else { this.selectSpace.canPark = 1 } this.parkTypeStr = getParkTypeStr(this.selectSpace.parkType, parkTypeArray) StorageSpaceModel.updateStorageSpace(this.selectSpace.id, this.selectSpace.enableState, this.selectSpace.storageType, this.selectSpace.capacity, this.selectSpace.canWay, this.selectSpace.canPark, this.selectSpace.parkType) this.controller.close() }) } }) } .listDirection(Axis.Vertical) // 排列方向 // .edgeEffect(EdgeEffect.Spring) // 滑动到边缘无效果 .height('80%') .width('100%') .alignListItem(ListItemAlign.Center) } .width('48%') .height('74%') .backgroundColor($r('app.color.page_general_background')) .justifyContent(FlexAlign.SpaceEvenly) .borderRadius($r('app.float.general_border_radius')) } } // 编辑仓储名称编码弹窗 @CustomDialog struct EditStorageNameDialog { @Link currentStorage: StorageInfo private storageName: string controller?: CustomDialogController cancel: () => void = () => {} confirm: () => void = () => {} build() { Column() { Row() { Text('仓储名称') .fontSize($r('app.float.title_font_size')) .fontWeight(FontWeight.Medium) .fontColor($r('app.color.general_font_color')) .opacity($r('app.float.general_font_opacity')) } .height('25%') .alignItems(VerticalAlign.Center) Row() { TextInput({placeholder: '请输入仓储名称' }) .placeholderColor($r('app.color.text_input_placeholder_font_color')) .placeholderFont({size: $r('app.float.robot_set_font_size'), weight: FontWeight.Regular}) .fontSize($r('app.float.robot_set_font_size')) .fontWeight(FontWeight.Regular) .fontColor($r('app.color.general_font_color')) .borderRadius($r('app.float.robot_set_radius')) .backgroundColor($r('app.color.general_font_white_color')) .onChange((value: string) => { this.storageName = value }) } .height('25%') .width('80%') .justifyContent(FlexAlign.SpaceAround) .alignItems(VerticalAlign.Center) Blank() Row() { Button('取消') .fontSize($r('app.float.robot_set_font_size')) .fontWeight(FontWeight.Medium) .fontColor($r('app.color.robot_set_card_blue')) .width('32%') .height('50%') .borderRadius($r('app.float.robot_set_radius')) .backgroundColor($r('app.color.robot_set_coord_card_grey')) .onClick(() => { this.controller.close() this.cancel() }) Row() .width('2.5%') Button('确认') .fontSize($r('app.float.robot_set_font_size')) .fontWeight(FontWeight.Medium) .fontColor($r('app.color.general_font_white_color')) .width('32%') .height('50%') .borderRadius($r('app.float.robot_set_radius')) .backgroundColor($r('app.color.robot_set_card_blue')) .onClick(() => { if (this.controller != undefined) { this.currentStorage.storageName = this.storageName StorageModel.updateStorage(this.currentStorage.id, this.currentStorage.storageName, this.currentStorage.xSize, this.currentStorage.ySize, this.currentStorage.defaultLayer) this.controller.close() } }) } .justifyContent(FlexAlign.Center) .alignItems(VerticalAlign.Center) .height('40%') .width('100%') } .width('48%') .height('37%') .backgroundColor($r('app.color.page_general_background')) .justifyContent(FlexAlign.SpaceEvenly) .borderRadius($r('app.float.general_border_radius')) } } // 编辑仓储尺寸弹窗 @CustomDialog struct EditStorageSizeDialog { @Link currentStorage: StorageInfo private x : number private y : number private xList : string[] = [] private yList : string[] = [] controller?: CustomDialogController cancel: () => void = () => {} confirm: () => void = () => {} aboutToAppear() { for (let index = 1; index <= 20; index++) { this.xList.push(index.toString()) } for (let index = 1; index <= 20; index++) { this.yList.push(index.toString()) } this.x = this.currentStorage.xSize this.y = this.currentStorage.ySize } build() { Column() { Row() { Text('仓储尺寸修改') .fontSize($r('app.float.title_font_size')) .fontWeight(FontWeight.Medium) .fontColor($r('app.color.general_font_color')) .opacity($r('app.float.general_font_opacity')) } .height('16%') .alignItems(VerticalAlign.Center) Row() { Text('X大小') .fontSize($r('app.float.robot_set_font_size')) .fontWeight(FontWeight.Medium) .fontColor($r('app.color.general_font_color')) .opacity($r('app.float.general_font_opacity')) Text('Y大小') .fontSize($r('app.float.robot_set_font_size')) .fontWeight(FontWeight.Medium) .fontColor($r('app.color.general_font_color')) .opacity($r('app.float.general_font_opacity')) } .height('8%') .width('80%') .justifyContent(FlexAlign.SpaceAround) .alignItems(VerticalAlign.Center) Row() { TextPicker({ range: this.xList, selected: this.currentStorage && this.currentStorage.xSize > 0 ? this.currentStorage.xSize - 1 : 0}) .onChange((value: string) => { this.x = Number.parseInt(value) }) .width('40%') .height('100%') .backgroundColor($r('app.color.bottom_bar_background')) .borderImage({source:$r('app.media.text_picker_frame'), fill:true}) TextPicker({ range: this.yList, selected: this.currentStorage && this.currentStorage.ySize > 0 ? this.currentStorage.ySize - 1 : 0}) .onChange((value: string) => { this.y = Number.parseInt(value) }) .width('40%') .height('100%') .backgroundColor($r('app.color.bottom_bar_background')) .borderImage({source:$r('app.media.text_picker_frame'), fill:true}) } .height('52%') .width('100%') .justifyContent(FlexAlign.Center) Row() { Button('取消') .fontSize($r('app.float.robot_set_font_size')) .fontWeight(FontWeight.Medium) .fontColor($r('app.color.robot_set_card_blue')) .width('32%') .height('50%') .borderRadius($r('app.float.robot_set_radius')) .backgroundColor($r('app.color.robot_set_coord_card_grey')) .onClick(() => { this.controller.close() this.cancel() }) Row() .width('2.5%') Button('确认') .fontSize($r('app.float.robot_set_font_size')) .fontWeight(FontWeight.Medium) .fontColor($r('app.color.general_font_white_color')) .width('32%') .height('50%') .borderRadius($r('app.float.robot_set_radius')) .backgroundColor($r('app.color.robot_set_card_blue')) .onClick(() => { if (this.controller != undefined) { this.currentStorage.xSize = this.x this.currentStorage.ySize = this.y StorageModel.updateStorage(this.currentStorage.id, this.currentStorage.storageName, this.currentStorage.xSize, this.currentStorage.ySize, this.currentStorage.defaultLayer) this.controller.close() this.confirm() } }) } .justifyContent(FlexAlign.Center) .height('24%') .width('100%') } .width('48%') .height('62%') .backgroundColor($r('app.color.page_general_background')) .justifyContent(FlexAlign.SpaceEvenly) .borderRadius($r('app.float.general_border_radius')) } } // 编辑仓储默认层数弹窗 @CustomDialog struct EditDefaultLayerDialog { @Link currentStorage: StorageInfo private layerArray: string[] = [] // 选择的容量 private selectLayer: string controller?: CustomDialogController cancel: () => void = () => {} confirm: () => void = () => {} aboutToAppear() { for (let index = 1; index <= 20; index++) { this.layerArray.push(index.toString()); } this.selectLayer = this.currentStorage.defaultLayer.toString() } build() { Column() { Row() { Text('层数设置') .fontSize($r('app.float.title_font_size')) .fontWeight(FontWeight.Medium) .fontColor($r('app.color.general_font_color')) .opacity($r('app.float.general_font_opacity')) } .height('16%') .alignItems(VerticalAlign.Center) Row() { TextPicker({ range: this.layerArray, selected: this.currentStorage && this.currentStorage.defaultLayer > 0 ? this.currentStorage.defaultLayer - 1 : 0}) .onChange((value: string) => { this.selectLayer = value }) .width('80%') .backgroundColor($r('app.color.bottom_bar_background')) .borderImage({source:$r('app.media.text_picker_frame'), fill:true}) } .width('100%') .layoutWeight(1) .justifyContent(FlexAlign.Center) Row() { Button('取消') .fontSize($r('app.float.robot_set_font_size')) .fontWeight(FontWeight.Medium) .fontColor($r('app.color.robot_set_card_blue')) .width('32%') .height('50%') .borderRadius($r('app.float.robot_set_radius')) .backgroundColor($r('app.color.robot_set_coord_card_grey')) .onClick(() => { this.controller.close() this.cancel() }) Row() .width('2.5%') Button('确认') .fontSize($r('app.float.robot_set_font_size')) .fontWeight(FontWeight.Medium) .fontColor($r('app.color.general_font_white_color')) .width('32%') .height('50%') .borderRadius($r('app.float.robot_set_radius')) .backgroundColor($r('app.color.robot_set_card_blue')) .onClick(() => { if (this.controller != undefined) { this.controller.close() this.currentStorage.defaultLayer = Number.parseInt(this.selectLayer) StorageModel.updateStorage(this.currentStorage.id, this.currentStorage.storageName, this.currentStorage.xSize, this.currentStorage.ySize, this.currentStorage.defaultLayer) } }) } .justifyContent(FlexAlign.Center) .height('20%') .width('100%') } .width('48%') .height('62%') .backgroundColor($r('app.color.page_general_background')) .justifyContent(FlexAlign.SpaceEvenly) .borderRadius($r('app.float.general_border_radius')) } } // 获取当前储位的仓储类型字符串 function getStorageTypeStr(storageType: string, typeArray: string[]): string { if (!storageType || storageType.length === 0) { return '' } let typeStr: string = '' let types : string[] = storageType.split(',') console.log('testTag', '------------'+JSON.stringify(types)); for (const type of types) { typeStr += typeArray[Number.parseInt(type)-1] + ',' } if (typeStr.length > 0) { typeStr = typeStr.slice(0, -1); } return typeStr } // 获取当前储位的停靠点类型字符串 function getParkTypeStr(parkType: number, typeArray: string[]): string { if (!parkType || parkType === 0) { return '' } return typeArray[parkType - 1] }