[ 'class' => LoginBehavior::className(), ], ]); } //列表 public function actionIndex() { if(\Yii::$app->request->isAjax){ $form = new DetectionListForm(); $form->attributes = \Yii::$app->request->get(); if(\Yii::$app->admin->identity->user->store){ $form->store_id = \Yii::$app->admin->identity->user->store->id; } $data = $form->search(); return $this->responseHandler($data); } $store = Store::find()->select('id,name')->where(['is_delete' => 0])->asArray()->all(); return $this->render('index',[ 'store' => $store ]); } //添加、编辑 public function actionEdit($id = 0) { $is_store = \Yii::$app->admin->identity->user->store; $model = Detection::findOne([ 'id' => $id, 'is_delete' => 0 ]); if($model == null) $model = new Detection(); if(\Yii::$app->request->isPost){ $form = new DetectionEditForm(); $form->attributes = \Yii::$app->request->post(); if($is_store){ $form->store_id = \Yii::$app->admin->identity->user->store->id; } $form->model = $model; $data = $form->edit(); return $this->responseHandler($data); } $store = Store::find()->select('id,name')->where(['is_delete' => 0])->asArray()->all(); $return_url = \Yii::$app->request->referrer; return $this->render('edit',[ 'model' => $model, 'return_url' => $return_url, 'store' => $store, ]); } //删除 public function actionDelete() { if(!\Yii::$app->request->isPost){ $data = $this->invaildRequest(); return $this->responseHandler($data); } $form = new DetectionActionForm(); $form->attributes = \Yii::$app->request->post(); $data = $form->delete(); return $this->responseHandler($data); } //解绑 public function actionUntie() { if(!\Yii::$app->request->isPost){ $data = $this->invaildRequest(); return $this->responseHandler($data); } $form = new DetectionActionForm(); $form->attributes = \Yii::$app->request->post(); $data = $form->untie(); return $this->responseHandler($data); } }