bug fixes and calendar fixes
This commit is contained in:
parent
0ec89a1269
commit
6cd3d138ad
9 changed files with 446 additions and 270 deletions
|
|
@ -444,6 +444,7 @@ const nameQuery = computed(() => route.query.name || "");
|
|||
const templateQuery = computed(() => route.query.template || "");
|
||||
const fromMeetingQuery = computed(() => route.query["from-meeting"] || "");
|
||||
const contactQuery = computed(() => route.query.contact || "");
|
||||
const projectTemplateQuery = computed(() => route.query["project-template"] || "");
|
||||
const isNew = computed(() => route.query.new === "true");
|
||||
|
||||
const isSubmitting = ref(false);
|
||||
|
|
@ -457,7 +458,7 @@ const formData = reactive({
|
|||
estimateName: null,
|
||||
requiresHalfPayment: false,
|
||||
projectTemplate: null,
|
||||
fromMeeting: null,
|
||||
fromOnsiteMeeting: null,
|
||||
});
|
||||
|
||||
const selectedAddress = ref(null);
|
||||
|
|
@ -757,7 +758,7 @@ const saveDraft = async () => {
|
|||
estimateName: formData.estimateName,
|
||||
requiresHalfPayment: formData.requiresHalfPayment,
|
||||
projectTemplate: formData.projectTemplate,
|
||||
fromMeeting: formData.fromMeeting,
|
||||
fromOnsiteMeeting: formData.fromOnsiteMeeting,
|
||||
company: company.currentCompany
|
||||
};
|
||||
estimate.value = await Api.createEstimate(data);
|
||||
|
|
@ -923,6 +924,8 @@ watch(
|
|||
const newIsNew = newQuery.new === "true";
|
||||
const newAddressQuery = newQuery.address;
|
||||
const newNameQuery = newQuery.name;
|
||||
const newFromMeetingQuery = newQuery["from-meeting"];
|
||||
const newProjectTemplateQuery = newQuery["project-template"];
|
||||
|
||||
if (newAddressQuery && newIsNew) {
|
||||
// Creating new estimate - pre-fill address
|
||||
|
|
@ -966,7 +969,15 @@ watch(
|
|||
};
|
||||
});
|
||||
}
|
||||
formData.requiresHalfPayment = estimate.value.custom_requires_half_payment || false;
|
||||
formData.requiresHalfPayment = Boolean(estimate.value.requiresHalfPayment || estimate.value.custom_requires_half_payment);
|
||||
// If estimate has fromOnsiteMeeting, fetch bid meeting
|
||||
if (estimate.value.fromOnsiteMeeting) {
|
||||
try {
|
||||
bidMeeting.value = await Api.getBidMeeting(estimate.value.fromOnsiteMeeting);
|
||||
} catch (error) {
|
||||
console.error("Error fetching bid meeting for existing estimate:", error);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error loading estimate:", error);
|
||||
|
|
@ -976,6 +987,35 @@ watch(
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Handle from-meeting for new estimates
|
||||
if (newFromMeetingQuery && newIsNew) {
|
||||
formData.fromOnsiteMeeting = newFromMeetingQuery;
|
||||
try {
|
||||
bidMeeting.value = await Api.getBidMeeting(newFromMeetingQuery);
|
||||
if (bidMeeting.value?.bidNotes?.quantities) {
|
||||
selectedItems.value = bidMeeting.value.bidNotes.quantities.map(q => {
|
||||
const item = quotationItems.value.find(i => i.itemCode === q.item);
|
||||
return {
|
||||
itemCode: q.item,
|
||||
itemName: item?.itemName || q.item,
|
||||
qty: q.quantity,
|
||||
standardRate: item?.standardRate || 0,
|
||||
discountAmount: null,
|
||||
discountPercentage: null,
|
||||
discountType: 'currency'
|
||||
};
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error fetching bid meeting:", error);
|
||||
}
|
||||
}
|
||||
|
||||
// Handle project-template
|
||||
if (newProjectTemplateQuery) {
|
||||
formData.projectTemplate = newProjectTemplateQuery;
|
||||
}
|
||||
}
|
||||
},
|
||||
{ deep: true }
|
||||
|
|
@ -995,16 +1035,36 @@ onMounted(async () => {
|
|||
|
||||
// Handle from-meeting query parameter
|
||||
if (fromMeetingQuery.value) {
|
||||
formData.fromMeeting = fromMeetingQuery.value;
|
||||
formData.fromOnsiteMeeting = fromMeetingQuery.value;
|
||||
// Fetch the bid meeting to check for bidNotes
|
||||
try {
|
||||
bidMeeting.value = await Api.getBidMeeting(fromMeetingQuery.value);
|
||||
// If new estimate and bid notes have quantities, set default items
|
||||
if (isNew.value && bidMeeting.value?.bidNotes?.quantities) {
|
||||
selectedItems.value = bidMeeting.value.bidNotes.quantities.map(q => {
|
||||
const item = quotationItems.value.find(i => i.itemCode === q.item);
|
||||
return {
|
||||
itemCode: q.item,
|
||||
itemName: item?.itemName || q.item,
|
||||
qty: q.quantity,
|
||||
standardRate: item?.standardRate || 0,
|
||||
discountAmount: null,
|
||||
discountPercentage: null,
|
||||
discountType: 'currency'
|
||||
};
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error fetching bid meeting:", error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handle project-template query parameter
|
||||
if (projectTemplateQuery.value) {
|
||||
formData.projectTemplate = projectTemplateQuery.value;
|
||||
}
|
||||
|
||||
if (addressQuery.value && isNew.value) {
|
||||
// Creating new estimate - pre-fill address
|
||||
await selectAddress(addressQuery.value);
|
||||
|
|
@ -1053,7 +1113,15 @@ onMounted(async () => {
|
|||
};
|
||||
});
|
||||
}
|
||||
formData.requiresHalfPayment = estimate.value.requiresHalfPayment || false;
|
||||
formData.requiresHalfPayment = Boolean(estimate.value.requiresHalfPayment || estimate.value.custom_requires_half_payment);
|
||||
// If estimate has fromOnsiteMeeting, fetch bid meeting
|
||||
if (estimate.value.fromOnsiteMeeting) {
|
||||
try {
|
||||
bidMeeting.value = await Api.getBidMeeting(estimate.value.fromOnsiteMeeting);
|
||||
} catch (error) {
|
||||
console.error("Error fetching bid meeting for existing estimate:", error);
|
||||
}
|
||||
}
|
||||
estimateResponse.value = estimate.value.customResponse;
|
||||
estimateResponseSelection.value = estimate.value.customResponse;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue