Browse Source

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

guhongwei 5 years ago
parent
commit
fc285cc4f9

+ 9 - 8
src/views/train-plan/attendance.vue

@@ -3,17 +3,17 @@
     <list-frame title="考勤管理" @query="onsearch" :total="total" :needFilter="false" :needAdd="false">
       <el-form :inline="true" size="mini">
         <el-form-item label="期">
-          <el-select v-model="form.termid" placeholder="请选择期数" @change="getBatch">
+          <el-select v-model="form.termid" placeholder="请选择期数" @change="getClasses">
             <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-form-item label="批次">
           <el-select v-model="form.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> -->
         <el-form-item label="班级">
-          <el-select v-model="form.classid" placeholder="请先选择批次">
+          <el-select v-model="form.classid" placeholder="请先选择班级">
             <el-option v-for="(i, index) in classList" :key="index" :label="i.name" :value="i._id"></el-option>
           </el-select>
         </el-form-item>
@@ -86,7 +86,7 @@ export default {
       this.$set(this, `termList`, terms);
       if (this.defaultOption.termid) {
         this.form.termid = this.defaultOption.termid;
-        this.getBatch(this.form.termid);
+        this.getClasses(this.form.termid);
       }
     },
     getBatch(termid) {
@@ -96,9 +96,10 @@ export default {
         this.$set(this, `batchList`, batchnum);
       }
     },
-    async getClasses(batchid) {
-      const res = await this.classesquery({ batchid });
-      this.$set(this, `classList`, res.data);
+    async getClasses(termid) {
+      const res = await this.classesquery({ termid });
+      var arr = res.data.filter(item => item.type == '0');
+      this.$set(this, `classList`, arr);
     },
     async onsearch({ skip = 0, limit = 10, ...info } = {}) {
       const res = await this.query({ termid: this.form.termid, classid: this.form.classid, ...info });

+ 65 - 35
src/views/train-plan/tsbattendance.vue

@@ -1,19 +1,19 @@
 <template>
   <div id="tsbattendance">
-    <list-frame title="特殊班考勤管理" @query="onsearch" :total="total" :needFilter="false" :needAdd="false">
+    <list-frame title="特殊班考勤管理" @query="onsearch" :total="total" :needPag="false" :needFilter="false" :needAdd="false">
       <el-form :inline="true" size="mini">
         <el-form-item label="期">
-          <el-select v-model="form.termid" placeholder="请选择期数" @change="getBatch">
+          <el-select v-model="form.termid" placeholder="请选择期数" @change="getClasses">
             <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-form-item label="批次">
           <el-select v-model="form.batchid" placeholder="请先选择期数" @change="getClasses">
-            <el-option v-for="(i, index) in batchList" :key="index" :label="i.name" :value="i._id"></el-option>
+            <el-option v-for="(i, index) in batchList" :key="index" :label="i.batch" :value="i._id"></el-option>
           </el-select>
-        </el-form-item>
+        </el-form-item> -->
         <el-form-item label="班级">
-          <el-select v-model="form.classid" placeholder="请先选择批次">
+          <el-select v-model="form.classid" placeholder="请先选择期数" @change="changeClass">
             <el-option v-for="(i, index) in classList" :key="index" :label="i.name" :value="i._id"></el-option>
           </el-select>
         </el-form-item>
@@ -22,7 +22,7 @@
         </el-form-item>
       </el-form>
       <el-col :span="24" class="btn">
-        <el-button type="primary" size="mini" @click="onekeyBtn">一键签到</el-button>
+        <el-button type="primary" size="mini" @click="onekeyBtn" :disabled="!allowSign && selected.length <= 0">一键签到</el-button>
       </el-col>
       <data-table :fields="fields" :data="list" :select="true" :selected="selected" @handleSelect="toSelect"> </data-table>
     </list-frame>
@@ -37,6 +37,7 @@ const { mapActions: attendance } = createNamespacedHelpers('attendance');
 const { mapActions: student } = createNamespacedHelpers('student');
 const { mapActions: trainplan } = createNamespacedHelpers('trainplan');
 const { mapActions: classes } = createNamespacedHelpers('classes');
+const { mapActions: classtype } = createNamespacedHelpers('classtype');
 
 export default {
   metaInfo: { title: '特殊班考勤管理' },
@@ -47,26 +48,27 @@ export default {
     dataTable,
   },
   data: () => ({
+    allowSign: false,
     classList: [],
     batchList: [],
     termList: [],
     fields: [
-      { label: '学生姓名', prop: 'stuname' },
-      { label: '日期', prop: 'date' },
-      { label: '时间', prop: 'time' },
-      {
-        label: '类型',
-        prop: 'type',
-        format: item => {
-          return item === '0' ? '上课考勤' : item === '1' ? '上课考勤' : '';
-        },
-      },
+      { label: '学生姓名', prop: 'name' },
+      // { label: '日期', prop: 'date' },
+      // { label: '时间', prop: 'time' },
+      // {
+      //   label: '类型',
+      //   prop: 'type',
+      //   format: item => {
+      //     return item === '0' ? '上课考勤' : item === '1' ? '上课考勤' : '';
+      //   },
+      // },
       {
         label: '状态',
-        prop: 'status',
-        format: item => {
-          return item === '0' ? '未签到' : item === '1' ? '签到' : '迟到';
-        },
+        prop: 'signStatus',
+        // format: item => {
+        //   return item === '0' ? '未签到' : item === '1' ? '签到' : '迟到';
+        // },
       },
     ],
     form: {},
@@ -74,12 +76,15 @@ export default {
     total: 0,
     // 特殊班一键签到选中列表
     selected: [],
+    classTypeList: [],
   }),
   created() {
     this.searchinfo();
+    this.getOtherList();
   },
   computed: { ...mapState(['user', 'defaultOption']) },
   methods: {
+    ...classtype({ getClassType: 'query' }),
     ...attendance(['query', 'delete', 'attendancecreateList']),
     ...student({ stuquery: 'query' }),
     ...trainplan({ planfetch: 'fetch' }),
@@ -90,7 +95,7 @@ export default {
       this.$set(this, `termList`, terms);
       if (this.defaultOption.termid) {
         this.form.termid = this.defaultOption.termid;
-        this.getBatch(this.form.termid);
+        this.getClasses(this.form.termid);
       }
     },
     getBatch(termid) {
@@ -100,24 +105,31 @@ export default {
         this.$set(this, `batchList`, batchnum);
       }
     },
-    async getClasses(batchid) {
-      const res = await this.classesquery({ batchid });
-      var arr = res.data.filter(item => item.type === '1');
+    async getClasses(termid) {
+      const res = await this.classesquery({ termid });
+      var arr = res.data.filter(item => item.type != '0');
       this.$set(this, `classList`, arr);
     },
     async onsearch({ skip = 0, limit = 10, ...info } = {}) {
-      const res = await this.query({ termid: this.form.termid, classid: this.form.classid, ...info });
-      const newdatas = [];
-      for (const data of res.data) {
-        for (const attend of data.attend) {
-          let newdata = { stuname: data.stuname, ...attend };
-          newdatas.push(newdata);
-        }
+      const res = await this.stuquery({ termid: this.form.termid, classid: this.form.classid, ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
       }
+      this.checkSign();
+    },
+    async checkSign() {
+      const res = await this.query({ termid: this.form.termid, classid: this.form.classid });
       if (this.$checkRes(res)) {
-        this.$set(this, `total`, newdatas.length);
-        let _newdatas = newdatas.splice(skip, skip + limit);
-        this.$set(this, `list`, _newdatas);
+        let signList = _.cloneDeep(res.data);
+        let dl = _.cloneDeep(this.list);
+        for (const stu of dl) {
+          let r = signList.find(f => f.studentid == stu._id);
+          if (r) {
+            // TODO 这个地方没有考勤记录,只是生成了这个学生的考勤数据,
+            stu.signStatus = '已签到';
+          }
+        }
+        this.$set(this, `list`, dl);
       }
     },
     // 选中签到学生
@@ -136,6 +148,24 @@ export default {
         });
       }
     },
+    async getOtherList() {
+      const res = await this.getClassType();
+      if (this.$checkRes(res)) this.$set(this, `classTypeList`, res.data);
+    },
+    changeClass(classid) {
+      let r = this.classList.find(f => f._id == classid);
+      if (r) {
+        let { type } = r;
+        r = this.classTypeList.find(f => f.code == type);
+        if (r) {
+          let { sign } = r;
+          if (sign == '0') {
+            this.allowSign = false;
+            this.$message.warning('该班级设置为学生签到,无法一键签到!');
+          }
+        }
+      }
+    },
   },
   watch: {
     defaultOption: {

+ 36 - 59
src/views/train-plan/tsbbedroom.vue

@@ -5,18 +5,31 @@
       <data-table :fields="fields" :data="list" :opera="opera" @edit="toEdit" :usePage="false"></data-table>
     </detail-frame>
     <detail-frame :title="classInfo.name" :returns="toReturns" v-if="view != 'list'">
-      <data-table :fields="stufields" :data="sutlist" :opera="stuopera" @edit="toQinshi"></data-table>
+      <el-row type="flex" align="middle" justify="end" class="btn_bar">
+        <el-col :span="2">
+          <el-button type="primary" size="mini" @click="toSave">保存</el-button>
+        </el-col>
+      </el-row>
+      <el-table :data="stulist" size="mini" border stripe>
+        <template v-for="(f, index) in stufields">
+          <template v-if="f.prop !== 'bedroom'">
+            <el-table-column :key="index" align="center" :label="f.label" :prop="f.prop"></el-table-column>
+          </template>
+          <template v-else-if="f.prop == 'bedroom'">
+            <el-table-column :key="index" align="center" :label="f.label">
+              <template v-slot="{ row }">
+                <el-input size="mini" v-model="row[f.prop]"></el-input>
+              </template>
+            </el-table-column>
+          </template>
+        </template>
+      </el-table>
     </detail-frame>
-    <el-dialog :visible.sync="dialog" title="编辑寝室" @close="toClose" width="30%">
-      <data-form :data="form" :fields="tsbbedroomFields" :rules="{}" @save="turnSave"> </data-form>
-    </el-dialog>
   </div>
 </template>
 
 <script>
 import _ from 'lodash';
-import axios from 'axios';
-import dataForm from '@frame/components/form';
 import dataTable from '@frame/components/filter-page-table';
 import detailFrame from '@frame/layout/admin/detail-frame';
 import { mapState, createNamespacedHelpers } from 'vuex';
@@ -27,22 +40,15 @@ const { mapActions: util } = createNamespacedHelpers('util');
 export default {
   name: 'tsbbedroom',
   props: {},
-  components: { detailFrame, dataTable, dataForm },
+  components: { detailFrame, dataTable },
   data: function() {
     return {
       view: 'list',
       dialog: false,
       form: {},
-      list: [
-        {
-          term: '1',
-          batch: '1',
-          name: '1',
-        },
-      ],
+      list: [],
       stuBedroom: [],
       bedroomList: [],
-      originBedRoomList: [],
       classInfo: {},
       opera: [
         {
@@ -58,31 +64,9 @@ export default {
       ],
       options: undefined,
       // 编辑学生所在寝室
-      sutlist: [
-        {
-          name: '测试',
-          gender: '男',
-          nation: '汉',
-          id_number: '220182199603257019',
-          termname: '1',
-          batchname: '1',
-          classname: '1',
-          school_name: '吉林大学',
-          faculty: '计算机',
-          major: '计算机',
-          phone: '17319450324',
-          email: '123456@163.com',
-        },
-      ],
-      stuopera: [
-        {
-          label: '编辑寝室',
-          icon: 'el-icon-view',
-          method: 'edit',
-        },
-      ],
+      stulist: [],
       stufields: [
-        { label: '寝室号', prop: 'code' },
+        { label: '寝室号', prop: 'bedroom' },
         { label: '姓名', prop: 'name' },
         { label: '性别', prop: 'gender' },
         { label: '民族', prop: 'nation' },
@@ -96,17 +80,12 @@ export default {
         { label: '手机号', prop: 'phone' },
         { label: '邮箱', prop: 'email' },
       ],
-      tsbbedroomFields: [
-        { label: '姓名', model: 'name', type: 'text' },
-        { label: '性别', model: 'gender', type: 'text' },
-        { label: '寝室号', prop: 'code', type: 'input' },
-      ],
     };
   },
   created() {},
   methods: {
     ...classes(['query']),
-    ...student({ getStudentList: 'query', updateStudent: 'update' }),
+    ...student({ getStudentList: 'query', updateStudent: 'update', batUpdateBedroom: 'updateBedroom' }),
     ...bedroom({ bedroomApart: 'apart', getBedroomList: 'query', classstuList: 'classstuList' }),
     ...util({ modelFetch: 'fetch' }),
     // 查询特殊班级
@@ -115,11 +94,16 @@ export default {
       if (!termid) return;
       let res = await this.query({ termid });
       if (this.$checkRes(res)) {
-        // this.$set(this, `list`, res.data);
+        let r = res.data.filter(f => f.type != '0');
+        this.$set(this, `list`, r);
       }
     },
     // 修改
-    toEdit({ data }) {
+    async toEdit({ data }) {
+      const res = await this.getStudentList({ classid: data._id });
+      if (this.$checkRes(res)) {
+        this.$set(this, `stulist`, res.data);
+      }
       this.$set(this, `classInfo`, data);
       this.view = 'class';
     },
@@ -129,18 +113,11 @@ export default {
       this.$set(this, `classInfo`, {});
       this.$set(this, `stuBedroom`, []);
     },
-    // 编辑寝室
-    toQinshi({ data }) {
-      this.$set(this, `form`, data);
-      this.dialog = true;
-    },
-    // 提交编辑寝室
-    turnSave() {
-      console.log(this.form);
-    },
-    // 关闭dialog
-    toClose() {
-      this.dialog = false;
+    async toSave() {
+      // TODO 批量保存学生
+      let duplicate = _.cloneDeep(this.stulist);
+      let res = await this.batUpdateBedroom(duplicate);
+      this.$checkRes(res, '修改成功', res.errmsg);
     },
   },
   watch: {