From e39eb1d338307b5a2ae39a2e492bc88cfadd00be Mon Sep 17 00:00:00 2001 From: linyaostalker <602604991@qq.com> Date: Tue, 26 Nov 2019 14:14:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E5=91=BD=E5=90=8D=E8=A7=84?= =?UTF-8?q?=E8=8C=83=E4=BF=AE=E6=94=B9=E5=89=8D=E7=AB=AF=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E6=96=87=E4=BB=B6=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/views/layouts/sidebar.php | 2 +- .../controllers/ShopcategoryController.php | 273 ------------------ .../{shopcategory => shop-category}/_form.php | 4 +- .../_search.php | 0 .../create.php | 0 .../{shopcategory => shop-category}/index.php | 0 .../update.php | 0 .../{shopcategory => shop-category}/view.php | 0 8 files changed, 4 insertions(+), 275 deletions(-) delete mode 100644 vendor/antgoods/goods/src/controllers/ShopcategoryController.php rename vendor/antgoods/goods/src/views/{shopcategory => shop-category}/_form.php (84%) rename vendor/antgoods/goods/src/views/{shopcategory => shop-category}/_search.php (100%) rename vendor/antgoods/goods/src/views/{shopcategory => shop-category}/create.php (100%) rename vendor/antgoods/goods/src/views/{shopcategory => shop-category}/index.php (100%) rename vendor/antgoods/goods/src/views/{shopcategory => shop-category}/update.php (100%) rename vendor/antgoods/goods/src/views/{shopcategory => shop-category}/view.php (100%) diff --git a/backend/views/layouts/sidebar.php b/backend/views/layouts/sidebar.php index 7fd5971..5a2ebd9 100755 --- a/backend/views/layouts/sidebar.php +++ b/backend/views/layouts/sidebar.php @@ -24,7 +24,7 @@ use iron\widgets\Menu; ['label' => '规格管理', 'url' => ['/antgoods/attribute/index']], ['label' => '商品列表', 'url' => ['/antgoods/goods/index']], ['label' => '后台商品分类', 'url' => ['/antgoods/category/index']], - ['label' => '前端商品分类', 'url' => ['/antgoods/shopcategory/index']], + ['label' => '前端商品分类', 'url' => ['/antgoods/shop-category/index']], ['label' => '品牌管理', 'url' => ['/antgoods/brand/index']], ['label' => '供应商管理', 'url' => ['/antgoods/supplier/index']], ] diff --git a/vendor/antgoods/goods/src/controllers/ShopcategoryController.php b/vendor/antgoods/goods/src/controllers/ShopcategoryController.php deleted file mode 100644 index 64c758a..0000000 --- a/vendor/antgoods/goods/src/controllers/ShopcategoryController.php +++ /dev/null @@ -1,273 +0,0 @@ - [ - 'class' => VerbFilter::className(), - 'actions' => [ - 'delete' => ['POST'], - ], - ], - ]; - } - - public function actions() - { - return [ - 'upload' => [ - 'class' => 'iron\actions\UploadAction', - 'path' => 'xls/', - 'maxSize' => 20480, - ] - ]; - } - - /** - * 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())) { - - //类目图片上传保存处理 - $icon_image_id_str = $model->iconImageId; - $model->save(); - $goods_manager = new GoodsManager(); - $save_icon_image_res = $goods_manager->saveFile(explode(',', $icon_image_id_str), $model, [], File::OWN_TYPE_CATEGORY_ICON); - if($save_icon_image_res['status']){ - $model->icon = $save_icon_image_res['first_file_id']; - $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); - $model->iconImageId = $model->icon; - //记录已保存的类目图片id,用于修改 - $icon_image_old_id_arr = $model->icon; - - if ($model->load(Yii::$app->request->post())) { - - //类目图片上传保存处理 - $icon_image_id_str = $model->iconImageId; - $model->save(); - $goods_manager = new GoodsManager(); - $save_icon_image_res = $goods_manager->saveFile(explode(',', $icon_image_id_str), $model, explode(',', $icon_image_old_id_arr), File::OWN_TYPE_CATEGORY_ICON); - if($save_icon_image_res['status'] && $save_icon_image_res['first_file_id'] !== 0){ - $model->icon = $save_icon_image_res['first_file_id']; - $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() - ]); - } - - /** - * 处理文件上传成功后回调保存到临时文件表中,并返回临时文件id - */ - public function actionSaveFile() - { - if(!class_exists('\common\models\ars\TemFile') || !class_exists('\backend\logic\file\FileManager')){ - return ''; - } - - $data = Yii::$app->request->get('data'); - $file_name = Yii::$app->request->get('fileName')[0]; - - if ($data['status'] == true) { - $model = new \common\models\ars\TemFile(); - $model->user_id = Yii::$app->user->identity->id; - $model->name = $file_name; - $file_manager = new \backend\logic\file\FileManager(); - $type_res = $file_manager->searchType(\backend\logic\file\FileManager::$extension, pathinfo($data['path'])['extension']); - if ($type_res['status']) { - $model->type = $type_res['type']; - } - $model->alias = $data['alias']; - $model->path = $data['path']; - $model->save(); - return $model->id; - } - } - - /** - * @return string - * 点击删除按钮时同时删除字符串中的id - */ - public function actionImgIdDel() - { - //判断该类是否存在 - if(!class_exists('\common\models\ars\TemFile') || !class_exists('\common\models\ars\File')){ - return ''; - } - - $img_id = Yii::$app->request->get('imgid'); - $img_id_arr = explode(',', $img_id); - if(isset(Yii::$app->request->get('data')['alias'])) { - $alias = Yii::$app->request->get('data')['alias']; - $tem_file = \common\models\ars\TemFile::findOne(['alias' => $alias]); - if ($tem_file) { - $img_id_arr = array_diff($img_id_arr, [$tem_file->id]); - } - }else{ - foreach (Yii::$app->request->get() as $key => $value) { - $tem_file = \common\models\ars\File::findOne(['alias' => $value]); - if ($tem_file) { - $img_id_arr = array_diff($img_id_arr, [$tem_file->id]); - } - } - } - $img_id_str = implode(',', $img_id_arr); - return $img_id_str; - } - - /** - * @return bool|false|string - * 加载已有的文件 - */ - public function actionImageFile() - { - //判断该类是否存在 - if(!class_exists('\common\models\ars\File')){ - return false; - } - - $file_id_str = Yii::$app->request->get('fileidstr'); - $file_id_arr = explode(',', $file_id_str); - $data = \common\models\ars\File::find()->where(['id' => $file_id_arr])->all(); - $res = array(); - if($data) { - $i = 0; - foreach ($data as $key => $value) { - $res[$i]['name'] = $value->alias; - $res[$i]['path'] = Yii::$app->request->hostInfo . '/' . $value->path; - $res[$i]['size'] = filesize($value->path); - $i++; - } - } - return json_encode($res); - } -} diff --git a/vendor/antgoods/goods/src/views/shopcategory/_form.php b/vendor/antgoods/goods/src/views/shop-category/_form.php similarity index 84% rename from vendor/antgoods/goods/src/views/shopcategory/_form.php rename to vendor/antgoods/goods/src/views/shop-category/_form.php index d213cda..9213502 100644 --- a/vendor/antgoods/goods/src/views/shopcategory/_form.php +++ b/vendor/antgoods/goods/src/views/shop-category/_form.php @@ -4,6 +4,8 @@ use yii\helpers\Html; use yii\bootstrap4\ActiveForm; use blobt\widgets\Icheck; use yii\helpers\Url; +use antgoods\goods\models\ars\Attribute; +use linyao\widgets\Select2; /* @var $this yii\web\View */ /* @var $model antgoods\goods\models\ars\ShopCategory */ @@ -36,7 +38,7 @@ use yii\helpers\Url; ], ])->label('类目图片') ?> - field($model, 'filter_attr')->textarea(['rows' => 6]) ?> + field($model, 'filter_attr')->widget(Select2::className(), ["items" => Attribute::modelColumn(), "promptText" => false, 'options' => ['multiple' => true, 'placeholder' => '请选择...'] ]) ?> field($model, 'is_show')->widget(Icheck::className(), ["items" => $model::$isShow, 'type' => "radio"]) ?> diff --git a/vendor/antgoods/goods/src/views/shopcategory/_search.php b/vendor/antgoods/goods/src/views/shop-category/_search.php similarity index 100% rename from vendor/antgoods/goods/src/views/shopcategory/_search.php rename to vendor/antgoods/goods/src/views/shop-category/_search.php diff --git a/vendor/antgoods/goods/src/views/shopcategory/create.php b/vendor/antgoods/goods/src/views/shop-category/create.php similarity index 100% rename from vendor/antgoods/goods/src/views/shopcategory/create.php rename to vendor/antgoods/goods/src/views/shop-category/create.php diff --git a/vendor/antgoods/goods/src/views/shopcategory/index.php b/vendor/antgoods/goods/src/views/shop-category/index.php similarity index 100% rename from vendor/antgoods/goods/src/views/shopcategory/index.php rename to vendor/antgoods/goods/src/views/shop-category/index.php diff --git a/vendor/antgoods/goods/src/views/shopcategory/update.php b/vendor/antgoods/goods/src/views/shop-category/update.php similarity index 100% rename from vendor/antgoods/goods/src/views/shopcategory/update.php rename to vendor/antgoods/goods/src/views/shop-category/update.php diff --git a/vendor/antgoods/goods/src/views/shopcategory/view.php b/vendor/antgoods/goods/src/views/shop-category/view.php similarity index 100% rename from vendor/antgoods/goods/src/views/shopcategory/view.php rename to vendor/antgoods/goods/src/views/shop-category/view.php