odc.xiaohui
2023-07-04 a012d96b2188cacc46f7ba63e60bf5ec142602a4
修改青羊后台答卷统计
4个文件已修改
1个文件已添加
242 ■■■■■ 已修改文件
src/api/dashboard.js 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router.js 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/answer/sheetStatistics.vue 128 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/exam/paper/edit.vue 42 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/user/student/list.vue 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/dashboard.js
@@ -1,5 +1,7 @@
import { post } from '@/utils/request'
export default {
  index: () => post('/api/admin/dashboard/index')
  index: () => post('/api/admin/dashboard/index'),
  getData: query => post('/api/admin/examPaperAnswer/paperStatistics',query),
  page: query => post('/api/admin/examPaperAnswer/page', query)
}
src/router.js
@@ -215,6 +215,12 @@
        component: () => import('@/views/answer/list'),
        name: 'AnswerPageList',
        meta: { title: '答卷列表', noCache: true }
      },
      {
        path: 'sheetStatistics',
        component: () => import('@/views/answer/sheetStatistics.vue'),
        name: 'AnswerPageList',
        meta: { title: '答卷统计', noCache: true }
      }
    ]
  },
src/views/answer/sheetStatistics.vue
New file
@@ -0,0 +1,128 @@
<template>
<div style="padding: 10px">
  <el-form :model="queryParam" ref="queryForm" :inline="true " style="display: flex">
    <el-form-item label="试卷名称:" >
      <el-input v-model="paperName.paperName"></el-input>
    </el-form-item>
<!--    <el-form-item label="试卷题目:">-->
<!--      <el-input v-model="queryParam.paperName"></el-input>-->
<!--    </el-form-item>-->
    <el-form-item>
      <el-button type="primary" @click="submitForm">查询</el-button>
    </el-form-item>
  </el-form>
  <div style="display: flex;justify-content: center;color: #0a76a4">
    <div >最低分:{{min}}</div>
    <div style="margin-left: 5px">最高分:{{max}}</div>
    <div style="margin-left: 5px">平均分:{{avg}}</div>
  </div>
  <el-row class="echarts-line">
    <div id="echarts-moth-user" style="width: 100%;height:400px;" v-loading="loading"/>
  </el-row>
</div>
</template>
<script>
import examPaperAnswerApi from '@/api/examPaperAnwser'
import dashboardApi from '@/api/dashboard'
const animationDuration = 6000
export default {
  data(){
    return{
      max:'',
      min:'',
      avg:'',
      paperName:{
        paperName:''
      },
      loading:false,
      examPaperCount: 0,
      questionCount: 0,
      doExamPaperCount: 0,
      doQuestionCount: 0,
      echartsUserAction: null,
      queryParam: {
        paperName:'',
        userName:'',
        subjectId: null,
        pageIndex: 1,
        pageSize: 10
      },
      listLoading:false
    }
  },
  mounted(){
    let _this = this
    dashboardApi.getData(this.paperName).then(re => {
      let response = re.response
      console.log(response)
      _this.avg = response.avg
      _this.max = response.max
      _this.min = response.min
      _this.examPaperCount = response.examPaperCount
      _this.questionCount = response.questionCount
      _this.doExamPaperCount = response.doExamPaperCount
      _this.doQuestionCount = response.doQuestionCount
      _this.echartsUserAction.setOption(this.option('用户活跃度', '{b}分{c}人', response.mothDayText, response))
      // _this.echartsQuestion.setOption(this.option('题目月数量', '{b}日{c}题', response.mothDayText, response.mothDayDoExamQuestionValue))
      this.loading = false
    })
    this.echartsUserAction = echarts.init(document.getElementById('echarts-moth-user'), 'macarons')
  },
  methods:{
    option (title, formatter, label, vaule) {
      return {
        title: {
          text: '答卷统计',
          x: 'center'
        },
        tooltip: {
          trigger: 'item',
          formatter: formatter
        },
        xAxis: {
          type: 'category',
          data: ['0-60','60-80','80-100']
        },
        grid: {
          left: 10,
          right: 10,
          bottom: 20,
          top: 30,
          containLabel: true
        },
        yAxis: {
          type: 'value'
        },
        series: [{
          data: [vaule.lowGrade,vaule.intermediate,vaule.advanced],
          type: 'bar',
          barMaxWidth:'10%'
        }]
      }
    },
    search () {
      // this.listLoading = true
      let _this = this
      dashboardApi.getData(this.paperName).then(re => {
        console.log(re)
        let response = re.response
        _this.avg = response.avg
        _this.max = response.max
        _this.min = response.min
        _this.echartsUserAction.setOption(this.option('用户活跃度', '{b}分{c}人', response.mothDayText, response))
      })
      this.echartsUserAction = echarts.init(document.getElementById('echarts-moth-user'), 'macarons')
    },
    submitForm () {
      this.queryParam.pageIndex = 1
      this.search()
    },
  }
}
</script>
<style scoped lang="scss">
</style>
src/views/exam/paper/edit.vue
@@ -37,13 +37,26 @@
          </el-col>
        </el-row>
      </el-form-item>
      <el-form-item :key="key" :label="titlejs(key)"   required  v-for="(value,key,index) in form.subjectSource"  v-if="form.paperType ==7">
      <el-form-item :key="item.subjectId" :label="item.label"   required  v-for="(item,key,index) in form.questionTypeVMS"  v-if="form.paperType ==7">
        <el-row >
          <el-col :span="3" >
            <span>题目数量:</span>
            <span>多选题:</span>
          </el-col>
          <el-col :span="9">
            <el-input v-model="form.subjectSource[key]" style="width: 80%"/>
          <el-col :span="3">
            <el-input v-model="form.questionTypeVMS[key].multipleChoice" style="width: 80%"/>
          </el-col>
          <el-col :span="3" >
            <span>单选题:</span>
          </el-col>
          <el-col :span="3">
            <el-input v-model="form.questionTypeVMS[key].singleChoice" style="width: 80%"/>
          </el-col>
          <el-col :span="3" >
            <span>判断题:</span>
          </el-col>
          <el-col :span="3">
            <el-input v-model="form.questionTypeVMS[key].trueFalse" style="width: 80%"/>
          </el-col>
        </el-row>
      </el-form-item>
@@ -135,7 +148,8 @@
        name: '',
        suggestTime: null,
        titleItems: [],
        subjectSource:{}
        subjectSource:{},
        questionTypeVMS:[]
      },
      subjectFilter: null,
      formLoading: false,
@@ -207,19 +221,29 @@
        this.$refs.subjectIdRef.selected.forEach(item=>{
          arr.push({
            label:item.label,
            id:item.value
            subjectId:item.value,
            singleChoice:'',
            multipleChoice:'',
            trueFalse:''
          })
        })
        console.log(arr)
        this.form.questionTypeVMS = arr
      }
      if (this.form.paperType ==7){
        //說明是隨機
        this.subjectIdList = arr
        let obj1={}
        let arr1 = []
        arr.forEach((item,index)=>{
          obj1[item.id]=''
          // obj1[item.id]=''
          arr1.push({
            subjectId:item.id,
            singleChoice:'',
            multipleChoice:'',
            trueFalse:''
          })
          // let obj={
          //   item
          // }
@@ -233,7 +257,9 @@
          // }
        })
        this.form.subjectSource = obj1
        console.log(this.form.subjectSource)
        console.log(this.form.questionTypeVMS)
        // this.form.paperType = 7
        this.form.titleItems = []
      }else {
src/views/user/student/list.vue
@@ -4,11 +4,25 @@
      <el-form-item label="用户名:">
        <el-input v-model="queryParam.userName"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm">查询</el-button>
        <router-link :to="{path:'/user/student/edit'}" class="link-left">
          <el-button type="primary">添加</el-button>
        </router-link>
      <el-form-item >
       <div style="display: flex">
         <el-button type="primary" @click="submitForm">查询</el-button>
         <router-link :to="{path:'/user/student/edit'}" class="link-left">
           <el-button type="primary">添加</el-button>
         </router-link>
         <el-upload
           class="upload-demo"
           :action="upLoadUrl"
           :with-credentials="true"
           :on-success="handlePreview"
           multiple
           :show-file-list="false"
           :file-list="fileList"
           :before-upload="beforeAvatarUpload">
           <el-button type="primary">导入</el-button>
           <!--          <div slot="tip" class="el-upload__tip">只能上传Excel文件</div>-->
         </el-upload>
       </div>
      </el-form-item>
    </el-form>
@@ -56,6 +70,8 @@
  components: { Pagination },
  data () {
    return {
      upLoadUrl:'/api/admin/user/import',
      fileList:[],
      queryParam: {
        userName: '',
        role: 1,
@@ -71,6 +87,37 @@
    this.search()
  },
  methods: {
    handlePreview(e){
      console.log(e)
      if (e.code==1){
        this.search()
        this.$message.success(e.message)
      }else {
        this.$message.error(e.message)
      }
    },
    beforeAvatarUpload(file) {
      let legalName = ['xlsx', 'xls']
      // 拿到后缀名
      let name = file.name.substring(file.name.lastIndexOf('.') + 1, file.name.length)
      if (legalName.includes(name)) {
        // console.log(legalName.includes(name));
      } else {
        this.$message.warning('文件格式不对,仅限xls和xlsx')
        return false
      }
      // console.log(file)
      // const isJPG = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
      // // const isLt2M = file.size / 1024 / 1024 < 2;
      //
      // if (!isJPG) {
      //   this.$message.error('上传文件只能是Excel!');
      // }
      // // if (!isLt2M) {
      // //   this.$message.error('上传头像图片大小不能超过 2MB!');
      // // }
      // return isJPG ;
    },
    search () {
      this.listLoading = true
      userApi.getUserPageList(this.queryParam).then(data => {
@@ -137,3 +184,8 @@
  }
}
</script>
<style lang="scss" scoped>
.upload-demo{
  margin-left: 5px;
}
</style>