This commit is contained in:
2026-10-20 15:48:27 +08:00
parent 489b1bcd16
commit db32f31cc2
67 changed files with 1262 additions and 71 deletions
@@ -15,6 +15,7 @@ import {
import { listAllPlatformWarehouses, type PlatformWarehouseResource } from '../../../warehouses/api/platformWarehouses'
import QueryToolbar, { type QueryField, type QueryModel } from '@/shared/components/QueryToolbar.vue'
import DataTable from '@/shared/components/DataTable.vue'
import LayoutPreferenceList from '@/shared/components/LayoutPreferenceList.vue'
import LocationsView from './LocationsView.vue'
const locationsSource = readFileSync(resolve(process.cwd(), 'src/modules/warehouse-resources/locations/pages/LocationsView.vue'), 'utf8')
@@ -179,6 +180,27 @@ describe('LocationsView', () => {
vi.mocked(createPlatformLocation).mockReset()
})
it('renders missing maximum weights as a dash and preserves zero and populated weights', async () => {
const missingWeight = { ...availableLocation }
Reflect.deleteProperty(missingWeight, 'maxWeightKg')
const records = [missingWeight, ...[null, '', 0, 2000, '10000.125'].map((maxWeightKg, index) => ({
...availableLocation, id: `weight-${index}`, locationCode: `WEIGHT-${index}`, maxWeightKg,
}))]
vi.mocked(listPlatformLocations).mockResolvedValue({ records, page: 1, size: 20, total: records.length, pages: 1 })
const wrapper = await mountView()
await wrapper.get('button[aria-label="列设置"]').trigger('click')
await flushPromises()
const preferences = wrapper.findComponent(DataTable).findComponent(LayoutPreferenceList)
preferences.vm.$emit('visibility', 'maxWeightKg', true)
await flushPromises()
const column = wrapper.findAll('thead th').findIndex(header => header.text().includes('最大承重'))
expect(column).toBeGreaterThan(-1)
expect(wrapper.findAll('tbody tr').map(row => row.findAll('td')[column]!.text())).toEqual([
'—', '—', '—', '0 kg', '2,000 kg', '10,000.125 kg',
])
expect(wrapper.text()).not.toContain('undefined kg')
})
it('loads only domestic warehouse candidates for querying and writes', async () => {
const wrapper = await mountView()
const toolbar = wrapper.findComponent(QueryToolbar)
@@ -188,8 +188,8 @@ function optionalText(value: string) {
return value.trim() || null
}
function formatWeight(value: number | string | null) {
if (value === null || value === '') return '—'
function formatWeight(value: number | string | null | undefined) {
if (value == null || value === '') return '—'
const numeric = Number(value)
return Number.isFinite(numeric) ? `${numeric.toLocaleString('zh-CN', { maximumFractionDigits: 3 })} kg` : `${value} kg`
}