App.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template lang="pug">
  2. .pos
  3. form-wizard(
  4. title=''
  5. subtitle=''
  6. color='#7c7bad'
  7. ref='wizard'
  8. )
  9. tab-content(
  10. title='Qué productos necesita?'
  11. :beforeChange='checkCart'
  12. )
  13. product-step
  14. tab-content(
  15. title='Quién es el cliente?'
  16. :beforeChange='checkCustomer'
  17. )
  18. customer-step
  19. tab-content(
  20. v-if='isSale'
  21. title='Cómo quieres pagar?'
  22. )
  23. payment-step
  24. template(
  25. slot='footer'
  26. slot-scope='props'
  27. )
  28. .wizard-footer-left
  29. wizard-button(
  30. v-if='props.activeTabIndex > 0'
  31. @click.native='goBack'
  32. :style='props.fillButtonStyle'
  33. ) Volver
  34. .wizard-footer-center(v-show='showStoreSelector')
  35. .store-selector
  36. span
  37. strong Sucursal
  38. input-select(
  39. :options='stores.map(s => ({ id: s.id, name: s.name }))'
  40. :selected='selectedStore'
  41. @onSelect='selectStore'
  42. )
  43. connection-status(@onChangeNet='changeNetStatus')
  44. .wizard-footer-right
  45. wizard-button(
  46. v-if='!props.isLastStep'
  47. class='wizard-footer-right'
  48. :style='props.fillButtonStyle'
  49. @click.native='goNext'
  50. ) Continuar
  51. wizard-button(
  52. v-else
  53. class='wizard-footer-right finish-button'
  54. :style='props.fillButtonStyle'
  55. @click.native='endProcess'
  56. ) {{ props.isLastStep ? 'Finalizar' : 'Continuar' }}
  57. settings-button(
  58. v-show='!loading && isManager && isWired'
  59. @onClick='toggleSettingsVisibility'
  60. )
  61. settings-modal(
  62. :show='settingsVisibility'
  63. :settings='settings'
  64. @onClose='toggleSettingsVisibility'
  65. @onChangeSetting='changeSetting'
  66. )
  67. loading-overlay(:show='loading')
  68. </template>
  69. <script>
  70. import { mapGetters, mapActions } from 'vuex'
  71. import { FormWizard, TabContent, WizardButton } from 'vue-form-wizard'
  72. import 'vue-form-wizard/dist/vue-form-wizard.min.css'
  73. import SettingsModal from './components/modals/SettingsModal'
  74. import {Product as ProductStep, Customer as CustomerStep, Payment as PaymentStep} from './components/steps'
  75. import { LoadingOverlay, SettingsButton, InputSelect, ConnectionStatus } from './components/common'
  76. export default {
  77. components: {
  78. FormWizard,
  79. TabContent,
  80. WizardButton,
  81. ProductStep,
  82. CustomerStep,
  83. PaymentStep,
  84. LoadingOverlay,
  85. SettingsButton,
  86. SettingsModal,
  87. InputSelect,
  88. ConnectionStatus
  89. },
  90. computed: mapGetters([
  91. 'isSale',
  92. 'footerButtonsVisibility',
  93. 'settingsVisibility',
  94. 'settings',
  95. 'stores',
  96. 'initialPayment',
  97. 'selectedStore',
  98. 'showStoreSelector',
  99. 'isManager',
  100. 'loading',
  101. 'completed',
  102. 'isWired'
  103. ]),
  104. methods: {
  105. goNext() {
  106. this.$refs.wizard.nextTab()
  107. if (this.$refs.wizard.activeTabIndex >= 1) {
  108. this.changeInitialPayment(this.initialPayment)
  109. }
  110. },
  111. goBack() {
  112. // if (this.$refs.wizard.activeTabIndex === 2) {
  113. // this.changeInitialPayment(0)
  114. // }
  115. this.$refs.wizard.prevTab()
  116. },
  117. handleKeyboard({key}) {
  118. this.handleNavigation(key)
  119. },
  120. // TODO: Improve navigation
  121. handleNavigation(key) {
  122. if (key === 'ArrowRight') {
  123. // this.goNext()
  124. return
  125. }
  126. if (key === 'ArrowLeft') {
  127. // this.goBack()
  128. }
  129. },
  130. ...mapActions([
  131. 'initProcess',
  132. 'checkCart',
  133. 'checkCustomer',
  134. 'toggleSettingsVisibility',
  135. 'changeSetting',
  136. 'changeInitialPayment',
  137. 'changeNetStatus',
  138. 'selectStore',
  139. 'endProcess',
  140. 'resetProcess'
  141. ])
  142. },
  143. watch: {
  144. completed(value) {
  145. if (!value) {
  146. return
  147. }
  148. this.$refs.wizard.changeTab(2, 0, false)
  149. this.resetProcess()
  150. }
  151. },
  152. created() {
  153. document.addEventListener('keyup', this.handleKeyboard)
  154. },
  155. destroyed() {
  156. document.removeEventListener('keyup', this.handleKeyboard)
  157. },
  158. mounted() {
  159. this.initProcess(this.$root.mode)
  160. }
  161. }
  162. </script>
  163. <style lang="sass">
  164. @import './assets/variables'
  165. .pos
  166. width: 100%
  167. height: 100%
  168. position: absolute
  169. .v--modal-overlay
  170. background: rgba(0, 0, 0, 0.7)
  171. z-index: 1001
  172. .vue-form-wizard
  173. width: 100%
  174. height: 100%
  175. padding-bottom: 0
  176. .wizard-header
  177. display: none
  178. .wizard-navigation
  179. width: 100%
  180. height: 100%
  181. .wizard-progress-with-circle
  182. top: 35px
  183. .wizard-icon-circle
  184. width: 60px
  185. height: 60px
  186. .wizard-tab-content
  187. width: 100%
  188. height: calc(100% - 82px)
  189. padding: 0
  190. overflow: hidden
  191. .wizard-tab-container
  192. width: calc(100% - 20px)
  193. height: calc(100% - 20px)
  194. margin: 10px
  195. .pos-step
  196. width: 100%
  197. height: 100%
  198. background: $app-bg-color
  199. .wizard-card-footer
  200. width: 100%
  201. height: 50px
  202. position: absolute
  203. bottom: 0
  204. text-align: center
  205. box-shadow: 2px 0px 5px rgba(0, 0, 0, 0.26)
  206. .wizard-footer-center
  207. width: 270px
  208. display: inline-block
  209. .store-selector
  210. span
  211. display: inline-block
  212. div
  213. width: 200px
  214. margin-left: 15px
  215. display: inline-block
  216. .wizard-footer-left, .wizard-footer-right
  217. margin-top: 3px
  218. .wizard-btn
  219. width: 160px
  220. height: 40px
  221. border-radius: 0
  222. box-shadow: none
  223. border: none
  224. &:hover, &:focus
  225. background: $app-main-color
  226. </style>