liufumingren 84291ca149 feat: 恢复签约管理页 ScanBox 筛选面板;仓库页移除发起签约、新增奇门配置只读查看;新建外仓商品页面
- warehouses: 恢复 ScanBox,移除预览签约,新增奇门配置查看(支持复制货主/仓库编码)

- stores: 恢复 ScanBox,移除发起签约按钮及弹窗(签约已统一由货主方发起)

- storeWarehouse API: 新增 storeWarehouseList 导出

- 新建 stock/external_stock 外仓商品页面
2026-07-09 03:33:51 +08:00

351 lines
12 KiB
Vue

<template>
<div class="external-stock-container">
<scan-box
ref="scanBox"
width="250px"
title="商品筛选"
:preset-tree="presetTree"
:available-fields="availableFields"
@condition-change="handleConditionChange"
@reset="handleReset"
/>
<div class="main-content">
<div class="toolbar">
<div class="toolbar-left">
<el-button size="small" @click="loadList">
<el-icon><Refresh /></el-icon> 刷新
</el-button>
</div>
<div class="toolbar-right">
<el-input
v-model="queryForm.keyword"
placeholder="搜索商品编码/名称/条码"
clearable
size="small"
style="width: 240px"
@keyup.enter="handleSearch"
>
<template #prefix>
<el-icon><Search /></el-icon>
</template>
</el-input>
</div>
</div>
<div class="upper-wrapper">
<upper-table
ref="tableRef"
default-align="center"
:data="list"
:columns="columns"
:loading="loading"
:pagination="pagination"
@current-change="handleRowClick"
@page-change="handlePageChange"
@page-size-change="handleSizeChange"
>
<template #column-is_sn_mgmt="{ row }">
<el-tag size="small" :type="row.is_sn_mgmt === 'Y' ? 'success' : 'info'">
{{ row.is_sn_mgmt === 'Y' ? '是' : '否' }}
</el-tag>
</template>
<template #column-is_shelf_life_mgmt="{ row }">
<el-tag size="small" :type="row.is_shelf_life_mgmt === 'Y' ? 'success' : 'info'">
{{ row.is_shelf_life_mgmt === 'Y' ? '是' : '否' }}
</el-tag>
</template>
<template #column-is_batch_mgmt="{ row }">
<el-tag size="small" :type="row.is_batch_mgmt === 'Y' ? 'success' : 'info'">
{{ row.is_batch_mgmt === 'Y' ? '是' : '否' }}
</el-tag>
</template>
<template #empty>
<el-empty description="暂无商品数据" :image-size="60" />
</template>
</upper-table>
</div>
<div class="lower-level" v-if="selectedRow">
<div class="detail-header">
<el-tabs v-model="activeTab" class="detail-tab">
<el-tab-pane label="基本信息" name="info" />
<el-tab-pane label="库存信息" name="storage" />
</el-tabs>
</div>
<div class="detail-container">
<el-descriptions v-if="activeTab === 'info'" :column="2" border size="small">
<el-descriptions-item label="商品编码">{{ selectedRow.item_code || '—' }}</el-descriptions-item>
<el-descriptions-item label="商品名称">{{ selectedRow.item_name || '—' }}</el-descriptions-item>
<el-descriptions-item label="品牌">{{ selectedRow.brand_name || '—' }}</el-descriptions-item>
<el-descriptions-item label="规格型号">{{ selectedRow.spec || '—' }}</el-descriptions-item>
<el-descriptions-item label="库存单位">{{ selectedRow.stock_unit || '—' }}</el-descriptions-item>
<el-descriptions-item label="条码">{{ selectedRow.barcode || '—' }}</el-descriptions-item>
<el-descriptions-item label="SN管理">
<el-tag size="small" :type="selectedRow.is_sn_mgmt === 'Y' ? 'success' : 'info'">
{{ selectedRow.is_sn_mgmt === 'Y' ? '是' : '否' }}
</el-tag>
</el-descriptions-item>
<el-descriptions-item label="效期管理">
<el-tag size="small" :type="selectedRow.is_shelf_life_mgmt === 'Y' ? 'success' : 'info'">
{{ selectedRow.is_shelf_life_mgmt === 'Y' ? '是' : '否' }}
</el-tag>
</el-descriptions-item>
<el-descriptions-item label="批次管理">
<el-tag size="small" :type="selectedRow.is_batch_mgmt === 'Y' ? 'success' : 'info'">
{{ selectedRow.is_batch_mgmt === 'Y' ? '是' : '否' }}
</el-tag>
</el-descriptions-item>
<el-descriptions-item label="毛重">{{ selectedRow.gross_weight ?? '—' }}</el-descriptions-item>
<el-descriptions-item label="打包要求">{{ selectedRow.packing_requirements || '—' }}</el-descriptions-item>
<el-descriptions-item label="创建时间" :span="2">{{ formatDate(selectedRow.created_at) }}</el-descriptions-item>
</el-descriptions>
<el-descriptions v-else-if="activeTab === 'storage'" :column="2" border size="small">
<el-descriptions-item label="仓库名称">{{ selectedRow.warehouse_name || '—' }}</el-descriptions-item>
<el-descriptions-item label="可用库存">{{ selectedRow.available_qty ?? '—' }}</el-descriptions-item>
<el-descriptions-item label="锁定库存">{{ selectedRow.locked_qty ?? '—' }}</el-descriptions-item>
<el-descriptions-item label="总库存">{{ selectedRow.total_qty ?? '—' }}</el-descriptions-item>
<el-descriptions-item label="在途库存">{{ selectedRow.in_transit_qty ?? '—' }}</el-descriptions-item>
</el-descriptions>
</div>
</div>
<div class="lower-level empty" v-else>
<el-empty description="请选择数据查看详情" :image-size="60" />
</div>
</div>
</div>
</template>
<script setup lang="ts">
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 ScanBox from '@/components/ScanBox/index.vue'
import UpperTable from '@/components/UpperTable/index.vue'
// ─── 列表列配置 ─────────────────────────────────────────────────────────────
const columns = [
{ prop: 'item_code', label: '商品编码', minWidth: 130 },
{ prop: 'item_name', label: '商品名称', minWidth: 150 },
{ prop: 'brand_name', label: '品牌', width: 100 },
{ prop: 'spec', label: '规格型号', width: 120 },
{ prop: 'stock_unit', label: '库存单位', width: 90 },
{ prop: 'warehouse_name', label: '所属仓库', minWidth: 130 },
{ prop: 'available_qty', 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 }
]
// ─── 筛选字段配置 ─────────────────────────────────────────────────────────
const availableFields = [
{
label: 'SN管理',
value: 'is_sn_mgmt',
type: 'select',
options: [
{ label: '全部', value: undefined },
{ label: '是', value: 'Y' },
{ label: '否', value: 'N' }
]
},
{
label: '效期管理',
value: 'is_shelf_life_mgmt',
type: 'select',
options: [
{ label: '全部', value: undefined },
{ label: '是', value: 'Y' },
{ label: '否', value: 'N' }
]
},
{
label: '批次管理',
value: 'is_batch_mgmt',
type: 'select',
options: [
{ label: '全部', value: undefined },
{ label: '是', value: 'Y' },
{ label: '否', value: 'N' }
]
}
]
const presetTree: any[] = []
// ─── 列表状态 ──────────────────────────────────────────────────────────────
const loading = ref(false)
const list = ref<any[]>([])
const selectedRow = ref<any>(null)
const tableRef = ref<any>(null)
const scanBox = ref<any>(null)
const activeTab = ref('info')
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
const queryForm = reactive({ keyword: '' })
const currentCondition = ref<any>({})
// ─── 加载列表 ──────────────────────────────────────────────────────────────
async function loadList() {
loading.value = true
try {
const params: any = {
pagination: {
page: pagination.currentPage,
pageSize: pagination.pageSize
},
where: { ...currentCondition.value }
}
if (queryForm.keyword) {
params.where.keyword = queryForm.keyword
}
const res = await stockWarehouse(params.pagination, 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
}
} catch (e) {
ElMessage.error('获取商品列表失败')
} finally {
loading.value = false
}
}
// ─── 事件处理 ──────────────────────────────────────────────────────────────
function handleConditionChange(condition: any) {
const where: any = {}
if (condition) {
Object.keys(condition).forEach(k => {
const c = condition[k]
if (c && typeof c === 'object' && c.value !== undefined) {
if (c.value !== '' && c.value !== null) {
where[k] = c.value
}
} else if (c !== '' && c !== null && c !== undefined) {
where[k] = c
}
})
}
currentCondition.value = where
pagination.currentPage = 1
loadList()
}
function handleSearch() {
pagination.currentPage = 1
loadList()
}
function handleReset() {
queryForm.keyword = ''
currentCondition.value = {}
if (scanBox.value?.reset) {
scanBox.value.reset()
} else {
pagination.currentPage = 1
loadList()
}
}
function handlePageChange(page: number) {
pagination.currentPage = page
loadList()
}
function handleSizeChange(size: number) {
pagination.pageSize = size
pagination.currentPage = 1
loadList()
}
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(() => {
loadList()
})
</script>
<style scoped lang="scss">
.external-stock-container {
display: flex;
height: 100%;
.main-content {
flex: 1;
display: flex;
flex-direction: column;
min-width: 0;
padding: 12px;
overflow: hidden;
}
.toolbar {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
flex-shrink: 0;
gap: 12px;
&-left {
display: flex;
align-items: center;
gap: 6px;
}
&-right {
display: flex;
align-items: center;
}
}
.upper-wrapper {
flex: 1;
min-height: 0;
overflow: hidden;
}
.lower-level {
margin-top: 8px;
border: 1px solid #ebeef5;
border-radius: 4px;
flex-shrink: 0;
display: flex;
flex-direction: column;
&.empty {
border: none;
}
.detail-header {
padding: 0 12px;
border-bottom: 1px solid #ebeef5;
flex-shrink: 0;
}
.detail-container {
padding: 12px;
overflow: auto;
max-height: 260px;
}
}
}
</style>