This commit is contained in:
2026-08-06 15:32:02 +08:00
parent 9e7e1afac8
commit 33a0c48b78
22 changed files with 685 additions and 402 deletions
@@ -105,7 +105,6 @@ const queryFields = computed<QueryField[]>(() => [
const emptyForm = () => ({
id: '',
customerId: '',
warehouseId: '',
zoneCode: '',
zoneName: '',
@@ -236,11 +235,11 @@ function requireCreateScope() {
ElMessage.warning('请选择国内仓')
return null
}
return { customerId: apiId(String(selectedWarehouse.value.tenantId)), warehouseId: apiId(form.warehouseId) }
return { warehouseId: apiId(form.warehouseId) }
}
function recordScope(row: PlatformLocationResource) {
return { customerId: apiId(String(row.tenantId)), warehouseId: apiId(String(row.warehouseId)) }
return { warehouseId: apiId(String(row.warehouseId)) }
}
async function loadWarehouses() {
@@ -249,9 +248,11 @@ async function loadWarehouses() {
warehouseError.value = null
warehouses.value = []
try {
const records = await listAllPlatformWarehouses()
// 库位只属于国内仓,查询候选仓库时直接限制仓库类型,避免把 FBA/海外仓带入页面。
const records = await listAllPlatformWarehouses({ warehouseType: 'DOMESTIC' })
if (sequence !== warehouseLoadSequence) return
warehouses.value = records
// 保留前端兜底过滤,避免旧接口或异常响应返回其他仓库类型。
warehouses.value = records.filter((warehouse) => warehouse.warehouseType === 'DOMESTIC')
} catch (error) {
if (sequence !== warehouseLoadSequence) return
warehouseError.value = getApiErrorDetails(error, '仓库列表加载失败,请稍后重试')
@@ -303,7 +304,6 @@ function applyFilters(model: QueryModel) {
function assignForm(resource: PlatformLocationResource) {
Object.assign(form, {
id: String(resource.id),
customerId: String(resource.tenantId),
warehouseId: String(resource.warehouseId),
zoneCode: resource.zoneCode,
zoneName: resource.zoneName,
@@ -320,7 +320,6 @@ function assignForm(resource: PlatformLocationResource) {
function openCreate() {
Object.assign(form, emptyForm())
form.warehouseId = isActiveDomesticWarehouse(selectedWarehouseId.value) ? selectedWarehouseId.value : ''
form.customerId = selectedWarehouse.value ? String(selectedWarehouse.value.tenantId) : ''
form.status = selectedWarehouse.value?.status === 'INACTIVE' ? 'DISABLED' : 'AVAILABLE'
detail.value = null
drawerError.value = null
@@ -342,7 +341,7 @@ async function loadDetail(row: PlatformLocationResource, mode: 'view' | 'edit')
drawerError.value = null
detail.value = null
try {
const result = await getPlatformLocation(scope.customerId, scope.warehouseId, row.id)
const result = await getPlatformLocation(scope.warehouseId, row.id)
detail.value = result
if (mode === 'edit') {
assignForm(result.location)
@@ -381,15 +380,13 @@ async function saveLocation() {
ElMessage.error(form.id ? '库位仅支持归属国内仓' : '新增库位仅支持选择启用的国内仓')
return
}
const scope = form.id
? { customerId: apiId(form.customerId), warehouseId: apiId(form.warehouseId) }
: requireCreateScope()
const scope = form.id ? { warehouseId: apiId(form.warehouseId) } : requireCreateScope()
if (!scope) return
saving.value = true
try {
const payload = buildPayload()
if (form.id) await updatePlatformLocation(scope.customerId, scope.warehouseId, form.id, payload)
else await createPlatformLocation(scope.customerId, payload)
if (form.id) await updatePlatformLocation(scope.warehouseId, form.id, payload)
else await createPlatformLocation(payload)
drawerOpen.value = false
ElMessage.success(form.id ? '库位资料已更新' : '库位已创建')
await loadLocations()
@@ -426,7 +423,7 @@ async function toggleStatus(row: PlatformLocationResource) {
}
setActionLoading(row.id, true)
try {
await changePlatformLocationStatus(scope.customerId, scope.warehouseId, row.id, nextStatus, row.version)
await changePlatformLocationStatus(scope.warehouseId, row.id, nextStatus, row.version)
ElMessage.success(`库位 ${row.locationCode} 已${action}`)
await loadLocations()
} catch (error) {
@@ -451,7 +448,7 @@ async function removeLocation(row: PlatformLocationResource) {
}
setActionLoading(row.id, true)
try {
await deletePlatformLocation(scope.customerId, scope.warehouseId, row.id, row.version)
await deletePlatformLocation(scope.warehouseId, row.id, row.version)
ElMessage.success(`库位 ${row.locationCode} 已删除`)
await loadLocations()
} catch (error) {
@@ -480,7 +477,6 @@ watch([page, pageSize], () => { void loadLocations() })
watch(() => form.warehouseId, (warehouseId) => {
if (drawerMode.value !== 'create') return
const warehouse = warehouses.value.find((item) => String(item.id) === warehouseId)
form.customerId = warehouse ? String(warehouse.tenantId) : ''
form.status = warehouse?.status === 'INACTIVE' ? 'DISABLED' : 'AVAILABLE'
})