lrf402788946 4 rokov pred
rodič
commit
12218b6935
1 zmenil súbory, kde vykonal 91 pridanie a 86 odobranie
  1. 91 86
      store/bedroom.js

+ 91 - 86
store/bedroom.js

@@ -1,86 +1,91 @@
-import Vue from 'vue';
-import Vuex from 'vuex';
-import axios from 'axios';
-import _ from 'lodash';
-Vue.use(Vuex);
-const api = {
-  interface: `/api/train/bedroom`,
-  apart: `/api/train/bedroom/apart`,
-  updateBat: `/api/train/bedroom/batch`,
-  assignroom: `/api/train/bedroom/assignroom`,
-};
-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 apart({ commit }, payload) {
-    const res = await this.$axios.$post(`${api.apart}`, payload);
-    return res;
-  },
-  async getClassList({ commit }, payload) {
-    const res = await this.$axios.$get(`${api.interface}/student/${payload}`);
-    return res;
-  },
-  // 批量修改寝室
-  async updateBat({ commit }, payload) {
-    const res = await this.$axios.$post(`${api.updateBat}`, payload);
-    return res;
-  },
-  // 获取本期可以获取
-  async getAssignRoom({ commit }, { termid }) {
-    const res = await this.$axios.$get(`${api.assignroom}`, { termid });
-    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 axios from 'axios';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  interface: `/api/train/bedroom`,
+  apart: `/api/train/bedroom/apart`,
+  updateBat: `/api/train/bedroom/batch`,
+  assignroom: `/api/train/bedroom/assignroom`,
+};
+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 apart({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.apart}`, payload);
+    return res;
+  },
+  async getClassList({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.interface}/student/${payload}`);
+    return res;
+  },
+  // 批量修改寝室
+  async updateBat({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.updateBat}`, payload);
+    return res;
+  },
+  // 获取本期可以获取
+  async getAssignRoom({ commit }, { termid }) {
+    const res = await this.$axios.$get(`${api.assignroom}`, { termid });
+    return res;
+  },
+  //还原寝室,payload:classid
+  async restore({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.interface}/restore/${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,
+};