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
@@ -50,7 +50,7 @@ const queryFields = computed<QueryField[]>(() => [
type: 'select',
width: 300,
placeholder: warehouseLoading.value ? '正在加载所属仓库' : warehouseError.value ? '所属仓库加载失败' : '全部仓库',
options: warehouses.value.map((warehouse) => ({
options: domesticWarehouses.value.map((warehouse) => ({
label: `${warehouse.warehouseName}(${warehouse.warehouseCode})`,
value: String(warehouse.id),
})),
@@ -71,7 +71,7 @@ const queryFields = computed<QueryField[]>(() => [
},
])
const emptyForm = () => ({ id: '', customerId: '', warehouseId: '', palletCode: '', palletType: '', capacityCbm: null as number | null, weightKg: null as number | null, color: '', remark: '' })
const emptyForm = () => ({ id: '', warehouseId: '', palletCode: '', palletType: '', capacityCbm: null as number | null, weightKg: null as number | null, color: '', remark: '' })
const form = reactive(emptyForm())
const rules: FormRules<typeof form> = {
warehouseId: [{ required: true, message: '请选择国内仓', trigger: 'change' }],
@@ -226,7 +226,6 @@ function resetFilters() {
function openCreate() {
Object.assign(form, emptyForm())
form.warehouseId = isActiveDomesticWarehouse(filters.value.warehouseId) ? filters.value.warehouseId : ''
form.customerId = editorWarehouse.value ? String(editorWarehouse.value.tenantId) : ''
editorOpen.value = true
captureBaseline()
void formRef.value?.clearValidate()
@@ -235,7 +234,6 @@ function openCreate() {
function assignForm(resource: PlatformPalletResource) {
Object.assign(form, {
id: String(resource.id),
customerId: String(resource.tenantId),
warehouseId: String(resource.warehouseId),
palletCode: resource.palletCode,
palletType: resource.palletType,
@@ -250,7 +248,7 @@ function assignForm(resource: PlatformPalletResource) {
}
async function fetchDetail(row: PlatformPalletResource) {
return getPlatformPallet(apiId(String(row.tenantId)), apiId(String(row.warehouseId)), row.id)
return getPlatformPallet(apiId(String(row.warehouseId)), row.id)
}
async function openDetail(row: PlatformPalletResource) {
@@ -289,20 +287,18 @@ async function savePallet() {
ElMessage.error(form.id ? '托盘仅支持归属国内仓' : '新增托盘仅支持选择启用的国内仓')
return
}
form.customerId = String(warehouse.tenantId)
saving.value = true
const payload: SavePlatformPalletRequest = {
warehouseId: apiId(form.warehouseId),
palletType: form.palletType.trim(),
capacityCbm: form.capacityCbm,
weightKg: form.weightKg,
color: form.color.trim() || null,
color: form.color.trim(),
remark: form.remark.trim() || null,
}
try {
const customerId = apiId(form.customerId)
if (form.id) await updatePlatformPallet(customerId, apiId(form.warehouseId), form.id, payload)
else await createPlatformPallet(customerId, payload)
if (form.id) await updatePlatformPallet(apiId(form.warehouseId), form.id, payload)
else await createPlatformPallet(payload)
ElMessage.success(form.id ? '托盘已更新' : '托盘已新增')
editorOpen.value = false
await loadPallets()
@@ -326,7 +322,7 @@ async function removePallet(row: PlatformPalletResource) {
const id = String(row.id)
deletingIds.value = new Set([...deletingIds.value, id])
try {
await deletePlatformPallet(apiId(String(row.tenantId)), apiId(String(row.warehouseId)), row.id)
await deletePlatformPallet(apiId(String(row.warehouseId)), row.id)
ElMessage.success('托盘已删除')
if (rows.value.length === 1 && page.value > 1) page.value -= 1
else await loadPallets()