title = '文章列表'; $sel_where = []; $sel_where[] = ['is_deleted','=',0]; $sel_where[] = ['type','=',2]; if($title = $this->request->get('title')) $sel_where[] = ['title','like','%'.$title.'%']; if($label = $this->request->get('label')) $sel_where[] = ['label','like','%'.$label.'%']; if($id = $this->request->get('id')) $sel_where[] = ['id','=',$id]; $this->is_vip = $is_vip = $this->request->get('is_vip',-1); if($is_vip >= 0) $sel_where[] = ['is_vip','=',$is_vip ]; $in_ids = ''; if($phone = $this->request->get('phone')) $in_ids = \app\common\model\ArticleItem::where('phone','like','%'.$phone.'%')->column('article_id'); $query = $this->_query($this->table); $query->where($sel_where) ->when($in_ids,function ($query)use ($in_ids){ if(!empty($in_ids)) $query->where('id','in',$in_ids); })->order('sort desc,id desc')->page(); } /** * 数据列表处理 * @auth true * @menu true * @param array $data * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ protected function _index_page_filter(&$data) { } /** * 添加 * @auth true * @menu true * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException * @throws \think\exception\PDOException */ public function add() { $this->title = '添加图文'; $this->type = input('get.type',2); $this->_form($this->table, 'form'); } /** * 编辑 * @auth true * @menu true * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException * @throws \think\exception\PDOException */ public function edit() { $this->title = '编辑图文'; $this->type = input('get.type',2); $this->_form($this->table, 'form') ; } /** * 禁用 * @auth true * @menu true * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException * @throws \think\exception\PDOException */ public function forbid() { $this->_save($this->table, ['status' => '0']); } /** * 启用 * @auth true * @menu true * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException * @throws \think\exception\PDOException */ public function resume() { $this->_save($this->table, ['status' => 1]); } /** * 删除图文 * @auth true * @menu true * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException * @throws \think\exception\PDOException */ public function del() { $this->_save($this->table, ['is_deleted' => 1]); } /** * 表单数据处理 * @auth true * @menu true * @param array $data */ protected function _form_filter(&$data) { if($this->request->isGet()){ $this->r = input('get.r',0); if($this->request->isGet()){ $all_cate = SeriesArticleCate::where(['is_deleted'=>0])->order('sort desc ,id desc')->select(); $this->cate_tree = make_tree($all_cate); } } if($this->request->isPost()) { if($this->request->action() == 'add') $data['item_num'] = 0; } } }