reloaded 4 éve
szülő
commit
f7a1828cce

+ 13 - 0
src/router/index.js

@@ -106,6 +106,19 @@ const routes = [
     meta: { title: '通知详情', isleftarrow: false },
     component: () => import('../views/messageInfo/index.vue'),
   },
+  // 教师教课列表
+  {
+    path: '/task/index',
+    name: 'task_index',
+    meta: { title: '课程列表', isleftarrow: true },
+    component: () => import('../views/task/index.vue'),
+  },
+  {
+    path: '/task/stutask',
+    name: 'task_stutask',
+    meta: { title: '学生作业', isleftarrow: true },
+    component: () => import('../views/task/stutask.vue'),
+  },
 ];
 
 const router = new VueRouter({

+ 2 - 0
src/store/index.js

@@ -25,6 +25,7 @@ import group from '@frame/store/group';
 import uploadtask from '@frame/store/uploadtask';
 import setting from '@frame/store/setting';
 import notice from '@frame/store/notice';
+import task from '@frame/store/task';
 import * as ustate from '@frame/store/user/state';
 import * as umutations from '@frame/store/user/mutations';
 import * as dostate from '@frame/store/setting/state';
@@ -68,5 +69,6 @@ export default new Vuex.Store({
     uploadtask,
     setting,
     notice,
+    task,
   },
 });

+ 2 - 0
src/views/home/classmenu.vue

@@ -40,6 +40,7 @@ export default {
       { name: '请假管理', icon: 'iconfont iconqingjia' },
       { name: '考勤管理', icon: 'iconfont iconkaoqin' },
       { name: '学生评分', icon: 'iconfont iconpingfenqia' },
+      { name: '学生作业', icon: 'iconfont iconchengji' },
     ],
     topImage: require('@/assets/logo.png'),
   }),
@@ -58,6 +59,7 @@ export default {
       if (name === '请假管理') this.$router.push({ path: '/user/teaLeave' });
       if (name === '考勤管理') this.$router.push({ path: '/user/attendance' });
       if (name === '学生评分') this.$router.push({ path: '/user/score' });
+      if (name === '学生作业') this.$router.push({ path: '/task/index' });
     },
   },
   mounted() {

+ 8 - 2
src/views/index.vue

@@ -62,7 +62,7 @@ export default {
     }
   },
   methods: {
-    ...lesson({ lessionInfo: 'fetch', lessionlist: 'query' }),
+    ...lesson({ lessionInfo: 'fetch', lessionlist: 'query', teaclass: 'teaclass' }),
     ...trainplan(['query']),
     ...classes({ classQuery: 'query' }),
     ...setting({ settingFetch: 'fetch' }),
@@ -79,7 +79,13 @@ export default {
       // index:计划id
       this.display = false;
       this.$set(this, `planId`, planid);
-      const classList = await this.classQuery({ planid: planid, headteacherid: this.user.userid });
+      let classList = [];
+      console.log(this.user);
+      if (this.user.type === '1') {
+        classList = await this.classQuery({ planid: planid, headteacherid: this.user.userid });
+      } else if (this.user.type === '3') {
+        classList = await this.teaclass({ planid: planid, teaid: this.user.userid });
+      }
       const today = moment().format('YYYY-MM-DD');
       for (const classes of classList.data) {
         const isclass = moment(today).isBetween(classes.startdate, classes.enddate, null, '[]');

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

@@ -0,0 +1,85 @@
+<template>
+  <div id="index">
+    <van-row>
+      <van-col class="style">
+        <van-col :span="24" class="top">
+          <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
+        </van-col>
+        <van-col class="main" :span="24">
+          <van-col class="lessonList" :span="24" v-for="(i, index) in lessonList" :key="index" @click.native="toDetail(i._id)">
+            <p>科目名称:{{ i.subname }}</p>
+            <p>
+              上课时间:{{ i.date }}<span style="margin-left:5px;">{{ i.time }}</span>
+            </p>
+          </van-col>
+        </van-col>
+      </van-col>
+    </van-row>
+  </div>
+</template>
+
+<script>
+import NavBar from '@/layout/common/topInfo.vue';
+import { mapState, createNamespacedHelpers, mapGetters } from 'vuex';
+const { mapActions: lesson } = createNamespacedHelpers('lesson');
+const { mapActions: util } = createNamespacedHelpers('util');
+export default {
+  name: 'index',
+  props: {},
+  components: { NavBar },
+  data: () => ({
+    title: '',
+    isleftarrow: '',
+    navShow: true,
+    lessonList: [],
+  }),
+  created() {
+    this.search();
+  },
+  computed: { ...mapState(['user']) },
+  methods: {
+    ...lesson({ lessionInfo: 'fetch', lessionList: 'query' }),
+    ...util({ modelFetch: 'fetch' }),
+    async search() {
+      const classid = sessionStorage.getItem('classid');
+      const userid = this.user.userid;
+      const lesson = await this.modelFetch({ model: 'lesson', classid });
+      const tealesson = lesson.data.lessons.filter(item => item.teaid === userid);
+      this.$set(this, `lessonList`, tealesson);
+    },
+    async toDetail(id) {
+      this.$router.push({ path: '/task/stutask', query: { id } });
+    },
+  },
+  mounted() {
+    this.title = this.$route.meta.title;
+    this.isleftarrow = this.$route.meta.isleftarrow;
+  },
+  watch: {
+    $route(to, from) {
+      this.title = to.meta.title;
+      this.isleftarrow = to.meta.isleftarrow;
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.style {
+  width: 100%;
+  min-height: 667px;
+  position: relative;
+  background-color: #f9fafc;
+}
+.top {
+  height: 46px;
+  overflow: hidden;
+}
+.lessonList {
+  margin: 10px;
+  padding: 20px;
+  border: 1px solid #ebeef5;
+  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
+  width: -webkit-fill-available;
+}
+</style>

+ 149 - 0
src/views/task/stutask.vue

@@ -0,0 +1,149 @@
+<template>
+  <div id="stutask">
+    <van-row>
+      <van-col class="style">
+        <van-col :span="24" class="top">
+          <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
+        </van-col>
+        <van-col class="main" :span="24" v-if="display === 'list'">
+          <van-col :span="24" class="taskList" v-for="(item, index) in taskList" :key="index">
+            <van-cell is-link @click="toDetail(item)">
+              <!-- 使用 title 插槽来自定义标题 -->
+              <template #title>
+                <span class="custom-title">{{ item.stuname }}</span>
+                <span v-if="item.score" style="margin-left:20px" class="custom-title">分数:{{ item.score }}</span>
+              </template>
+            </van-cell>
+          </van-col>
+        </van-col>
+        <van-col :span="24" v-else-if="display === 'detail'">
+          <van-col :span="12" style="margin:5px 10px">
+            <van-button plain icon="arrow-left" size="small" @click="display = 'list'">返回学生列表</van-button>
+          </van-col>
+          <template v-if="tasktype === 'task'">
+            <van-col :span="24" class="title">
+              {{ task.title }}
+            </van-col>
+            <van-col :span="24" class="question" v-for="(item, index) in task.question" :key="index">
+              <p>
+                {{ index + 1 }}、(<template>{{ item.type === '0' ? '单选' : item.type === '1' ? '多选' : item.type === '2' ? '简答' : '' }}</template
+                >)({{ item.score }}分)
+              </p>
+              <p>{{ item.topic }}({{ item.stuanswer }})</p>
+              <p v-for="i in item.option" :key="i._id">{{ i.number }}、{{ i.opname }}</p>
+              <p v-if="item.answer">正确答案:{{ item.answer }}</p>
+            </van-col>
+          </template>
+          <template v-else-if="tasktype === 'pic'">
+            <van-image :src="picrul"></van-image>
+          </template>
+          <van-field v-model="score" type="number" label="作业成绩:" placeholder="请输入学生成绩" />
+          <van-button round type="info" @click="onSubmit">提交成绩</van-button>
+        </van-col>
+      </van-col>
+    </van-row>
+  </div>
+</template>
+
+<script>
+import NavBar from '@/layout/common/topInfo.vue';
+import { mapState, createNamespacedHelpers, mapGetters } from 'vuex';
+const { mapActions: uploadtask } = createNamespacedHelpers('uploadtask');
+const { mapActions: task } = createNamespacedHelpers('task');
+export default {
+  name: 'stutask',
+  props: {},
+  components: { NavBar },
+  data: () => ({
+    title: '',
+    isleftarrow: '',
+    navShow: true,
+    taskList: [],
+    display: 'list',
+    task: {},
+    tasktype: '',
+    picrul: '',
+    score: '',
+    uploadtask: {},
+  }),
+  created() {
+    this.search();
+  },
+  computed: {
+    id() {
+      return this.$route.query.id;
+    },
+  },
+  methods: {
+    ...uploadtask(['fetch', 'query', 'update']),
+    ...task({ taskInfo: 'fetch' }),
+    async search() {
+      const stutasks = await this.query({ lessonid: this.id });
+      this.$set(this, `taskList`, stutasks.data);
+    },
+    async toDetail(item) {
+      this.$set(this, `uploadtask`, item);
+      this.display = 'detail';
+      if (item.taskid) {
+        this.tasktype = 'task';
+        const task = await this.taskInfo(item.taskid);
+        for (const question of task.data.question) {
+          const answer = item.answers.find(item => item.questionid === question._id);
+          question.stuanswer = answer.answer;
+        }
+        this.$set(this, `task`, task.data);
+        console.log(task.data);
+      } else if (item.picrul) {
+        this.tasktype = 'pic';
+        this.picrul = item.picrul;
+      }
+      if (item.score) {
+        this.score = item.score;
+      }
+    },
+    async onSubmit() {
+      this.uploadtask.score = this.score;
+      const res = await this.update(this.uploadtask);
+      if (res.errcode === 0) {
+        this.$toast('提交学生成绩成功');
+        this.display = 'list';
+      }
+      console.log(this.uploadtask);
+    },
+  },
+  mounted() {
+    this.title = this.$route.meta.title;
+    this.isleftarrow = this.$route.meta.isleftarrow;
+  },
+  watch: {
+    $route(to, from) {
+      this.title = to.meta.title;
+      this.isleftarrow = to.meta.isleftarrow;
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.style {
+  width: 100%;
+  min-height: 667px;
+  position: relative;
+  background-color: #f9fafc;
+}
+.top {
+  height: 46px;
+  overflow: hidden;
+}
+.title {
+  text-align: center;
+  font-weight: bold;
+  font-size: 20px;
+}
+/deep/.van-field {
+  width: 70%;
+  border: 1px solid #f5f5f5;
+  display: -webkit-inline-box;
+  margin-right: 10px;
+}
+</style>