Jelajahi Sumber

Merge branch 'master' of http://git.cc-lotus.info/new_train/frame

reloaded 5 tahun lalu
induk
melakukan
6ac784bd38
3 mengubah file dengan 78 tambahan dan 0 penghapusan
  1. 4 0
      store/bedroom.js
  2. 5 0
      store/classes.js
  3. 69 0
      store/count.js

+ 4 - 0
store/bedroom.js

@@ -35,6 +35,10 @@ const actions = {
     const res = await this.$axios.$post(`${api.apart}`, payload);
     const res = await this.$axios.$post(`${api.apart}`, payload);
     return res;
     return res;
   },
   },
+  async getClassList({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.interface}/student/${payload}`);
+    return res;
+  },
   async mergeRequest({ commit, dispatch }, { method, data }) {
   async mergeRequest({ commit, dispatch }, { method, data }) {
     let toRequest = () => {
     let toRequest = () => {
       let res = [];
       let res = [];

+ 5 - 0
store/classes.js

@@ -8,6 +8,7 @@ const api = {
   divide: `/api/train/class/divide`,
   divide: `/api/train/class/divide`,
   updateHeadTeacher: `/api/train/class/uptea`,
   updateHeadTeacher: `/api/train/class/uptea`,
   addStudent: id => `/api/train/class/upstuclass/${id} `, //id:班级id, ids:学生ID列表
   addStudent: id => `/api/train/class/upstuclass/${id} `, //id:班级id, ids:学生ID列表
+  teacherQuery: `/api/train/lesson/classbyteaid`,
 };
 };
 const state = () => ({});
 const state = () => ({});
 const mutations = {};
 const mutations = {};
@@ -17,6 +18,10 @@ const actions = {
     const res = await this.$axios.$get(`${api.interface}`, { skip, limit, ...info });
     const res = await this.$axios.$get(`${api.interface}`, { skip, limit, ...info });
     return res;
     return res;
   },
   },
+  async teacherQuery({ commit }, { skip = 0, limit, ...info } = {}) {
+    const res = await this.$axios.$get(`${api.teacherQuery}`, { skip, limit, ...info });
+    return res;
+  },
   async create({ commit }, payload) {
   async create({ commit }, payload) {
     const res = await this.$axios.$post(`${api.interface}`, payload);
     const res = await this.$axios.$post(`${api.interface}`, payload);
     return res;
     return res;

+ 69 - 0
store/count.js

@@ -0,0 +1,69 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import axios from 'axios';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  interface: `/api/train/count/countstudent`,
+  countSchool: id => `/api/train/count/countschstu/${id}`,
+};
+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 schoolQuery({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.countSchool(payload)}`);
+    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 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,
+};