From 7ece30bffa0b7fd02ea9ead90b18e4efd25e0aa3 Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Tue, 11 Aug 2026 20:02:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/GlobalSmartLoadingView.test.ts | 15 ++++++++ .../pages/GlobalSmartLoadingView.vue | 12 ++++--- .../pages/SmartLoadingWorkbenchView.vue | 11 +++--- src/shared/api/http.test.ts | 34 +++++++++++++++++++ src/shared/components/DataTable.test.ts | 14 ++++++++ src/shared/components/DataTable.vue | 4 ++- 6 files changed, 81 insertions(+), 9 deletions(-) diff --git a/src/modules/container-loading/pages/GlobalSmartLoadingView.test.ts b/src/modules/container-loading/pages/GlobalSmartLoadingView.test.ts index 07fc61fe..39e2402c 100644 --- a/src/modules/container-loading/pages/GlobalSmartLoadingView.test.ts +++ b/src/modules/container-loading/pages/GlobalSmartLoadingView.test.ts @@ -71,6 +71,21 @@ describe('GlobalSmartLoadingView', () => { expect(wrapper.text()).toContain('ORD-1') }) + it('rounds capacity percentages and hides column settings in embedded tables', async () => { + vi.mocked(listContainers).mockResolvedValue({ records: [{ ...container, capacityCbm: 100, maxWeightKg: 100000 }], page: 1, size: 100, total: 1, pages: 1 }) + vi.mocked(getSmartLoadingPlanByBooking).mockResolvedValue({ + ...plan, + items: [{ ...plan.items[0], volumeCbm: 0.187, grossWeightKg: 13.6 }], + }) + const wrapper = mount(GlobalSmartLoadingView, { global: { plugins: [ElementPlus] } }) + await flushPromises() + + expect(wrapper.text()).toContain('0.17%') + expect(wrapper.text()).toContain('0.01%') + expect(wrapper.text()).not.toContain('0.169999999') + expect(wrapper.findAll('button[aria-label="列设置"]')).toHaveLength(0) + }) + it('keeps unsupported prototype filters out of the real workbench', async () => { const wrapper = mount(GlobalSmartLoadingView, { global: { plugins: [ElementPlus] } }) await flushPromises() diff --git a/src/modules/container-loading/pages/GlobalSmartLoadingView.vue b/src/modules/container-loading/pages/GlobalSmartLoadingView.vue index c9e05e39..3e0bd7e1 100644 --- a/src/modules/container-loading/pages/GlobalSmartLoadingView.vue +++ b/src/modules/container-loading/pages/GlobalSmartLoadingView.vue @@ -66,6 +66,8 @@ const volumeLimit = computed(() => Number(selectedContainer.value?.capacityCbm | const weightLimit = computed(() => Number(selectedContainer.value?.maxWeightKg || 0) * 1.1) const volumePercent = computed(() => volumeLimit.value ? totalVolume.value / volumeLimit.value * 100 : 0) const weightPercent = computed(() => weightLimit.value ? totalWeight.value / weightLimit.value * 100 : 0) +const displayedVolumePercent = computed(() => percentage(volumePercent.value)) +const displayedWeightPercent = computed(() => percentage(weightPercent.value)) const queryFields = computed(() => [ { key: 'orderKeyword', type: 'input', label: '订单或货物', placeholder: '订单号、入库单、客户、货物', width: 250 }, @@ -123,8 +125,9 @@ const itemColumns: DataTableColumn[] = [ ] function formatNumber(value: number, digits = 3) { - return Number.isFinite(value) ? value.toFixed(digits) : '0.000' + return Number.isFinite(value) ? value.toLocaleString('zh-CN', { maximumFractionDigits: digits }) : '0' } +function percentage(value: number) { return Number.isFinite(value) ? Number(Math.max(value, 0).toFixed(2)) : 0 } function candidateRow(source: object) { return source as SmartLoadingCandidate } function itemRow(source: object) { return source as SmartLoadingItem } function statusLabel(status: ContainerPlanStatus) { @@ -360,6 +363,7 @@ onMounted(load) :columns="candidateColumns" :loading="loading || selectionLoading || mutating" preference-key="global-smart-loading-candidates" + :show-column-settings="false" :empty-text="selectedContainer ? '当前仓库暂无可装货物' : '暂无可用柜次'" >