import axios from 'axios'; export default { namespaced: true, state: { list: [], item: {}, message: undefined, }, mutations: { setList(state, list) { state.list = list; }, }, getters: {}, actions: { getList({ commit, }) { axios .get('/api/template/getSimple') .then(result => commit('setList', result.data)) .catch(console.error); }, addItem({ dispatch, }, item) { axios .post('/api/template', item) .then(() => dispatch('getList')) .catch(console.error); }, editItem({ dispatch, }, item) { axios .put(`/api/template/${item.id}`, item) .then(() => dispatch('getList')) .catch(console.error); }, }, };