linyaostalker
5 years ago
4 changed files with 212 additions and 3 deletions
-
149backend/controllers/ExpressTemplateController.php
-
14common/models/ars/TakingSite.php
-
30console/migrations/m191203_030210_update_columns_province_city_area_in_table_ats_taking_site.php
-
22console/migrations/m191203_030911_update_column_address_in_table_ats_taking_site.php
@ -0,0 +1,149 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace backend\controllers; |
||||
|
|
||||
|
use Yii; |
||||
|
use common\models\ars\ExpressTemplate; |
||||
|
use common\models\searchs\ExpressTemplateSearch; |
||||
|
use yii\web\Controller; |
||||
|
use yii\web\NotFoundHttpException; |
||||
|
use yii\filters\VerbFilter; |
||||
|
|
||||
|
/** |
||||
|
* ExpressTemplateController implements the CRUD actions for ExpressTemplate model. |
||||
|
*/ |
||||
|
class ExpressTemplateController extends Controller |
||||
|
{ |
||||
|
/** |
||||
|
* {@inheritdoc} |
||||
|
*/ |
||||
|
public function behaviors() |
||||
|
{ |
||||
|
return [ |
||||
|
'verbs' => [ |
||||
|
'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() |
||||
|
]); |
||||
|
} |
||||
|
} |
@ -0,0 +1,30 @@ |
|||||
|
<?php |
||||
|
|
||||
|
use yii\db\Migration; |
||||
|
|
||||
|
/** |
||||
|
* Class m191203_030210_update_columns_province_city_area_in_table_ats_taking_site |
||||
|
*/ |
||||
|
class m191203_030210_update_columns_province_city_area_in_table_ats_taking_site extends Migration |
||||
|
{ |
||||
|
public function up() |
||||
|
{ |
||||
|
$this->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; |
||||
|
} |
||||
|
} |
@ -0,0 +1,22 @@ |
|||||
|
<?php |
||||
|
|
||||
|
use yii\db\Migration; |
||||
|
|
||||
|
/** |
||||
|
* Class m191203_030911_update_column_address_in_table_ats_taking_site |
||||
|
*/ |
||||
|
class m191203_030911_update_column_address_in_table_ats_taking_site extends Migration |
||||
|
{ |
||||
|
public function up() |
||||
|
{ |
||||
|
$this->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; |
||||
|
} |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue