Commit 79e0c9a6 by 宋珺琪

判断的修改和删除、图片回显

parent 0169dfed
File deleted
......@@ -84,8 +84,16 @@
<div class="right">
<div class="title">
<p>{{title}}({{optionValue}})</p>
<ul style="display: flex;margin-left: 30px">
<li v-for="item in reduceAnswer.img" style="overflow: visible;display: flex">
<img :src="item" alt=""
@click="magnifyPhoto(item)"
style="width: 100px; height:90px; margin-left: 10px;margin-top: -5px">
</li>
</ul>
<i class="iconfont icon-right auto-right"></i>
<span>全卷共{{topicCount[0] + topicCount[1] + topicCount[2]}}<i class="iconfont icon-time"></i><!--倒计时:<b>{{time}}</b>分钟--></span>
<span>全卷共1<i class="iconfont icon-time"></i><!--倒计时:<b>{{time}}</b>分钟--></span>
</div>
<div class="content">
<p class="topic">{{showQuestion}}</p>
......@@ -133,48 +141,34 @@
</ul>
</div>
</div>
<!-- <div class="fill" v-if="currentType == 2">
<div v-for="(item,currentIndex) in part" :key="currentIndex">
<el-input placeholder="请填在此处"
v-model="fillAnswer[index][currentIndex]"
clearable
@blur="fillBG">
</el-input>
</div>
<div class="analysis" v-if="fillAnswer[index][3]">
<ul>
<li> <el-tag type="success">正确答案:</el-tag><span class="right">{{topic[2][index].answer}}</span></li>
<li><el-tag>题目解析:</el-tag></li>
<li>{{topic[2][index].analysis == null ? '暂无解析': topic[2][index].analysis}}</li>
</ul>
</div>
</div> -->
<!-- <div class="judge" v-if="currentType == 3">
<el-radio-group v-model="judgeAnswer[index]" @change="getJudgeLabel" v-if="currentType == 3">
<el-radio :label="1">正确</el-radio>
<el-radio :label="2">错误</el-radio>
<div class="judge" v-if=" optionValue == '判断题'">
<el-radio-group v-model="judgeAnswer[index]" @change="getJudgeLabel">
<el-radio :label="1" :disabled='radioFlag' :class="[isradio ? (this.reduceAnswer.rightAnswer==='A' ? 'checkboxTrueStyle' : 'checkboxFlaseStyle'):'noStyle']">正确</el-radio>
<el-radio :label="2" :disabled='radioFlag' :class="[isradio ? (this.reduceAnswer.rightAnswer==='A' ? 'checkboxTrueStyle' : 'checkboxFlaseStyle'):'noStyle']">错误</el-radio>
</el-radio-group>
<div class="analysis" id="topic3Right" style="display: none">
<ul>
<li> <el-tag type="success">正确答案:</el-tag><span class="right">{{topic[3][index].answer}}</span></li>
<li><el-tag>题目解析:</el-tag></li>
<li>{{topic[3][index].analysis == null ? '暂无解析': topic[3][index].analysis}}</li>
<li>
<el-tag type="success">正确答案:</el-tag>
<span class="right">{{reduceAnswer.answer}}</span></li>
<li>
<el-tag>题目解析:</el-tag>
</li>
<li>{{reduceAnswer.analysis == null ? '暂无解析': reduceAnswer.analysis}}</li>
</ul>
</div>
</div>-->
</div>
</div>
<!-- <div class="operation">
<ul class="end">
<li @click="previous()"><i class="iconfont icon-previous"></i><span>上一题</span></li>
&lt;!&ndash; <li @click="commit()"><i class="iconfont icon-previous"></i><span>结束考试</span></li>&ndash;&gt;
<li @click="next()"><span>下一题</span><i class="iconfont icon-next"></i></li>
</ul>
</div>-->
</div>
</transition>
</div>
</div>
<el-image
style=" position: absolute;display: none"
:preview-src-list="[dialogImageUrl]"
ref="elImage"
>
</el-image>
</div>
</template>
......@@ -183,6 +177,7 @@ import {mapState} from 'vuex'
export default {
data() {
return {
dialogImageUrl:"",//放大的图片
isradio:false, //默认为false 。。点击后改为true
ischeckBox:false, //默认为false 。。点击后改为true
startTime: null, //考试开始时间
......@@ -233,15 +228,16 @@ export default {
},
watch: {
optionValue(newValue) {
if (this.optionValue=='1'){
this.optionValue = "单选题"
}else if (this.optionValue=='2'){
this.optionValue = "多选题"
}
console.log(this.optionValue )
},
},
methods: {
//图片放大功能
magnifyPhoto(file) {
this.dialogImageUrl = file;
this.$refs.elImage.clickHandler();
},
getTime(date) { //日期格式化
let year = date.getFullYear()
let month= date.getMonth()+ 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
......@@ -256,9 +252,6 @@ export default {
this.userInfo.name = this.$route.query.cname
this.userInfo.id = this.$route.query.cid
let role = this.$route.query.role
console.log(this.userInfo.name)
console.log(this.userInfo.id)
console.log(role)
if(role == "0"){
this.roleflag = true;
}
......@@ -266,7 +259,45 @@ export default {
calcuScore() { //计算答题分数
},
getExamData() { //获取当前试卷所有信息
getExamData: function () { //获取当前试卷所有信息
let date = new Date()
this.startTime = this.getTime(date)
let examCode = this.$route.query.examCode //获取路由传递过来的试卷编号
this.$axios(`/api/exam/${examCode}`).then(res => { //通过examCode请求试卷详细信息
this.examData = {...res.data.data} //获取考试详情
this.index = 0
this.time = this.examData.totalScore //获取分钟数
let paperId = this.examData.paperId
this.$axios(`/api/paper/${paperId}`).then(res => { //通过paperId获取试题题目信息
this.topic = {...res.data}
let reduceAnswer = this.getRandomData(this.topic[1], this.topic[2], this.topic[3]) //获取随机一道题
console.log(reduceAnswer)
this.reduceAnswer = reduceAnswer
if (reduceAnswer.oneOrMore=='1'){
this.optionValue = "单选题"
this.showAnswer ={
answerA:reduceAnswer.answerA,
answerB:reduceAnswer.answerB,
answerC:reduceAnswer.answerC,
answerD:reduceAnswer.answerD,
}
}else if (reduceAnswer.oneOrMore=='2'){
this.optionValue = "多选题"
this.showAnswer ={
answerA:reduceAnswer.answerA,
answerB:reduceAnswer.answerB,
answerC:reduceAnswer.answerC,
answerD:reduceAnswer.answerD,
}
}else if (!reduceAnswer.oneOrMore) {
reduceAnswer.oneOrMore = '3'
this.optionValue = '判断题'
}
this.showQuestion = reduceAnswer.question
})
})
},
/* getExamData() { //获取当前试卷所有信息
let date = new Date()
this.startTime = this.getTime(date)
let examCode = this.$route.query.examCode //获取路由传递过来的试卷编号
......@@ -277,12 +308,14 @@ export default {
let paperId = this.examData.paperId
this.$axios(`/api/paper/${paperId}`).then(res => { //通过paperId获取试题题目信息
this.topic = {...res.data}
console.log(res)
console.log(res.data)
let reduceAnswer = this.topic[1][this.index]
this.reduceAnswer = reduceAnswer
console.log(this.reduceAnswer)
let keys = Object.keys(this.topic) //对象转数组
// console.log(this.topic[1][0]) //获取第一个题干类型
this.optionValue = this.topic[1][0].oneOrMore
this.optionValue = this.topic[3][0].oneOrMore
keys.forEach(e => {
let data = this.topic[e]
this.topicCount.push(data.length)
......@@ -299,112 +332,41 @@ export default {
father.push(children)
}
this.fillAnswer = father
let dataInit = this.topic[1]
let dataInit = this.topic[3]
this.number = 1
this.showQuestion = dataInit[0].question
this.showAnswer = dataInit[0]
})
})
},
/* change(index) { //选择题
if(index == -1){
this.index = 1
}else{
this.index = index
}
let reduceAnswer = this.topic[1][this.index]
this.reduceAnswer = reduceAnswer
this.isFillClick = true
this.currentType = 1
let len = this.topic[1].length
var topic1Right = document.getElementById("topic1Right");// 答案以=及解析
if(topic1Right != null && topic1Right != undefined){
if(this.topic1Answer[this.index] != undefined){
topic1Right.style.display = "block";
this.radioFlag = true
}else{
topic1Right.style.display = "none";
this.radioFlag = false
},*/
//获取随机题
getRandomData(multiQuestionRes ,fillQuestionsRes , judgeQuestionRes ) {
let availableLists = [];
if (multiQuestionRes.length > 0) {
availableLists.push(multiQuestionRes);
}
if (fillQuestionsRes.length > 0) {
availableLists.push(fillQuestionsRes);
}
if(this.index < len) {
if(this.index <= 0){
this.index = 0
}
console.log(`总长度${len}`)
console.log(`当前index:${index}`)
this.title = "请选择正确的选项"
let Data = this.topic[1]
// console.log(Data)
this.showQuestion = Data[this.index].question //获取题目信息
this.optionValue = Data[this.index].oneOrMore
this.showAnswer = Data[this.index]
this.number = this.index + 1
}else if(this.index >= len) {
this.index = 0
this.fill(this.index)
if (judgeQuestionRes.length > 0) {
availableLists.push(judgeQuestionRes);
}
},
fillBG() { //填空题已答题目 如果已答该题目,设置第四个元素为true为标识符
if(this.fillAnswer[this.index][0] != null) {
this.fillAnswer[this.index][3] = true
if (availableLists.length > 0) {
let randomListIndex = this.getRandomIndex(availableLists.length);
let randomList = availableLists[randomListIndex];
return randomList[this.getRandomIndex(randomList.length)];
}
return null; // 如果没有可用的数据,则返回null或其他合适的值
},
fill(index) { //填空题
let len = this.topic[2].length
this.currentType = 2
this.index = index
if(index < len) {
if(index < 0) {
index = this.topic[1].length -1
this.change(index)
}else {
console.log(`总长度${len}`)
console.log(`当前index:${index}`)
this.title = "请在横线处填写答案"
let Data = this.topic[2]
console.log(Data)
this.showQuestion = Data[index].question //获取题目信息
let part= this.showQuestion.split("()").length -1 //根据题目中括号的数量确定填空横线数量
this.part = part
this.number = this.topicCount[0] + index + 1
}
}else if(index >= len) {
this.index = 0
this.judge(this.index)
}
getRandomIndex(length) {
return Math.floor(Math.random() * length);
},
judge(index) { //判断题
let len = this.topic[3].length
this.currentType = 3
this.index = index
var topic3Right = document.getElementById("topic3Right");// 答案以=及解析
if(topic3Right != null && topic3Right != undefined){
if(this.judgeAnswer[this.index] != undefined){
topic3Right.style.display = "block";
}else{
topic3Right.style.display = "none";
}
}
if(this.index < len) {
if(this.index < 0){
this.index = this.topic[2].length - 1
this.fill(this.index)
}else {
console.log(`总长度${len}`)
console.log(`当前index:${this.index}`)
this.title = "请作出正确判断"
let Data = this.topic[3]
this.showQuestion = Data[index].question //获取题目信息
this.number = this.topicCount[0] + this.topicCount[1] + index + 1
}
}else if (this.index >= len) {
this.index = 0
this.change(this.index)
}
},*/
//多选题点击显示提交按钮
handleCheckboxChange(val) {
console.log('多选中的值为:', val);
this.radio[this.index] = val //当前选择的序号
......@@ -441,13 +403,11 @@ export default {
});
console.log('选中的项:', this.checkList);*/
},
getChangeLabel(val) { //获取选择题作答选项
//获取选择题作答选项
getChangeLabel(val) {
this.radio[this.index] = val //当前选择的序号
console.log(val)
if(val) {
let data = this.topic[1]
this.bg_flag = true
data[this.index]["isClick"] = true
var topic1Right = document.getElementById("topic1Right");
topic1Right.style.display = "block";
this.radioFlag = true
......@@ -456,56 +416,17 @@ export default {
this.topic1Answer[this.index] = val
this.commit()
},
/* getJudgeLabel(val) { //获取判断题作答选项
this.judgeAnswer[this.index] = val
//获取判断题作答选项
getJudgeLabel(val) {
this.judgeAnswer[this.index] = val
if(val) {
let data = this.topic[3]
this.bg_flag = true
data[this.index]["isClick"] = true
var topic3Right = document.getElementById("topic3Right");
topic3Right.style.display = "block";
this.radioFlag = true
}
},
previous() { //上一题
this.index --
switch(this.currentType) {
case 1:
this.change(this.index)
break
case 2:
this.fill(this.index)
break
case 3:
this.judge(this.index)
break
}
},
next() { //下一题
this.index ++
switch(this.currentType) {
case 1:
this.change(this.index)
break
case 2:
this.fill(this.index)
break
case 3:
this.judge(this.index)
break
}
},
mark() { //标记功能
switch(this.currentType) {
case 1:
this.topic[1][this.index]["isMark"] = true //选择题标记
break
case 2:
this.topic[2][this.index]["isMark"] = true //填空题标记
break
case 3:
this.topic[3][this.index]["isMark"] = true //判断题标记
}
},*/
this.commit()
},
commit() { //答案提交计算分数
/* 计算选择题总分 */
let finalScore = 0 //分数
......@@ -527,13 +448,10 @@ export default {
case 4:
right = "D"
}
if(right == this.topic[1][index].rightAnswer) { // 当前选项与正确答案对比
finalScore += this.topic[1][index].score // 计算总分数
if(right == this.reduceAnswer.rightAnswer) { // 当前选项与正确答案对比
finalScore = this.reduceAnswer.score // 计算总分数
}
this.isradio = true
console.log(this.reduceAnswer.rightAnswer) //题的答案
console.log(right,this.topic[1][index].rightAnswer)
}
})
} else if (this.optionValue == "多选题") {
......@@ -543,37 +461,21 @@ export default {
const result = this.checkList.map(number => String.fromCharCode(64 + parseInt(number, 10))).join(",");
if (result == truwAnswer) {
console.log("回答正确")
finalScore = 1
finalScore = this.reduceAnswer.score
}
}else if (this.optionValue=="判断题"){
let pitch = this.judgeAnswer[this.index]
console.log("当前选中的 = "+ pitch)
if (pitch=='1'){
pitch = "T"
}else {
pitch = "F"
}
console.log(pitch)
if (pitch === this.reduceAnswer.answer){
finalScore = this.reduceAnswer.score
}
}
// /**计算判断题总分 */
// // console.log(`this.fillAnswer${this.fillAnswer}`)
// // console.log(this.topic[2][this.index])
// let fillAnswer = this.fillAnswer
// fillAnswer.forEach((element,index) => { //此处index和 this.index数据不一致,注意
// element.forEach((inner) => {
// if(this.topic[2][index].answer.includes(inner)) { //判断填空答案是否与数据库一致
// console.log("正确")
// finalScore += this.topic[2][this.index].score
// }
// })
// });
// /** 计算判断题总分 */
// let topic3Answer = this.judgeAnswer
// topic3Answer.forEach((element,index) => {
// let right = null
// switch(element) {
// case 1:
// right = "T"
// break
// case 2:
// right = "F"
// }
// if(right == this.topic[3][index].answer) { // 当前选项与正确答案对比
// finalScore += this.topic[3][index].score // 计算总分数
// }
// })
console.log(`目前总分${finalScore}`)
if(this.time != 0) {
console.log("交卷")
......@@ -593,21 +495,6 @@ export default {
}).then(res => {
if(res.data.code == 200) {
console.log("关闭当前页面")
// window.open("http://www.xz.cq/#/home","_self")
// http://localhost:8088/#/jumplogin
// this.$router.push("/answer")
// 模拟用户按下 Alt+F4 快捷键,并调用 window.close() 方法来关闭当前窗口
/* const event = new KeyboardEvent('keydown', {
key: 'F4',
code: 'F4',
altKey: true,
});
window.dispatchEvent(event);
window.close();*/
/* const popup = window.open('', '_self');
popup.close();*/
// window.location.href = 'about:blank';
// window.open('/', '_self');
}
}).catch(() => {
console.log("继续答题")
......@@ -635,6 +522,10 @@ export default {
</script>
<style lang="less">
/*放大的图片*/
.el-image-viewer__img{
height: 500px;
}
.submitAnswerClass{
/*background-color: red;*/
margin-top: 15px;
......
......@@ -27,7 +27,7 @@
clearable>
</el-input>
</li>
<li v-if="optionValue == '填空题'">
<!-- <li v-if="optionValue == '填空题'">
<span>所属章节:</span>
<el-input
placeholder="请输入对应章节"
......@@ -35,7 +35,7 @@
class="w150"
clearable>
</el-input>
</li>
</li>-->
<li v-if="optionValue == '判断题'">
<span>所属章节:</span>
<el-input
......@@ -56,7 +56,7 @@
</el-option>
</el-select>
</li>
<li v-if="optionValue == '填空题'">
<!-- <li v-if="optionValue == '填空题'">
<span>难度等级:</span>
<el-select v-model="postFill.level" placeholder="选择难度等级" class="w150">
<el-option
......@@ -66,7 +66,7 @@
:value="item.value">
</el-option>
</el-select>
</li>
</li>-->
<li v-if="optionValue == '判断题'">
<span>难度等级:</span>
<el-select v-model="postJudge.level" placeholder="选择难度等级" class="w150">
......@@ -113,22 +113,21 @@
resize="none"
class="answer">
</el-input>
<!-- <el-upload
<el-upload
class="upload-demo"
action="#"
accept="image/jpg,image/jpeg,image/png"
:auto-upload="false"
:on-change="
(file, fileList) => {
handlePhotoChange(file, fileList);
}
"
:on-change="(file, fileList) => {handlePhotoChange(file, fileList);}"
:on-remove="handleRemove"
:file-list="photoList"
list-type="picture">
<el-button size="small" type="primary">点击上传</el-button>
&lt;!&ndash; <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>&ndash;&gt;
</el-upload>-->
<div>
<el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件</div>
</div>
</el-upload>
</div>
<div class="options">
<ul>
......@@ -182,10 +181,10 @@
<el-button v-else type="primary" @click="editSubmit()">确认修改</el-button>
</div>
</div>
<!-- 填空题部分 -->
<!-- &lt;!&ndash; 填空题部分 &ndash;&gt;
<div class="change fill" v-if="optionValue == '填空题'">
<div class="title">
<el-tag>题目:</el-tag><span>输入题目,形如--从计算机网络系统组成的角度看,计算机网络可以分为()和()。注意需要考生答题部分一定要用括号(英文半角)括起来。</span>
<el-tag>题目:</el-tag><span>输入题目,形如&#45;&#45;从计算机网络系统组成的角度看,计算机网络可以分为()和()。注意需要考生答题部分一定要用括号(英文半角)括起来。</span>
<el-input
type="textarea"
rows="4"
......@@ -213,7 +212,7 @@
<div class="submit">
<el-button type="primary" @click="fillSubmit()">立即添加</el-button>
</div>
</div>
</div>-->
<!-- 判断题 -->
<div class="change judge" v-if="optionValue == '判断题'">
<div class="title">
......@@ -226,6 +225,21 @@
resize="none"
class="answer">
</el-input>
<el-upload
class="upload-demo"
action="#"
accept="image/jpg,image/jpeg,image/png"
:auto-upload="false"
:on-change="(file, fileList) => {handlePhotoChange(file, fileList);}"
:on-remove="handleRemove"
:file-list="photoList"
list-type="picture">
<div>
<el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件</div>
</div>
</el-upload>
</div>
<div class="judgeAnswer">
<el-radio v-model="postJudge.answer" label="T">正确</el-radio>
......@@ -256,7 +270,9 @@
</template>
<script>
export default {
import base64 from '../../utils/Base64'
export default {
data() {
return {
oneSelect:'',
......@@ -373,22 +389,35 @@ export default {
paperId: null,
questionType: null, // 试卷类型 1--选择题 2--填空题 3--判断题
questionId: null,
}
},
};
},
//监听optionValue题目类型的变化 去重置正确选项的值
watch: {
optionValue(newValue) {
this.postChange.rightAnswer=''
this.photoList=[]
}
},
created() {
//编辑的时候从路由上获取参数
if (this.$route.query.row){
const row = JSON.parse(this.$route.query.row);
console.log(row)
this.row = row
console.log(this.row)
//点击编辑时获取照片信息并回显
this.$axios(`/api/answersPhoto/${row.questionid}/${row.tablename}/${row.subject}`).then(res => {
const imgs = res.data.data
console.log(imgs)
if (imgs && imgs.length>0){
imgs.forEach(img=>{
this.photoList.push({
url : img.img
})
})
}
console.log(this.photoList)
})
this.isAddOrEdit = false
if (row.oneOrMore=='1'){ //单选题
this.postChange.answerA = row.answerA
......@@ -474,7 +503,7 @@ export default {
this.postPaper.paperId = paperId
},
changeSubmit() { //选择题题库提交
// console.log(this.textcccc)
let self = this;
this.postChange.oneOrMore = '1'
this.postChange.rightAnswer = this.oneSelect
this.postChange.subject = this.subject
......@@ -504,18 +533,27 @@ export default {
let questionId = res.data.data.questionId
this.postPaper.questionId = questionId
this.postPaper.questionType = 1
console.log(this.postPaper)
var params = new FormData();
params.append('questionId',questionId)
params.append('questionType','1')
params.append('paperId',self.paperId)
self.photoList.forEach(file => {
params.append('files', file.raw);
});
this.$axios({
url: '/api/paperManage',
method: 'Post',
data: {
...this.postPaper
}
data: params
})
this.photoList=[]
})
})
},
//单选多选修改
editSubmit(){
console.log(this.photoList)
let self = this;
this.postChange.oneOrMore = '1'
this.postChange.rightAnswer = this.oneSelect
......@@ -533,7 +571,24 @@ export default {
data: {
...this.postChange
}
}).then(res => { //添加成功显示提示
}).then(res => {
var params = new FormData();
params.append('questionId',self.row.questionid)
params.append('questionType','1')
params.append('paperId',self.row.paperid)
self.photoList.forEach(file => {
if (file.raw){
params.append('files', file.raw);
}else {
params.append('files', base64.dataURLtoFile(file.url));
}
});
console.log(params)
this.$axios({
url: '/api/updateAnswersPhoto',
method: 'Post',
data: params
})
let status = res.data.code
if(status == 200) {
this.$message({
......@@ -546,6 +601,7 @@ export default {
},
//判断修改
editSubmit2(){
let self = this;
this.$axios({ //提交数据到选择题题库表
url: '/api/updateAnswers',
method: 'post',
......@@ -560,7 +616,24 @@ export default {
questionid:this.row.questionid,
type:"判断题"
}
}).then(res => { //添加成功显示提示
}).then(res => {
var params = new FormData();
params.append('questionId',self.row.questionid)
params.append('questionType','3')
params.append('paperId',self.row.paperid)
self.photoList.forEach(file => {
if (file.raw){
params.append('files', file.raw);
}else {
params.append('files', base64.dataURLtoFile(file.url));
}
});
console.log(params)
this.$axios({
url: '/api/updateAnswersPhoto',
method: 'Post',
data: params
})
let status = res.data.code
if(status == 200) {
this.$message({
......@@ -570,7 +643,7 @@ export default {
}
})
},
fillSubmit() { //填空题提交
/* fillSubmit() { //填空题提交
this.postFill.subject = this.subject
this.$axios({
url: '/api/fillQuestion',
......@@ -601,8 +674,11 @@ export default {
})
})
})
},
judgeSubmit() { //判断题提交
},*/
//判断题提交
judgeSubmit() {
let self = this;
this.postJudge.subject = this.subject
this.$axios({
url: '/api/judgeQuestion',
......@@ -621,16 +697,20 @@ export default {
}
}).then(() => {
this.$axios(`/api/judgeQuestionId`).then(res => { //获取当前题目的questionId
var params = new FormData();
let questionId = res.data.data.questionId
this.postPaper.questionId = questionId
this.postPaper.questionType = 3
params.append('questionId',questionId)
params.append('questionType','3')
params.append('paperId',self.paperId)
self.photoList.forEach(file => {
params.append('files', file.raw);
});
this.$axios({
url: '/api/paperManage',
method: 'Post',
data: {
...this.postPaper
}
data: params
})
this.photoList=[]
})
})
}
......@@ -639,6 +719,17 @@ export default {
</script>
<style lang="less" scoped>
//点击上传
.upload-demo{
height: 100px;
display: flex;
}
//图片列表
/deep/.el-upload-list--picture{
display: flex;
margin-left: 10px;
margin-top: -15px;
}
.add {
margin: 0px 40px;
.box {
......
......@@ -98,8 +98,9 @@ export default {
this.getAnswerInfo();
},
methods: {
//查询按钮
//模糊查询按钮
searchList(){
this.pagination.current = 1
this.getAnswerInfo(this.searchForm.question)
},
//清空按钮
......
/**
* Base64字符串转二进制流
* @param {String} dataurl Base64字符串(字符串包含Data URI scheme,例如:data:image/png;base64, )
*/
function dataURLtoBlob(dataurl) {
var arr = dataurl.split(","),
mime = arr[0].match(/:(.*?);/)[1],
bstr = atob(arr[1]),
n = bstr.length,
u8arr = new Uint8Array(n);
while (n--) {
u8arr[n] = bstr.charCodeAt(n);
}
return new Blob([u8arr], {
type: mime,
});
}
/**
* Base64字符串转File文件
* @param {String} dataurl Base64字符串(字符串包含Data URI scheme,例如:data:image/png;base64, )
* @param {String} filename 文件名称
*/
function dataURLtoFile(dataurl, ) {
let arr = dataurl.split(',');
let mime = arr[0].match(/:(.*?);/)[1];
let bstr = atob(arr[1]);
let n = bstr.length;
let u8arr = new Uint8Array(n);
while (n--) {
u8arr[n] = bstr.charCodeAt(n);
}
return new File([u8arr], {
type: mime
});
}
export default {
dataURLtoBlob,
dataURLtoFile
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment