title='公告列表'; DataXw::mQuery() ->like('title') ->dateBetween('create_time')->layTable(); } /** * 公告添加 * @auth true * @menu true */ public function add(){ $this->xw_vali(); DataXw::mForm('form'); } /** * 公告编辑 * @auth true * @menu true */ public function edit(){ $this->xw_vali(); DataXw::mForm('form'); } protected function xw_vali(){ if($this->request->isPost()){ $this->_vali([ 'title.max:50'=>'标题过长', 'summary.require'=>'概要必须', 'summary.max:250'=>'概要最长250', 'content.require'=>'内容必须', ]); } } /** * 公告删除 * @auth true * @menu true */ public function remove(){ $ids=$this->request->post('id'); DataXw::whereIn('id',$ids)->select()->each(function ($d){$d->delete();}); $this->success('删除成功'); } /** * 表单结果处理 * @param boolean $state */ protected function _form_result(bool $state) { if ($state) { $this->success('保存成功!',in_array($this->request->action(),['add','edit'])? 'javascript:history.back()':''); } } }