diff --git a/backend/views/layouts/sidebar.php b/backend/views/layouts/sidebar.php index 54868f1..c8f8ada 100755 --- a/backend/views/layouts/sidebar.php +++ b/backend/views/layouts/sidebar.php @@ -22,7 +22,8 @@ use iron\widgets\Menu; ], ['label' => '商品管理', 'url' => '#', 'icon' => 'far fa-archive', 'items' => [ ['label' => '商品列表', 'url' => ['/antgoods/goods/index']], - ['label' => '商品分类', 'url' => ['/antgoods/category/index']], + ['label' => '后台商品分类', 'url' => ['/antgoods/category/index']], + ['label' => '前端商品分类', 'url' => ['/antgoods/shopcategory/index']], ['label' => '品牌管理', 'url' => ['/antgoods/brand/index']], ] ], diff --git a/vendor/antgoods/goods/src/controllers/ShopcategoryController.php b/vendor/antgoods/goods/src/controllers/ShopcategoryController.php new file mode 100644 index 0000000..ef1feec --- /dev/null +++ b/vendor/antgoods/goods/src/controllers/ShopcategoryController.php @@ -0,0 +1,149 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ]; + } + + /** + * Lists all ShopCategory models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new ShopCategorySearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + 'columns' => $searchModel->columns() + ]); + } + + /** + * Displays a single ShopCategory 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 ShopCategory model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new ShopCategory(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect('index'); + } + + return $this->render('create', [ + 'model' => $model, + ]); + } + + /** + * Updates an existing ShopCategory 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 ShopCategory 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 ShopCategory model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return ShopCategory the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = ShopCategory::findOne($id)) !== null) { + return $model; + } + + throw new NotFoundHttpException('The requested page does not exist.'); + } + /** + * @author iron + * 文件导出 + */ + public function actionExport() + { + $searchModel = new ShopCategorySearch(); + $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' =>'Shop Categories'. "-" .date('Y-m-d H/i/s', time()), + 'columns' => $searchModel->columns() + ]); + } +} diff --git a/vendor/antgoods/goods/src/models/ars/ShopCategory.php b/vendor/antgoods/goods/src/models/ars/ShopCategory.php index 2ffb20c..a848f51 100644 --- a/vendor/antgoods/goods/src/models/ars/ShopCategory.php +++ b/vendor/antgoods/goods/src/models/ars/ShopCategory.php @@ -25,6 +25,18 @@ use yii\behaviors\TimestampBehavior; */ class ShopCategory extends \yii\db\ActiveRecord { + //是否显示is_show + const IS_SHOW_DISPLAY = 0;//显示 + const IS_SHOW_HIDE = 1;//隐藏 + //是否删除is_delete + const IS_DELETE_NO = 0;//未删除 + const IS_DELETE_YES = 1;//已删除 + + public static $isShow = [ + self::IS_SHOW_DISPLAY => '显示', + self::IS_SHOW_HIDE => '隐藏' + ]; + /** * {@inheritdoc} */ @@ -65,8 +77,8 @@ class ShopCategory extends \yii\db\ActiveRecord 'icon_type' => '图标类型', 'icon' => '图标', 'filter_attr' => '筛选属性', - 'is_show' => '是否显示,1为不显示', - 'is_delete' => '是否删除,1为已删除', + 'is_show' => '是否显示', + 'is_delete' => '是否删除', 'created_at' => '创建时间', 'updated_at' => '更新时间', ]; diff --git a/vendor/antgoods/goods/src/models/searchs/ShopCategorySearch.php b/vendor/antgoods/goods/src/models/searchs/ShopCategorySearch.php new file mode 100644 index 0000000..524eb11 --- /dev/null +++ b/vendor/antgoods/goods/src/models/searchs/ShopCategorySearch.php @@ -0,0 +1,159 @@ + 'blobt\grid\CheckboxColumn', + 'width' => '2%', + 'align' => 'center' + ], + 'id', + 'name', + 'pid', + 'goods_count', + 'keywords', + //'desc', + //'sort_order', + //'icon_type', + //'icon', + //'filter_attr', + //'is_show', + //'is_delete', + //'created_at', + //'updated_at', + [ + 'class' => 'iron\grid\ActionColumn', + 'align' => 'center', + ], + ]; + } + /** + * @param $params + * @return ActiveDataProvider + * 不分页的所有数据 + */ + public function allData($params) + { + $query = ShopCategory::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 = ShopCategory::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, + 'pid' => $this->pid, + 'goods_count' => $this->goods_count, + 'sort_order' => $this->sort_order, + 'icon_type' => $this->icon_type, + 'is_show' => $this->is_show, + 'is_delete' => $this->is_delete, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + ]); + + $query->andFilterWhere(['like', 'name', $this->name]) + ->andFilterWhere(['like', 'keywords', $this->keywords]) + ->andFilterWhere(['like', 'desc', $this->desc]) + ->andFilterWhere(['like', 'icon', $this->icon]) + ->andFilterWhere(['like', 'filter_attr', $this->filter_attr]); + 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/vendor/antgoods/goods/src/views/shopcategory/_form.php b/vendor/antgoods/goods/src/views/shopcategory/_form.php new file mode 100644 index 0000000..1c3efe6 --- /dev/null +++ b/vendor/antgoods/goods/src/views/shopcategory/_form.php @@ -0,0 +1,41 @@ + + +
+ = Html::a('返回列表', ['index'], ['class' => 'btn btn-success']) ?> +
+ + = DetailView::widget([ + 'model' => $model, + 'attributes' => [ + 'id', + 'name', + 'pid', + 'goods_count', + 'keywords', + 'desc', + 'sort_order', + 'icon_type', + 'icon', + 'filter_attr:ntext', + 'is_show', + 'is_delete', + 'created_at', + 'updated_at', + ], + ]) ?> + +