refactor(stockout): 出库单页面优化
This commit is contained in:
parent
21b0249097
commit
692e5cd4a4
@ -65,6 +65,18 @@
|
|||||||
</el-tag>
|
</el-tag>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<template #column-actions="{ row }">
|
||||||
|
<el-button
|
||||||
|
v-if="row.order_status === 'CREATED' || row.order_status === 'PENDING'"
|
||||||
|
type="primary"
|
||||||
|
size="small"
|
||||||
|
:loading="row._stockoutLoading"
|
||||||
|
@click.stop="handleSingleRowStockout(row)"
|
||||||
|
>
|
||||||
|
一键出库
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
|
||||||
<template #empty>
|
<template #empty>
|
||||||
<div class="empty-tip">暂无出库单</div>
|
<div class="empty-tip">暂无出库单</div>
|
||||||
</template>
|
</template>
|
||||||
@ -240,8 +252,7 @@ const toolbarActionMap: Record<string, () => void> = {
|
|||||||
toggleDetailVisible: () => toggleDetailVisible(),
|
toggleDetailVisible: () => toggleDetailVisible(),
|
||||||
handleCreateStockout: () => handleCreateStockout(),
|
handleCreateStockout: () => handleCreateStockout(),
|
||||||
handleImport: () => handleImport(),
|
handleImport: () => handleImport(),
|
||||||
confirmBatchCancel: () => { void confirmBatchCancel() },
|
confirmBatchCancel: () => { void confirmBatchCancel() }
|
||||||
confirmStockout: () => { void confirmStockout() }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleToolbarButtonClick(action: ToolbarButtonConfig['action']) {
|
function handleToolbarButtonClick(action: ToolbarButtonConfig['action']) {
|
||||||
@ -477,6 +488,41 @@ function handleCreateStockout() {
|
|||||||
ElMessage.info('新建出库单功能')
|
ElMessage.info('新建出库单功能')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 单行一键出库 */
|
||||||
|
async function handleSingleRowStockout(row: any) {
|
||||||
|
try {
|
||||||
|
await ElMessageBox.confirm(
|
||||||
|
`确定要一键出库出库单「${row.stockout_order_code || row.id}」吗?确认后状态将变更为"已完成"。请确保已填写运单号。`,
|
||||||
|
'一键出库',
|
||||||
|
{ type: 'warning', confirmButtonText: '确认', cancelButtonText: '取消' }
|
||||||
|
)
|
||||||
|
} catch {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
row._stockoutLoading = true
|
||||||
|
try {
|
||||||
|
const res: any = await stockoutApi.stockoutConfirm({ id: row.id })
|
||||||
|
if (res && (res.code === 1 || res.code === 200 || res.code === 20000 || res.flag === 'success')) {
|
||||||
|
const data = res?.data || res
|
||||||
|
if (data?.expressCode) {
|
||||||
|
row.express_code = data.expressCode
|
||||||
|
}
|
||||||
|
if (data?.expressCodes) {
|
||||||
|
row.express_codes = data.expressCodes
|
||||||
|
}
|
||||||
|
ElMessage.success('出库成功')
|
||||||
|
loadData()
|
||||||
|
} else {
|
||||||
|
ElMessage.error(res?.message || '出库失败')
|
||||||
|
}
|
||||||
|
} catch (e: any) {
|
||||||
|
ElMessage.error(e?.message || '出库失败')
|
||||||
|
} finally {
|
||||||
|
row._stockoutLoading = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function confirmBatchCancel() {
|
async function confirmBatchCancel() {
|
||||||
if (!selectionRows.value.length) {
|
if (!selectionRows.value.length) {
|
||||||
ElMessage.warning('请先选择要作废的出库单')
|
ElMessage.warning('请先选择要作废的出库单')
|
||||||
@ -490,60 +536,6 @@ async function confirmBatchCancel() {
|
|||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function confirmStockout() {
|
|
||||||
const rows = selectionRows.value
|
|
||||||
if (!rows.length) {
|
|
||||||
ElMessage.warning('请先选择要确认出库的出库单')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 仅允许 CREATED / PENDING 状态进行确认
|
|
||||||
const confirmable = rows.filter(
|
|
||||||
(r: any) => r.order_status === 'CREATED' || r.order_status === 'PENDING'
|
|
||||||
)
|
|
||||||
if (!confirmable.length) {
|
|
||||||
ElMessage.warning('所选出库单状态不支持确认操作,仅"已创建"或"待出库"状态可确认')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
await ElMessageBox.confirm(
|
|
||||||
`确定要直出确认以下 ${confirmable.length} 个出库单吗?确认后状态将变更为"已完成"。请确保已在详情面板填写运单号。`,
|
|
||||||
'确认出库',
|
|
||||||
{ type: 'warning', confirmButtonText: '确认', cancelButtonText: '取消' }
|
|
||||||
)
|
|
||||||
} catch {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
let successCount = 0
|
|
||||||
let failCount = 0
|
|
||||||
for (const row of confirmable) {
|
|
||||||
try {
|
|
||||||
const res: any = await stockoutApi.stockoutConfirm({ id: row.id })
|
|
||||||
// 更新列表中对应行的运单信息
|
|
||||||
const data = res?.data || res
|
|
||||||
if (data?.expressCode) {
|
|
||||||
row.express_code = data.expressCode
|
|
||||||
}
|
|
||||||
if (data?.expressCodes) {
|
|
||||||
row.express_codes = data.expressCodes
|
|
||||||
}
|
|
||||||
successCount++
|
|
||||||
} catch (e: any) {
|
|
||||||
failCount++
|
|
||||||
console.error(`确认出库单 ${row.stockout_order_code || row.id} 失败`, e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (failCount === 0) {
|
|
||||||
ElMessage.success(`成功确认 ${successCount} 个出库单`)
|
|
||||||
} else {
|
|
||||||
ElMessage.warning(`确认完成:成功 ${successCount} 个,失败 ${failCount} 个`)
|
|
||||||
}
|
|
||||||
loadData()
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleExport(mode: 'waybill' | 'item' = 'waybill') {
|
async function handleExport(mode: 'waybill' | 'item' = 'waybill') {
|
||||||
const sourceRows = selectionRows.value.length ? selectionRows.value : list.value
|
const sourceRows = selectionRows.value.length ? selectionRows.value : list.value
|
||||||
if (!sourceRows.length) {
|
if (!sourceRows.length) {
|
||||||
|
|||||||
@ -42,14 +42,6 @@ export const stockoutToolbarButtons: ToolbarButtonConfig[] = [
|
|||||||
size: 'small',
|
size: 'small',
|
||||||
action: 'handleImport'
|
action: 'handleImport'
|
||||||
},
|
},
|
||||||
{
|
|
||||||
key: 'confirmStockout',
|
|
||||||
label: '确认出库',
|
|
||||||
category: 'action',
|
|
||||||
size: 'small',
|
|
||||||
disabledKey: 'hasNoSelection',
|
|
||||||
action: 'confirmStockout'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
key: 'batchCancel',
|
key: 'batchCancel',
|
||||||
label: '批量作废',
|
label: '批量作废',
|
||||||
@ -159,7 +151,8 @@ export const entryColums = [
|
|||||||
{ prop: 'remark', label: '备注', minWidth: '150' },
|
{ prop: 'remark', label: '备注', minWidth: '150' },
|
||||||
{ prop: 'order_create_time', label: '下单时间', width: '160', sortable: true, formatter: (row: any) => formatDateTime(row.order_create_time) },
|
{ prop: 'order_create_time', label: '下单时间', width: '160', sortable: true, formatter: (row: any) => formatDateTime(row.order_create_time) },
|
||||||
{ prop: 'created_at', label: '创建时间', width: '160', sortable: true, formatter: (row: any) => formatDateTime(row.created_at) },
|
{ prop: 'created_at', label: '创建时间', width: '160', sortable: true, formatter: (row: any) => formatDateTime(row.created_at) },
|
||||||
{ prop: 'updated_at', label: '更新时间', width: '160', sortable: true, formatter: (row: any) => formatDateTime(row.updated_at) }
|
{ prop: 'updated_at', label: '更新时间', width: '160', sortable: true, formatter: (row: any) => formatDateTime(row.updated_at) },
|
||||||
|
{ prop: 'actions', label: '操作', width: '120', fixed: 'right' }
|
||||||
]
|
]
|
||||||
|
|
||||||
export const availableFields: StockoutScanFieldConfig[] = [
|
export const availableFields: StockoutScanFieldConfig[] = [
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user