This commit is contained in:
2026-08-14 14:27:03 +08:00
parent 724848feb6
commit a81af4a664
64 changed files with 961 additions and 176 deletions
@@ -1,6 +1,19 @@
import { readFileSync } from 'node:fs'
import { resolve } from 'node:path'
import { describe, expect, it } from 'vitest'
import type { PlatformTenantResource } from '@/modules/iam'
import { loadAllActiveCustomers } from '../task-list'
function activeCustomer(id: string, tenantName: string, legalName: string | null, tenantCode: string): PlatformTenantResource {
return {
id, tenantName, legalName, tenantCode, status: 'ACTIVE', legalRepresentative: null,
unifiedSocialCreditCode: null, contactName: null, contactPhone: null, contactEmail: null,
servicePackage: null, contactWechat: null, salesOwnerName: null, paymentTermDays: null,
enterpriseType: null, establishedDate: null, registeredCapital: null,
registeredCapitalCurrency: null, registeredAddress: null, internalRemark: null,
createdAt: null, approvedAt: null,
}
}
describe('InboundTaskList measurement scope', () => {
it('uses the inbound tenant isolation key for measurement and review requests', () => {
@@ -10,6 +23,42 @@ describe('InboundTaskList measurement scope', () => {
expect(source).not.toContain('selectedInbound.customerId || selectedInbound.tenantId')
})
it('loads only active customers and exposes a searchable name-only select', () => {
const source = readFileSync(resolve('src/modules/inbounds/components/InboundTaskList.vue'), 'utf8')
const queryFieldsSource = source.slice(source.indexOf('const queryFields'), source.indexOf('const columns'))
expect(source).toContain('loadAllActiveCustomers')
expect(queryFieldsSource).toContain("type: 'select'")
expect(queryFieldsSource).toContain('filterable: true')
expect(queryFieldsSource).toContain('label: customer.legalName?.trim() || customer.tenantName')
expect(queryFieldsSource).not.toContain('tenantCode')
expect(queryFieldsSource).not.toContain('客户编码')
})
it('requests every active-customer page and merges name-only options', async () => {
const calls: Array<{ page: number; size: number; status: 'ACTIVE' }> = []
const records = await loadAllActiveCustomers(async (query) => {
calls.push(query)
if (query.page === 1) {
return {
pages: 2,
records: [activeCustomer('10001', '客户一', '客户一有限公司', 'CUS-001')],
}
}
return {
pages: 2,
records: [activeCustomer('10002', '客户二', null, 'CUS-002')],
}
})
expect(calls).toEqual([
{ page: 1, size: 200, status: 'ACTIVE' },
{ page: 2, size: 200, status: 'ACTIVE' },
])
expect(records.map((customer) => customer.legalName?.trim() || customer.tenantName)).toEqual(['客户一有限公司', '客户二'])
expect(records.map((customer) => customer.legalName?.trim() || customer.tenantName).join(' ')).not.toContain('CUS-')
})
it('opens the shared unified order detail from the view action', () => {
const source = readFileSync(resolve('src/modules/inbounds/components/InboundTaskList.vue'), 'utf8')
@@ -17,7 +17,7 @@ import type { InboundOrderSummary } from '../core/types'
import InboundMeasurementPanel from '../measurement/InboundMeasurementPanel.vue'
import MeasurementReviewPanel from '../review/MeasurementReviewPanel.vue'
import { inboundProcessStatusLabels, inboundReviewStatusLabels, inboundStatusLabel } from '../status'
import { buildInboundTaskQuery, type InboundTaskMode } from '../task-list'
import { buildInboundTaskQuery, loadAllActiveCustomers, type InboundTaskMode } from '../task-list'
type FilterModel = QueryModel & {
customerId: string
@@ -43,6 +43,7 @@ const warehouseOptions = ref<Array<{ label: string; value: string }>>([])
const selectedInbound = ref<InboundOrderSummary | null>(null)
const taskDialogOpen = ref(false)
let requestSerial = 0
let optionsRequestSerial = 0
let disposed = false
let activatedOnce = false
@@ -109,14 +110,15 @@ function dateParam(value: string | undefined, end = false) {
}
async function loadOptions() {
const serial = ++optionsRequestSerial
customerLoadError.value = null
try {
const [customerPage, warehousePage] = await Promise.all([
listPlatformTenants({ page: 1, size: 200, status: 'ACTIVE' }),
const [customerRecords, warehousePage] = await Promise.all([
loadAllActiveCustomers((query) => listPlatformTenants(query)),
listPlatformWarehouses(1, 200),
])
if (disposed) return
customers.value = customerPage.records
if (disposed || serial !== optionsRequestSerial) return
customers.value = customerRecords
warehouseOptions.value = warehousePage.records.map((warehouse) => ({
label: `${warehouse.warehouseName} · ${warehouse.warehouseCode}`,
value: String(warehouse.id),
@@ -190,7 +192,7 @@ onActivated(() => {
}
void loadTasks()
})
onBeforeUnmount(() => { disposed = true; requestSerial += 1 })
onBeforeUnmount(() => { disposed = true; requestSerial += 1; optionsRequestSerial += 1 })
</script>
<template>
@@ -241,7 +241,7 @@ onBeforeUnmount(() => {
<div class="inbound-operation-dialog__footer">
<el-button :disabled="Boolean(reviewPanelRef?.actionLoading)" @click="reviewDialogOpen = false">取消</el-button>
<el-button v-if="reviewPanelRef?.isPending && reviewPanelRef?.canReview" type="danger" plain :loading="reviewPanelRef?.actionLoading === 'reject'" @click="reviewPanelRef?.openReasonDialog('reject')">驳回</el-button>
<el-button v-if="reviewPanelRef?.isPending && reviewPanelRef?.canReview" type="primary" :loading="reviewPanelRef?.actionLoading === 'approve'" @click="reviewPanelRef?.confirmApprove()">通过并完成入库</el-button>
<el-button v-if="reviewPanelRef?.isPending && reviewPanelRef?.canReview" type="primary" :loading="reviewPanelRef?.actionLoading === 'approve'" @click="reviewPanelRef?.confirmApprove()">通过并进入待分柜</el-button>
<el-button v-if="reviewPanelRef?.isRejected && reviewPanelRef?.canRelease" type="warning" plain :loading="reviewPanelRef?.actionLoading === 'release'" @click="reviewPanelRef?.openReasonDialog('release')">异常放行</el-button>
</div>
</template>