products.js 779 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. const state = {
  2. products: []
  3. }
  4. const getters = {
  5. getProducts (state) {
  6. return state.products
  7. }
  8. }
  9. const mutations = {
  10. pushProducts(state, payload) {
  11. state.products = [...payload.products]
  12. }
  13. }
  14. const actions = {
  15. fetchProducts ({ commit }) {
  16. let pos = new openerp.web.Model('eiru.pos')
  17. pos.call('get_products').then(response => {
  18. commit('pushProducts', {
  19. products: response
  20. })
  21. }).fail(error => {
  22. console.log(error)
  23. })
  24. },
  25. // selectProduct({ dispatch }, payload) {
  26. // // dispatch('addToCart', payload)
  27. // }
  28. selectProduct(args) {
  29. console.log(args)
  30. }
  31. }
  32. export default {
  33. state,
  34. getters,
  35. mutations,
  36. actions
  37. }