選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

individual.js 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* eslint-disable no-restricted-syntax */
  2. /* eslint-disable guard-for-in */
  3. import axios from 'axios';
  4. export default {
  5. namespaced: true,
  6. state: {
  7. items: [],
  8. indiv: undefined,
  9. },
  10. mutations: {
  11. addItem(state, item) {
  12. state[item.name].push(item.value);
  13. },
  14. setItem(state, item) {
  15. state[item.name] = item.value;
  16. },
  17. },
  18. getters: {},
  19. actions: {
  20. getIndividual({ commit, rootGetters }, userId) {
  21. let id = 0;
  22. if (!userId || userId === 0) {
  23. const rootItem = rootGetters['authentication/getUser'];
  24. id = rootItem ? rootItem.id : 0;
  25. } else id = userId;
  26. axios
  27. .get(`/api/individual/getIndividual/${id}`)
  28. .then(r => commit('setItem', {
  29. name: 'indiv',
  30. value: r.data,
  31. }),)
  32. .catch(console.error);
  33. },
  34. getAllIndividuals({ commit }) {
  35. axios
  36. .get('/api/individual/getAllIndividuals')
  37. .then(x => commit('setItem', {
  38. name: 'items',
  39. value: x.data,
  40. }),)
  41. .catch(console.error);
  42. },
  43. },
  44. };