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

71 lines
1.4 KiB

  1. <template>
  2. <Dialog @close="$emit('close')">
  3. <h3>{{heading || "New Fee"}}</h3>
  4. <label>Name</label>
  5. <input type=""
  6. :value="fee.name"
  7. @input="(e) => fee.name = stripLetters(e)">
  8. <label>Amount</label>
  9. <input
  10. type=""
  11. :value="fee.amount"
  12. @input="(e) => {fee.perc = 0; fee.amount = strip(e)}">
  13. <label>Percentage of price</label>
  14. <input
  15. type=""
  16. :value="fee.perc"
  17. @input="(e) => { fee.perc = stripPerc(e);
  18. fee.amount = stripPerc(e)/100*price }">
  19. <select id="" name="" v-model="fee.type">
  20. <option value="Title Company">Title Company</option>
  21. <option value="Government">Government</option>
  22. <option value="Lender">Lender</option>
  23. <option value="Services Required by Lender">Required by Lender</option>
  24. <option value="Other">Other</option>
  25. </select>
  26. <button :disabled="!validFee" @click="() => $emit('save', fee, true)">
  27. Debit
  28. </button>
  29. <button :disabled="!validFee" @click="() => $emit('save', fee, false)">
  30. Credit
  31. </button>
  32. </Dialog>
  33. </template>
  34. <script>
  35. import Dialog from "./dialog.vue"
  36. import { stripLetters, strip, stripInt, stripPerc } from "../helpers.js"
  37. function validFee() {
  38. const fee = this.fee
  39. if (!fee.name || !fee.type || !fee.amount) {
  40. return false
  41. }
  42. return true
  43. }
  44. export default {
  45. components: { Dialog },
  46. methods: {
  47. stripLetters, strip, stripInt, stripPerc
  48. },
  49. computed: {
  50. validFee,
  51. },
  52. props: ['initial', 'heading', 'price'],
  53. emits: ['close', 'save'],
  54. data() {
  55. return { fee: Object.assign({}, this.initial) }
  56. },
  57. }
  58. </script>