actions.js 1002 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import axios from 'axios'
  2. import { INIT_SALE_URL, CREATE_CUSTOMER_URL, PROCESS_SALE_URL } from '@/constants/resourcePaths'
  3. const actions = {
  4. /**
  5. *
  6. * @param {*} param0
  7. * @param {*} payload
  8. */
  9. notify({ commit }, payload) {
  10. openerp.web.notification.do_warn('Atención', payload)
  11. return false
  12. },
  13. /**
  14. *
  15. * @param {*} param0
  16. */
  17. initSale({ dispatch }) {
  18. return axios.get(INIT_SALE_URL).then(response => {
  19. dispatch('explodeData', response.data)
  20. }).catch(error => {
  21. console.log(error)
  22. })
  23. },
  24. /**
  25. *
  26. * @param {*} param0
  27. * @param {*} payload
  28. */
  29. explodeData({ dispatch }, payload) {
  30. for (let value in payload) {
  31. dispatch(`INIT_${value.split(/(?=[A-Z])/).join('_').toUpperCase()}`, payload[value])
  32. }
  33. },
  34. /**
  35. *
  36. * @param {*} param0
  37. */
  38. createSale({ getters , dispatch }) {
  39. }
  40. }
  41. export default actions