1
This commit is contained in:
parent
b26129cf4d
commit
b38c6ae918
@ -72,8 +72,28 @@ export type ReturnUnpackRecord = {
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
/** 原订单商品明细行(order.items 顶层透出) */
|
||||
export type ReturnUnpackOrderItem = {
|
||||
/** 商品编码 */
|
||||
item_code?: string
|
||||
/** 商品名称 */
|
||||
item_name?: string
|
||||
/** 规格属性 */
|
||||
sku_property?: string
|
||||
/** 数量 */
|
||||
quantity?: number
|
||||
/** 计划数量 */
|
||||
plan_qty?: number
|
||||
/** 条码数组 */
|
||||
barcodes?: { id?: number; barcode?: string }[]
|
||||
/** 图片数组 */
|
||||
image_url?: string[]
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
/** 原订单详情(原单退回时返回,含 items 明细) */
|
||||
export type ReturnUnpackOriginalOrder = {
|
||||
items?: ReturnUnpackOrderItem[]
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
@ -113,6 +133,8 @@ export type ReturnUnpackCreateResponse = {
|
||||
store_remark: string
|
||||
/** 原订单详情(仅原单退回时返回,非原单为 null) */
|
||||
order?: ReturnUnpackOriginalOrder | null
|
||||
/** 原订单商品明细数组(order.items 顶层透出,仅原单退回时返回;非原单退回或原订单详情缺失时为 null) */
|
||||
order_items?: ReturnUnpackOrderItem[] | null
|
||||
/** 是否幂等复用已有拆包单 */
|
||||
reused?: boolean
|
||||
}
|
||||
|
||||
@ -10,10 +10,12 @@
|
||||
>
|
||||
<div class="picker-toolbar">
|
||||
<el-input
|
||||
ref="keywordRef"
|
||||
v-model="keyword"
|
||||
placeholder="商品编码 / 条码 / 名称"
|
||||
clearable
|
||||
size="small"
|
||||
@focus="focusMode = 'search'"
|
||||
@keyup.enter="handleSearch"
|
||||
/>
|
||||
<el-button type="primary" size="small" :loading="loading" @click="handleSearch">搜索</el-button>
|
||||
@ -46,7 +48,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue'
|
||||
import { nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { warehouseSearch, stockWarehouse } from '@/api/stock/stock'
|
||||
import {
|
||||
@ -83,6 +85,7 @@ const tableRef = ref<any>(null)
|
||||
|
||||
watch(visible, (opened) => {
|
||||
if (!opened) return
|
||||
focusMode.value = 'search'
|
||||
keyword.value = props.initialKeyword || ''
|
||||
currentRow.value = null
|
||||
if (props.initialKeyword) {
|
||||
@ -90,6 +93,9 @@ watch(visible, (opened) => {
|
||||
} else {
|
||||
loadInitialList()
|
||||
}
|
||||
nextTick(() => {
|
||||
keywordRef.value?.focus()
|
||||
})
|
||||
})
|
||||
|
||||
function mapRow(row: any): StockPickerItem | null {
|
||||
@ -176,6 +182,101 @@ function handleClosed() {
|
||||
currentRow.value = null
|
||||
tableRef.value?.setCurrentRow?.()
|
||||
}
|
||||
|
||||
// ==================== 表单键盘快捷键 ====================
|
||||
// 弹窗打开时生效(页面快捷键由外层页面在弹窗打开时禁用,互不干扰):
|
||||
// - ←/→:在「搜索框 ↔ 商品列表」之间切换焦点
|
||||
// - ↑/↓:切换商品(移动高亮行)
|
||||
// - Enter:在商品列表内确定选中
|
||||
const keywordRef = ref<any>(null)
|
||||
const focusMode = ref<'search' | 'list'>('search')
|
||||
|
||||
/** 移出搜索框焦点,避免回车被输入框自身的 @keyup.enter 截获 */
|
||||
function blurKeyword() {
|
||||
keywordRef.value?.blur?.()
|
||||
const input = keywordRef.value?.$el?.querySelector?.('input')
|
||||
input?.blur?.()
|
||||
}
|
||||
|
||||
function ensureCurrentRow() {
|
||||
if (!currentRow.value && list.value.length) {
|
||||
const first = list.value[0]
|
||||
if (first) {
|
||||
currentRow.value = first
|
||||
tableRef.value?.setCurrentRow?.(first)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function moveRow(direction: 1 | -1) {
|
||||
const rows = list.value
|
||||
if (!rows.length) return
|
||||
const idx = rows.findIndex((r) => r === currentRow.value)
|
||||
const base = idx >= 0 ? idx : direction > 0 ? -1 : 0
|
||||
const next = (base + direction + rows.length) % rows.length
|
||||
const target = rows[next]
|
||||
if (!target) return
|
||||
currentRow.value = target
|
||||
tableRef.value?.setCurrentRow?.(target)
|
||||
nextTick(() => {
|
||||
const body = tableRef.value?.$el?.querySelector('.el-table__body-wrapper')
|
||||
const rowEls = body?.querySelectorAll?.('.el-table__row')
|
||||
rowEls?.[next]?.scrollIntoView?.({ block: 'nearest' })
|
||||
})
|
||||
}
|
||||
|
||||
function handleKeydown(e: KeyboardEvent) {
|
||||
if (!visible.value) return
|
||||
const el = e.target as HTMLElement | null
|
||||
const tag = el?.tagName?.toUpperCase()
|
||||
const isNumberInput = tag === 'INPUT' && (el?.className?.includes('el-input-number') ?? false)
|
||||
|
||||
// 左/右:搜索框 ↔ 商品列表
|
||||
if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {
|
||||
if (isNumberInput) return
|
||||
e.preventDefault()
|
||||
focusMode.value = focusMode.value === 'search' ? 'list' : 'search'
|
||||
nextTick(() => {
|
||||
if (focusMode.value === 'search') {
|
||||
keywordRef.value?.focus()
|
||||
} else {
|
||||
// 切到列表:移出搜索框焦点,并选中首行
|
||||
blurKeyword()
|
||||
ensureCurrentRow()
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 上/下:切换商品
|
||||
if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
|
||||
if (isNumberInput) return
|
||||
e.preventDefault()
|
||||
focusMode.value = 'list'
|
||||
blurKeyword()
|
||||
moveRow(e.key === 'ArrowUp' ? -1 : 1)
|
||||
return
|
||||
}
|
||||
|
||||
// Enter:列表模式下确定选中(搜索模式下交给输入框自身搜索)
|
||||
if (e.key === 'Enter') {
|
||||
if (focusMode.value === 'list' && currentRow.value) {
|
||||
e.preventDefault()
|
||||
// 阻止同一次按键继续传播到页面级监听,避免选择商品后误触发「提交确认」
|
||||
e.stopImmediatePropagation()
|
||||
handleConfirm()
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
window.addEventListener('keydown', handleKeydown)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('keydown', handleKeydown)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
v-model="waybillCode"
|
||||
placeholder="运单号"
|
||||
clearable
|
||||
:disabled="!!createResult?.id"
|
||||
@keyup.enter="handleCreate"
|
||||
/>
|
||||
<!-- <el-button type="primary" @click="handleScan">扫描</el-button> -->
|
||||
@ -39,7 +40,6 @@
|
||||
</el-form-item>
|
||||
<el-form-item v-if="createResult?.id" label="货主">
|
||||
<el-select
|
||||
ref="storeSelectRef"
|
||||
v-model="selectedStoreId"
|
||||
placeholder="无"
|
||||
clearable
|
||||
@ -56,26 +56,38 @@
|
||||
<el-button v-if="createResult?.record?.status === 'unpacking'" size="small" type="success" :loading="submitLoading" @click="handleSubmit">提交确认</el-button>
|
||||
<el-button v-if="createResult?.record?.status === 'unpacking'" size="small" type="warning" :loading="cancelLoading" @click="handleCancel">取消</el-button>
|
||||
<el-button size="small" type="danger" :loading="deleteLoading" @click="handleDeleteUnpack">删除</el-button>
|
||||
<el-button v-if="createResult?.record?.status === 'completed' || createResult?.record?.status === 'cancelled'" size="small" @click="handleClearInfo">清除信息</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<div class="shortcut-tips">
|
||||
<div class="shortcut-tips-title">⌨ 键盘快捷键</div>
|
||||
<div class="shortcut-tips-sub">页面(未打开弹窗时生效)</div>
|
||||
<div class="shortcut-row">
|
||||
<kbd>Enter</kbd><span>运单号:创建拆包单</span>
|
||||
<kbd>Enter</kbd><span>运单号:创建拆包单(创建后运单号锁定置灰)</span>
|
||||
</div>
|
||||
<div class="shortcut-row">
|
||||
<kbd>Enter</kbd><span>商品条码:查询并添加</span>
|
||||
</div>
|
||||
<div class="shortcut-row">
|
||||
<kbd>←</kbd><kbd>→</kbd><span>切换焦点(运单号/商品条码/货主/无选中)</span>
|
||||
<kbd>←</kbd><kbd>→</kbd><span>切换焦点(运单号/商品条码)</span>
|
||||
</div>
|
||||
<div class="shortcut-row">
|
||||
<kbd>↑</kbd><kbd>↓</kbd><span>产品状态:正常 / 破损</span>
|
||||
<kbd>Enter</kbd><kbd>空格</kbd><span>表单内:确认;无表单时:提交确认</span>
|
||||
</div>
|
||||
<div class="shortcut-row">
|
||||
<kbd>空格</kbd><kbd>Enter</kbd><span>无选中时:提交确认</span>
|
||||
<kbd>Esc</kbd><span>拆包中:取消拆包;已提交/已取消:清除信息</span>
|
||||
</div>
|
||||
<div class="shortcut-tips-sub">表单(商品选择弹窗内生效)</div>
|
||||
<div class="shortcut-row">
|
||||
<kbd>←</kbd><kbd>→</kbd><span>切换焦点(搜索框/商品列表)</span>
|
||||
</div>
|
||||
<div class="shortcut-row">
|
||||
<kbd>↑</kbd><kbd>↓</kbd><span>切换商品</span>
|
||||
</div>
|
||||
<div class="shortcut-row">
|
||||
<kbd>Enter</kbd><span>确定选中商品</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -107,12 +119,35 @@
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="货主备注">{{ createResult.store_remark || '-' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<div v-if="createResult.is_original_return && createResult.order_items?.length" class="order-items-block">
|
||||
<div class="order-items-title">原订单商品</div>
|
||||
<el-table :data="createResult.order_items" size="small" border>
|
||||
<el-table-column prop="item_code" label="商品编码" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="item_name" label="商品名称" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="sku_property" label="规格" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column prop="quantity" label="数量" width="80" />
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
<el-empty v-else description="点击「创建拆包」后显示开单结果" :image-size="60" />
|
||||
</div>
|
||||
<div class="right-body">
|
||||
<el-table :data="detailList" v-loading="detailListLoading" size="small" border class="detail-table" empty-text="暂无明细">
|
||||
<el-table-column prop="id" label="明细ID" width="80" />
|
||||
<el-table-column label="商品图片" width="90">
|
||||
<template #default="{ row }">
|
||||
<el-image
|
||||
v-if="detailImage(row)"
|
||||
:src="detailImage(row)"
|
||||
:preview-src-list="detailImages(row)"
|
||||
preview-teleported
|
||||
fit="cover"
|
||||
class="stock-thumb"
|
||||
/>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="item_code" label="商品编码" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="item_name" label="商品名称" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="barcode" label="条码" min-width="120" show-overflow-tooltip />
|
||||
@ -259,6 +294,66 @@
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 取消拆包确认(Esc 由全局快捷键统一控制打开/关闭) -->
|
||||
<el-dialog
|
||||
v-model="cancelConfirmVisible"
|
||||
title="取消拆包确认"
|
||||
width="420px"
|
||||
align-center
|
||||
:close-on-press-escape="false"
|
||||
>
|
||||
<div class="cancel-confirm-tip">确认取消拆包单?取消将硬删除该单及全部明细,不可恢复。</div>
|
||||
<template #footer>
|
||||
<el-button @click="cancelConfirmVisible = false">返回</el-button>
|
||||
<el-button type="warning" :loading="cancelLoading" @click="confirmCancel">取消拆包</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 提交确认(Esc 由全局快捷键统一控制关闭) -->
|
||||
<el-dialog
|
||||
v-model="submitConfirmVisible"
|
||||
title="提交确认"
|
||||
width="420px"
|
||||
align-center
|
||||
:close-on-press-escape="false"
|
||||
>
|
||||
<div class="cancel-confirm-tip">确认提交拆包单?提交后转为已完成终态,不可再录/移除明细。</div>
|
||||
<template #footer>
|
||||
<el-button @click="submitConfirmVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="submitLoading" @click="confirmSubmit">提交</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 删除确认(Esc 由全局快捷键统一控制关闭) -->
|
||||
<el-dialog
|
||||
v-model="deleteConfirmVisible"
|
||||
title="删除确认"
|
||||
width="420px"
|
||||
align-center
|
||||
:close-on-press-escape="false"
|
||||
>
|
||||
<div class="cancel-confirm-tip">确认删除拆包单?删除为物理删除(含全部明细),不可恢复。</div>
|
||||
<template #footer>
|
||||
<el-button @click="deleteConfirmVisible = false">取消</el-button>
|
||||
<el-button type="danger" :loading="deleteLoading" @click="confirmDelete">删除</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 移除明细确认(Esc 由全局快捷键统一控制关闭) -->
|
||||
<el-dialog
|
||||
v-model="removeDetailConfirmVisible"
|
||||
title="移除明细确认"
|
||||
width="420px"
|
||||
align-center
|
||||
:close-on-press-escape="false"
|
||||
>
|
||||
<div class="cancel-confirm-tip">确认移除该明细(明细ID {{ removeDetailRow?.id ?? '-' }})?移除为物理删除,不可恢复。</div>
|
||||
<template #footer>
|
||||
<el-button @click="removeDetailConfirmVisible = false">取消</el-button>
|
||||
<el-button type="danger" :loading="removingDetailLoading" @click="confirmRemoveDetail">移除</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 商品选择弹窗 -->
|
||||
<StockPickerDialog
|
||||
v-model="stockPickerVisible"
|
||||
@ -299,7 +394,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onMounted, onUnmounted, reactive, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import {
|
||||
returnUnpackCreate,
|
||||
returnUnpackAddDetail,
|
||||
@ -355,32 +450,32 @@ const storeOptions = ref<Array<{ label: string; value: number }>>([])
|
||||
// 产品状态(快速添加明细时使用)
|
||||
const defaultProductStatus = ref<'normal' | 'damaged'>('normal')
|
||||
|
||||
// 货主下拉 ref
|
||||
const storeSelectRef = ref<any>(null)
|
||||
|
||||
// 焦点切换与提交确认弹窗防重
|
||||
const FOCUS_ORDER = ['waybill', 'barcode', 'store', 'none'] as const
|
||||
// 页面焦点顺序:运单号 ↔ 商品条码
|
||||
const FOCUS_ORDER = ['waybill', 'barcode'] as const
|
||||
type FocusTarget = (typeof FOCUS_ORDER)[number]
|
||||
const focusTarget = ref<FocusTarget>('waybill')
|
||||
const submitConfirmOpen = ref(false)
|
||||
const submitConfirmVisible = ref(false)
|
||||
const cancelConfirmVisible = ref(false)
|
||||
const deleteConfirmVisible = ref(false)
|
||||
const removeDetailConfirmVisible = ref(false)
|
||||
const removeDetailRow = ref<any>(null)
|
||||
const removingDetailLoading = ref(false)
|
||||
|
||||
function focusTargetElement(target: FocusTarget) {
|
||||
if (target === 'waybill') {
|
||||
waybillInputRef.value?.focus()
|
||||
} else if (target === 'barcode') {
|
||||
detailBarcodeRef.value?.focus()
|
||||
} else if (target === 'store') {
|
||||
storeSelectRef.value?.focus()
|
||||
} else {
|
||||
const active = document.activeElement as HTMLElement | null
|
||||
active?.blur?.()
|
||||
}
|
||||
}
|
||||
|
||||
function moveFocus(direction: 1 | -1) {
|
||||
const idx = FOCUS_ORDER.indexOf(focusTarget.value)
|
||||
const next = (idx + direction + FOCUS_ORDER.length) % FOCUS_ORDER.length
|
||||
const target = FOCUS_ORDER[next] as FocusTarget
|
||||
const order = FOCUS_ORDER
|
||||
const idx = order.indexOf(focusTarget.value)
|
||||
const base = idx >= 0 ? idx : direction > 0 ? -1 : 0
|
||||
const next = (base + direction + order.length) % order.length
|
||||
const target = order[next] as FocusTarget
|
||||
focusTarget.value = target
|
||||
focusTargetElement(target)
|
||||
}
|
||||
@ -499,6 +594,15 @@ function statusLabel(val: any): string {
|
||||
return map[String(val)] ?? String(val ?? '-')
|
||||
}
|
||||
|
||||
/** 明细商品图片(与 UnpackDetailTable 一致:stock / stockWarehouse 上的 image_url) */
|
||||
function detailImage(row: any): string {
|
||||
return row?.stock?.image_url?.[0] ?? row?.stockWarehouse?.image_url?.[0] ?? row?.image_url?.[0] ?? ''
|
||||
}
|
||||
|
||||
function detailImages(row: any): string[] {
|
||||
return row?.stock?.image_url ?? row?.stockWarehouse?.image_url ?? row?.image_url ?? []
|
||||
}
|
||||
|
||||
function handleScan() {
|
||||
waybillCode.value = ''
|
||||
waybillInputRef.value?.focus()
|
||||
@ -530,9 +634,10 @@ async function handleCreate() {
|
||||
addStoreCandidate(recordStoreId, data.store_remark || '')
|
||||
}
|
||||
ElMessage.success(`拆包单创建成功,ID ${data.id}`)
|
||||
waybillCode.value = ''
|
||||
// 保留输入的运单号显示在锁定的输入框中(创建后运单号置灰不可改)
|
||||
loadUnpackList()
|
||||
loadDetailList()
|
||||
focusTarget.value = 'barcode'
|
||||
nextTick(() => {
|
||||
detailBarcodeRef.value?.focus()
|
||||
})
|
||||
@ -760,6 +865,10 @@ async function quickAddDetail(item: any) {
|
||||
detailBarcode.value = ''
|
||||
ElMessage.success('相同商品数量已累加')
|
||||
loadDetailList()
|
||||
focusTarget.value = 'barcode'
|
||||
nextTick(() => {
|
||||
detailBarcodeRef.value?.focus()
|
||||
})
|
||||
} else {
|
||||
ElMessage.error(res?.message || '明细累加失败')
|
||||
}
|
||||
@ -776,6 +885,10 @@ async function quickAddDetail(item: any) {
|
||||
detailBarcode.value = ''
|
||||
ElMessage.success('明细添加成功')
|
||||
loadDetailList()
|
||||
focusTarget.value = 'barcode'
|
||||
nextTick(() => {
|
||||
detailBarcodeRef.value?.focus()
|
||||
})
|
||||
} else {
|
||||
ElMessage.error(res?.message || '明细添加失败')
|
||||
}
|
||||
@ -910,6 +1023,7 @@ function resetWorkState() {
|
||||
selectedStoreId.value = null
|
||||
storeOptions.value = []
|
||||
defaultProductStatus.value = 'normal'
|
||||
focusTarget.value = 'waybill'
|
||||
}
|
||||
|
||||
function focusWaybill() {
|
||||
@ -919,26 +1033,31 @@ function focusWaybill() {
|
||||
})
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
/** 清除当前拆包单信息,恢复创建拆包单页面 */
|
||||
function handleClearInfo() {
|
||||
resetWorkState()
|
||||
loadUnpackList()
|
||||
focusWaybill()
|
||||
}
|
||||
|
||||
/** 打开「提交确认」弹窗 */
|
||||
function handleSubmit() {
|
||||
const id = createResult.value?.id
|
||||
if (!id || submitConfirmOpen.value) return
|
||||
submitConfirmOpen.value = true
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
'确认提交拆包单?提交后转为已完成终态,不可再录/移除明细。',
|
||||
'提交确认',
|
||||
{ type: 'warning', confirmButtonText: '提交', cancelButtonText: '取消' }
|
||||
)
|
||||
} catch {
|
||||
submitConfirmOpen.value = false
|
||||
return
|
||||
}
|
||||
submitConfirmOpen.value = false
|
||||
if (!id) return
|
||||
submitConfirmVisible.value = true
|
||||
}
|
||||
|
||||
/** 确认提交拆包 */
|
||||
async function confirmSubmit() {
|
||||
const id = createResult.value?.id
|
||||
if (!id || submitLoading.value) return
|
||||
submitLoading.value = true
|
||||
try {
|
||||
const res: any = await returnUnpackSubmit({ id })
|
||||
if (isOk(res)) {
|
||||
ElMessage.success('提交成功')
|
||||
submitConfirmVisible.value = false
|
||||
// 提交后自动清除信息,恢复创建页面
|
||||
resetWorkState()
|
||||
loadUnpackList()
|
||||
focusWaybill()
|
||||
@ -952,23 +1071,24 @@ async function handleSubmit() {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleCancel() {
|
||||
/** 打开「取消拆包确认」弹窗 */
|
||||
function handleCancel() {
|
||||
const id = createResult.value?.id
|
||||
if (!id) return
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
'确认取消拆包单?取消将硬删除该单及全部明细,不可恢复。',
|
||||
'取消拆包确认',
|
||||
{ type: 'warning', confirmButtonText: '取消拆包', cancelButtonText: '返回' }
|
||||
)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
cancelConfirmVisible.value = true
|
||||
}
|
||||
|
||||
/** 确认取消拆包 */
|
||||
async function confirmCancel() {
|
||||
const id = createResult.value?.id
|
||||
if (!id || cancelLoading.value) return
|
||||
cancelLoading.value = true
|
||||
try {
|
||||
const res: any = await returnUnpackCancel({ id })
|
||||
if (isOk(res)) {
|
||||
ElMessage.success('已取消拆包单')
|
||||
cancelConfirmVisible.value = false
|
||||
// 取消后自动清除信息,恢复创建页面
|
||||
resetWorkState()
|
||||
loadUnpackList()
|
||||
} else {
|
||||
@ -981,23 +1101,23 @@ async function handleCancel() {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDeleteUnpack() {
|
||||
/** 打开「删除确认」弹窗 */
|
||||
function handleDeleteUnpack() {
|
||||
const id = createResult.value?.id
|
||||
if (!id) return
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
'确认删除拆包单?删除为物理删除(含全部明细),不可恢复。',
|
||||
'删除确认',
|
||||
{ type: 'warning', confirmButtonText: '删除', cancelButtonText: '取消' }
|
||||
)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
deleteConfirmVisible.value = true
|
||||
}
|
||||
|
||||
/** 确认删除拆包 */
|
||||
async function confirmDelete() {
|
||||
const id = createResult.value?.id
|
||||
if (!id || deleteLoading.value) return
|
||||
deleteLoading.value = true
|
||||
try {
|
||||
const res: any = await returnUnpackDelete({ id })
|
||||
if (isOk(res)) {
|
||||
ElMessage.success('删除成功')
|
||||
deleteConfirmVisible.value = false
|
||||
resetWorkState()
|
||||
loadUnpackList()
|
||||
} else {
|
||||
@ -1011,24 +1131,48 @@ async function handleDeleteUnpack() {
|
||||
}
|
||||
|
||||
// ==================== 键盘快捷键 ====================
|
||||
// 快捷键分为「页面部分」与「表单部分」:
|
||||
// - 页面部分(未打开弹窗时):←/→ 在 运单号/商品条码 间切换焦点,回车提交,Esc 清除已终态信息
|
||||
// - 表单部分(商品选择弹窗打开时):←/→ 在搜索框/商品列表间切换,↑/↓ 切换商品
|
||||
// 弹窗打开时页面快捷键不生效,两者互不干扰。
|
||||
|
||||
function handleKeydown(e: KeyboardEvent) {
|
||||
const el = e.target as HTMLElement | null
|
||||
const tag = el?.tagName?.toUpperCase()
|
||||
const isTyping = tag === 'INPUT' || tag === 'TEXTAREA' || el?.isContentEditable === true
|
||||
const inSelect = el?.closest?.('.el-select') != null
|
||||
const inDetailTable = el?.closest?.('.detail-table') != null
|
||||
const isNumberInput = tag === 'INPUT' && (el?.className?.includes('el-input-number') ?? false)
|
||||
|
||||
// 左/右方向键:在 运单号 → 商品条码 → 货主 → 无选中 间循环切换焦点(备注文本域除外)
|
||||
// 表单(弹窗)打开时:交给弹窗自身的快捷键处理,页面快捷键不生效
|
||||
if (stockPickerVisible.value || quickAddPickerVisible.value || detailFormVisible.value) {
|
||||
return
|
||||
}
|
||||
|
||||
// 左/右方向键:在 运单号 ↔ 商品条码 间切换焦点(明细表内备注/数量编辑不触发)
|
||||
if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {
|
||||
if (tag === 'TEXTAREA') return
|
||||
if (tag === 'TEXTAREA' || isNumberInput || inDetailTable) return
|
||||
e.preventDefault()
|
||||
moveFocus(e.key === 'ArrowRight' ? 1 : -1)
|
||||
return
|
||||
}
|
||||
|
||||
// 空格键:提交确认(输入框/下拉内不触发;确认弹窗打开时不重复触发)
|
||||
if (e.code === 'Space' || e.key === ' ') {
|
||||
if (isTyping || inSelect || submitConfirmOpen.value) return
|
||||
// 回车/空格:表单打开时=该表单的确认动作;未打开表单时(不在输入框/下拉/按钮内)=提交确认
|
||||
if (e.key === 'Enter' || e.code === 'Space' || e.key === ' ') {
|
||||
if (isTyping || inSelect || tag === 'BUTTON') return
|
||||
|
||||
// 1) 受控确认弹窗打开:回车/空格 = 该表单的确认动作
|
||||
if (cancelConfirmVisible.value) { e.preventDefault(); confirmCancel(); return }
|
||||
if (submitConfirmVisible.value) { e.preventDefault(); confirmSubmit(); return }
|
||||
if (deleteConfirmVisible.value) { e.preventDefault(); confirmDelete(); return }
|
||||
if (removeDetailConfirmVisible.value) { e.preventDefault(); confirmRemoveDetail(); return }
|
||||
|
||||
// 2) 其他弹窗打开(摄像头/添加明细/商品选择):不触发页面提交
|
||||
if (cameraSettingsVisible.value || detailFormVisible.value || stockPickerVisible.value || quickAddPickerVisible.value) {
|
||||
return
|
||||
}
|
||||
|
||||
// 3) 无任何表单打开:提交确认
|
||||
const record = createResult.value?.record
|
||||
if (createResult.value?.id && record?.status === 'unpacking') {
|
||||
e.preventDefault()
|
||||
@ -1037,25 +1181,32 @@ function handleKeydown(e: KeyboardEvent) {
|
||||
return
|
||||
}
|
||||
|
||||
// 回车键:无选中状态下确认提交
|
||||
if (e.key === 'Enter') {
|
||||
if (focusTarget.value === 'none' && !submitConfirmOpen.value) {
|
||||
const record = createResult.value?.record
|
||||
if (createResult.value?.id && record?.status === 'unpacking') {
|
||||
e.preventDefault()
|
||||
handleSubmit()
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
// Esc:打开表单时关闭表单;未打开任何表单时打开「取消拆包确认」
|
||||
if (e.key === 'Escape') {
|
||||
// 焦点是否在某个弹窗/遮罩内
|
||||
const inOverlay = el?.closest?.('.el-overlay') != null
|
||||
|
||||
// 上/下方向键:切换产品状态(textarea/数字输入框/下拉内不触发)
|
||||
if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
|
||||
const isNumberInput = tag === 'INPUT' && (el?.className?.includes('el-input-number') ?? false)
|
||||
if (tag === 'TEXTAREA' || isNumberInput || inSelect || el?.isContentEditable === true) return
|
||||
// 1) 已打开受控确认弹窗:Esc 关闭之(不打开取消拆包确认)
|
||||
if (cancelConfirmVisible.value) { cancelConfirmVisible.value = false; return }
|
||||
if (submitConfirmVisible.value) { submitConfirmVisible.value = false; return }
|
||||
if (deleteConfirmVisible.value) { deleteConfirmVisible.value = false; return }
|
||||
if (removeDetailConfirmVisible.value) { removeDetailConfirmVisible.value = false; return }
|
||||
|
||||
// 2) 其他弹窗打开(摄像头/添加明细/商品选择)或焦点在遮罩内:交给弹窗原生 Esc 关闭
|
||||
if (inOverlay || cameraSettingsVisible.value || detailFormVisible.value || stockPickerVisible.value || quickAddPickerVisible.value) {
|
||||
return
|
||||
}
|
||||
|
||||
// 3) 无任何表单打开:拆包中打开「取消拆包确认」;已提交/已取消时清除信息
|
||||
const record = createResult.value?.record
|
||||
if (!createResult.value?.id) return
|
||||
e.preventDefault()
|
||||
defaultProductStatus.value = e.key === 'ArrowUp' ? 'normal' : 'damaged'
|
||||
if (record?.status === 'unpacking') {
|
||||
e.preventDefault()
|
||||
handleCancel()
|
||||
} else if (record?.status === 'completed' || record?.status === 'cancelled') {
|
||||
e.preventDefault()
|
||||
handleClearInfo()
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -1157,28 +1308,34 @@ async function handleSaveDetail(row: any) {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleRemoveDetail(row: any) {
|
||||
/** 打开「移除明细确认」弹窗 */
|
||||
function handleRemoveDetail(row: any) {
|
||||
const unpackId = createResult.value?.id
|
||||
if (!unpackId) return
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`确认移除该明细(明细ID ${row.id})?移除为物理删除,不可恢复。`,
|
||||
'移除明细确认',
|
||||
{ type: 'warning', confirmButtonText: '移除', cancelButtonText: '取消' }
|
||||
)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
if (!unpackId || !row?.id) return
|
||||
removeDetailRow.value = row
|
||||
removeDetailConfirmVisible.value = true
|
||||
}
|
||||
|
||||
/** 确认移除明细 */
|
||||
async function confirmRemoveDetail() {
|
||||
const unpackId = createResult.value?.id
|
||||
const row = removeDetailRow.value
|
||||
if (!unpackId || !row?.id || removingDetailLoading.value) return
|
||||
removingDetailLoading.value = true
|
||||
try {
|
||||
const res: any = await returnUnpackRemoveDetail({ id: unpackId, detail_id: row.id })
|
||||
if (isOk(res)) {
|
||||
ElMessage.success('明细移除成功')
|
||||
removeDetailConfirmVisible.value = false
|
||||
removeDetailRow.value = null
|
||||
loadDetailList()
|
||||
} else {
|
||||
ElMessage.error(res?.message || '明细移除失败')
|
||||
}
|
||||
} catch {
|
||||
// 请求层已提示错误
|
||||
} finally {
|
||||
removingDetailLoading.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -1233,6 +1390,13 @@ async function handleRemoveDetail(row: any) {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.shortcut-tips-sub {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #909399;
|
||||
margin: 10px 0 6px;
|
||||
}
|
||||
|
||||
.shortcut-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@ -1332,6 +1496,17 @@ async function handleRemoveDetail(row: any) {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.order-items-block {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.order-items-title {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
/* 摄像头设置弹窗 */
|
||||
.camera-settings-body {
|
||||
min-height: 200px;
|
||||
@ -1345,6 +1520,12 @@ async function handleRemoveDetail(row: any) {
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
.cancel-confirm-tip {
|
||||
font-size: 14px;
|
||||
color: #606266;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.camera-checkbox-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@ -1437,6 +1618,12 @@ async function handleRemoveDetail(row: any) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.stock-thumb {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.inline-number {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
39
src/views/storage/log/component/TransactionDetail.vue
Normal file
39
src/views/storage/log/component/TransactionDetail.vue
Normal file
@ -0,0 +1,39 @@
|
||||
<template>
|
||||
<div class="transaction-detail">
|
||||
<el-descriptions :column="2" border size="small">
|
||||
<el-descriptions-item label="交易类型">
|
||||
<el-tag
|
||||
:type="row?.transaction_type === 'INBOUND' ? 'success' : 'danger'"
|
||||
size="small"
|
||||
>
|
||||
{{ row?.transaction_type === 'INBOUND' ? '入库' : '出库' }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="商品ID">{{ row?.stock_id ?? '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="库位ID">{{ row?.space_id ?? '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="仓库ID">{{ row?.warehouse_id ?? '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="货主ID">{{ row?.store_id ?? '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="订单类型">{{ getOrderTypeLabel(row?.order_type) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="操作人">{{ row?.operator_name ?? '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="数量">{{ row?.quantity ?? '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="记录数">{{ row?.record_count ?? '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="首次创建" :span="2">{{ formatDateTime(row?.first_created_at) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="最后创建" :span="2">{{ formatDateTime(row?.last_created_at) }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { formatDateTime, getOrderTypeLabel } from '../log-config'
|
||||
|
||||
defineProps<{
|
||||
id?: string | number | null
|
||||
row?: any
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.transaction-detail {
|
||||
padding: 12px;
|
||||
}
|
||||
</style>
|
||||
28
src/views/storage/log/component/TransactionStockItem.vue
Normal file
28
src/views/storage/log/component/TransactionStockItem.vue
Normal file
@ -0,0 +1,28 @@
|
||||
<template>
|
||||
<div class="transaction-stock-item">
|
||||
<el-descriptions :column="2" border size="small">
|
||||
<el-descriptions-item label="商品编码">{{ stockItem?.item_code || '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="商品名称">{{ stockItem?.item_name || '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="规格">{{ stockItem?.sku_property || '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="库存单位">{{ stockItem?.stock_unit || '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="商品ID">{{ stockItem?.id ?? row?.stock_id ?? '—' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
|
||||
const props = defineProps<{
|
||||
id?: string | number | null
|
||||
row?: any
|
||||
}>()
|
||||
|
||||
const stockItem = computed(() => props.row?.stockItem || null)
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.transaction-stock-item {
|
||||
padding: 12px;
|
||||
}
|
||||
</style>
|
||||
@ -81,32 +81,21 @@
|
||||
/>
|
||||
<div v-if="selectedLogId" class="lower-level" :class="tableSize" :style="lowerPaneStyle">
|
||||
<div class="detail-header">
|
||||
<div class="detail-info">
|
||||
<span class="detail-title">出入库记录详情</span>
|
||||
</div>
|
||||
<el-tabs v-model="activeTab" class="detail-tab">
|
||||
<el-tab-pane label="基础信息" name="detail" />
|
||||
<!-- <el-tab-pane label="商品信息" name="stockItem" /> -->
|
||||
</el-tabs>
|
||||
</div>
|
||||
|
||||
<div class="detail-container">
|
||||
<el-descriptions :data="selectedRowData" size="small" border :column="2">
|
||||
<el-descriptions-item label="交易类型">
|
||||
<el-tag
|
||||
:type="selectedRowData.transaction_type === 'INBOUND' ? 'success' : 'danger'"
|
||||
size="small"
|
||||
>
|
||||
{{ selectedRowData.transaction_type === 'INBOUND' ? '入库' : '出库' }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="商品ID">{{ selectedRowData.stock_id }}</el-descriptions-item>
|
||||
<el-descriptions-item label="库位ID">{{ selectedRowData.space_id }}</el-descriptions-item>
|
||||
<el-descriptions-item label="仓库ID">{{ selectedRowData.warehouse_id }}</el-descriptions-item>
|
||||
<el-descriptions-item label="货主ID">{{ selectedRowData.store_id }}</el-descriptions-item>
|
||||
<el-descriptions-item label="订单类型">{{ getOrderTypeLabel(selectedRowData.order_type) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="操作人">{{ selectedRowData.operator_name }}</el-descriptions-item>
|
||||
<el-descriptions-item label="数量">{{ selectedRowData.quantity }}</el-descriptions-item>
|
||||
<el-descriptions-item label="记录数">{{ selectedRowData.record_count }}</el-descriptions-item>
|
||||
<el-descriptions-item label="首次创建" :span="2">{{ formatDateTime(selectedRowData.first_created_at) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="最后创建" :span="2">{{ formatDateTime(selectedRowData.last_created_at) }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<KeepAlive>
|
||||
<component
|
||||
:is="activeComponent"
|
||||
class="transaction-detail-pane"
|
||||
:id="selectedLogId"
|
||||
:row="selectedRowData"
|
||||
/>
|
||||
</KeepAlive>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -141,6 +130,8 @@ import {
|
||||
transactionTypeConfig,
|
||||
getOrderTypeLabel
|
||||
} from './log-config'
|
||||
import TransactionDetail from './component/TransactionDetail.vue'
|
||||
import TransactionStockItem from './component/TransactionStockItem.vue'
|
||||
import { useSettingsStore } from '@/stores/modules/settings'
|
||||
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
|
||||
import dayjs from 'dayjs'
|
||||
@ -245,6 +236,14 @@ const selectedRowData = computed(() => {
|
||||
return list.value.find(item => item.id === selectedLogId.value) || {}
|
||||
})
|
||||
|
||||
/** 详情 tab 组件映射(对齐 storage/receiving 详情结构) */
|
||||
const activeTab = ref('detail')
|
||||
const componentMap: Record<string, any> = {
|
||||
detail: TransactionDetail,
|
||||
stockItem: TransactionStockItem
|
||||
}
|
||||
const activeComponent = computed(() => componentMap[activeTab.value] || componentMap.detail)
|
||||
|
||||
onMounted(() => {
|
||||
loadFilterData()
|
||||
loadData()
|
||||
|
||||
@ -0,0 +1,69 @@
|
||||
<template>
|
||||
<div class="productflow-detail">
|
||||
<el-descriptions :column="2" border size="small">
|
||||
<el-descriptions-item label="流水ID">{{ row?.id ?? '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="流水时间">{{ formatDateTime(row?.created_at) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="流水类型">
|
||||
<el-tag size="small" :type="getTransactionTypeTag(row?.transaction_type)" effect="light">
|
||||
{{ getTransactionTypeLabel(row?.transaction_type) }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="操作人">{{ row?.operator_name || '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="商品ID">{{ row?.stock_id ?? '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="货主ID">{{ row?.store_id ?? '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="仓库ID">{{ row?.warehouse_id ?? '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="批次号">{{ row?.batch_no || '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="变动数量">
|
||||
<span :class="getQuantityClass(row)">{{ formatQuantityDisplay(row) }}</span>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="可用库存">
|
||||
{{ row?.before_quantity ?? '—' }} → {{ row?.after_quantity ?? '—' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="锁定库存">
|
||||
{{ row?.before_locked_quantity ?? '—' }} → {{ row?.after_locked_quantity ?? '—' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="订单类型">{{ getOrderTypeLabel(row?.order_type) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="订单号">{{ row?.order_no || '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="订单ID">{{ row?.order_id || '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="收货单ID">{{ row?.receiving_id || '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="入库单ID">{{ row?.entry_order_id || '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="备注" :span="2">{{ row?.remark || '—' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
formatDateTime,
|
||||
getTransactionTypeLabel,
|
||||
getTransactionTypeTag,
|
||||
getOrderTypeLabel,
|
||||
formatQuantityDisplay,
|
||||
getQuantityClass
|
||||
} from '../productflow-config'
|
||||
|
||||
defineProps<{
|
||||
id?: number | string | null
|
||||
row?: any
|
||||
}>()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.productflow-detail {
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.qty-up {
|
||||
color: var(--el-color-success);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.qty-down {
|
||||
color: var(--el-color-danger);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.qty-flat {
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
</style>
|
||||
@ -0,0 +1,28 @@
|
||||
<template>
|
||||
<div class="productflow-stock-item">
|
||||
<el-descriptions :column="2" border size="small">
|
||||
<el-descriptions-item label="商品ID">{{ stockItem?.id ?? row?.stock_id ?? '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="商品编码">{{ stockItem?.item_code || '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="商品名称">{{ stockItem?.item_name || '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="规格">{{ stockItem?.sku_property || '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="库存单位">{{ stockItem?.stock_unit || '—' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
|
||||
const props = defineProps<{
|
||||
id?: number | string | null
|
||||
row?: any
|
||||
}>()
|
||||
|
||||
const stockItem = computed(() => props.row?.stockItem || null)
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.productflow-stock-item {
|
||||
padding: 12px;
|
||||
}
|
||||
</style>
|
||||
@ -109,40 +109,20 @@
|
||||
/>
|
||||
<div v-if="selectedFlowId" class="lower-level" :class="tableSize" :style="lowerPaneStyle">
|
||||
<div class="detail-header">
|
||||
<div class="detail-info">
|
||||
<span class="detail-title">流水详情 #{{ selectedFlowId }}</span>
|
||||
</div>
|
||||
<el-tabs v-model="activeTab" class="detail-tab">
|
||||
<el-tab-pane label="基础信息" name="detail" />
|
||||
<!-- <el-tab-pane label="商品信息" name="stockItem" /> -->
|
||||
</el-tabs>
|
||||
</div>
|
||||
<div class="detail-container">
|
||||
<el-descriptions :column="2" border size="small">
|
||||
<el-descriptions-item label="流水ID">{{ selectedRowData.id }}</el-descriptions-item>
|
||||
<el-descriptions-item label="流水时间">{{ formatDateTime(selectedRowData.created_at) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="流水类型">
|
||||
<el-tag size="small" :type="getTransactionTypeTag(selectedRowData.transaction_type)" effect="light">
|
||||
{{ getTransactionTypeLabel(selectedRowData.transaction_type) }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="操作人">{{ selectedRowData.operator_name || '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="商品ID">{{ selectedRowData.stock_id ?? '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="货主ID">{{ selectedRowData.store_id ?? '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="仓库ID">{{ selectedRowData.warehouse_id ?? '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="批次号">{{ selectedRowData.batch_no || '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="变动数量">
|
||||
<span :class="getQuantityClass(selectedRowData)">{{ formatQuantityDisplay(selectedRowData) }}</span>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="可用库存">
|
||||
{{ selectedRowData.before_quantity ?? '—' }} → {{ selectedRowData.after_quantity ?? '—' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="锁定库存">
|
||||
{{ selectedRowData.before_locked_quantity ?? '—' }} → {{ selectedRowData.after_locked_quantity ?? '—' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="订单类型">{{ getOrderTypeLabel(selectedRowData.order_type) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="订单号">{{ selectedRowData.order_no || '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="订单ID">{{ selectedRowData.order_id || '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="收货单ID">{{ selectedRowData.receiving_id || '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="入库单ID">{{ selectedRowData.entry_order_id || '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="备注" :span="2">{{ selectedRowData.remark || '—' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<KeepAlive>
|
||||
<component
|
||||
:is="activeComponent"
|
||||
class="productflow-detail-pane"
|
||||
:id="selectedFlowId"
|
||||
:row="selectedRowData"
|
||||
/>
|
||||
</KeepAlive>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="no-selection" :style="lowerPaneStyle">
|
||||
@ -194,8 +174,15 @@ import {
|
||||
getTransactionTypeLabel,
|
||||
getTransactionTypeTag,
|
||||
getOrderTypeLabel,
|
||||
formatQuantityDelta
|
||||
formatQuantityDisplay,
|
||||
formatStockQuantity,
|
||||
formatLockQuantity,
|
||||
getQuantityClass,
|
||||
getStockClass,
|
||||
getLockClass
|
||||
} from './productflow-config'
|
||||
import ProductflowDetail from './component/ProductflowDetail.vue'
|
||||
import ProductflowStockItem from './component/ProductflowStockItem.vue'
|
||||
|
||||
const scanBox = ref<any>(null)
|
||||
const upperTable = ref<any>(null)
|
||||
@ -270,6 +257,14 @@ const selectedRowData = computed(() => {
|
||||
return list.value.find(item => item.id === selectedFlowId.value) || {}
|
||||
})
|
||||
|
||||
/** 详情 tab 组件映射(对齐 storage/receiving 详情结构) */
|
||||
const activeTab = ref('detail')
|
||||
const componentMap: Record<string, any> = {
|
||||
detail: ProductflowDetail,
|
||||
stockItem: ProductflowStockItem
|
||||
}
|
||||
const activeComponent = computed(() => componentMap[activeTab.value] || componentMap.detail)
|
||||
|
||||
function resolveButtonLoading(loadingKey?: string) {
|
||||
if (!loadingKey) return false
|
||||
return Boolean((buttonLoadingMap.value as Record<string, boolean>)[loadingKey])
|
||||
@ -348,52 +343,6 @@ function normalizeToWhere(condition: any) {
|
||||
return {}
|
||||
}
|
||||
|
||||
function formatQuantityDisplay(row: any): string {
|
||||
const qty = formatQuantityDelta(row)
|
||||
if (qty === undefined || qty === null) return '—'
|
||||
if (qty > 0) return `+${qty}`
|
||||
return String(qty)
|
||||
}
|
||||
|
||||
/** 库存变动列:仅 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([
|
||||
@ -760,6 +709,48 @@ onMounted(() => {
|
||||
min-height: 42px;
|
||||
box-sizing: border-box;
|
||||
|
||||
.detail-tab {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
margin-bottom: -1px;
|
||||
|
||||
:deep(.el-tabs__header) {
|
||||
margin: 0;
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
:deep(.el-tabs__nav-wrap::after) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:deep(.el-tabs__active-bar) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:deep(.el-tabs__item) {
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
font-size: 13px;
|
||||
padding: 0 16px;
|
||||
color: #606266;
|
||||
border: 1px solid transparent;
|
||||
border-bottom: none;
|
||||
border-radius: 4px 4px 0 0;
|
||||
transition: color 0.2s;
|
||||
}
|
||||
|
||||
:deep(.el-tabs__item:hover) {
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
|
||||
:deep(.el-tabs__item.is-active) {
|
||||
color: var(--el-color-primary);
|
||||
background-color: #fff;
|
||||
border-color: #ebeef5;
|
||||
border-bottom-color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
.detail-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@ -215,3 +215,58 @@ export function formatQuantityDelta(row: {
|
||||
}
|
||||
return abs
|
||||
}
|
||||
|
||||
/** 变动数量展示文本(正数带 + 号) */
|
||||
export function formatQuantityDisplay(row: {
|
||||
quantity?: number
|
||||
before_quantity?: number
|
||||
after_quantity?: number
|
||||
transaction_type?: string
|
||||
}): string {
|
||||
const qty = formatQuantityDelta(row)
|
||||
if (qty === undefined || qty === null) return '—'
|
||||
if (qty > 0) return `+${qty}`
|
||||
return String(qty)
|
||||
}
|
||||
|
||||
/** 库存变动列:仅 INBOUND/OUTBOUND 有值,其余为 0 */
|
||||
export function formatStockQuantity(row: any): string {
|
||||
const t = (row.transaction_type || '').toUpperCase()
|
||||
if (t === 'INBOUND' || t === 'OUTBOUND') return formatQuantityDisplay(row)
|
||||
return '0'
|
||||
}
|
||||
|
||||
/** 锁定变动列:仅 LOCK/UNLOCK 有值,其余为 0 */
|
||||
export function formatLockQuantity(row: any): string {
|
||||
const t = (row.transaction_type || '').toUpperCase()
|
||||
if (t === 'LOCK' || t === 'UNLOCK') return formatQuantityDisplay(row)
|
||||
return '0'
|
||||
}
|
||||
|
||||
/** 数量颜色类:mode=stock 仅 INBOUND/OUTBOUND 有色,mode=lock 仅 LOCK/UNLOCK 有色 */
|
||||
export 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'
|
||||
}
|
||||
|
||||
/** 可用库存颜色类 */
|
||||
export function getStockClass(type?: string): string {
|
||||
const t = (type || '').toUpperCase()
|
||||
if (t === 'INBOUND') return 'stock-in'
|
||||
if (t === 'OUTBOUND') return 'stock-out'
|
||||
return ''
|
||||
}
|
||||
|
||||
/** 锁定库存颜色类 */
|
||||
export function getLockClass(type?: string): string {
|
||||
const t = (type || '').toUpperCase()
|
||||
if (t === 'LOCK') return 'lock-lock'
|
||||
if (t === 'UNLOCK') return 'lock-unlock'
|
||||
return ''
|
||||
}
|
||||
|
||||
@ -581,8 +581,9 @@ async function submitForm() {
|
||||
p.weight_type = formData.weight_type
|
||||
p.shop_name = formData.shopNameList.length ? formData.shopNameList : undefined
|
||||
p.store_ids = formData.storeIdsList.length ? formData.storeIdsList : undefined
|
||||
p.regions = formData.regionsList.length ? formData.regionsList : undefined
|
||||
p.exclude_regions = formData.excludeRegionsList.length ? formData.excludeRegionsList : undefined
|
||||
// 限定地区/排除地区无数据时传空数组(而非 undefined),确保后端能清除已有地区
|
||||
p.regions = formData.regionsList.length ? formData.regionsList : []
|
||||
p.exclude_regions = formData.excludeRegionsList.length ? formData.excludeRegionsList : []
|
||||
p.min_weight_g = formData.min_weight_g
|
||||
p.max_weight_g = formData.max_weight_g
|
||||
p.priority = formData.priority
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user