PricelistModal.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template lang="pug">
  2. modal(
  3. name='pricelist-modal'
  4. transition='nice-modal-fade'
  5. width='400px'
  6. height='600px'
  7. :classes="['v--modal', 'pricelist-modal']"
  8. @before-close='beforeClose'
  9. )
  10. .pricelist-content
  11. h1 Lista de precios
  12. .pricelist-items-wrapper
  13. ul.pricelist-items
  14. li.pricelist-item(
  15. v-for='item in items'
  16. :key='item.id'
  17. @click.prevent='onApply(item)'
  18. )
  19. h3 {{ computePrice(item) }}
  20. h1 {{ item.pricelistName }}
  21. .pricelist-options
  22. button.pricelist-option(
  23. @click.prevent='onCancel'
  24. ) Cancelar
  25. </template>
  26. <script>
  27. export default {
  28. props: {
  29. show: {
  30. type: Boolean,
  31. default: false
  32. },
  33. items: {
  34. type: Array,
  35. default: []
  36. }
  37. },
  38. watch: {
  39. show(canShow) {
  40. if (canShow) {
  41. this.$modal.show('pricelist-modal')
  42. return
  43. }
  44. this.$modal.hide('pricelist-modal')
  45. }
  46. },
  47. methods: {
  48. beforeClose(e) {
  49. if(this.show) {
  50. e.stop()
  51. }
  52. },
  53. computePrice(item) {
  54. return (item.productPrice * (1 + item.priceDiscount)) + item.priceSurcharge
  55. },
  56. onApply(item) {
  57. const price = this.computePrice(item)
  58. this.$emit('onApply', price)
  59. },
  60. onCancel(e) {
  61. this.$emit('onCancel')
  62. }
  63. }
  64. }
  65. </script>
  66. <style lang="sass">
  67. @import '../../assets/variables'
  68. .pricelist-modal
  69. .pricelist-content
  70. width: 100%
  71. height: 100%
  72. padding: 15px
  73. h1
  74. font-size: 12pt
  75. color: #757575
  76. .pricelist-items-wrapper
  77. width: 100%
  78. height: calc(100% - 95px)
  79. overflow-y: auto
  80. .pricelist-items
  81. width: 100%
  82. padding-left: 0
  83. a
  84. .pricelist-item
  85. list-style: none
  86. padding: 0
  87. border-bottom: 1px solid #d3d3d3
  88. h1
  89. font-size: 10pt
  90. &:hover
  91. cursor: pointer
  92. border-bottom: 2px solid $app-main-color
  93. .pricelist-options
  94. float: right
  95. .pricelist-option
  96. width: 160px
  97. height: 40px
  98. border: none
  99. box-shadow: none
  100. border-radius: 0
  101. margin-right: 5px
  102. background: $app-main-color
  103. color: $app-bg-color
  104. </style>