From 08b43dff7eedb759ba98f4d640fcb2a01796f797 Mon Sep 17 00:00:00 2001 From: linyaostalker <602604991@qq.com> Date: Wed, 20 Nov 2019 11:46:35 +0800 Subject: [PATCH] =?UTF-8?q?antgoods=E6=A8=A1=E5=9D=97=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=A7=84=E6=A0=BC=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/views/layouts/sidebar.php | 1 + .../src}/controllers/AttributeController.php | 24 ++- .../src/models/searchs/AttributeSearch.php | 147 ++++++++++++++++++ .../goods/src}/views/attribute/_form.php | 2 +- .../goods/src}/views/attribute/_search.php | 2 +- .../goods/src}/views/attribute/create.php | 2 +- .../goods/src}/views/attribute/index.php | 2 +- .../goods/src}/views/attribute/update.php | 2 +- .../goods/src}/views/attribute/view.php | 2 +- 9 files changed, 165 insertions(+), 19 deletions(-) rename {backend => vendor/antgoods/goods/src}/controllers/AttributeController.php (89%) mode change 100755 => 100644 create mode 100644 vendor/antgoods/goods/src/models/searchs/AttributeSearch.php rename {backend => vendor/antgoods/goods/src}/views/attribute/_form.php (93%) mode change 100755 => 100644 rename {backend => vendor/antgoods/goods/src}/views/attribute/_search.php (94%) mode change 100755 => 100644 rename {backend => vendor/antgoods/goods/src}/views/attribute/create.php (86%) mode change 100755 => 100644 rename {backend => vendor/antgoods/goods/src}/views/attribute/index.php (91%) mode change 100755 => 100644 rename {backend => vendor/antgoods/goods/src}/views/attribute/update.php (89%) mode change 100755 => 100644 rename {backend => vendor/antgoods/goods/src}/views/attribute/view.php (92%) mode change 100755 => 100644 diff --git a/backend/views/layouts/sidebar.php b/backend/views/layouts/sidebar.php index c8f8ada..63c126a 100755 --- a/backend/views/layouts/sidebar.php +++ b/backend/views/layouts/sidebar.php @@ -21,6 +21,7 @@ use iron\widgets\Menu; ] ], ['label' => '商品管理', 'url' => '#', 'icon' => 'far fa-archive', 'items' => [ + ['label' => '规格管理', 'url' => ['/antgoods/attribute/index']], ['label' => '商品列表', 'url' => ['/antgoods/goods/index']], ['label' => '后台商品分类', 'url' => ['/antgoods/category/index']], ['label' => '前端商品分类', 'url' => ['/antgoods/shopcategory/index']], diff --git a/backend/controllers/AttributeController.php b/vendor/antgoods/goods/src/controllers/AttributeController.php old mode 100755 new mode 100644 similarity index 89% rename from backend/controllers/AttributeController.php rename to vendor/antgoods/goods/src/controllers/AttributeController.php index a4b35c7..bc99f99 --- a/backend/controllers/AttributeController.php +++ b/vendor/antgoods/goods/src/controllers/AttributeController.php @@ -1,11 +1,10 @@ $searchModel, 'dataProvider' => $dataProvider, 'columns' => $searchModel->columns() - ]); + ]); } /** @@ -126,25 +125,24 @@ class AttributeController extends Controller throw new NotFoundHttpException('The requested page does not exist.'); } - /** - * @author iron - * 文件导出 - */ + * @author iron + * 文件导出 + */ public function actionExport() { - $searchModel = new attributeSearch(); + $searchModel = new AttributeSearch(); $params = Yii::$app->request->queryParams; if ($params['page-type'] == 'all') { - $dataProvider = $searchModel->allData($params); + $dataProvider = $searchModel->allData($params); } else { $dataProvider = $searchModel->search($params); } - \iron\widget\Excel::export([ + \iron\widget\Excel::export([ 'models' => $dataProvider->getModels(), 'format' => 'Xlsx', 'asAttachment' => true, - 'fileName' => 'Attributes' . "-" . date('Y-m-d H/i/s', time()), + 'fileName' =>'Attributes'. "-" .date('Y-m-d H/i/s', time()), 'columns' => $searchModel->columns() ]); } diff --git a/vendor/antgoods/goods/src/models/searchs/AttributeSearch.php b/vendor/antgoods/goods/src/models/searchs/AttributeSearch.php new file mode 100644 index 0000000..f5cc763 --- /dev/null +++ b/vendor/antgoods/goods/src/models/searchs/AttributeSearch.php @@ -0,0 +1,147 @@ + 'blobt\grid\CheckboxColumn', + 'width' => '2%', + 'align' => 'center' + ], + 'id', + 'name', + 'value', + 'type', + 'sort_order', + //'is_delete', + //'created_at', + //'updated_at', + [ + 'class' => 'iron\grid\ActionColumn', + 'align' => 'center', + ], + ]; + } + /** + * @param $params + * @return ActiveDataProvider + * 不分页的所有数据 + */ + public function allData($params) + { + $query = Attribute::find(); + $dataProvider = new ActiveDataProvider([ + 'query' => $query, + 'pagination' => false, + 'sort' => false + ]); + $this->load($params); + return $this->filter($query, $dataProvider); + } + + /** + * Creates data provider instance with search query applied + * + * @param array $params + * + * @return ActiveDataProvider + */ + public function search($params) + { + $query = Attribute::find(); + + // add conditions that should always apply here + + $dataProvider = new ActiveDataProvider([ + 'query' => $query, + 'pagination' => [ + 'pageSizeLimit' => [1, 200] + ], + 'sort' => [ + 'defaultOrder' => [ + 'id' => SORT_DESC, + ] + ], + ]); + + $this->load($params); + return $this->filter($query, $dataProvider); + } + /** + * @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 + // $query->where('0=1'); + return $dataProvider; + } + + // grid filtering conditions + $query->andFilterWhere([ + 'id' => $this->id, + 'type' => $this->type, + 'sort_order' => $this->sort_order, + 'is_delete' => $this->is_delete, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + ]); + + $query->andFilterWhere(['like', 'name', $this->name]) + ->andFilterWhere(['like', 'value', $this->value]); + if ($this->created_at_range) { + $arr = explode(' ~ ', $this->created_at_range); + $start = strtotime($arr[0]); + $end = strtotime($arr[1]) + 3600 * 24; + $query->andFilterWhere(['between', 'created_at', $start, $end]); + } + return $dataProvider; + } +} diff --git a/backend/views/attribute/_form.php b/vendor/antgoods/goods/src/views/attribute/_form.php old mode 100755 new mode 100644 similarity index 93% rename from backend/views/attribute/_form.php rename to vendor/antgoods/goods/src/views/attribute/_form.php index de4e895..7d6644c --- a/backend/views/attribute/_form.php +++ b/vendor/antgoods/goods/src/views/attribute/_form.php @@ -4,7 +4,7 @@ use yii\helpers\Html; use yii\widgets\ActiveForm; /* @var $this yii\web\View */ -/* @var $model common\models\ars\Attribute */ +/* @var $model antgoods\goods\models\ars\Attribute */ /* @var $form yii\widgets\ActiveForm */ ?> diff --git a/backend/views/attribute/_search.php b/vendor/antgoods/goods/src/views/attribute/_search.php old mode 100755 new mode 100644 similarity index 94% rename from backend/views/attribute/_search.php rename to vendor/antgoods/goods/src/views/attribute/_search.php index e8f58ee..0a9d3be --- a/backend/views/attribute/_search.php +++ b/vendor/antgoods/goods/src/views/attribute/_search.php @@ -5,7 +5,7 @@ use yii\widgets\ActiveForm; use \blobt\widgets\DateRangePicker; /* @var $this yii\web\View */ -/* @var $model common\models\searchs\attributeSearch */ +/* @var $model common\models\searchs\AttributeSearch */ /* @var $form yii\widgets\ActiveForm */ ?> diff --git a/backend/views/attribute/create.php b/vendor/antgoods/goods/src/views/attribute/create.php old mode 100755 new mode 100644 similarity index 86% rename from backend/views/attribute/create.php rename to vendor/antgoods/goods/src/views/attribute/create.php index d5578e6..1eaf0e4 --- a/backend/views/attribute/create.php +++ b/vendor/antgoods/goods/src/views/attribute/create.php @@ -3,7 +3,7 @@ use yii\helpers\Html; /* @var $this yii\web\View */ -/* @var $model common\models\ars\Attribute */ +/* @var $model antgoods\goods\models\ars\Attribute */ $this->title = '创建 Attribute'; $this->params['breadcrumbs'][] = ['label' => 'Attributes', 'url' => ['index']]; diff --git a/backend/views/attribute/index.php b/vendor/antgoods/goods/src/views/attribute/index.php old mode 100755 new mode 100644 similarity index 91% rename from backend/views/attribute/index.php rename to vendor/antgoods/goods/src/views/attribute/index.php index 3b9e384..6bdf668 --- a/backend/views/attribute/index.php +++ b/vendor/antgoods/goods/src/views/attribute/index.php @@ -4,7 +4,7 @@ use yii\helpers\Html; use iron\grid\GridView; /* @var $this yii\web\View */ -/* @var $searchModel common\models\searchs\attributeSearch */ +/* @var $searchModel common\models\searchs\AttributeSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = 'Attributes'; diff --git a/backend/views/attribute/update.php b/vendor/antgoods/goods/src/views/attribute/update.php old mode 100755 new mode 100644 similarity index 89% rename from backend/views/attribute/update.php rename to vendor/antgoods/goods/src/views/attribute/update.php index 4532da0..e48b930 --- a/backend/views/attribute/update.php +++ b/vendor/antgoods/goods/src/views/attribute/update.php @@ -3,7 +3,7 @@ use yii\helpers\Html; /* @var $this yii\web\View */ -/* @var $model common\models\ars\Attribute */ +/* @var $model antgoods\goods\models\ars\Attribute */ $this->title = '编辑 Attribute: ' . $model->name; $this->params['breadcrumbs'][] = ['label' => 'Attributes', 'url' => ['index']]; diff --git a/backend/views/attribute/view.php b/vendor/antgoods/goods/src/views/attribute/view.php old mode 100755 new mode 100644 similarity index 92% rename from backend/views/attribute/view.php rename to vendor/antgoods/goods/src/views/attribute/view.php index 8e54adb..beac055 --- a/backend/views/attribute/view.php +++ b/vendor/antgoods/goods/src/views/attribute/view.php @@ -4,7 +4,7 @@ use yii\helpers\Html; use yii\widgets\DetailView; /* @var $this yii\web\View */ -/* @var $model common\models\ars\Attribute */ +/* @var $model antgoods\goods\models\ars\Attribute */ $this->title = $model->name; $this->params['breadcrumbs'][] = ['label' => 'Attributes', 'url' => ['index']];