You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

template.js 788B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import axios from 'axios';
  2. export default {
  3. namespaced: true,
  4. state: {
  5. list: [],
  6. item: {},
  7. message: undefined,
  8. },
  9. mutations: {
  10. setList(state, list) {
  11. state.list = list;
  12. },
  13. },
  14. getters: {},
  15. actions: {
  16. getList({
  17. commit,
  18. }) {
  19. axios
  20. .get('/api/template/getSimple')
  21. .then(result => commit('setList', result.data))
  22. .catch(console.error);
  23. },
  24. addItem({
  25. dispatch,
  26. }, item) {
  27. axios
  28. .post('/api/template', item)
  29. .then(() => dispatch('getList'))
  30. .catch(console.error);
  31. },
  32. editItem({
  33. dispatch,
  34. }, item) {
  35. axios
  36. .put(`/api/template/${item.id}`, item)
  37. .then(() => dispatch('getList'))
  38. .catch(console.error);
  39. },
  40. },
  41. };