diff --git a/src/api/index/index.ts b/src/api/index/index.ts index a95c26a7..d465bbf5 100644 --- a/src/api/index/index.ts +++ b/src/api/index/index.ts @@ -26,6 +26,22 @@ export function loadStores(type:any) { isSystemApi: true } as any) } + +/** 查询仓库列表(无需鉴权,需登录) */ +export function loadWarehouses(data?: Record) { + return request({ + url: '/system', + method: 'post', + params: { + method: 'index.loadWarehouses', + v: '1.0', + timestamp: new Date().getTime() + }, + data: data ?? {}, + isSystemApi: true + } as any) +} + export function getCOSUploadConfig(data:any){ return request({ url: '/system', diff --git a/src/api/stock/stock.ts b/src/api/stock/stock.ts index 0bb91fdd..b76de535 100644 --- a/src/api/stock/stock.ts +++ b/src/api/stock/stock.ts @@ -30,6 +30,31 @@ export function stockWarehouse(pagination: any, data: any, sort?: StockWarehouse } as any) } +/** 外仓商品列表 */ +export function stockWarehouseExternalList(params: { + warehouse_id?: number | string + pagination?: { page?: number; pageSize?: number } + where?: Record + sort?: StockWarehouseListSort +}) { + return request({ + url: '/system', + method: 'post', + params: { + method: 'stock.warehouse.externalList', + v, + timestamp: new Date().getTime() + }, + data: { + warehouse_id: params.warehouse_id, + pagination: params.pagination, + where: params.where, + sort: params.sort + }, + isSystemApi: true + } as any) +} + export function getProhibitedType() { return request({ url: '/system', diff --git a/src/views/stock/external_stock/index.vue b/src/views/stock/external_stock/index.vue index 2dc97665..88d80932 100644 --- a/src/views/stock/external_stock/index.vue +++ b/src/views/stock/external_stock/index.vue @@ -18,6 +18,22 @@
+ + +
+ +
+ 总库存 {{ summary.total_quantity ?? 0 }} + | + 锁定库存 {{ summary.total_locked ?? 0 }} + | + 可用库存 {{ summary.total_available ?? 0 }} +
+
+ + + @@ -78,10 +112,21 @@ {{ selectedRow.item_code || '—' }} {{ selectedRow.item_name || '—' }} + {{ selectedRow.goods_code || '—' }} {{ selectedRow.brand_name || '—' }} - {{ selectedRow.spec || '—' }} {{ selectedRow.stock_unit || '—' }} - {{ selectedRow.barcode || '—' }} + {{ selectedRow.gross_weight ?? '—' }} + + + — + {{ selectedRow.is_sn_mgmt === 'Y' ? '是' : '否' }} @@ -97,17 +142,18 @@ {{ selectedRow.is_batch_mgmt === 'Y' ? '是' : '否' }} - {{ selectedRow.gross_weight ?? '—' }} - {{ selectedRow.packing_requirements || '—' }} - {{ formatDate(selectedRow.created_at) }} + {{ selectedRow.packing_requirements || '—' }} + {{ selectedRow.create_at_display || '—' }} + {{ selectedRow.update_at_display || '—' }} - {{ selectedRow.warehouse_name || '—' }} - {{ selectedRow.available_qty ?? '—' }} - {{ selectedRow.locked_qty ?? '—' }} - {{ selectedRow.total_qty ?? '—' }} - {{ selectedRow.in_transit_qty ?? '—' }} + {{ selectedRow['store_stock.warehouse.company_name'] || '—' }} + {{ selectedRow['store_stock.store_remask'] || '—' }} + {{ selectedRow.quantity ?? '—' }} + {{ selectedRow.locked_quantity ?? '—' }} + {{ selectedRow.available_quantity ?? '—' }} + {{ selectedRow.lock_rate_display || '—' }}
@@ -122,7 +168,8 @@ import { ref, reactive, onMounted } from 'vue' import { ElMessage } from 'element-plus' import { Search, Refresh } from '@element-plus/icons-vue' -import { stockWarehouse } from '@/api/stock/stock' +import { stockWarehouseExternalList } from '@/api/stock/stock' +import { loadWarehouses } from '@/api/index/index' import ScanBox from '@/components/ScanBox/index.vue' import UpperTable from '@/components/UpperTable/index.vue' @@ -130,15 +177,17 @@ import UpperTable from '@/components/UpperTable/index.vue' const columns = [ { prop: 'item_code', label: '商品编码', minWidth: 130 }, { prop: 'item_name', label: '商品名称', minWidth: 150 }, + { prop: 'goods_code', label: '商家编码', width: 120 }, { prop: 'brand_name', label: '品牌', width: 100 }, - { prop: 'spec', label: '规格型号', width: 120 }, { prop: 'stock_unit', label: '库存单位', width: 90 }, - { prop: 'warehouse_name', label: '所属仓库', minWidth: 130 }, + { prop: 'warehouse_name', label: '所属仓库', minWidth: 140 }, + { prop: 'quantity', label: '总库存', width: 90 }, + { prop: 'locked_quantity', label: '锁定库存', width: 90 }, { prop: 'available_qty', label: '可用库存', width: 90 }, + { prop: 'lock_rate_display', label: '锁定率', width: 90 }, { prop: 'is_sn_mgmt', label: 'SN管理', width: 80 }, - { prop: 'is_shelf_life_mgmt', label: '效期管理', width: 80 }, { prop: 'is_batch_mgmt', label: '批次管理', width: 80 }, - { prop: 'updated_at', label: '更新时间', width: 160 } + { prop: 'update_at_display', label: '更新时间', width: 160 } ] // ─── 筛选字段配置 ───────────────────────────────────────────────────────── @@ -186,8 +235,28 @@ const scanBox = ref(null) const activeTab = ref('info') const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 }) -const queryForm = reactive({ keyword: '' }) +const queryForm = reactive({ keyword: '', warehouse_id: undefined as number | string | undefined }) const currentCondition = ref({}) +const summary = ref(null) + +// ─── 仓库列表 ────────────────────────────────────────────────────────────── +const warehouseList = ref([]) + +async function loadWarehouseList() { + try { + const res = await loadWarehouses() as any + if (res?.data) { + warehouseList.value = res.data.list || res.data || [] + } + } catch { + // 仓库列表加载失败不影响主流程 + } +} + +function handleWarehouseChange() { + pagination.currentPage = 1 + loadList() +} // ─── 加载列表 ────────────────────────────────────────────────────────────── async function loadList() { @@ -204,13 +273,18 @@ async function loadList() { params.where.keyword = queryForm.keyword } - const res = await stockWarehouse(params.pagination, params.where) as any + const res = await stockWarehouseExternalList({ + warehouse_id: queryForm.warehouse_id, + pagination: params.pagination, + where: params.where + }) as any if (res?.data) { const payload = res.data list.value = payload.list || [] pagination.total = payload.pagination?.total || payload.total || 0 pagination.currentPage = payload.pagination?.page || payload.page || pagination.currentPage pagination.pageSize = payload.pagination?.pageSize || payload.page_size || pagination.pageSize + summary.value = payload.summary || null } } catch (e) { ElMessage.error('获取商品列表失败') @@ -246,6 +320,7 @@ function handleSearch() { function handleReset() { queryForm.keyword = '' + queryForm.warehouse_id = undefined currentCondition.value = {} if (scanBox.value?.reset) { scanBox.value.reset() @@ -270,14 +345,9 @@ function handleRowClick(row: any) { selectedRow.value = row } -// ─── 工具函数 ────────────────────────────────────────────────────────────── -function formatDate(dateStr: string | null | undefined) { - if (!dateStr) return '' - return new Date(dateStr).toLocaleString('zh-CN', { hour12: false }).replace(/\//g, '-') -} - // ─── 初始化 ──────────────────────────────────────────────────────────────── onMounted(() => { + loadWarehouseList() loadList() }) @@ -322,6 +392,28 @@ onMounted(() => { overflow: hidden; } + .summary-bar { + display: flex; + align-items: center; + gap: 12px; + padding: 8px 12px; + margin-bottom: 8px; + background: #f0f9eb; + border-radius: 4px; + font-size: 13px; + color: #606266; + flex-shrink: 0; + + b { + color: #303133; + font-weight: 600; + } + + .summary-divider { + color: #dcdfe6; + } + } + .lower-level { margin-top: 8px; border: 1px solid #ebeef5;