render($this->action->id); } /** * 查询数据 * @return mixed */ public function actionIndexform() { $Post = Yii::$app->request->post(); $Model = new HouseEmail(); $List = $Model->getList($Post); if ($List) { foreach ($List as &$val) { $val['create_at'] = date('Y-m-d H:i', $val['create_at']); } return Help::JsonData(0, Yii::t('app', 'get_success'), $Model->Total($Post), $List); } return Help::JsonCode(Help::ERROR, Yii::t('app', 'get_error')); } /** * @return string */ public function actionAdd() { return $this->render($this->action->id); } /** * 添加数据 * @return mixed */ public function actionAddform() { $Model = new HouseEmail(); $Model->scenario = 'add'; if ($Model->load(Yii::$app->request->post(), '') && $Model->save()) { return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'add_success')); } return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'add_error'), $Model->errors); } /** * @return string */ public function actionEdit() { $Row = HouseEmail::findOne(Yii::$app->request->get('id')); if ($Row) { return $this->render($this->action->id, ['row' => $Row]); } } /** * 修改数据 * @return mixed * @throws \Throwable * @throws \yii\db\StaleObjectException */ public function actionEditform() { $Row = HouseEmail::findOne(Yii::$app->request->post('id')); $Row->scenario = 'edit'; if ($Row->load(Yii::$app->request->post(), '') && $Row->save()) { return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'edit_success')); } return Help::JsonCode(Help::ERROR, Yii::t('app', 'edit_error'), $Row->errors); } /** * 删除数据 * @return mixed * @throws \Throwable * @throws \yii\db\StaleObjectException */ public function actionDelemail() { $Row = HouseEmail::findOne(Yii::$app->request->post('id')); if ($Row->delete()) { return Help::JsonCode(Help::SUCCESS, Yii::t('app', 'del_success')); } return Help::JsonCode(Help::ERROR, Yii::t('app', 'del_error'), $Row->errors); } }