Skouter mortgage estimates. Web application with view written in PHP and Vue, but controller and models in Go.
 
 
 
 
 
 

156 satır
3.4 KiB

  1. <template>
  2. <div id="new" class="page">
  3. <h2>New Loan</h2>
  4. <section class="loans-list">
  5. <h3 v-for="(l, indx) in loans"
  6. :class="sel == indx ? 'sel' : ''"
  7. @click="() => sel = indx"
  8. >
  9. {{l.title}}
  10. </h3>
  11. <div class="add">
  12. <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
  13. fill="currentColor" class="bi bi-plus" viewBox="0 0 16 16"> <path d="M8 4a.5.5 0
  14. 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0
  15. 0 1 8 4z"/> </svg>
  16. </div>
  17. </section>
  18. <section class="radios form">
  19. <h3>Transaction Type</h3>
  20. <input type="radio" name="transaction_type" value="transaction"
  21. @input="e => loans[sel].transaction = 0"
  22. selected="loans[sel].transaction == 0">
  23. <label>Purchase</label>
  24. <input type="radio" name="transaction_type" value="refinance"
  25. @input="e => loans[sel].transaction = 1"
  26. selected="loans[sel].transaction == 1">
  27. <label>Refinance</label>
  28. </section>
  29. <section class="form">
  30. <h3>Property Details</h3>
  31. <label>Price ($)</label>
  32. <input :value="loans[sel].price" @input="setPrice">
  33. <label>Type</label>
  34. <select id="" name="" v-model="loans[sel].property">
  35. <option value="attched">Single Family Attached</option>
  36. <option value="detached">Single Family Detached</option>
  37. <option value="lorise">Lo-rise (4 stories or less)</option>
  38. <option value="hirise">Hi-rise (over 4 stories)</option>
  39. </select>
  40. <label></label>
  41. </section>
  42. <section class="radios form">
  43. <h3>Loan Type</h3>
  44. <input type="radio" name="loan_type" value="conv" v-model="loans[sel].type"
  45. >
  46. <label>Conventional</label>
  47. <input type="radio" name="loan_type" value="fha" v-model="loans[sel].type">
  48. <label>FHA</label>
  49. <input type="radio" name="loan_type" value="va" v-model="loans[sel].type">
  50. <label>VA</label>
  51. <input type="radio" name="loan_type" value="usda" v-model="loans[sel].type">
  52. <label>USDA</label>
  53. </section>
  54. <section class="form">
  55. <h3>Loan Details</h3>
  56. <label>Loan Term (years)</label>
  57. <input :value="loans[sel].term"
  58. @input="(e) => loans[sel].term = parseInt(e.target.value.replace(/[^0-9]/g, ''))">
  59. <label>Loan Program</label>
  60. <select id="" name="" v-model="loans[sel].program">
  61. <option value="none">None</option>
  62. </select>
  63. <label>Loan to Value</label>
  64. <input :value="loans[sel].ltv" @input="setLtv">
  65. <label>Loan Amount</label>
  66. <input :value="loans[sel].amount"
  67. @input="setAmount">
  68. </section>
  69. </div>
  70. </template>
  71. <script>
  72. function setLtv(loan, ltv) {
  73. if (ltv > 100) ltv = 100
  74. if (ltv < 0) ltv = 0
  75. loan.ltv = ltv
  76. loan.amount = ltv / 100 * loan.price
  77. }
  78. function setAmount(e) {
  79. let amount = parseInt(e.target.value.replace(/[^0-9]/g, ''))
  80. let loan = this.loans[this.sel]
  81. if (amount > loan.price) amount = loan.price
  82. if (amount < 0) amount = 0
  83. loan.amount = amount
  84. loan.ltv = amount / loan.price * 100
  85. }
  86. function setPrice(e) {
  87. let value =
  88. parseInt(e.target.value.replace(/[^0-9]/g, ''))
  89. // Should check for NaN after backspace
  90. console.log("the price is %s", value)
  91. this.loans[this.sel].price =
  92. value
  93. }
  94. const loans = [
  95. {
  96. title: "Loan Example",
  97. property: "",
  98. transaction: 0,
  99. type: "",
  100. price: 0,
  101. term: 0,
  102. ltv: 0,
  103. amount: 0,
  104. program: "",
  105. pud: false,
  106. zip: ''
  107. },
  108. {
  109. title: "Another One",
  110. property: "",
  111. transaction: 0,
  112. type: "",
  113. price: 0,
  114. term: 0,
  115. ltv: 0,
  116. program: "",
  117. pud: true,
  118. zip: ''
  119. }
  120. ]
  121. const propertyTypes = [
  122. ]
  123. export default {
  124. methods: { setPrice },
  125. props: ['user'],
  126. data() {
  127. return {
  128. loans: loans, sel: 0, loan: loans[0],
  129. }
  130. }
  131. }
  132. </script>