- 刷新 - - - 导出 - - - - 字段设置 - {{ detailVisible ? '隐藏详情' : '显示详情' }} -
- -
-
@@ -201,10 +176,12 @@ import { ref, reactive, onMounted, computed } from 'vue' import { useRoute } from 'vue-router' import { ElMessage } from 'element-plus' -import { ArrowDown } from '@element-plus/icons-vue' import ScanBox from '@/components/ScanBox/index.vue' import UpperTable from '@/components/UpperTable/index.vue' +import WarehouseSelect from '@/components/WarehouseSelect.vue' import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vue' +import OrderToolbarButtonGroup from '@/views/order/orderManagement/component/OrderToolbarButtonGroup.vue' +import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config' import { useAsyncExportTask } from '@/composables/useAsyncExportTask' import * as indexApi from '@/api/index/index' import * as entryApi from '@/api/storage.entry/entry' @@ -222,7 +199,6 @@ import entrydetail from '@/views/storage/entry/component/entrydetail.vue' import log from '@/views/storage/entry/component/log.vue' import DirectInboundLogs from '@/views/storage/entry/component/DirectInboundLogs.vue' import EntryBindingRelations from '@/views/storage/entry/component/EntryBindingRelations.vue' -import WarehouseSelect from '@/components/WarehouseSelect.vue' import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane' import { useSettingsStore } from '@/stores/modules/settings' @@ -260,6 +236,86 @@ function openColumnConfigPanel() { upperTable.value?.openColumnConfig?.() } +// ─── 工具栏按钮配置 ──────────────────────────────────────────────────────── +const toolbarButtons = computed(() => [ + { + key: 'refresh', + label: '刷新', + type: 'primary', + size: 'small', + action: 'handleRefresh' + }, + { + key: 'export', + label: '导出', + size: 'small', + plain: true, + loadingKey: 'exportLoading', + action: 'handleExportAll', + buttonType: 'dropdown', + dropdownOptions: [ + { label: '导出选中', action: 'handleExportSelected' }, + { label: '导出全部', action: 'handleExportAll', divided: true } + ] + }, + { + key: 'columnConfig', + label: '字段设置', + size: 'small', + action: 'openColumnConfigPanel' + }, + { + key: 'toggleDetail', + label: '显示详情', + dynamicLabelKey: 'detailToggleLabel', + size: 'small', + action: 'toggleDetailVisible' + } +]) + +const buttonLoadingMap = computed(() => ({ + exportLoading: exportLoading.value +})) + +const buttonLabelMap = computed(() => ({ + detailToggleLabel: detailVisible.value ? '隐藏详情' : '显示详情' +})) + +const toolbarLayoutKey = computed(() => + JSON.stringify({ + loading: buttonLoadingMap.value, + labels: buttonLabelMap.value + }) +) + +function resolveButtonLoading(loadingKey?: string) { + if (!loadingKey) return false + return Boolean((buttonLoadingMap.value as Record)[loadingKey]) +} + +function resolveButtonDisabled(_disabledKey?: string) { + return false +} + +function resolveButtonLabel(defaultLabel: string, dynamicLabelKey?: string) { + if (!dynamicLabelKey) return defaultLabel + return (buttonLabelMap.value as Record)[dynamicLabelKey] || defaultLabel +} + +const toolbarActionMap: Record void> = { + handleRefresh: () => loadData(), + handleExportAll: () => handleExportAll(), + handleExportSelected: () => handleExportSelected(), + openColumnConfigPanel: () => openColumnConfigPanel(), + toggleDetailVisible: () => toggleDetailVisible() +} + +function handleToolbarButtonClick(action: ToolbarButtonConfig['action']) { + const handler = toolbarActionMap[action] + if (!handler) return + handler() +} + const route = useRoute() const initialConditions = ref(null) @@ -267,10 +323,23 @@ const currentCondition = ref(null) const currentConditionRaw = ref(null) const presetTree = ref([]) -// 货主侧:移除货主筛选项(由登录身份决定) -const availableFieldsRef = reactive( - JSON.parse(JSON.stringify(availableFields)).filter((f: any) => f.value !== 'store_id') -) +// 货主侧:移除货主筛选项,添加仓库筛选(插入到第一个基础信息分类中) +const availableFieldsRef = reactive((() => { + const fields = JSON.parse(JSON.stringify(availableFields)).filter((f: any) => f.value !== 'store_id') + // 在入库单号之后插入全部仓库 + const idx = fields.findIndex((f: any) => f.value === 'entry_order_code') + if (idx !== -1) { + fields.splice(idx + 1, 0, { + label: '全部仓库', + value: 'warehouse_id', + type: 'custom', + component: WarehouseSelect, + props: { width: '100%' }, + group: '基础信息' + }) + } + return fields +})()) const activeTab = ref('details') @@ -307,9 +376,6 @@ const columns = ref(entryStoreColums) const selectedEntryId = ref(null) const currentSort = reactive({ prop: '', order: '' }) -// 仓库选择(v-model 绑定 WarehouseSelect 组件) -const selectedWarehouseId = ref(null) - const componentMap: Record = { details: entrydetail, bindingRelations: EntryBindingRelations, @@ -482,11 +548,6 @@ async function loadData() { try { const where = currentCondition.value || normalizeToWhere(scanBox.value?.getConditions?.() || {}) - // 仓库筛选:如果选择了仓库,加入 where 条件 - if (selectedWarehouseId.value) { - where.warehouse_id = { operator: 'eq', value: selectedWarehouseId.value, type: 'number' } - } - const params: StorageEntryListParams = { pagination: { page: pagination.currentPage, @@ -568,11 +629,6 @@ function handleConditionReset() { loadData() } -function handleWarehouseChange() { - pagination.currentPage = 1 - loadData() -} - function handleRowClick(row: any) { selectedEntryId.value = row?.id || null } @@ -590,9 +646,6 @@ function handlePageSizeChange(size: number) { function buildExportPayload() { const where = currentCondition.value || normalizeToWhere(scanBox.value?.getConditions?.() || {}) - if (selectedWarehouseId.value) { - where.warehouse_id = { operator: 'eq', value: selectedWarehouseId.value, type: 'number' } - } const payload: any = { where } if (currentSort.prop) { payload.sort = { @@ -610,9 +663,6 @@ function buildExportSelectedPayload() { id: { operator: 'in', value: ids } } } - if (selectedWarehouseId.value) { - payload.where.warehouse_id = { operator: 'eq', value: selectedWarehouseId.value, type: 'number' } - } return payload } @@ -628,13 +678,6 @@ async function handleExportSelected() { await submitExportTask(buildExportSelectedPayload()) } -function handleExportCommand(command: string) { - if (command === 'selected') { - handleExportSelected() - } else if (command === 'all') { - handleExportAll() - } -}