修复普通搜索无法执行搜索的BUG

pull/135/MERGE v0.1.0.20170721_beta
Karson 2017-07-21 18:22:30 +08:00
parent 5cb04aab5e
commit 241c6fc370
1 changed files with 15 additions and 35 deletions

View File

@ -11,7 +11,7 @@ trait Backend
public function index() public function index()
{ {
//设置过滤方法 //设置过滤方法
$this->request->filter(['strip_tags', 'htmlspecialchars']); $this->request->filter(['strip_tags']);
if ($this->request->isAjax()) if ($this->request->isAjax())
{ {
//如果发送的来源是Selectpage则转发到Selectpage //如果发送的来源是Selectpage则转发到Selectpage
@ -45,7 +45,6 @@ trait Backend
{ {
if ($this->request->isPost()) if ($this->request->isPost())
{ {
$this->code = -1;
$params = $this->request->post("row/a"); $params = $this->request->post("row/a");
if ($params) if ($params)
{ {
@ -65,24 +64,19 @@ trait Backend
$result = $this->model->save($params); $result = $this->model->save($params);
if ($result !== false) if ($result !== false)
{ {
$this->code = 1; $this->success();
} }
else else
{ {
$this->msg = $this->model->getError(); $this->error($this->model->getError());
} }
} }
catch (\think\exception\PDOException $e) catch (\think\exception\PDOException $e)
{ {
$this->msg = $e->getMessage(); $this->error($e->getMessage());
} }
} }
else $this->error(__('Parameter %s can not be empty', ''));
{
$this->msg = __('Parameter %s can not be empty', '');
}
return;
} }
return $this->view->fetch(); return $this->view->fetch();
} }
@ -97,7 +91,6 @@ trait Backend
$this->error(__('No Results were found')); $this->error(__('No Results were found'));
if ($this->request->isPost()) if ($this->request->isPost())
{ {
$this->code = -1;
$params = $this->request->post("row/a"); $params = $this->request->post("row/a");
if ($params) if ($params)
{ {
@ -111,30 +104,25 @@ trait Backend
if ($this->modelValidate) if ($this->modelValidate)
{ {
$name = basename(str_replace('\\', '/', get_class($this->model))); $name = basename(str_replace('\\', '/', get_class($this->model)));
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : true) : $this->modelValidate; $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : true) : $this->modelValidate;
$row->validate($validate); $row->validate($validate);
} }
$result = $row->save($params); $result = $row->save($params);
if ($result !== false) if ($result !== false)
{ {
$this->code = 1; $this->success();
} }
else else
{ {
$this->msg = $row->getError(); $this->error($row->getError());
} }
} }
catch (think\exception\PDOException $e) catch (think\exception\PDOException $e)
{ {
$this->msg = $e->getMessage(); $this->error($e->getMessage());
} }
} }
else $this->error(__('Parameter %s can not be empty', ''));
{
$this->msg = __('Parameter %s can not be empty', '');
}
return;
} }
$this->view->assign("row", $row); $this->view->assign("row", $row);
return $this->view->fetch(); return $this->view->fetch();
@ -145,17 +133,15 @@ trait Backend
*/ */
public function del($ids = "") public function del($ids = "")
{ {
$this->code = -1;
if ($ids) if ($ids)
{ {
$count = $this->model->destroy($ids); $count = $this->model->destroy($ids);
if ($count) if ($count)
{ {
$this->code = 1; $this->success();
} }
} }
$this->error(__('Parameter %s can not be empty', 'ids'));
return;
} }
/** /**
@ -163,7 +149,6 @@ trait Backend
*/ */
public function multi($ids = "") public function multi($ids = "")
{ {
$this->code = -1;
$ids = $ids ? $ids : $this->request->param("ids"); $ids = $ids ? $ids : $this->request->param("ids");
if ($ids) if ($ids)
{ {
@ -176,21 +161,16 @@ trait Backend
$count = $this->model->where($this->model->getPk(), 'in', $ids)->update($values); $count = $this->model->where($this->model->getPk(), 'in', $ids)->update($values);
if ($count) if ($count)
{ {
$this->code = 1; $this->success();
} }
} }
else else
{ {
$this->msg = __('You have no permission'); $this->error(__('You have no permission'));
} }
} }
else
{
$this->msg = __('Parameter %s can not be empty', '');
} }
} $this->error(__('Parameter %s can not be empty', 'ids'));
return;
} }
} }