|
@@ -30,6 +30,7 @@ const mutations = {
|
|
|
state.pages = pages;
|
|
|
},
|
|
|
setTopicNos(state, topicNos) {
|
|
|
+ topicNos.sort((a, b) => a - b);
|
|
|
state.topicNos = topicNos;
|
|
|
},
|
|
|
setCardConfig(state, cardConfig) {
|
|
@@ -191,6 +192,12 @@ const actions = {
|
|
|
state.pages
|
|
|
);
|
|
|
if (positionInfos.length) {
|
|
|
+ // 缓存已编辑的小题高度信息。
|
|
|
+ const elementHeights = positionInfos.map(pos => {
|
|
|
+ return state.pages[pos._pageNo].columns[pos._columnNo].elements[
|
|
|
+ pos._elementNo
|
|
|
+ ].h;
|
|
|
+ });
|
|
|
// 删除所有解答题
|
|
|
positionInfos.reverse().forEach(pos => {
|
|
|
const elems =
|
|
@@ -201,6 +208,7 @@ const actions = {
|
|
|
const newElements = createFunc[element.type](element);
|
|
|
const pos = positionInfos.pop();
|
|
|
newElements.forEach((newElement, index) => {
|
|
|
+ newElement.h = elementHeights[index] || newElement.h;
|
|
|
state.pages[pos._pageNo].columns[pos._columnNo].elements.splice(
|
|
|
pos._elementNo + index,
|
|
|
0,
|
|
@@ -334,7 +342,10 @@ const actions = {
|
|
|
if (elementDom) {
|
|
|
element.h = elementDom.offsetHeight;
|
|
|
element.w = elementDom.offsetWidth;
|
|
|
+ // 解答题小题与其他题有些区别。
|
|
|
+ // 其他题都是通过内部子元素自动撑高元件,而解答题则需要手动设置高度。
|
|
|
element.isCovered =
|
|
|
+ element.type !== "EXPLAIN_CHILDREN" &&
|
|
|
elementDom.offsetHeight < elementDom.firstChild.offsetHeight;
|
|
|
}
|
|
|
// 过滤掉所有topic-head元素,这个元素是动态加的,页面重排时可能会添加重复元件。
|