model = model('Users'); $this->view->assign("statusList", $this->model->getStatusList()); } /** * 查看 */ public function index() { //设置过滤方法 $this->request->filter(['strip_tags', 'trim']); if ($this->request->isAjax()) { //如果发送的来源是Selectpage,则转发到Selectpage if ($this->request->request('keyField')) { return $this->selectpage(); } list($where, $sort, $order, $offset, $limit) = $this->buildparams(); $list = $this->model ->where($where)->where('is_agent', 1)->where('is_delete', 0) ->order($sort, $order) ->paginate($limit); $result = array("total" => $list->total(), "rows" => $list->items()); return json($result); } return $this->view->fetch(); } /** * 禁用 * @param $ids * @return string * @throws DbException * @throws \think\Exception */ public function disable($ids = null, $is_lock=0) { $row = $this->model->get($ids); if (!$row) { $this->error(__('No Results were found')); } $result = false; try { $result = $row->allowField(true)->save(['is_lock'=>$is_lock]); } catch (ValidateException|PDOException|Exception $e) { $this->error($e->getMessage()); } if (false === $result) { $this->error(__('No rows were updated')); } $this->success(); } }