App.vue 8.5 KB

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