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
@@ -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>