diff --git a/module/block/config.php b/module/block/config.php index 59df2e3825..516595e120 100644 --- a/module/block/config.php +++ b/module/block/config.php @@ -309,3 +309,5 @@ $config->block->size['product']['release'] = array('2' => '6', '1' => '6'); $config->block->size['project']['overview'] = array('1' => '3'); $config->block->size['execution']['overview'] = array('1' => '3'); + +$config->block->size['qa']['case'] = array('2' => '6', '1' => '6'); diff --git a/module/block/control.php b/module/block/control.php index a80e5c6e76..cc6f92f572 100755 --- a/module/block/control.php +++ b/module/block/control.php @@ -43,8 +43,12 @@ class block extends control $formData->account = $this->app->user->account; $formData->vision = $this->config->vision; $formData->params = json_encode($formData->params); + + if(empty($formData->width)) $formData->width = 1; if(!empty($this->config->block->size[$formData->module][$formData->code][$formData->width])) $formData->height = $this->config->block->size[$formData->module][$formData->code][$formData->width]; - $formData->top = $this->block->getNewTop($dashboard); + if(empty($formData->height)) $formData->height = 3; + $formData->left = $formData->width == 2 ? 0 : 2; + $formData->top = $this->block->computeBlockTop($formData); $this->block->create($formData); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); diff --git a/module/block/model.php b/module/block/model.php index 683494373f..28e29d040a 100644 --- a/module/block/model.php +++ b/module/block/model.php @@ -394,14 +394,20 @@ class blockModel extends model } /** - * Get new block top. + * 计算区块距离顶部的高度。 + * compute block top height. * - * @param string $dashboard + * @param object $block * @access public * @return int */ - public function getNewTop($dashboard): int + public function computeBlockTop(object $block): int { - return $this->dao->select('max(`top` + `height`) AS top')->from(TABLE_BLOCK)->where('dashboard')->eq($dashboard)->andWhere('hidden')->eq('0')->fetch('top'); + return $this->dao->select('max(`top` + `height`) AS top')->from(TABLE_BLOCK) + ->where('dashboard')->eq($block->dashboard) + ->andWhere('width')->eq($block->width) + ->andWhere('vision')->eq($block->vision) + ->andWhere('hidden')->eq('0') + ->fetch('top'); } } diff --git a/module/block/tao.php b/module/block/tao.php index d11d01d5c7..c90c0180cc 100644 --- a/module/block/tao.php +++ b/module/block/tao.php @@ -18,6 +18,7 @@ class blockTao extends blockModel ->andWhere('dashboard')->eq($dashboard) ->andWhere('hidden')->eq($hidden) ->andWhere('vision')->eq($this->config->vision) + ->orderBy('width_desc,top_asc') ->fetchAll(); } diff --git a/module/block/zen.php b/module/block/zen.php index b48dc882e8..e2ce32e4e8 100644 --- a/module/block/zen.php +++ b/module/block/zen.php @@ -176,6 +176,23 @@ class blockZen extends block /* 生成更多链接。 */ $this->createMoreLink($block, $projectID); } + + $blocks = array_values($blocks); + $height = array(1 => 0, 2 => 0); + foreach($blocks as $block) + { + if($block->width == 3) + { + $block->top = max($height[0], $height[1]); + $height[0] += $block->height; + $height[1] += $block->height; + } + else + { + $block->top = $height[$block->width]; + $height[$block->width] += $block->height; + } + } return $blocks; }