StorageSetView.ets 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155
  1. import CommonConstants from '../common/constants/CommonConstants'
  2. import StorageModel from '../model/database/StorageModel'
  3. import StorageSpaceModel from '../model/database/StorageSpaceModel'
  4. import StorageInfo from '../model/StorageInfo'
  5. import StorageSpace from '../model/StorageSpace'
  6. import StorageSpaceGrid from '../common/component/StorageSpaceGrid'
  7. import SpaceStateList from '../model/SpaceStateList'
  8. import JGRequest from '../common/util/request/Request'
  9. import StorageConfig from '../viewmodel/StorageConfig'
  10. let storageTypeArray: string[] = CommonConstants.STORAGE_TYPE
  11. let parkTypeArray: string[] = CommonConstants.PARK_TYPE
  12. @Component
  13. export struct StorageSetView {
  14. storages: StorageInfo[] = []
  15. @State currentStorage: StorageInfo = null
  16. // key为storageSpace的y值
  17. @State spaceArray: StorageSpace[][] = []
  18. // 储位状态(1:禁用 2:未设置类型 3:正常 4:禁用+选中 5:未设置类型+选中 6:正常+选中)
  19. @State stateArray: Array<SpaceStateList> = [];
  20. @State selectSpace: StorageSpace = null
  21. @State storageTypeStr: string = ''
  22. @State parkTypeStr: string = ''
  23. // 仓储图效(1:2D 2:3D)
  24. @State imageEffect: number = 1
  25. // @State yNum: NumberDataSource = new NumberDataSource
  26. @State yNum: number[] = []
  27. // 编辑机仓储类型的弹窗控制器
  28. editStorageTypeController: CustomDialogController = new CustomDialogController({
  29. builder: EditStorageTypeDialog({
  30. selectSpace: this.selectSpace,
  31. storageTypeStr: this.storageTypeStr,
  32. confirm: ()=> {
  33. if (this.selectSpace.storageType && this.selectSpace.storageType.length > 0 && this.selectSpace.enableState === 1) {
  34. this.stateArray[this.selectSpace.y-1][this.selectSpace.x-1] += 1
  35. }
  36. }
  37. }),
  38. autoCancel: true,
  39. alignment: DialogAlignment.Center,
  40. // gridCount: 3,
  41. customStyle: true,
  42. })
  43. // 编辑机储位容量的弹窗控制器
  44. editCapacityController: CustomDialogController = new CustomDialogController({
  45. builder: EditCapacityDialog({
  46. selectSpace: this.selectSpace,
  47. maxCapacity: this.currentStorage.defaultLayer
  48. }),
  49. autoCancel: true,
  50. alignment: DialogAlignment.Center,
  51. // gridCount: 3,
  52. customStyle: true,
  53. })
  54. // 编辑储位能否途经的弹窗控制器
  55. editCanWayController: CustomDialogController = new CustomDialogController({
  56. builder: EditCanWayDialog({
  57. selectSpace: this.selectSpace,
  58. }),
  59. autoCancel: true,
  60. alignment: DialogAlignment.Center,
  61. // gridCount: 3,
  62. customStyle: true,
  63. })
  64. // 编辑机仓储类型的弹窗控制器
  65. editParkTypeController: CustomDialogController = new CustomDialogController({
  66. builder: EditParkTypeDialog({
  67. selectSpace: this.selectSpace,
  68. parkTypeStr: this.parkTypeStr
  69. }),
  70. autoCancel: true,
  71. alignment: DialogAlignment.Center,
  72. // gridCount: 3,
  73. customStyle: true,
  74. })
  75. // 编辑仓储名称的弹窗控制器
  76. editStorageNameController: CustomDialogController = new CustomDialogController({
  77. builder: EditStorageNameDialog({
  78. currentStorage: $currentStorage
  79. }),
  80. autoCancel: true,
  81. alignment: DialogAlignment.Center,
  82. // gridCount: 3,
  83. customStyle: true,
  84. })
  85. // 编辑仓储尺寸的弹窗控制器
  86. editStorageSizeController: CustomDialogController = new CustomDialogController({
  87. builder: EditStorageSizeDialog({
  88. currentStorage: $currentStorage,
  89. confirm: ()=> {
  90. this.updateStorageSpaceData(true)
  91. }
  92. }),
  93. autoCancel: true,
  94. alignment: DialogAlignment.Center,
  95. // gridCount: 3,
  96. customStyle: true,
  97. })
  98. // 编辑仓储默认层数的弹窗控制器
  99. editDefaultLayerController: CustomDialogController = new CustomDialogController({
  100. builder: EditDefaultLayerDialog({
  101. currentStorage: $currentStorage
  102. }),
  103. autoCancel: true,
  104. alignment: DialogAlignment.Center,
  105. // gridCount: 3,
  106. customStyle: true,
  107. })
  108. async aboutToAppear() {
  109. // 查询后台数据库的线边库
  110. let config: StorageConfig = await JGRequest.get("/api/v1/wms/position/houseConfigInfo/" + 1, {})
  111. // 查询本地数据库,没有则添加数据(仓储和储位数据)
  112. this.storages = await StorageModel.getStorageList()
  113. if (!config && (!this.storages || this.storages.length <= 0)) {
  114. return
  115. }
  116. if ((!this.storages || this.storages.length <= 0) && config) {
  117. this.storages.push({storageName: config.houseName, xSize: config.xNum, ySize: config.yNum, defaultLayer: config.layer} as StorageInfo)
  118. let storageId = await StorageModel.addStorage(config.houseName, config.xNum, config.yNum, config.layer)
  119. this.storages[0].id = storageId
  120. if (config.xNum && config.xNum > 0 && config.yNum && config.yNum > 0) {
  121. for (let y = 1; y <= config.yNum; y++) {
  122. for (let x = 1; x <= config.xNum; x++) {
  123. let space: StorageSpace = {storageId: storageId, x: x, y: y, enableState: 1, storageType: '', capacity: config.layer, canWay: 1, canPark: 0}
  124. await StorageSpaceModel.addStorageSpace(space)
  125. }
  126. }
  127. }
  128. } else if ((this.storages[0].xSize != config.xNum || this.storages[0].ySize != config.yNum) && config) {
  129. // 如果本地数据保存数据和后台不匹配,后台数据库为主
  130. this.currentStorage = this.storages[0]
  131. StorageModel.updateStorage(this.storages[0].id, this.storages[0].storageName, config.xNum, config.yNum, config.layer)
  132. this.updateStorageSpaceData(false)
  133. }
  134. // 渲染封装数据
  135. this.currentStorage = this.storages[0]
  136. let x: number = 0
  137. if (this.currentStorage.xSize && this.currentStorage.xSize > 0) {
  138. x = this.currentStorage.xSize
  139. } else {
  140. return
  141. }
  142. // 生成需要遍历的行 (y倒序)
  143. if (this.currentStorage.ySize && this.currentStorage.ySize > 0) {
  144. if (this.currentStorage.ySize && this.currentStorage.ySize > 0) {
  145. for (let index = this.currentStorage.ySize - 1; index >= 0; index--) {
  146. this.yNum.push(index)
  147. }
  148. }
  149. } else {
  150. return
  151. }
  152. StorageSpaceModel.getListByStorageId(this.currentStorage.id).then(spaces => {
  153. if (spaces && spaces.length > 0) {
  154. let tempArray: StorageSpace[] = []
  155. let stateList = new SpaceStateList()
  156. for (const space of spaces) {
  157. tempArray.push(space)
  158. // 储位状态创建
  159. if (space.enableState === 2) {
  160. stateList.push(1)
  161. } else if (!space.storageType || space.storageType.length === 0) {
  162. stateList.push(2)
  163. } else {
  164. stateList.push(3)
  165. }
  166. if (tempArray.length === x) {
  167. this.spaceArray.push(tempArray)
  168. this.stateArray.push(stateList)
  169. tempArray = []
  170. stateList = new SpaceStateList()
  171. }
  172. }
  173. }
  174. })
  175. }
  176. /*
  177. * updateArray
  178. * */
  179. /**
  180. * 更新本地数据库的仓储储位
  181. * @param updateArray 是否更新spaceArray(aboutToAppear调用时不更新)
  182. */
  183. async updateStorageSpaceData(updateArray: boolean) {
  184. this.spaceArray = []
  185. this.stateArray = []
  186. let y = 1
  187. this.yNum = []
  188. // let oldSize = this.spaceArray.length
  189. for (let index = this.currentStorage.ySize - 1; index >= 0; index--) {
  190. let tempArray: StorageSpace[] = []
  191. let stateList = new SpaceStateList()
  192. for (let x = 1; x <= this.currentStorage.xSize; x++) {
  193. 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})
  194. stateList.push(2)
  195. }
  196. this.spaceArray.push(tempArray)
  197. this.stateArray.push(stateList)
  198. this.yNum.push(index)
  199. y++
  200. }
  201. await StorageSpaceModel.initDataByStorage(this.currentStorage)
  202. if (updateArray) {
  203. StorageSpaceModel.getListByStorageId(this.currentStorage.id).then(spaces => {
  204. if (spaces && spaces.length > 0) {
  205. for (const space of spaces) {
  206. this.spaceArray[space.y - 1][space.x - 1].id = space.id
  207. }
  208. }
  209. })
  210. }
  211. }
  212. build() {
  213. Column() {
  214. Row() {
  215. Column() {
  216. Column() {
  217. StorageSpaceGrid({
  218. stateArray: $stateArray,
  219. spaceArray: $spaceArray,
  220. yNum:$yNum,
  221. selectSpace: $selectSpace,
  222. storageTypeStr: $storageTypeStr,
  223. parkTypeStr: $parkTypeStr,
  224. })
  225. // 2D/3D切换按钮
  226. Row() {
  227. Row() {
  228. Row() {
  229. Stack() {
  230. if (this.imageEffect === 1) {
  231. Text()
  232. .backgroundColor($r('app.color.general_card_background_color'))
  233. .width('100%')
  234. .height('100%')
  235. .borderRadius($r('app.float.general_border_radius'))
  236. }
  237. Text('2D')
  238. .fontSize($r('app.float.set_card_font_size'))
  239. .fontColor($r('app.color.general_font_color'))
  240. .opacity(this.imageEffect === 1 ? $r('app.float.card_font_select_opacity') : $r('app.float.card_font_default_opacity'))
  241. }
  242. .width('100%')
  243. .height('100%')
  244. }
  245. .onClick(() => {
  246. if (this.selectSpace) {
  247. this.stateArray[this.selectSpace.y-1][this.selectSpace.x-1] -= 3
  248. }
  249. this.imageEffect = 1
  250. })
  251. .width('50%')
  252. Row() {
  253. Stack() {
  254. if (this.imageEffect === 2) {
  255. Text()
  256. .backgroundColor($r('app.color.general_card_background_color'))
  257. .width('100%')
  258. .height('100%')
  259. .borderRadius($r('app.float.general_border_radius'))
  260. }
  261. Text('3D')
  262. .fontSize($r('app.float.set_card_font_size'))
  263. .fontColor($r('app.color.general_font_color'))
  264. .opacity(this.imageEffect === 2 ? $r('app.float.card_font_select_opacity') : $r('app.float.card_font_default_opacity'))
  265. }
  266. .width('100%')
  267. .height('100%')
  268. }
  269. .width('50%')
  270. .onClick(() => {
  271. if (this.selectSpace) {
  272. this.stateArray[this.selectSpace.y-1][this.selectSpace.x-1] -= 3
  273. }
  274. this.imageEffect = 2
  275. })
  276. }
  277. .width($r('app.float.storage_set_image_effect_width'))
  278. .height($r('app.float.storage_set_image_effect_height'))
  279. .borderRadius($r('app.float.general_border_radius'))
  280. .backgroundColor($r('app.color.robot_toward_set_card_background'))
  281. }
  282. .height('16%')
  283. .width('100%')
  284. .alignItems(VerticalAlign.Center)
  285. .justifyContent(FlexAlign.Start)
  286. }
  287. .height('100%')
  288. .layoutWeight(1)
  289. }
  290. .height('100%')
  291. .layoutWeight(1)
  292. .justifyContent(FlexAlign.Center)
  293. .alignItems(HorizontalAlign.Center)
  294. .onClick(() => {
  295. if (this.selectSpace) {
  296. this.stateArray[this.selectSpace.y-1][this.selectSpace.x-1] -= 3
  297. }
  298. this.selectSpace = null
  299. this.storageTypeStr = null
  300. this.parkTypeStr = null
  301. })
  302. // 储位设置
  303. if (this.selectSpace) {
  304. Column() {
  305. Row() {
  306. Column() {
  307. Text(this.selectSpace && this.selectSpace.x && this.selectSpace.y ? 'X:' + this.selectSpace.x + ' Y:' + this.selectSpace.y : '')
  308. .fontSize($r('app.float.card_title_font_size'))
  309. .fontColor($r('app.color.general_font_color'))
  310. .fontWeight(FontWeight.Medium)
  311. .opacity($r('app.float.general_font_opacity'))
  312. Text(this.selectSpace && this.selectSpace.enableState === 1 ? '启用' : '禁用')
  313. .fontSize($r('app.float.card_info_font_size'))
  314. .fontColor($r('app.color.general_font_color'))
  315. .fontWeight(FontWeight.Regular)
  316. .opacity($r('app.float.card_font_default_opacity'))
  317. }
  318. .alignItems(HorizontalAlign.Start)
  319. .padding({ left: '10%' })
  320. Blank()
  321. Column() {
  322. Toggle({ type: ToggleType.Switch, isOn: this.selectSpace && this.selectSpace.enableState === 1 ? true : false })
  323. .height('33%')
  324. .width('60%')
  325. .onChange((isOn: boolean) => {
  326. let enableState = isOn ? 1 : 2
  327. this.selectSpace.enableState = enableState
  328. this.spaceArray[this.selectSpace.y - 1][this.selectSpace.x - 1].enableState = enableState
  329. if (isOn) {
  330. 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) {
  331. this.stateArray[this.selectSpace.y - 1][this.selectSpace.x - 1] = 5
  332. } else {
  333. this.stateArray[this.selectSpace.y - 1][this.selectSpace.x - 1] = 6
  334. }
  335. } else {
  336. this.stateArray[this.selectSpace.y - 1][this.selectSpace.x - 1] = 4
  337. }
  338. StorageSpaceModel.updateStorageSpace(this.selectSpace.id, enableState, this.selectSpace.storageType, this.selectSpace.capacity, this.selectSpace.canWay, this.selectSpace.canPark, this.selectSpace.parkType)
  339. })
  340. }
  341. .width('41%')
  342. .height('100%')
  343. .justifyContent(FlexAlign.Center)
  344. }
  345. .width('100%')
  346. .height('16%')
  347. .backgroundColor($r('app.color.robot_set_card_white'))
  348. .borderRadius($r('app.float.general_border_radius'))
  349. Row() {
  350. this.displayCard({
  351. cardName: '仓储类型',
  352. displayInfo: this.storageTypeStr ? this.storageTypeStr : '',
  353. clickEvent: ()=>{
  354. this.editStorageTypeController.open()
  355. }})
  356. }
  357. .width('100%')
  358. .height('16%')
  359. .backgroundColor($r('app.color.robot_set_card_white'))
  360. .borderRadius($r('app.float.general_border_radius'))
  361. Row() {
  362. this.displayCard({
  363. cardName: '容量',
  364. displayInfo: this.selectSpace && this.selectSpace.capacity ? this.selectSpace.capacity + '层' : '',
  365. clickEvent: ()=>{
  366. this.editCapacityController.open()
  367. }})
  368. }
  369. .width('100%')
  370. .height('16%')
  371. .backgroundColor($r('app.color.robot_set_card_white'))
  372. .borderRadius($r('app.float.general_border_radius'))
  373. Row() {
  374. this.displayCard({
  375. cardName: '能否途经',
  376. displayInfo: !this.selectSpace || !this.selectSpace.canWay ? '' : (this.selectSpace.canWay === 1 ? '能' : '否'),
  377. clickEvent: ()=>{
  378. this.editCanWayController.open()
  379. }
  380. })
  381. }
  382. .width('100%')
  383. .height('16%')
  384. .backgroundColor($r('app.color.robot_set_card_white'))
  385. .borderRadius($r('app.float.general_border_radius'))
  386. Row() {
  387. this.displayCard({
  388. cardName: '是否为出入库停靠点',
  389. displayInfo: !this.selectSpace || !this.selectSpace.canPark ? '' : (this.selectSpace.canPark === 2 ? '否' : this.parkTypeStr),
  390. clickEvent: ()=>{
  391. this.editParkTypeController.open()
  392. }
  393. })
  394. }
  395. .width('100%')
  396. .height('16%')
  397. .backgroundColor($r('app.color.robot_set_card_white'))
  398. .borderRadius($r('app.float.general_border_radius'))
  399. }
  400. .height('100%')
  401. .width('20%')
  402. .justifyContent(FlexAlign.SpaceEvenly)
  403. }
  404. }
  405. .width('100%')
  406. .height('82%')
  407. // 仓储设置
  408. Row() {
  409. Column() {
  410. this.displayCard({
  411. cardName: '仓储名称',
  412. displayInfo: this.currentStorage && this.currentStorage.storageName ? this.currentStorage.storageName : '',
  413. clickEvent: ()=>{
  414. this.editStorageNameController.open()
  415. }
  416. })
  417. }
  418. .height('90%')
  419. .width('32%')
  420. Column() {
  421. this.displayCard({
  422. cardName: '总尺寸',
  423. displayInfo: this.currentStorage && this.currentStorage.xSize && this.currentStorage.ySize ? this.currentStorage.xSize + '*' + this.currentStorage.ySize : '',
  424. clickEvent: ()=>{
  425. this.editStorageSizeController.open()
  426. },
  427. })
  428. }
  429. .height('90%')
  430. .width('32%')
  431. Column() {
  432. this.displayCard({
  433. cardName: '层数设置',
  434. displayInfo: this.currentStorage && this.currentStorage.defaultLayer ? this.currentStorage.defaultLayer.toString() + '层' : '',
  435. clickEvent: ()=>{
  436. this.editDefaultLayerController.open()
  437. },
  438. })
  439. }
  440. .height('90%')
  441. .width('32%')
  442. }
  443. .width('100%')
  444. .height('18%')
  445. .justifyContent(FlexAlign.SpaceBetween)
  446. }
  447. .width('100%')
  448. .height('100%')
  449. }
  450. @Builder
  451. displayCard($$: {
  452. cardName: string,
  453. displayInfo: string,
  454. clickEvent?: Function
  455. }) {
  456. Column() {
  457. Row() {
  458. Text($$.cardName)
  459. .height('30%')
  460. .fontSize($r('app.float.card_title_font_size'))
  461. .fontColor($r('app.color.general_font_color'))
  462. .fontWeight(FontWeight.Medium)
  463. .opacity($r('app.float.general_font_opacity'))
  464. }
  465. .alignItems(VerticalAlign.Center)
  466. .justifyContent(FlexAlign.Start)
  467. .padding({ left: '6.6%', right: '4.5%' })
  468. .width('100%')
  469. Row() {
  470. Text($$.displayInfo)
  471. .fontSize($r('app.float.card_info_font_size'))
  472. .fontColor($r('app.color.general_font_color'))
  473. .fontWeight(FontWeight.Regular)
  474. .opacity($r('app.float.card_font_default_opacity'))
  475. }
  476. .alignItems(VerticalAlign.Center)
  477. .justifyContent(FlexAlign.Start)
  478. .padding({ left: '6.6%', right: '4.5%' })
  479. .width('100%')
  480. Row() {
  481. Image($r('app.media.subscript'))
  482. .height($r('app.float.card_subscript_size'))
  483. .width($r('app.float.card_subscript_size'))
  484. }
  485. .alignItems(VerticalAlign.Center)
  486. .justifyContent(FlexAlign.End)
  487. .padding({ right: '4.5%' })
  488. .width('100%')
  489. }
  490. .height('100%')
  491. .width('100%')
  492. .justifyContent(FlexAlign.Center)
  493. .borderRadius($r('app.float.general_border_radius'))
  494. .backgroundColor($r('app.color.general_card_background_color'))
  495. .onClick(() => {
  496. try {
  497. $$.clickEvent()
  498. } catch (err) {
  499. console.log('testTag', '---------err' + JSON.stringify(err))
  500. }
  501. })
  502. }
  503. }
  504. // 编辑仓储类型弹窗
  505. @CustomDialog
  506. struct EditStorageTypeDialog {
  507. @Link selectSpace: StorageSpace
  508. @Link storageTypeStr: string
  509. controller?: CustomDialogController
  510. cancel: () => void = () => {}
  511. confirm: () => void = () => {}
  512. build() {
  513. Column() {
  514. Row() {
  515. Text('仓储类型')
  516. .fontSize($r('app.float.title_font_size'))
  517. .fontWeight(FontWeight.Medium)
  518. .fontColor($r('app.color.general_font_color'))
  519. .opacity($r('app.float.general_font_opacity'))
  520. }
  521. .height('15%')
  522. .alignItems(VerticalAlign.Center)
  523. List({ space: 20, initialIndex: 0 }) {
  524. ForEach(storageTypeArray, (item: string, index: number) => {
  525. ListItem() {
  526. Text(item)
  527. .fontSize($r('app.float.robot_set_font_size'))
  528. .fontWeight(FontWeight.Medium)
  529. .fontColor(this.storageTypeStr && item === this.storageTypeStr ? $r('app.color.general_font_white_color') : $r('app.color.general_font_color'))
  530. .textAlign(TextAlign.Center)
  531. .width('71%')
  532. .height('12.5%')
  533. .borderRadius($r('app.float.general_border_radius'))
  534. .backgroundColor(this.storageTypeStr && item === this.storageTypeStr ? $r('app.color.robot_set_card_blue') : $r('app.color.robot_set_card_white'))
  535. .onClick(()=>{
  536. this.selectSpace.storageType = (index + 1).toString()
  537. this.storageTypeStr = getStorageTypeStr(this.selectSpace.storageType, storageTypeArray)
  538. StorageSpaceModel.updateStorageSpace(this.selectSpace.id, this.selectSpace.enableState, this.selectSpace.storageType, this.selectSpace.capacity, this.selectSpace.canWay, this.selectSpace.canPark, this.selectSpace.parkType)
  539. this.controller.close()
  540. this.confirm()
  541. })
  542. }
  543. })
  544. }
  545. .listDirection(Axis.Vertical) // 排列方向
  546. // .edgeEffect(EdgeEffect.Spring) // 滑动到边缘无效果
  547. .height('80%')
  548. .width('100%')
  549. .alignListItem(ListItemAlign.Center)
  550. }
  551. .width('48%')
  552. .height('74%')
  553. .backgroundColor($r('app.color.page_general_background'))
  554. .justifyContent(FlexAlign.SpaceEvenly)
  555. .borderRadius($r('app.float.general_border_radius'))
  556. }
  557. }
  558. // 编辑储位容量弹窗
  559. @CustomDialog
  560. struct EditCapacityDialog {
  561. @Link selectSpace: StorageSpace
  562. // 最大容量(仓储默认层数)
  563. maxCapacity: number
  564. private capacityArray: string[] = []
  565. // 选择的容量
  566. private selectCapacity: string
  567. controller?: CustomDialogController
  568. cancel: () => void = () => {}
  569. confirm: () => void = () => {}
  570. aboutToAppear() {
  571. for (let index = 1; index <= this.maxCapacity; index++) {
  572. this.capacityArray.push(index.toString());
  573. }
  574. this.selectCapacity = this.selectSpace.capacity.toString()
  575. }
  576. build() {
  577. Column() {
  578. Row() {
  579. Text('容量')
  580. .fontSize($r('app.float.title_font_size'))
  581. .fontWeight(FontWeight.Medium)
  582. .fontColor($r('app.color.general_font_color'))
  583. .opacity($r('app.float.general_font_opacity'))
  584. }
  585. .height('16%')
  586. .alignItems(VerticalAlign.Center)
  587. Row() {
  588. TextPicker({ range: this.capacityArray, selected: this.selectSpace && this.selectSpace.capacity > 0 ? this.selectSpace.capacity - 1 : 0})
  589. .onChange((value: string) => {
  590. this.selectCapacity = value
  591. })
  592. .width('80%')
  593. .backgroundColor($r('app.color.bottom_bar_background'))
  594. .borderImage({source:$r('app.media.text_picker_frame'), fill:true})
  595. }
  596. .width('100%')
  597. .layoutWeight(1)
  598. .justifyContent(FlexAlign.Center)
  599. Row() {
  600. Button('取消')
  601. .fontSize($r('app.float.robot_set_font_size'))
  602. .fontWeight(FontWeight.Medium)
  603. .fontColor($r('app.color.robot_set_card_blue'))
  604. .width('32%')
  605. .height('50%')
  606. .borderRadius($r('app.float.robot_set_radius'))
  607. .backgroundColor($r('app.color.robot_set_coord_card_grey'))
  608. .onClick(() => {
  609. this.controller.close()
  610. this.cancel()
  611. })
  612. Row()
  613. .width('2.5%')
  614. Button('确认')
  615. .fontSize($r('app.float.robot_set_font_size'))
  616. .fontWeight(FontWeight.Medium)
  617. .fontColor($r('app.color.general_font_white_color'))
  618. .width('32%')
  619. .height('50%')
  620. .borderRadius($r('app.float.robot_set_radius'))
  621. .backgroundColor($r('app.color.robot_set_card_blue'))
  622. .onClick(() => {
  623. if (this.controller != undefined) {
  624. this.controller.close()
  625. this.selectSpace.capacity = Number.parseInt(this.selectCapacity)
  626. StorageSpaceModel.updateStorageSpace(this.selectSpace.id, this.selectSpace.enableState, this.selectSpace.storageType, this.selectSpace.capacity, this.selectSpace.canWay, this.selectSpace.canPark, this.selectSpace.parkType)
  627. // this.confirm()
  628. }
  629. })
  630. }
  631. .justifyContent(FlexAlign.Center)
  632. .height('20%')
  633. .width('100%')
  634. }
  635. .width('48%')
  636. .height('62%')
  637. .backgroundColor($r('app.color.page_general_background'))
  638. .justifyContent(FlexAlign.SpaceEvenly)
  639. .borderRadius($r('app.float.general_border_radius'))
  640. }
  641. }
  642. // 编辑能否途径弹窗
  643. @CustomDialog
  644. struct EditCanWayDialog {
  645. @Link selectSpace: StorageSpace
  646. @State canWay: number = 1
  647. controller?: CustomDialogController
  648. cancel: () => void = () => {}
  649. confirm: () => void = () => {}
  650. aboutToAppear() {
  651. this.canWay = this.selectSpace.canWay
  652. }
  653. build() {
  654. Column() {
  655. Row() {
  656. Text('能否途经')
  657. .fontSize($r('app.float.title_font_size'))
  658. .fontWeight(FontWeight.Medium)
  659. .fontColor($r('app.color.general_font_color'))
  660. .opacity($r('app.float.general_font_opacity'))
  661. }
  662. .height('30%')
  663. .alignItems(VerticalAlign.Center)
  664. Row() {
  665. Row() {
  666. Row() {
  667. Stack() {
  668. if (this.canWay === 1) {
  669. Text()
  670. .backgroundColor($r('app.color.general_card_background_color'))
  671. .width('100%')
  672. .height('100%')
  673. .borderRadius($r('app.float.general_border_radius'))
  674. }
  675. Text('能')
  676. .fontSize($r('app.float.set_card_font_size'))
  677. .fontColor($r('app.color.general_font_color'))
  678. .opacity(this.canWay === 1 ? $r('app.float.card_font_select_opacity') : $r('app.float.card_font_default_opacity'))
  679. }
  680. .width('100%')
  681. .height('100%')
  682. }
  683. .height('100%')
  684. .width('50%')
  685. .onClick(() => {
  686. this.selectSpace.canWay = 1
  687. this.canWay = 1
  688. StorageSpaceModel.updateStorageSpace(this.selectSpace.id, this.selectSpace.enableState, this.selectSpace.storageType, this.selectSpace.capacity, this.selectSpace.canWay, this.selectSpace.canPark, this.selectSpace.parkType)
  689. })
  690. Row() {
  691. Stack() {
  692. if (this.canWay === 2) {
  693. Text()
  694. .backgroundColor($r('app.color.general_card_background_color'))
  695. .width('100%')
  696. .height('100%')
  697. .borderRadius($r('app.float.general_border_radius'))
  698. }
  699. Text('否')
  700. .fontSize($r('app.float.set_card_font_size'))
  701. .fontColor($r('app.color.general_font_color'))
  702. .opacity(this.canWay === 2 ? $r('app.float.card_font_select_opacity') : $r('app.float.card_font_default_opacity'))
  703. }
  704. .width('100%')
  705. .height('100%')
  706. }
  707. .height('100%')
  708. .width('50%')
  709. .onClick(() => {
  710. this.selectSpace.canWay = 2
  711. this.canWay = 2
  712. StorageSpaceModel.updateStorageSpace(this.selectSpace.id, this.selectSpace.enableState, this.selectSpace.storageType, this.selectSpace.capacity, this.selectSpace.canWay, this.selectSpace.canPark, this.selectSpace.parkType)
  713. })
  714. }
  715. .height('50%')
  716. .width('100%')
  717. .borderRadius($r('app.float.general_border_radius'))
  718. .backgroundColor($r('app.color.robot_toward_set_card_background'))
  719. }
  720. .width('60%')
  721. .height('60%')
  722. Blank()
  723. }
  724. .width('48%')
  725. .height('48%')
  726. .backgroundColor($r('app.color.page_general_background'))
  727. .borderRadius($r('app.float.general_border_radius'))
  728. }
  729. }
  730. // 编辑停靠点弹窗
  731. @CustomDialog
  732. struct EditParkTypeDialog {
  733. @Link selectSpace: StorageSpace
  734. @Link parkTypeStr: string
  735. typeArray: string[] = []
  736. controller?: CustomDialogController
  737. cancel: () => void = () => {}
  738. confirm: () => void = () => {}
  739. aboutToAppear() {
  740. this.typeArray.push('非停靠点')
  741. this.typeArray = this.typeArray.concat(parkTypeArray)
  742. }
  743. build() {
  744. Column() {
  745. Row() {
  746. Text('停靠点类型')
  747. .fontSize($r('app.float.title_font_size'))
  748. .fontWeight(FontWeight.Medium)
  749. .fontColor($r('app.color.general_font_color'))
  750. .opacity($r('app.float.general_font_opacity'))
  751. }
  752. .height('15%')
  753. .alignItems(VerticalAlign.Center)
  754. List({ space: 20, initialIndex: 0 }) {
  755. ForEach(this.typeArray, (item: string, index: number) => {
  756. ListItem() {
  757. Text(item)
  758. .fontSize($r('app.float.robot_set_font_size'))
  759. .fontWeight(FontWeight.Medium)
  760. .fontColor(this.selectSpace && index === this.selectSpace.parkType ? $r('app.color.general_font_white_color') : $r('app.color.general_font_color'))
  761. .textAlign(TextAlign.Center)
  762. .width('71%')
  763. .height('12.5%')
  764. .borderRadius($r('app.float.general_border_radius'))
  765. .backgroundColor(this.selectSpace && index === this.selectSpace.parkType ? $r('app.color.robot_set_card_blue') : $r('app.color.robot_set_card_white'))
  766. .onClick(()=>{
  767. this.selectSpace.parkType = index
  768. if (index === 0) {
  769. this.selectSpace.canPark = 2
  770. } else {
  771. this.selectSpace.canPark = 1
  772. }
  773. this.parkTypeStr = getParkTypeStr(this.selectSpace.parkType, parkTypeArray)
  774. StorageSpaceModel.updateStorageSpace(this.selectSpace.id, this.selectSpace.enableState, this.selectSpace.storageType, this.selectSpace.capacity, this.selectSpace.canWay, this.selectSpace.canPark, this.selectSpace.parkType)
  775. this.controller.close()
  776. })
  777. }
  778. })
  779. }
  780. .listDirection(Axis.Vertical) // 排列方向
  781. // .edgeEffect(EdgeEffect.Spring) // 滑动到边缘无效果
  782. .height('80%')
  783. .width('100%')
  784. .alignListItem(ListItemAlign.Center)
  785. }
  786. .width('48%')
  787. .height('74%')
  788. .backgroundColor($r('app.color.page_general_background'))
  789. .justifyContent(FlexAlign.SpaceEvenly)
  790. .borderRadius($r('app.float.general_border_radius'))
  791. }
  792. }
  793. // 编辑仓储名称编码弹窗
  794. @CustomDialog
  795. struct EditStorageNameDialog {
  796. @Link currentStorage: StorageInfo
  797. private storageName: string
  798. controller?: CustomDialogController
  799. cancel: () => void = () => {}
  800. confirm: () => void = () => {}
  801. build() {
  802. Column() {
  803. Row() {
  804. Text('仓储名称')
  805. .fontSize($r('app.float.title_font_size'))
  806. .fontWeight(FontWeight.Medium)
  807. .fontColor($r('app.color.general_font_color'))
  808. .opacity($r('app.float.general_font_opacity'))
  809. }
  810. .height('25%')
  811. .alignItems(VerticalAlign.Center)
  812. Row() {
  813. TextInput({placeholder: '请输入仓储名称' })
  814. .placeholderColor($r('app.color.text_input_placeholder_font_color'))
  815. .placeholderFont({size: $r('app.float.robot_set_font_size'), weight: FontWeight.Regular})
  816. .fontSize($r('app.float.robot_set_font_size'))
  817. .fontWeight(FontWeight.Regular)
  818. .fontColor($r('app.color.general_font_color'))
  819. .borderRadius($r('app.float.robot_set_radius'))
  820. .backgroundColor($r('app.color.general_font_white_color'))
  821. .onChange((value: string) => {
  822. this.storageName = value
  823. })
  824. }
  825. .height('25%')
  826. .width('80%')
  827. .justifyContent(FlexAlign.SpaceAround)
  828. .alignItems(VerticalAlign.Center)
  829. Blank()
  830. Row() {
  831. Button('取消')
  832. .fontSize($r('app.float.robot_set_font_size'))
  833. .fontWeight(FontWeight.Medium)
  834. .fontColor($r('app.color.robot_set_card_blue'))
  835. .width('32%')
  836. .height('50%')
  837. .borderRadius($r('app.float.robot_set_radius'))
  838. .backgroundColor($r('app.color.robot_set_coord_card_grey'))
  839. .onClick(() => {
  840. this.controller.close()
  841. this.cancel()
  842. })
  843. Row()
  844. .width('2.5%')
  845. Button('确认')
  846. .fontSize($r('app.float.robot_set_font_size'))
  847. .fontWeight(FontWeight.Medium)
  848. .fontColor($r('app.color.general_font_white_color'))
  849. .width('32%')
  850. .height('50%')
  851. .borderRadius($r('app.float.robot_set_radius'))
  852. .backgroundColor($r('app.color.robot_set_card_blue'))
  853. .onClick(() => {
  854. if (this.controller != undefined) {
  855. this.currentStorage.storageName = this.storageName
  856. StorageModel.updateStorage(this.currentStorage.id, this.currentStorage.storageName, this.currentStorage.xSize, this.currentStorage.ySize, this.currentStorage.defaultLayer)
  857. this.controller.close()
  858. }
  859. })
  860. }
  861. .justifyContent(FlexAlign.Center)
  862. .alignItems(VerticalAlign.Center)
  863. .height('40%')
  864. .width('100%')
  865. }
  866. .width('48%')
  867. .height('37%')
  868. .backgroundColor($r('app.color.page_general_background'))
  869. .justifyContent(FlexAlign.SpaceEvenly)
  870. .borderRadius($r('app.float.general_border_radius'))
  871. }
  872. }
  873. // 编辑仓储尺寸弹窗
  874. @CustomDialog
  875. struct EditStorageSizeDialog {
  876. @Link currentStorage: StorageInfo
  877. private x : number
  878. private y : number
  879. private xList : string[] = []
  880. private yList : string[] = []
  881. controller?: CustomDialogController
  882. cancel: () => void = () => {}
  883. confirm: () => void = () => {}
  884. aboutToAppear() {
  885. for (let index = 1; index <= 20; index++) {
  886. this.xList.push(index.toString())
  887. }
  888. for (let index = 1; index <= 20; index++) {
  889. this.yList.push(index.toString())
  890. }
  891. this.x = this.currentStorage.xSize
  892. this.y = this.currentStorage.ySize
  893. }
  894. build() {
  895. Column() {
  896. Row() {
  897. Text('仓储尺寸修改')
  898. .fontSize($r('app.float.title_font_size'))
  899. .fontWeight(FontWeight.Medium)
  900. .fontColor($r('app.color.general_font_color'))
  901. .opacity($r('app.float.general_font_opacity'))
  902. }
  903. .height('16%')
  904. .alignItems(VerticalAlign.Center)
  905. Row() {
  906. Text('X大小')
  907. .fontSize($r('app.float.robot_set_font_size'))
  908. .fontWeight(FontWeight.Medium)
  909. .fontColor($r('app.color.general_font_color'))
  910. .opacity($r('app.float.general_font_opacity'))
  911. Text('Y大小')
  912. .fontSize($r('app.float.robot_set_font_size'))
  913. .fontWeight(FontWeight.Medium)
  914. .fontColor($r('app.color.general_font_color'))
  915. .opacity($r('app.float.general_font_opacity'))
  916. }
  917. .height('8%')
  918. .width('80%')
  919. .justifyContent(FlexAlign.SpaceAround)
  920. .alignItems(VerticalAlign.Center)
  921. Row() {
  922. TextPicker({ range: this.xList, selected: this.currentStorage && this.currentStorage.xSize > 0 ? this.currentStorage.xSize - 1 : 0})
  923. .onChange((value: string) => {
  924. this.x = Number.parseInt(value)
  925. })
  926. .width('40%')
  927. .height('100%')
  928. .backgroundColor($r('app.color.bottom_bar_background'))
  929. .borderImage({source:$r('app.media.text_picker_frame'), fill:true})
  930. TextPicker({ range: this.yList, selected: this.currentStorage && this.currentStorage.ySize > 0 ? this.currentStorage.ySize - 1 : 0})
  931. .onChange((value: string) => {
  932. this.y = Number.parseInt(value)
  933. })
  934. .width('40%')
  935. .height('100%')
  936. .backgroundColor($r('app.color.bottom_bar_background'))
  937. .borderImage({source:$r('app.media.text_picker_frame'), fill:true})
  938. }
  939. .height('52%')
  940. .width('100%')
  941. .justifyContent(FlexAlign.Center)
  942. Row() {
  943. Button('取消')
  944. .fontSize($r('app.float.robot_set_font_size'))
  945. .fontWeight(FontWeight.Medium)
  946. .fontColor($r('app.color.robot_set_card_blue'))
  947. .width('32%')
  948. .height('50%')
  949. .borderRadius($r('app.float.robot_set_radius'))
  950. .backgroundColor($r('app.color.robot_set_coord_card_grey'))
  951. .onClick(() => {
  952. this.controller.close()
  953. this.cancel()
  954. })
  955. Row()
  956. .width('2.5%')
  957. Button('确认')
  958. .fontSize($r('app.float.robot_set_font_size'))
  959. .fontWeight(FontWeight.Medium)
  960. .fontColor($r('app.color.general_font_white_color'))
  961. .width('32%')
  962. .height('50%')
  963. .borderRadius($r('app.float.robot_set_radius'))
  964. .backgroundColor($r('app.color.robot_set_card_blue'))
  965. .onClick(() => {
  966. if (this.controller != undefined) {
  967. this.currentStorage.xSize = this.x
  968. this.currentStorage.ySize = this.y
  969. StorageModel.updateStorage(this.currentStorage.id, this.currentStorage.storageName, this.currentStorage.xSize, this.currentStorage.ySize, this.currentStorage.defaultLayer)
  970. this.controller.close()
  971. this.confirm()
  972. }
  973. })
  974. }
  975. .justifyContent(FlexAlign.Center)
  976. .height('24%')
  977. .width('100%')
  978. }
  979. .width('48%')
  980. .height('62%')
  981. .backgroundColor($r('app.color.page_general_background'))
  982. .justifyContent(FlexAlign.SpaceEvenly)
  983. .borderRadius($r('app.float.general_border_radius'))
  984. }
  985. }
  986. // 编辑仓储默认层数弹窗
  987. @CustomDialog
  988. struct EditDefaultLayerDialog {
  989. @Link currentStorage: StorageInfo
  990. private layerArray: string[] = []
  991. // 选择的容量
  992. private selectLayer: string
  993. controller?: CustomDialogController
  994. cancel: () => void = () => {}
  995. confirm: () => void = () => {}
  996. aboutToAppear() {
  997. for (let index = 1; index <= 20; index++) {
  998. this.layerArray.push(index.toString());
  999. }
  1000. this.selectLayer = this.currentStorage.defaultLayer.toString()
  1001. }
  1002. build() {
  1003. Column() {
  1004. Row() {
  1005. Text('层数设置')
  1006. .fontSize($r('app.float.title_font_size'))
  1007. .fontWeight(FontWeight.Medium)
  1008. .fontColor($r('app.color.general_font_color'))
  1009. .opacity($r('app.float.general_font_opacity'))
  1010. }
  1011. .height('16%')
  1012. .alignItems(VerticalAlign.Center)
  1013. Row() {
  1014. TextPicker({ range: this.layerArray, selected: this.currentStorage && this.currentStorage.defaultLayer > 0 ? this.currentStorage.defaultLayer - 1 : 0})
  1015. .onChange((value: string) => {
  1016. this.selectLayer = value
  1017. })
  1018. .width('80%')
  1019. .backgroundColor($r('app.color.bottom_bar_background'))
  1020. .borderImage({source:$r('app.media.text_picker_frame'), fill:true})
  1021. }
  1022. .width('100%')
  1023. .layoutWeight(1)
  1024. .justifyContent(FlexAlign.Center)
  1025. Row() {
  1026. Button('取消')
  1027. .fontSize($r('app.float.robot_set_font_size'))
  1028. .fontWeight(FontWeight.Medium)
  1029. .fontColor($r('app.color.robot_set_card_blue'))
  1030. .width('32%')
  1031. .height('50%')
  1032. .borderRadius($r('app.float.robot_set_radius'))
  1033. .backgroundColor($r('app.color.robot_set_coord_card_grey'))
  1034. .onClick(() => {
  1035. this.controller.close()
  1036. this.cancel()
  1037. })
  1038. Row()
  1039. .width('2.5%')
  1040. Button('确认')
  1041. .fontSize($r('app.float.robot_set_font_size'))
  1042. .fontWeight(FontWeight.Medium)
  1043. .fontColor($r('app.color.general_font_white_color'))
  1044. .width('32%')
  1045. .height('50%')
  1046. .borderRadius($r('app.float.robot_set_radius'))
  1047. .backgroundColor($r('app.color.robot_set_card_blue'))
  1048. .onClick(() => {
  1049. if (this.controller != undefined) {
  1050. this.controller.close()
  1051. this.currentStorage.defaultLayer = Number.parseInt(this.selectLayer)
  1052. StorageModel.updateStorage(this.currentStorage.id, this.currentStorage.storageName, this.currentStorage.xSize, this.currentStorage.ySize, this.currentStorage.defaultLayer)
  1053. }
  1054. })
  1055. }
  1056. .justifyContent(FlexAlign.Center)
  1057. .height('20%')
  1058. .width('100%')
  1059. }
  1060. .width('48%')
  1061. .height('62%')
  1062. .backgroundColor($r('app.color.page_general_background'))
  1063. .justifyContent(FlexAlign.SpaceEvenly)
  1064. .borderRadius($r('app.float.general_border_radius'))
  1065. }
  1066. }
  1067. // 获取当前储位的仓储类型字符串
  1068. function getStorageTypeStr(storageType: string, typeArray: string[]): string {
  1069. if (!storageType || storageType.length === 0) {
  1070. return ''
  1071. }
  1072. let typeStr: string = ''
  1073. let types : string[] = storageType.split(',')
  1074. console.log('testTag', '------------'+JSON.stringify(types));
  1075. for (const type of types) {
  1076. typeStr += typeArray[Number.parseInt(type)-1] + ','
  1077. }
  1078. if (typeStr.length > 0) {
  1079. typeStr = typeStr.slice(0, -1);
  1080. }
  1081. return typeStr
  1082. }
  1083. // 获取当前储位的停靠点类型字符串
  1084. function getParkTypeStr(parkType: number, typeArray: string[]): string {
  1085. if (!parkType || parkType === 0) {
  1086. return ''
  1087. }
  1088. return typeArray[parkType - 1]
  1089. }