优化
This commit is contained in:
@@ -74,9 +74,10 @@ describe('OutboundDispatchesView', () => {
|
||||
|
||||
it('loads only active customer names for the filter', () => {
|
||||
const source = readFileSync(resolve(process.cwd(), 'src/modules/outbound-dispatch/pages/OutboundDispatchesView.vue'), 'utf8')
|
||||
expect(source).toContain("listPlatformTenants({ page: 1, size: 200, status: 'ACTIVE' })")
|
||||
expect(source).toContain("records.filter((customer) => customer.status === 'ACTIVE')")
|
||||
expect(source).toContain("item.legalName?.trim() || item.tenantName")
|
||||
expect(source).toContain("listPlatformTenants({ page: currentPage, size: 200, status: 'ACTIVE' })")
|
||||
expect(source).toContain("result.records.filter((customer) => customer.status === 'ACTIVE')")
|
||||
expect(source).toContain('while (currentPage <= pages)')
|
||||
expect(source).toContain("item.tenantName")
|
||||
expect(source).not.toContain('item.tenantCode')
|
||||
})
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ let detailRequestId = 0
|
||||
let disposed = false
|
||||
|
||||
const fields = computed<QueryField[]>(() => [
|
||||
{ key: 'customerId', type: 'select', label: '客户', width: 240, placeholder: '全部客户', options: customers.value.map((item) => ({ label: item.legalName?.trim() || item.tenantName, value: String(item.id) })), props: { filterable: true, loading: optionsLoading.value } },
|
||||
{ key: 'customerId', type: 'select', label: '客户', width: 240, placeholder: '全部客户', options: customers.value.map((item) => ({ label: item.tenantName, value: String(item.id) })), props: { filterable: true, loading: optionsLoading.value } },
|
||||
{ key: 'orderId', type: 'select', label: '订单 / 入库单', width: 280, placeholder: filters.value.customerId ? '请选择该客户的订单' : '请选择订单或入库单', options: orders.value.map((item) => ({ label: `${item.orderNo || item.orderId} / ${item.inboundCode || item.inboundId || '未入库'}`, value: String(item.orderId), disabled: item.inboundId == null })), props: { filterable: true, loading: optionsLoading.value } },
|
||||
{ key: 'containerBookingId', type: 'select', label: '柜次', width: 240, placeholder: '请选择柜号或集装箱号', options: containers.value.map((item) => ({ label: `${item.cabinetNo || item.bookingNo}${item.containerNo ? ` / ${item.containerNo}` : ''}`, value: item.id })), props: { filterable: true, loading: optionsLoading.value } },
|
||||
])
|
||||
@@ -115,12 +115,12 @@ async function loadOptions(customerId = filters.value.customerId) {
|
||||
optionsLoading.value = true
|
||||
optionsError.value = ''
|
||||
const results = await Promise.allSettled([
|
||||
listPlatformTenants({ page: 1, size: 200, status: 'ACTIVE' }),
|
||||
loadActiveCustomers(),
|
||||
listPlatformUnifiedOrders({ customerId: customerId || undefined, page: 1, size: 200 }),
|
||||
listContainers({ page: 1, size: 200 }),
|
||||
])
|
||||
if (disposed || requestId !== optionRequestId) return
|
||||
if (results[0].status === 'fulfilled') customers.value = results[0].value.records.filter((customer) => customer.status === 'ACTIVE')
|
||||
if (results[0].status === 'fulfilled') customers.value = results[0].value
|
||||
if (results[1].status === 'fulfilled') orders.value = results[1].value.records
|
||||
if (results[2].status === 'fulfilled') containers.value = results[2].value.records
|
||||
const failed = ['客户', '订单', '柜次'].filter((_, index) => results[index]?.status === 'rejected')
|
||||
@@ -128,6 +128,19 @@ async function loadOptions(customerId = filters.value.customerId) {
|
||||
optionsLoading.value = false
|
||||
}
|
||||
|
||||
async function loadActiveCustomers() {
|
||||
const records: PlatformTenantResource[] = []
|
||||
let currentPage = 1
|
||||
let pages = 1
|
||||
do {
|
||||
const result = await listPlatformTenants({ page: currentPage, size: 200, status: 'ACTIVE' })
|
||||
records.push(...result.records.filter((customer) => customer.status === 'ACTIVE'))
|
||||
pages = Math.max(1, result.pages)
|
||||
currentPage += 1
|
||||
} while (currentPage <= pages)
|
||||
return records
|
||||
}
|
||||
|
||||
watch(() => filters.value.customerId, (customerId, previous) => {
|
||||
if (customerId === previous) return
|
||||
filters.value = { ...filters.value, orderId: '' }
|
||||
|
||||
Reference in New Issue
Block a user