|
|
@@ -54,18 +54,23 @@ ${{(estimate.price / 100).toLocaleString()}} |
|
|
|
<label>Total monthly: ${{format(l.result.totalMonthly)}}</label> |
|
|
|
<label>Cash to close: ${{format(l.result.cashToClose)}}</label> |
|
|
|
</div> |
|
|
|
<button @click="() => $emit('download', estimate)">Download</button> |
|
|
|
<button @click="() => download(estimate)">PDF</button> |
|
|
|
<button @click="() => estimate = null">Cancel</button> |
|
|
|
</div> |
|
|
|
|
|
|
|
</section> |
|
|
|
|
|
|
|
<DDialog v-if="dlink" @close="() => dlink = ''" |
|
|
|
:fileName="`estimate-${estimate.id}.pdf`" :url="dlink"> |
|
|
|
</DDialog> |
|
|
|
|
|
|
|
</div> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script setup> |
|
|
|
import { ref, computed, onMounted } from 'vue' |
|
|
|
import FeeDialog from "./fee-dialog.vue" |
|
|
|
import DDialog from "./download-dialog.vue" |
|
|
|
import { format } from "../helpers.js" |
|
|
|
|
|
|
|
const props = defineProps(['user', 'fees', 'token']) |
|
|
@@ -73,6 +78,7 @@ const emit = defineEmits(['addFeeTemp', 'removeFeeTemp', 'preview']) |
|
|
|
let edit = ref(null) |
|
|
|
let estimates = ref([]) |
|
|
|
let estimate = ref() |
|
|
|
let dlink = ref("") |
|
|
|
|
|
|
|
function newFee(fee, isDebit) { |
|
|
|
if (!isDebit) { |
|
|
@@ -156,7 +162,30 @@ function summarize() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
function download(estimate) { |
|
|
|
fetch(`/api/pdf`, |
|
|
|
{method: 'POST', |
|
|
|
body: JSON.stringify(estimate), |
|
|
|
headers: { |
|
|
|
"Accept": "application/json", |
|
|
|
"Authorization": `Bearer ${props.token}`, |
|
|
|
}, |
|
|
|
}).then(response => { |
|
|
|
if (response.ok) { return response.blob() } |
|
|
|
}).then (result => { |
|
|
|
if (!result) return // Exit if token is invalid or blank file returned |
|
|
|
dlink.value = URL.createObjectURL(result) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
onMounted(() => { |
|
|
|
getEstimates() |
|
|
|
}) |
|
|
|
</script> |
|
|
|
|
|
|
|
<style scoped> |
|
|
|
.modal a.button { |
|
|
|
margin: auto; |
|
|
|
margin-top: 30px; |
|
|
|
} |
|
|
|
</style> |