diff --git a/backend/controllers/ExpressTemplateController.php b/backend/controllers/ExpressTemplateController.php new file mode 100644 index 0000000..602385f --- /dev/null +++ b/backend/controllers/ExpressTemplateController.php @@ -0,0 +1,149 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ]; + } + + /** + * Lists all ExpressTemplate models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new ExpressTemplateSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + 'columns' => $searchModel->columns() + ]); + } + + /** + * Displays a single ExpressTemplate model. + * @param integer $id + * @return mixed + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new ExpressTemplate model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new ExpressTemplate(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect('index'); + } + + return $this->render('create', [ + 'model' => $model, + ]); + } + + /** + * Updates an existing ExpressTemplate model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect('index'); + } + + return $this->render('update', [ + 'model' => $model, + ]); + } + + /** + * Deletes an existing ExpressTemplate model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionDelete($id) + { + $this->findModel($id)->delete(); + + return $this->redirect(['index']); + } + + /** + * Finds the ExpressTemplate model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return ExpressTemplate the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = ExpressTemplate::findOne($id)) !== null) { + return $model; + } + + throw new NotFoundHttpException('The requested page does not exist.'); + } + /** + * @author iron + * 文件导出 + */ + public function actionExport() + { + $searchModel = new ExpressTemplateSearch(); + $params = Yii::$app->request->queryParams; + if ($params['page-type'] == 'all') { + $dataProvider = $searchModel->allData($params); + } else { + $dataProvider = $searchModel->search($params); + } + \iron\widget\Excel::export([ + 'models' => $dataProvider->getModels(), + 'format' => 'Xlsx', + 'asAttachment' => true, + 'fileName' =>'Express Templates'. "-" .date('Y-m-d H/i/s', time()), + 'columns' => $searchModel->columns() + ]); + } +} diff --git a/common/models/ars/TakingSite.php b/common/models/ars/TakingSite.php index cbd36bd..85364ea 100644 --- a/common/models/ars/TakingSite.php +++ b/common/models/ars/TakingSite.php @@ -20,6 +20,14 @@ use yii\behaviors\TimestampBehavior; */ class TakingSite extends \yii\db\ActiveRecord { + //是否为默认 + const IS_DEFAULT_NO = 0; //否 + const IS_DEFAULT_YES = 1; //是 + + public static $isDefault = [ + self::IS_DEFAULT_NO => '否', + self::IS_DEFAULT_YES => '是' + ]; /** * {@inheritdoc} */ @@ -34,7 +42,7 @@ class TakingSite extends \yii\db\ActiveRecord public function rules() { return [ - [['name'], 'required'], + [['name', 'province', 'city', 'area', 'address'], 'required'], [['address'], 'string'], [['is_default'], 'integer'], [['name'], 'string', 'max' => 120], @@ -53,8 +61,8 @@ class TakingSite extends \yii\db\ActiveRecord 'province' => '省份', 'city' => '城市', 'area' => '区域', - 'address' => '地址', - 'is_default' => '是否为默认,1为默认', + 'address' => '详细地址', + 'is_default' => '是否为默认', 'updated_at' => '更新时间', 'created_at' => '创建时间', ]; diff --git a/console/migrations/m191203_030210_update_columns_province_city_area_in_table_ats_taking_site.php b/console/migrations/m191203_030210_update_columns_province_city_area_in_table_ats_taking_site.php new file mode 100644 index 0000000..7d0c87d --- /dev/null +++ b/console/migrations/m191203_030210_update_columns_province_city_area_in_table_ats_taking_site.php @@ -0,0 +1,30 @@ +dropColumn('ats_taking_site', 'province'); + $this->addColumn('ats_taking_site', 'province', $this->string(10)->notNull()->defaultValue(null)->comment('省份')); + $this->dropColumn('ats_taking_site', 'city'); + $this->addColumn('ats_taking_site', 'city', $this->string(10)->notNull()->defaultValue(null)->comment('城市')); + $this->dropColumn('ats_taking_site', 'area'); + $this->addColumn('ats_taking_site', 'area', $this->string(10)->notNull()->defaultValue(null)->comment('区域')); + } + + public function down() + { + $this->dropColumn('ats_taking_site', 'province'); + $this->addColumn('ats_taking_site', 'province', $this->string(10)->defaultValue(null)->comment('省份')); + $this->dropColumn('ats_taking_site', 'city'); + $this->addColumn('ats_taking_site', 'city', $this->string(10)->defaultValue(null)->comment('城市')); + $this->dropColumn('ats_taking_site', 'area'); + $this->addColumn('ats_taking_site', 'area', $this->string(10)->defaultValue(null)->comment('区域')); + return true; + } +} diff --git a/console/migrations/m191203_030911_update_column_address_in_table_ats_taking_site.php b/console/migrations/m191203_030911_update_column_address_in_table_ats_taking_site.php new file mode 100644 index 0000000..b5b623b --- /dev/null +++ b/console/migrations/m191203_030911_update_column_address_in_table_ats_taking_site.php @@ -0,0 +1,22 @@ +dropColumn('ats_taking_site', 'address'); + $this->addColumn('ats_taking_site', 'address', $this->text()->notNull()->comment('地址')); + } + + public function down() + { + $this->dropColumn('ats_taking_site', 'address'); + $this->addColumn('ats_taking_site', 'address', $this->text()->comment('地址')); + return true; + } +}