title = '举报类目列表'; $query = $this->_query($this->table)->where('is_deleted',0)->page(false); } /** * 数据列表处理 * @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) { foreach ($data as &$vo) { $vo['ids'] = join(',', Data::getArrSubIds($data, $vo['id'])); } $data = Data::arr2table($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->_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->_form($this->table, 'form'); } /** * 表单数据处理 * @param array $vo * @throws \ReflectionException * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ protected function _form_filter(&$vo) { if ($this->request->isGet()) { // 读取系统功能节点 $this->nodes = MenuService::instance()->getList(); // 选择自己的上级举报类目 if (empty($vo['pid']) && $this->request->get('pid', '0')) $vo['pid'] = $this->request->get('pid', '0'); // 列出可选上级举报类目 $menus = Db::name($this->table)->where(['status' => '1'])->order('sort desc,id asc')->column('id,pid,title'); $this->menus = Data::arr2table(array_merge($menus, [['id' => '0', 'pid' => '-1', 'title' => '顶部举报类目']])); if (isset($vo['id'])) foreach ($this->menus as $key => $menu) if ($menu['id'] === $vo['id']) $vo = $menu; foreach ($this->menus as $key => &$menu) { if ($menu['spt'] >= 2) unset($this->menus[$key]); if (isset($vo['spt']) && $vo['spt'] <= $menu['spt']) unset($this->menus[$key]); } } if($this->request->isPost() && in_array($this->request->action(),['add','edit'])){ if(!isset($vo['id']) && $vo['pid']){ $plev = Db::name($this->table)->where('id',$vo['pid'])->value('lev'); $vo['lev'] = $plev + 1; } } } /** * 启用 * @auth true * @menu true * @throws \think\Exception * @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 forbid() { $this->_save($this->table, ['status' => '0']); } /** * 删除 * @auth true * @menu true * @throws \think\Exception * @throws \think\exception\PDOException */ public function remove() { $this->_save($this->table, ['is_deleted' => 1]); } }