|
@@ -427,7 +427,9 @@ onMounted(async () => {
|
|
|
} catch (e) { console.error("Failed to load initial data:", e); }
|
|
} catch (e) { console.error("Failed to load initial data:", e); }
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
-watch([() => files.value.map(f => f.quantity), selectedMaterial, modelLink], async () => {
|
|
|
|
|
|
|
+import { useDebounceFn } from "@vueuse/core";
|
|
|
|
|
+
|
|
|
|
|
+const updatePriceEstimate = useDebounceFn(async () => {
|
|
|
if ((files.value.length > 0) && selectedMaterial.value) {
|
|
if ((files.value.length > 0) && selectedMaterial.value) {
|
|
|
try {
|
|
try {
|
|
|
const res = await getPriceEstimate({
|
|
const res = await getPriceEstimate({
|
|
@@ -435,17 +437,18 @@ watch([() => files.value.map(f => f.quantity), selectedMaterial, modelLink], asy
|
|
|
file_sizes: files.value.map(f => f.size),
|
|
file_sizes: files.value.map(f => f.size),
|
|
|
file_quantities: files.value.map(f => f.quantity),
|
|
file_quantities: files.value.map(f => f.quantity),
|
|
|
});
|
|
});
|
|
|
- // Assign individual prices to files for local quantity multiplication
|
|
|
|
|
if (res.file_prices && Array.isArray(res.file_prices)) {
|
|
if (res.file_prices && Array.isArray(res.file_prices)) {
|
|
|
files.value.forEach((f, i) => {
|
|
files.value.forEach((f, i) => {
|
|
|
f.basePrice = res.file_prices[i];
|
|
f.basePrice = res.file_prices[i];
|
|
|
});
|
|
});
|
|
|
estimateMetadata.value = res.metadata;
|
|
estimateMetadata.value = res.metadata;
|
|
|
- // Force reactivity update
|
|
|
|
|
- files.value = [...files.value];
|
|
|
|
|
}
|
|
}
|
|
|
} catch { /* silent */ }
|
|
} catch { /* silent */ }
|
|
|
}
|
|
}
|
|
|
|
|
+}, 500);
|
|
|
|
|
+
|
|
|
|
|
+watch([() => files.value.map(f => f.quantity), selectedMaterial, modelLink], () => {
|
|
|
|
|
+ updatePriceEstimate();
|
|
|
}, { deep: true });
|
|
}, { deep: true });
|
|
|
|
|
|
|
|
const isFormValid = computed(() =>
|
|
const isFormValid = computed(() =>
|