fix(admin): 完善弹窗滚动与表单交互布局

This commit is contained in:
2026-10-21 07:40:08 +08:00
parent 2f9a3330e5
commit 0a1968a134
41 changed files with 614 additions and 131 deletions
@@ -16,7 +16,7 @@ describe('InboundMeasurementDialog', () => {
expect(source).toContain('class="inbound-measurement-workspace-dialog admin-density-dialog admin-density-workspace inbound-density admin-workbench is-dialog"')
expect(source).toContain('width="min(1560px, calc(100vw - 48px))"')
expect(source).toContain('height: 92vh')
expect(densitySource).toContain('.admin-density-dialog.el-dialog .el-dialog__header')
expect(densitySource).toContain('.admin-density-dialog.el-dialog > .el-dialog__header')
expect(densitySource).toContain('padding: var(--admin-space-4, 10px) 48px var(--admin-space-4, 10px) var(--admin-space-6, 16px)')
expect(source).toContain('<WeightOcrPanel')
expect(source).toContain('<InboundMeasurementPanel')
@@ -143,19 +143,19 @@ function handleSubmitted() {
</style>
<style>
.inbound-measurement-workspace-dialog.el-dialog { display: flex; max-width: calc(100vw - 32px); height: 92vh; max-height: 92vh; margin-bottom: 0; flex-direction: column; overflow: hidden; }
.inbound-measurement-workspace-dialog .el-dialog__body { flex: 1 1 auto; }
.inbound-measurement-workspace-dialog.el-dialog:not(.is-fullscreen) { display: flex; max-width: calc(100vw - 32px); height: 92vh; max-height: 92vh; margin-bottom: 0; flex-direction: column; overflow: hidden; }
.inbound-measurement-workspace-dialog > .el-dialog__body { flex: 1 1 auto; }
.inbound-measurement-workspace-dialog .measurement-panel { border: 0; border-radius: 0; box-shadow: none; }
.inbound-measurement-workspace-dialog .measurement-panel__heading .measurement-panel__actions,
.inbound-measurement-workspace-dialog .measurement-panel__footer { display: none; }
@media (max-width: 720px) {
.inbound-measurement-workspace-dialog.el-dialog { width: calc(100vw - 20px) !important; max-width: calc(100vw - 20px); }
.inbound-measurement-workspace-dialog .el-dialog__header { padding: 16px; }
.inbound-measurement-workspace-dialog .el-dialog__body { padding: 14px; }
.inbound-measurement-workspace-dialog.el-dialog:not(.is-fullscreen) { width: calc(100vw - 20px) !important; max-width: calc(100vw - 20px); }
.inbound-measurement-workspace-dialog > .el-dialog__header { padding: 16px; }
.inbound-measurement-workspace-dialog > .el-dialog__body { padding: 14px; }
}
@media (max-width: 360px) {
.inbound-measurement-workspace-dialog.el-dialog { width: calc(100vw - 12px) !important; max-width: calc(100vw - 12px); }
.inbound-measurement-workspace-dialog .el-dialog__header { padding: 14px 12px; }
.inbound-measurement-workspace-dialog .el-dialog__body { padding: 10px; }
.inbound-measurement-workspace-dialog.el-dialog:not(.is-fullscreen) { width: calc(100vw - 12px) !important; max-width: calc(100vw - 12px); }
.inbound-measurement-workspace-dialog > .el-dialog__header { padding: 14px 12px; }
.inbound-measurement-workspace-dialog > .el-dialog__body { padding: 10px; }
}
</style>
@@ -21,6 +21,7 @@ import {
} from '../api/weightOcr'
import type { WeightResultResource, WeightWorkspaceResource } from '../types'
import WeightOcrPanel from './WeightOcrPanel.vue'
import InboundMeasurementDialog from '../../measurement/InboundMeasurementDialog.vue'
vi.mock('../api/weightOcr', async () => {
const actual = await vi.importActual<typeof import('../api/weightOcr')>('../api/weightOcr')
@@ -151,6 +152,46 @@ function dialogConfirmButton(text = '确认重量') {
}
describe('WeightOcrPanel confirmation behavior', () => {
it('keeps the weight confirmation outside its measurement parent with independent fullscreen and cancel state', async () => {
const pinia = createPinia()
setActivePinia(pinia)
const auth = useAuthStore()
auth.token = 'token'
auth.permissions = allWeightPermissions
useAccessPreviewStore().initializeAfterLogin()
const wrapper = mount(InboundMeasurementDialog, {
attachTo: document.body,
props: { modelValue: true, customerId: '10001', inboundId: '20001', inboundCode: 'RK-20001' },
global: {
plugins: [pinia, ElementPlus],
stubs: { InboundMeasurementPanel: { template: '<section class="measurement-panel" />' } },
},
})
await flushPromises()
const panel = wrapper.getComponent(WeightOcrPanel)
await openWeightDialog(panel)
const popup = panel.getComponent(AppDialog)
const parent = document.querySelector('.inbound-measurement-workspace-dialog')!
const child = document.querySelector('input[aria-label="当前图片确认重量"]')!.closest('.el-dialog')!
expect(document.body.contains(child)).toBe(true)
expect(parent.contains(child)).toBe(false)
expect(child.classList.contains('admin-workbench')).toBe(true)
await dialogWeightInput().setValue('286.125')
await new DOMWrapper(child).get('button[aria-label="展开全屏"]').trigger('click')
expect(child.classList.contains('is-fullscreen')).toBe(true)
expect(parent.classList.contains('is-fullscreen')).toBe(false)
expect(dialogWeightInput().element.value).toBe('286.125')
await new DOMWrapper(child).findAll('button').find(button => button.text() === '取消')!.trigger('click')
await flushPromises()
expect(popup.props('modelValue')).toBe(false)
expect(wrapper.getComponent(AppDialog).props('modelValue')).toBe(true)
expect(wrapper.emitted('update:modelValue')).toBeUndefined()
await openWeightDialog(panel)
expect(popup.props('modelValue')).toBe(true)
expect(child.classList.contains('is-fullscreen')).toBe(false)
expect(confirmWeightResult).not.toHaveBeenCalled()
})
beforeEach(() => {
vi.clearAllMocks()
document.body.innerHTML = ''
@@ -658,6 +658,7 @@ defineExpose({ reload: loadWorkspace })
:confirm-text="previewConfirmText"
confirm-type="success"
width="min(1080px, calc(100vw - 28px))"
append-to-body
fullscreenable
@confirm="previewResult && confirmResult(previewResult, true)"
>