lrf402788946 4 years ago
parent
commit
ca124732b8
1 changed files with 25 additions and 25 deletions
  1. 25 25
      src/views/task/taskList.vue

+ 25 - 25
src/views/task/taskList.vue

@@ -1,11 +1,14 @@
 <template>
   <div id="taskList">
-    <list-frame :title="pageTitle" @query="search" :needFilter="false" :needAdd="false" :needPag="false">
-      <el-col :span="24" class="total">
-        <p>
-          班级人数:<span>{{ stuTotal }}</span> 作业人数:<span>{{ total }}</span>
-        </p>
-      </el-col>
+    <list-frame :title="pageTitle" returns="/task/index" @query="search" :needFilter="false" :needAdd="false" :needPag="false">
+      <el-row class="total">
+        <el-col :span="24">
+          <p>
+            班级人数:<span>{{ stuTotal }}</span> 作业人数:<span>{{ total }}</span>
+          </p>
+        </el-col>
+        <el-col :span="24" style="font-size:18px;color:#ff0000">没交作业的学生:{{ getNoTask() }}</el-col>
+      </el-row>
       <data-table :fields="fields" :data="tableData" :opera="opera" @view="toTaskDetail">
         <template #custom="{item, row}">
           <template v-if="item.prop === 'picurl'">
@@ -51,6 +54,7 @@ export default {
     options: undefined,
     image: require('@/assets/logo.png'),
     dialog: false,
+    stuList: [],
   }),
   created() {
     this.search();
@@ -84,31 +88,27 @@ export default {
     // 查班级学生
     async searchstu() {
       let res = await this.stuQuery({ classid: this.id });
-      if (res.errcode == 0) this.$set(this, `stuTotal`, res.total);
+      if (res.errcode == 0) {
+        this.$set(this, `stuTotal`, res.total);
+        this.$set(this, `stuList`, res.data);
+      }
     },
     // 放大图片
     btnpicurl(url) {
       this.$set(this, `image`, url);
       this.dialog = true;
     },
-  },
-  watch: {
-    defaultOption: {
-      immediate: true,
-      deep: true,
-      handler(val) {
-        if (!_.get(this, 'options')) {
-          this.$set(this, `options`, _.cloneDeep(val));
-          this.search();
-        } else {
-          let nid = _.get(val, 'classid');
-          let oid = _.get(this.options, 'classid');
-          if (nid && !_.isEqual(nid, oid)) {
-            this.$set(this, `options`, _.cloneDeep(val));
-            this.search();
-          }
-        }
-      },
+    // 获取没有交作业的学生名单
+    getNoTask() {
+      const hasTaskList = this.tableData.map(i => i.studentid);
+      const list = this.stuList.filter(f => !hasTaskList.includes(f._id));
+      let namelist = list.map(i => i.name);
+      namelist = namelist.join(';');
+      // let word = '';
+      // for (const stu of list) {
+      //   word = `${word} ${stu.name}`;
+      // }
+      return namelist;
     },
   },
 };