|
@@ -3,7 +3,7 @@
|
|
|
<div :id="ids + 'btn'" class="base-editor-tools" v-show="isShowTools">
|
|
|
<!-- <div :id="ids + 'btn'" class="base-editor-tools" v-show="isShowTools" @mouseenter="isShowTools = true" @mouseleave="isShowTools = false"> -->
|
|
|
<span class="select-model" @click="onSelectModal" v-if="type !== '0'">编辑</span>
|
|
|
- <span class="select-model btn-delete" @click="onDeleteBlock">删除</span>
|
|
|
+ <span class="select-model btn-delete" @click="onDeleteBlock" v-if="!isAutoCreate">删除</span>
|
|
|
</div>
|
|
|
<p class="margin-block"></p>
|
|
|
<!-- <div @mouseenter="isShowTools = true" @mouseleave="isShowTools = false"> -->
|
|
@@ -80,6 +80,7 @@
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
+ preTop:0,
|
|
|
fixArr:[],
|
|
|
pArr:[],
|
|
|
isShowTools:false,
|
|
@@ -92,7 +93,8 @@
|
|
|
completeItems: [],
|
|
|
isNewPage: false,
|
|
|
pageCount: 1,
|
|
|
- curEditorSetting: null
|
|
|
+ curEditorSetting: null,
|
|
|
+ curItemId:null
|
|
|
};
|
|
|
},
|
|
|
methods: {
|
|
@@ -103,6 +105,9 @@
|
|
|
|
|
|
/* 删除当前富文本块 */
|
|
|
onDeleteBlock() {
|
|
|
+ console.log(this.curItemId)
|
|
|
+ this.$store.commit('deleteItem',this.curItemId)
|
|
|
+ this.$parent.subjectiveItems.splice(this.$parent.subjectiveItems.map(i => i.id).indexOf(this.curItemId),1)
|
|
|
document.getElementById(this.ids).remove()
|
|
|
document.getElementById(this.ids + 'btn').remove()
|
|
|
this.myEditor.destroy()
|
|
@@ -276,14 +281,17 @@
|
|
|
if (!scrollDom) return
|
|
|
let editorDom = this.myEditor.$textElem.elems[0]
|
|
|
let scrollDis = scrollDom.getPosition().scrollTop
|
|
|
+ // let scrollDis = +localStorage.getItem('scrollDis') || scrollDom.getPosition().scrollTop
|
|
|
let allItemIds = this.$store.state.answerSheet.paperItem.item.map(i => i.id)
|
|
|
let subjectiveItem = items[0];
|
|
|
let itemOrder = allItemIds.indexOf(subjectiveItem.id) + 1;
|
|
|
+ this.curItemId = subjectiveItem.id
|
|
|
let addStr = '<p>' + itemOrder + "(" + (subjectiveItem.score + "分)") + '</p>'; // 渲染题号
|
|
|
let defaultBrCounts = 1; // 问答题默认回答区域空行数量
|
|
|
let brHtml = new Array(defaultBrCounts).fill("<p><br></p>").join("");
|
|
|
this.myEditor.txt.html('<span></span>')
|
|
|
let curSetting = this.hasEditorSetting(this.ids)
|
|
|
+ // 如果vuex有保存 之前的文本内容 则渲染 否则按照默认只显示题号
|
|
|
if (curSetting && curSetting.content) {
|
|
|
this.myEditor.txt.append(curSetting.content);
|
|
|
}else{
|
|
@@ -295,19 +303,18 @@
|
|
|
let isNewPage = this.$store.state.answerSheet.isNewPage;
|
|
|
let lastBottomGap = 20;
|
|
|
let rectTop = editorDom.getBoundingClientRect().top
|
|
|
- let Y = scrollDis < 20 ? rectTop + scrollDis - 90 : rectTop + scrollDis;
|
|
|
+ let Y = rectTop + scrollDis - 90;
|
|
|
let paperH = PAPER_H;
|
|
|
let curEditorY = Y > paperH ? +((Y % paperH).toFixed(4)) : Y;
|
|
|
let curEditorH = editorDom.clientHeight; // 默认200px
|
|
|
- console.log(itemOrder, 'getBoundingClientRect', rectTop);
|
|
|
- console.log(itemOrder, 'getBoundingClientRect222', editorDom.getBoundingClientRect());
|
|
|
+ console.log(itemOrder, 'rectTop', rectTop);
|
|
|
console.log(itemOrder, 'scrollDis', scrollDis);
|
|
|
console.log(itemOrder, '当前Y', Y);
|
|
|
let leftHeight = paperH - curEditorY - lastBottomGap - SVG_BORDER_MB;
|
|
|
console.log(itemOrder, '高度', curEditorH)
|
|
|
console.log(itemOrder, 'LEFT高度', leftHeight)
|
|
|
let fixHeight = curEditorH - leftHeight + 20
|
|
|
- // console.log(itemOrder, '需要fix的高度', fixHeight)
|
|
|
+ console.log(itemOrder, '需要fix的高度', fixHeight)
|
|
|
// 如果 渲染当前富文本的时候 需要渲染的高度超过当前页的剩余高度 则需要进行加页处理
|
|
|
if (curEditorY + curEditorH + lastBottomGap + SVG_BORDER_MB > PAPER_H) {
|
|
|
// console.log(itemOrder, Y , curEditorY , curEditorH , '超出了')
|
|
@@ -457,6 +464,8 @@
|
|
|
function mouseup() {
|
|
|
document.removeEventListener("mousemove", mousemove);
|
|
|
document.removeEventListener("mouseup", mouseup);
|
|
|
+ let editorDom = that.myEditor.$textElem.elems[0]
|
|
|
+ that.preTop = editorDom.getBoundingClientRect().top
|
|
|
// 如果是补充区域 则需要把高度计算到主区域 进行重新渲染
|
|
|
if(curId.includes('fix')){
|
|
|
let mainEditorId = curId.split('fix')[0]
|
|
@@ -481,6 +490,9 @@
|
|
|
content:editor.txt.html()
|
|
|
})
|
|
|
}
|
|
|
+ let scrollDom = that.$parent.$parent.$parent.$parent.$parent.$refs["evScroll"]
|
|
|
+ localStorage.setItem('scrollDis',scrollDom.getPosition().scrollTop)
|
|
|
+
|
|
|
that.$EventBus.$emit('doRefresh')
|
|
|
}
|
|
|
// 将鼠标事件绑定到 document 上
|
|
@@ -692,6 +704,10 @@
|
|
|
return this.$store.state.answerSheet.editorInfos[ids]
|
|
|
}
|
|
|
},
|
|
|
+ // 是否为根据试卷自动生成的答题卡
|
|
|
+ isAutoCreate(){
|
|
|
+ return this.$store.state.answerSheet.isAutoCreate
|
|
|
+ }
|
|
|
},
|
|
|
watch: {
|
|
|
items: {
|