lrf 1 年之前
父节点
当前提交
8de5157a8d

+ 6 - 5
README.md

@@ -1,6 +1,7 @@
 测试用户
-赵燕-班主任
-http://free.liaoningdoupo.com/api/train/authtest?redirect_uri=http://localhost:8200/&type=0&openid=o3ORKt8yN1OHAJWrX1ApOf2vWM5U
-
-赵燕-教师
-http://free.liaoningdoupo.com/api/train/authtest?redirect_uri=http://localhost:8200/&type=0&openid=o3ORKt51UhEl0tPUwLOQdo_q_g8U
+教师:
+http://localhost:8200/login?openid=testTeacherOpenid&type=3
+ocPqjs-DqONf4KND1nfYbKRgpCSY
+班主任
+http://localhost:8200/login?openid=testDirpenid&type=1
+ocPqjs5UgByxHASxW1QiTz5zsGB0

+ 5 - 21
src/layout/class/achieve.vue

@@ -4,20 +4,10 @@
       <el-col :span="24">
         <van-tabs v-model="active">
           <van-tab title="平时成绩">
-            <peaceAchieve v-on="$listeners" :peaceAchieveList="peaceAchieveList" :showPicker="showPicker" :peaceScore="peaceScore"></peaceAchieve>
+            <peaceAchieve v-on="$listeners" :data="studentList" :scoreList="scoreList" :classInfo="classInfo" :lesson="lesson"></peaceAchieve>
           </van-tab>
           <van-tab title="作业成绩">
-            <homeworkAchiece
-              v-on="$listeners"
-              :lesslist="lesslist"
-              :lesson="lesson"
-              :achieveList="achieveList"
-              :deptList="deptList"
-              :show="show"
-              :form="form"
-              :names="names"
-              :score="score"
-            ></homeworkAchiece>
+            <homeworkAchiece :achieveList="achieveList"></homeworkAchiece>
           </van-tab>
         </van-tabs>
       </el-col>
@@ -31,17 +21,11 @@ import homeworkAchiece from '@/layout/class/achieveList/homeworkAchiece.vue';
 export default {
   name: 'achieve',
   props: {
-    peaceAchieveList: null, //平时成绩
-    showPicker: null, //平時成绩显示
-    peaceScore: null, //平时成绩分数
     achieveList: null, //作业成绩
-    show: null, //显示弹框
-    form: null, //修改form
-    deptList: null,
+    studentList: null,
+    scoreList: null,
+    classInfo: null,
     lesson: null,
-    lesslist: null,
-    names: null,
-    score: null,
   },
   components: {
     peaceAchieve, //平時成績

+ 22 - 26
src/layout/class/achieveList/homeworkAchiece.vue

@@ -2,30 +2,28 @@
   <div id="homeworkAchiece">
     <el-row>
       <el-col :span="24" class="list">
-        <van-collapse v-model="openCollapse">
+        <van-collapse v-model="openCollapse" accordion>
           <van-collapse-item :name="index" v-for="(item, index) in achieveList" :key="index">
-            <div slot="title" class="title" @click="clickcds(item.id)">
+            <div slot="title" class="title">
               <span class="name">{{ item.name }}</span>
             </div>
-            <van-row v-for="(tag, index) in lesson" :key="index">
+            <van-row v-for="(tag, index) in item.lesson" :key="index">
               <el-col :span="18">
                 <van-col :span="24" class="score"> 名称:{{ tag.lessonname }} </van-col>
                 <van-col :span="24" class="score"> 作业分: {{ tag.score }}分</van-col>
               </el-col>
               <el-col :span="6" class="anniu">
-                <van-col :span="3" class="score">
-                  <van-button v-if="user.type == '3'" type="primary" size="mini" @click="clickBtn(tag.id, tag.name, tag.score)">上成绩</van-button>
-                </van-col>
+                <van-button v-if="user.type == '3'" type="primary" size="mini" @click="clickBtn(tag.id, tag.lessonname, tag.score)">上成绩</van-button>
               </el-col>
             </van-row>
           </van-collapse-item>
         </van-collapse>
       </el-col>
     </el-row>
-    <van-dialog v-model="show" title="学生成绩上传" :showConfirmButton="false">
+    <van-dialog v-model="show" @before-close="closeDialog" title="学生成绩上传" :showConfirmButton="false" show-cancel-button>
       <van-form @submit="onSubmit">
-        <span class="lesson">课程名称</span><span class="lesson">{{ names }}</span>
-        <van-field v-model="form.score" name="作业分数" :value="score" label="作业分数" placeholder="请输入作业分数" />
+        <span class="lesson">课程名称</span><span class="lesson">{{ form.name }}</span>
+        <van-field v-model="form.score" name="作业分数" label="作业分数" placeholder="请输入作业分数" />
         <div style="margin: 16px;">
           <van-button round block type="info" native-type="submit">
             提交
@@ -42,40 +40,38 @@ export default {
   name: 'homeworkAchiece',
   props: {
     achieveList: null,
-    show: null,
-    form: null,
-    lessonList: null,
-    deptList: null,
-    lesson: null,
-    lesslist: null,
-    names: null,
-    score: null,
   },
   components: {},
   data: () => ({
     ruleForm: {
       region: '',
+      lesson: [],
     },
+    show: false,
+    dscore: 0,
+    form: {},
     value: '',
-    columns: ['杭州', '宁波', '温州', '嘉兴', '湖州'],
-    showPicker: false,
     openCollapse: [],
   }),
   created() {},
   computed: { ...mapState(['user']) },
   methods: {
-    onConfirm(value) {
-      this.value = value;
-      this.showPicker = false;
-    },
-    clickcds(id) {
-      this.$emit('submitss', { id: id });
+    clickcds(index) {
+      this.openCollapse = index;
     },
     clickBtn(id, name, score) {
-      this.$emit('clickDialog', { id: id, name: name, score: score });
+      this.form = { id, name, score };
+      this.dscore = score;
+      this.show = true;
     },
     onSubmit() {
       this.$emit('submit', { data: this.form });
+      this.closeDialog();
+    },
+    closeDialog() {
+      this.form = {};
+      this.show = false;
+      this.dscore = 0;
     },
   },
 };

+ 82 - 48
src/layout/class/achieveList/peaceAchieve.vue

@@ -1,67 +1,101 @@
 <template>
   <div id="peaceAchieve">
-    <el-row>
-      <el-col :span="24" class="info">
-        <el-col :span="24" class="list" v-for="(item, index) in peaceAchieveList" :key="index">
-          <el-col :span="12" class="name">
-            {{ item.name }}
-          </el-col>
-          <el-col :span="8" class="score">
-            <span>分数:{{ item.selfscore }}分</span>
-          </el-col>
-          <el-col :span="4" class="score">
-            <el-button type="primary" v-if="user.job == '学委' || user.type == '3'" size="mini" @click="showBtn(item.id)" round>选择</el-button>
-          </el-col>
-        </el-col>
-      </el-col>
-    </el-row>
-    <van-popup v-model="showPicker" position="bottom">
-      <van-picker show-toolbar :columns="columns" @confirm="onConfirm" @cancel="showPicker = false" />
-    </van-popup>
+    <van-notice-bar color="#1989fa" background="#ecf9ff" left-icon="info-o" text="点击查看每天的评分" />
+    <van-cell v-for="(stu, index) in data" :key="index" :title="stu.name" :value="getScore(stu.id)" @click="searchDailyList(stu)" />
+    <van-dialog v-model="show" :show-confirm-button="false" show-cancel-button @confirm="toSave">
+      <template #title>
+        <van-row style="padding:15px 0;" type="flex" justify="center">
+          <van-col span="8">{{ form.name }}</van-col>
+        </van-row>
+      </template>
+      <template>
+        <van-cell v-for="(i, index) in dailyList" :key="index" :title="i.date" :value="i.score" />
+      </template>
+    </van-dialog>
   </div>
 </template>
 
 <script>
-import { mapState, createNamespacedHelpers, mapGetters } from 'vuex';
+const moment = require('moment');
+import { mapState, createNamespacedHelpers } from 'vuex';
 export default {
   name: 'peaceAchieve',
   props: {
-    peaceAchieveList: null,
-    showPicker: null,
-    peaceScore: null,
+    data: { type: Array, default: () => [] },
+    scoreList: { type: Array, default: () => [] },
+    lesson: { type: Array, default: () => [] },
+    classInfo: { type: Object, default: () => {} },
   },
   components: {},
-  data: () => ({
-    columns: ['1', '2', '3', '4', '5', '7', '8', '9', '10'],
-  }),
-  created() {},
-  computed: {
-    ...mapState(['user']),
+  data: function() {
+    return {
+      show: false,
+      limitJob: '学委',
+      form: {},
+      dailyList: [],
+    };
   },
+  created() {},
   methods: {
-    showBtn(id) {
-      this.$emit('showBtn', id);
+    getScore(stuid) {
+      let list = this.scoreList.filter(f => f.studentid === stuid);
+      const res = list.reduce((p, n) => p + (n['score'] * 1 || 0), 0);
+      return res;
+    },
+    searchDailyList(stu) {
+      this.$set(this, `form`, stu);
+      let list = this.scoreList.filter(f => f.studentid === stu.id);
+      this.show = true;
+      list = _.orderBy(list, ['date'], ['asc']);
+      this.$set(this, `dailyList`, list);
+    },
+    add() {
+      const { startdate, enddate, id: classid } = this.classInfo;
+      let obj = { classid, studentid: this.form.id, score: 0 };
+      // 在分数列表中找到该学生的所有日常分数
+      let list = _.cloneDeep(this.dailyList);
+      if (list.length <= 0) {
+        let lesson = this.findDate(startdate, startdate, enddate);
+        if (lesson) (obj.date = lesson.date), (obj.subid = lesson.subid);
+      } else {
+        let last = _.last(list);
+        let date = moment(last.date)
+          .add(1, 'days')
+          .format('YYYY-MM-DD');
+        let lesson = this.findDate(date, startdate, enddate);
+        if (lesson) (obj.date = lesson.date), (obj.subid = lesson.subid);
+      }
+      list.push(obj);
+      if (obj.date) this.$set(this, `dailyList`, list);
+      else this.$toast('无法添加,已添加本班所有上课的日期');
     },
-    onConfirm(value) {
-      this.$emit('onConfirm', value);
+    findDate(date, start, end) {
+      let r = this.lesson.find(f => f.date == date);
+      while (!r) {
+        date = moment(date)
+          .add(1, 'days')
+          .format('YYYY-MM-DD');
+        if (moment(date).isBetween(start, end, null, '[]')) {
+          r = this.lesson.find(f => f.date == date);
+        } else break;
+      }
+      return r;
     },
+    toSave() {
+      console.log(this.dailyList);
+      this.$emit('save', _.cloneDeep(this.dailyList));
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
   },
 };
 </script>
 
-<style lang="less" scoped>
-.list {
-  background: #fff;
-  margin: 0 10px 10px 10px;
-  width: 95%;
-}
-.list .name {
-  padding: 15px 15px;
-}
-.list .score {
-  padding: 15px 0;
-}
-.list .score span {
-  padding: 0 7px 0 0;
-}
-</style>
+<style lang="less" scoped></style>

+ 6 - 0
src/router/index.js

@@ -5,6 +5,12 @@ import store from '@/store/index';
 Vue.use(VueRouter);
 
 const routes = [
+  {
+    path: '/login',
+    name: 'login',
+    meta: { title: '登录中...', isleftarrow: false },
+    component: () => import('../views/login.vue'),
+  },
   {
     path: '/',
     name: 'index',

+ 71 - 177
src/views/class/achieve.vue

@@ -3,27 +3,17 @@
     <el-row>
       <el-col :span="24" class="style">
         <el-col :span="24" class="top">
-          <!-- <topInfo></topInfo> -->
           <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
         </el-col>
         <el-col :span="24" class="main">
           <achieves
-            @clickDialog="opensave"
             @submit="onsave"
-            :peaceAchieveList="peaceAchieveList"
-            :showPicker="showPicker"
-            :peaceScore="peaceScore"
-            @showBtn="showBtn"
-            @onConfirm="onConfirm"
-            :achieveList="achieveList"
-            @submitss="onsist"
-            :show="show"
-            :form="form"
-            :deptList="deptList"
+            @save="dailyUpdate"
+            :studentList="studentList"
+            :scoreList="scoreList"
+            :classInfo="classInfo"
             :lesson="lesson"
-            :lesslist="lesslist"
-            :names="names"
-            :score="score"
+            :achieveList="achieveList"
           ></achieves>
         </el-col>
       </el-col>
@@ -36,11 +26,10 @@ import NavBar from '@/layout/common/topInfo.vue';
 import achieves from '@/layout/class/achieve.vue';
 import { mapState, createNamespacedHelpers, mapGetters } from 'vuex';
 const { mapActions: mapStudent } = createNamespacedHelpers('student');
-const { mapActions: mapClass } = createNamespacedHelpers('classes');
-const { mapActions: mapLesson } = createNamespacedHelpers('lesson');
+const { mapActions: util } = createNamespacedHelpers('util');
+const { mapActions: classes } = createNamespacedHelpers('classes');
 const { mapActions: mapUploadtask } = createNamespacedHelpers('uploadtask');
-const { mapActions: mapSubject } = createNamespacedHelpers('subject');
-const { mapActions: group } = createNamespacedHelpers('group');
+const { mapActions: pscore } = createNamespacedHelpers('personalscore');
 export default {
   name: 'achieve',
   props: {},
@@ -49,33 +38,74 @@ export default {
     achieves, //班级学生成绩列表
   },
   data: () => ({
-    peaceAchieveList: [],
-    showPicker: false,
-    peaceScore: '',
-    studid: '',
-    lesson: [],
-    lesslist: [],
-    names: '',
-    score: '',
-    deptList: [],
+    studentList: [],
     achieveList: [],
-    show: false,
-    form: {},
+    scoreList: [],
+    lesson: [],
+    classInfo: {},
     title: '',
     isleftarrow: '',
-    transitionName: 'fade',
     navShow: true,
-    // 修改
-    stuid: '',
-    taskid: '',
-    subname: '',
-    task: [],
-    homework: [],
-    groupsocre: '',
   }),
-  created() {
-    this.search();
-    this.searchinfo();
+  async created() {
+    await this.getClass();
+    await this.toGetPScoreList();
+    await this.search();
+  },
+  methods: {
+    ...util({ modelFetch: 'fetch' }),
+    ...pscore({ getPScoreList: 'query', pscoreOpera: 'opera' }),
+    ...mapStudent({ list: 'query' }),
+    ...classes({ getClassInfo: 'fetch' }),
+    ...mapUploadtask({ uploadtaskinfo: 'fetch', uploadtasklist: 'query', uploadtaskupdate: 'update' }),
+    async getClass() {
+      const res = await this.getClassInfo(this.classid);
+      if (this.$checkRes(res)) this.$set(this, `classInfo`, res.data);
+      const lres = await this.modelFetch({ model: 'lesson', classid: this.classid });
+      if (this.$checkRes(lres)) {
+        let { lessons } = lres.data;
+        if (lessons) {
+          lessons = _.uniqBy(
+            lessons.filter(f => f.subid),
+            'subid'
+          );
+          this.$set(this, `lesson`, lessons);
+        }
+      }
+    },
+    // 平时成绩学生名单查询+作业成绩学生名单查询
+    async search() {
+      let classid = this.classid;
+      const res = await this.list({ classid });
+      this.$set(this, `studentList`, res.data);
+      const result = await this.uploadtasklist({ classid });
+      // 整理学生的作业
+      const stuGroups = _.groupBy(result.data, 'studentid');
+      const aList = [];
+      for (const id in stuGroups) {
+        const head = stuGroups[id][0];
+        if (!head) continue;
+        const { stuname: name } = head;
+        const newobj = { name, lesson: stuGroups[id] };
+        aList.push(newobj);
+      }
+      this.$set(this, `achieveList`, aList);
+    },
+    //third 获取该班平时分
+    async toGetPScoreList() {
+      const res = await this.getPScoreList({ classid: this.classid });
+      if (this.$checkRes(res)) this.$set(this, `scoreList`, res.data);
+    },
+    // third 平时分保存(添加/修改)
+    async dailyUpdate(data) {
+      const res = await this.pscoreOpera(data);
+      if (this.$checkRes(res, '修改成功', res.errmsg || '修改失败')) this.toGetPScoreList();
+    },
+    async onsave({ data }) {
+      const obj = { id: data.id, score: data.score };
+      await this.uploadtaskupdate(obj);
+      this.search();
+    },
   },
   computed: {
     ...mapState(['user']),
@@ -93,142 +123,6 @@ export default {
       this.isleftarrow = to.meta.isleftarrow;
     },
   },
-  methods: {
-    ...mapStudent({ list: 'query', add: 'create', fet: 'fetch', updates: 'update' }),
-    ...mapClass({ classinfo: 'fetch', classlist: 'query' }),
-    ...mapLesson({ lessoninfo: 'fetch', lessonlist: 'query' }),
-    ...mapUploadtask({ uploadtaskinfo: 'fetch', uploadtasklist: 'query', uploadtaskupdate: 'update' }),
-    ...mapSubject({ subjectinfo: 'fetch', subjectlist: 'query' }),
-    ...group({ groupinfo: 'query', groupfetch: 'fetch', findbystuid: 'findbystuid', groupupdate: 'update' }),
-    // 平时成绩学生名单查询+作业成绩学生名单查询
-    async search() {
-      let classid;
-      classid = this.user.classid;
-      const res = await this.list({ classid });
-
-      this.$set(this, `peaceAchieveList`, res.data);
-      let classsid = this.user.classid;
-      const result = await this.uploadtasklist({ classsid });
-
-      for (const accc of result.data) {
-        var arr = res.data.filter(item => item.id === accc.studentid);
-        this.$set(this, `achieveList`, arr);
-      }
-    },
-    // 学委上作业分+存储学生id
-    clickAchieve({ id }) {
-      this.$set(this, `stuid`, id);
-      this.show = true;
-    },
-    // 学委上作业分提交
-    async submitAchieve(form) {
-      this.form.id = this.stuid;
-      let data = this.form;
-      const res = await this.uploadtaskupdate(data);
-      this.show = false;
-    },
-    // 平时成绩上分显示+学生id
-    showBtn(id) {
-      this.$set(this, `studid`, id);
-      this.showPicker = true;
-    },
-    // 给学生上分
-    async onConfirm(peaceScore) {
-      let data = {};
-      data.id = this.studid;
-
-      const ress = await this.fet(this.studid);
-
-      data.selfscore = Number(ress.data.selfscore) + Number(peaceScore);
-
-      const res = await this.updates(data);
-      this.$message({
-        message: '平时成绩上分成功',
-        type: 'success',
-      });
-
-      let classid = this.user.classid;
-
-      const group = await this.findbystuid({ stuid: this.studid });
-
-      for (const acc of group.data.students) {
-        var ref = this.peaceAchieveList.filter(item => item.id === acc.stuid);
-
-        for (const aaa of ref) {
-          acc.stores = aaa.selfscore;
-        }
-        let asd = group.data.students.map(i => i.stores);
-        let nes = asd.filter(d => d);
-        let snewcore = eval(nes.join('+'));
-        this.groupsocre = snewcore;
-      }
-      group.data.score = Number(data.selfscore) + Number(this.groupsocre);
-      let groups = group.data;
-      const groupup = await this.groupupdate(groups);
-      this.search();
-      this.showPicker = false;
-    },
-    //  作业成绩列表
-    async searchinfo({ ...info } = {}) {
-      // let classid = this.user.classid;
-      // const result = await this.uploadtasklist({ classid });
-      // const res = await this.list({ classid });
-      // for (const accc of res.data) {
-      //   var arr = result.data.filter(item => item.studentid === accc.id);
-      // }
-      // // let lessons = [];
-      // let lessone = [];
-      // let stus = [];
-      // for (const val of result.data) {
-      //   let newsid = val.lessonid;
-      //   let classid = this.user.classid;
-      //   //查询这个班的课程
-      //   const lessonInfo = await this.lessonlist({ classid });
-      //   for (const hic of lessonInfo.data) {
-      //     //过滤出有作业的科目
-      //     var fff = hic.lessons.filter(item => item._id === newsid);
-      //     for (const less of fff) {
-      //       this.$set(this, `subname`, less.subname);
-      //     }
-      //   }
-      //   val.subName = this.subname;
-      //   const stuInfo = await this.fet(val.studentid);
-      //   val.stuName = stuInfo.data.name;
-      //   //创建学生名字相关数组
-      //   let stu = [{ stuname: stuInfo.data.name, id: val.studentid }];
-      //   //合并数组
-      //   stus = [...stu, ...stus];
-      //   //去掉重复数组对象
-      //   var appArray = _.uniqWith(stus, _.isEqual);
-      //   //合并数组
-      //   this.$set(this, `achieveList`, appArray);
-      //   let lessonss = [{ name: this.subname, id: val.studentid, taskid: val.id, score: val.score, less: [] }];
-      //   lessone = [...lessonss, ...lessone];
-      //   var appArrayss = _.uniqWith(lessone, _.isEqual);
-      //   this.$set(this, `task`, lessone);
-      //   console.log(appArrayss);
-      // }
-    },
-    //为了获取当前点击学生id和当前学生上传的作业
-    async onsist({ id }) {
-      const result = await this.uploadtasklist({ studentid: id });
-
-      this.$set(this, `lesson`, result.data);
-    },
-    async opensave({ id, name, score }) {
-      this.show = true;
-      this.$set(this, `names`, name);
-      this.$set(this.form, `score`, score);
-      this.$set(this, `taskid`, id);
-    },
-    async onsave(form) {
-      this.form.id = this.taskid;
-
-      let res = await this.uploadtaskupdate(this.form);
-      this.show = false;
-      this.search();
-    },
-  },
 };
 </script>
 

+ 6 - 6
src/views/class/info/headStuList.vue

@@ -2,16 +2,16 @@
   <div id="headStuList">
     <el-row>
       <el-col :span="24" class="info">
-       <el-col :span="24" v-if="nojob.length > 0" class="nojob">
-        <p>未设定职位名称:</p>
-        <span v-for="(item, index) in nojob" :key="index">{{ item.name }}</span>
-      </el-col>
+        <el-col :span="24" v-if="nojob.length > 0" class="nojob">
+          <p>未设定职位名称:</p>
+          <span v-for="(item, index) in nojob" :key="index">{{ item.name }}</span>
+        </el-col>
         <el-col v-for="item in groupStuList" :key="item.id">
           <el-col v-if="item.students.length > 0">
             <van-divider content-position="left">
               <span style="padding:0 10px;">{{ item.name }}</span>
               <van-button type="primary" size="small" round style="margin:0 10px 0 0;" v-if="item.status == '0'" @click="affirm(item)">确认小组</van-button>
-              <van-button type="danger" size="small" round v-if="item.status == '1'" @click="cancel(item)">取消小组</van-button>
+              <van-button type="danger" size="small" round v-if="item.status == '1' && user.type === '1'" @click="cancel(item)">取消小组</van-button>
             </van-divider>
             <el-col :span="11" class="list" v-for="i in item.students" :key="i.stuid" @click.native="clickAssign({ id: i.stuid })">
               <p class="name" :style="`font-size:${changeNum(i.stuname)}px`">{{ i.stuname }}</p>
@@ -87,7 +87,7 @@ export default {
     job_list: null,
     // 学校列表
     schoolList: { type: Array },
-    nojob:{type:Array}
+    nojob: { type: Array },
   },
   components: {},
   data: () => ({

+ 1 - 1
src/views/home/classmenu.vue

@@ -73,7 +73,7 @@ export default {
       if (name === '班级成绩') this.$router.push({ path: '/class/achieve', query: { classid: this.classid } });
       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: '/user/score', query: { classid: this.classid } });
       if (name === '学生作业') this.$router.push({ path: '/task/index' });
     },
   },

+ 5 - 3
src/views/index.vue

@@ -13,7 +13,7 @@
             </el-col>
           </span>
           <span v-else>
-            <el-col :span="24" class="list" v-for="(item, index) in classList" :key="index" @click.native="classBtn(item.id)">
+            <el-col :span="24" class="list" v-for="(item, index) in classList" :key="index" @click.native="classBtn(item.id || item._id)">
               <p>班级时间:{{ item.startdate }}~{{ item.enddate }}</p>
               <p>第{{ item.term }}期-第{{ item.batch }}批</p>
               <p>
@@ -69,6 +69,7 @@ export default {
     ...setting({ settingFetch: 'fetch' }),
     async search() {
       const setting = await this.settingFetch();
+      console.log(setting);
       if (setting.data.planid) {
         this.toClass(setting.data.planid);
       } else {
@@ -84,7 +85,7 @@ export default {
       if (this.userinfo.type === '1') {
         classList = await this.classQuery({ planid: planid, headteacherid: this.userinfo.userid });
       } else if (this.userinfo.type === '3') {
-        classList = await this.teaclass({ planid: planid, teaid: this.userinfo.userid });
+        classList = await this.teaclass({ planid: planid, termid: this.defaultOption.termid, teaid: this.userinfo.userid });
       }
       const today = moment().format('YYYY-MM-DD');
       for (const classes of classList.data) {
@@ -97,6 +98,7 @@ export default {
     },
     classBtn(index) {
       // index:班级id
+      console.log(index);
       sessionStorage.setItem('classid', index);
       this.$router.push({ path: '/home/classmenu', query: { id: index } });
     },
@@ -116,7 +118,7 @@ export default {
     },
   },
   computed: {
-    ...mapState(['user']),
+    ...mapState(['user', 'defaultOption']),
   },
   mounted() {
     this.title = this.$route.meta.title;

+ 22 - 6
src/views/login.vue

@@ -6,7 +6,8 @@
 
 <script>
 const jwt = require('jsonwebtoken');
-
+import { createNamespacedHelpers } from 'vuex';
+const { mapActions: login } = createNamespacedHelpers('login');
 export default {
   metaInfo: { title: '正在登陆...' },
   name: 'login',
@@ -15,19 +16,34 @@ export default {
   data: () => ({
     is_dev: process.env.NODE_ENV === 'development',
   }),
-  created() {
+  async created() {
     this.$toast.loading({
       message: '登陆中...',
       duration: 0,
     });
     let token = this.$route.query.token;
-    let user = jwt.decode(token);
-    sessionStorage.setItem('user', JSON.stringify(user));
-    this.$toast.clear();
-    if (!this.is_dev) this.toIndex();
+    if (token) {
+      let user = jwt.decode(token);
+      sessionStorage.setItem('user', JSON.stringify(user));
+      this.$toast.clear();
+      if (this.redirect_uri) this.$router.push(this.redirect_uri);
+      else if (!this.is_dev) this.toIndex();
+    } else {
+      let openid = this.$route.query.openid;
+      let type = this.$route.query.type;
+      if (openid && type) {
+        const obj = { openid, type };
+        const res = await this.openidLogin(obj);
+        if (res.data) {
+          this.$toast.clear();
+          this.$router.push({ path: '/', query: { token: res.data } });
+        }
+      }
+    }
   },
   computed: {},
   methods: {
+    ...login(['openidLogin']),
     toIndex() {
       this.$router.push({ path: '/' });
     },

+ 174 - 81
src/views/user/score.vue

@@ -1,128 +1,221 @@
 <template>
-  <div id="score">
+  <div id="league">
     <el-row>
       <el-col :span="24" class="style">
         <el-col :span="24" class="top">
-          <NavBar v-show="true" :title="pageTitle" :isleftarrow="true"> </NavBar>
+          <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
         </el-col>
-        <el-col :span="24" class="main" style="margin-top:5rem">
-          <el-row>
-            <el-col :span="24" class="info">
-              <el-col :span="6" class="list" v-for="(item, index) in list" :key="index" @click.native="checkScore(item)">
-                <p class="name" :style="`font-size:${changeNum(item.name)}px`">{{ item.name }}</p>
-                <p class="job">总分:{{ item.selfscore * 1 + item.taskScore * 1 || 0 }}</p>
-              </el-col>
-            </el-col>
-          </el-row>
+        <el-col :span="24" class="main">
+          <el-col :span="24" class="list" v-for="(item, index) in leagueList" :key="index">
+            <el-collapse accordion>
+              <el-collapse-item>
+                <template slot="title">
+                  <el-col :span="8" class="titleOne"> 组名:{{ item.groupname }} </el-col>
+                  <el-col :span="8" class="titleTwo"> 姓名:{{ item.stuname }} </el-col>
+                  <el-col :span="8" class="titleThree"> 总分:{{ calcTotal(item) }}分 </el-col>
+                </template>
+                <el-col :span="24" class="lessonList" v-for="(tag, index) in item.lessonList" :key="index">
+                  <el-col :span="24" class="subname"> 课程:{{ tag.subname }} </el-col>
+                  <el-col :span="24" class="info">
+                    <el-col :span="8" class="one">团队:{{ getGroupscore(item.groupid, tag.subid) || '暂无' }} </el-col>
+                    <el-col :span="8" class="one">个人:{{ getpscore(item.stuid, tag._id) || '暂无' }} </el-col>
+                    <el-col :span="8" class="one">作业: {{ gethomework(item.stuid, tag._id) || '暂无' }}</el-col>
+                  </el-col>
+                </el-col>
+              </el-collapse-item>
+            </el-collapse>
+          </el-col>
         </el-col>
-        <!-- <el-col :span="24" class="foot">
-          <footInfo></footInfo>
-        </el-col> -->
       </el-col>
     </el-row>
-    <van-dialog v-model="dialog" :title="form.name">
-      <van-cell title="总分" :value="form.selfscore * 1 + form.taskScore * 1 || 0" size="large" />
-      <van-cell title="平时分" :value="form.selfscore || 0" size="large" />
-      <van-cell title="作业分" :value="form.taskScore || 0" size="large" />
-    </van-dialog>
   </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: group } = createNamespacedHelpers('group');
 const { mapActions: uploadtask } = createNamespacedHelpers('uploadtask');
+const { mapActions: pscore } = createNamespacedHelpers('personalscore');
+const { mapActions: groupscore } = createNamespacedHelpers('groupscore');
+const { mapActions: util } = createNamespacedHelpers('util');
+
 export default {
-  name: 'score',
+  name: 'league',
   props: {},
   components: {
     NavBar,
-    // footInfo
   },
   data: function() {
     return {
-      list: [],
-      form: {},
-      dialog: false,
+      title: '',
+      isleftarrow: '',
+      transitionName: 'fade',
+      navShow: true,
+      // 积分榜
+      leagueList: [],
+      // 课程列表
+      lessonList: [],
+      // 平时分
+      getPScore: [],
+      // 作业分
+      homeworkList: [],
+      // 团队分
+      groupscoreList: [],
+      // 团队列表
+      groupList: [],
     };
   },
   created() {
+    this.searchOther();
     this.search();
   },
   methods: {
-    ...student(['query']),
-    ...uploadtask({ getTaskList: 'query' }),
+    ...group({ groupQuery: 'query', groupFetch: 'fetch' }),
+    ...groupscore({ groupscoreQuery: 'query', groupscoreFetch: 'fetch' }),
+    ...uploadtask({ uploadtaskQuery: 'query' }),
+    ...pscore({ getPScoreList: 'query', pscoreOpera: 'opera' }),
+    ...util({ modelFetch: 'fetch' }),
+    // 查询班级信息 课表,团队分,个人分,作业分
+    async searchOther() {
+      let classid = this.classid;
+      // 课表
+      let res = await this.modelFetch({ model: 'lesson', classid });
+      let r = res.data.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);
+      });
+      this.$set(this, `lessonList`, r);
+      res = await this.groupQuery({ classid });
+      this.$set(this, `groupList`, res.data);
+      // 团队分
+      res = await this.groupscoreQuery({ classid });
+      this.$set(this, `groupscoreList`, res.data);
+      // 个人分
+      res = await this.getPScoreList({ classid: classid });
+      this.$set(this, `getPScore`, res.data);
+      // 作业分
+      res = await this.uploadtaskQuery({ classid });
+      this.$set(this, `homeworkList`, res.data);
+    },
+    // 查询班级组
     async search() {
-      let res = await this.query({ classid: this.classid });
-      let classList = [];
-      if (this.$checkRes(res)) {
-        classList = res.data;
+      let classid = this.classid;
+      // 组列表
+      let groupQuery = await this.groupQuery({ classid });
+      // 组分放入数组中去
+      for (const val of groupQuery.data) {
+        for (const student of val.students) {
+          student.groupname = val.name;
+          student.groupid = val.id;
+        }
       }
-      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);
+      let arr = groupQuery.data.map(item => item.students);
+      arr = _.flattenDeep(arr);
+      for (const group of arr) {
+        group.lessonList = this.lessonList;
       }
+      this.$set(this, `leagueList`, arr);
     },
-    changeNum(name) {
-      if (name.length >= 5) {
-        return 10;
-      } else {
-        return 15;
-      }
+    // 团队
+    getGroupscore(groupid, prop) {
+      let res = this.groupscoreList.find(f => f.subid == prop && f.groupid == groupid);
+      if (res) return res.score;
+    },
+    // 平时
+    getpscore(stuid, prop) {
+      let lesson = this.lessonList.find(f => f._id == prop);
+      let res = this.getPScore.find(f => f.date == lesson.date && f.studentid == stuid);
+      if (res) return res.score;
+    },
+    // 作业
+    gethomework(stuid, prop) {
+      let res = this.homeworkList.find(f => f.lessonid == prop && f.studentid == stuid);
+      if (res) return res.score;
     },
-    checkScore(data) {
-      this.form = data;
-      this.dialog = true;
+    // 计算总分
+    calcTotal(data) {
+      // 个人
+      let getPScore = this.getPScore.filter(f => f.studentid == data.stuid);
+      let psSum = getPScore.reduce((p, n) => p + (n['score'] * 1 || 0), 0);
+      // 作业
+      let homework = this.homeworkList.filter(f => f.studentid == data.stuid);
+      // 二次过滤,排除,课表里没有的课程
+      homework = homework.filter(f => this.lessonList.find(lf => lf._id === f.lessonid));
+      let hwSum = homework.reduce((p, n) => p + (n['score'] * 1 || 0), 0);
+      // // 团队
+      let groupscore = this.groupscoreList.filter(f => f.groupid == data.groupid);
+      let groupLength = this.groupList.find(f => f.id == data.groupid);
+      let grSum = groupscore.reduce((p, n) => p + ((n['score'] * 1) / groupLength.students.length || 0), 0);
+      return hwSum + psSum + grSum;
     },
   },
   computed: {
-    ...mapState(['user', 'classid']),
-    pageTitle() {
-      return `${this.$route.meta.title}`;
+    ...mapState(['user']),
+    classid() {
+      return this.$route.query.classid;
     },
   },
-  metaInfo() {
-    return { title: this.$route.meta.title };
+  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>
-p {
-  padding: 0;
-  margin: 0;
+.style {
+  width: 100%;
+  min-height: 667px;
+  position: relative;
+  background-color: #f9fafc;
 }
-.info {
-  margin: 15px 0 0 0;
+.top {
+  height: 46px;
+  overflow: hidden;
 }
-.list {
-  text-align: center;
-  border: 1px solid #2c69fe;
-  width: 70px;
-  margin: 0 11px 10px 12px;
-  padding: 5px 0px;
-  border-radius: 10px;
-}
-.list .job {
-  font-size: 10px;
-  color: #405ffe;
+.main {
+  min-height: 620px;
+  padding: 5px;
+  .titleOne {
+    text-align: center;
+    font-size: 16px;
+  }
+  .titleTwo {
+    text-align: center;
+    font-size: 16px;
+  }
+  .titleThree {
+    text-align: center;
+    font-size: 16px;
+  }
+  .lessonList {
+    .subname {
+      text-align: center;
+      font-size: 16px;
+      color: #2c69fe;
+      font-weight: bold;
+      padding: 5px 0;
+    }
+    .info {
+      .one {
+        text-align: center;
+        border: 1px dashed #cccccc5f;
+      }
+    }
+  }
 }
 </style>

+ 5 - 4
vue.config.js

@@ -1,6 +1,7 @@
 const path = require('path');
 const question = path.resolve(__dirname, '../question-examine');
 const frame = path.resolve(__dirname, '../frame');
+const ip = 'http://127.0.0.1';
 module.exports = {
   publicPath: process.env.NODE_ENV === 'development' ? '/' : '/mobiledirtea',
   outputDir: 'mobiledirtea',
@@ -23,21 +24,21 @@ module.exports = {
     //api地址前缀
     proxy: {
       '/files': {
-        target: 'http://free.liaoningdoupo.com',
+        target: 'http://jytz.jilinjobs.cn',
         changeOrigin: true,
         ws: true,
       },
       '/ws': {
-        target: 'http://free.liaoningdoupo.com',
+        target: 'http://jytz.jilinjobs.cn',
         ws: true,
       },
       '/weixin': {
-        target: 'http://smart.cc-lotus.info',
+        target: 'http://jytz.jilinjobs.cn',
         changeOrigin: true,
         ws: true,
       },
       '/api': {
-        target: 'http://free.liaoningdoupo.com',
+        target: ip,
         changeOrigin: true,
         ws: true,
       },