From 5f40462c7455c1cfb8ad71e730388947c5c104a1 Mon Sep 17 00:00:00 2001 From: linyaostalker <602604991@qq.com> Date: Fri, 6 Dec 2019 10:21:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BC=98=E5=8C=96gridview?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=EF=BC=8C=E5=BC=80=E5=8F=91=E8=BF=90=E8=B4=B9?= =?UTF-8?q?=E5=8C=BA=E5=9F=9F=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/ExpressTemplateController.php | 20 ++++++ .../models/searchs/ExpressTemplateSearch.php | 23 +++++++ .../express-template/express_area_list.php | 33 ++++++++++ vendor/iron/grid/GridView.php | 63 ++++++++++++++++--- 4 files changed, 131 insertions(+), 8 deletions(-) create mode 100644 backend/modules/shop/views/express-template/express_area_list.php diff --git a/backend/modules/shop/controllers/ExpressTemplateController.php b/backend/modules/shop/controllers/ExpressTemplateController.php index 460be98..4f6e9a0 100755 --- a/backend/modules/shop/controllers/ExpressTemplateController.php +++ b/backend/modules/shop/controllers/ExpressTemplateController.php @@ -4,6 +4,7 @@ namespace backend\modules\shop\controllers; use backend\modules\shop\models\ars\City; use backend\modules\shop\models\ars\Province; +use backend\modules\shop\models\searchs\ExpressAreaSearch; use Yii; use backend\modules\shop\models\ars\ExpressTemplate; use backend\modules\shop\models\searchs\ExpressTemplateSearch; @@ -13,6 +14,7 @@ use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; use yii\web\Response; use yii\widgets\ActiveForm; +use backend\modules\shop\models\ars\ExpressArea; /** * ExpressTemplateController implements the CRUD actions for ExpressTemplate model. @@ -213,4 +215,22 @@ class ExpressTemplateController extends Controller 'columns' => $searchModel->columns() ]); } + + /** + * @return string + * 运费区域列表 + */ + public function actionExpressAreaList($id) + { + $expressTemplate = ExpressTemplate::findOne($id); + $searchModel = new ExpressAreaSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams, $id); + + return $this->render('express_area_list', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + 'columns' => $searchModel->columns(), + 'expressTemplate' => $expressTemplate + ]); + } } diff --git a/backend/modules/shop/models/searchs/ExpressTemplateSearch.php b/backend/modules/shop/models/searchs/ExpressTemplateSearch.php index 73fe403..a1e4b16 100755 --- a/backend/modules/shop/models/searchs/ExpressTemplateSearch.php +++ b/backend/modules/shop/models/searchs/ExpressTemplateSearch.php @@ -57,6 +57,29 @@ class ExpressTemplateSearch extends ExpressTemplate [ 'class' => 'iron\grid\ActionColumn', 'align' => 'center', + 'config' => [ + [ + 'name' => 'view', + 'icon' => 'list', + 'title' => '详情', + ], + [ + 'name' => 'update', + 'icon' => 'pencil', + 'title' => '修改' + ], + [ + 'name' => 'express-area-list', + 'icon' => 'hard-drive', + 'title' => '配送区域' + ], + [ + 'name' => 'delete', + 'icon' => 'trash', + 'title' => '删除', + 'contents' => '确定删除?' + ] + ], ], ]; } diff --git a/backend/modules/shop/views/express-template/express_area_list.php b/backend/modules/shop/views/express-template/express_area_list.php new file mode 100644 index 0000000..465718b --- /dev/null +++ b/backend/modules/shop/views/express-template/express_area_list.php @@ -0,0 +1,33 @@ +title = '运费区域模板:'.$expressTemplate->name; +$this->params['breadcrumbs'][] = $this->title; +?> +
+
+ $dataProvider, + 'filter' => $this->render("_search", ['model' => $searchModel]), + 'batch' => [ + [ + "label" => "删除", + "url" => "express-area/deletes" + ], + ], + 'columns' => $columns, + 'batchTemplate' => '', + 'create' => '', + 'export' => '', + 'content' => Html::a('创建', ['index'], ['class' => 'btn btn-default']). + Html::a('返回', ['index'], ['class' => 'btn btn-default']) + ]); + ?> +
+
\ No newline at end of file diff --git a/vendor/iron/grid/GridView.php b/vendor/iron/grid/GridView.php index 5b42816..809a4ad 100644 --- a/vendor/iron/grid/GridView.php +++ b/vendor/iron/grid/GridView.php @@ -219,16 +219,11 @@ class GridView extends BaseListView
{batch} - 添加 + {create} -
- - -
+ {export} + {content}
{filter} @@ -263,6 +258,25 @@ HTML;
HTML; + public $export =<< + + +
+HTML; + public $create =<<添加 +HTML; + /** + * @var + * 表单头部内容 + */ + public $content; + + /** * 初始化 grid view. @@ -445,6 +459,12 @@ SCRIPT; return $this->renderFilter(); case '{batch}': return $this->renderBatch(); + case '{export}': + return $this->renderExport(); + case '{create}': + return $this->renderCreate(); + case '{content}': + return $this->renderContent(); default: return false; } @@ -694,4 +714,31 @@ SCRIPT; ]); } + /** + * 渲染导出部分 + * @return string + */ + protected function renderExport() + { + return $this->export; + } + + /** + * 渲染创建部分 + * @return string + */ + protected function renderCreate() + { + return $this->create; + } + + /** + * 渲染表单头部内容 + * @return string + */ + protected function renderContent() + { + return Html::tag('div', $this->content, ['class' => 'btn-group']); + } + }