Commit 7da0f74e by 宋珺琪

添加视频按钮、解决添加照片bug

parent 79da9020
......@@ -23,6 +23,13 @@
}}" class="router1">个人统计
</router-link>
</li>
<li>
<router-link
:to="{
path: '/videoList',
}" class="router1">视频
</router-link>
</li>
<li><i class="iconfont icon-arrLeft icon20"></i></li>
</ul>
</div>
......@@ -1039,6 +1046,13 @@ export default {
display: flex;
align-items: center;
}
//视频
#answer .top .item li:nth-child(5){
display: flex;
align-items: center;
justify-content: center;
margin-left: 10px;
}
#answer {
position:relative;
padding-bottom: 30px;
......
......@@ -173,7 +173,7 @@
action="#"
accept="image/jpg,image/jpeg,image/png"
:auto-upload="false"
:on-change="(file, fileList) => {BhandlePhotoChange(file, fileList);}"
:on-change="(Bfile, BfileList) => {BhandlePhotoChange(Bfile, BfileList);}"
:on-remove="BhandleRemove"
:file-list="BphotoList"
:on-exceed="exceedFile"
......@@ -418,10 +418,10 @@
answerB: '',
answerC: '',
answerD: '',
Aimg:'',
Bimg:'',
Cimg:'',
Dimg:'',
aimg:'',
bimg:'',
cimg:'',
dimg:'',
},
postFill: { //填空题提交内容
subject: '', //试卷名称
......@@ -449,15 +449,18 @@
//监听optionValue题目类型的变化 去重置正确选项的值
watch: {
optionValue(newValue) {
this.postChange.rightAnswer=''
this.photoList=[]
this.AphotoList=[]
this.BphotoList=[]
this.CphotoList=[]
this.DphotoList=[]
// this.postChange = {}
// this.oneSelect= ''
// this.moreSelect = ""
if (!this.$route.query.row){
//如果不是编辑再监听执行重置的操作
this.photoList=[]
this.AphotoList=[]
this.BphotoList=[]
this.CphotoList=[]
this.DphotoList=[]
this.postChange = {}
this.oneSelect= ''
this.moreSelect = ""
}
}
},
created() {
......@@ -466,10 +469,6 @@
const row = JSON.parse(this.$route.query.row);
console.log(row)
this.row = row
if(row.aimg){this.AphotoList.push({url:row.aimg})}
if(row.bimg){this.BphotoList.push({url:row.bimg})}
if(row.cimg){this.BphotoList.push({url:row.cimg})}
if(row.dimg){this.BphotoList.push({url:row.dimg})}
//点击编辑时获取照片信息并回显
this.$axios(`/api/answersPhoto/${row.questionid}/${row.tablename}/${row.paperid}`).then(res => {
const imgs = res.data.data
......@@ -514,7 +513,10 @@
this.postJudge.answer = row.rightAnswer
this.postJudge.analysis = row.analysis //解析
}
if(row.aimg){this.AphotoList.push({url:row.aimg})}
if(row.bimg){this.BphotoList.push({url:row.bimg})}
if(row.cimg){this.CphotoList.push({url:row.cimg})}
if(row.dimg){this.DphotoList.push({url:row.dimg})}
}
this.getParams()
},
......@@ -542,11 +544,11 @@
let self = this;
self.DphotoList = fileList
},
//添加照片
handlePhotoChange(file, fileList) {
let self = this;
self.photoList = fileList
},
//移除照片
AhandleRemove(file,fileList) {
let self = this;
self.AphotoList = fileList
......@@ -563,7 +565,6 @@
let self = this;
self.DphotoList = fileList
},
//移除照片
handleRemove(file,fileList) {
let self = this;
self.photoList = fileList
......@@ -606,21 +607,22 @@
this.postPaper.paperId = paperId
},
//选择题题库提交
changeSubmit() {
async changeSubmit() {
await this.getABCDImg()
let self = this;
this.postChange.oneOrMore = '1'
this.postChange.rightAnswer = this.oneSelect
this.postChange.subject = this.subject
this.getABCDImg()
console.log(this.postChange)
if (this.optionValue=='多选题' && this.moreSelect){
this.postChange.rightAnswer = this.moreSelect.join(', ');
this.postChange.oneOrMore = '2'
}
console.log(self.postChange)
this.$axios({ //提交数据到选择题题库表
url: '/api/MultiQuestion',
method: 'post',
data: {...this.postChange}
data: {...self.postChange}
}).then(res => { //添加成功显示提示
let status = res.data.code
if(status == 200) {
......@@ -634,7 +636,6 @@
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')
......@@ -666,52 +667,70 @@
reader.readAsDataURL(blob);
});
},
getABCDImg(){
async getABCDImg(){
let self = this;
if (this.AphotoList[0]){
const file = this.AphotoList[0];
this.processImageFile(file)
.then((imageDataUrl) => {
self.postChange.Aimg = imageDataUrl;
})
.catch((error) => {
console.error(error);
});
if (self.AphotoList[0]){
const file = self.AphotoList[0];
if (file.raw){
await self.processImageFile(file)
.then((imageDataUrl) => {
self.postChange.aimg = imageDataUrl;
})
.catch((error) => {
console.error(error);
});
}else {
self.postChange.aimg = file.url
}
}
if (this.BphotoList[0]){
const file = this.BphotoList[0]; // 获取文件对象
this.processImageFile(file)
.then((imageDataUrl) => {
self.postChange.Bimg = imageDataUrl;
})
.catch((error) => {
console.error(error);
});
if (self.BphotoList[0]){
const file = self.BphotoList[0]; // 获取文件对象
if (file.raw){
await self.processImageFile(file)
.then((imageDataUrl) => {
self.postChange.bimg = imageDataUrl;
})
.catch((error) => {
console.error(error);
});
}else {
self.postChange.bimg = file.url
}
}
if (this.CphotoList[0]){
const file = this.CphotoList[0]; // 获取文件对象
this.processImageFile(file)
.then((imageDataUrl) => {
self.postChange.Cimg = imageDataUrl;
})
.catch((error) => {
console.error(error);
});
if (self.CphotoList[0]){
const file = self.CphotoList[0]; // 获取文件对象
if (file.raw){
await self.processImageFile(file)
.then((imageDataUrl) => {
self.postChange.cimg = imageDataUrl;
})
.catch((error) => {
console.error(error);
});
}else {
self.postChange.cimg = file.url
}
}
if (this.DphotoList[0]){
const file = this.DphotoList[0]; // 获取文件对象
this.processImageFile(file)
.then((imageDataUrl) => {
self.postChange.Dimg = imageDataUrl;
})
.catch((error) => {
console.error(error);
});
if (self.DphotoList[0]){
const file = self.DphotoList[0]; // 获取文件对象
if (file.raw){
await self.processImageFile(file)
.then((imageDataUrl) => {
self.postChange.dimg = imageDataUrl;
})
.catch((error) => {
console.error(error);
});
}else {
self.postChange.dimg = file.url
}
}
},
//单选多选修改
editSubmit(){
console.log(this.photoList)
async editSubmit(){
let self = this;
this.postChange.oneOrMore = '1'
this.postChange.rightAnswer = this.oneSelect
......@@ -724,7 +743,7 @@
this.postChange.subject = this.row.subject
this.postChange.questionid = this.row.questionid
this.postChange.tablename = this.row.tablename
this.getABCDImg()
await this.getABCDImg()
this.$axios({ //提交数据到选择题题库表
url: '/api/updateAnswers',
method: 'post',
......@@ -732,7 +751,6 @@
...this.postChange
}
}).then(res => {
console.log(self.row)
var params = new FormData();
params.append('questionId',self.row.questionid)
params.append('questionType','1')
......@@ -744,7 +762,6 @@
params.append('files', base64.dataURLtoFile(file.url));
}
});
console.log(params)
this.$axios({
url: '/api/updateAnswersPhoto',
method: 'Post',
......@@ -789,7 +806,6 @@
params.append('files', base64.dataURLtoFile(file.url));
}
});
console.log(params)
this.$axios({
url: '/api/updateAnswersPhoto',
method: 'Post',
......
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