From a6b0bb31f6fa0291517c16086c95fc2464a3d41e Mon Sep 17 00:00:00 2001
From: vine_liutk <961510893@qq.com>
Date: Fri, 3 Dec 2021 13:35:55 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=95=86=E5=93=81=E7=AE=A1?=
=?UTF-8?q?=E7=90=86=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/Admin/Actions/Grid/ArticleList.php | 42 +++++------------
app/Admin/Actions/Grid/ReleaseCancel.php | 42 +++++++++--------
app/Admin/Actions/Grid/ReleaseDown.php | 42 +++++++++--------
app/Admin/Actions/Grid/ReleaseUp.php | 42 +++++++++--------
app/Admin/Actions/Grid/SkuList.php | 45 ++++++-------------
app/Admin/Actions/Grid/SkuSyncSpu.php | 42 +++++++++--------
app/Admin/Actions/Grid/SkuVerify.php | 28 +++++++-----
.../Controllers/ArticleCategoryController.php | 2 +-
.../Controllers/ProductSkuController.php | 12 +++--
.../Controllers/ProductSpuController.php | 8 ++--
.../Grid/Tools/Product/BatchReleaseCancel.php | 14 +++++-
.../Grid/Tools/Product/BatchReleaseDown.php | 14 +++++-
.../Grid/Tools/Product/BatchReleaseUp.php | 14 +++++-
.../Grid/Tools/Product/BatchSkuSyncSpu.php | 14 +++++-
.../Grid/Tools/Product/BatchSkuVerify.php | 14 +++++-
resources/lang/zh_CN/admin_message.php | 16 +++++++
16 files changed, 217 insertions(+), 174 deletions(-)
diff --git a/app/Admin/Actions/Grid/ArticleList.php b/app/Admin/Actions/Grid/ArticleList.php
index ba32f9e4..230fa18c 100644
--- a/app/Admin/Actions/Grid/ArticleList.php
+++ b/app/Admin/Actions/Grid/ArticleList.php
@@ -14,39 +14,15 @@ class ArticleList extends RowAction
/**
* @return string
*/
- protected $title = 'Title';
+ protected $title = '';
public function title()
{
if ($this->title) {
- return $this->title;
+ return $this->title.' '.__('admin.list');
}
- return ' '.__('admin.list').' ';
- }
-
- /**
- * Handle the action request.
- *
- * @param Request $request
- *
- * @return Response
- */
- public function handle(Request $request)
- {
- // dump($this->getKey());
-
- return $this->response()
- // ->success('Processed successfully: '.$this->getKey())
- ->redirect(admin_route('articles.index', ['category' =>$this->getKey()]));
- }
-
- /**
- * @return string|array|void
- */
- public function confirm()
- {
- // return ['Confirm?', 'contents'];
+ return __('admin.list');
}
/**
@@ -60,10 +36,16 @@ class ArticleList extends RowAction
}
/**
- * @return array
+ * Handle the action request.
+ *
+ * @param Request $request
+ *
+ * @return Response
*/
- protected function parameters()
+ public function handle(Request $request)
{
- return [];
+ return $this->response()
+ // ->success('Processed successfully: '.$this->getKey())
+ ->redirect(admin_route('articles.index', ['category' =>$this->getKey()]));
}
}
diff --git a/app/Admin/Actions/Grid/ReleaseCancel.php b/app/Admin/Actions/Grid/ReleaseCancel.php
index 5e4897a4..2619dd8e 100644
--- a/app/Admin/Actions/Grid/ReleaseCancel.php
+++ b/app/Admin/Actions/Grid/ReleaseCancel.php
@@ -5,9 +5,6 @@ namespace App\Admin\Actions\Grid;
use App\Models\ProductSku;
use Dcat\Admin\Actions\Response;
use Dcat\Admin\Grid\RowAction;
-use Dcat\Admin\Traits\HasPermissions;
-use Illuminate\Contracts\Auth\Authenticatable;
-use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Throwable;
@@ -17,7 +14,26 @@ class ReleaseCancel extends RowAction
/**
* @return string
*/
- protected $title = '取消上架申请';
+ protected $title = '';
+
+ public function title()
+ {
+ if ($this->title) {
+ return $this->title.' '.__('admin_message.actions.grid.release_cancel');
+ }
+
+ return __('admin_message.actions.grid.release_cancel');
+ }
+
+ /**
+ * @param Model|Authenticatable|HasPermissions|null $user
+ *
+ * @return bool
+ */
+ protected function authorize($user): bool
+ {
+ return $user->can('dcat.admin.product_skus.release_cancel');
+ }
/**
* Handle the action request.
@@ -47,22 +63,4 @@ class ReleaseCancel extends RowAction
{
return ['确认当前商品取消上架申请?'];
}
-
- /**
- * @param Model|Authenticatable|HasPermissions|null $user
- *
- * @return bool
- */
- protected function authorize($user): bool
- {
- return true;
- }
-
- /**
- * @return array
- */
- protected function parameters()
- {
- return [];
- }
}
diff --git a/app/Admin/Actions/Grid/ReleaseDown.php b/app/Admin/Actions/Grid/ReleaseDown.php
index 36d51152..aff65a9a 100644
--- a/app/Admin/Actions/Grid/ReleaseDown.php
+++ b/app/Admin/Actions/Grid/ReleaseDown.php
@@ -5,9 +5,6 @@ namespace App\Admin\Actions\Grid;
use App\Models\ProductSku;
use Dcat\Admin\Actions\Response;
use Dcat\Admin\Grid\RowAction;
-use Dcat\Admin\Traits\HasPermissions;
-use Illuminate\Contracts\Auth\Authenticatable;
-use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Throwable;
@@ -17,7 +14,26 @@ class ReleaseDown extends RowAction
/**
* @return string
*/
- protected $title = '下架商品';
+ protected $title = '';
+
+ public function title()
+ {
+ if ($this->title) {
+ return $this->title.' '.__('admin_message.actions.grid.release_down');
+ }
+
+ return __('admin_message.actions.grid.release_down');
+ }
+
+ /**
+ * @param Model|Authenticatable|HasPermissions|null $user
+ *
+ * @return bool
+ */
+ protected function authorize($user): bool
+ {
+ return $user->can('dcat.admin.product_skus.release_down');
+ }
/**
* Handle the action request.
@@ -47,22 +63,4 @@ class ReleaseDown extends RowAction
{
return ['确认当前商品下架?'];
}
-
- /**
- * @param Model|Authenticatable|HasPermissions|null $user
- *
- * @return bool
- */
- protected function authorize($user): bool
- {
- return true;
- }
-
- /**
- * @return array
- */
- protected function parameters()
- {
- return [];
- }
}
diff --git a/app/Admin/Actions/Grid/ReleaseUp.php b/app/Admin/Actions/Grid/ReleaseUp.php
index 941cfe85..837bc406 100644
--- a/app/Admin/Actions/Grid/ReleaseUp.php
+++ b/app/Admin/Actions/Grid/ReleaseUp.php
@@ -5,9 +5,6 @@ namespace App\Admin\Actions\Grid;
use App\Models\ProductSku;
use Dcat\Admin\Actions\Response;
use Dcat\Admin\Grid\RowAction;
-use Dcat\Admin\Traits\HasPermissions;
-use Illuminate\Contracts\Auth\Authenticatable;
-use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Throwable;
@@ -17,7 +14,26 @@ class ReleaseUp extends RowAction
/**
* @return string
*/
- protected $title = '上架申请';
+ protected $title = '';
+
+ public function title()
+ {
+ if ($this->title) {
+ return $this->title.' '.__('admin_message.actions.grid.release_up');
+ }
+
+ return __('admin_message.actions.grid.release_up');
+ }
+
+ /**
+ * @param Model|Authenticatable|HasPermissions|null $user
+ *
+ * @return bool
+ */
+ protected function authorize($user): bool
+ {
+ return $user->can('dcat.admin.product_skus.release_up');
+ }
/**
* Handle the action request.
@@ -47,22 +63,4 @@ class ReleaseUp extends RowAction
{
return ['确认当前商品提交上架申请?'];
}
-
- /**
- * @param Model|Authenticatable|HasPermissions|null $user
- *
- * @return bool
- */
- protected function authorize($user): bool
- {
- return true;
- }
-
- /**
- * @return array
- */
- protected function parameters()
- {
- return [];
- }
}
diff --git a/app/Admin/Actions/Grid/SkuList.php b/app/Admin/Actions/Grid/SkuList.php
index e2ba8a2f..f07a2e09 100644
--- a/app/Admin/Actions/Grid/SkuList.php
+++ b/app/Admin/Actions/Grid/SkuList.php
@@ -4,9 +4,6 @@ namespace App\Admin\Actions\Grid;
use Dcat\Admin\Actions\Response;
use Dcat\Admin\Grid\RowAction;
-use Dcat\Admin\Traits\HasPermissions;
-use Illuminate\Contracts\Auth\Authenticatable;
-use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
class SkuList extends RowAction
@@ -14,15 +11,25 @@ class SkuList extends RowAction
/**
* @return string
*/
- protected $title = 'Title';
+ protected $title = '';
public function title()
{
if ($this->title) {
- return $this->title;
+ return $this->title.' '.__('admin.list');
}
- return ' '.__('admin.list').' ';
+ return __('admin.list');
+ }
+
+ /**
+ * @param Model|Authenticatable|HasPermissions|null $user
+ *
+ * @return bool
+ */
+ protected function authorize($user): bool
+ {
+ return $user->can('dcat.admin.product_skus.index');
}
/**
@@ -40,30 +47,4 @@ class SkuList extends RowAction
// ->success('Processed successfully: '.$this->getKey())
->redirect(admin_route('product_spus.list', ['spu' =>$this->getKey()]));
}
-
- /**
- * @return string|array|void
- */
- public function confirm()
- {
- // return ['Confirm?', 'contents'];
- }
-
- /**
- * @param Model|Authenticatable|HasPermissions|null $user
- *
- * @return bool
- */
- protected function authorize($user): bool
- {
- return $user->can('dcat.admin.product_skus.index');
- }
-
- /**
- * @return array
- */
- protected function parameters()
- {
- return [];
- }
}
diff --git a/app/Admin/Actions/Grid/SkuSyncSpu.php b/app/Admin/Actions/Grid/SkuSyncSpu.php
index f54cc722..a8ee94a0 100644
--- a/app/Admin/Actions/Grid/SkuSyncSpu.php
+++ b/app/Admin/Actions/Grid/SkuSyncSpu.php
@@ -5,9 +5,6 @@ namespace App\Admin\Actions\Grid;
use App\Models\ProductSku;
use Dcat\Admin\Actions\Response;
use Dcat\Admin\Grid\RowAction;
-use Dcat\Admin\Traits\HasPermissions;
-use Illuminate\Contracts\Auth\Authenticatable;
-use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Throwable;
@@ -17,7 +14,26 @@ class SkuSyncSpu extends RowAction
/**
* @return string
*/
- protected $title = '同步主商品';
+ protected $title = '';
+
+ public function title()
+ {
+ if ($this->title) {
+ return $this->title.' '.__('admin_message.actions.grid.sku_sync_spu');
+ }
+
+ return __('admin_message.actions.grid.sku_sync_spu');
+ }
+
+ /**
+ * @param Model|Authenticatable|HasPermissions|null $user
+ *
+ * @return bool
+ */
+ protected function authorize($user): bool
+ {
+ return $user->can('dcat.admin.product_skus.sku_sync_spu');
+ }
/**
* Handle the action request.
@@ -47,22 +63,4 @@ class SkuSyncSpu extends RowAction
{
return ['确认当前商品同步主商品信息?'];
}
-
- /**
- * @param Model|Authenticatable|HasPermissions|null $user
- *
- * @return bool
- */
- protected function authorize($user): bool
- {
- return $user->can('dcat.admin.product_skus.sku_sync_spu');
- }
-
- /**
- * @return array
- */
- protected function parameters()
- {
- return [];
- }
}
diff --git a/app/Admin/Actions/Grid/SkuVerify.php b/app/Admin/Actions/Grid/SkuVerify.php
index 0bd620a6..d36b3a4e 100644
--- a/app/Admin/Actions/Grid/SkuVerify.php
+++ b/app/Admin/Actions/Grid/SkuVerify.php
@@ -4,26 +4,22 @@ namespace App\Admin\Actions\Grid;
use App\Admin\Forms\SkuVerify as SkuVerifyForm;
use Dcat\Admin\Grid\RowAction;
-use Dcat\Admin\Traits\HasPermissions;
use Dcat\Admin\Widgets\Modal;
-use Illuminate\Contracts\Auth\Authenticatable;
-use Illuminate\Database\Eloquent\Model;
class SkuVerify extends RowAction
{
/**
* @return string
*/
- protected $title = '审核商品';
+ protected $title = '';
- public function render()
+ public function title()
{
- $form = SkuVerifyForm::make()->payload(['id'=>$this->getKey()]);
- return Modal::make()
- ->lg()
- ->title($this->title)
- ->body($form)
- ->button($this->title);
+ if ($this->title) {
+ return $this->title.' '.__('admin_message.actions.grid.sku_verify');
+ }
+
+ return __('admin_message.actions.grid.sku_verify');
}
/**
@@ -35,4 +31,14 @@ class SkuVerify extends RowAction
{
return $user->can('dcat.admin.product_sku_verifies.verify');
}
+
+ public function render()
+ {
+ $form = SkuVerifyForm::make()->payload(['id'=>$this->getKey()]);
+ return Modal::make()
+ ->lg()
+ ->title($this->title)
+ ->body($form)
+ ->button($this->title);
+ }
}
diff --git a/app/Admin/Controllers/ArticleCategoryController.php b/app/Admin/Controllers/ArticleCategoryController.php
index dbb5288f..6c1178dd 100644
--- a/app/Admin/Controllers/ArticleCategoryController.php
+++ b/app/Admin/Controllers/ArticleCategoryController.php
@@ -63,7 +63,7 @@ class ArticleCategoryController extends AdminController
$grid->actions(function (Grid\Displayers\Actions $actions) {
$actions->disableDelete(Admin::user()->cannot('dcat.admin.article_categories.destroy'));
if (Admin::user()->can('dcat.admin.articles.index')) {
- $actions->prepend(new ArticleList(__('admin.list')));
+ $actions->prepend(new ArticleList());
}
});
diff --git a/app/Admin/Controllers/ProductSkuController.php b/app/Admin/Controllers/ProductSkuController.php
index 3b918b74..94aed147 100644
--- a/app/Admin/Controllers/ProductSkuController.php
+++ b/app/Admin/Controllers/ProductSkuController.php
@@ -79,15 +79,15 @@ class ProductSkuController extends AdminController
if (Admin::user()->can('dcat.admin.product_skus.release_up')) {
$actions->append(new ReleaseUp());
}
- if (Admin::user()->can('dcat.admin.product_skus.sku_sync_spu')) {
- $actions->append(new SkuSyncSpu());
- }
}
if ($actions->row->verify_state == 1) {
if (Admin::user()->can('dcat.admin.product_skus.release_cancel')) {
$actions->append(new ReleaseCancel());
}
}
+ if (Admin::user()->can('dcat.admin.product_skus.sku_sync_spu')) {
+ $actions->append(new SkuSyncSpu());
+ }
}
if ($actions->row->release_at) {//已上架
if (Admin::user()->can('dcat.admin.product_skus.release_down')) {
@@ -177,6 +177,12 @@ class ProductSkuController extends AdminController
$form->divider();
$form->select('attr_group')->options(ProductGroup::all()->pluck('name', 'id'));
$form->selectAttr('attrs')->listen('attr_group');
+ $form->hidden('verify_state');
+ $form->saving(function (Form $form) {
+ $form->verify_state = 0;
+ });
+
+
$form->ignore(['attr_group']);
$form->display('created_at');
diff --git a/app/Admin/Controllers/ProductSpuController.php b/app/Admin/Controllers/ProductSpuController.php
index 71506072..329589a9 100644
--- a/app/Admin/Controllers/ProductSpuController.php
+++ b/app/Admin/Controllers/ProductSpuController.php
@@ -65,7 +65,7 @@ class ProductSpuController extends AdminController
$actions->disableEdit(Admin::user()->cannot('dcat.admin.product_spus.edit'));
$actions->disableDelete(Admin::user()->cannot('dcat.admin.product_spus.destroy'));
if (Admin::user()->can('dcat.admin.product_spus.list')) {
- $actions->prepend(new SkuList(__('admin.list')));
+ $actions->prepend(new SkuList());
}
});
@@ -253,15 +253,15 @@ class ProductSpuController extends AdminController
if (Admin::user()->can('dcat.admin.product_skus.release_up')) {
$actions->append(new ReleaseUp());
}
- if (Admin::user()->can('dcat.admin.product_skus.sku_sync_spu')) {
- $actions->append(new SkuSyncSpu());
- }
}
if ($actions->row->verify_state == 1) {
if (Admin::user()->can('dcat.admin.product_skus.release_cancel')) {
$actions->append(new ReleaseCancel());
}
}
+ if (Admin::user()->can('dcat.admin.product_skus.sku_sync_spu')) {
+ $actions->append(new SkuSyncSpu());
+ }
}
if ($actions->row->release_at) {//已上架
if (Admin::user()->can('dcat.admin.product_skus.release_down')) {
diff --git a/app/Admin/Extensions/Grid/Tools/Product/BatchReleaseCancel.php b/app/Admin/Extensions/Grid/Tools/Product/BatchReleaseCancel.php
index 7f8ab5c0..40e7e55c 100644
--- a/app/Admin/Extensions/Grid/Tools/Product/BatchReleaseCancel.php
+++ b/app/Admin/Extensions/Grid/Tools/Product/BatchReleaseCancel.php
@@ -10,7 +10,19 @@ use Throwable;
class BatchReleaseCancel extends BatchAction
{
- protected $title = '取消上架审核';
+ /**
+ * @return string
+ */
+ protected $title = '';
+
+ public function title()
+ {
+ if ($this->title) {
+ return $this->title.' '.__('admin_message.extensions.grid.batch.release_cancel');
+ }
+
+ return __('admin_message.extensions.grid.batch.release_cancel');
+ }
protected function authorize($user): bool
{
diff --git a/app/Admin/Extensions/Grid/Tools/Product/BatchReleaseDown.php b/app/Admin/Extensions/Grid/Tools/Product/BatchReleaseDown.php
index d72ddafe..f920e4b0 100644
--- a/app/Admin/Extensions/Grid/Tools/Product/BatchReleaseDown.php
+++ b/app/Admin/Extensions/Grid/Tools/Product/BatchReleaseDown.php
@@ -10,7 +10,19 @@ use Throwable;
class BatchReleaseDown extends BatchAction
{
- protected $title = '下架操作';
+ /**
+ * @return string
+ */
+ protected $title = '';
+
+ public function title()
+ {
+ if ($this->title) {
+ return $this->title.' '.__('admin_message.extensions.grid.batch.release_down');
+ }
+
+ return __('admin_message.extensions.grid.batch.release_down');
+ }
protected function authorize($user): bool
{
diff --git a/app/Admin/Extensions/Grid/Tools/Product/BatchReleaseUp.php b/app/Admin/Extensions/Grid/Tools/Product/BatchReleaseUp.php
index 7d4dbae1..f9545fcb 100644
--- a/app/Admin/Extensions/Grid/Tools/Product/BatchReleaseUp.php
+++ b/app/Admin/Extensions/Grid/Tools/Product/BatchReleaseUp.php
@@ -10,7 +10,19 @@ use Throwable;
class BatchReleaseUp extends BatchAction
{
- protected $title = '上架审核';
+ /**
+ * @return string
+ */
+ protected $title = '';
+
+ public function title()
+ {
+ if ($this->title) {
+ return $this->title.' '.__('admin_message.extensions.grid.batch.release_up');
+ }
+
+ return __('admin_message.extensions.grid.batch.release_up');
+ }
protected function authorize($user): bool
{
diff --git a/app/Admin/Extensions/Grid/Tools/Product/BatchSkuSyncSpu.php b/app/Admin/Extensions/Grid/Tools/Product/BatchSkuSyncSpu.php
index 75eec8ed..98fbe9d1 100644
--- a/app/Admin/Extensions/Grid/Tools/Product/BatchSkuSyncSpu.php
+++ b/app/Admin/Extensions/Grid/Tools/Product/BatchSkuSyncSpu.php
@@ -10,7 +10,19 @@ use Throwable;
class BatchSkuSyncSpu extends BatchAction
{
- protected $title = '同步主商品';
+ /**
+ * @return string
+ */
+ protected $title = '';
+
+ public function title()
+ {
+ if ($this->title) {
+ return $this->title.' '.__('admin_message.extensions.grid.batch.sku_sync_spu');
+ }
+
+ return __('admin_message.extensions.grid.batch.sku_sync_spu');
+ }
/**
* 是否有权限判断.
diff --git a/app/Admin/Extensions/Grid/Tools/Product/BatchSkuVerify.php b/app/Admin/Extensions/Grid/Tools/Product/BatchSkuVerify.php
index 0f10f80a..0b60adf0 100644
--- a/app/Admin/Extensions/Grid/Tools/Product/BatchSkuVerify.php
+++ b/app/Admin/Extensions/Grid/Tools/Product/BatchSkuVerify.php
@@ -8,7 +8,19 @@ use Dcat\Admin\Widgets\Modal;
class BatchSkuVerify extends BatchAction
{
- protected $title = '批量审核';
+ /**
+ * @return string
+ */
+ protected $title = '';
+
+ public function title()
+ {
+ if ($this->title) {
+ return $this->title.' '.__('admin_message.extensions.grid.batch.sku_verify');
+ }
+
+ return __('admin_message.extensions.grid.batch.sku_verify');
+ }
/**
* 是否有权限判断.
diff --git a/resources/lang/zh_CN/admin_message.php b/resources/lang/zh_CN/admin_message.php
index ad8e8100..e24fbb04 100644
--- a/resources/lang/zh_CN/admin_message.php
+++ b/resources/lang/zh_CN/admin_message.php
@@ -31,6 +31,13 @@ return [
'init_sku_by_specs'=>'初始化SKU',
'add_sku'=>'添加SKU',
],
+ 'batch'=>[
+ 'release_up'=>'批量上架申请',
+ 'release_down'=>'批量商品下架',
+ 'release_cancel'=>'批量取消申请',
+ 'sku_sync_spu'=>'批量同步主商品',
+ 'sku_verify'=>'批量审核',
+ ],
'init_sku_by_specs'=>[
'confirm'=>[
'title'=>'初始化SKU',
@@ -55,4 +62,13 @@ return [
],
],
],
+ 'actions'=>[
+ 'grid' =>[
+ 'release_cancel'=>'取消上架申请',
+ 'release_down'=>'商品下架',
+ 'release_up'=>'申请上架',
+ 'sku_sync_spu'=>'同步主商品',
+ 'sku_verify'=>'商品审核',
+ ],
+ ],
];