lrf402788946 4 éve
szülő
commit
6c5f1e6aad
1 módosított fájl, 56 hozzáadás és 81 törlés
  1. 56 81
      src/views/kaoqin/index.vue

+ 56 - 81
src/views/kaoqin/index.vue

@@ -2,19 +2,9 @@
   <div id="index">
     <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.id" size="mini" placeholder="请选择计划" @change="changejh">
-            <el-option v-for="(i, index) in planList" :key="index" :label="i.title" :value="i.id"></el-option>
-          </el-select>
-        </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.termid"></el-option>
-          </el-select>
-        </el-form-item>
-        <el-form-item label="批次">
-          <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 v-model="form.termid" placeholder="请选择期数" @change="getClass">
+            <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="班级">
@@ -26,17 +16,7 @@
           <el-button type="primary" size="mini" @click="onsearch()"> 查询</el-button>
         </el-form-item>
       </el-form>
-
-      <!-- <el-select v-model="form.termid" size="mini" placeholder="请选择期" @change="changeqi">
-        <el-option label="请选择" value="shanghai"></el-option>
-        <el-option v-for="(m, index) in termList" :key="index" :label="m.termnum" :value="m.termid"></el-option>
-      </el-select>
-
-      <el-select v-model="form.name" size="mini" placeholder="请选择班">
-        <el-option v-for="(m, index) in classList" :key="index" :label="m.name" :value="m.id"></el-option>
-      </el-select> -->
-      <!-- <el-button type="primary" size="mini" @click="onsearch()"> 查询</el-button> -->
-      <data-table :fields="fields" :data="list" :opera="opera" @edit="toEdit" @delete="toDelete"> </data-table>
+      <data-table :fields="fields" :data="list" :opera="opera"> </data-table>
     </list-frame>
   </div>
 </template>
@@ -52,7 +32,7 @@ const { mapActions: util } = createNamespacedHelpers('util');
 const { mapActions: classes } = createNamespacedHelpers('classes');
 
 export default {
-  metaInfo: { title: '题库列表页' },
+  metaInfo: { title: '考勤管理' },
   name: 'index',
   props: {},
   components: {
@@ -64,21 +44,9 @@ export default {
     batchList: [],
     termList: [],
     planList: [],
-    opera: [
-      {
-        label: '编辑',
-        icon: 'el-icon-edit',
-        method: 'edit',
-      },
-      {
-        label: '删除',
-        icon: 'el-icon-delete',
-        method: 'delete',
-        confirm: true,
-      },
-    ],
+    opera: [],
     fields: [
-      { label: '日期', prop: 'date' },
+      { label: '学生姓名', prop: 'stuname' },
       { label: '时间', prop: 'time' },
 
       {
@@ -100,64 +68,71 @@ export default {
     list: [],
     total: 0,
     arrange: [],
+    options: undefined,
   }),
-  created() {
-    this.searchinfo();
-  },
+  created() {},
   computed: { ...mapState(['user', 'defaultOption']) },
   methods: {
     ...mapActions(['query', 'delete']),
     ...student({ stuquery: 'query' }),
-    ...trainplan({ schPlanquery: 'query' }),
+    ...trainplan({ schPlanquery: 'query', planFetch: 'fetch' }),
     ...util({ fetchUtil: 'fetch' }),
     ...classes({ classesquery: 'query' }),
-    async searchinfo() {
-      let stuid = this.user.id;
-      const res = await this.schPlanquery();
-      this.$set(this, `planList`, res.data);
-    },
-    //计划
-    async changejh(ids) {
-      const res = await this.fetchUtil({ model: 'schtime', planid: ids, schid: this.user.code });
-      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.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 search() {
+      const res = await this.planFetch(this.defaultOption.planid);
+      this.$set(this, `termList`, _.get(res.data, 'termnum'));
+      if (this.defaultOption.termid) this.form.termid = this.defaultOption.termid;
+      this.getClass(this.defaultOption.termid);
     },
-    async getClass(batchid) {
-      const res = await this.classesquery({ batchid });
+    async getClass(termid) {
+      const res = await this.classesquery({ termid });
       if (this.$checkRes(res)) this.$set(this, `classList`, res.data);
     },
 
     async onsearch({ skip = 0, limit = 10, ...info } = {}) {
-      const res = await this.query({ skip, termid: this.form.termid, classid: this.form.classid, limit, ...info, schid: this.user.code });
+      const res = await this.query({ termid: this.form.termid, classid: this.form.classid, ...info });
+      const newdatas = [];
+      if (this.form.name) {
+        var arr = res.data.filter(item => item.stuname == this.form.name);
+        for (const data of arr) {
+          for (const attend of data.attend) {
+            let newdata = { stuname: data.stuname, ...attend };
+            newdatas.push(newdata);
+          }
+        }
+      } else {
+        for (const data of res.data) {
+          for (const attend of data.attend) {
+            let newdata = { stuname: data.stuname, ...attend };
+            newdatas.push(newdata);
+          }
+        }
+      }
       if (this.$checkRes(res)) {
-        this.$set(this, `list`, res.data);
-        this.$set(this, `total`, res.total);
+        this.$set(this, `total`, newdatas.length);
+        let _newdatas = newdatas.splice(skip, skip + limit);
+        this.$set(this, `list`, _newdatas);
       }
     },
-    toEdit({ data }) {
-      this.$router.push({ path: '/itembank/detail', query: { id: data.id } });
-    },
-    async toDelete({ data }) {
-      const res = await this.delete(data.id);
-      this.$checkRes(res, '删除成功', '删除失败');
-      this.search();
+  },
+
+  watch: {
+    defaultOption: {
+      immediate: true,
+      deep: true,
+      handler(val) {
+        if (!_.get(this, 'options')) {
+          this.$set(this, `options`, _.cloneDeep(val));
+          this.search();
+        } else {
+          let ntermid = _.get(val, 'termid');
+          let otermid = _.get(this.options, 'termid');
+          if (ntermid && !_.isEqual(ntermid, otermid)) {
+            this.$set(this, `options`, _.cloneDeep(val));
+            this.search();
+          }
+        }
+      },
     },
   },
 };