Browse Source

[FIX] products currency symbol

Gogs 7 years ago
parent
commit
7277ce8ea1
3 changed files with 23 additions and 3 deletions
  1. 1 1
      src/App.vue
  2. 14 1
      src/components/ProductCard.vue
  3. 8 1
      src/components/ProductsGrid.vue

+ 1 - 1
src/App.vue

@@ -4,7 +4,7 @@
             .pos
                 .products-container
                     products-searcher
-                    products-grid
+                    products-grid(:symbol="currency.symbol")
                 .cart-container
                     cart-total(:total="total" :symbol="currency.symbol")
                     cart-items(:symbol="currency.symbol")

+ 14 - 1
src/components/ProductCard.vue

@@ -17,6 +17,19 @@
                 default: () => {
                     return {}
                 }
+            },
+            symbol: {
+                type: String,
+                default: '$',
+                required: true
+            },
+            separator: {
+                type: String,
+                default: '.'
+            },
+            decimals: {
+                type: Number,
+                default: 0
             }
         },
         computed: {
@@ -29,7 +42,7 @@
         },
         methods: {
             getPrice() {
-                return accounting.formatMoney(this.data.list_price, '₲', 0, '.', ',')
+                return accounting.formatMoney(this.data.list_price, this.symbol, this.decimals, this.separator, ',')
             },
             drawImage() {
                 let ctx = this.$el.querySelector('.product-image').getContext('2d')

+ 8 - 1
src/components/ProductsGrid.vue

@@ -1,7 +1,7 @@
 <template lang="pug">
     .products-grid
         template(v-for="product in products")
-            product-card(:data="product")
+            product-card(:data="product" :symbol="symbol")
         product-selector
 
 </template>
@@ -13,6 +13,13 @@
     import { mapGetters, mapActions } from 'vuex'
 
     export default {
+        props: {
+            symbol: {
+                type: String,
+                default: '$',
+                required: true
+            }
+        },
         components: {
             'product-card': ProductCard,
             'product-selector': ProductSelector