From 5ed04dd2a18d0d045c05b202fa1c5c17f36ea971 Mon Sep 17 00:00:00 2001 From: linyaostalker <602604991@qq.com> Date: Tue, 17 Dec 2019 14:08:42 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E4=BF=AE=E6=94=B9=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E8=A7=86=E5=9B=BE=E7=95=8C=E9=9D=A2=E5=AD=97=E6=AE=B5=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shop/models/searchs/CommentSearch.php | 46 +++++++++---------- backend/modules/shop/views/comment/view.php | 21 +++++++-- 2 files changed, 40 insertions(+), 27 deletions(-) diff --git a/backend/modules/shop/models/searchs/CommentSearch.php b/backend/modules/shop/models/searchs/CommentSearch.php index becdd17..ac8e189 100644 --- a/backend/modules/shop/models/searchs/CommentSearch.php +++ b/backend/modules/shop/models/searchs/CommentSearch.php @@ -13,13 +13,13 @@ use backend\modules\shop\models\ars\Comment; class CommentSearch extends Comment { /** - * @return array - * 增加创建时间查询字段 - */ + * @return array + * 增加创建时间查询字段 + */ public function attributes() - { - return ArrayHelper::merge(['created_at_range'], parent::attributes()); - } + { + return ArrayHelper::merge(['created_at_range'], parent::attributes()); + } /** * {@inheritdoc} */ @@ -41,14 +41,14 @@ class CommentSearch extends Comment return Model::scenarios(); } /** - * @return array - * 列格式 - */ + * @return array + * 列格式 + */ public function columns() { return [ - 'id', - 'user_id', + 'id', + 'user_id', [ 'attribute' => 'order_goods_id', 'value' => function ($model) { @@ -56,8 +56,8 @@ class CommentSearch extends Comment }, 'label' => '商品名称' ], - 'star', - 'content', + 'star', + 'content', [ 'attribute' => 'status', 'value' => function ($model) { @@ -65,7 +65,7 @@ class CommentSearch extends Comment }, 'label' => '状态' ], - 'created_at:datetime', + 'created_at:datetime', [ 'class' => 'iron\grid\ActionColumn', 'align' => 'center', @@ -106,10 +106,10 @@ class CommentSearch extends Comment ]; } /** - * @param $params - * @return ActiveDataProvider - * 不分页的所有数据 - */ + * @param $params + * @return ActiveDataProvider + * 不分页的所有数据 + */ public function allData($params) { $query = Comment::find(); @@ -151,11 +151,11 @@ class CommentSearch extends Comment return $this->filter($query, $dataProvider); } /** - * @param $query - * @param $dataProvider - * @return ActiveDataProvider - * 条件筛选 - */ + * @param $query + * @param $dataProvider + * @return ActiveDataProvider + * 条件筛选 + */ private function filter($query, $dataProvider){ if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails diff --git a/backend/modules/shop/views/comment/view.php b/backend/modules/shop/views/comment/view.php index beefa45..a57e1bb 100644 --- a/backend/modules/shop/views/comment/view.php +++ b/backend/modules/shop/views/comment/view.php @@ -1,5 +1,6 @@ params['breadcrumbs'][] = $this->title; 'attributes' => [ 'id', 'user_id', - 'order_goods_id', + [ + 'attribute' => 'order_goods_id', + 'value' => function ($model) { + return $model->orderGoods->goods_name; + }, + 'label' => '商品名称' + ], 'star', 'content:ntext', - 'status', - 'updated_at', - 'created_at', + [ + 'attribute' => 'status', + 'value' => function ($model) { + return Comment::$commentStatus[$model->status]; + }, + 'label' => '状态' + ], + 'updated_at:datetime', + 'created_at:datetime', ], ]) ?>