From 677a666d9b92c15d5f7139b19fa49fea301700ae Mon Sep 17 00:00:00 2001 From: liuyihe <2513762445@qq.com> Date: Thu, 3 Sep 2026 14:30:39 +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 --- .../customers/components/CustomerBillingRulesPanel.test.ts | 7 +++++-- .../customers/components/CustomerBillingRulesPanel.vue | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/modules/customers/components/CustomerBillingRulesPanel.test.ts b/src/modules/customers/components/CustomerBillingRulesPanel.test.ts index 8a41e82a..df4b73dd 100644 --- a/src/modules/customers/components/CustomerBillingRulesPanel.test.ts +++ b/src/modules/customers/components/CustomerBillingRulesPanel.test.ts @@ -11,6 +11,7 @@ import { } from '@/modules/fba-pricing' import { useAccessPreviewStore } from '@/core/access/accessPreview' import { useAuthStore } from '@/core/auth/auth' +import AppDialog from '@/shared/components/AppDialog.vue' import CustomerBillingRulesPanel from './CustomerBillingRulesPanel.vue' vi.mock('@/modules/dimension-config', () => ({ getCustomerDimensionConfig: vi.fn(), updateCustomerDimensionConfig: vi.fn(), updateCustomerDimensionDefaultCalculationMode: vi.fn() })) @@ -93,7 +94,7 @@ describe('CustomerBillingRulesPanel', () => { }) it('submits all four rows in one update request', async () => { - mount(CustomerBillingRulesPanel, { attachTo: document.body, props: { customerId: '8', customerName: '柏悦物流' }, global: { plugins: [ElementPlus] } }) + const wrapper = mount(CustomerBillingRulesPanel, { attachTo: document.body, props: { customerId: '8', customerName: '柏悦物流' }, global: { plugins: [ElementPlus] } }) await flushPromises() ;[...document.querySelectorAll('button')].find((button) => button.textContent?.trim() === '编辑规则')?.click() await flushPromises() @@ -105,6 +106,7 @@ describe('CustomerBillingRulesPanel', () => { expect(Object.keys(submittedRules[0]).sort()).toEqual([ 'boxType', 'edgeAdditionCm', 'innerHeightCm', 'innerLengthCm', 'innerWidthCm', 'remark', 'version', ]) + expect(wrapper.findComponent(AppDialog).props('modelValue')).toBe(false) }) it('keeps the editor open when the whole-set save fails', async () => { @@ -125,7 +127,7 @@ describe('CustomerBillingRulesPanel', () => { ...config, defaultCalculationMode: 'MULTIPLY', }) - mount(CustomerBillingRulesPanel, { attachTo: document.body, props: { customerId: '8', customerName: '柏悦物流' }, global: { plugins: [ElementPlus] } }) + const wrapper = mount(CustomerBillingRulesPanel, { attachTo: document.body, props: { customerId: '8', customerName: '柏悦物流' }, global: { plugins: [ElementPlus] } }) await flushPromises() ;[...document.querySelectorAll('button')].find((button) => button.textContent?.trim() === '编辑规则')?.click() @@ -139,6 +141,7 @@ describe('CustomerBillingRulesPanel', () => { remark: expect.stringMatching(/SMALL:30,20,20;系数:\d+(?:\.\d+)?/), })) expect(setCustomerChargeRuleDefault).toHaveBeenCalledWith('8', '201') + expect(wrapper.findComponent(AppDialog).props('modelValue')).toBe(false) const defaultRuleCheckboxes = [...document.querySelectorAll('input[type="checkbox"]')] defaultRuleCheckboxes[1]?.click() diff --git a/src/modules/customers/components/CustomerBillingRulesPanel.vue b/src/modules/customers/components/CustomerBillingRulesPanel.vue index 59e3d805..bff779d8 100644 --- a/src/modules/customers/components/CustomerBillingRulesPanel.vue +++ b/src/modules/customers/components/CustomerBillingRulesPanel.vue @@ -193,8 +193,8 @@ async function saveConfig() { })) config.value = await updateCustomerDimensionConfig(props.customerId, { rules }) config.value.rules = sortRules(config.value.rules) - form.rules = cloneRules(config.value.rules) editorDirty.value = false + editorVisible.value = false ElMessage.success('箱规尺寸规则已保存') } catch (error) { ElMessage.error(getApiErrorDetails(error, '箱规尺寸规则保存失败,请刷新后重试').message) @@ -240,6 +240,8 @@ async function saveChargeConfig() { const created = await createCustomerChargeRule(props.customerId, { ...chargeForm, ruleCode: `RULE-${Date.now()}`, lengthFactor: coefficient, widthFactor: coefficient, heightFactor: coefficient, defaultRule: false, remark: chargeRows.map((row) => `${row.boxType}:${row.length},${row.width},${row.height};系数:${row.coefficient};${BOX_NAMES[row.boxType]}:${row.remark || '—'}`).join(';') }) await setCustomerChargeRuleDefault(props.customerId, created.id) await loadChargeRules() + editorDirty.value = false + editorVisible.value = false ElMessage.success('权重系数规则已保存') } catch (error) { ElMessage.error(getApiErrorDetails(error, '权重系数规则保存失败').message) } finally { chargeSaving.value = false }