From 638a2423b9fdc76b000c265293d9b0e8ed926cb8 Mon Sep 17 00:00:00 2001 From: daihh Date: Wed, 21 Dec 2022 14:54:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/exam/Question.vue | 295 +++++++++++++++++------------------- 1 file changed, 135 insertions(+), 160 deletions(-) diff --git a/src/views/exam/Question.vue b/src/views/exam/Question.vue index 51e0d7da..449a556f 100644 --- a/src/views/exam/Question.vue +++ b/src/views/exam/Question.vue @@ -14,19 +14,11 @@ --> - - - + + - +
@@ -81,8 +73,7 @@
-
- - 类型 - + +
+ 类型 + 单选 多选 判断题 @@ -105,45 +95,36 @@
- + - - - - 点击上传图片 -
只能上传jpg/png文件,且不超过500kb
-
+ + + + +
+ + 删除 +
+
+ + 点击上传图片 +
jpg/png文件不超过500kb
+
+
+
-
+
- - + - 正确 - 正确 - + 正确 + 正确 删除 -
添加选项
- + - + - +
@@ -216,61 +181,59 @@
- + - + + + + + +
+ + 删除 +
+
+ + 点击上传图片 +
jpg/png文件不超过500kb
+
+
+
+
- 正确 - 错误 + 正确 + 错误 - + + :value="item.value" > - - + + + + + show-word-limit> +
@@ -278,6 +241,7 @@
+
@@ -323,6 +287,7 @@ import { numberToLetter} from "../../utils/tools.js"; import { mapGetters,mapActions} from 'vuex'; import fileUpload from '@/components/FileUpload/index.vue'; import { setTimeout } from 'timers'; +import { getToken } from "@/utils/token"; // import {resOwnerIndexName} from '@/utils/type.js'; const questionData = { type: 1, @@ -335,10 +300,10 @@ const questionData = { images:"", statue: 0, optionList: [ - { content: "", score: "", isAnswer: false ,images:""}, - { content: "", score: "", isAnswer: false ,images:""}, - { content: "", score: "", isAnswer: false ,images:""}, - { content: "", score: "", isAnswer: false ,images:""}, + { content: "", score: "", isAnswer: false ,images:"",imgList:[]}, + { content: "", score: "", isAnswer: false ,images:"",imgList:[]}, + { content: "", score: "", isAnswer: false ,images:"",imgList:[]}, + { content: "", score: "", isAnswer: false ,images:"",imgList:[]}, ], // resSysId: [], // 试题目录 difficulty: "", // 难度 @@ -354,6 +319,10 @@ export default { return { curOption:[], uploadImgUrl: process.env.VUE_APP_BASE_API + "/xboe/sys/xuploader/file/upload", // 上传的图片服务器地址 + imageBaseUrl:process.env.VUE_APP_FILE_BASE_URL, + headers: { + 'XBOE-Access-Token': getToken(), + }, fileList:[], resOwnerListMap: [], // resOwnerName: resOwnerIndexName, @@ -363,18 +332,9 @@ export default { viewVolumeShow: false, isAdd: false, optionsList: [ - { - value: "1", - label: "单选", - }, - { - value: "2", - label: "多选", - }, - { - value: "3", - label: "判断", - }, + {value: "1",label: "单选"}, + {value: "2",label: "多选"}, + {value: "3",label: "判断"}, ], inputValue: "", params: { type: "", resSysId: "", title: "", ownership: [] }, @@ -383,24 +343,12 @@ export default { count: 0, pageIndex: 1, url: `${this.webBaseUrl}/temp/exam.png`, - resourceProps: { - value: "code", - label: "name", - }, + resourceProps: {value: "code",label: "name"}, question: questionData, difficultyOptions: [ - { - value: 1, - label: "容易", - }, - { - value: 2, - label: "中等", - }, - { - value: 3, - label: "困难", - }, + {value: 1,label: "容易"}, + {value: 2,label: "中等"}, + {value: 3,label: "困难"}, ], addQuestionDialog: false, questionRules: { @@ -415,24 +363,29 @@ export default { this.loadData(1); }, mounted() { - + this.getResOwnerTree().then(rs=>{ this.resOwnerListMap=rs; }); }, methods: { - handleUploadOptionsSuccess(res){ - this.curOption.push(res.result.filePath); - this.question.optionList[0].images = this.curOption[0]; - this.question.optionList[1].images = this.curOption[1]; - this.question.optionList[2].images = this.curOption[2]; - this.question.optionList[3].images = this.curOption[3]; - console.log(this.question) + handleBeforeUploadOption(file){ + //上传前的处理,与data关联 + console.log(file); + return true; + }, + handleUploadOptionsSuccess(optIdx,res){ + console.log(optIdx,'optIdx'); + console.log(res,'res'); + this.question.optionList[optIdx].images=res.result.filePath; + this.question.optionList[optIdx].imgList=[ + {url:res.result.httpPath}, + ] }, handleUploadSuccess(res) { console.log(res.result.filePath); - questionData.images = res.result.filePath; - console.log(questionData.images) + this.question.images=res.result.filePath; + }, handleRemove(file, fileList) { console.log(file, fileList); @@ -641,9 +594,8 @@ export default { }, editQuestion(row) { this.isAdd = false; - examQuestionApi - .detail(row.id) - .then((res) => { + let $this=this; + examQuestionApi.detail(row.id).then((res) => { if (res.status == 200) { this.addQuestionDialog = true; this.question = res.result; @@ -661,9 +613,16 @@ export default { if (this.question.optionList == null) { this.question.optionList = []; } + this.question.optionList.forEach(opt=>{ + if(opt.images){ + opt.imgList=[{url:this.imageBaseUrl+opt.images}]; + }else{ + opt.imgList=[]; + } + + }) } - }) - .catch((err) => { + }).catch((err) => { this.$message({ type: "error", message: err }); }); }, @@ -674,6 +633,10 @@ export default { this.addQuestionDialog = true; this.question.type = type; }, + deleteQImage(){ + this.question.images=''; + //同时后吧删除图片,后续要补上 + }, addOption() { if (this.question.optionList.length < 10) { this.question.optionList.push({ content: "", score: "", isAnswer: 0 ,images:""}); @@ -757,4 +720,16 @@ export default { flex: 12; } } +.upload-drag{ + .el-uoload{ + .el-upload-dragger{ + height: 50px; + width: 120px + } + } + +} +::v-deep .el-upload-dragger{ + height: 50px; +}