Sfoglia il codice sorgente

[ADD] add check for change states

Gogs 7 anni fa
parent
commit
60e1cd37e3
2 ha cambiato i file con 17 aggiunte e 7 eliminazioni
  1. 16 6
      src/App.vue
  2. 1 1
      src/store/modules/cart.js

+ 16 - 6
src/App.vue

@@ -1,7 +1,7 @@
 <template lang="pug">
     .app
         form-wizard(title="" subtitle="" nextButtonText="Continuar" backButtonText="Volver" finishButtonText="Finalizar" color="#7c7bad")
-            tab-content(title="Agregue productos al carrito")
+            tab-content(title="Agregue productos al carrito" :before-change="checkCart")
                 .pos
                     .products-container
                         products-searcher
@@ -9,7 +9,7 @@
                     .cart-container
                         cart-total(:total="total" :symbol="currency.symbol")
                         cart-items(:symbol="currency.symbol")
-            tab-content(title="Seleccione un cliente")
+            tab-content(title="Seleccione un cliente" :before-change="checkCustomer")
                 customer-searcher
                 customers-grid
             tab-content(title="Vea un resumen de su operación")
@@ -50,11 +50,21 @@
         },
         computed: mapGetters({
             total: 'getTotal',
-            currency: 'getCurrency'
+            currency: 'getCurrency',
+            cartIsEmpty: 'cartIsEmpty',
+            hasSelectedCustomer: 'hasSelectedCustomer'
         }),
-        methods: mapActions([
-            'fetchData'
-        ]),
+        methods: {
+            checkCart() {
+                return this.cartIsEmpty
+            },
+            checkCustomer() {
+                return this.hasSelectedCustomer
+            },
+            ...mapActions([
+                'fetchData'
+            ])
+        },
         mounted() {
             this.fetchData()
         }

+ 1 - 1
src/store/modules/cart.js

@@ -10,7 +10,7 @@ const getters = {
     getTotal(state) {
         return state.total
     },
-    isEmpty(state) {
+    cartIsEmpty(state) {
         return state.cart.length !== 0
     }
 }