guhongwei %!s(int64=4) %!d(string=hai) anos
pai
achega
e7defc3616

+ 19 - 0
src/router/index.js

@@ -181,6 +181,25 @@ const routes = [
         meta: { title: '学校', sub: '管理' },
         meta: { title: '学校', sub: '管理' },
         component: () => import('@/views/school/index.vue'),
         component: () => import('@/views/school/index.vue'),
       },
       },
+      // 09-17
+      {
+        path: '/task/index',
+        name: 'task_index',
+        meta: { title: '作业管理' },
+        component: () => import('@/views/task/index.vue'),
+      },
+      {
+        path: '/task/taskList',
+        name: 'task_taskList',
+        meta: { title: '学生作业列表' },
+        component: () => import('@/views/task/taskList.vue'),
+      },
+      {
+        path: '/task/taskDetail',
+        name: 'task_taskDetail',
+        meta: { title: '学生作业详情' },
+        component: () => import('@/views/task/taskDetail.vue'),
+      },
     ],
     ],
   },
   },
   {
   {

+ 2 - 0
src/store/index.js

@@ -30,6 +30,7 @@ import group from '@frame/store/group';
 import personalscore from '@frame/store/personalscore';
 import personalscore from '@frame/store/personalscore';
 import groupscore from '@frame/store/groupscore';
 import groupscore from '@frame/store/groupscore';
 import uploadtask from '@frame/store/uploadtask';
 import uploadtask from '@frame/store/uploadtask';
+import task from '@frame/store/task';
 import trainvideo from '@frame/store/trainvideo';
 import trainvideo from '@frame/store/trainvideo';
 import cerconfirm from '@frame/store/cerconfirm';
 import cerconfirm from '@frame/store/cerconfirm';
 import * as ustate from '@frame/store/user/state';
 import * as ustate from '@frame/store/user/state';
@@ -72,6 +73,7 @@ export default new Vuex.Store({
     uploadtask,
     uploadtask,
     trainvideo,
     trainvideo,
     cerconfirm,
     cerconfirm,
+    task,
   },
   },
   state: { ...ustate, ...dostate },
   state: { ...ustate, ...dostate },
   mutations: { ...umutations, ...domutations },
   mutations: { ...umutations, ...domutations },

+ 94 - 0
src/views/task/index.vue

@@ -0,0 +1,94 @@
+<template>
+  <div id="index">
+    <list-frame :title="pageTitle" @query="search" :total="total" :needFilter="false" :needAdd="false">
+      <data-table :fields="fields" :data="tableData" :opera="opera" @view="toTaskList"></data-table>
+    </list-frame>
+  </div>
+</template>
+
+<script>
+import listFrame from '@frame/layout/admin/list-frame';
+import dataTable from '@frame/components/data-table';
+import _ from 'lodash';
+import { mapState, createNamespacedHelpers, mapGetters } from 'vuex';
+const { mapActions: lesson } = createNamespacedHelpers('lesson');
+const { mapActions: util } = createNamespacedHelpers('util');
+export default {
+  name: 'index',
+  props: {},
+  components: { listFrame, dataTable },
+  data: () => ({
+    opera: [
+      {
+        label: '查看学生作业',
+        icon: 'el-icon-view',
+        method: 'view',
+      },
+    ],
+    fields: [
+      { label: '课程日期', prop: 'date' },
+      { label: '课程名称', prop: 'subname' },
+    ],
+    tableData: [],
+    total: 0,
+  }),
+  created() {
+    this.search();
+  },
+  computed: {
+    ...mapState(['user', 'defaultOption']),
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+    id() {
+      return this.defaultOption.classid;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  methods: {
+    ...lesson({ lessionInfo: 'fetch', lessionList: 'query' }),
+    ...util({ modelFetch: 'fetch' }),
+    async search({ skip, limit, ...info } = {}) {
+      const classid = this.id;
+      const userid = this.user.userid;
+      const lesson = await this.modelFetch({ model: 'lesson', classid });
+      let lessons = _.get(lesson.data, 'lessons', []);
+      // lesson排序,只去时间最早的作为作业的上传lessonid,需要和学生作业列表处相同处理
+      let r = lessons.filter(f => f.subid);
+      r = r.map(r => {
+        let time = r.time.split('-');
+        r.start = `${r.date} ${time[0]}`;
+        return r;
+      });
+      r = Object.values(_.groupBy(r, 'subid'));
+      r = r.map(a => {
+        let na = _.orderBy(a, ['start'], ['asc']);
+        return _.head(na);
+      });
+      console.log(r);
+      this.$set(this, `tableData`, r);
+      this.$set(this, `total`, r.length);
+      // const tealesson = r.filter(item => item.teaid === userid);
+      // let data = _.slice(tealesson, skip, limit);
+      // this.$set(this, `tableData`, data);
+      // this.$set(this, `total`, tealesson.length);
+    },
+    toTaskList(item) {
+      this.$router.push({ path: '/task/taskList', query: { lessonid: item.data._id } });
+    },
+  },
+  watch: {
+    id: {
+      handler(val) {
+        if (val) this.search();
+        else this.$set(this, `tableData`, []);
+      },
+      immediate: true,
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 153 - 0
src/views/task/taskDetail.vue

@@ -0,0 +1,153 @@
+<template>
+  <div id="taskDetail">
+    <detail-frame title="作业详情" :returns="toreturn">
+      <el-row style="text-align:center">
+        <el-col :span="24">
+          <el-row type="flex" :gutter="20">
+            <el-col :span="getSpan('task')" v-if="task && task.question">
+              <el-card header="在线作业">
+                <el-table :data="task.question" size="mini" border stripe>
+                  <el-table-column align="center" type="expand">
+                    <template v-slot="{ row }">
+                      <el-row class="task_list">
+                        <el-col :span="24">
+                          {{ row.topic }}
+                        </el-col>
+                        <el-col :span="24" v-for="(o, oi) in row.option" :key="`${index}-${oi}`"> {{ o.number }} - {{ o.opname }} </el-col>
+                        <el-col :span="24">学生答案:{{ row.answers }}</el-col>
+                      </el-row>
+                    </template>
+                  </el-table-column>
+                  <el-table-column align="center" label="题目" prop="topic"></el-table-column>
+                  <el-table-column align="center" label="题目类型">
+                    <template v-slot="{ row }">
+                      <span>{{ row.type == '0' ? '单选' : row.type == '1' ? '多选' : row.type == '2' ? '问答' : '暂无' }}</span>
+                    </template>
+                  </el-table-column>
+                  <el-table-column align="center" label="答案" prop="answers"></el-table-column>
+                </el-table>
+              </el-card>
+            </el-col>
+            <el-col :span="getSpan('picurl')" v-if="taskAnswer && taskAnswer.picurl">
+              <el-card header="上传作业">
+                <el-col :span="24" v-if="taskAnswer">
+                  <p style="padding: 0 0 15px 0;font-size: 23px;">作业成绩:{{ taskAnswer.score }}</p>
+                </el-col>
+                <!-- <el-alert title="点击查看大图" type="success" style="margin:10px" center></el-alert> -->
+                <el-image :src="taskAnswer.picurl" :preview-src-list="[taskAnswer.picurl]"></el-image>
+              </el-card>
+            </el-col>
+          </el-row>
+        </el-col>
+        <!-- <el-col :span="24">
+          <el-input class="score" v-model="taskAnswer.score" type="number" label="作业成绩:" placeholder="请输入学生成绩" />
+          <el-button round @click="onSubmit">提交成绩</el-button>
+        </el-col> -->
+      </el-row>
+    </detail-frame>
+  </div>
+</template>
+
+<script>
+import _ from 'lodash';
+import detailFrame from '@frame/layout/admin/detail-frame';
+import { mapState, createNamespacedHelpers, mapGetters } from 'vuex';
+const { mapActions: uploadtask } = createNamespacedHelpers('uploadtask');
+const { mapActions: task } = createNamespacedHelpers('task');
+const { mapActions: util } = createNamespacedHelpers('util');
+export default {
+  name: 'taskDetail',
+  props: {},
+  components: { detailFrame },
+  data: () => ({
+    task: null,
+    active: '',
+    picurl: '',
+    score: '',
+    taskAnswer: null,
+  }),
+  created() {
+    this.search();
+  },
+  computed: {
+    uploadtaskid() {
+      return this.$route.query.uploadtaskid;
+    },
+  },
+  methods: {
+    ...util({ modelFetch: 'fetch' }),
+    ...task({ taskInfo: 'fetch' }),
+    ...uploadtask(['fetch', 'query', 'update']),
+    async search() {
+      const taskAnswer = await this.fetch(this.uploadtaskid);
+      const item = taskAnswer.data;
+      this.$set(this, `taskAnswer`, item);
+      if (item.taskid) {
+        let task = await this.taskInfo(item.taskid);
+        if (task.errcode == '0') {
+          const { answers } = item;
+          let { question } = task.data;
+          question = question.map(i => {
+            const r = answers.find(f => f.questionid == i._id);
+            if (r) i.answers = r.answer;
+            return i;
+          });
+          task.data.question = question;
+        }
+        console.log(task.data);
+        this.$set(this, `task`, task.data);
+      }
+    },
+    async onSubmit() {
+      const res = await this.update(this.taskAnswer);
+      if (res.errcode === 0) {
+        this.$message({
+          message: '提交学生成绩成功',
+          type: 'success',
+        });
+        this.toreturn();
+      }
+    },
+    toreturn() {
+      window.history.go(-1);
+    },
+    getSpan(type) {
+      let span = 0;
+      if (type == 'task') {
+        if (this.task) span = 12;
+        if (!_.get(this.taskAnswer, 'picurl')) span = 24;
+      } else {
+        if (_.get(this.taskAnswer, 'picurl')) span = 12;
+        if (!this.task) span = 24;
+      }
+      return span;
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.task_list {
+  .el-col {
+    padding: 5px 0;
+  }
+}
+.overflow {
+  overflow: hidden;
+  white-space: nowrap;
+  text-overflow: ellipsis;
+  -o-text-overflow: ellipsis;
+}
+.title {
+  text-align: center;
+  font-weight: bold;
+  font-size: 20px;
+}
+.question {
+  margin: 10px;
+}
+.score {
+  width: 50%;
+  margin-right: 20px;
+}
+</style>

+ 84 - 0
src/views/task/taskList.vue

@@ -0,0 +1,84 @@
+<template>
+  <div id="taskList">
+    <list-frame :title="pageTitle" @query="search" :total="total" :needFilter="false" :needAdd="false">
+      <data-table :fields="fields" :data="tableData" :opera="opera" @view="toTaskDetail"></data-table>
+    </list-frame>
+  </div>
+</template>
+
+<script>
+import _ from 'lodash';
+import listFrame from '@frame/layout/admin/list-frame';
+import dataTable from '@frame/components/data-table';
+import { mapState, createNamespacedHelpers, mapGetters } from 'vuex';
+const { mapActions: uploadtask } = createNamespacedHelpers('uploadtask');
+const { mapActions: task } = createNamespacedHelpers('task');
+export default {
+  name: 'taskList',
+  props: {},
+  components: { listFrame, dataTable },
+  data: () => ({
+    opera: [
+      {
+        label: '查看作业详情',
+        icon: 'el-icon-view',
+        method: 'view',
+      },
+    ],
+    fields: [
+      { label: '学生名称', prop: 'stuname' },
+      { label: '作业得分', prop: 'score' },
+    ],
+    tableData: [],
+    total: 0,
+    options: undefined,
+  }),
+  created() {
+    this.search();
+  },
+  computed: {
+    ...mapState(['user', 'defaultOption']),
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+    id() {
+      return this.defaultOption.classid;
+    },
+    lessonid() {
+      return this.$route.query.lessonid;
+    },
+  },
+  methods: {
+    ...uploadtask(['fetch', 'query', 'update']),
+    async search({ skip, limit, ...info } = {}) {
+      const stutasks = await this.query({ skip, limit, lessonid: this.lessonid, classid: this.id });
+      this.$set(this, `tableData`, stutasks.data);
+      this.$set(this, `total`, stutasks.total);
+    },
+    toTaskDetail(item) {
+      this.$router.push({ path: '/task/taskDetail', query: { uploadtaskid: item.data._id } });
+    },
+  },
+  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();
+          }
+        }
+      },
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped></style>