model = new WorkerOutModel(); } //查看 #[Route("GET,JSON","index")] public function index() { // return $this->_index(); if (false === $this->request->isAjax()) { return $this->fetch(); } if ($this->request->post('selectpage')) { return $this->selectpage(); } [$where, $order, $limit, $with] = $this->buildparams(); $list = $this->model->alias('w') ->join("user u", "w.pid = u.id", "LEFT") ->join("group_user g", "w.user_id = g.id", "LEFT") ->where($where) ->order($order) ->field(['w.*','u.nickname' => 'manage_nickname','g.nickname' => 'worker_nickname','g.avatar']) ->paginate($limit)->each(function ($item, $key) { $item['avatar']= startsWithHttp($item['avatar'])?$item['avatar']:request()->domain().'/' . $item['avatar']; return $item; }); $result = ['total' => $list->total(), 'rows' => $list->items()]; return json($result); } //添加 #[Route("GET,POST","add")] public function add() { //通过定义postParams来增加或覆盖post提交的表单 $this->postParams=[]; //通过定义callback回调函数来执行添加后的操作 $this->callback=function ($model){}; return $this->_add(); } //修改 #[Route("GET,POST","edit")] public function edit() { //通过定义postParams来增加或覆盖post提交的表单 $this->postParams=[]; //通过定义callback回调函数来执行修改后的操作 $this->callback=function ($model){}; return $this->_edit(); } //删除 #[Route("GET,POST","del")] public function del() { //通过定义callback回调函数来执行删除后的操作 $this->callback=function ($ids){}; return $this->_del(); } //更新 #[Route("GET,POST","multi")] public function multi() { //通过定义callback回调函数来执行更新后的操作 $this->callback=function ($ids,$field,$value){}; return $this->_multi(); } //导入 #[Route("GET,POST","import")] public function import() { //通过定义callback回调函数来处理导入的数据 $this->callback=function ($inserData){ return $inserData; }; return $this->_import(); } //下载 #[Route("GET,POST","download")] public function download() { //通过定义callback回调函数来处理下载的数据 $this->callback=function ($downloadData){ return $downloadData; }; return $this->_download(); } }