diff --git a/lib/zin/wg/dynamic/js/v1.js b/lib/zin/wg/dynamic/js/v1.js index 2f63713c12..8956086908 100644 --- a/lib/zin/wg/dynamic/js/v1.js +++ b/lib/zin/wg/dynamic/js/v1.js @@ -2,6 +2,7 @@ window.showMore = function(e) { let $this = $(e.target); if($this.attr('id') != 'showMoreDynamic') $this = $this.closest('#showMoreDynamic'); + $this.find('i').removeClass('icon-chevron-down').addClass('spin icon-refresh'); let $appendTo = $this.closest('li').prev().find('ul'); let lastActionID = $this.data('lastid'); @@ -11,6 +12,7 @@ window.showMore = function(e) let hasMore = $appendTo.children('#hasMore').html() == '1'; $this.attr('data-lastid', $appendTo.children('#lastid').html()); + $this.find('i').addClass('icon-chevron-down').removeClass('spin icon-refresh'); if(!hasMore) $this.closest('li').remove(); $appendTo.children('style').remove(); diff --git a/module/action/control.php b/module/action/control.php index dfea54c04e..b8de34540a 100755 --- a/module/action/control.php +++ b/module/action/control.php @@ -414,9 +414,10 @@ class action extends control public function ajaxGetMoreActions(int $lastActionID) { $actions = $this->action->getMoreActions($lastActionID); + $lastAction = end($actions); $this->view->actions = $actions; - $this->view->hasMore = $this->action->hasMoreAction(end($actions)); + $this->view->hasMore = $lastAction ? $this->action->hasMoreAction($lastAction) : false; $this->view->users = $this->loadModel('user')->getPairs('noletter'); $this->display(); } diff --git a/module/action/model.php b/module/action/model.php index 4e263b324d..5d5d0dbd9c 100755 --- a/module/action/model.php +++ b/module/action/model.php @@ -1747,17 +1747,14 @@ class actionModel extends model if(empty($date)) return false; $condition = $this->session->actionQueryCondition; - /* 移除搜索中的时间筛选条件。 */ - /* Remove time filter from search. */ - $condition = preg_replace("/AND +`?date`? +(<|>|<=|>=) +'\d{4}\-\d{2}\-\d{2}'/", '', $condition); - $count = $this->dao->select('COUNT(1) AS count') - ->from(TABLE_ACTION)->alias('action') + $actions = $this->dao->select('action.id')->from(TABLE_ACTION)->alias('action') ->leftJoin(TABLE_ACTIONPRODUCT)->alias('t2')->on('action.id=t2.action') ->where($condition) ->andWhere('date' . ($direction == 'next' ? '<' : '>') . "'{$date}'") - ->fetch('count'); + ->limit(1) + ->fetchAll(); - return $count > 0; + return count($actions) > 0; } /** @@ -2471,14 +2468,15 @@ class actionModel extends model */ public function hasMoreAction(object $lastAction): bool { - $hasCount = $this->dao->select('count(*) AS count')->from(TABLE_ACTION)->alias('action') + $actions = $this->dao->select('action.id')->from(TABLE_ACTION)->alias('action') ->leftJoin(TABLE_ACTIONPRODUCT)->alias('t2')->on('action.id=t2.action') ->where($this->session->actionQueryCondition) ->andWhere("`date`")->like(substr($lastAction->originalDate, 0, 10) . " %") ->andWhere('action.id < ' . $lastAction->id) ->orderBy($this->session->actionOrderBy) - ->fetch('count'); - return $hasCount > 0; + ->limit(1) + ->fetchAll(); + return count($actions) > 0; } /** @@ -2490,7 +2488,7 @@ class actionModel extends model * @access public * @return array */ - public function getMoreActions(int $lastActionID, int $limit = 100): array + public function getMoreActions(int $lastActionID, int $limit = 50): array { $lastAction = $this->dao->select('*')->from(TABLE_ACTION)->where('id')->eq($lastActionID)->fetch(); $actions = $this->dao->select('action.*')->from(TABLE_ACTION)->alias('action') diff --git a/module/company/control.php b/module/company/control.php index ee868d7da9..e5bf486196 100755 --- a/module/company/control.php +++ b/module/company/control.php @@ -176,8 +176,7 @@ class company extends control /* 根据日期补充动态数据。*/ /* Supplement action by date.*/ $dateGroups = $this->action->buildDateGroup($actions, $direction, $orderBy); - - if(empty($recTotal)) $recTotal = !(empty($date) && $browseType == 'all') ? array_sum(array_map('count', $dateGroups)) : $this->action->getDynamicCount(); + $recTotal = $this->action->getDynamicCount(); /* Assign.*/ $this->view->title = $this->lang->company->common . $this->lang->hyphen . $this->lang->company->dynamic;