|
|
|
@ -40,9 +40,6 @@ |
|
|
|
|
<span class="index">{{index+1}}.</span> |
|
|
|
|
<div v-html="item.questionStem"></div> |
|
|
|
|
</div> |
|
|
|
|
<div class="options"> |
|
|
|
|
<p v-for="(option,i) in item.options" :key="i">{{i}}.{{item.options[i]}}</p> |
|
|
|
|
</div> |
|
|
|
|
</li> |
|
|
|
|
</ul> |
|
|
|
|
</li> |
|
|
|
@ -68,9 +65,6 @@ |
|
|
|
|
<span class="index">{{index+1}}.</span> |
|
|
|
|
<div v-html="item.questionStem"></div> |
|
|
|
|
</div> |
|
|
|
|
<div class="options"> |
|
|
|
|
<p v-for="(option,i) in item.options" :key="i">{{i}}.{{item.options[i]}}</p> |
|
|
|
|
</div> |
|
|
|
|
</li> |
|
|
|
|
</ul> |
|
|
|
|
</li> |
|
|
|
@ -175,9 +169,9 @@ function getUrlBase64(url, ext, callback) { |
|
|
|
|
img.crossOrigin = 'Anonymous'; |
|
|
|
|
img.src = url; |
|
|
|
|
img.onload = function () { |
|
|
|
|
canvas.height = 60; //指定画板的高度,自定义 |
|
|
|
|
canvas.width = 85; //指定画板的宽度,自定义 |
|
|
|
|
ctx.drawImage(img, 0, 0, 60, 85); //参数可自定义 |
|
|
|
|
canvas.height = 300; //指定画板的高度,自定义 |
|
|
|
|
canvas.width = 300; //指定画板的宽度,自定义 |
|
|
|
|
ctx.drawImage(img, 0, 0, 300, 300); //参数可自定义 |
|
|
|
|
var dataURL = canvas.toDataURL("image/" + ext); |
|
|
|
|
callback.call(this, dataURL); //回掉函数获取Base64编码 |
|
|
|
|
canvas = null; |
|
|
|
@ -327,8 +321,7 @@ export default { |
|
|
|
|
this.loading = true |
|
|
|
|
this.exportVisible = true |
|
|
|
|
this.paperName = row.name |
|
|
|
|
this.$post(`${this.api.previewtestPaper}?id=${row.id}`) |
|
|
|
|
.then(res => { |
|
|
|
|
this.$post(`${this.api.previewtestPaper}?id=${row.id}`).then(res => { |
|
|
|
|
let list = res.data |
|
|
|
|
let reg = /<img src=".*?">/gi |
|
|
|
|
let index = 0 |
|
|
|
@ -342,9 +335,10 @@ export default { |
|
|
|
|
list[i].map(n => { |
|
|
|
|
let src = reg.exec(n.questionStem) |
|
|
|
|
if(src){ |
|
|
|
|
console.log(11,src,src[0],reg.lastIndex) |
|
|
|
|
src = src[0].replace('<img src="','').replace('">','') |
|
|
|
|
getUrlBase64(src, 'jpg', function (base64) { |
|
|
|
|
n.questionStem = n.questionStem.replace(reg,`<img src="${base64}">`) |
|
|
|
|
n.questionStem = n.questionStem.replace(reg,`<img width="300" src="${base64}">`) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
@ -355,7 +349,8 @@ export default { |
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
setTimeout(() => { |
|
|
|
|
html2Canvas(document.querySelector('#pdfDom'), { |
|
|
|
|
allowTaint: true |
|
|
|
|
allowTaint: true, |
|
|
|
|
tainttest : true, |
|
|
|
|
}).then(canvas => { |
|
|
|
|
let contentWidth = canvas.width |
|
|
|
|
let contentHeight = canvas.height |
|
|
|
|