lrf402788946 5 年之前
父节点
当前提交
e955632ca1
共有 9 个文件被更改,包括 215 次插入4 次删除
  1. 2 1
      package.json
  2. 38 0
      store/attendance.js
  3. 48 0
      store/group.js
  4. 38 0
      store/leave.js
  5. 5 0
      store/login.js
  6. 10 0
      store/questionnaire.js
  7. 38 0
      store/score.js
  8. 1 3
      store/teacher.js
  9. 35 0
      utils/methods-util.js

+ 2 - 1
package.json

@@ -8,8 +8,9 @@
     "lint": "vue-cli-service lint"
   },
   "dependencies": {
+    "axios": "^0.19.2",
     "core-js": "^3.4.4",
-    "element": "^0.1.4",
+    "element-ui": "^2.13.0",
     "jsonwebtoken": "^8.5.1",
     "lodash": "^4.17.15",
     "vue": "^2.6.10",

+ 38 - 0
store/attendance.js

@@ -0,0 +1,38 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  checkInfo: `/api/train/attendance`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit, ...info } = {}) {
+    const res = await this.$axios.$get(`${api.checkInfo}`, { skip, limit, ...info });
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.checkInfo}`, payload);
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.checkInfo}/${payload}`);
+    return res;
+  },
+  async update({ commit }, { id, ...data }) {
+    const res = await this.$axios.$post(`${api.checkInfo}/update/${id}`, data);
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.checkInfo}/${payload}`);
+    return res;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 48 - 0
store/group.js

@@ -0,0 +1,48 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  groupInfo: `/api/train/group`,
+  // insertInfo: `/api/train/group/insert`,
+  // exitInfo: `/api/train/group/exit`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit, termid, batchid, classid, ...info } = {}) {
+    const res = await this.$axios.$get(`${api.groupInfo}`, { skip, limit, ...info, termid, batchid, classid });
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.groupInfo}`, payload);
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.groupInfo}/${payload}`);
+    return res;
+  },
+  async update({ commit }, { id, ...data }) {
+    const res = await this.$axios.$post(`${api.groupInfo}/update/${id}`, data);
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.groupInfo}/${payload}`);
+    return res;
+  },
+  async insert({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.groupInfo}/insert`, payload);
+    return res;
+  },
+  async exit({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.groupInfo}/exit`, payload);
+    return res;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 38 - 0
store/leave.js

@@ -0,0 +1,38 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  leaveInfo: `/api/train/leave`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit, ...info } = {}) {
+    const res = await this.$axios.$get(`${api.leaveInfo}`, { skip, limit, ...info });
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.leaveInfo}`, payload);
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.leaveInfo}/${payload}`);
+    return res;
+  },
+  async update({ commit }, { id, ...data }) {
+    const res = await this.$axios.$post(`${api.leaveInfo}/update/${id}`, data);
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.leaveInfo}/${payload}`);
+    return res;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 5 - 0
store/login.js

@@ -7,6 +7,7 @@ Vue.use(Vuex);
 const api = {
   interface: `/api/train/login`,
   user: id => `/api/train/user/update/${id}`,
+  bind: `/api/train/user/bind`,
 };
 const state = () => ({});
 const mutations = {};
@@ -46,6 +47,10 @@ const actions = {
     let res = await this.$axios.$post(`${api.user(id)}`, info);
     return res;
   },
+  async bind({ commit }, payload) {
+    let res = await this.$axios.$post(`${api.bind}`, payload);
+    return res;
+  },
 };
 export default {
   namespaced: true,

+ 10 - 0
store/questionnaire.js

@@ -1,6 +1,7 @@
 import Vue from 'vue';
 import Vuex from 'vuex';
 import _ from 'lodash';
+import axios from 'axios';
 Vue.use(Vuex);
 const api = {
   interface: `/api/train/questionnaire`,
@@ -29,6 +30,15 @@ const actions = {
     const res = await this.$axios.$delete(`${api.interface}/${payload}`);
     return res;
   },
+  async mergeRequest({ commit, dispatch }, { method, data }) {
+    let toRequest = () => {
+      let res = [];
+      res.push(dispatch(method, data));
+    };
+    let result = await axios.all(toRequest());
+    let arr = _.flattenDeep(_.flattenDeep(result).map(item => item.data));
+    return arr;
+  },
 };
 export default {
   namespaced: true,

+ 38 - 0
store/score.js

@@ -0,0 +1,38 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  scoreInfo: `/api/train/score`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit, ...info } = {}) {
+    const res = await this.$axios.$get(`${api.scoreInfo}`, { skip, limit, ...info });
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.scoreInfo}`, payload);
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.scoreInfo}/${payload}`);
+    return res;
+  },
+  async update({ commit }, { id, ...data }) {
+    const res = await this.$axios.$post(`${api.scoreInfo}/update/${id}`, data);
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.scoreInfo}/${payload}`);
+    return res;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 1 - 3
store/teacher.js

@@ -4,8 +4,6 @@ import _ from 'lodash';
 Vue.use(Vuex);
 const api = {
   interface: `/api/train/teacher`,
-  interfaceEdit: id => `/api/train/teacher/update/${id}`,
-  // interfaceSelect: id => `/api/teacher/show/${id}`,
 };
 const state = () => ({});
 const mutations = {};
@@ -20,7 +18,7 @@ const actions = {
     return res;
   },
   async fetch({ commit }, payload) {
-    const res = await this.$axios.$get(`${api.interface}/show/${payload}`);
+    const res = await this.$axios.$get(`${api.interface}/${payload}`);
     return res;
   },
 

+ 35 - 0
utils/methods-util.js

@@ -0,0 +1,35 @@
+//获取url的参数params
+export const getParams = () => {
+  let str = location.href;
+  let num = str.indexOf('?');
+  const param = {};
+  str = str.substr(num + 1);
+  //history模式使用这个
+  // let num2 = str.indexOf('#');
+  // console.log(num2);
+  // let str2 = '';
+  // if (num2 > 0) {
+  //   str2 = str.substr(0, num2);
+  // } else {
+  //   num2 = str.indexOf('/');
+  //   str2 = str.substr(0, num2);
+  //   console.log(str2);
+  // }
+  const arr = str.split('&');
+  for (let i = 0; i < arr.length; i++) {
+    num = arr[i].indexOf('=');
+    if (num > 0) {
+      const name = arr[i].substring(0, num);
+      const value = arr[i].substr(num + 1);
+      param[name] = decodeURI(value);
+    }
+  }
+  return param;
+};
+
+//判断信息是否过期
+export const isDateOff = dataDate => {
+  const now = new Date(new Date().getTime() - 24 * 60 * 60 * 1000);
+  dataDate = new Date(dataDate);
+  return now.getTime() <= dataDate.getTime();
+};