Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
liexin_supplier
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
18006628
authored
Jun 14, 2023
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
批量添加主营品牌
parent
7f2699d3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
113 additions
and
88 deletions
.gitignore
app/Http/Controllers/Api/SupplierApiController.php
app/Http/Services/StandardBrandService.php
public/plugins/assets/js/common.js
public/plugins/common.js
resources/views/script/supplier/SupplierBaseScript.blade.php
resources/views/web/AddSupplier.blade.php
resources/views/web/supplier/SupplierBase.blade.php
vendor/_laravel_idea/_ide_helper_facades.php
.gitignore
View file @
18006628
...
...
@@ -5,4 +5,5 @@ Homestead.json
/.idea
/.vscode
/.history
/vendor/_laravel_idea/*
/vendor/_laravel_idea
app/Http/Controllers/Api/SupplierApiController.php
View file @
18006628
...
...
@@ -7,6 +7,7 @@ use App\Http\Controllers\Filter\SupplierFilter;
use
App\Http\Services\AdminUserService
;
use
App\Http\Services\CompanyService
;
use
App\Http\Services\LogService
;
use
App\Http\Services\StandardBrandService
;
use
App\Http\Services\SupplierAuditService
;
use
App\Http\Services\SupplierService
;
use
App\Http\Services\SupplierStatisticsService
;
...
...
@@ -724,4 +725,12 @@ class SupplierApiController extends Controller
$this
->
response
(
0
,
'查询成功'
,
$supplier
);
}
//批量获取需要新增主营品牌信息
public
function
getBatchAddMainBrandsData
(
$request
)
{
$standardBrandNames
=
$request
->
input
(
'standard_brand_names'
);
$result
=
(
new
StandardBrandService
())
->
getBatchAddMainBrandsData
(
$standardBrandNames
);
$this
->
response
(
0
,
'ok'
,
$result
);
}
}
app/Http/Services/StandardBrandService.php
View file @
18006628
...
...
@@ -88,4 +88,11 @@ class StandardBrandService
}
return
$result
?:
[];
}
public
function
getBatchAddMainBrandsData
(
$standardBrandNames
)
{
$standardBrandNames
=
explode
(
','
,
trim
(
$standardBrandNames
,
','
));
$standardBrandIds
=
StandardBrandModel
::
whereIn
(
'brand_name'
,
$standardBrandNames
)
->
pluck
(
'standard_brand_id'
)
->
toArray
();
return
$this
->
getBrandInitValue
(
implode
(
','
,
$standardBrandIds
));
}
}
\ No newline at end of file
public/plugins/assets/js/common.js
View file @
18006628
...
...
@@ -114,3 +114,31 @@ function getLogDomain() {
}
function
arrayColumn
(
arr
,
column
)
{
return
arr
.
map
(
function
(
row
)
{
return
row
[
column
];
});
}
//数组去重
function
arrayUnique
(
arr
)
{
var
res
=
[];
for
(
var
i
=
0
,
len
=
arr
.
length
;
i
<
len
;
i
++
)
{
var
item
=
arr
[
i
];
for
(
var
j
=
0
,
jLen
=
res
.
length
;
j
<
jLen
;
j
++
)
{
if
(
item
==
res
[
j
])
break
;
}
if
(
j
==
jLen
)
res
.
push
(
item
);
}
return
res
;
}
function
multiArrayUnique
(
arr
)
{
return
arr
.
filter
(
function
(
item
,
index
)
{
const
json
=
JSON
.
stringify
(
item
);
return
arr
.
findIndex
(
function
(
subItem
)
{
return
JSON
.
stringify
(
subItem
)
===
json
;
})
===
index
;
});
}
\ No newline at end of file
public/plugins/common.js
View file @
18006628
...
...
@@ -71,3 +71,5 @@ function ajax(url,data){
})
return
result
;
}
resources/views/script/supplier/SupplierBaseScript.blade.php
View file @
18006628
...
...
@@ -163,35 +163,6 @@
}
});
// //主营品牌限制的初始化
// let mainBrandsLimitTypeObj = $('#main_brands_limit_type');
// if (supplierId) {
// let mainBrandsLimitObj = $('#main_brands_limit');
// if (mainBrandsLimitObj.val() == -1) {
// mainBrandsLimitTypeObj.val(2);
// mainBrandsLimitObj.val('');
// mainBrandsLimitObj.attr('disabled', true);
// mainBrandsLimitObj.addClass('layui-disabled');
// form.render('select');
// }
// }
{{
--
let
supplierGroupMap
=
{
!!
json_encode
(
config
(
'fixed.SupplierGroup'
))
!!
};
--
}}
{{
--
let
limitMap
=
{
!!
json_encode
(
config
(
'field.SupplierGroupMainBrandsLimitMap'
))
!!
};
--
}}
{{
--
//监听主营品牌限制的数字,不同供应商性质的数量限制不一样--}}
{{
--
$
(
document
).
on
(
'change'
,
'#main_brands_limit'
,
function
()
{
--
}}
{{
--
let
supplierGroup
=
$
(
'#supplier_group'
).
val
();
--
}}
{{
--
if
(
!
supplierGroup
)
{
--
}}
{{
--
layer
.
msg
(
"请先选择供应商性质"
,
{
icon
:
5
});
--
}}
{{
--
$
(
'#main_brands_limit'
).
val
(
''
);
--
}}
{{
--
return
false
;
--
}}
{{
--
}
--
}}
{{
--
let
limit
=
limitMap
[
supplierGroup
];
--
}}
{{
--
if
(
$
(
this
).
val
()
>
limit
&&
limit
!==
-
1
)
{
--
}}
{{
--
layer
.
msg
(
"供应商性质为"
+
supplierGroupMap
[
supplierGroup
]
+
"时,主营品牌数量最大可以设置为 "
+
limit
,
{
icon
:
5
});
--
}}
{{
--
$
(
'#main_brands_limit'
).
val
(
limit
);
--
}}
{{
--
}
--
}}
{{
--
});
--
}}
//监听供应商性质选择,如果为混合分销商,那么要展示混合分销商品牌设置
form
.
on
(
'select(supplier_group)'
,
function
(
data
)
{
...
...
@@ -200,39 +171,8 @@
}
else
{
$
(
'#agency_brands_div'
).
hide
();
}
// // 这里还要去判断主营品牌数量限制的切换
// // 原厂,代理商,分销平台,品牌数量不做限制;默认为“无限制”;
// // 混合分销商,现货商,代工厂,品牌数量默认为10;
// // 方案商,其他,品牌数量默认为5;
// let mainBrandsLimitObj = $('#main_brands_limit');
// let limit = limitMap[data.value];
// console.log(limit)
// if (limit === -1) {
// mainBrandsLimitObj.attr('disabled', true);
// mainBrandsLimitObj.addClass('layui-disabled');
// mainBrandsLimitTypeObj.val(2);
// } else {
// mainBrandsLimitObj.attr('disabled', false);
// mainBrandsLimitObj.removeClass('layui-disabled');
// mainBrandsLimitTypeObj.val(1);
// }
// form.render('select');
//
// mainBrandsLimitObj.val(limit === -1 ? '' : limit);
});
// form.on('select(main_brands_limit_type)', function (data) {
// let mainBrandsLimitObj = $('#main_brands_limit');
// if (data.value == 2) {
// mainBrandsLimitObj.attr('disabled', true);
// mainBrandsLimitObj.addClass('layui-disabled');
// } else {
// mainBrandsLimitObj.attr('disabled', false);
// mainBrandsLimitObj.removeClass('layui-disabled');
// }
// });
//如果没有直接忽略公司校验的权限,那么就要做到下面的互相disable
@
if
(
!
checkPerm
(
'IgnoreCompanyCheck'
))
//修改供应商名称,那么公司税号就禁用,反之亦然
...
...
@@ -335,6 +275,44 @@
let
brandInitValue
=
{
!!
json_encode
(
$brand_init_value
?:[])
!!
};
brandSelector
.
setValue
(
brandInitValue
);
//批量新增主营品牌
$
(
'#batchAddMainBrands'
).
click
(
function
()
{
layer
.
open
({
title
:
"批量增加主营品牌"
,
area
:
[
'600px'
,
'400px'
],
type
:
1
,
content
:
$
(
'#batchAddMainBrandsDiv'
)
});
});
$
(
'#confirmBatchAddMainBrands'
).
click
(
function
()
{
let
standardBrandNames
=
$
(
'#batchAddMainBrandsTextarea'
).
val
();
//请求接口获取返回的数据,并且合并目前选择的主营品牌,重新渲染xm-select
let
res
=
ajax
(
'/api/supplier/getBatchAddMainBrandsData'
,
{
standard_brand_names
:
standardBrandNames
});
let
data
=
res
.
data
;
let
brandNames
=
arrayColumn
(
data
,
'brand_name'
).
join
(
','
)
$
(
'#batchAddMainBrandsBlockQuote'
).
text
(
brandNames
);
if
(
data
.
length
===
0
)
{
layer
.
msg
(
'没有匹配到有效的标准品牌'
,{
icon
:
5
});
return
false
;
}
else
{
brandInitValue
=
brandInitValue
.
concat
(
data
);
brandInitValue
=
multiArrayUnique
(
brandInitValue
);
brandSelector
.
setValue
(
brandInitValue
);
$
(
'#main_brands'
).
val
(
arrayColumn
(
brandInitValue
,
'brand_id'
).
join
(
','
));
$
(
'#batchAddMainBrandsTextarea'
).
val
(
''
);
$
(
'#batchAddMainBrandsBlockQuote'
).
text
(
''
);
layer
.
msg
(
'批量添加主营品牌成功'
,{
icon
:
6
});
}
});
$
(
'#closeBatchAddMainBrands'
).
click
(
function
()
{
$
(
'#batchAddMainBrandsTextarea'
).
val
(
''
);
$
(
'#batchAddMainBrandsBlockQuote'
).
text
(
''
);
layer
.
closeAll
();
});
//代理品牌的渲染
let
agencyBrandOption
=
getBrandOption
(
'agency_brand_selector'
,
'agency_brands'
);
let
agencyBrandSelector
=
xmSelect
.
render
(
agencyBrandOption
);
...
...
resources/views/web/AddSupplier.blade.php
View file @
18006628
...
...
@@ -219,23 +219,21 @@
<input
type=
"hidden"
name=
"main_brands"
value=
""
id=
"main_brands"
>
</div>
<a
style=
"color: #009688;"
id=
"batchAddMainBrands"
>
+批量增加主营品牌
</a>
<div
id=
"batchAddMainBrandsDiv"
style=
"padding-left: 30px;padding-top: 30px;padding-right: 30px;display: none"
>
<div
class=
"layui-col-md12"
>
<textarea
rows=
"7"
placeholder=
"标准品牌名称,多个用英文逗号隔开"
class=
"layui-textarea"
id=
"batchAddMainBrandsTextarea"
></textarea>
<blockquote
class=
"layui-elem-quote"
id=
"batchAddMainBrandsBlockQuote"
></blockquote>
<span
style=
"color: red"
id=
"invalid_${name}_name_list"
></span>
</div>
<div
class=
"layui-col-md12"
>
<button
class=
"layui-btn layui-btn-sm"
type=
"button"
id=
"confirmBatchAddMainBrands"
>
验证并且添加
</button>
<button
class=
"layui-btn layui-btn-sm layui-btn-primary"
type=
"button"
id=
"closeBatchAddMainBrands"
>
关闭
</button>
</div>
</div>
</div>
{{--
<div
class=
"layui-col-md4"
>
--}}
{{--
<label
class=
"layui-form-label"
style=
"width: 100px"
>
主营品牌数量:
</label>
--}}
{{--
<div
class=
"layui-input-inline"
style=
"width: 150px"
>
--}}
{{--
<input
type=
"text"
name=
"main_brands_limit"
id=
"main_brands_limit"
--
}}
{{
--
placeholder=
"请输入主营品牌数量限制"
class=
"layui-input"
value=
""
>
--}}
{{--
</div>
--}}
{{--
<div
class=
"layui-inline"
>
--}}
{{--
<select
id=
"main_brands_limit_type"
lay-filter=
"main_brands_limit_type"
name=
"main_brands_limit_type"
>
--}}
{{--
<option
value=
"1"
>
自定义
</option>
--}}
{{--
<option
value=
"2"
>
无限制
</option>
--}}
{{--
</select>
--}}
{{--
</div>
--}}
{{--
</div>
--}}
</div>
{{--选择“混合分销商”时,在主营品牌下面新增一栏“代理品牌”;代理品牌取值同主营品牌一样--}}
<div
class=
"layui-form-item"
id=
"agency_brands_div"
style=
"display: none"
>
<label
class=
"layui-form-label"
>
<span
class=
"require"
>
*
</span>
...
...
resources/views/web/supplier/SupplierBase.blade.php
View file @
18006628
...
...
@@ -223,20 +223,20 @@
<input
type=
"hidden"
name=
"main_brands"
value=
""
id=
"main_brands"
value=
"{{$supplier['main_brands'] or ''}}"
>
</div>
<a
style=
"color: #009688;"
id=
"batchAddMainBrands"
>
+批量增加主营品牌
</a>
<div
id=
"batchAddMainBrandsDiv"
style=
"padding-left: 30px;padding-top: 30px;padding-right: 30px;display: none"
>
<div
class=
"layui-col-md12"
>
<textarea
rows=
"7"
placeholder=
"标准品牌名称,多个用英文逗号隔开"
class=
"layui-textarea"
id=
"batchAddMainBrandsTextarea"
></textarea>
<blockquote
class=
"layui-elem-quote"
id=
"batchAddMainBrandsBlockQuote"
></blockquote>
<span
style=
"color: red"
id=
"invalid_${name}_name_list"
></span>
</div>
<div
class=
"layui-col-md12"
>
<button
class=
"layui-btn layui-btn-sm"
type=
"button"
id=
"confirmBatchAddMainBrands"
>
验证并且添加
</button>
<button
class=
"layui-btn layui-btn-sm layui-btn-primary"
type=
"button"
id=
"closeBatchAddMainBrands"
>
关闭
</button>
</div>
</div>
</div>
{{--
<div
class=
"layui-col-md4"
>
--}}
{{--
<label
class=
"layui-form-label"
style=
"width: 100px"
>
主营品牌数量:
</label>
--}}
{{--
<div
class=
"layui-input-inline"
style=
"width: 150px"
>
--}}
{{--
<input
type=
"text"
name=
"main_brands_limit"
id=
"main_brands_limit"
--
}}
{{
--
placeholder=
"请输入主营品牌数量限制"
class=
"layui-input"
value=
"{{$supplier['main_brands_limit'] or ''}}"
>
--}}
{{--
</div>
--}}
{{--
<div
class=
"layui-inline"
>
--}}
{{--
<select
id=
"main_brands_limit_type"
name=
"main_brands_limit_type"
lay-filter=
"main_brands_limit_type"
>
--}}
{{--
<option
value=
"1"
>
自定义
</option>
--}}
{{--
<option
value=
"2"
>
无限制
</option>
--}}
{{--
</select>
--}}
{{--
</div>
--}}
{{--
</div>
--}}
</div>
{{--选择“混合分销商”时,在主营品牌下面新增一栏“代理品牌”;代理品牌取值同主营品牌一样--}}
...
...
vendor/_laravel_idea/_ide_helper_facades.php
View file @
18006628
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment