|
@@ -1,112 +1,112 @@
|
|
|
-import Vue from 'vue';
|
|
|
-import Vuex from 'vuex';
|
|
|
-import _ from 'lodash';
|
|
|
-import axios from 'axios';
|
|
|
-Vue.use(Vuex);
|
|
|
-const api = {
|
|
|
- interface: `/api/train/lesson`,
|
|
|
- model: `/api/train/lessonmode`,
|
|
|
- arrange: id => `/api/train/lesson/autolesson/${id}`,
|
|
|
- pluralUpdate: `/api/train/lesson/uplessones`,
|
|
|
- teaclass: `/api/train/lesson/teaclass`,
|
|
|
- confirm: `/api/train/lesson/check`, //锁死课表
|
|
|
- newArrange: `/api/train/lesson/newarrange`,
|
|
|
-};
|
|
|
-const state = () => ({});
|
|
|
-const mutations = {};
|
|
|
-
|
|
|
-const actions = {
|
|
|
- async query({ commit }, { skip = 0, limit, ...info } = {}) {
|
|
|
- const res = await this.$axios.$get(`${api.interface}`, { skip, limit, ...info });
|
|
|
- return res;
|
|
|
- },
|
|
|
- async create({ commit }, payload) {
|
|
|
- const res = await this.$axios.$post(`${api.interface}`, payload);
|
|
|
- return res;
|
|
|
- },
|
|
|
- async fetch({ commit }, payload) {
|
|
|
- const res = await this.$axios.$get(`${api.interface}/${payload}`);
|
|
|
- return res;
|
|
|
- },
|
|
|
- async update({ commit }, { id, ...data }) {
|
|
|
- const res = await this.$axios.$post(`${api.interface}/update/${id}`, data);
|
|
|
- return res;
|
|
|
- },
|
|
|
- async delete({ commit }, payload) {
|
|
|
- const res = await this.$axios.$delete(`${api.interface}/${payload}`);
|
|
|
- return res;
|
|
|
- },
|
|
|
- async modelQuery({ commit }, { skip = 0, limit, ...info } = {}) {
|
|
|
- const res = await this.$axios.$get(`${api.model}`, { skip, limit, ...info });
|
|
|
- return res;
|
|
|
- },
|
|
|
- async modelCreate({ commit }, payload) {
|
|
|
- const res = await this.$axios.$post(`${api.model}`, payload);
|
|
|
- return res;
|
|
|
- },
|
|
|
- async modelFetch({ commit }, payload) {
|
|
|
- const res = await this.$axios.$get(`${api.model}/${payload}`);
|
|
|
- return res;
|
|
|
- },
|
|
|
- async modelUpdate({ commit }, { id, ...data }) {
|
|
|
- const res = await this.$axios.$post(`${api.model}/update/${id}`, data);
|
|
|
- return res;
|
|
|
- },
|
|
|
- async modelDelete({ commit }, payload) {
|
|
|
- const res = await this.$axios.$delete(`${api.model}/${payload}`);
|
|
|
- return res;
|
|
|
- },
|
|
|
- async arrange({ commit }, payload) {
|
|
|
- const res = await this.$axios.$post(api.arrange(payload));
|
|
|
- return res;
|
|
|
- },
|
|
|
- async teaclass({ commit }, { skip = 0, limit, ...info } = {}) {
|
|
|
- const res = await this.$axios.$get(`${api.teaclass}`, { ...info });
|
|
|
- return res;
|
|
|
- },
|
|
|
- async confirmLesson({ commit }, payload) {
|
|
|
- const res = await this.$axios.$post(`${api.confirm}`, { ids: payload });
|
|
|
- return res;
|
|
|
- },
|
|
|
- // 新排课表 payload :{ids,planid}
|
|
|
- async newArrange({ commit }, payload) {
|
|
|
- const res = await this.$axios.$post(`${api.newArrange}`, payload);
|
|
|
- return res;
|
|
|
- },
|
|
|
- //批量修改
|
|
|
- async pluralUpdate({ commit }, payload) {
|
|
|
- const res = await this.$axios.$post(`${api.pluralUpdate}`, payload);
|
|
|
- return res;
|
|
|
- },
|
|
|
- async mergeRequest({ commit, dispatch }, { method, data }) {
|
|
|
- let toRequest = () => {
|
|
|
- let res = [];
|
|
|
- for (const i of data) {
|
|
|
- res.push(dispatch(method, i));
|
|
|
- }
|
|
|
- return res;
|
|
|
- };
|
|
|
- let result = await axios.all(toRequest());
|
|
|
- let newFilter = data => {
|
|
|
- let res = data.map(i => {
|
|
|
- let type = _.isArray(i);
|
|
|
- if (!type) {
|
|
|
- //fetch的多个请求 是object 将errcode为0的data取出来
|
|
|
- return _.get(i, `data`, i);
|
|
|
- } else {
|
|
|
- //query的多个请求 array 将此数据再次走这个方法
|
|
|
- return newFilter(i);
|
|
|
- }
|
|
|
- });
|
|
|
- return res;
|
|
|
- };
|
|
|
- let returns = _.flattenDeep(newFilter(result));
|
|
|
- return returns;
|
|
|
- },
|
|
|
-};
|
|
|
-export default {
|
|
|
- namespaced: true,
|
|
|
- state,
|
|
|
- mutations,
|
|
|
- actions,
|
|
|
-};
|
|
|
+import Vue from 'vue';
|
|
|
+import Vuex from 'vuex';
|
|
|
+import _ from 'lodash';
|
|
|
+import axios from 'axios';
|
|
|
+Vue.use(Vuex);
|
|
|
+const api = {
|
|
|
+ interface: `/api/train/lesson`,
|
|
|
+ model: `/api/train/lessonmode`,
|
|
|
+ arrange: id => `/api/train/lesson/autolesson/${id}`,
|
|
|
+ pluralUpdate: `/api/train/lesson/uplessones`,
|
|
|
+ teaclass: `/api/train/lesson/teaclass`,
|
|
|
+ confirm: `/api/train/lesson/check`, //锁死课表
|
|
|
+ newArrange: `/api/train/lesson/newarrange`,
|
|
|
+};
|
|
|
+const state = () => ({});
|
|
|
+const mutations = {};
|
|
|
+
|
|
|
+const actions = {
|
|
|
+ async query({ commit }, { skip = 0, limit, ...info } = {}) {
|
|
|
+ const res = await this.$axios.$get(`${api.interface}`, { skip, limit, ...info });
|
|
|
+ return res;
|
|
|
+ },
|
|
|
+ async create({ commit }, payload) {
|
|
|
+ const res = await this.$axios.$post(`${api.interface}`, payload);
|
|
|
+ return res;
|
|
|
+ },
|
|
|
+ async fetch({ commit }, payload) {
|
|
|
+ const res = await this.$axios.$get(`${api.interface}/${payload}`);
|
|
|
+ return res;
|
|
|
+ },
|
|
|
+ async update({ commit }, { id, ...data }) {
|
|
|
+ const res = await this.$axios.$post(`${api.interface}/update/${id}`, data);
|
|
|
+ return res;
|
|
|
+ },
|
|
|
+ async delete({ commit }, payload) {
|
|
|
+ const res = await this.$axios.$delete(`${api.interface}/${payload}`);
|
|
|
+ return res;
|
|
|
+ },
|
|
|
+ async modelQuery({ commit }, { skip = 0, limit, ...info } = {}) {
|
|
|
+ const res = await this.$axios.$get(`${api.model}`, { skip, limit, ...info });
|
|
|
+ return res;
|
|
|
+ },
|
|
|
+ async modelCreate({ commit }, payload) {
|
|
|
+ const res = await this.$axios.$post(`${api.model}`, payload);
|
|
|
+ return res;
|
|
|
+ },
|
|
|
+ async modelFetch({ commit }, payload) {
|
|
|
+ const res = await this.$axios.$get(`${api.model}/${payload}`);
|
|
|
+ return res;
|
|
|
+ },
|
|
|
+ async modelUpdate({ commit }, { id, ...data }) {
|
|
|
+ const res = await this.$axios.$post(`${api.model}/update/${id}`, data);
|
|
|
+ return res;
|
|
|
+ },
|
|
|
+ async modelDelete({ commit }, payload) {
|
|
|
+ const res = await this.$axios.$delete(`${api.model}/${payload}`);
|
|
|
+ return res;
|
|
|
+ },
|
|
|
+ async arrange({ commit }, payload) {
|
|
|
+ const res = await this.$axios.$post(api.arrange(payload));
|
|
|
+ return res;
|
|
|
+ },
|
|
|
+ async teaclass({ commit }, { skip = 0, limit, ...info } = {}) {
|
|
|
+ const res = await this.$axios.$get(`${api.teaclass}`, { ...info });
|
|
|
+ return res;
|
|
|
+ },
|
|
|
+ async confirmLesson({ commit }, payload) {
|
|
|
+ const res = await this.$axios.$post(`${api.confirm}`, payload);
|
|
|
+ return res;
|
|
|
+ },
|
|
|
+ // 新排课表 payload :{ids,planid}
|
|
|
+ async newArrange({ commit }, payload) {
|
|
|
+ const res = await this.$axios.$post(`${api.newArrange}`, payload);
|
|
|
+ return res;
|
|
|
+ },
|
|
|
+ //批量修改
|
|
|
+ async pluralUpdate({ commit }, payload) {
|
|
|
+ const res = await this.$axios.$post(`${api.pluralUpdate}`, payload);
|
|
|
+ return res;
|
|
|
+ },
|
|
|
+ async mergeRequest({ commit, dispatch }, { method, data }) {
|
|
|
+ let toRequest = () => {
|
|
|
+ let res = [];
|
|
|
+ for (const i of data) {
|
|
|
+ res.push(dispatch(method, i));
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ };
|
|
|
+ let result = await axios.all(toRequest());
|
|
|
+ let newFilter = data => {
|
|
|
+ let res = data.map(i => {
|
|
|
+ let type = _.isArray(i);
|
|
|
+ if (!type) {
|
|
|
+ //fetch的多个请求 是object 将errcode为0的data取出来
|
|
|
+ return _.get(i, `data`, i);
|
|
|
+ } else {
|
|
|
+ //query的多个请求 array 将此数据再次走这个方法
|
|
|
+ return newFilter(i);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return res;
|
|
|
+ };
|
|
|
+ let returns = _.flattenDeep(newFilter(result));
|
|
|
+ return returns;
|
|
|
+ },
|
|
|
+};
|
|
|
+export default {
|
|
|
+ namespaced: true,
|
|
|
+ state,
|
|
|
+ mutations,
|
|
|
+ actions,
|
|
|
+};
|