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
@@ -117,7 +117,7 @@ describe('PalletsView', () => {
vi.mocked(createPlatformPallet).mockReset().mockResolvedValue('20002')
})
it('starts with all warehouse candidates for querying using compact filters', async () => {
it('starts with enabled domestic warehouse candidates for querying using compact filters', async () => {
const wrapper = await mountView()
const toolbar = wrapper.findComponent(QueryToolbar)
const fields = toolbar.props('fields')
@@ -132,8 +132,6 @@ describe('PalletsView', () => {
expect(fields.find((field) => field.key === 'warehouseId')?.placeholder).toBe('全部仓库')
expect(fields.find((field) => field.key === 'warehouseId')?.options).toEqual([
{ label: '义乌收货仓(CN-YW-01)', value: '19001' },
{ label: 'ONT8 FBA 仓(FBA-ONT8)', value: '19002' },
{ label: '洛杉矶海外仓(US-LAX-01)', value: '19003' },
])
expect(listAllPlatformWarehouses).toHaveBeenCalledWith()
expect(listPlatformPallets).toHaveBeenCalledWith({
@@ -205,8 +203,6 @@ describe('PalletsView', () => {
expect(listAllPlatformWarehouses).toHaveBeenCalledTimes(1)
expect(warehouseField?.options).toEqual([
{ label: '义乌收货仓(CN-YW-01)', value: '19001' },
{ label: 'ONT8 FBA 仓(FBA-ONT8)', value: '19002' },
{ label: '洛杉矶海外仓(US-LAX-01)', value: '19003' },
])
})
@@ -256,7 +252,7 @@ describe('PalletsView', () => {
await saveButton?.trigger('click')
await flushPromises()
expect(createPlatformPallet).toHaveBeenCalledWith(0, {
expect(createPlatformPallet).toHaveBeenCalledWith({
warehouseId: 19001, palletType: '塑料托盘', capacityCbm: 1.5, weightKg: 10, color: '黑色', remark: '标准托盘',
})
})
@@ -322,7 +318,7 @@ describe('PalletsView', () => {
await viewButton?.trigger('click')
await flushPromises()
expect(getPlatformPallet).toHaveBeenCalledWith(0, 19001, '20001')
expect(getPlatformPallet).toHaveBeenCalledWith(19001, '20001')
expect(document.body.textContent).toContain('资源作用域')
expect(document.body.textContent).toContain('平台公共资源')
expect(document.body.textContent).not.toContain('所属企业')
@@ -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()