1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- namespace app\admin\controller;
- use app\data\model\DataNotice as DataXw;
- use think\admin\Controller;
- /**
- * 公告
- * Class Xw
- * @package app\admin\controller\Notice
- */
- class Notice extends Controller
- {
- /**
- * 公告列表
- * @auth true
- * @menu true
- */
- public function index(){
- $this->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();});
- DataXw::whereIn('id',$ids)->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()':'');
- }
- }
- }
|