123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155 |
- 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<SpaceStateList> = [];
- @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]
- }
|