From 99ce32cc46607c38d3ff2ca793547eb35a6e388d Mon Sep 17 00:00:00 2001 From: 648132694@qq.com <ysx@ichunt.com> Date: Tue, 30 Apr 2024 15:25:10 +0800 Subject: [PATCH] 标签获取方式兼容华云 --- app/Http/Controllers/Api/SkuApiController.php | 3 ++- app/Http/Services/SkuService.php | 7 ++++--- resources/views/script/BatchAddSkuTagScript.blade.php | 4 ++-- resources/views/script/BatchAddTagScript.blade.php | 2 +- resources/views/script/SkuListScript.blade.php | 12 +++++++++++- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/Api/SkuApiController.php b/app/Http/Controllers/Api/SkuApiController.php index 23911d6..53faf6a 100644 --- a/app/Http/Controllers/Api/SkuApiController.php +++ b/app/Http/Controllers/Api/SkuApiController.php @@ -180,8 +180,9 @@ class SkuApiController extends Controller //获取所有系统标签 public function GetSystemTagList($request) { + $orgId = $request->input('org_id'); $skuService = new SkuService(); - $data = $skuService->getSystemTags(); + $data = $skuService->getSystemTags($orgId); $this->response(0, 'ok', $data, count($data)); } diff --git a/app/Http/Services/SkuService.php b/app/Http/Services/SkuService.php index 9406dbc..c02a9ac 100644 --- a/app/Http/Services/SkuService.php +++ b/app/Http/Services/SkuService.php @@ -85,9 +85,9 @@ class SkuService } } } - $standardBrandId = array_get($spu,'s_brand_id'); + $standardBrandId = array_get($spu, 's_brand_id'); if ($standardBrandId) { - $standardBrand = $redis->hget('standard_brand',$standardBrandId); + $standardBrand = $redis->hget('standard_brand', $standardBrandId); $standardBrand = json_decode($standardBrand, true); $sku['standard_brand_name'] = $standardBrand['brand_name']; } @@ -338,9 +338,10 @@ class SkuService return $result; } - public function getSystemTags() + public function getSystemTags($orgId = 1) { $tags = TagsModel::where('tag_use', 16)->where('tag_type', 2)->where('status', TagsModel::STATUS_OK) + ->where('org_id', $orgId) ->pluck('tag_name', 'tag_name')->toArray(); $result = []; foreach ($tags as $key => $value) { diff --git a/resources/views/script/BatchAddSkuTagScript.blade.php b/resources/views/script/BatchAddSkuTagScript.blade.php index 4717295..3032ffc 100644 --- a/resources/views/script/BatchAddSkuTagScript.blade.php +++ b/resources/views/script/BatchAddSkuTagScript.blade.php @@ -43,7 +43,7 @@ function getTagOption(element) { //获取系统标签列表 - let url = '/api/sku/GetSystemTagList'; + let url = '/api/sku/GetSystemTagList?org_id=' + getQueryVariable('org_id'); let tagResult = ajax(url); let tagList = tagResult.data; return { @@ -75,4 +75,4 @@ let systemTagOption = getTagOption('sku_tags_selector', 2); let tagSelector = xmSelect.render(systemTagOption); }); -</script> \ No newline at end of file +</script> diff --git a/resources/views/script/BatchAddTagScript.blade.php b/resources/views/script/BatchAddTagScript.blade.php index 8e9dce3..87a9982 100644 --- a/resources/views/script/BatchAddTagScript.blade.php +++ b/resources/views/script/BatchAddTagScript.blade.php @@ -119,4 +119,4 @@ $(this).parents('tr').remove(); }); }); -</script> \ No newline at end of file +</script> diff --git a/resources/views/script/SkuListScript.blade.php b/resources/views/script/SkuListScript.blade.php index 78378d3..8360dbc 100644 --- a/resources/views/script/SkuListScript.blade.php +++ b/resources/views/script/SkuListScript.blade.php @@ -434,10 +434,20 @@ let checkStatus = table.checkStatus('skuList'); let data = checkStatus.data; let skuIds = Array.from(data, ({goods_id}) => goods_id); + if (skuIds.length === 0) { + parent.layer.msg('请选择要操作的sku', {icon: 5}); + return false; + } + let orgIds = Array.from(data, ({org_id}) => org_id); + orgIds = [...new Set(orgIds)] + if (orgIds.length > 1) { + parent.layer.msg('只能操作相同组织的sku', {icon: 5}); + return false; + } skuIds = skuIds.join(','); layer.open({ type: 2, - content: '/sku/BatchAddSkuTag?view=iframe&sku_ids=' + skuIds, + content: '/sku/BatchAddSkuTag?view=iframe&sku_ids=' + skuIds + '&org_id=' + orgIds[0], area: ['800px', '600px'], title: '批量设置SKU标签', end: function () { -- libgit2 0.25.0