sxd hace 6 años
padre
commit
f6b77aa29e
Se han modificado 3 ficheros con 21 adiciones y 14 borrados
  1. 18 12
      src/js/main2.js
  2. 0 1
      src/js/yzDom.js
  3. 3 1
      src/js/yzQuestion.js

+ 18 - 12
src/js/main2.js

@@ -146,8 +146,7 @@ pageManager.prototype._mergeData = function () {
     rectNo: -1,
     isSubject: true,
     cdelete: 0,
-    minHeight: -1,
-    content: null
+    minHeight: -1
   };
   for (let index in data) {
     item = data[index];
@@ -246,17 +245,19 @@ pageManager.prototype._itemToPage = function (item) {
         item.questions = questionsTemp;
         domOption.height = holdHeight;
         domOption.questions = cHoldQuestions;
-        if (domOption.questions.length > 0) {
-          item.height -= domOption.height;
-          item.height < nextBoxHeight && (item.height = nextBoxHeight);
-          this.currentPage.addDom(domOption);
-        }
-
+        
+        
         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;
@@ -266,10 +267,14 @@ pageManager.prototype._itemToPage = function (item) {
         this.currentPage = null;
         if (item.height > this.minHeight) {
           // 如果有最小高度,则说明是刷新状态
-          if(item.minHeight) {
-            item.minHeight <= 0 && (item.cdelete = 1);
+          if (item.questions.length < 1) {
+            let lastQuestion = JSON.parse(JSON.stringify( domOption.questions[domOption.questions.length - 1] ));
+            lastQuestion.minHeight = item.height;
+            lastQuestion.isSubQuestion = true;
+            item.questions.push(lastQuestion);
           }
 
+          item.minHeight <= 0 ? item.cdelete = 1 : item.cdelete = 0;
           this._itemToPage(item);
         }
     } else {
@@ -333,10 +338,11 @@ pageManager.prototype._refreshPage = function () {
         questions: doms[j].questions,
         rectNo: doms[j].rectNo,
         minHeight: doms[j].minHeight,
-        content: doms[j].content
+        content: doms[j].content,
+        cdelete: 0
       };
       if(parseInt(item.rectNo) === nowRectNo) {
-        data[(length-1)].questions.push.apply(data[(length-1)].questions, item.questions);
+        !item.questions[0].isSubQuestion && data[(length-1)].questions.push.apply(data[(length-1)].questions, item.questions);
         data[(length-1)].height += item.height;
       } else {
         nowRectNo = parseInt(item.rectNo);

+ 0 - 1
src/js/yzDom.js

@@ -12,7 +12,6 @@ var yzDom = function(cfg) {
   this.isDrag = cfg.isDrag;
   this.rowDetail = cfg.rowDetail;
   this.isSubject = cfg.isSubject;
-  this.content = cfg.content || null;
   this.questionsDom = [];
 
  // 该dom第几个question 

+ 3 - 1
src/js/yzQuestion.js

@@ -16,6 +16,8 @@ let yzQuestion = function (cfg) {
   this.title = cfg.title || '';
   this.inDetail = cfg.inDetail;
   this.isSubject = cfg.isSubject;
+  // 是否是跨栏添加的小问
+  this.isSubQuestion = cfg.isSubQuestion || false;
   this.blockindex = parseInt(cfg.blockindex);
   this.blocknum = parseInt(cfg.blocknum);
 
@@ -105,7 +107,7 @@ yzQuestion.prototype.renderToDom = function () {
   this.vdom.css({
     minHeight: this.minHeight
   })
-  this._renderTitleDom();
+  !this.isSubQuestion && this._renderTitleDom();
   // 如果是客观题
   if (!this.isSubject) {
     let width = 100/this.allblock + '%';