model = new \app\common\model\VideoUser(); $videolist=[]; $platformlist=[]; $video=model('videolist')->field('id,name')->select(); foreach ($video as $k => $v){ $videolist[$v['id']]=$v['name']; } $this->view->assign('videolist', $videolist); } /** * 查看 */ public function index() { //设置过滤方法 $this->request->filter(['strip_tags']); if ($this->request->isAjax()) { //如果发送的来源是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 ->where($where) ->with('user,videolist') ->order($sort, $order) ->limit($offset, $limit) ->select(); $result = array("total" => $total, "rows" => $list); return json($result); } return $this->view->fetch(); } /** * 编辑 */ public function edit($ids = NULL) { $row = $this->model->get($ids); if (!$row){ $this->error(__('No Results were found')); } if ($this->request->isPost()) { $params = $this->request->post("row/a"); } $vid = $this->model->where('id', $ids)->value('vid'); $this->view->assign("vid", $vid); return parent::edit($ids); } public function add($vid=0) { if ($this->request->isPost()) { $params = $this->request->post("row/a"); $vid = $this->request->post("vid"); $uid = $this->request->post("uid"); if ($params) { $params['vid'] = $vid; if ($this->model->where('vid', $vid)->where('uid', $uid)->find()){ $this->error('该短剧已拥有记录'); } $params['vname'] = model('videolist')->where('id', $params['vid'])->value('name'); $result = $this->model->save($params); if ($result === false) { $this->error($this->model->getError()); } $this->success(); }else{ $this->error(); } } return $this->view->fetch(); } }