From 41996eb93d5f16d612f1be0accf282c53a5c1d0b Mon Sep 17 00:00:00 2001 From: travis <310243791@qq.com> Date: Sat, 7 Dec 2019 17:29:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E5=8F=91=E8=B4=A7?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/modules/shop/models/ars/Delivery.php | 24 +++++++++++++++++++ .../shop/models/searchs/DeliverySearch.php | 9 ++++--- backend/modules/shop/views/delivery/view.php | 7 +++++- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/backend/modules/shop/models/ars/Delivery.php b/backend/modules/shop/models/ars/Delivery.php index 866b413..6e5db5a 100755 --- a/backend/modules/shop/models/ars/Delivery.php +++ b/backend/modules/shop/models/ars/Delivery.php @@ -85,4 +85,28 @@ class Delivery extends \yii\db\ActiveRecord ], ]; } + + /** + * @param $column + * @param null $value + * @return bool + * 获取各状态数组 + */ + public static function dropDown($column, $value = null) + { + $dropDownList = [ + 'type' => [ + self::TYPE_SHIPMENT_ALL => '全部发货', + self::TYPE_SHIPMENT_PORTION => '部分发货', + ], + ]; + + //根据具体值显示对应的值 + if ($value !== null) + return array_key_exists($column, $dropDownList) ? $dropDownList[$column][$value] : false; + //返回关联数组,用户下拉的filter实现 + else + return array_key_exists($column, $dropDownList) ? $dropDownList[$column] : false; + } + } diff --git a/backend/modules/shop/models/searchs/DeliverySearch.php b/backend/modules/shop/models/searchs/DeliverySearch.php index f0a0804..9016666 100644 --- a/backend/modules/shop/models/searchs/DeliverySearch.php +++ b/backend/modules/shop/models/searchs/DeliverySearch.php @@ -58,7 +58,7 @@ class DeliverySearch extends Delivery ], [ 'attribute' => 'order_id', - 'width' => '10%', + 'width' => '7%', ], [ 'attribute' => 'shipping_name', @@ -70,7 +70,10 @@ class DeliverySearch extends Delivery ], [ 'attribute' => 'type', - 'width' => '7%', + 'width' => '8%', + 'value' => function ($model) { + return Delivery::dropDown('type', $model->type); + } ], [ 'attribute' => 'status', @@ -78,7 +81,7 @@ class DeliverySearch extends Delivery ], [ 'attribute' => 'decription', - 'width' => '7%', + 'width' => '15%', ], [ 'attribute' => 'created_at', diff --git a/backend/modules/shop/views/delivery/view.php b/backend/modules/shop/views/delivery/view.php index a452682..a1302e2 100644 --- a/backend/modules/shop/views/delivery/view.php +++ b/backend/modules/shop/views/delivery/view.php @@ -24,7 +24,12 @@ $this->params['breadcrumbs'][] = $this->title; 'order_id', 'shipping_name', 'shipping_id', - 'type', + [ + 'attribute' => 'type', + 'value' => function ($model) { + return \backend\modules\shop\models\ars\Delivery::dropDown('type', $model->type); + } + ], 'status', 'decription:ntext', [