fix(admin): remove warehouse selector from loading lists

This commit is contained in:
2026-08-10 18:07:33 +08:00
parent 1595fbcae2
commit b593d72222
5 changed files with 27 additions and 38 deletions
@@ -72,6 +72,16 @@ describe('GlobalSmartLoadingView', () => {
expect(wrapper.text()).not.toContain('美森正班')
})
it('prefers an editable container on first load so pushed plans do not show a false editing error', async () => {
const pushed = { ...container, id: '9007199254740995', planStatus: 'LOADING' as const }
vi.mocked(listContainers).mockResolvedValue({ records: [pushed, container], page: 1, size: 100, total: 2, pages: 1 })
const wrapper = mount(GlobalSmartLoadingView, { global: { plugins: [ElementPlus] } })
await flushPromises()
expect(getSmartLoadingPlanByBooking).toHaveBeenCalledWith(container.id)
expect(wrapper.text()).toContain('CB-1 装柜方案')
})
it('refreshes the latest plan after A0409 without losing the selected container', async () => {
const wrapper = mount(GlobalSmartLoadingView, { global: { plugins: [ElementPlus] } })
await flushPromises()
@@ -99,6 +99,12 @@ const filteredCandidates = computed(() => {
.some((value) => String(value || '').toLowerCase().includes(keyword)))
})
function preferredContainerId() {
const visible = filteredContainers.value
if (String(appliedQuery.value.status || '').trim()) return visible[0]?.id || ''
return visible.find((item) => item.planStatus === 'EDITING')?.id || visible[0]?.id || ''
}
const candidateColumns: DataTableColumn[] = [
{ key: 'actions', label: '操作', width: 92, fixed: 'left', slotName: 'actions' },
{ key: 'order', label: '订单/入库单', minWidth: 170, slotName: 'order' },
@@ -192,7 +198,7 @@ async function load() {
? await Promise.all(Array.from({ length: firstPage.pages - 1 }, (_, index) => listContainers({ page: index + 2, size: 100 })))
: []
containers.value = [firstPage, ...remainingPages].flatMap((page) => page.records)
if (!filteredContainers.value.some((item) => item.id === selectedContainerId.value)) selectedContainerId.value = filteredContainers.value[0]?.id || ''
if (!filteredContainers.value.some((item) => item.id === selectedContainerId.value)) selectedContainerId.value = preferredContainerId()
await loadSelectedData()
} catch (error) {
loadError.value = getApiErrorDetails(error, '智能装柜工作台加载失败')
@@ -209,7 +215,7 @@ async function selectContainer(containerId: string) {
async function applyFilters(model: QueryModel) {
appliedQuery.value = { ...model }
if (!filteredContainers.value.some((item) => item.id === selectedContainerId.value)) {
selectedContainerId.value = filteredContainers.value[0]?.id || ''
selectedContainerId.value = preferredContainerId()
await loadSelectedData()
}
}
@@ -317,7 +323,6 @@ onMounted(load)
preference-key="global-smart-loading-query"
:search-on-reset="false"
@search="applyFilters"
@reset="applyFilters"
/>
<LoadErrorState v-if="loadError" title="智能装柜工作台加载失败" :message="loadError.message" :loading="loading" @retry="load">
@@ -13,9 +13,12 @@ describe('LoadingListsView', () => {
expect(source.indexOf("key: 'actions'", source.indexOf("key: 'actions'") + 1)).toBeLessThan(source.indexOf("key: 'loadingListNo'"))
})
it('queries all warehouses when the warehouse filter is empty', () => {
expect(source).toContain("placeholder: loadingWarehouses.value ? '仓库加载中' : '全部仓库'")
expect(source).toContain('warehouseId: warehouseId || undefined')
it('queries all warehouses without exposing a warehouse selector', () => {
expect(source).not.toContain('listAllPlatformWarehouses')
expect(source).not.toContain("key: 'warehouseId'")
expect(source).not.toContain('loadingWarehouses')
expect(source).not.toContain('warehouseId: warehouseId || undefined')
expect(source).toContain("selectedWarehouseId.value = String(row.warehouseId || '')")
expect(source).not.toContain("ElMessage.warning('请先选择仓库')")
expect(source).not.toContain("'请先选择仓库后查询'")
})
@@ -3,7 +3,6 @@ import { computed, onMounted, reactive, ref, watch } from 'vue'
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
import { Eye } from '@lucide/vue'
import { useAccessPreviewStore } from '@/core/access/accessPreview'
import { listAllPlatformWarehouses } from '@/modules/warehouses'
import { getApiErrorDetails, type ApiErrorDetails } from '@/shared/api/http'
import AdminPage from '@/shared/components/AdminPage.vue'
import ApiErrorMeta from '@/shared/components/ApiErrorMeta.vue'
@@ -31,14 +30,12 @@ import {
const props = defineProps<{ mode: LoadingListMode }>()
const access = useAccessPreviewStore()
const rows = ref<LoadingListSummary[]>([])
const warehouses = ref<Array<{ id: string; name: string }>>([])
const loadingWarehouses = ref(false)
const loading = ref(false)
const error = ref<ApiErrorDetails | null>(null)
const page = ref(1)
const pageSize = ref(20)
const total = ref(0)
const query = reactive<QueryModel>({ warehouseId: '', keyword: '', createdRange: [] })
const query = reactive<QueryModel>({ keyword: '', createdRange: [] })
const detailOpen = ref(false)
const detailLoading = ref(false)
const detailError = ref<ApiErrorDetails | null>(null)
@@ -59,11 +56,6 @@ const canList = computed(() => access.can(listPermission.value))
const canView = computed(() => access.can(viewPermission.value))
const canEdit = computed(() => isPreload.value && access.can('platform:firstleg:preload:edit'))
const fields = computed<QueryField[]>(() => [
{
key: 'warehouseId', type: 'select', label: '仓库', placeholder: loadingWarehouses.value ? '仓库加载中' : '全部仓库', width: 220,
options: warehouses.value.map((warehouse) => ({ label: warehouse.name, value: warehouse.id })),
props: { loading: loadingWarehouses.value, clearable: true, 'aria-label': '仓库' },
},
{ key: 'keyword', type: 'input', label: '关键词', placeholder: isPreload.value ? '预装单号/集装箱号/柜号' : '装柜清单号/集装箱号/柜号', width: 250 },
{ key: 'createdRange', type: 'daterange', label: '创建日期', width: 260 },
])
@@ -116,30 +108,16 @@ function formatNumber(value?: number | null, digits = 3) {
}
function toQuery(): LoadingListQuery {
const warehouseId = String(query.warehouseId || '').trim()
const range = Array.isArray(query.createdRange) ? query.createdRange.map(String) : []
return {
page: page.value,
size: pageSize.value,
warehouseId: warehouseId || undefined,
keyword: String(query.keyword || '').trim() || undefined,
createdFrom: range[0] ? `${range[0]}T00:00:00` : undefined,
createdTo: range[1] ? `${range[1]}T23:59:59` : undefined,
}
}
async function loadWarehouses() {
loadingWarehouses.value = true
try {
const result = await listAllPlatformWarehouses({ status: 'ACTIVE', warehouseType: 'DOMESTIC' })
warehouses.value = result.map((warehouse) => ({ id: String(warehouse.id), name: warehouse.warehouseName }))
} catch (cause) {
error.value = getApiErrorDetails(cause, '仓库列表加载失败,请刷新后重试')
} finally {
loadingWarehouses.value = false
}
}
async function load() {
if (!canList.value) return
const request = toQuery()
@@ -161,10 +139,6 @@ function search() {
else void load()
}
function reset() {
page.value = 1
void load()
}
async function loadDetail() {
if (!selectedPlanId.value || !selectedWarehouseId.value || !canView.value) return
@@ -184,7 +158,7 @@ async function loadDetail() {
function openDetail(rowValue: object) {
const row = rowValue as LoadingListSummary
selectedPlanId.value = String(row.planId)
selectedWarehouseId.value = String(row.warehouseId || query.warehouseId || '')
selectedWarehouseId.value = String(row.warehouseId || '')
detail.value = null
detailError.value = null
detailOpen.value = true
@@ -225,7 +199,6 @@ async function saveTransport() {
watch([page, pageSize], () => void load())
onMounted(() => {
void loadWarehouses()
void load()
})
</script>
@@ -241,9 +214,7 @@ onMounted(() => {
:fields="fields"
:available-fields="fields"
:preference-key="`loading-lists-${mode}-query`"
:search-on-reset="false"
@search="search"
@reset="reset"
/>
</template>
+1 -1
View File
@@ -7,7 +7,7 @@ export const loadingListRoutes = [
component: () => import('./pages/PreloadPlansView.vue'),
meta: {
title: '预装清单',
description: '按仓库查看装柜中的预装计划、货物明细和操作历史',
description: '查看全部仓库装柜中的预装计划、货物明细和操作历史',
permission: 'platform:firstleg:preload:list',
},
},