Browse Source

[FIX] cart items symbols

Gogs 7 years ago
parent
commit
aa4ca3134e
3 changed files with 28 additions and 15 deletions
  1. 1 1
      src/App.vue
  2. 18 2
      src/components/CartItem.vue
  3. 9 12
      src/components/CartItems.vue

+ 1 - 1
src/App.vue

@@ -7,7 +7,7 @@
                     products-grid
                 .cart-container
                     cart-total(:total="total" :symbol="currency.symbol")
-                    cart-items
+                    cart-items(:symbol="currency.symbol")
         tab-content(title="Seleccione un cliente")
             customer-searcher
             customers-grid

+ 18 - 2
src/components/CartItem.vue

@@ -17,14 +17,30 @@
                 default: () => {
                     return {}
                 }
+            },
+            symbol: {
+                type: String,
+                default: '$',
+                required: true
+            },
+            separator: {
+                type: String,
+                default: '.'
+            },
+            decimals: {
+                type: Number,
+                default: 0
             }
         },
         methods: {
+            getSymbol() {
+                return this.symbol
+            },
             getPrice() {
-                return accounting.formatMoney(this.item.list_price, '₲', 0, '.', ',')
+                return accounting.formatMoney(this.item.list_price, this.symbol, 0, this.separator, ',')
             },
             getSubtotal() {
-                return accounting.formatMoney(this.item.list_price * this.item.qty, '₲', 0, '.', ',')
+                return accounting.formatMoney(this.item.list_price * this.item.qty, this.symbol, 0, this.separator, ',')
             }
         },
         mounted() {

+ 9 - 12
src/components/CartItems.vue

@@ -1,6 +1,6 @@
 <template lang="pug">
     transition-group(name="list" tag="ul" class="cart-items")
-        cart-item(v-for="item in items" v-bind:key="item" :item="item")
+        cart-item(v-for="item in items" v-bind:key="item" :item="item" :symbol="symbol")
 </template>
 
 <script>
@@ -9,11 +9,10 @@
 
     export default {
         props: {
-            decimals: {
-                type: Number,
-                default: 0
-            },
-            
+            symbol: {
+                type: String,
+                default: '$'
+            }
         },
         components: {
             'cart-item': CartItem
@@ -21,12 +20,10 @@
         computed: mapGetters({
             items: 'getCartItems'
         }),
-        methods: {
-            ...mapActions([
-                'addToCart',
-                'removeFromCart'
-            ])
-        }
+        methods: mapActions([
+            'addToCart',
+            'removeFromCart'
+        ])
     }
 </script>