ProductForm.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template lang="pug">
  2. modal(name='product-modal' transition='nice-modal-fade' @before-close='beforeClose' :classes="['v--modal', 'product-modal']")
  3. h2 Nuevo producto
  4. hr
  5. form.product-form
  6. .form-item
  7. label.form-label Nombre
  8. input.form-input(v-model='product.name' autofocus)
  9. .form-item
  10. label.form-label Precio de Costo
  11. input.form-input(v-model='product.price')
  12. .form-item
  13. label.form-label Código de Barras
  14. input.form-input(v-model='product.ean13')
  15. .form-actions
  16. button.form-button(@click='submitProduct(product)') Aceptar
  17. button.form-button(@click='submitProduct()') Cancelar
  18. </template>
  19. <script>
  20. import { mapGetters, mapActions } from 'vuex'
  21. export default {
  22. computed: mapGetters([
  23. 'showProductForm'
  24. ]),
  25. watch: {
  26. showProductForm(value) {
  27. if(!value) {
  28. this.$modal.hide('product-modal')
  29. return
  30. }
  31. this.product.name = ''
  32. this.product.price = ''
  33. this.product.ean13 = ''
  34. this.$modal.show('product-modal')
  35. }
  36. },
  37. methods: {
  38. beforeClose(e) {
  39. if (this.showProductForm) {
  40. e.stop()
  41. }
  42. },
  43. ...mapActions([
  44. 'submitProduct'
  45. ])
  46. },
  47. data() {
  48. return {
  49. product: {
  50. name: '',
  51. price: '',
  52. ean13: ''
  53. }
  54. }
  55. }
  56. }
  57. </script>
  58. <style lang="sass">
  59. @import '../../assets/variables'
  60. .product-modal
  61. h2
  62. font-size: 10pt
  63. color: $app-title-color
  64. margin-left: 15px
  65. hr
  66. margin: 0 15px
  67. .product-form
  68. width: 100%
  69. height: 250px
  70. padding: 15px
  71. .form-item
  72. width: 100%
  73. height: 40px
  74. margin-bottom: 15px
  75. .form-label
  76. width: 30%
  77. height: 40px
  78. font-size: 14pt
  79. .form-input
  80. width: 70%
  81. height: 40px
  82. font-size: 18pt
  83. border-radius: 0
  84. .form-actions
  85. float: right
  86. margin-top: 15px
  87. .form-button
  88. width: 160px
  89. height: 40px
  90. border: none
  91. box-shadow: none
  92. border-radius: 0
  93. margin-right: 5px
  94. background: $app-main-color
  95. color: $app-bg-color
  96. </style>