xiangpei
2024-07-11 595f08770a5dca4954c4fc0225d3585504a4bbdd
Merge remote-tracking branch 'origin/dev' into dev
8个文件已修改
232 ■■■■ 已修改文件
src/api/question.js 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/UploadC.vue 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router.js 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/education/resource/list.vue 77 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/exam/exam/MarkPaper.vue 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/exam/paper/list.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/exam/question/list.vue 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
vue.config.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/question.js
@@ -1,9 +1,10 @@
import { post } from '@/utils/request'
import { post, download } from '@/utils/request'
export default {
  pageList: query => post('/api/admin/question/page', query),
  edit: query => post('/api/admin/question/edit', query),
  select: id => post('/api/admin/question/select/' + id),
  deleteQuestion: id => post('/api/admin/question/delete/' + id),
  updateStatus: query => post('/api/admin/question/status', query)
  updateStatus: query => post('/api/admin/question/status', query),
  downloadImportTemplate: () => download('/api/admin/question/download/importTemplate'),
}
src/components/UploadC.vue
@@ -1,10 +1,11 @@
<template>
  <div>
    <el-upload :action="uploadUrl" :show-file-list="true" :limit="uploadNum" :accept="acceptList" multiple
      :file-list="fileUrl" :on-remove="handleRemove" :before-remove="beforeRemove" :on-success="handleUploadSuccess"
               :file-list="fileUrl" :on-remove="handleRemove" :before-remove="beforeRemove"
               :on-success="handleUploadSuccess"
      :before-upload="beforeUpload">
      <el-button size="small" type="primary">点击上传</el-button>
      <div slot="tip" class="el-upload__tip">只能上传pdf、mp4、avi、png、jpg、jpge文件,且不超过{{ fileSizeLimitM }}M</div>
      <div slot="tip" class="el-upload__tip">只能上传pdf、mp3、mp4、avi、webm、png、jpg、jpge、doc、docx、xls、xlsx、ppt、pptx文件,且不超过{{ fileSizeLimitM }}M</div>
      <div v-if="fileUrl && fileUrl.length > 0 && uploadNum === 1">
        <video controls class="returnShow" v-if="fileType === 'video'" :src="'/api/files/' + fileUrl[0].url"></video>
        <img class="returnShow" v-if="fileType === 'img'" :src="'/api/files/' + fileUrl[0].url" />
@@ -16,7 +17,7 @@
<script>
export default {
  name: "UploadC",
  name: 'UploadC',
  props: {
    uploadNum: {
      required: false,
@@ -40,65 +41,71 @@
  },
  data() {
    return {
      uploadUrl: "http://localhost:8000/api/upload/upload",
      uploadUrl: 'http://localhost:8000/api/upload/upload',
      fileTypeList: {
        'video': ['mp4', 'avi'],
        'video': ['mp4', 'avi', 'webm'],
        'img': ['jpg', 'png', 'jpeg'],
        'pdf': ['pdf'],
        'word': ['doc', 'docx'],
        'excel': ['xlsx', 'xls'],
        'audio': ['mp3'],
        'ppt': ['ppt', 'pptx'],
        'file': ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'png', 'jpg', 'jpeg', 'pdf'],
      }
    };
    }
  },
  methods: {
    clearFile() {
      this.fileUrl = [];
      this.fileUrl = []
    },
    beforeRemove(file, fileList) {
      if (file && file.status === "success") {
        return this.$confirm(`确定移除 ${file.name}?`);
      if (file && file.status === 'success') {
        return this.$confirm(`确定移除 ${file.name}?`)
      }
    },
    handleRemove(file, fileList) {
      this.$emit('removeFile', this.fileUrl, file.name);
      this.$emit('removeFile', this.fileUrl, file.name)
    },
    handleUploadSuccess(res, file) {
      this.fileUrl.push(res.data);
      this.$emit('getUploadUrl', this.fileUrl);
      this.fileUrl.push(res.data)
      this.$emit('getUploadUrl', this.fileUrl)
    },
    beforeUpload(file) {
      const { type } = file;
      const typeList = this.fileTypeList[this.fileType];
      let limitType = true;
      const fileName = file.name // 获取文件名
      const extension = fileName.split('.').pop() // 提取扩展名
      const typeList = this.fileTypeList[this.fileType]
      let limitType = true
      if (typeList) {
        const tempType = typeList.find(item => {
          if (type.includes(item)) {
            return true;
          if (extension.toLowerCase() === item) {
            return true
          } else {
            return false;
            return false
          }
        });
        })
        if (!tempType) {
          this.$message.error(`请上传正确的文件格式!`);
          limitType = false;
          this.$message.error(`请上传正确的文件格式!`)
          limitType = false
        }
      }
      const limit = file.size / 1024 / 1024 < this.fileSizeLimitM;
      const limit = file.size / 1024 / 1024 < this.fileSizeLimitM
      if (!limit) {
        this.$message.error(`上传文件大小不能超过 ${this.fileSizeLimitM}MB!`);
        this.$message.error(`上传文件大小不能超过 ${this.fileSizeLimitM}MB!`)
      }
      return limitType && limit;
      return limitType && limit
    },
  },
  computed: {
    acceptList() {
      let temp = '.*';
      let temp = '.*'
      if (this.fileTypeList[this.fileType]) {
        temp = this.fileTypeList[this.fileType].map(item => '.' + item).join(',');
        temp = this.fileTypeList[this.fileType].map(item => '.' + item).join(',')
      }
      return temp;
      return temp
    }
  }
};
}
</script>
<style scoped>
src/router.js
@@ -50,21 +50,21 @@
        path: '/exam/mark/paper',
        component: () => import('@/views/exam/exam/MarkPaper'),
        name: 'MarkPaper',
        meta: { title: '阅卷'},
        meta: { title: '阅卷', noCache: true },
        hidden: true
      },
      {
        path: '/exam/mark/paper/detail',
        component: () => import('@/views/exam/exam/MarkPaperDetail'),
        name: 'MarkPaperDetail',
        meta: { title: '阅卷'},
        meta: { title: '阅卷详情', noCache: true },
        hidden: true
      },
      {
        path: '/exam/monitor',
        component: () => import('@/views/exam/exam/monitor'),
        name: 'monitor',
        meta: { title: '监控'},
        meta: { title: '监控', noCache: true },
        hidden: true
      }
    ]
@@ -385,7 +385,8 @@
      }
    ]
  },
  { path: '*',
  {
    path: '*',
    hidden: true,
    component: () => import('@/views/error-page/404'),
    meta: { title: '404', noCache: true }
src/views/education/resource/list.vue
@@ -17,6 +17,16 @@
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="文件类型">
          <el-select v-model="searchForm.contentType" clearable @clear="page" @change="page" placeholder="文件类型">
            <el-option
              v-for="item in contentTypeList"
              :key="item.value"
              :label="item.name"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="page" size="small">查询</el-button>
        </el-form-item>
@@ -46,8 +56,14 @@
                    class="showContent"></el-image>
          <!-- <img v-if="scope.row.contentType === 'img'" :src="'/api/files/' + scope.row.contentUrl.url"
            class="showContent" /> -->
          <el-link type="primary" v-if="scope.row.contentType === 'pdf'" class="showContent"
                   @click="checkPdf('/api/files/' + scope.row.contentUrl.url)">点击查看
          <audio controls v-if="scope.row.contentType === 'audio'"
                 class="showContent">
            <source :src="'/api/files/' + scope.row.contentUrl.url">
          </audio>
          <el-link type="primary"
                   v-if="scope.row.contentType !== 'video' && scope.row.contentType !== 'audio'  && scope.row.contentType !== 'img'"
                   class="showContent"
                   @click="check(scope.row)">点击查看
          </el-link>
        </template>
      </el-table-column>
@@ -57,6 +73,13 @@
            <el-link type="primary" :href="'/api/upload/download?url=' + item.url +'&fileName=' + item.name">
              {{ item.name }}
            </el-link>
          </div>
        </template>
      </el-table-column>
      <el-table-column prop="visitUrl" label="访问链接">
        <template slot-scope="scope">
          <div v-if="scope.row.contentType === 'video'">
            {{ scope.row.visitUrl }}
          </div>
        </template>
      </el-table-column>
@@ -98,9 +121,12 @@
        </el-form-item>
        <el-form-item label="文件类型" prop="contentType">
          <el-select v-model="form.contentType" placeholder="不同类型的文件阅览方式不同,多余文件请以附件形式上传" @change="fileChange">
            <el-option label="视频" value="video"></el-option>
            <el-option label="PDF" value="pdf"></el-option>
            <el-option label="图片" value="img"></el-option>
            <el-option
              v-for="item in contentTypeList"
              :key="item.value"
              :label="item.name"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="上传文件(一个)" prop="contentUrl">
@@ -147,12 +173,22 @@
      dialogTitle: '添加学习内容',
      ids: [],
      typeList: [],
      contentTypeList: [
        { name: '视频', value: 'video' },
        { name: '图片', value: 'img' },
        { name: '音频', value: 'audio' },
        { name: 'PDF', value: 'pdf' },
        { name: 'EXCEL', value: 'excel' },
        { name: 'WORD', value: 'word' },
        { name: 'PPT', value: 'ppt' }
      ],
      classesIds: [],
      searchForm: {
        pageNum: 1,
        pageSize: 5,
        subjectId: null,
        introduction: null
        introduction: null,
        contentType: null
      },
      total: 0,
      tableData: [],
@@ -169,10 +205,10 @@
      },
      rules: {
        contentUrl: [
          { required: true, message: '请上传文件', trigger: 'blur' },
          { required: true, message: '请上传文件', trigger: 'blur' }
        ],
        introduction: [
          { required: true, message: '请输入主题内容', trigger: 'blur' },
          { required: true, message: '请输入主题内容', trigger: 'blur' }
        ],
        belongType: [
          { required: true, message: '请选择学习分类', trigger: 'change' }
@@ -190,9 +226,10 @@
        this.classesIds = re.data.data
      })
    },
    checkPdf (url) {
      this.pdf = url
      this.pdfDialog = true
    check (row) {
      // this.pdf = url
      // this.pdfDialog = true
      window.open(row.visitUrl)
    },
    closePdfDialog () {
      this.pdfDialog = false
@@ -213,9 +250,22 @@
      if (row.contentType === 'img') {
        return '图片'
      }
      if (row.contentType === 'audio') {
        return '音频'
      }
      if (row.contentType === 'pdf') {
        return 'PDF'
      }
      if (row.contentType === 'excel') {
        return 'EXCEL'
      }
      if (row.contentType === 'word') {
        return 'WORD'
      }
      if (row.contentType === 'ppt') {
        return 'PPT'
      }
    },
    clearFile () {
      this.form.contentUrl = []
@@ -244,13 +294,14 @@
    batchRemove () {
      if (this.ids.length < 1) {
        this.$message.warning('请选择要删除的数据')
      }
      } else {
      EducationResourceAPI.remove(this.ids).then(res => {
        if (res.code === 1) {
          this.$message.success('删除成功')
          this.ids = []
        }
      })
      }
    },
    getTitle (typeName) {
      return '确定要删除' + typeName + '这个文件吗?'
@@ -319,7 +370,7 @@
      this.form.belongType = row.belongType
      this.dialogTitle = '修改学习内容'
      this.open = true
    }
    },
  },
  mounted () {
    this.page()
src/views/exam/exam/MarkPaper.vue
@@ -76,7 +76,7 @@
        width="300px"
      >
        <template slot-scope="scope">
          <el-button @click="markPaper(scope.row.userId)" type="warning">阅卷</el-button>
          <el-button @click="markPaper(scope.row)" type="warning">阅卷</el-button>
        </template>
      </el-table-column>
    </el-table>
@@ -91,10 +91,18 @@
  mounted () {
    this.examInfo.examName = this.$route.query.examName
    this.examInfo.examId = this.$route.query.examId
    console.log('------->' + this.examInfo.examName + '------->' + this.examInfo.examId)
    if (this.examInfo.examId) {
      this.getExamInfo()
    }
  },
  // watch: {
  //   $route: {
  //     handler () {
  //       this.reloadPage()
  //     }
  //   }
  // },
  data () {
    return {
      examInfo: {
@@ -111,6 +119,14 @@
    }
  },
  methods: {
    // reloadPage () {
    //   this.examInfo.examName = this.$route.query.examName
    //   this.examInfo.examId = this.$route.query.examId
    //   console.log('------->' + this.examInfo.examName + '------->' + this.examInfo.examId)
    //   if (this.examInfo.examId) {
    //     this.getExamInfo()
    //   }
    // },
    statusFormatter (row, column, cellValue, index) {
      if (cellValue === 'finish') {
        return '完成'
@@ -118,9 +134,12 @@
        return '未完成'
      }
    },
    markPaper (userId) {
    markPaper (row) {
      // todo打开阅卷页面
      this.$router.push({path: "/exam/mark/paper/detail", query: {examId: this.examInfo.examId, examName: this.examInfo.examName, userId: userId}})
      this.$router.push({
        path: '/exam/mark/paper/detail',
        query: { examId: this.examInfo.examId, examName: this.examInfo.examName, userId: row.userId }
      })
    },
    getExamInfo () {
      getExamMarkPaperInfo(this.examInfo.examId).then(res => {
@@ -136,14 +155,17 @@
.title {
  font-size: 18px;
}
.bottom5 {
  margin-bottom: 5px;
}
.nameInfo {
  width: 100%;
  display: flex;
  flex-direction: column;
}
.nameClass {
  width: 100%;
  display: flex;
@@ -153,6 +175,7 @@
  height: 70px;
  background-color: #cb5858;
}
.staticNum {
  width: 100%;
  display: flex;
src/views/exam/paper/list.vue
@@ -9,7 +9,7 @@
        <router-link :to="{ path: '/exam/paper/edit' }" class="link-left">
          <el-button type="primary" >添加</el-button>
        </router-link>
        <el-button class="link-left" type="danger" @click="downloadImportTemplate">下载导入模板</el-button>
        <el-button class="link-left" type="danger" @click="downloadImportTemplate">下载模板</el-button>
        <router-link :to="{ path: '/exam/paper/import' }" class="link-left">
          <el-button type="success">导入</el-button>
        </router-link>
@@ -75,7 +75,7 @@
    // 下载导入模板
    downloadImportTemplate() {
      examPaperApi.downloadImportTemplate().then(res => {
        downloadExcel(res, '题目导入模板')
        downloadExcel(res, '试卷导入模板')
      })
    },
    submitForm() {
src/views/exam/question/list.vue
@@ -28,6 +28,18 @@
          </el-button>
          <el-button slot="reference" type="primary" class="link-left">添加</el-button>
        </el-popover>
        <el-button class="link-left" type="danger" @click="downloadImportTemplate">下载模板</el-button>
        <el-upload
          style="display: inline;"
          class="op-item link-left"
          action="/api/admin/question/import"
          :with-credentials="true"
          :on-success="handlePreview"
          accept=".xls,.xlsx"
          :show-file-list="false"
          :before-upload="beforeAvatarUpload">
          <el-button v-loading="importLoading" type="primary">导入</el-button>
        </el-upload>
      </el-form-item>
    </el-form>
    <el-table v-loading="listLoading" :data="tableData" border fit highlight-current-row style="width: 100%">
@@ -73,11 +85,13 @@
import Pagination from '@/components/Pagination'
import QuestionShow from './components/Show'
import questionApi from '@/api/question'
import { downloadExcel } from '@/utils/download'
export default {
  components: { Pagination, QuestionShow },
  data() {
    return {
      importLoading: '',
      queryParam: {
        id: null,
        questionType: null,
@@ -103,6 +117,33 @@
    this.search()
  },
  methods: {
    handlePreview (e) {
      this.importLoading = false
      if (e.code === 1) {
        this.search()
        this.$message.success(e.message)
      } else {
        this.$message.error(e.message)
      }
    },
    beforeAvatarUpload (file) {
      this.importLoading = true
      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
      }
    },
    // 下载导入模板
    downloadImportTemplate() {
      questionApi.downloadImportTemplate().then(res => {
        downloadExcel(res, '题目导入模板')
      })
    },
    statusQuestion(row) {
      let question = {
        id: row.id,
vue.config.js
@@ -19,8 +19,8 @@
    hotOnly: false,
    proxy: {
      '/api': {
        // target: 'http://localhost:8000',
        target: 'http://192.168.3.64:8000',
        target: 'http://localhost:8000',
        // target: 'http://192.168.3.64:8000',
        changeOrigin: true
      }
    }