正在显示
3 个修改的文件
包含
15 行增加
和
21 行删除
@@ -8,35 +8,28 @@ | @@ -8,35 +8,28 @@ | ||
8 | $this->relationSearch = {%relationSearch%}; | 8 | $this->relationSearch = {%relationSearch%}; |
9 | //设置过滤方法 | 9 | //设置过滤方法 |
10 | $this->request->filter(['strip_tags', 'trim']); | 10 | $this->request->filter(['strip_tags', 'trim']); |
11 | - if ($this->request->isAjax()) | ||
12 | - { | 11 | + if ($this->request->isAjax()) { |
13 | //如果发送的来源是Selectpage,则转发到Selectpage | 12 | //如果发送的来源是Selectpage,则转发到Selectpage |
14 | - if ($this->request->request('keyField')) | ||
15 | - { | 13 | + if ($this->request->request('keyField')) { |
16 | return $this->selectpage(); | 14 | return $this->selectpage(); |
17 | } | 15 | } |
18 | list($where, $sort, $order, $offset, $limit) = $this->buildparams(); | 16 | list($where, $sort, $order, $offset, $limit) = $this->buildparams(); |
19 | - $total = $this->model | ||
20 | - {%relationWithList%} | ||
21 | - ->where($where) | ||
22 | - ->order($sort, $order) | ||
23 | - ->count(); | ||
24 | 17 | ||
25 | $list = $this->model | 18 | $list = $this->model |
26 | {%relationWithList%} | 19 | {%relationWithList%} |
27 | ->where($where) | 20 | ->where($where) |
28 | ->order($sort, $order) | 21 | ->order($sort, $order) |
29 | ->limit($offset, $limit) | 22 | ->limit($offset, $limit) |
30 | - ->select(); | 23 | + ->paginate(); |
31 | 24 | ||
32 | foreach ($list as $row) { | 25 | foreach ($list as $row) { |
33 | {%visibleFieldList%} | 26 | {%visibleFieldList%} |
34 | {%relationVisibleFieldList%} | 27 | {%relationVisibleFieldList%} |
35 | } | 28 | } |
36 | - $list = collection($list)->toArray(); | ||
37 | - $result = array("total" => $total, "rows" => $list); | 29 | + |
30 | + $result = array("total" => $list->total(), "rows" => $list->items()); | ||
38 | 31 | ||
39 | return json($result); | 32 | return json($result); |
40 | } | 33 | } |
41 | return $this->view->fetch(); | 34 | return $this->view->fetch(); |
42 | - } | ||
35 | + } |
@@ -50,19 +50,14 @@ trait Backend | @@ -50,19 +50,14 @@ trait Backend | ||
50 | return $this->selectpage(); | 50 | return $this->selectpage(); |
51 | } | 51 | } |
52 | list($where, $sort, $order, $offset, $limit) = $this->buildparams(); | 52 | list($where, $sort, $order, $offset, $limit) = $this->buildparams(); |
53 | - $total = $this->model | ||
54 | - ->where($where) | ||
55 | - ->order($sort, $order) | ||
56 | - ->count(); | ||
57 | 53 | ||
58 | $list = $this->model | 54 | $list = $this->model |
59 | ->where($where) | 55 | ->where($where) |
60 | ->order($sort, $order) | 56 | ->order($sort, $order) |
61 | ->limit($offset, $limit) | 57 | ->limit($offset, $limit) |
62 | - ->select(); | 58 | + ->paginate(); |
63 | 59 | ||
64 | - $list = collection($list)->toArray(); | ||
65 | - $result = array("total" => $total, "rows" => $list); | 60 | + $result = array("total" => $list->total(), "rows" => $list->items()); |
66 | 61 | ||
67 | return json($result); | 62 | return json($result); |
68 | } | 63 | } |
@@ -75,7 +70,7 @@ trait Backend | @@ -75,7 +70,7 @@ trait Backend | ||
75 | public function recyclebin() | 70 | public function recyclebin() |
76 | { | 71 | { |
77 | //设置过滤方法 | 72 | //设置过滤方法 |
78 | - $this->request->filter(['strip_tags']); | 73 | + $this->request->filter(['strip_tags', 'trim']); |
79 | if ($this->request->isAjax()) { | 74 | if ($this->request->isAjax()) { |
80 | list($where, $sort, $order, $offset, $limit) = $this->buildparams(); | 75 | list($where, $sort, $order, $offset, $limit) = $this->buildparams(); |
81 | $total = $this->model | 76 | $total = $this->model |
@@ -377,6 +377,12 @@ class Backend extends Controller | @@ -377,6 +377,12 @@ class Backend extends Controller | ||
377 | $sym = $sym == 'RANGE' ? '>=' : '<'; | 377 | $sym = $sym == 'RANGE' ? '>=' : '<'; |
378 | $arr = $arr[0]; | 378 | $arr = $arr[0]; |
379 | } | 379 | } |
380 | + $tableArr = explode('.', $k); | ||
381 | + if (count($tableArr) > 1) { | ||
382 | + //修复关联模型下时间无法搜索的BUG | ||
383 | + $relation = Loader::parseName($tableArr[0], 1, false); | ||
384 | + $this->model->alias([$this->model->$relation()->getTable() => $tableArr[0]]); | ||
385 | + } | ||
380 | $where[] = [$k, str_replace('RANGE', 'BETWEEN', $sym) . ' time', $arr]; | 386 | $where[] = [$k, str_replace('RANGE', 'BETWEEN', $sym) . ' time', $arr]; |
381 | break; | 387 | break; |
382 | case 'NULL': | 388 | case 'NULL': |
-
请 注册 或 登录 后发表评论