Procházet zdrojové kódy

班级名单更新

guhongwei před 5 roky
rodič
revize
00196bcdf6

+ 50 - 0
src/layout/class/groupList.vue

@@ -0,0 +1,50 @@
+<template>
+  <div id="groupList">
+    <el-row>
+      <el-col :span="24" class="list" v-for="(item, index) in groupList" :key="index">
+        <el-col :span="20" class="name"> 组名:{{ item.name }} </el-col>
+        <el-col :span="4" class="name">
+          <el-button type="success" size="mini" @click="$router.push({ path: '/class/joinGroup', query: { id: item.id } })">加入</el-button>
+          <!-- <el-button type="success" size="mini" @click="deteles(item.id)">删除</el-button> -->
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'groupList',
+  props: {
+    groupList: null,
+  },
+  components: {},
+  data: () => ({}),
+  created() {},
+  computed: {},
+  methods: {
+    // 删除组
+    // deteles(id) {
+    //   this.$emit('shanchu', id);
+    // },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+p {
+  padding: 0;
+  margin: 0;
+}
+.list {
+  background: #fff;
+  margin: 0 5px 5px 5px;
+  width: 97%;
+  padding: 0 10px;
+  border-radius: 15px;
+}
+.list .name {
+  padding: 15px 0;
+  font-size: 18px;
+}
+</style>

+ 54 - 0
src/layout/class/groupStuList.vue

@@ -0,0 +1,54 @@
+<template>
+  <div id="groupStuList">
+    <el-row>
+      <el-col :span="24" class="list" v-for="(item, index) in groupStuList" :key="index">
+        <van-swipe-cell>
+          <van-cell :border="false" :title="'学生姓名:' + item.name" />
+          <template slot="right">
+            <van-button square type="primary" text="指派" @click="clickLeader()" />
+            <van-button square type="danger" text="退出" @click="clickOut()" />
+          </template>
+        </van-swipe-cell>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'groupStuList',
+  props: {
+    groupStuList: null,
+  },
+  components: {},
+  data: () => ({}),
+  created() {},
+  computed: {},
+  methods: {
+    clickOut() {
+      this.$emit('clickOut');
+    },
+    clickLeader() {
+      this.$emit('clickLeader');
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+p {
+  padding: 0;
+  margin: 0;
+}
+.list {
+  background: #fff;
+  margin: 0 5px 5px 5px;
+  width: 97%;
+  padding: 0 10px;
+  border-radius: 15px;
+}
+.list .name {
+  padding: 15px 0;
+  font-size: 18px;
+}
+</style>

+ 12 - 0
src/router/index.js

@@ -22,6 +22,18 @@ const routes = [
     name: 'class',
     component: () => import('../views/class/achieve.vue'),
   },
+  // 班级名单-分组
+  {
+    path: '/class/group',
+    name: 'class',
+    component: () => import('../views/class/group.vue'),
+  },
+  // 班级名单-加入组
+  {
+    path: '/class/joinGroup',
+    name: 'class',
+    component: () => import('../views/class/joinGroup.vue'),
+  },
   // 问卷调查
   {
     path: '/question/index',

+ 48 - 0
src/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, ...info } = {}) {
+    const res = await this.$axios.$get(`${api.groupInfo}`, { skip, limit, ...info });
+    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.$delete(`${api.groupInfo}/exit`, payload);
+    return res;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 2 - 0
src/store/index.js

@@ -2,12 +2,14 @@ import Vue from 'vue';
 import Vuex from 'vuex';
 import leave from './leave';
 import attendance from './attendance';
+import group from './group';
 Vue.use(Vuex);
 
 export default new Vuex.Store({
   modules: {
     leave,
     attendance,
+    group,
   },
   state: {}, //变量
   mutations: {}, //同步方法

+ 4 - 1
src/util/axios-wrapper.js

@@ -45,7 +45,10 @@ export default class AxiosWrapper {
   $post(uri, data = {}, query, options) {
     return this.$request(uri, data, query, options);
   }
-
+  $delete(uri, data = {}, router, query, options = {}) {
+    options = { ...options, method: 'delete' };
+    return this.$request(uri, data, query, options, router);
+  }
   async $request(uri, data, query, options) {
     // TODO: 合并query和options
     if (_.isObject(query) && _.isObject(options)) {

+ 5 - 1
src/views/class/achieve.vue

@@ -4,7 +4,7 @@
       <el-col :span="24" class="info">
         <el-col :span="24" class="top">
           <el-col :span="15" class="title">
-            学生成绩名单
+            班级学生成绩
           </el-col>
         </el-col>
         <el-col :span="24" class="main">
@@ -81,6 +81,10 @@ export default {
   padding: 0 15px;
   font-size: 20px;
 }
+.top .btn {
+  text-align: right;
+  padding: 0 30px;
+}
 .main {
   margin: 0 0 50px 0;
 }

+ 117 - 0
src/views/class/group.vue

@@ -0,0 +1,117 @@
+<template>
+  <div id="group">
+    <el-row>
+      <el-col :span="24" class="info">
+        <el-col :span="24" class="top">
+          <el-col :span="15" class="title">
+            班级分组名单
+          </el-col>
+          <span v-if="role === '4'">
+            <el-col :span="9" class="btn">
+              <el-button type="primary" @click="clickAdd()">创建组</el-button>
+            </el-col>
+          </span>
+        </el-col>
+        <el-col :span="24" class="main">
+          <groupList :groupList="groupList"></groupList>
+          <!-- 删除组 -->
+          <!-- @shanchu="shanchu" -->
+        </el-col>
+        <el-col :span="24" class="foot">
+          <footInfo></footInfo>
+        </el-col>
+      </el-col>
+    </el-row>
+    <van-dialog v-model="show" title="创建小组" :showConfirmButton="false">
+      <van-form @submit="onSubmit">
+        <van-field v-model="form.name" name="组名" label="组名" placeholder="请输入小组名称" />
+        <div style="margin: 16px;">
+          <van-button round block type="info" native-type="submit">
+            提交
+          </van-button>
+        </div>
+      </van-form>
+    </van-dialog>
+  </div>
+</template>
+
+<script>
+import footInfo from '@/layout/index/footInfo.vue';
+import groupList from '@/layout/class/groupList.vue';
+import { createNamespacedHelpers, mapGetters } from 'vuex';
+const { mapActions: mapGroup } = createNamespacedHelpers('group');
+export default {
+  name: 'achieve',
+  props: {},
+  components: {
+    footInfo, //底部信息
+    groupList, //分组列表
+  },
+  data: () => ({
+    role: '4',
+    groupList: [],
+    form: {},
+    show: false,
+  }),
+  created() {
+    this.searchInfo();
+  },
+  computed: {
+    keyWord() {
+      let meta = this.$route.meta;
+      let main = meta.title || '';
+      return main;
+    },
+  },
+  methods: {
+    ...mapGroup(['query', 'create', 'delete']),
+    clickAdd() {
+      this.show = true;
+    },
+    async searchInfo({ ...info } = {}) {
+      const res = await this.query({ ...info });
+      this.$set(this, `groupList`, res.data);
+    },
+    async onSubmit(form) {
+      let data = this.form;
+      let res = await this.create(data);
+      let msg = `${this.keyWord}创建分组成功`;
+      if (this.$checkRes(res, msg)) this.show = false;
+      this.searchInfo();
+    },
+    // 删除组
+    // async shanchu(id) {
+    //   console.log(id);
+    //   const res = await this.delete(id);
+    //   this.$checkRes(res, '删除成功', '删除失败');
+    //   this.searchInfo();
+    // },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.info {
+  width: 100%;
+  min-height: 667px;
+  position: relative;
+  background-color: #edeae8;
+}
+.top {
+  height: 50px;
+  line-height: 50px;
+  margin: 0 0 10px 0;
+  background: #fff;
+}
+.top .title {
+  padding: 0 15px;
+  font-size: 20px;
+}
+.top .btn {
+  text-align: right;
+  padding: 0 30px;
+}
+.main {
+  margin: 0 0 50px 0;
+}
+</style>

+ 6 - 4
src/views/class/index.vue

@@ -3,11 +3,14 @@
     <el-row>
       <el-col :span="24" class="info">
         <el-col :span="24" class="top">
-          <el-col :span="15" class="title">
+          <el-col :span="10" class="title">
             班级学生名单
           </el-col>
+          <el-col :span="7" class="btn">
+            <el-button type="primary" @click="$router.push({ path: '/class/group' })">分组</el-button>
+          </el-col>
           <span v-if="role === '4'">
-            <el-col :span="9" class="btn">
+            <el-col :span="7" class="btn">
               <el-button type="primary" @click="$router.push({ path: '/class/achieve' })">上成绩</el-button>
             </el-col>
           </span>
@@ -103,8 +106,7 @@ export default {
   font-size: 20px;
 }
 .top .btn {
-  text-align: right;
-  padding: 0 30px;
+  text-align: center;
 }
 .main {
   margin: 0 0 50px 0;

+ 113 - 0
src/views/class/joinGroup.vue

@@ -0,0 +1,113 @@
+<template>
+  <div id="joinGroup">
+    <el-row>
+      <el-col :span="24" class="info">
+        <el-col :span="24" class="top">
+          <el-col :span="15" class="title">
+            {{ groupName }}
+          </el-col>
+          <el-col :span="9" class="btn">
+            <el-button type="primary" @click="joinGroup()">进组</el-button>
+          </el-col>
+        </el-col>
+        <el-col :span="24" class="main">
+          <groupStuList :groupStuList="groupStuList" @clickLeader="clickLeader" @clickOut="clickOut"></groupStuList>
+        </el-col>
+        <el-col :span="24" class="foot">
+          <footInfo></footInfo>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import footInfo from '@/layout/index/footInfo.vue';
+import groupStuList from '@/layout/class/groupStuList.vue';
+
+import { createNamespacedHelpers, mapGetters } from 'vuex';
+const { mapActions: mapGroup } = createNamespacedHelpers('group');
+export default {
+  name: 'joinGroup',
+  props: {},
+  components: {
+    footInfo, //底部信息
+    groupStuList, //组学生列表
+  },
+  data: () => ({
+    groupName: '',
+    groupStuList: [
+      {
+        name: '流域',
+      },
+    ],
+  }),
+  created() {
+    this.searchInfo();
+  },
+  computed: {
+    id() {
+      return this.$route.query.id;
+    },
+    keyWord() {
+      let meta = this.$route.meta;
+      let main = meta.title || '';
+      return main;
+    },
+  },
+  methods: {
+    ...mapGroup(['query', 'create', 'delete', 'fetch', 'update', 'insert', 'exit']),
+    async searchInfo() {
+      if (this.$route.query.id) {
+        const res = await this.fetch(this.id);
+        this.$set(this, `groupName`, res.data.name);
+        // this.$set(this, `groupStuList`, res.data.studentid);
+        for (const val of res.data.studentid) {
+          console.log(val);
+        }
+      }
+    },
+    async joinGroup() {
+      const res = await this.insert({ groupid: this.id, studentid: '20200220' });
+      const msg = `${this.keyWord}进组成功`;
+      if (this.$checkRes(res, msg));
+      this.searchInfo();
+    },
+    async clickOut() {
+      const res = await this.exit({ groupid: this.id, studentid: '20200220' });
+      const msg = `${this.keyWord}退组成功`;
+      if (this.$checkRes(res, msg));
+      this.searchInfo();
+    },
+    clickLeader() {
+      console.log('指派组长');
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.info {
+  width: 100%;
+  min-height: 667px;
+  position: relative;
+  background-color: #edeae8;
+}
+.top {
+  height: 50px;
+  line-height: 50px;
+  margin: 0 0 10px 0;
+  background: #fff;
+}
+.top .title {
+  padding: 0 15px;
+  font-size: 20px;
+}
+.top .btn {
+  text-align: right;
+  padding: 0 30px;
+}
+.main {
+  margin: 0 0 50px 0;
+}
+</style>