753 lines
25 KiB
Vue
753 lines
25 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>
|
|
<el-button size="small" plain @click="tableRef?.openColumnConfig?.()">字段设置</el-button>
|
|
</div>
|
|
<div class="toolbar-right">
|
|
<el-select
|
|
v-model="queryForm.warehouse_id"
|
|
placeholder="全部仓库"
|
|
clearable
|
|
filterable
|
|
size="small"
|
|
style="width: 200px; margin-right: 8px"
|
|
@change="handleWarehouseChange"
|
|
>
|
|
<el-option
|
|
v-for="wh in warehouseList"
|
|
:key="wh.warehouse_id"
|
|
:label="wh.warehouse_name"
|
|
:value="wh.warehouse_id"
|
|
/>
|
|
</el-select>
|
|
<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="summary-bar" v-if="summary">
|
|
<span>总库存 <b>{{ summary.total_quantity ?? 0 }}</b></span>
|
|
<span class="summary-divider">|</span>
|
|
<span>锁定库存 <b>{{ summary.total_locked ?? 0 }}</b></span>
|
|
<span class="summary-divider">|</span>
|
|
<span>可用库存 <b>{{ summary.total_available ?? 0 }}</b></span>
|
|
</div>
|
|
|
|
<div class="split-stack" ref="splitStackRef">
|
|
<div class="upper-wrapper" :style="upperPaneStyle">
|
|
<upper-table
|
|
ref="tableRef"
|
|
default-align="center"
|
|
:enable-column-config="true"
|
|
table-id="external-stock-list"
|
|
:data="list"
|
|
:columns="columns"
|
|
:loading="loading"
|
|
:pagination="pagination"
|
|
:show-actions="true"
|
|
@current-change="handleRowClick"
|
|
@page-change="handlePageChange"
|
|
@page-size-change="handleSizeChange"
|
|
@sort-change="handleSortChange"
|
|
>
|
|
<template #column-id="{ row }">
|
|
<span class="sku-text">{{ row.id ?? '—' }}</span>
|
|
</template>
|
|
<template #column-images="{ row }">
|
|
<el-image
|
|
v-if="row.images && row.images.length"
|
|
:src="row.images[0]"
|
|
:preview-src-list="row.images"
|
|
fit="cover"
|
|
preview-teleported
|
|
class="table-thumb"
|
|
/>
|
|
<span v-else style="color:#909399">—</span>
|
|
</template>
|
|
<template #column-actions="{ row }">
|
|
<el-button link type="primary" size="small" @click.stop="openEdit(row)">编辑</el-button>
|
|
</template>
|
|
<template #column-warehouse_name="{ row }">
|
|
<span>{{ row['warehouse_remask'] || '—' }}</span>
|
|
</template>
|
|
<template #column-available_qty="{ row }">
|
|
<span>{{ row.available_quantity ?? '—' }}</span>
|
|
</template>
|
|
<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 #column-update_at_display="{ row }">
|
|
<span>{{ row.update_at_display || '—' }}</span>
|
|
</template>
|
|
<template #empty>
|
|
<el-empty description="暂无商品数据" :image-size="60" />
|
|
</template>
|
|
</upper-table>
|
|
</div>
|
|
|
|
<div
|
|
class="pane-resizer"
|
|
title="拖动调整列表与详情区域高度"
|
|
@mousedown="beginSplitDrag"
|
|
/>
|
|
|
|
<div class="lower-level" v-if="selectedRow" :style="lowerPaneStyle">
|
|
<div class="detail-header">
|
|
<el-tabs v-model="activeTab" class="detail-tab">
|
|
<el-tab-pane label="基本信息" name="info" />
|
|
<el-tab-pane label="商品图片" name="images" />
|
|
<el-tab-pane label="库存信息" name="storage" />
|
|
<el-tab-pane label="外部绑定" name="erpStock" />
|
|
<el-tab-pane label="日志" name="log" />
|
|
</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.goods_code || '—' }}</el-descriptions-item>
|
|
<el-descriptions-item label="品牌">{{ selectedRow.brand_name || '—' }}</el-descriptions-item>
|
|
<el-descriptions-item label="库存单位">{{ selectedRow.stock_unit || '—' }}</el-descriptions-item>
|
|
<el-descriptions-item label="毛重">{{ selectedRow.gross_weight ?? '—' }}</el-descriptions-item>
|
|
<el-descriptions-item label="条码" :span="2">
|
|
<template v-if="selectedRow.barcodes && selectedRow.barcodes.length">
|
|
<el-tag
|
|
v-for="(bc, idx) in selectedRow.barcodes"
|
|
:key="idx"
|
|
size="small"
|
|
style="margin-right: 4px; margin-bottom: 2px"
|
|
>{{ bc }}</el-tag>
|
|
</template>
|
|
<span v-else>—</span>
|
|
</el-descriptions-item>
|
|
<el-descriptions-item label="序列号管理">
|
|
<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="打包要求" :span="2">{{ selectedRow.packing_requirements || '—' }}</el-descriptions-item>
|
|
<el-descriptions-item label="创建时间">{{ selectedRow.create_at_display || '—' }}</el-descriptions-item>
|
|
<el-descriptions-item label="更新时间">{{ selectedRow.update_at_display || '—' }}</el-descriptions-item>
|
|
</el-descriptions>
|
|
|
|
<!-- 商品图片 -->
|
|
<div v-else-if="activeTab === 'images'" class="image-gallery" v-loading="imageLoading">
|
|
<template v-if="imageList.length">
|
|
<el-image
|
|
v-for="(img, idx) in imageList"
|
|
:key="idx"
|
|
:src="img.url"
|
|
:preview-src-list="imageList.map(i => i.url)"
|
|
:initial-index="idx"
|
|
fit="cover"
|
|
preview-teleported
|
|
class="gallery-image"
|
|
/>
|
|
</template>
|
|
<el-empty v-else description="暂无商品图片" :image-size="60" />
|
|
</div>
|
|
|
|
<!-- 外部商品绑定 -->
|
|
<div v-else-if="activeTab === 'erpStock'" class="erp-stock-wrapper">
|
|
<ErpStock :id="selectedRow.id" />
|
|
</div>
|
|
|
|
<!-- 日志 -->
|
|
<div v-else-if="activeTab === 'log'" class="log-wrapper">
|
|
<Log :id="selectedRow.id" />
|
|
</div>
|
|
|
|
<el-descriptions v-else-if="activeTab === 'storage'" :column="2" border size="small">
|
|
<el-descriptions-item label="仓库名称">{{ selectedRow['warehouse_remask'] || '—' }}</el-descriptions-item>
|
|
<el-descriptions-item label="货主备注">{{ selectedRow['store_stock.store_remask'] || '—' }}</el-descriptions-item>
|
|
<el-descriptions-item label="总库存">{{ selectedRow.quantity ?? '—' }}</el-descriptions-item>
|
|
<el-descriptions-item label="锁定库存">{{ selectedRow.locked_quantity ?? '—' }}</el-descriptions-item>
|
|
<el-descriptions-item label="可用库存">{{ selectedRow.available_quantity ?? '—' }}</el-descriptions-item>
|
|
<el-descriptions-item label="锁定率">{{ selectedRow.lock_rate_display || '—' }}</el-descriptions-item>
|
|
</el-descriptions>
|
|
</div>
|
|
</div>
|
|
<div class="lower-level empty" v-else :style="lowerPaneStyle">
|
|
<el-empty description="请选择数据查看详情" :image-size="60" />
|
|
</div>
|
|
</div><!-- .split-stack -->
|
|
</div>
|
|
|
|
<!-- 编辑弹窗 -->
|
|
<el-dialog v-model="editVisible" title="编辑商品" width="520px" :close-on-click-modal="false">
|
|
<el-form ref="editFormRef" :model="editForm" label-width="90px" size="small">
|
|
<el-form-item label="商品名称">
|
|
<el-input v-model="editForm.item_name" placeholder="请输入商品名称" clearable />
|
|
</el-form-item>
|
|
<el-form-item label="商品编码">
|
|
<el-input v-model="editForm.item_code" placeholder="请输入商品编码" clearable />
|
|
</el-form-item>
|
|
<el-form-item label="商家编码">
|
|
<el-input v-model="editForm.goods_code" placeholder="请输入商家编码" clearable />
|
|
</el-form-item>
|
|
<el-form-item label="品牌">
|
|
<el-input v-model="editForm.brand_name" placeholder="请输入品牌" clearable />
|
|
</el-form-item>
|
|
<el-form-item label="库存单位">
|
|
<el-input v-model="editForm.stock_unit" placeholder="请输入库存单位" clearable />
|
|
</el-form-item>
|
|
<el-form-item label="条码">
|
|
<el-input v-model="editForm.barcodeInput" placeholder="多个条码用逗号分隔" clearable />
|
|
</el-form-item>
|
|
</el-form>
|
|
<template #footer>
|
|
<el-button size="small" @click="editVisible = false">取消</el-button>
|
|
<el-button size="small" type="primary" :loading="editSaving" @click="handleEditSave">保存</el-button>
|
|
</template>
|
|
</el-dialog>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { ref, reactive, onMounted, watch } from 'vue'
|
|
import { ElMessage } from 'element-plus'
|
|
import { Search, Refresh } from '@element-plus/icons-vue'
|
|
import { stockWarehouseExternalList, saveWarehouseStock, type StockWarehouseListSort } from '@/api/stock/stock'
|
|
import { loadWarehouses, getImages } from '@/api/index/index'
|
|
import ScanBox from '@/components/ScanBox/index.vue'
|
|
import UpperTable from '@/components/UpperTable/index.vue'
|
|
import ErpStock from '@/views/stock/stock/component/erpStock.vue'
|
|
import Log from '@/views/stock/stock/component/log.vue'
|
|
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
|
|
|
|
// ─── 列表列配置 ─────────────────────────────────────────────────────────────
|
|
const columns = [
|
|
{ prop: 'id', label: 'SKU', width: 80 },
|
|
{ prop: 'images', label: '商品图片', width: 80 },
|
|
{ prop: 'item_code', label: '商品编码', minWidth: 130 },
|
|
{ prop: 'item_name', label: '商品名称', minWidth: 150, sortable: true },
|
|
{ prop: 'goods_code', label: '商家编码', width: 120 },
|
|
{ prop: 'barcodes', label: '条码', minWidth: 150, formatter: (row: any) => row.barcodes?.length ? row.barcodes.join(' | ') : '—' },
|
|
{ prop: 'brand_name', label: '品牌', width: 100 },
|
|
{ prop: 'stock_unit', label: '库存单位', width: 90 },
|
|
{ prop: 'warehouse_name', label: '所属仓库', minWidth: 140 },
|
|
{ prop: 'quantity', label: '总库存', width: 90, sortable: true },
|
|
{ prop: 'locked_quantity', label: '锁定库存', width: 90, sortable: true },
|
|
{ prop: 'available_qty', label: '可用库存', width: 90, sortable: true },
|
|
{ prop: 'lock_rate_display', label: '锁定率', width: 90 },
|
|
{ prop: 'is_sn_mgmt', label: 'SN管理', width: 80 },
|
|
{ prop: 'is_batch_mgmt', label: '批次管理', width: 80 },
|
|
{ prop: 'update_at_display', label: '更新时间', width: 160, sortable: true }
|
|
]
|
|
|
|
// ─── 筛选字段配置 ─────────────────────────────────────────────────────────
|
|
const availableFields = [
|
|
{
|
|
label: '商品名称',
|
|
value: 'item_name',
|
|
type: 'text'
|
|
},
|
|
{
|
|
label: '品牌',
|
|
value: 'brand_name',
|
|
type: 'text'
|
|
},
|
|
{
|
|
label: '货物编码',
|
|
value: 'goods_code',
|
|
type: 'text'
|
|
},
|
|
{
|
|
label: '外部商品绑定',
|
|
value: 'has_bound_item',
|
|
type: 'select',
|
|
options: [
|
|
{ label: '全部', value: undefined },
|
|
{ label: '是', value: 'Y' },
|
|
{ label: '否', value: 'N' }
|
|
]
|
|
},
|
|
{
|
|
label: 'SKU',
|
|
value: 'id',
|
|
type: 'text'
|
|
},
|
|
{
|
|
label: '条码',
|
|
value: 'barcode',
|
|
type: 'text'
|
|
},
|
|
{
|
|
label: '库存数量',
|
|
value: 'quantity',
|
|
type: 'text'
|
|
},
|
|
{
|
|
label: 'ABC分类',
|
|
value: 'level',
|
|
type: 'select',
|
|
options: [
|
|
{ label: '全部', value: undefined },
|
|
{ label: 'A', value: 'A' },
|
|
{ label: 'B', value: 'B' },
|
|
{ label: 'C', value: 'C' }
|
|
]
|
|
},
|
|
{
|
|
label: '是否图片',
|
|
value: 'is_images',
|
|
type: 'select',
|
|
options: [
|
|
{ label: '全部', value: undefined },
|
|
{ label: '是', value: 'Y' },
|
|
{ label: '否', value: 'N' }
|
|
]
|
|
},
|
|
{
|
|
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: '', warehouse_id: undefined as number | string | undefined })
|
|
const currentCondition = ref<any>({})
|
|
const currentSort = reactive({ prop: '', order: '' })
|
|
const summary = ref<any>(null)
|
|
|
|
// ─── 上下分栏拖动 ──────────────────────────────────────────────────────────
|
|
const { splitStackRef, beginSplitDrag, lowerPaneStyle, upperPaneStyle } = useVerticalSplitPane({
|
|
defaultLowerPercent: 35,
|
|
minLowerPercent: 15,
|
|
maxLowerPercent: 70
|
|
})
|
|
|
|
// ─── 仓库列表 ──────────────────────────────────────────────────────────────
|
|
const warehouseList = ref<any[]>([])
|
|
|
|
async function loadWarehouseList() {
|
|
try {
|
|
const res = await loadWarehouses() as any
|
|
const raw = res?.warehouses || res?.data?.list || res?.data || []
|
|
warehouseList.value = raw.map((item: any) => ({
|
|
warehouse_id: item.value ?? item.warehouse_id ?? item.id,
|
|
warehouse_name: item.label || item.warehouse_name || item.company_name || String(item.value ?? '')
|
|
}))
|
|
} catch {
|
|
// 仓库列表加载失败不影响主流程
|
|
}
|
|
}
|
|
|
|
function handleWarehouseChange() {
|
|
pagination.currentPage = 1
|
|
loadList()
|
|
}
|
|
|
|
// ─── 加载列表 ──────────────────────────────────────────────────────────────
|
|
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 sort: StockWarehouseListSort | undefined = currentSort.prop
|
|
? {
|
|
sortField: currentSort.prop,
|
|
sortOrder: currentSort.order === 'ascending' ? 'ASC' : 'DESC'
|
|
}
|
|
: undefined
|
|
|
|
const res = await stockWarehouseExternalList({
|
|
warehouse_id: queryForm.warehouse_id,
|
|
pagination: params.pagination,
|
|
where: params.where,
|
|
sort
|
|
}) 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('获取商品列表失败')
|
|
} 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 = ''
|
|
queryForm.warehouse_id = undefined
|
|
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
|
|
loadImages(row)
|
|
}
|
|
|
|
// ─── 商品图片 ──────────────────────────────────────────────────────────────
|
|
const imageList = ref<{ url: string; name: string }[]>([])
|
|
const imageLoading = ref(false)
|
|
|
|
async function loadImages(row: any) {
|
|
if (!row?.id) {
|
|
imageList.value = []
|
|
return
|
|
}
|
|
imageLoading.value = true
|
|
try {
|
|
const res: any = await getImages({ type: 'stock', id: row.id })
|
|
const raw = res?.data || res || []
|
|
imageList.value = (Array.isArray(raw) ? raw : []).map((img: any) => ({
|
|
url: img?.file?.file_url || img?.url || '',
|
|
name: img?.file?.file_name || img?.name || ''
|
|
}))
|
|
} catch {
|
|
imageList.value = []
|
|
} finally {
|
|
imageLoading.value = false
|
|
}
|
|
}
|
|
|
|
function handleSortChange({ prop, order }: any) {
|
|
currentSort.prop = prop
|
|
currentSort.order = order
|
|
pagination.currentPage = 1
|
|
loadList()
|
|
}
|
|
|
|
// ─── 编辑弹窗 ──────────────────────────────────────────────────────────────
|
|
const editVisible = ref(false)
|
|
const editSaving = ref(false)
|
|
const editFormRef = ref<any>(null)
|
|
const editingRow = ref<any>(null)
|
|
const editForm = reactive({
|
|
item_name: '',
|
|
item_code: '',
|
|
goods_code: '',
|
|
brand_name: '',
|
|
stock_unit: '',
|
|
barcodeInput: ''
|
|
})
|
|
|
|
function openEdit(row: any) {
|
|
editingRow.value = row
|
|
editForm.item_name = row.item_name || ''
|
|
editForm.item_code = row.item_code || ''
|
|
editForm.goods_code = row.goods_code || ''
|
|
editForm.brand_name = row.brand_name || ''
|
|
editForm.stock_unit = row.stock_unit || ''
|
|
editForm.barcodeInput = (row.barcodes || []).join(',')
|
|
editVisible.value = true
|
|
}
|
|
|
|
async function handleEditSave() {
|
|
if (!editingRow.value?.id) return
|
|
editSaving.value = true
|
|
try {
|
|
const barcodes = editForm.barcodeInput
|
|
? editForm.barcodeInput.split(',').map((s: string) => s.trim()).filter(Boolean)
|
|
: []
|
|
const res: any = await saveWarehouseStock({
|
|
id: editingRow.value.id,
|
|
item_name: editForm.item_name,
|
|
item_code: editForm.item_code,
|
|
goods_code: editForm.goods_code,
|
|
brand_name: editForm.brand_name,
|
|
stock_unit: editForm.stock_unit,
|
|
barcodes
|
|
})
|
|
if (res?.flag === 'success' || res?.code === 200) {
|
|
ElMessage.success('保存成功')
|
|
editVisible.value = false
|
|
loadList()
|
|
} else {
|
|
ElMessage.error(res?.message || '保存失败')
|
|
}
|
|
} catch {
|
|
ElMessage.error('保存失败')
|
|
} finally {
|
|
editSaving.value = false
|
|
}
|
|
}
|
|
|
|
// ─── 初始化 ────────────────────────────────────────────────────────────────
|
|
onMounted(() => {
|
|
loadWarehouseList()
|
|
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;
|
|
}
|
|
|
|
.split-stack {
|
|
flex: 1;
|
|
min-height: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
|
|
.pane-resizer {
|
|
flex: 0 0 6px;
|
|
min-height: 6px;
|
|
background: #e4e7ed;
|
|
cursor: row-resize;
|
|
flex-shrink: 0;
|
|
position: relative;
|
|
z-index: 2;
|
|
|
|
&:hover {
|
|
background: #dcdfe6;
|
|
}
|
|
}
|
|
}
|
|
|
|
.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;
|
|
}
|
|
}
|
|
|
|
.table-thumb {
|
|
width: 48px;
|
|
height: 48px;
|
|
border-radius: 4px;
|
|
border: 1px solid #ebeef5;
|
|
cursor: pointer;
|
|
vertical-align: middle;
|
|
}
|
|
|
|
.sku-text {
|
|
font-family: 'Courier New', monospace;
|
|
font-size: 12px;
|
|
}
|
|
|
|
.lower-level {
|
|
border: 1px solid #ebeef5;
|
|
border-radius: 4px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
|
|
&.empty {
|
|
border: none;
|
|
}
|
|
|
|
.detail-header {
|
|
padding: 0 12px;
|
|
border-bottom: 1px solid #ebeef5;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.detail-container {
|
|
padding: 12px;
|
|
overflow: auto;
|
|
flex: 1;
|
|
min-height: 0;
|
|
|
|
.image-gallery {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 8px;
|
|
|
|
.gallery-image {
|
|
width: 100px;
|
|
height: 100px;
|
|
border-radius: 4px;
|
|
border: 1px solid #ebeef5;
|
|
cursor: pointer;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style>
|