lrf402788946 5 jaren geleden
bovenliggende
commit
d935302366

+ 6 - 0
src/router/index.js

@@ -54,6 +54,12 @@ const newPlan = [
     meta: { title: '分寝' },
     component: () => import('@/views/new-plan/class/bedroom.vue'),
   },
+  {
+    path: '/newPlan/classes/namelist',
+    name: 'newPlan_classes_namelist',
+    meta: { title: '班级人员' },
+    component: () => import('@/views/new-plan/class/name-list.vue'),
+  },
 ];
 
 const routes = [

+ 31 - 18
src/views/new-plan/class/classes.vue

@@ -1,20 +1,24 @@
 <template>
   <div id="plan">
-    <!-- 根据计划,获取所有期数及期数下批次,然后提供选择期数;查询出该期数下学校上报的学生,选择学生手动分班 -->
-    <list-frame :title="mainTitle" @query="stuSearch" :total="total" :filter="filterFields" :needAdd="false" returns="./index">
+    <!-- 根据计划,获取所有期数及期数下批次,然后提供选择期数;查询出该期数下学校上报的学生,选择学生手动分班  :filter="filterFields"-->
+    <list-frame :title="mainTitle" @query="stuSearch" :total="total" :needAdd="false" :needFilter="false" returns="./index">
       <template #options="{item}">
         <template v-if="item.model === 'termid'">
           <el-option v-for="(i, index) in termList" :key="index" :label="`第${i.term}期`" :value="i._id"></el-option>
         </template>
       </template>
       <el-card style="padding:10px">
-        <el-row type="flex" justify="space-around" :gutter="10" align="middle" style="padding:10px 0;">
-          <el-col :span="7">班级需求:{{ selectInfo.personReq }}人</el-col>
-          <el-col :span="7">已选择学生:{{ selected.length }}人</el-col>
-          <el-col :span="7">男性:{{ selectInfo.male }}人</el-col>
-          <el-col :span="7">女性:{{ selectInfo.female }}人</el-col>
-        </el-row>
         <el-row>
+          <el-form :inline="true" size="mini">
+            <el-form-item label="期">
+              <el-select v-model="selectInfo.termid" placeholder="请选择期数" @change="stuSearch">
+                <el-option v-for="(i, index) in termList" :key="index" :label="`第${i.term}期`" :value="i._id"></el-option>
+              </el-select>
+            </el-form-item>
+            <el-form-item>
+              <el-button type="primary" @click="toSetClass">一键分班</el-button>
+            </el-form-item>
+          </el-form>
           <el-form :inline="true" size="mini">
             <el-form-item label="批次">
               <el-select v-model="selectInfo.batchid" placeholder="请先选择期数" @change="getClasses">
@@ -31,6 +35,13 @@
             </el-form-item>
           </el-form>
         </el-row>
+        <el-row type="flex" justify="space-around" :gutter="10" align="middle" style="padding:10px 0;">
+          <el-col :span="7">班级需求:{{ selectInfo.personReq }}人</el-col>
+          <el-col :span="7">已选择学生:{{ selected.length }}人</el-col>
+          <el-col :span="7">男性:{{ selectInfo.male }}人</el-col>
+          <el-col :span="7">女性:{{ selectInfo.female }}人</el-col>
+        </el-row>
+
         <data-table
           ref="table"
           :fields="fields"
@@ -70,7 +81,7 @@ export default {
       { label: '学校', prop: 'school_name' },
       { label: '性别', prop: 'gender' },
     ],
-    filterFields: [{ label: '期数', model: 'termid', type: 'select' }],
+    filterFields: [], //{ label: '期数', model: 'termid', type: 'select' }
     list: [],
     selected: [],
     selectedTest: [],
@@ -105,15 +116,15 @@ export default {
     },
     //查询选择期上报的学生,提供批次选择
     async stuSearch({ skip = 0, limit = 10, ...info } = {}) {
-      let { termid } = info;
-      this.selectInfo.termid = termid;
-      const res = await this.getStudentList({ termid: termid, skip, limit });
+      // let { termid } = info;
+      // this.selectInfo.termid = termid;
+      const res = await this.getStudentList({ termid: this.selectInfo.termid, skip, limit });
       if (this.$checkRes(res)) {
         this.$set(this, `list`, res.data);
         this.$set(this, `total`, res.total);
       }
       if (skip !== 0) return;
-      this.getBatch(termid);
+      this.getBatch(this.selectInfo.termid);
     },
     getBatch(termid) {
       let batchs = this.termList.filter(f => f._id === termid);
@@ -171,12 +182,14 @@ export default {
     },
     async toSetClass() {
       // 整理数据生成班级;将学生列表重新查询=>为了将已经有班级的学生剔除,以便继续分班(重新查询)
-      let info = JSON.parse(JSON.stringify(_.omit(this.selectInfo, ['male', 'female', 'personReq'])));
-      let stuList = JSON.parse(JSON.stringify(this.selected));
-      // if (this.isOutRange(stuList)) return;
-      info.students = stuList;
+      let info = JSON.parse(JSON.stringify(_.omit(this.selectInfo, ['male', 'female', 'personReq', 'students'])));
+      info.planid = this.id;
+      //手动添加学生使用这部分,接口换了,之后转移到新加的手动
+      // let stuList = JSON.parse(JSON.stringify(this.selected));
+      // // if (this.isOutRange(stuList)) return;
+      // info.students = stuList;
       let res = await this.createClass(info);
-      if (this.$checkRes(res, '分班成功', '分班失败')) this.$router.push({ path: '/plan/index' });
+      if (this.$checkRes(res, '分班成功', '分班失败')) this.$router.push({ path: './index' });
       //重置信息
       // this.selectInfo = {
       //   male: 0,

+ 9 - 0
src/views/new-plan/class/index-class.vue

@@ -10,6 +10,7 @@
         @setting="toSetting"
         @msg="sendMsg"
         @bedroom="toBedroom"
+        @classlist="toClasslist"
       ></data-table>
     </list-frame>
   </div>
@@ -48,6 +49,11 @@ export default {
           icon: 'el-icon-school',
           method: 'classes',
         },
+        {
+          label: '班级人员管理',
+          icon: 'el-icon-s-custom',
+          method: 'classlist',
+        },
         {
           label: '分寝',
           icon: 'el-icon-s-home',
@@ -108,6 +114,9 @@ export default {
     toBedroom({ data }) {
       this.$router.push({ path: './bedroom', query: { id: data.id } });
     },
+    toClasslist({ data }) {
+      this.$router.push({ path: './namelist', query: { id: data.id } });
+    },
     async sendMsg({ data }) {
       //TODO need test
       let res = await this.getClasses({ planid: data._id });

+ 129 - 0
src/views/new-plan/class/name-list.vue

@@ -0,0 +1,129 @@
+<template>
+  <div id="name-list">
+    <list-frame :title="pageTitle" @query="classSearch" :total="total" :needAdd="false" :needFilter="false" returns="./index">
+      <el-card style="padding:10px">
+        <el-row>
+          <el-form :inline="true" size="mini">
+            <el-form-item label="期">
+              <el-select v-model="selectInfo.termid" placeholder="请选择期数" @change="getBatch">
+                <el-option v-for="(i, index) in termList" :key="index" :label="`第${i.term}期`" :value="i._id"></el-option>
+              </el-select>
+            </el-form-item>
+            <el-form-item label="批次">
+              <el-select v-model="selectInfo.batchid" placeholder="请先选择期数" @change="getClasses">
+                <el-option v-for="(i, index) in batchList" :key="index" :label="i.name" :value="i._id"></el-option>
+              </el-select>
+            </el-form-item>
+            <el-form-item label="班级">
+              <el-select v-model="selectInfo.classname" placeholder="请先选择批次" @change="getStudent">
+                <el-option v-for="(i, index) in classList" :key="index" :label="i.name" :value="i._id"></el-option>
+              </el-select>
+            </el-form-item>
+          </el-form>
+        </el-row>
+        <data-table :fields="fields" :data="list" :opera="opera" @turn="toTurn" @delete="toDelete"></data-table>
+      </el-card>
+    </list-frame>
+  </div>
+</template>
+
+<script>
+import _ from 'lodash';
+import listFrame from '@frame/layout/admin/list-frame';
+import dataTable from '@frame/components/data-table';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: trainPlan } = createNamespacedHelpers('trainplan');
+const { mapActions: classes } = createNamespacedHelpers('classes');
+const { mapActions: student } = createNamespacedHelpers('student');
+export default {
+  name: 'name-list',
+  props: {},
+  components: { listFrame, dataTable },
+  data: function() {
+    return {
+      termList: [],
+      batchList: [],
+      classList: [],
+      list: [],
+      opera: [
+        {
+          label: '转班',
+          icon: 'el-icon-refresh',
+          method: 'turn',
+        },
+        {
+          label: '移除该班',
+          icon: 'el-icon-delete',
+          method: 'delete',
+          confirm: true,
+        },
+      ],
+      fields: [
+        { label: '姓名', prop: 'name' },
+        { label: '性别', prop: 'gender' },
+        { label: '民族', prop: 'nation' },
+        { label: '身份证号', prop: 'id_number' },
+        { label: '期', prop: 'term' },
+        { label: '批次', prop: 'batch' },
+        { label: '班级', prop: 'class' },
+        { label: '学校', prop: 'school_name' },
+        { label: '院系', prop: 'faculty' },
+        { label: '专业', prop: 'major' },
+        { label: '手机号', prop: 'phone' },
+        { label: '邮箱', prop: 'email' },
+      ],
+      selectInfo: {},
+      total: 0,
+    };
+  },
+  created() {
+    this.search();
+  },
+  methods: {
+    ...trainPlan(['fetch']),
+    ...classes({ getClassesList: 'query' }),
+    ...student({ getStudentList: 'query' }),
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      const res = await this.fetch(this.id);
+      if (this.$checkRes(res)) {
+        let { termnum } = res.data;
+        this.$set(this, `termList`, termnum);
+      }
+    },
+    getBatch(termid) {
+      let batchs = this.termList.filter(f => f._id === termid);
+      if (batchs.length > 0) {
+        let { batchnum } = batchs[0];
+        this.$set(this, `batchList`, batchnum);
+      }
+    },
+    //根据批次id,查询下面的班级
+    async getClasses(data) {
+      const res = await this.getClassesList({ batchid: data });
+      if (this.$checkRes(res)) {
+        this.$set(this, `classList`, res.data);
+      }
+    },
+    async getStudent(batchid) {
+      let res = await this.getStudentList({ batchid });
+    },
+    async classSearch({ skip = 0, limit = 10, ...info } = {}) {},
+    toTurn({ data }) {},
+    toDelete({ data }) {},
+  },
+  computed: {
+    ...mapState(['user']),
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+    id() {
+      return this.$route.query.id;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+
+<style lang="less" scoped></style>