123456789101112131415161718192021222324252627282930313233343536373839404142 |
- 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);
- },
- },
- };
|