fix(data-entry): Show action buttons after saving new receipt
Vue Router reuses the component when navigating from create to view mode, so onMounted doesn't run again and loadReceipt() was never called. This left receipt.value as null, causing the Edit/Submit buttons to not appear. Added a watcher for route.params.id that loads the receipt when navigating from create to view mode, and resets the form when navigating back to create. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -914,6 +914,48 @@ const syncSuppliersIfNeeded = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// Watch for route param changes - reload receipt when navigating from create to view
|
||||
// This handles the case where Vue Router reuses the component instance
|
||||
watch(
|
||||
() => route.params.id,
|
||||
async (newId, oldId) => {
|
||||
if (newId && newId !== oldId) {
|
||||
// Navigated to a receipt (view or edit mode)
|
||||
console.log('[ReceiptCreateView] Route changed to receipt:', newId)
|
||||
await loadReceipt()
|
||||
} else if (!newId && oldId) {
|
||||
// Navigated back to create mode - reset state
|
||||
console.log('[ReceiptCreateView] Route changed to create mode')
|
||||
receipt.value = null
|
||||
existingAttachments.value = []
|
||||
selectedFiles.value = []
|
||||
ocrData.value = null
|
||||
form.value = {
|
||||
receipt_type: 'bon_fiscal',
|
||||
direction: 'cheltuiala',
|
||||
receipt_date: new Date(),
|
||||
amount: null,
|
||||
partner_name: null,
|
||||
cui: '',
|
||||
ocr_raw_text: '',
|
||||
expense_type_code: null,
|
||||
payment_mode: null,
|
||||
cash_register_id: null,
|
||||
cash_register_name: null,
|
||||
cash_register_account: null,
|
||||
receipt_number: '',
|
||||
description: '',
|
||||
company_id: getSelectedCompanyId(),
|
||||
tva_breakdown: [],
|
||||
tva_total: null,
|
||||
items_count: null,
|
||||
vendor_address: '',
|
||||
payment_methods: [],
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
// Watch for company changes - sync suppliers in background
|
||||
watch(
|
||||
() => companyStore.selectedCompany,
|
||||
|
||||
Reference in New Issue
Block a user