x
This commit is contained in:
@@ -38,12 +38,14 @@ const editingItem = ref<any>(null)
|
||||
const form = ref<any>({})
|
||||
const orderItems = ref<any[]>([])
|
||||
const purchaseWarehouseId = ref<number | null>(null)
|
||||
const saving = ref(false)
|
||||
|
||||
const showReceiveModal = ref(false)
|
||||
const receivingOrder = ref<any>(null)
|
||||
const receiveItems = ref<any[]>([])
|
||||
const receiveWarehouseId = ref<number | null>(null)
|
||||
const receiveRemark = ref('')
|
||||
const receiving = ref(false)
|
||||
|
||||
function openCreateOrder() {
|
||||
editingItem.value = null
|
||||
@@ -99,6 +101,7 @@ async function editOrder(order: any) {
|
||||
}
|
||||
|
||||
async function savePurchaseOrder() {
|
||||
if (saving.value) return
|
||||
if (!form.value.supplier_id) {
|
||||
addNotification('请选择供应商', 'warning')
|
||||
return
|
||||
@@ -117,6 +120,7 @@ async function savePurchaseOrder() {
|
||||
return
|
||||
}
|
||||
}
|
||||
saving.value = true
|
||||
try {
|
||||
const payload = {
|
||||
supplier_id: form.value.supplier_id,
|
||||
@@ -148,6 +152,8 @@ async function savePurchaseOrder() {
|
||||
loadPurchaseOrders()
|
||||
} catch (e) {
|
||||
handleApiError(e, '保存采购订单')
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,6 +189,7 @@ async function openReceiveDialog(order: any) {
|
||||
}
|
||||
|
||||
async function receivePurchaseOrder() {
|
||||
if (receiving.value) return
|
||||
if (!receiveWarehouseId.value) {
|
||||
addNotification('请选择入库仓库', 'warning')
|
||||
return
|
||||
@@ -197,6 +204,7 @@ async function receivePurchaseOrder() {
|
||||
addNotification('请输入本次入库数量', 'warning')
|
||||
return
|
||||
}
|
||||
receiving.value = true
|
||||
try {
|
||||
await apiRequest(`/api/purchase-orders/${receivingOrder.value.id}/receive`, {
|
||||
method: 'POST',
|
||||
@@ -215,6 +223,8 @@ async function receivePurchaseOrder() {
|
||||
loadMovements()
|
||||
} catch (e) {
|
||||
handleApiError(e, '采购入库')
|
||||
} finally {
|
||||
receiving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -456,8 +466,8 @@ onMounted(() => {
|
||||
订单总金额:{{ formatCurrency(orderTotalAmount) }}
|
||||
</div>
|
||||
<template #footer>
|
||||
<t-button @click="showModal = false">取消</t-button>
|
||||
<t-button type="primary" @click="savePurchaseOrder">保存</t-button>
|
||||
<t-button @click="showModal = false" :disabled="saving">取消</t-button>
|
||||
<t-button type="primary" :loading="saving" :disabled="saving" @click="savePurchaseOrder">保存</t-button>
|
||||
</template>
|
||||
</t-dialog>
|
||||
|
||||
@@ -501,8 +511,8 @@ onMounted(() => {
|
||||
</t-table-column>
|
||||
</t-table>
|
||||
<template #footer>
|
||||
<t-button @click="showReceiveModal = false">取消</t-button>
|
||||
<t-button type="primary" @click="receivePurchaseOrder">确认入库</t-button>
|
||||
<t-button @click="showReceiveModal = false" :disabled="receiving">取消</t-button>
|
||||
<t-button type="primary" :loading="receiving" :disabled="receiving" @click="receivePurchaseOrder">确认入库</t-button>
|
||||
</template>
|
||||
</t-dialog>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user