123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- <?php
- namespace app\admin\controller\cms;
- use app\admin\model\cms\Participate;
- use app\common\controller\Backend;
- use app\common\model\UserRoleLog;
- use think\Db;
- use think\exception\PDOException;
- use think\exception\ValidateException;
- /**
- * 会议管理
- *
- * @icon fa fa-cny
- */
- class Conference extends Backend
- {
- /**
- * Conference模型对象
- * @var \app\admin\model\cms\Conference
- */
- protected $model = null;
- protected $searchFields = 'id';
- protected $noNeedRight = ['detail', 'is_adopt'];
- public function _initialize()
- {
- parent::_initialize();
- $this->model = new \app\admin\model\cms\Conference();
- }
- /**
- * 查看
- */
- public function index()
- {
- //设置过滤方法
- $this->request->filter(['strip_tags']);
- if ($this->request->isAjax()) {
- $this->relationSearch = true;
- //如果发送的来源是Selectpage,则转发到Selectpage
- if ($this->request->request('keyField')) {
- return $this->selectpage();
- }
- list($where, $sort, $order, $offset, $limit) = $this->buildparams();
- $total = $this->model
- ->where($where)
- ->order($sort, $order)
- ->count();
- $list = $this->model->with(['user'])
- ->where($where)
- ->order($sort, $order)
- ->limit($offset, $limit)
- ->select();
- $result = array("total" => $total, "rows" => $list);
- return json($result);
- }
- return $this->view->fetch();
- }
- /**
- * 参与会议详情
- *
- * @param $ids
- * @return string|\think\response\Json
- * @throws Exception
- */
- public function detail($ids = null)
- {
- //设置过滤方法
- $this->request->filter(['strip_tags', 'trim']);
- if ($this->request->isAjax()) {
- //如果发送的来源是Selectpage,则转发到Selectpage
- if ($this->request->request('keyField')) {
- return $this->selectpage();
- }
- list($where, $sort, $order, $offset, $limit) = $this->buildparams();
- $model = new Participate();
- $list = $model->with(['user', 'conference'])
- ->where(['conference_id' => $ids])
- ->where($where)
- ->order($sort, $order)
- ->paginate($limit);
- $result = array("total" => $list->total(), "rows" => $list->items());
- return json($result);
- }
- return $this->view->fetch();
- }
- /**
- * 会议申请操作
- *
- * @param $ids
- * @param $status
- * @return void
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- public function is_adopt($ids = null, $status = null)
- {
- $row = $this->model->get($ids);
- if (!$row) {
- $this->error(__('No Results were found'));
- }
- $result = false;
- Db::startTrans();
- try {
- //是否采用模型验证
- if ($this->modelValidate) {
- $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
- $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
- $row->validateFailException()->validate($validate);
- }
- $result = $row->allowField(true)->save(['status' => $status]);
- Db::commit();
- } catch (ValidateException|PDOException|Exception $e) {
- Db::rollback();
- $this->error($e->getMessage());
- }
- if (false === $result) {
- $this->error(__('No rows were updated'));
- }
- $this->success();
- }
- }
|