|
@@ -146,7 +146,8 @@ pageManager.prototype._mergeData = function () {
|
|
|
rectNo: -1,
|
|
|
isSubject: true,
|
|
|
cdelete: 0,
|
|
|
- minHeight: -1
|
|
|
+ minHeight: -1,
|
|
|
+ content: null
|
|
|
};
|
|
|
for (let index in data) {
|
|
|
item = data[index];
|
|
@@ -225,62 +226,57 @@ pageManager.prototype._itemToPage = function (item) {
|
|
|
let domOption = JSON.parse(JSON.stringify(item));
|
|
|
if ( item.height > this.currentPage.gap) {
|
|
|
let gap = this.currentPage.gap;
|
|
|
- if (gap > this.minHeight) {
|
|
|
+ if (gap > 0) {
|
|
|
let holdHeight = gap;
|
|
|
- // item中减去已经放进页面的高度,继续递归
|
|
|
- // 循环item的questions,看看能容纳几个question,出去已经容纳的question
|
|
|
+ //1、 cHoldQuestions 当前页可以容纳的小题数组
|
|
|
+ //2、 questionsTemp 当前页容纳不了的小题数组
|
|
|
let cHoldQuestions = [];
|
|
|
- let tempCanHolderItem = {};
|
|
|
let questionsTemp = [];
|
|
|
+
|
|
|
+ // 下一页的高度
|
|
|
+ let nextBoxHeight = 0;
|
|
|
item.questions.filter(domItem => {
|
|
|
-
|
|
|
gap -= domItem.minHeight;
|
|
|
if (gap >= 0) {
|
|
|
cHoldQuestions.push(domItem);
|
|
|
- return false;
|
|
|
} else {
|
|
|
- gap = Math.abs(gap);
|
|
|
- tempCanHolderItem = JSON.parse(JSON.stringify(domItem))
|
|
|
- domItem.minHeight = gap;
|
|
|
- tempCanHolderItem.minHeight -= gap;
|
|
|
- // 如果该页剩余小于最小高度,则跳到下一页
|
|
|
- if (tempCanHolderItem.minHeight >= this.minHeight) {
|
|
|
- cHoldQuestions.push(tempCanHolderItem);
|
|
|
- }
|
|
|
- // 如果该小问在下一页高度小于最小高度,则舍去
|
|
|
- if (domItem.minHeight >= this.minHeight) {
|
|
|
- questionsTemp.push(domItem);
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- return false;
|
|
|
- }
|
|
|
+ // 如果该页容纳不了该小问,则该小问在下一页显示
|
|
|
+ nextBoxHeight += domItem.minHeight;
|
|
|
+ questionsTemp.push(domItem);
|
|
|
}
|
|
|
})
|
|
|
item.questions = questionsTemp;
|
|
|
- item.height -= holdHeight;
|
|
|
-
|
|
|
domOption.height = holdHeight;
|
|
|
domOption.questions = cHoldQuestions;
|
|
|
- if (item.height > this.minHeight) {
|
|
|
- domOption.isDrag = false;
|
|
|
- } else {
|
|
|
- domOption.isDrag = true;
|
|
|
+ if (domOption.questions.length > 0) {
|
|
|
+ item.height -= domOption.height;
|
|
|
+ item.height < nextBoxHeight && (item.height = nextBoxHeight);
|
|
|
+ this.currentPage.addDom(domOption);
|
|
|
}
|
|
|
- // 如果有最小高度,则说明是刷新状态
|
|
|
- if(item.minHeight) {
|
|
|
- item.minHeight -= domOption.height;
|
|
|
- item.minHeight = item.minHeight <= 0 ? 0 : item.minHeight;
|
|
|
- }
|
|
|
- this.currentPage.addDom(domOption);
|
|
|
- this.currentPage.gap = 0;
|
|
|
- this.currentPage = null;
|
|
|
- if (item.height > this.minHeight) {
|
|
|
+ if(item.questions.length > 0 ) {
|
|
|
+ if (item.height > this.minHeight) {
|
|
|
+ domOption.isDrag = false;
|
|
|
+ } else {
|
|
|
+ domOption.isDrag = true;
|
|
|
+ }
|
|
|
// 如果有最小高度,则说明是刷新状态
|
|
|
if(item.minHeight) {
|
|
|
- item.minHeight <= 0 && (item.cdelete = 1);
|
|
|
+ item.minHeight -= domOption.height;
|
|
|
+ item.minHeight = item.minHeight <= 0 ? 0 : item.minHeight;
|
|
|
+ }
|
|
|
+ this.currentPage.gap = 0;
|
|
|
+ this.currentPage = null;
|
|
|
+ if (item.height > this.minHeight) {
|
|
|
+ // 如果有最小高度,则说明是刷新状态
|
|
|
+ if(item.minHeight) {
|
|
|
+ item.minHeight <= 0 && (item.cdelete = 1);
|
|
|
+ }
|
|
|
+ this._itemToPage(item);
|
|
|
}
|
|
|
- this._itemToPage(item);
|
|
|
+ } else {
|
|
|
+ domOption.isDrag = true;
|
|
|
}
|
|
|
+
|
|
|
} else {
|
|
|
this.currentPage.gap = 0;
|
|
|
this.currentPage = null;
|
|
@@ -339,7 +335,9 @@ pageManager.prototype._refreshPage = function () {
|
|
|
isSubject: doms[j].isSubject,
|
|
|
questions: doms[j].questions,
|
|
|
rectNo: doms[j].rectNo,
|
|
|
- minHeight: doms[j].minHeight
|
|
|
+ minHeight: doms[j].minHeight,
|
|
|
+ content: doms[j].content
|
|
|
+
|
|
|
};
|
|
|
if(parseInt(item.rectNo) === nowRectNo) {
|
|
|
data[(length-1)].questions.push.apply(data[(length-1)].questions, item.questions);
|