12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- import Vue from 'vue';
- import Vuex from 'vuex';
- import _ from 'lodash';
- // import axios from 'axios';
- import AxiosWrapper from '../utils/axios-wrapper';
- Vue.use(Vuex);
- const api = {
- interface: `/api/train/setting/findone`,
- update: id => `/api/train/setting/update/${id}`,
- termlist: `/api/train/setting/termlist`,
- };
- const state = () => ({});
- const mutations = {};
- const actions = {
- async create({ commit }, payload) {
- const res = await this.$axios.$post(`${api.interface}`, payload);
- return res;
- },
- async fetch({ commit }, payload) {
- const axios = new AxiosWrapper({ baseUrl: process.env.VUE_APP_AXIOS_BASE_URL, unwrap: true });
- const res = await axios.$get(api.interface);
- if (res.errcode == 0) {
- commit('setDefOpt', res.data, { root: true });
- return res;
- }
- },
- async checkCache({ rootState, commit, dispatch }) {
- let res = commit('setDefOpt', null, { root: true });
- dispatch('fetch');
- },
- async update({ commit }, { id, ...data }) {
- const res = await this.$axios.$post(`${api.update(id)}`, data);
- if (res.errcode == '0') {
- commit('setDefOpt', res.data, { root: true });
- }
- return res;
- },
- async termList() {
- const res = await this.$axios.$get(`${api.termlist}`);
- return res;
- },
- };
- export default {
- namespaced: true,
- state,
- mutations,
- actions,
- };
|