Ver código fonte

Merge branch 'master' of http://git.cc-lotus.info/new_train/train-student

nihao 5 anos atrás
pai
commit
95acdbf7db

+ 3 - 1
src/layout/class/achieveList/peaceAchieve.vue

@@ -6,8 +6,10 @@
           <el-col :span="12" class="name">
             {{ item.name }}
           </el-col>
-          <el-col :span="12" class="score">
+          <el-col :span="8" class="score">
             <span>分数:{{ item.selfscore }}分</span>
+          </el-col>
+          <el-col :span="4" class="score">
             <el-button type="primary" size="mini" @click="showBtn(item.id)" round>选择</el-button>
           </el-col>
         </el-col>

+ 3 - 2
src/layout/class/groupList.vue

@@ -12,14 +12,14 @@
               </el-col>
               <el-col :span="1"></el-col>
               <el-col :span="4">
-                <el-button round type="danger" size="mini" @click="deleteGroup(item.id)">删除</el-button>
+                <el-button round type="danger" plain size="mini" @click="deleteGroup(item.id)">删除</el-button>
               </el-col>
               <el-col :span="1"></el-col>
               <el-col :span="4">
                 <el-button round type="success" size="mini" v-if="stuIdAndGroupId.groupId === '' && item.students.length <= 10" @click="joinGroup(item.id)"
                   >加入</el-button
                 >
-                <el-button round type="danger" size="mini" v-if="stuIdAndGroupId.groupId === item.id" @click="exitGroup(item.id)">退出</el-button>
+                <el-button round type="danger" size="mini" v-if="stuIdAndGroupId.groupId === item.id" plain @click="exitGroup(item.id)">退出</el-button>
               </el-col>
             </template>
             <el-col :span="24" class="list" v-for="(itemStrudent, indexStudent) in item.students" :key="indexStudent">
@@ -48,6 +48,7 @@ export default {
   data: () => ({}),
   created() {},
   computed: {
+    ...mapState(['user']),
     userid() {
       return this.user.userid;
     },

+ 7 - 0
src/layout/class/headStuList.vue

@@ -1,5 +1,12 @@
 <template>
   <div id="headStuList">
+    <el-row type="flex" justify="center" style="padding:10px 0">
+      <el-col :span="6">
+        <el-button type="primary" plain size="mini" @click.native="$router.push({ path: '/class/achieve', query: { classid: $attrs.classid } })">
+          查看平时成绩
+        </el-button>
+      </el-col>
+    </el-row>
     <el-row>
       <el-col :span="24" class="info">
         <el-col :span="6" class="list" v-for="(item, index) in headStuList" :key="index" @click.native="clickAssign(item.id)">

+ 8 - 1
src/layout/class/nameList/stuNameList.vue

@@ -1,8 +1,15 @@
 <template>
   <div id="stuNameList">
     <el-row>
+      <el-row type="flex" justify="center" style="padding:10px 0">
+        <el-col :span="6">
+          <el-button type="primary" plain size="mini" @click.native="$router.push({ path: '/class/achieve', query: { classid: $attrs.classid } })">
+            查看平时成绩
+          </el-button>
+        </el-col>
+      </el-row>
       <el-col :span="24" class="info">
-        <el-col :span="6" class="list" v-for="(item, index) in stuNameList" :key="index" @click.native="$router.push({ path: '/class/achieve' })">
+        <el-col :span="6" class="list" v-for="(item, index) in stuNameList" :key="index">
           <p class="name">{{ item.name }}</p>
           <p class="job" v-if="item.job">{{ item.job }}<i class="el-icon-circle-check"></i></p>
         </el-col>

+ 1 - 1
src/layout/common/writeStu.vue

@@ -14,7 +14,7 @@
           <van-field v-model="form.mobile" name="手机号" label="手机号" placeholder="手机号" :rules="[{ required: true, message: '请填写手机号' }]" />
           <div style="margin: 16px;">
             <van-button round block type="info" native-type="submit">
-              
+              
             </van-button>
           </div>
         </van-form>

+ 8 - 2
src/layout/index/mainData.vue

@@ -19,7 +19,10 @@
             </el-col>
             <el-col :span="6" class="date">
               <el-col :span="24" class="info">
-                <el-button type="primary" @click="$router.push({ path: 'teacherscore/index', query: { teaid: lesson.teaid, lessonid: lesson._id } })"
+                <el-button
+                  v-if="user.type != '1'"
+                  type="primary"
+                  @click="$router.push({ path: 'teacherscore/index', query: { teaid: lesson.teaid, lessonid: lesson._id } })"
                   >教师评分</el-button
                 >
               </el-col>
@@ -68,6 +71,7 @@
 </template>
 
 <script>
+import { mapActions, mapState, createNamespacedHelpers } from 'vuex';
 export default {
   name: 'mainData',
   props: {
@@ -78,7 +82,9 @@ export default {
   components: {},
   data: () => ({}),
   created() {},
-  computed: {},
+  computed: {
+    ...mapState(['user']),
+  },
   methods: {
     changeLesson(date) {
       this.$emit('getLesson', date);

+ 6 - 7
src/layout/user/datiList.vue

@@ -12,11 +12,11 @@
             </el-form-item>
             <template v-if="item.type === '0'">
               <el-col :span="24" v-for="(items, index) in item.option" :key="index">
-                <el-radio v-model="item.answer" :label="items.opname">{{ items.opname }}</el-radio>
+                <el-radio v-model="item.answers" :label="items.opname">{{ items.opname }}</el-radio>
               </el-col>
             </template>
             <template v-else-if="item.type === '1'">
-              <el-checkbox-group v-model="item.answer">
+              <el-checkbox-group v-model="item.answers">
                 <el-col :span="24" v-for="(items, index) in item.option" :key="index">
                   <el-checkbox :label="items.opname">{{ items.opname }}</el-checkbox>
                 </el-col>
@@ -26,7 +26,7 @@
               <el-input
                 type="textarea"
                 placeholder="请输入内容"
-                v-model="item.answer"
+                v-model="item.answers"
                 :autosize="{ minRows: 4, maxRows: 6 }"
                 maxlength="300"
                 show-word-limit
@@ -49,16 +49,15 @@ export default {
   props: {
     form: null,
     datilist: null,
+    answer: null,
   },
   components: {},
-  data: () => ({
-    task: {},
-  }),
+  data: () => ({}),
   created() {},
   computed: {},
   methods: {
     onSubmit() {
-      this.$emit('submit', this.task);
+      this.$emit('submit');
     },
   },
 };

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

@@ -193,7 +193,7 @@
           <el-col :span="24" class="mess">
             <el-col :span="22" class="info">
               <p class="title">是否可讲礼仪课</p>
-              <p class="name">{{ teainfo.is_etiquette_teacher === 0 ? '否' : '是' }}</p>
+              <p class="name">{{ teainfo.islyteacher === 0 ? '否' : '是' }}</p>
             </el-col>
             <el-col :span="2" class="icon">
               <van-icon name="arrow" />

+ 13 - 6
src/layout/user/stuleaveList.vue

@@ -16,13 +16,20 @@
       <div class="wrapper" @click="clickDown">
         <el-col :span="24" class="leaveInfo">
           <p class="jilu">请假记录</p>
-          <el-col :span="24" class="leavelist" v-for="(item, index) in leaveInfo" :key="index">
-            <el-col :span="14" class="date">
-              <p>开始时间:{{ item.starttime }}</p>
-              <p>结束时间:{{ item.endtime }}</p>
+          <template v-if="leaveInfo.length > 0">
+            <el-col :span="24" class="leavelist" v-for="(item, index) in leaveInfo" :key="index">
+              <el-col :span="14" class="date">
+                <p>开始时间:{{ item.starttime }}</p>
+                <p>结束时间:{{ item.endtime }}</p>
+              </el-col>
+              <el-col :span="10" class="status"> 审核结果:{{ item.status == 0 ? '审核中' : item.status == 1 ? '通过' : '未通过' }} </el-col>
             </el-col>
-            <el-col :span="10" class="status"> 审核结果:{{ item.status == 0 ? '审核中' : item.status == 1 ? '通过' : '未通过' }} </el-col>
-          </el-col>
+          </template>
+          <template>
+            <el-col :span="24" class="leavelist" style="text-align:center">
+              <p>暂无请假记录</p>
+            </el-col>
+          </template>
         </el-col>
       </div>
     </van-overlay>

+ 6 - 6
src/layout/user/workList.vue

@@ -4,9 +4,9 @@
       <el-col :span="24" class="info">
         <el-col :span="24" class="list" v-for="(item, index) in workLists" :key="index">
           <el-col :span="24" class="time">
-            <el-col :span="18">科目:{{ item.name }}</el-col>
+            <el-col :span="18">科目:{{ item.subname }}</el-col>
             <el-col :span="6" class="anniu">
-              <el-button v-if="item.display === 'second'" type="primary" size="small" @click="clickBtn(item.name)">在线作答</el-button>
+              <el-button v-if="item.display === 'second'" type="primary" size="small" @click="clickBtn(item.subname, item.subid, item._id)">在线作答</el-button>
               <el-button v-else type="primary" size="small" @click="clickzy(item.id)">上传作业</el-button>
             </el-col>
           </el-col>
@@ -29,11 +29,11 @@ export default {
   created() {},
   computed: {},
   methods: {
-    clickBtn(name) {
-      this.$router.push({ path: '/user/dati', query: { name: name } });
+    clickBtn(subname, subid, _id) {
+      this.$router.push({ path: '/user/dati', query: { name: subname, id: subid, lessonid: _id } });
     },
-    clickzy(id) {
-      this.$router.push({ path: '/user/chuanzuoye', query: { id: id } });
+    clickzy(_id) {
+      this.$router.push({ path: '/user/chuanzuoye', query: { id: _id } });
     },
   },
 };

+ 1 - 1
src/plugins/setting.js

@@ -2,7 +2,7 @@ import Vue from 'vue';
 Vue.config.weixin = {
   // baseUrl: process.env.BASE_URL + 'weixin',
   baseUrl: 'http://free.liaoningdoupo.com',
-  target: process.env.NODE_ENV === 'development' ? 'http://10.16.10.7:8001' : 'http://free.liaoningdoupo.com/mobile',
+  target: process.env.NODE_ENV === 'development' ? 'http://10.16.10.7:8001' : 'http://free.liaoningdoupo.com/student',
 };
 
 Vue.config.stomp = {

+ 1 - 1
src/router/index.js

@@ -162,7 +162,7 @@ const routes = [
 
 const router = new VueRouter({
   mode: 'history',
-  base: process.env.NODE_ENV === 'development' ? '' : process.env.VUE_APP_ROOT_URL + 'mobile',
+  base: process.env.NODE_ENV === 'development' ? '' : 'student',
   routes,
 });
 

+ 1 - 1
src/views/bind/bind.vue

@@ -5,7 +5,7 @@
         <el-col :span="24" class="top">
           <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
         </el-col>
-        <el-col :span="24" class="mess">
+        <el-col :span="24" class="mess" style="padding-top:10vh;">
           <writeStu :form="form" @onSubmit="onSubmit"></writeStu>
         </el-col>
       </el-col>

+ 6 - 1
src/views/class/achieve.vue

@@ -75,6 +75,9 @@ export default {
   },
   computed: {
     ...mapState(['user']),
+    classid() {
+      return this.$route.query.classid;
+    },
   },
   mounted() {
     this.title = this.$route.meta.title;
@@ -94,7 +97,9 @@ export default {
     ...mapSubject({ subjectinfo: 'fetch', subjectlist: 'query' }),
     // 平时成绩学生名单查询+作业成绩学生名单查询
     async search() {
-      let classid = this.user.classid;
+      let classid;
+      if (this.user.type === '1') classid = this.classid;
+      else classid = this.user.classid;
       const res = await this.list({ classid });
       this.$set(this, `peaceAchieveList`, res.data);
     },

+ 1 - 0
src/views/class/classStuList.vue

@@ -15,6 +15,7 @@
             @outForm="outAssignShow"
             @onForm="onAssignShow"
             @handleClose="handleClose"
+            :classid="this.id"
           ></headStuList>
         </el-col>
       </el-col>

+ 1 - 0
src/views/class/index.vue

@@ -22,6 +22,7 @@
               @joinGroup="joinGroup"
               :stuIdAndGroupId="stuIdAndGroupId"
               :noGroupStudentNames="noGroupStudentNames"
+              :classid="this.user.classid"
             ></classList>
             <!-- :groupList="groupList"
               @saveGroup="saveGroup"

+ 1 - 0
src/views/index.vue

@@ -29,6 +29,7 @@ const { mapActions: lesson } = createNamespacedHelpers('lesson');
 const { mapActions: classes } = createNamespacedHelpers('classes');
 
 export default {
+  metaInfo: { title: '首页' },
   name: 'index',
   props: {},
   components: {

+ 146 - 10
src/views/user/dati.vue

@@ -8,7 +8,7 @@
         <el-col :span="24" class="main">
           <el-col :span="24" class="leaveBtn"> </el-col>
           <el-col :span="24" class="leaveList">
-            <datiList :datilist="datilist"></datiList>
+            <datiList :datilist="datilist" :form="form" :answer="answer" @submit="onsave"></datiList>
           </el-col>
         </el-col>
       </el-col>
@@ -21,6 +21,8 @@ import NavBar from '@/layout/common/topInfo.vue';
 import datiList from '@/layout/user/datiList.vue';
 import { mapState, createNamespacedHelpers, mapGetters } from 'vuex';
 const { mapActions: mapTask } = createNamespacedHelpers('task');
+const { mapActions: mapTaskUploadtask } = createNamespacedHelpers('uploadtask');
+
 export default {
   name: 'homework',
   props: {},
@@ -35,6 +37,11 @@ export default {
     navShow: true,
     title: '',
     isleftarrow: '',
+    answer: [],
+    form: {},
+    taskid: '',
+    resdata: '',
+    valid: '',
   }),
   mounted() {
     this.title = this.$route.meta.title;
@@ -55,26 +62,155 @@ export default {
     name() {
       return this.$route.query.name;
     },
+    id() {
+      return this.$route.query.id;
+    },
+    lessonid() {
+      return this.$route.query.lessonid;
+    },
   },
   methods: {
     ...mapTask({ list: 'query', add: 'create', fet: 'fetch', updates: 'update' }),
+    ...mapTaskUploadtask({ Uploadtasklist: 'query', Uploadtaskadd: 'create', Uploadtaskfet: 'fetch', Uploadtaskupdates: 'update' }),
+
+    //查询作业
     async search() {
       console.log(this.name);
       const res = await this.list();
-      var tilist = res.data.filter(item => item.name === this.name);
-      for (const result of tilist) {
-        this.$set(this, `datilist`, result);
-
-        for (const option of result.question) {
-   
-          console.log(answer);
+      var tilist = res.data.filter(item => item.code === this.id);
+      let result = tilist[0];
+      console.log(result.id);
+      this.$set(this, `taskid`, result.id);
+      result.question = result.question.map(i => {
+        if (i.type == 1) {
+          i.answers = [];
+        } else {
+          i.answers = '';
         }
 
-        // let  answer=[]
-      }
+        return i;
+        console.log(result.question);
+      });
+      this.$set(this, `datilist`, result);
+      let stuid = this.user.userid;
+      let lessonid = this.lessonid;
+
+      let ress = await this.Uploadtasklist({ lessonid });
+      console.log(ress.data);
 
+      this.$set(this, `resdata`, ress.data);
+      //回显
+      for (const val of ress.data) {
+        let less = val.answers;
+        console.log(val.id);
+        this.$set(this, `valid`, val.id);
+        console.log(less);
+        result.question.map(i => {
+          if (i.type == 1) {
+            val.answers.map(m => {
+              if (i._id == m.questionid) {
+                // 将string类型还原
+                i.answers = JSON.parse(m.answer);
+                return m;
+              }
+            });
+          } else {
+            less.map(n => {
+              if (i._id == n.questionid) {
+                i.answers = n.answer;
+                return n;
+              }
+            });
+          }
+          return i;
+          console.log(result.question);
+        });
+      }
       this.loading = false;
     },
+
+    async onsave() {
+      let answerss = {
+        termid: this.user.termid,
+        batchid: this.user.batchid,
+        classid: this.user.classid,
+        lessonid: this.lessonid,
+        id: this.valid,
+        studentid: this.user.userid,
+        taskid: this.taskid,
+      };
+      let answers = {};
+      let data = this.datilist.question;
+      var answer = data.map(i => {
+        answers.questionid = i._id;
+        answers.answer = JSON.stringify(i.answers);
+        if (i.type == 1) {
+          return {
+            answer: JSON.stringify(i.answers),
+            questionid: i._id,
+          };
+        } else {
+          return {
+            answer: i.answers,
+            questionid: i._id,
+          };
+        }
+      });
+      console.log(answer);
+
+      //上传
+      let dati = this.resdata;
+      //作业
+      let task = this.datilist;
+      console.log(task);
+      //合并集合时使用
+      let newsc = [];
+      for (const shangchan of dati) {
+        console.log(shangchan);
+        task.question.map(n => {
+          if (n.type == 1) {
+            // a b array类型
+            let a = n.answer.split(';');
+            let b = n.answers;
+            console.log(b);
+            let c = new Set(a);
+            let d = new Set(b);
+            //差集判断答案
+            let differenceABSet = new Set([...d].filter(x => !c.has(x)));
+            var sc = shangchan.answers.map(a => {
+              if (n._id == a.questionid) {
+                if (differenceABSet.size === 0) {
+                  return {
+                    // 转换成string
+                    answer: JSON.stringify(n.answers),
+                    questionid: n._id,
+                    questionscore: n.score,
+                  };
+                }
+              }
+            });
+          } else {
+            var sc = shangchan.answers.map(a => {
+              //字符串判断答案
+              if (n._id == a.questionid) {
+                if (n.answers === n.answer) {
+                  return {
+                    answer: n.answers,
+                    questionid: n._id,
+                    questionscore: n.score,
+                  };
+                }
+              }
+            });
+          }
+          //合并数组
+          newsc = [...sc, ...newsc];
+          var arr = newsc.filter(item => item);
+          answerss.answers = arr;
+        });
+      }
+      let res = await this.Uploadtaskupdates(answerss);
+    },
   },
 };
 </script>

+ 9 - 7
src/views/user/homework.vue

@@ -70,16 +70,18 @@ export default {
     async search() {
       let classid = this.user.classid;
       const ress = await this.classinfo(classid);
-      console.log(ress.data.lessonid);
+
       let lessonid = ress.data.lessonid;
-      const res = await this.subjectList({ lessonid });
-      console.log(res.data);
+      const res = await this.lessonList({ lessonid });
       const resout = await this.list();
       for (const val of resout.data) {
-        // console.log(result.data.lessons);
-        // var crr = result.data.lessons.filter(item => item.subid);
-        this.$set(this, `workLists`, res.data);
-        var arr = res.data.filter(item => item.name === val.name);
+        for (const tyl of res.data) {
+          var crr = tyl.lessons.filter(item => item.subid);
+          this.$set(this, `workLists`, crr);
+        }
+
+        console.log(crr);
+        var arr = crr.filter(item => item.subid === val.code);
 
         for (const att of arr) {
           att.display = 'second';

+ 2 - 2
vue.config.js

@@ -2,8 +2,8 @@ const path = require('path');
 const question = path.resolve(__dirname, '../question-examine');
 const frame = path.resolve(__dirname, '../frame');
 module.exports = {
-  publicPath: process.env.NODE_ENV === 'development' ? '/' : process.env.VUE_APP_ROOT_URL + 'teacher',
-
+  publicPath: process.env.NODE_ENV === 'development' ? '/' : '/student',
+  outputDir: 'student',
   configureWebpack: config => {
     Object.assign(config, {
       // 开发生产共同配置