作者 Karson

优化会员列表显示

优化个人资料列表显示
优化基类模型
@@ -24,10 +24,10 @@ class Profile extends Backend @@ -24,10 +24,10 @@ class Profile extends Backend
24 //设置过滤方法 24 //设置过滤方法
25 $this->request->filter(['strip_tags', 'trim']); 25 $this->request->filter(['strip_tags', 'trim']);
26 if ($this->request->isAjax()) { 26 if ($this->request->isAjax()) {
27 - $model = model('AdminLog'); 27 + $this->model = model('AdminLog');
28 list($where, $sort, $order, $offset, $limit) = $this->buildparams(); 28 list($where, $sort, $order, $offset, $limit) = $this->buildparams();
29 29
30 - $list = $model 30 + $list = $this->model
31 ->where($where) 31 ->where($where)
32 ->where('admin_id', $this->auth->id) 32 ->where('admin_id', $this->auth->id)
33 ->order($sort, $order) 33 ->order($sort, $order)
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 </ul> 15 </ul>
16 </div> 16 </div>
17 </div> 17 </div>
18 - <table id="table" class="table table-striped table-bordered table-hover" 18 + <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
19 data-operate-edit="{:$auth->check('user/user/edit')}" 19 data-operate-edit="{:$auth->check('user/user/edit')}"
20 data-operate-del="{:$auth->check('user/user/del')}" 20 data-operate-del="{:$auth->check('user/user/del')}"
21 width="100%"> 21 width="100%">
@@ -388,7 +388,7 @@ class Backend extends Controller @@ -388,7 +388,7 @@ class Backend extends Controller
388 $arr = $arr[0]; 388 $arr = $arr[0];
389 } 389 }
390 $tableArr = explode('.', $k); 390 $tableArr = explode('.', $k);
391 - if (count($tableArr) > 1 && $tableArr[0] != $name && !in_array($tableArr[0], $alias)) { 391 + if (count($tableArr) > 1 && $tableArr[0] != $name && !in_array($tableArr[0], $alias) && !empty($this->model)) {
392 //修复关联模型下时间无法搜索的BUG 392 //修复关联模型下时间无法搜索的BUG
393 $relation = Loader::parseName($tableArr[0], 1, false); 393 $relation = Loader::parseName($tableArr[0], 1, false);
394 $alias[$this->model->$relation()->getTable()] = $tableArr[0]; 394 $alias[$this->model->$relation()->getTable()] = $tableArr[0];
@@ -406,12 +406,15 @@ class Backend extends Controller @@ -406,12 +406,15 @@ class Backend extends Controller
406 } 406 }
407 $index++; 407 $index++;
408 } 408 }
409 - 409 + if (!empty($this->model)) {
410 $this->model->alias($alias); 410 $this->model->alias($alias);
  411 + }
411 $model = $this->model; 412 $model = $this->model;
412 $where = function ($query) use ($where, $alias, $bind, &$model) { 413 $where = function ($query) use ($where, $alias, $bind, &$model) {
  414 + if (!empty($model)) {
413 $model->alias($alias); 415 $model->alias($alias);
414 $model->bind($bind); 416 $model->bind($bind);
  417 + }
415 foreach ($where as $k => $v) { 418 foreach ($where as $k => $v) {
416 if (is_array($v)) { 419 if (is_array($v)) {
417 call_user_func_array([$query, 'where'], $v); 420 call_user_func_array([$query, 'where'], $v);