Added the Confirm Estimate reponse in the UI.
This commit is contained in:
parent
20a3517d7b
commit
d30fc77527
3 changed files with 70 additions and 21 deletions
|
|
@ -2,6 +2,7 @@
|
|||
<div class="estimate-page">
|
||||
<h2>{{ isNew ? 'Create Estimate' : 'View Estimate' }}</h2>
|
||||
<div v-if="!isNew && estimate" class="page-actions">
|
||||
<Button label="Estimate Response" @click="showResponseModal = true" />
|
||||
<Button label="Duplicate" icon="pi pi-copy" @click="duplicateEstimate" />
|
||||
</div>
|
||||
|
||||
|
|
@ -113,6 +114,18 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Manual Response Modal -->
|
||||
<Modal
|
||||
:visible="showResponseModal"
|
||||
@update:visible="showResponseModal = $event"
|
||||
@close="showResponseModal = false"
|
||||
:options="{ showActions: false }"
|
||||
>
|
||||
<template #title>Set Response</template>
|
||||
<Select v-model="estimateResponse" :options="responses" placeholder="Select Response"/>
|
||||
<Button label="Submit" @click="submitResponse"/>
|
||||
</Modal>
|
||||
|
||||
<!-- Address Search Modal -->
|
||||
<Modal
|
||||
:visible="showAddressModal"
|
||||
|
|
@ -260,14 +273,17 @@ const formData = reactive({
|
|||
|
||||
const selectedAddress = ref(null);
|
||||
const selectedContact = ref(null);
|
||||
const estimateResponse = ref(null);
|
||||
const contacts = ref([]);
|
||||
const contactOptions = ref([]);
|
||||
const quotationItems = ref([]);
|
||||
const selectedItems = ref([]);
|
||||
const responses = ref(["Accepted", "Rejected"]);
|
||||
|
||||
const showAddressModal = ref(false);
|
||||
const showAddItemModal = ref(false);
|
||||
const showConfirmationModal = ref(false);
|
||||
const showResponseModal = ref(false);
|
||||
const addressSearchResults = ref([]);
|
||||
const itemSearchTerm = ref("");
|
||||
|
||||
|
|
@ -384,7 +400,7 @@ const saveDraft = async () => {
|
|||
formData.estimateName ? "Estimate updated successfully" : "Estimate created successfully",
|
||||
"success"
|
||||
);
|
||||
|
||||
|
||||
// Redirect to view mode (remove new param)
|
||||
router.push(`/estimate?address=${encodeURIComponent(formData.address)}`);
|
||||
} catch (error) {
|
||||
|
|
@ -395,6 +411,10 @@ const saveDraft = async () => {
|
|||
}
|
||||
};
|
||||
|
||||
const submitResponse = () => {
|
||||
Api.updateEstimateResponse(estimate.value.name, estimateResponse.value, false);
|
||||
}
|
||||
|
||||
const duplicateEstimate = () => {
|
||||
if (!estimate.value) return;
|
||||
|
||||
|
|
@ -501,7 +521,7 @@ watch(
|
|||
// Reload data based on new query params
|
||||
const newIsNew = newQuery.new === "true";
|
||||
const newAddressQuery = newQuery.address;
|
||||
|
||||
|
||||
if (newAddressQuery && newIsNew) {
|
||||
// Creating new estimate - pre-fill address
|
||||
await selectAddress(newAddressQuery);
|
||||
|
|
@ -509,13 +529,13 @@ watch(
|
|||
// Viewing existing estimate - load and populate all fields
|
||||
try {
|
||||
estimate.value = await Api.getEstimateFromAddress(newAddressQuery);
|
||||
|
||||
|
||||
if (estimate.value) {
|
||||
formData.estimateName = estimate.value.name;
|
||||
await selectAddress(newAddressQuery);
|
||||
formData.contact = estimate.value.partyName;
|
||||
selectedContact.value = contacts.value.find((c) => c.name === estimate.value.partyName) || null;
|
||||
|
||||
|
||||
if (estimate.value.items && estimate.value.items.length > 0) {
|
||||
selectedItems.value = estimate.value.items.map(item => {
|
||||
const fullItem = quotationItems.value.find(qi => qi.itemCode === item.itemCode);
|
||||
|
|
@ -562,7 +582,7 @@ onMounted(async () => {
|
|||
if (estimate.value) {
|
||||
// Set the estimate name for upserting
|
||||
formData.estimateName = estimate.value.name;
|
||||
|
||||
|
||||
await selectAddress(addressQuery.value);
|
||||
// Set the contact from the estimate
|
||||
formData.contact = estimate.value.partyName;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue