Product.vue 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template lang="pug">
  2. .pos-step
  3. .products-selector
  4. searcher(
  5. mode='normal'
  6. :items='products'
  7. :keys="['name', 'ean13', 'defaultCode']"
  8. @onSearch='filterProducts'
  9. )
  10. card-grid(
  11. @onAdd='showProductForm'
  12. :items='visibleProducts'
  13. :details="['price:c']"
  14. :options='currency'
  15. :loading='loadingProducts'
  16. @onSelect='selectProduct'
  17. )
  18. product-modal(
  19. :show='showingProductForm'
  20. @onAccept='submitProduct'
  21. @onCancel='hideProductForm'
  22. )
  23. variant-modal
  24. discount-modal(
  25. :item='itemToDiscount'
  26. :options='currency'
  27. :show='!!itemToDiscount'
  28. @onAccept='applyPrice'
  29. @onCancel='applyPrice'
  30. )
  31. cart(
  32. :items='cartItems'
  33. :options='currency'
  34. @onTotalComputed='changeCartTotal'
  35. @onIncrementQty='addToCart'
  36. @onUndoPrice='undoPrice'
  37. @onChangePrice='changePrice'
  38. @onDecrementQty='decreaseFromCart'
  39. @onDeleteItem='removeFromCart'
  40. )
  41. </template>
  42. <script>
  43. import { mapGetters, mapActions } from 'vuex'
  44. import { Searcher, CardGrid, Cart } from '@@/common'
  45. import ProductModal from '@@/modals/ProductModal'
  46. import VariantModal from '@@/modals/VariantModal'
  47. import DiscountModal from '@@/modals/DiscountModal'
  48. export default {
  49. components: {
  50. Searcher,
  51. CardGrid,
  52. Cart,
  53. ProductModal,
  54. VariantModal,
  55. DiscountModal
  56. },
  57. computed: {
  58. ...mapGetters([
  59. 'products',
  60. 'visibleProducts',
  61. 'loadingProducts',
  62. 'showingProductForm',
  63. 'cartItems',
  64. 'itemToDiscount',
  65. 'currency'
  66. ])
  67. },
  68. methods: mapActions([
  69. 'filterProducts',
  70. 'selectProduct',
  71. 'showProductForm',
  72. 'hideProductForm',
  73. 'submitProduct',
  74. 'changeCartTotal',
  75. 'addToCart',
  76. 'decreaseFromCart',
  77. 'undoPrice',
  78. 'changePrice',
  79. 'applyPrice',
  80. 'removeFromCart'
  81. ])
  82. }
  83. </script>
  84. <style lang="sass">
  85. .pos-step
  86. .products-selector
  87. width: calc(100% - 300px)
  88. height: 100%
  89. padding-right: 5px
  90. display: inline-block
  91. </style>