瀏覽代碼

改了很多.忘了

lrf402788946 4 年之前
父節點
當前提交
d45e5e455c
共有 3 個文件被更改,包括 36 次插入35 次删除
  1. 25 14
      src/views/kaoqin/index.vue
  2. 10 20
      src/views/new-plan/detail.vue
  3. 1 1
      src/views/new-plan/student.vue

+ 25 - 14
src/views/kaoqin/index.vue

@@ -9,12 +9,12 @@
         </el-form-item>
         <el-form-item label="期">
           <el-select v-model="form.termid" placeholder="请选择期数" @change="getBatch">
-            <el-option v-for="(i, index) in termList" :key="index" :label="`第${i.term}期`" :value="i._id"></el-option>
+            <el-option v-for="(i, index) in termList" :key="index" :label="`第${i.term}期`" :value="i.termid"></el-option>
           </el-select>
         </el-form-item>
         <el-form-item label="批次">
-          <el-select v-model="form.batchid" placeholder="请先选择期数">
-            <el-option v-for="(i, index) in batchList" :key="index" :label="i.name" :value="i._id"></el-option>
+          <el-select v-model="form.batchid" placeholder="请先选择期数" @change="getClass">
+            <el-option v-for="(i, index) in batchList" :key="index" :label="`第${i.batch}批`" :value="i.batchid"></el-option>
           </el-select>
         </el-form-item>
         <el-form-item label="班级">
@@ -41,6 +41,7 @@
   </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';
@@ -98,6 +99,7 @@ export default {
     form: {},
     list: [],
     total: 0,
+    arrange: [],
   }),
   created() {
     this.searchinfo();
@@ -117,20 +119,29 @@ export default {
     //计划
     async changejh(ids) {
       const res = await this.fetchUtil({ model: 'schtime', planid: ids, schid: this.user.code });
-
-      this.$set(this, `termList`, res.data.term);
+      if (this.$checkRes(res)) {
+        let { arrange } = res.data;
+        this.$set(this, `arrange`, arrange);
+        let termList = arrange.map(i => {
+          let { term, termid } = i;
+          return { term, termid };
+        });
+        termList = _.orderBy(_.uniqBy(termList, 'termid'), ['term'], ['asc']);
+        this.$set(this, `termList`, termList);
+      }
     },
     getBatch(termid) {
-      let batchs = this.termList.filter(f => f._id === termid);
-      if (batchs.length > 0) {
-        let { batchnum } = batchs[0];
-        this.$set(this, `batchList`, batchnum);
-      }
+      let batchs = this.arrange.filter(f => f.termid === termid);
+      let batchList = batchs.map(i => {
+        let { batch, batchid } = i;
+        return { batch, batchid };
+      });
+      batchList = _.orderBy(_.uniqBy(batchList, 'batchid'), ['batch'], ['asc']);
+      this.$set(this, `batchList`, batchList);
     },
-    async changeqi(termid) {
-      const res = await this.classesquery({ termid });
-      console.log(res.data);
-      this.$set(this, `classList`, res.data);
+    async getClass(batchid) {
+      const res = await this.classesquery({ batchid });
+      if (this.$checkRes(res)) this.$set(this, `classList`, res.data);
     },
 
     async onsearch({ skip = 0, limit = 10, ...info } = {}) {

+ 10 - 20
src/views/new-plan/detail.vue

@@ -43,6 +43,7 @@ export default {
       list: [],
       fields: [
         { label: '期数', prop: 'term' },
+        { label: '批次', prop: 'batch' },
         { label: '人数', prop: 'number' },
         { label: '班级类型', prop: 'type', format: true },
       ],
@@ -86,32 +87,21 @@ export default {
       if (this.$checkRes(res)) {
         let { arrange } = res.data;
         let { termnum } = this.plan;
-        arrange = _.groupBy(arrange, 'term');
-        let keys = Object.keys(arrange);
-        let arr = keys.map(key => {
-          let rt = termnum.find(f => f.term == key);
-          let ar = arrange[key];
-          ar = ar.map(a => {
-            let rb = rt.batchnum.find(f => f.batch == a.batch);
+        arrange = arrange.map(i => {
+          let rt = termnum.find(f => f.term == i.term);
+          if (rt) {
+            let rb = rt.batchnum.find(f => f.batch == i.batch);
             if (rb) {
               let bh = _.head(rb.class);
               let { type } = bh;
-              a.type = type;
-              return a;
+              i.type = type;
             }
-          });
-          let garr = _.groupBy(ar, 'type');
-          let gks = Object.keys(garr);
-          garr = gks.map(gk => {
-            let { term, termid } = _.head(garr[gk]);
-            let number = garr[gk].reduce((p, n) => p + n.number * 1, 0);
-            return { term, termid, number, type: gk };
-          });
-          return garr;
+          }
+          return i;
         });
-        arr = arr.flat();
+        arrange = _.orderBy(arrange, ['term', 'batch'], ['asc', 'asc']);
         this.$set(this, `info`, res.data);
-        this.$set(this, `list`, arr);
+        this.$set(this, `list`, arrange);
       }
     },
     toNamelist({ data }) {

+ 1 - 1
src/views/new-plan/student.vue

@@ -3,7 +3,7 @@
     <list-frame :title="pageTitle" @query="search" :total="total" :needFilter="false" :needAdd="false" :returns="toReturns">
       <el-row style="margin: 20px 0 5px 0" type="flex" align="middle" justify="end">
         <el-col :span="2">
-          <el-button type="danger" size="mini" :disabled="batchdet.length <= 0" @click="batchdelete">批量删除</el-button>
+          <el-button type="danger" size="mini" :disabled="batchdet.length <= 0" @click="batchdelete">删除</el-button>
         </el-col>
       </el-row>
       <data-table :fields="fields" :data="list" @handleSelect="handleSelect" :select="true" :opera="opera" @edit="toEdit" @delete="toDelete"></data-table>