x
This commit is contained in:
@@ -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)"
|
||||
>
|
||||
编辑
|
||||
|
||||
@@ -212,25 +212,43 @@ export function useInventory() {
|
||||
const statusMap: Record<string, string> = {
|
||||
draft: '已下单',
|
||||
pending: '已下单',
|
||||
partial_received: '部分收货',
|
||||
received: '已收货',
|
||||
paid: '已付款'
|
||||
paid: '已付款',
|
||||
cancelled: '已作废'
|
||||
}
|
||||
return statusMap[status] || status
|
||||
}
|
||||
|
||||
const isPurchaseOrderLocked = (status: string): boolean => {
|
||||
return ['received', 'paid'].includes(status)
|
||||
return ['received', 'paid', 'cancelled'].includes(status)
|
||||
}
|
||||
|
||||
const getSalesOrderStatusLabel = (status: string): string => {
|
||||
const statusMap: Record<string, string> = {
|
||||
manufacturing: '制造中',
|
||||
delivered: '已交付',
|
||||
paid: '已收款'
|
||||
paid: '已收款',
|
||||
cancelled: '已作废'
|
||||
}
|
||||
return statusMap[status] || status
|
||||
}
|
||||
|
||||
const getDeliveryStatusLabel = (ds: string): string => {
|
||||
const map: Record<string, string> = { manufacturing: '制造中', delivered: '已交付', cancelled: '已作废' }
|
||||
return map[ds] || ds
|
||||
}
|
||||
|
||||
const getPaymentStatusLabel = (ps: string): string => {
|
||||
const map: Record<string, string> = { unpaid: '未收款', paid: '已收款' }
|
||||
return map[ps] || ps
|
||||
}
|
||||
|
||||
const getReceiptStatusLabel = (rs: string): string => {
|
||||
const map: Record<string, string> = { pending: '已下单', partial_received: '部分收货', received: '已收货', cancelled: '已作废' }
|
||||
return map[rs] || rs
|
||||
}
|
||||
|
||||
const checkBackendHealth = async () => {
|
||||
try {
|
||||
const resp = await fetch('/health', { method: 'GET' })
|
||||
@@ -468,6 +486,9 @@ export function useInventory() {
|
||||
getPurchaseOrderStatusLabel,
|
||||
isPurchaseOrderLocked,
|
||||
getSalesOrderStatusLabel,
|
||||
getDeliveryStatusLabel,
|
||||
getPaymentStatusLabel,
|
||||
getReceiptStatusLabel,
|
||||
checkBackendHealth,
|
||||
loadDashboard,
|
||||
loadFinishedProducts,
|
||||
|
||||
Reference in New Issue
Block a user