diff --git a/src/api/stock/stock.ts b/src/api/stock/stock.ts index b76de535..4ec4120d 100644 --- a/src/api/stock/stock.ts +++ b/src/api/stock/stock.ts @@ -581,3 +581,61 @@ export function stockTransactionStoreList( isSystemApi: true } as any) } + +// ─── 商品流水导出 ────────────────────────────────────────────────────────── + +/** 仓库侧异步导出商品流水 */ +export function transactionExport(data?: { + where?: Record + sort?: StockTransactionListSort + all?: boolean + mode?: string +}) { + return request({ + url: '/system', + method: 'post', + params: { + method: 'stock.transaction.export', + v, + timestamp: new Date().getTime() + }, + data: data ?? {}, + isSystemApi: true + } as any) +} + +/** 货主侧异步导出商品流水 */ +export function transactionExportStore(data?: { + store_id: number + where?: Record + sort?: StockTransactionListSort + all?: boolean + mode?: string +}) { + return request({ + url: '/system', + method: 'post', + params: { + method: 'stock.transaction.exportStore', + v, + timestamp: new Date().getTime() + }, + data: data ?? {}, + isSystemApi: true + } as any) +} + +/** 查询商品流水导出任务进度(仓库/货主共用) */ +export function transactionExportTaskProgress(data: { task_id: string }) { + return request({ + url: '/system', + method: 'post', + params: { + method: 'stock.transaction.exportTaskProgress', + v, + timestamp: new Date().getTime() + }, + data, + isSystemApi: true + } as any) +} diff --git a/src/api/storage.report/report.ts b/src/api/storage.report/report.ts index 9c834bf8..8ce1d01e 100644 --- a/src/api/storage.report/report.ts +++ b/src/api/storage.report/report.ts @@ -90,7 +90,7 @@ export function searchInventoryReport( url: '/system', method: 'post', params: { - method: 'storage.report.search', + method: 'stock.report.search', v, timestamp: new Date().getTime() }, @@ -107,7 +107,7 @@ export function searchStoreReport( url: '/system', method: 'post', params: { - method: 'storage.report.searchStore', + method: 'stock.report.searchStore', v, timestamp: new Date().getTime() }, @@ -123,7 +123,7 @@ export function exportInventoryReport( url: '/system', method: 'post', params: { - method: 'storage.report.export', + method: 'stock.report.export', v, timestamp: new Date().getTime() }, @@ -140,7 +140,7 @@ export function exportStoreReport( url: '/system', method: 'post', params: { - method: 'storage.report.exportStore', + method: 'stock.report.exportStore', v, timestamp: new Date().getTime() }, @@ -156,7 +156,7 @@ export function getExportTaskProgress( url: '/system', method: 'post', params: { - method: 'storage.report.exportTaskProgress', + method: 'stock.report.exportTaskProgress', v, timestamp: new Date().getTime() }, diff --git a/src/api/workbench/workbench.ts b/src/api/workbench/workbench.ts index 9aee220a..9ac3efa4 100644 --- a/src/api/workbench/workbench.ts +++ b/src/api/workbench/workbench.ts @@ -126,3 +126,21 @@ export function business(data: { isSystemApi: true } as any) } + +/** 工作台绑定/解绑摄像头,校验工作台与摄像头归属后更新 device_ids */ +export function bindCamera(data: { + id: number + camera_ids?: number[] +}) { + return request({ + url: '/system', + method: 'post', + params: { + method: 'workbench.bindCamera', + v, + timestamp: new Date().getTime() + }, + data, + isSystemApi: true + } as any) +} diff --git a/src/router/map.ts b/src/router/map.ts index a448925b..823d0bb7 100644 --- a/src/router/map.ts +++ b/src/router/map.ts @@ -37,6 +37,8 @@ export const componentMap: Record = { 'storage/inventory': () => import('@/views/storage/inventory/index.vue'), 'storage/stockout': () => import('@/views/storage/stockout/index.vue'), 'store/productflow': () => import('@/views/storage/productflow/index.vue'), + /** 货主侧商品流水 */ + 'storage/productflow/store': () => import('@/views/storage/productflow/store/index.vue'), 'store/index': () => import('@/views/store/stores/index.vue'), 'Externalwarehouse/shipperSigning/index': () => import('@/views/Externalwarehouse/shipperSigning/index.vue'), 'wave/index': () => import('@/views/order/waveOrder/index.vue'), @@ -61,4 +63,6 @@ export const componentMap: Record = { 'material/packageMaterial/index':() => import('@/views/material/packageMaterial/index.vue'), 'material/packageSupplier/index':() => import('@/views/material/packageSupplier/index.vue'), 'system/setting/pickcart/index':() => import('@/views/system/setting/pickcart/index.vue'), + 'video/cameraServer/index': () => import('@/views/video/cameraServer/index.vue'), + 'video/camera/index': () => import('@/views/video/camera/index.vue'), }; \ No newline at end of file diff --git a/src/views/storage/productflow/index.vue b/src/views/storage/productflow/index.vue index b382c154..5853abbf 100644 --- a/src/views/storage/productflow/index.vue +++ b/src/views/storage/productflow/index.vue @@ -40,9 +40,11 @@ :table-size="tableSize" :pagination="pagination" :show-index="true" + show-selection :loading="loading" :query-time="queryTime" @current-change="handleRowClick" + @selection-change="handleSelectionChange" @page-change="handlePageChange" @page-size-change="handlePageSizeChange" @sort-change="handleSortChange" @@ -56,8 +58,23 @@ {{ getTransactionTypeLabel(row.transaction_type) }} - @@ -142,11 +172,13 @@ import ScanBox from '@/components/ScanBox/index.vue' import UpperTable from '@/components/UpperTable/index.vue' import OrderToolbarButtonGroup from '@/views/order/orderManagement/component/OrderToolbarButtonGroup.vue' import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/order-common-config' -import { stockTransactionList } from '@/api/stock/stock' +import { stockTransactionList, transactionExport, transactionExportTaskProgress } from '@/api/stock/stock' import * as indexApi from '@/api/index/index' import { useSettingsStore } from '@/stores/modules/settings' import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane' +import { useAsyncExportTask } from '@/composables/useAsyncExportTask' import { safeInvoke } from '@/utils/safe-invoke' +import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vue' import { columns as defaultColumns, availableFields, @@ -185,11 +217,29 @@ const queryTime = ref(0) const list = ref([]) const selectedFlowId = ref(null) const detailVisible = ref(true) + +const { + exportLoading, + exportDialogVisible, + exportTaskProgress, + exportProgressPercent, + exportProgressStatus, + exportStatusLabel, + submitExportTaskWithMode, + resumeExportTaskFromStorage, + hasPendingExportTask +} = useAsyncExportTask({ + storageKey: 'stock.transaction.export.taskId', + submitExport: (payload) => transactionExport(payload as any), + queryProgress: (params) => transactionExportTaskProgress(params) +}) + const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 }) const tableSize = ref('small') const columns = ref(defaultColumns) const currentCondition = ref(null) const currentSort = reactive({ prop: 'created_at', order: 'DESC' }) +const selectedIds = ref([]) const toolbarButtons = productflowToolbarButtons @@ -231,7 +281,13 @@ const toolbarActionMap: Record void> = { void loadList() }, openColumnConfigPanel: () => openColumnConfigPanel(), - toggleDetailVisible: () => toggleDetailVisible() + toggleDetailVisible: () => toggleDetailVisible(), + handleExportAll: () => { + void handleExportAction('all') + }, + handleExportSelected: () => { + void handleExportAction('selected') + } } function handleToolbarButtonClick(action: ToolbarButtonConfig['action']) { @@ -291,12 +347,45 @@ function formatQuantityDisplay(row: any): string { return String(qty) } -function getQuantityClass(row: any): string { +/** 库存变动列:仅 INBOUND/OUTBOUND 有值,其余为 0 */ +function formatStockQuantity(row: any): string { + const t = (row.transaction_type || '').toUpperCase() + if (t === 'INBOUND' || t === 'OUTBOUND') return formatQuantityDisplay(row) + return '0' +} + +/** 锁定变动列:仅 LOCK/UNLOCK 有值,其余为 0 */ +function formatLockQuantity(row: any): string { + const t = (row.transaction_type || '').toUpperCase() + if (t === 'LOCK' || t === 'UNLOCK') return formatQuantityDisplay(row) + return '0' +} + +function getQuantityClass(row: any, mode?: 'stock' | 'lock'): string { + const t = (row.transaction_type || '').toUpperCase() + // 非目标类型 → 灰色 + if (mode === 'stock' && t !== 'INBOUND' && t !== 'OUTBOUND') return 'qty-flat' + if (mode === 'lock' && t !== 'LOCK' && t !== 'UNLOCK') return 'qty-flat' + const qty = formatQuantityDelta(row) if (qty === undefined || qty === null || qty === 0) return 'qty-flat' return qty > 0 ? 'qty-up' : 'qty-down' } +function getStockClass(type?: string): string { + const t = (type || '').toUpperCase() + if (t === 'INBOUND') return 'stock-in' + if (t === 'OUTBOUND') return 'stock-out' + return '' +} + +function getLockClass(type?: string): string { + const t = (type || '').toUpperCase() + if (t === 'LOCK') return 'lock-lock' + if (t === 'UNLOCK') return 'lock-unlock' + return '' +} + async function loadFilterData() { try { const [storesRes, presetRes]: any = await Promise.all([ @@ -388,6 +477,10 @@ function handleRowClick(row: any) { selectedFlowId.value = row?.id ?? null } +function handleSelectionChange(rows: any[]) { + selectedIds.value = rows.map((r: any) => r.id).filter((id: any) => id != null) +} + function handlePageChange(page: number) { pagination.currentPage = page loadList() @@ -407,6 +500,41 @@ function handleSortChange(payload: { prop?: string; order?: string }) { loadList() } +// ─── 导出 ──────────────────────────────────────────────────────────────────── + +function buildExportPayload(mode: 'all' | 'selected'): Record { + const where: Record = {} + // 导出选中:用 ids 作为条件 + if (mode === 'selected' && selectedIds.value.length > 0) { + where.ids = selectedIds.value + } else if (mode === 'all') { + // 导出全部:使用当前筛选条件 + Object.assign(where, currentCondition.value || {}) + } + + return { + where: Object.keys(where).length > 0 ? where : undefined, + sort: { + sortField: currentSort.prop || 'created_at', + sortOrder: currentSort.order || 'DESC' + }, + mode + } +} + +async function handleExportAction(mode: 'all' | 'selected') { + if (mode === 'selected' && selectedIds.value.length === 0) { + ElMessage.warning('请先勾选要导出的流水记录') + return + } + if (hasPendingExportTask()) { + ElMessage.warning('检测到未完成导出任务,请等待当前任务完成后再试') + resumeExportTaskFromStorage() + return + } + await submitExportTaskWithMode(buildExportPayload(mode), mode) +} + onMounted(() => { loadFilterData() loadList() @@ -463,6 +591,26 @@ onMounted(() => { color: var(--el-text-color-secondary); } +.stock-in { + font-weight: 700; + color: var(--el-color-success); +} + +.stock-out { + font-weight: 700; + color: var(--el-color-danger); +} + +.lock-lock { + font-weight: 700; + color: var(--el-color-warning); +} + +.lock-unlock { + font-weight: 700; + color: var(--el-color-info); +} + .empty-tip { text-align: center; font-size: 13px; diff --git a/src/views/storage/productflow/productflow-config.ts b/src/views/storage/productflow/productflow-config.ts index 2be98013..6a979fe2 100644 --- a/src/views/storage/productflow/productflow-config.ts +++ b/src/views/storage/productflow/productflow-config.ts @@ -8,10 +8,8 @@ export function formatDateTime(dateStr: string | null | undefined): string { export const transactionTypeConfig: Record = { INBOUND: { text: '入库', tagType: 'success' }, OUTBOUND: { text: '出库', tagType: 'danger' }, - LOCK: { text: '锁定', tagType: 'warning' }, - UNLOCK: { text: '解锁', tagType: 'info' }, - ADJUST: { text: '调整', tagType: 'primary' }, - TRANSFER: { text: '移库', tagType: 'primary' } + LOCK: { text: '锁定库存', tagType: 'warning' }, + UNLOCK: { text: '取消锁定', tagType: 'info' } } export const orderTypeConfig: Record = { @@ -29,7 +27,8 @@ export const columns = [ { prop: 'stock_id', label: '商品ID', width: 90 }, { prop: 'store_id', label: '货主ID', width: 90 }, { prop: 'warehouse_id', label: '仓库ID', width: 90 }, - { prop: 'quantity', label: '变动数量', width: 90 }, + { prop: 'stock_quantity', label: '库存变动', width: 90 }, + { prop: 'lock_quantity', label: '锁定变动', width: 90 }, { prop: 'before_quantity', label: '变动前库存', width: 100 }, { prop: 'after_quantity', label: '变动后库存', width: 100 }, { prop: 'before_locked_quantity', label: '变动前锁定', width: 100 }, @@ -46,6 +45,16 @@ export const columns = [ export const productflowToolbarButtons: ToolbarButtonConfig[] = [ { key: 'refresh', label: '刷新', type: 'primary', size: 'small', loadingKey: 'loading', action: 'loadList' }, { key: 'columnConfig', label: '字段设置', size: 'small', action: 'openColumnConfigPanel' }, + { + key: 'export', + label: '导出', + buttonType: 'dropdown', + size: 'small', + dropdownOptions: [ + { label: '导出全部', action: 'handleExportAll' }, + { label: '导出选中', action: 'handleExportSelected', divided: true } + ] + }, { key: 'toggleDetail', label: '显示详情', @@ -123,6 +132,75 @@ export const availableFields = [ } ] +/** 货主侧筛选字段:仓库筛选替代货主筛选 */ +export const storeAvailableFields = [ + { + label: '商品ID', + value: 'stock_id', + type: 'number', + placeholder: '请输入商品ID', + operators: ['eq'], + defaultOperator: 'eq' + }, + { + label: '订单号', + value: 'order_no', + type: 'text', + placeholder: '请输入订单号', + operators: ['contains', 'eq'], + defaultOperator: 'eq' + }, + { + label: '批次号', + value: 'batch_no', + type: 'text', + placeholder: '请输入批次号', + operators: ['contains', 'eq'], + defaultOperator: 'eq' + }, + { + label: '操作人', + value: 'operator_name', + type: 'text', + placeholder: '请输入操作人', + operators: ['eq', 'contains'], + defaultOperator: 'eq' + }, + { + label: '仓库', + value: 'warehouse_id', + type: 'select', + multiple: true, + filterable: true, + options: [] as Array<{ label: string; value: unknown }> + }, + { + label: '流水时间', + value: 'created_at', + type: 'date', + operators: ['between', 'eq', 'gt', 'lt'], + defaultOperator: 'between' + }, + { + label: '流水类型', + value: 'transaction_type', + type: 'select', + options: Object.entries(transactionTypeConfig).map(([value, cfg]) => ({ + label: cfg.text, + value + })) + }, + { + label: '订单类型', + value: 'order_type', + type: 'select', + options: Object.entries(orderTypeConfig).map(([value, label]) => ({ + label, + value + })) + } +] + export function getTransactionTypeLabel(type: string): string { return transactionTypeConfig[type]?.text || type || '—' } @@ -141,9 +219,23 @@ export function formatQuantityDelta(row: { after_quantity?: number transaction_type?: string }): number | undefined { - if (row.quantity !== undefined && row.quantity !== null) return row.quantity - const before = row.before_quantity - const after = row.after_quantity - if (before === undefined || after === undefined) return undefined - return after - before + let value: number | undefined + if (row.quantity !== undefined && row.quantity !== null) { + value = row.quantity + } else { + const before = row.before_quantity + const after = row.after_quantity + if (before === undefined || after === undefined) return undefined + value = after - before + } + + if (value === undefined) return undefined + + // 根据流水类型决定正负号:出库/锁定为负,入库/解锁为正 + const type = row.transaction_type?.toUpperCase() || '' + const abs = Math.abs(value) + if (type === 'OUTBOUND' || type === 'LOCK') { + return -abs + } + return abs } diff --git a/src/views/storage/productflow/store/index.vue b/src/views/storage/productflow/store/index.vue new file mode 100644 index 00000000..a0b2ab7f --- /dev/null +++ b/src/views/storage/productflow/store/index.vue @@ -0,0 +1,643 @@ + + + + + diff --git a/src/views/system/setting/workbench/index.vue b/src/views/system/setting/workbench/index.vue index a5011727..99f192f9 100644 --- a/src/views/system/setting/workbench/index.vue +++ b/src/views/system/setting/workbench/index.vue @@ -46,6 +46,13 @@ + + @@ -57,6 +64,7 @@ @@ -129,12 +137,60 @@ + + + +
+
+ + + +
+ 已选 {{ selectedCameraIds.length }} / {{ allCameras.length }} 个摄像头 +
+
+ + +
+ {{ cam.custom_name || cam.channel_name || `摄像头-${cam.id}` }} + {{ cam.server?.name || '' }} +
+
+
+ +
+ +
+ + diff --git a/src/views/video/cameraServer/index.vue b/src/views/video/cameraServer/index.vue new file mode 100644 index 00000000..432acbfa --- /dev/null +++ b/src/views/video/cameraServer/index.vue @@ -0,0 +1,493 @@ + + + + +