lrf402788946 4 년 전
부모
커밋
66eaf69299
1개의 변경된 파일56개의 추가작업 그리고 5개의 파일을 삭제
  1. 56 5
      src/views/student/index.vue

+ 56 - 5
src/views/student/index.vue

@@ -20,6 +20,9 @@
         </el-form-item>
       </el-form>
       <el-row style="margin: 20px 0 5px 0" type="flex" align="middle" justify="end">
+        <el-col :span="2">
+          <el-button type="primary" size="mini" @click="toExportStudent">导出学生</el-button>
+        </el-col>
         <el-col :span="2">
           <el-button type="danger" size="mini" :disabled="batchdet.length <= 0" @click="batchdelete">批量删除</el-button>
         </el-col>
@@ -38,6 +41,20 @@
         </template>
       </data-form>
     </el-dialog>
+    <el-dialog title="选择导出学生的范围" :visible.sync="exportDialog" @close="toClose" width="30%">
+      <data-form :data="exportInfo" :fields="exportFields" :rules="{}" @save="toExportExcel" submitText="导出">
+        <template #custom="{ item, form }">
+          <template v-if="item.model === 'termid'">
+            {{ getTerm(form[item.model]) }}
+          </template>
+        </template>
+        <template #options="{item,form}">
+          <template v-if="item.model === 'batchid'">
+            <el-option v-for="(i, index) in batchList" :key="index" :label="`第${i.batch}批`" :value="i._id"></el-option>
+          </template>
+        </template>
+      </data-form>
+    </el-dialog>
   </div>
 </template>
 
@@ -62,6 +79,7 @@ export default {
   },
   data: () => ({
     dialog: false,
+    exportDialog: false,
     opera: [
       {
         label: '编辑',
@@ -108,6 +126,12 @@ export default {
     total: 0,
     selectClassList: [],
     batchdet: [],
+    exportInfo: {},
+    exportFields: [
+      { label: '导出期', model: 'termid', custom: true },
+      { label: '导出批次', model: 'batchid', type: 'select' },
+    ],
+    allClassList: [],
   }),
   created() {
     this.getPlan();
@@ -115,7 +139,7 @@ export default {
   computed: { ...mapState(['user', 'defaultOption']) },
   methods: {
     ...trainplan({ planfetch: 'fetch' }),
-    ...mapActions(['query', 'delete', 'update', 'removeAll', 'computedIsFine']),
+    ...mapActions(['query', 'delete', 'update', 'removeAll', 'computedIsFine', 'toExport']),
     ...classes({ classesquery: 'query' }),
     async search({ skip = 0, limit = 10, ...info } = {}) {
       const res = await this.query({ skip, limit, termid: this.form.termid, classid: this.form.classid, name: this.form.name });
@@ -157,9 +181,10 @@ export default {
         this.getClasses(this.form.termid);
       }
     },
-    async getClasses(termid) {
-      const res = await this.classesquery({ termid });
-      this.$set(this, `classList`, res.data);
+    async getClasses(termid, ...condition) {
+      const res = await this.classesquery({ termid, ...condition });
+      if (condition) this.$set(this, `classList`, res.data);
+      else return res.data;
     },
     async toTurnClass({ data }) {
       let { termid } = data;
@@ -183,8 +208,34 @@ export default {
       if (this.$checkRes(res, '优秀学员设置成功', res.errmsg || '优秀学员设置失败')) this.search();
     },
     toClose() {
+      this.exportDialog = false;
       this.dialog = false;
-      this.form = {};
+      this.exportInfo = {};
+    },
+    // 导出学生弹框
+    toExportStudent() {
+      const { termid } = this.defaultOption;
+      this.$set(this.exportInfo, `termid`, termid);
+      this.toBatchList(termid);
+      this.exportDialog = true;
+    },
+    // 批次列表更改
+    async toBatchList(termid) {
+      const r = this.termList.find(f => f._id === termid);
+      if (r) {
+        const { batchnum } = r;
+        if (batchnum) this.$set(this, `batchList`, batchnum);
+      }
+    },
+    async toExportExcel() {
+      console.log('in function:');
+      let duplicate = _.cloneDeep(this.exportInfo);
+      const res = await this.toExport(duplicate);
+    },
+    getTerm(termid) {
+      console.log(termid);
+      const r = this.termList.find(f => f._id === termid);
+      if (r) return `第${r.term}期`;
     },
   },
   watch: {