@@ -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;
+}