lrf402788946 4 年之前
父節點
當前提交
cb545d86b8
共有 4 個文件被更改,包括 87 次插入1 次删除
  1. 1 1
      src/layout/user/clickBtn.vue
  2. 6 0
      src/router/index.js
  3. 2 0
      src/store/index.js
  4. 78 0
      src/views/user/score.vue

+ 1 - 1
src/layout/user/clickBtn.vue

@@ -15,7 +15,7 @@
           <van-cell is-link @click="$router.push({ path: '/user/homework' })">作业管理</van-cell>
         </el-col>
         <el-col :span="24" class="native" v-if="this.user.type === '1'">
-          <van-cell is-link @click="$router.push({ path: '/user/pingfenclass' })">评分</van-cell>
+          <van-cell is-link @click="$router.push({ path: '/user/score' })">评分</van-cell>
         </el-col>
         <el-col :span="24" class="native" v-if="this.user.type === '4'">
           <van-cell is-link @click="$router.push({ path: '/user/quit' })">退出</van-cell>

+ 6 - 0
src/router/index.js

@@ -52,6 +52,12 @@ const routes = [
     meta: { title: '个人信息', isleftarrow: true },
     component: () => import('../views/user/personalDetail.vue'),
   },
+  {
+    path: '/user/score',
+    name: 'user_score',
+    meta: { title: '学生评分', isleftarrow: true },
+    component: () => import('../views/user/score.vue'),
+  },
 ];
 
 const router = new VueRouter({

+ 2 - 0
src/store/index.js

@@ -21,6 +21,7 @@ import bedroom from '@frame/store/bedroom';
 import util from '@frame/store/util';
 import attendance from '@frame/store/attendance';
 import leave from '@frame/store/leave';
+import uploadtask from '@frame/store/uploadtask';
 
 import * as ustate from '@frame/store/user/state';
 import * as umutations from '@frame/store/user/mutations';
@@ -58,5 +59,6 @@ export default new Vuex.Store({
     util,
     attendance,
     leave,
+    uploadtask,
   },
 });

+ 78 - 0
src/views/user/score.vue

@@ -0,0 +1,78 @@
+<template>
+  <div id="score">
+    <el-row>
+      <el-col :span="24" class="style">
+        <el-col :span="24" class="top">
+          <NavBar v-show="true" :title="pageTitle" :isleftarrow="true"> </NavBar>
+        </el-col>
+        <el-col :span="24" class="main"> </el-col>
+        <el-col :span="24" class="foot">
+          <footInfo></footInfo>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import _ from 'lodash';
+import NavBar from '@/layout/common/topInfo.vue';
+import footInfo from '@/layout/common/footInfo.vue';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: student } = createNamespacedHelpers('student');
+const { mapActions: uploadtask } = createNamespacedHelpers('uploadtask');
+export default {
+  name: 'score',
+  props: {},
+  components: { NavBar, footInfo },
+  data: function() {
+    return {
+      list: [],
+    };
+  },
+  created() {
+    this.search();
+  },
+  methods: {
+    ...student(['query']),
+    ...uploadtask({ getTaskList: 'query' }),
+    async search() {
+      let res = await this.query({ classid: this.classid });
+      let classList = [];
+      if (this.$checkRes(res)) {
+        classList = res.data;
+      }
+      let classTask = await this.getTaskList({ classid: this.classid });
+      if (this.$checkRes(classTask)) {
+        classList = classList.map(i => {
+          let r = classTask.data.filter(f => f.studentid == i.id);
+          // if (r.length > 0) {
+          r = r.map(task => {
+            let score = 0;
+            if (task.answers.length > 0) {
+              let s = task.answers.reduce((prev, next) => prev + next.questionscore * 1, 0);
+              score = _.isNumber(s) ? s : 0;
+            }
+            return score;
+          });
+          i.taskScore = r.reduce((prev, next) => prev + next * 1, 0);
+          // }
+          return i;
+        });
+        this.$set(this, `list`, classList);
+      }
+    },
+  },
+  computed: {
+    ...mapState(['user', 'classid']),
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+
+<style lang="less" scoped></style>