|
@@ -6,6 +6,7 @@ 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
|
|
@@ -95,7 +96,7 @@ export struct StorageSetView {
|
|
|
builder: EditStorageSizeDialog({
|
|
|
currentStorage: $currentStorage,
|
|
|
confirm: ()=> {
|
|
|
- this.updateStorageSpaceData()
|
|
|
+ this.updateStorageSpaceData(true)
|
|
|
}
|
|
|
}),
|
|
|
autoCancel: true,
|
|
@@ -118,26 +119,30 @@ export struct StorageSetView {
|
|
|
async aboutToAppear() {
|
|
|
// 查询后台数据库的线边库
|
|
|
let config: StorageConfig = await JGRequest.get("/api/v1/wms/position/houseConfigInfo/" + 1, {})
|
|
|
- if (!config) {
|
|
|
- return
|
|
|
- }
|
|
|
+
|
|
|
// 查询本地数据库,没有则添加数据(仓储和储位数据)
|
|
|
this.storages = await StorageModel.getStorageList()
|
|
|
- if (!this.storages || this.storages.length <= 0) {
|
|
|
+ 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.yNum; x++) {
|
|
|
- await StorageSpaceModel.addStorageSpace(storageId, x, y, 1, '', config.layer, 1, 2)
|
|
|
+ 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) {
|
|
|
+ } 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()
|
|
|
+ this.updateStorageSpaceData(false)
|
|
|
}
|
|
|
// 渲染封装数据
|
|
|
this.currentStorage = this.storages[0]
|
|
@@ -182,7 +187,14 @@ export struct StorageSetView {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- updateStorageSpaceData() {
|
|
|
+ /*
|
|
|
+ * updateArray
|
|
|
+ * */
|
|
|
+ /**
|
|
|
+ * 更新本地数据库的仓储储位
|
|
|
+ * @param updateArray 是否更新spaceArray(aboutToAppear调用时不更新)
|
|
|
+ */
|
|
|
+ async updateStorageSpaceData(updateArray: boolean) {
|
|
|
this.spaceArray = []
|
|
|
this.stateArray = []
|
|
|
let y = 1
|
|
@@ -202,14 +214,16 @@ export struct StorageSetView {
|
|
|
this.yNum.push(index)
|
|
|
y++
|
|
|
}
|
|
|
- StorageSpaceModel.initDataByStorage(this.currentStorage)
|
|
|
- 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
|
|
|
+ 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() {
|
|
@@ -1138,19 +1152,4 @@ function getParkTypeStr(parkType: number, typeArray: string[]): string {
|
|
|
return ''
|
|
|
}
|
|
|
return typeArray[parkType - 1]
|
|
|
-}
|
|
|
-
|
|
|
-class StorageConfig {
|
|
|
- // 干燥柜及货架区域
|
|
|
- area?: number;
|
|
|
- // 仓库名称
|
|
|
- houseName?: string
|
|
|
- // 储位类型 1 线边仓 2 干燥柜 3 货架
|
|
|
- houseType: string
|
|
|
- // 使用层数
|
|
|
- layer?: number;
|
|
|
- // x尺寸
|
|
|
- xNum?: number;
|
|
|
- // y尺寸
|
|
|
- yNum?: number;
|
|
|
}
|