Skouter mortgage estimates. Web application with view written in PHP and Vue, but controller and models in Go.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

estimates.vue 2.7 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <div class="page">
  3. <h2>Estimates</h2>
  4. <section class="form inputs">
  5. <h3>Default Fees</h3>
  6. <div
  7. v-for="(fee, indx) in fees"
  8. :key="fee.name + indx" class="fee"
  9. >
  10. <label @click="() => edit = fee">
  11. ${{fee.amount/100}}{{ fee.perc ? ` ${fee.perc}%` : ''}} - {{fee.name}}<br>
  12. {{fee.type}}
  13. </label>
  14. <img width="21" height="21" src="/assets/image/icon/x-red.svg"
  15. @click="() => remove(indx, 1)">
  16. </div>
  17. <button @click="() => edit = {}">New Fee</button>
  18. </section>
  19. <fee-dialog v-if="edit"
  20. :heading="'Fee'"
  21. :initial="edit"
  22. :price="0"
  23. @close="() => edit = null"
  24. @save="newFee"
  25. />
  26. <section class="inputs estimates">
  27. <h3>Saved Estimates</h3>
  28. <div class="entry" v-for="e in estimates" v-if="!estimate"
  29. @click="() => estimate = e" key="e.id">
  30. <span>
  31. {{e.id}} - {{e.property}} - ${{(e.price/100).toLocaleString()}}
  32. </span>
  33. </div>
  34. <div class="details" v-if="estimate">
  35. <label>
  36. #{{estimate.id}} -
  37. {{estimate.transaction}} -
  38. {{estimate.property}} -
  39. ${{(estimate.price / 100).toLocaleString()}}
  40. </label>
  41. <label>Borrowers: {{estimate.borrower.num}}</label>
  42. <label>Credit: {{estimate.borrower.credit}}</label>
  43. <label>Income: {{(estimate.borrower.income/100).toLocaleString()}}</label>
  44. <div v-for="l in estimate.loans" class="details">
  45. <h4>{{l.title}}</h4>
  46. <label>{{l.type.name}}</label>
  47. <label>{{l.id}}</label>
  48. </div>
  49. <button @click="() => estimate = null">Cancel</button>
  50. </div>
  51. </section>
  52. </div>
  53. </template>
  54. <script setup>
  55. import { ref, computed, onMounted } from 'vue'
  56. import FeeDialog from "./fee-dialog.vue"
  57. const props = defineProps(['user', 'fees', 'token'])
  58. let edit = ref(null)
  59. let estimates = ref([])
  60. let estimate = ref()
  61. function newFee(fee, isDebit) {
  62. this.edit = null
  63. }
  64. function newType() {
  65. }
  66. function remove() {
  67. }
  68. function getEstimates() {
  69. fetch(`/api/estimates`,
  70. {method: 'GET',
  71. headers: {
  72. "Accept": "application/json",
  73. "Authorization": `Bearer ${props.token}`,
  74. },
  75. }).then(response => {
  76. if (response.ok) { return response.json() } else {
  77. response.text().then(t => console.log(t))
  78. }
  79. }).then (result => {
  80. if (!result || !result.length) return // Exit if token is invalid or no fees are saved
  81. estimates.value = result
  82. // console.log(result)
  83. })
  84. }
  85. function summarize() {
  86. fetch(`/api/estimate/summarize`,
  87. {method: 'POST',
  88. headers: {
  89. "Accept": "application/json",
  90. "Authorization": `Bearer ${props.token}`,
  91. },
  92. body: JSON.stringify(estimate.value),
  93. }).then(response => {
  94. if (response.ok) { return response.json() } else {
  95. response.text().then(t => console.log(t))
  96. }
  97. }).then(result => {
  98. if (!result || !result.length) return // Exit if token is invalid or no fees are saved
  99. console.log('done', result)
  100. })
  101. }
  102. onMounted(() => {
  103. getEstimates()
  104. })
  105. </script>