From fb41713930fd5bf4707e42d481140263548a386f Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Tue, 15 Sep 2026 13:46:20 +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 --- .../locations/pages/LocationsView.test.ts | 42 +---------- .../locations/pages/LocationsView.vue | 47 +----------- .../utils/locationLabelPrint.test.ts | 37 ---------- .../locations/utils/locationLabelPrint.ts | 74 ------------------- 4 files changed, 5 insertions(+), 195 deletions(-) delete mode 100644 src/modules/warehouse-resources/locations/utils/locationLabelPrint.test.ts delete mode 100644 src/modules/warehouse-resources/locations/utils/locationLabelPrint.ts diff --git a/src/modules/warehouse-resources/locations/pages/LocationsView.test.ts b/src/modules/warehouse-resources/locations/pages/LocationsView.test.ts index ca434d0a..93d546d6 100644 --- a/src/modules/warehouse-resources/locations/pages/LocationsView.test.ts +++ b/src/modules/warehouse-resources/locations/pages/LocationsView.test.ts @@ -15,7 +15,6 @@ import { import { listAllPlatformWarehouses, type PlatformWarehouseResource } from '../../../warehouses/api/platformWarehouses' import QueryToolbar, { type QueryField, type QueryModel } from '@/shared/components/QueryToolbar.vue' import DataTable from '@/shared/components/DataTable.vue' -import { printLocationLabels } from '../utils/locationLabelPrint' import LocationsView from './LocationsView.vue' const locationsSource = readFileSync(resolve(process.cwd(), 'src/modules/warehouse-resources/locations/pages/LocationsView.vue'), 'utf8') @@ -29,10 +28,6 @@ vi.mock('../api/platformLocations', () => ({ changePlatformLocationStatus: vi.fn(), deletePlatformLocation: vi.fn(), })) -vi.mock('../utils/locationLabelPrint', async (importOriginal) => { - const actual = await importOriginal() - return { ...actual, printLocationLabels: vi.fn(() => true) } -}) class ResizeObserverStub implements ResizeObserver { observe() {} @@ -182,7 +177,6 @@ describe('LocationsView', () => { location: availableLocation, warehouseCode: warehouse.warehouseCode, warehouseName: warehouse.warehouseName, }) vi.mocked(createPlatformLocation).mockReset() - vi.mocked(printLocationLabels).mockClear() }) it('loads only domestic warehouse candidates for querying and writes', async () => { @@ -242,7 +236,7 @@ describe('LocationsView', () => { expect(wrapper.text()).toContain('义乌收货仓') expect(wrapper.text()).toContain('A1-01') expect(wrapper.findAll('thead th').map((item) => item.text().trim())).toEqual([ - '操作', '', '库位编码', '所属仓库', '库区', '库位类型', '状态', + '操作', '库位编码', '所属仓库', '库区', '库位类型', '状态', ]) }) @@ -286,7 +280,6 @@ describe('LocationsView', () => { expect(bodyRows[1]?.text()).not.toContain('详情') expect(bodyRows[1]?.text()).not.toContain('编辑') expect(bodyRows[1]?.text()).not.toContain('更多') - expect(bodyRows[1]?.text()).toContain('打印') }) it('shows all available actions directly when a row has no more than three', async () => { @@ -294,7 +287,6 @@ describe('LocationsView', () => { const row = wrapper.find('tbody tr') expect(row.text()).not.toContain('详情') - expect(row.text()).toContain('打印') expect(row.text()).toContain('停用') expect(row.text()).not.toContain('更多') }) @@ -308,7 +300,6 @@ describe('LocationsView', () => { expect(row.text()).not.toContain('详情') expect(row.text()).toContain('编辑') - expect(row.text()).toContain('打印') expect(row.text()).toContain('启用') expect(row.text()).toContain('删除') expect(row.text()).not.toContain('更多') @@ -347,36 +338,7 @@ describe('LocationsView', () => { expect(occupiedRow?.text()).not.toContain('详情') expect(occupiedRow?.text()).not.toContain('编辑') - expect(occupiedRow?.findAll('button').map((button) => button.text().trim())).toEqual(['打印']) - }) - - it('prints one row directly and supports printing the selected current-page rows', async () => { - const wrapper = await mountView(['platform:location:list']) - const bodyRows = wrapper.findAll('tbody tr') - const rowPrint = bodyRows[0]?.findAll('button').find((button) => button.text().trim() === '打印') - - await rowPrint!.trigger('click') - expect(printLocationLabels).toHaveBeenLastCalledWith([{ - locationCode: 'A1-01', - locationName: 'A1 区 01 位', - warehouseCode: 'CN-YW-01', - warehouseName: '义乌收货仓', - zoneCode: 'A', - zoneName: '常规区', - }]) - - wrapper.findComponent(DataTable).vm.$emit('selection-change', [availableLocation, occupiedLocation]) - await flushPromises() - const batchPrint = wrapper.find('.table-panel .data-table__toolbar').findAll('button') - .find((button) => button.text().includes('打印所选')) - expect(batchPrint?.attributes('disabled')).toBeUndefined() - expect(batchPrint?.text()).toContain('2') - await batchPrint!.trigger('click') - - expect(printLocationLabels).toHaveBeenLastCalledWith(expect.arrayContaining([ - expect.objectContaining({ locationCode: 'A1-01' }), - expect.objectContaining({ locationCode: 'A1-02' }), - ])) + expect(occupiedRow?.findAll('button')).toHaveLength(0) }) it('clears the warehouse on reset and immediately restores the full query', async () => { diff --git a/src/modules/warehouse-resources/locations/pages/LocationsView.vue b/src/modules/warehouse-resources/locations/pages/LocationsView.vue index e2955a29..50845b46 100644 --- a/src/modules/warehouse-resources/locations/pages/LocationsView.vue +++ b/src/modules/warehouse-resources/locations/pages/LocationsView.vue @@ -2,7 +2,7 @@ import '@/styles/adminDensity.css' import { computed, onMounted, reactive, ref, watch } from 'vue' import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from 'element-plus' -import { MapPin, Plus, Printer, Save } from '@lucide/vue' +import { MapPin, Plus, Save } from '@lucide/vue' import { useAccessPreviewStore } from '@/core/access/accessPreview' import { useUnsavedWorkRegistration } from '@/core/unsaved-work/useUnsavedWorkRegistration' import { getApiErrorDetails, type ApiErrorDetails } from '@/shared/api/http' @@ -27,7 +27,6 @@ import { type SavePlatformLocationRequest, } from '../api/platformLocations' import { listAllPlatformWarehouses, type PlatformWarehouseResource } from '../../../warehouses/api/platformWarehouses' -import { printLocationLabels, type LocationLabelPrintItem } from '../utils/locationLabelPrint' type EditorMode = 'create' | 'edit' type LocationFilters = QueryModel & { @@ -52,7 +51,6 @@ const warehouseError = ref(null) const loading = ref(false) const loadError = ref(null) const rows = ref([]) -const selectedRows = ref([]) const page = ref(1) const pageSize = ref(20) const total = ref(0) @@ -172,8 +170,7 @@ const typeLabels: Record = { } const columns: DataTableColumn[] = [ - { key: 'actions', label: '操作', width: 300, fixed: 'left', slotName: 'actions' }, - { key: 'selection', type: 'selection', width: 48, fixed: 'left' }, + { key: 'actions', label: '操作', width: 240, fixed: 'left', slotName: 'actions' }, { key: 'location', label: '库位编码', minWidth: 190, slotName: 'location' }, { key: 'warehouse', label: '所属仓库', minWidth: 210, slotName: 'warehouse' }, { key: 'zone', label: '库区', minWidth: 150, slotName: 'zone' }, @@ -242,32 +239,6 @@ function recordScope(row: PlatformLocationResource) { return { warehouseId: apiId(String(row.warehouseId)) } } -function printItem(row: PlatformLocationResource): LocationLabelPrintItem { - const warehouse = warehouses.value.find((item) => String(item.id) === String(row.warehouseId)) - return { - locationCode: row.locationCode, - locationName: row.locationName, - warehouseCode: row.warehouseCode || warehouse?.warehouseCode, - warehouseName: row.warehouseName || warehouse?.warehouseName, - zoneCode: row.zoneCode, - zoneName: row.zoneName, - } -} - -function printRows(targets: readonly PlatformLocationResource[]) { - if (!targets.length) { - ElMessage.warning('请先勾选需要打印的库位') - return - } - if (!printLocationLabels(targets.map(printItem))) { - ElMessage.warning('打印窗口被浏览器拦截,请允许弹出窗口后重试') - } -} - -function onSelectionChange(selection: object[]) { - selectedRows.value = selection as PlatformLocationResource[] -} - async function loadWarehouses() { const sequence = ++warehouseLoadSequence warehouseLoading.value = true @@ -304,12 +275,10 @@ async function loadLocations() { const result = await listPlatformLocations(query) if (sequence !== locationLoadSequence) return rows.value = result.records - selectedRows.value = [] total.value = result.total } catch (error) { if (sequence !== locationLoadSequence) return rows.value = [] - selectedRows.value = [] total.value = 0 loadError.value = getApiErrorDetails(error, '库位列表加载失败,请稍后重试') } finally { @@ -558,20 +527,10 @@ onMounted(() => { row-key="id" aria-label="库位列表" :empty-text="emptyDescription" - @selection-change="onSelectionChange" > - +