This commit is contained in:
2026-06-09 13:44:53 +08:00
parent 5d73a7d036
commit fa2178fbd8
18 changed files with 168 additions and 40 deletions
@@ -10,6 +10,8 @@ const {
formatDateTime,
formatDate,
getPurchaseOrderStatusLabel,
getReceiptStatusLabel,
getPaymentStatusLabel,
isPurchaseOrderLocked,
loadPurchaseOrders,
loadSuppliers,
@@ -218,6 +220,23 @@ async function markAsPaid(orderId: number) {
}
}
async function updateStatus(orderId: number, status: string) {
const label = status === 'cancelled' ? '作废' : status
if (!confirm(`确认${label}该订单?`)) return
try {
await apiRequest(`/api/purchase-orders/${orderId}/status`, {
method: 'PATCH',
body: JSON.stringify({ status })
})
addNotification(`订单已${label}`, 'success')
loadPurchaseOrders()
loadMovements()
loadInventory()
} catch (e) {
handleApiError(e, '更新状态')
}
}
function closeModal() {
showModal.value = false
editingItem.value = null
@@ -267,9 +286,16 @@ onMounted(() => {
<el-table-column prop="supplier_name" label="供应商" />
<el-table-column label="状态">
<template #default="{ row }">
<el-tag :type="row.status === 'received' ? 'success' : row.status === 'paid' ? 'info' : 'warning'">
{{ getPurchaseOrderStatusLabel(row.status) }}
</el-tag>
<div style="display: flex; gap: 4px;">
<el-tag
:type="row.receipt_status === 'received' ? 'success' : row.receipt_status === 'partial_received' ? 'warning' : row.receipt_status === 'cancelled' ? 'danger' : 'info'"
size="small"
>{{ getReceiptStatusLabel(row.receipt_status) }}</el-tag>
<el-tag
:type="row.payment_status === 'paid' ? 'success' : 'info'"
size="small"
>{{ getPaymentStatusLabel(row.payment_status) }}</el-tag>
</div>
</template>
</el-table-column>
<el-table-column label="订单创建">
@@ -309,7 +335,7 @@ onMounted(() => {
删除
</el-button>
<el-button
v-if="row.status === 'pending'"
v-if="row.receipt_status === 'pending' || row.receipt_status === 'partial_received'"
type="success"
size="small"
@click="openReceiveDialog(row)"
@@ -317,13 +343,21 @@ onMounted(() => {
到货入库
</el-button>
<el-button
v-if="row.status === 'received'"
v-if="row.receipt_status === 'received' && row.payment_status !== 'paid'"
type="warning"
size="small"
@click="markAsPaid(row.id)"
>
标记为已付款
</el-button>
<el-button
v-if="row.payment_status !== 'paid' && row.receipt_status !== 'cancelled'"
type="info"
size="small"
@click="updateStatus(row.id, 'cancelled')"
>
作废
</el-button>
</template>
</el-table-column>
</el-table>
@@ -10,6 +10,8 @@ const {
formatDateTime,
formatDate,
getSalesOrderStatusLabel,
getDeliveryStatusLabel,
getPaymentStatusLabel,
loadProductionOrders,
loadFinishedProducts,
loadCustomers,
@@ -309,30 +311,36 @@ onMounted(() => {
<el-table-column label="实际收款">
<template #default="{ row }">{{ row.paid_at ? formatDateTime(row.paid_at) : '-' }}</template>
</el-table-column>
<el-table-column label="订单状态">
<el-table-column label="订单状态" width="160">
<template #default="{ row }">
<el-tag :type="row.status === 'paid' ? 'success' : row.status === 'delivered' ? 'warning' : 'info'">
{{ getSalesOrderStatusLabel(row.status) }}
</el-tag>
<div style="display: flex; gap: 4px;">
<el-tag
:type="row.delivery_status === 'delivered' ? 'warning' : row.delivery_status === 'cancelled' ? 'danger' : 'info'"
size="small"
>{{ getDeliveryStatusLabel(row.delivery_status) }}</el-tag>
<el-tag
:type="row.payment_status === 'paid' ? 'success' : 'info'"
size="small"
>{{ getPaymentStatusLabel(row.payment_status) }}</el-tag>
</div>
</template>
</el-table-column>
<el-table-column label="操作" width="240">
<template #default="{ row }">
<el-dropdown style="margin-right: 8px;">
<el-button size="small">
状态 ▾
</el-button>
<el-dropdown style="margin-right: 8px;" v-if="row.delivery_status !== 'cancelled' && row.payment_status !== 'paid'">
<el-button size="small">状态 ▾</el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item @click="updateStatus(row.id, 'delivered')">已交付</el-dropdown-item>
<el-dropdown-item @click="updateStatus(row.id, 'paid')">已收款</el-dropdown-item>
<el-dropdown-item v-if="row.delivery_status === 'manufacturing'" @click="updateStatus(row.id, 'delivered')">已交付</el-dropdown-item>
<el-dropdown-item v-if="row.delivery_status === 'delivered' && row.payment_status !== 'paid'" @click="updateStatus(row.id, 'paid')">已收款</el-dropdown-item>
<el-dropdown-item v-if="row.payment_status !== 'paid'" @click="updateStatus(row.id, 'cancelled')" style="color: #f56c6c;">作废</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
<el-button
type="primary"
size="small"
:disabled="row.status === 'paid'"
:disabled="row.payment_status === 'paid' || row.delivery_status === 'cancelled'"
@click="editOrder(row)"
>
编辑