Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
h5
/
account
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 1d9f84e0
authored
Nov 24, 2023
by
前端
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修复bug
1 parent
86f1f1a2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
150 additions
and
117 deletions
html/merchant/edit.html
html/merchant/edit.html
View file @
1d9f84e
...
...
@@ -739,29 +739,24 @@ var _merchantModel; // 商户模型变量
var
_xmSelectData
=
[]
//存储上级商户的下拉数据
var
_currentMerchantLevel
=
''
//当前的账户等级
var
_superMerchantInfo
=
{}
//上级商户的信息
var
_searchValue
=
''
var
_searchCount
=
0
var
_initFactoryCheckArr
=
[]
// var accountlevelselect = $('#accountLevelElTab');
// accountLevelselect.empty();
// //根据当前商户等级和下级商户情况调整账户等级选项
// accountLevels.forEach(function(level) {
// var option = new Option(level.name,level.level)
// if(_subMerchantNoList && level.level == 2){
// }
// })
// accountLevelselect.val(merchantAccountLevel);
// form.render( ' select');
function
loadSuperiorMerchants
(
pageNum
=
1
,
val
=
''
)
{
function
loadSuperiorMerchants
(
pageNum
=
1
)
{
console
.
log
(
'accountLevelUpdate'
,
_currentMerchantLevel
)
return
new
Promise
((
resolve
,
reject
)
=>
{
var
params
=
{
method
:
'merchants.api.open.findMerchantListByPage'
,
pageSize
:
10
0
,
pageSize
:
5
0
,
pageNum
:
pageNum
,
merchantNoOrName
:
val
,
merchantModel
:
_merchantModel
merchantNoOrName
:
_searchValue
,
merchantModel
:
_merchantModel
,
accountLevelUpdate
:
_currentMerchantLevel
};
request
(
params
,
function
(
response
)
{
_searchCount
=
response
.
data
.
count
var
list
=
response
.
data
.
data
.
map
(
function
(
merchant
)
{
return
{
name
:
merchant
.
merchantName
,
...
...
@@ -786,25 +781,28 @@ var mySelect = layui.xmSelect.render({
remoteMethod
:
function
(
val
,
cb
,
show
)
{
// 输入时触发搜索
if
(
val
)
{
_searchValue
=
val
loadSuperiorMerchants
(
currentPage
=
1
,
val
).
then
(
function
(
res
){
cb
([])
mySelect
.
update
({
data
:
res
});
cb
([])
cb
(
res
)
});
}
else
{
cb
([])
_searchValue
=
''
if
(
_merchantModel
!==
undefined
){
loadSuperiorMerchants
(
currentPage
).
then
(
function
(
list
)
{
loadSuperiorMerchants
(
currentPage
=
1
).
then
(
function
(
list
)
{
console
.
log
(
list
)
cb
([])
mySelect
.
update
({
data
:
list
});
cb
(
list
)
});
}
}
},
on
:
function
(
data
)
{
console
.
log
(
'上级商户选择的数据'
,
data
)
_superMerchantInfo
=
data
?.
arr
[
0
]
var
handleAccountTypeToArray
=
data
?.
arr
[
0
]?.
accountType
.
split
(
','
)
var
handleAccountTypeToArray
=
data
?.
arr
[
0
]?.
accountType
?
.
split
(
','
)
renderAccountTypes
(
handleAccountTypeToArray
,
merchantForm
.
accountType
,
merchantForm
.
subAccountTypeList
,
_currentMerchantLevel
)
clearRoleAuthTabContent
();
prepareExecuteFindMenuFun
()
...
...
@@ -830,16 +828,11 @@ $(document).on('mouseup', function(e) {
function
resetXmSelectSearch
()
{
// 重置 currentPage 为初始值
currentPage
=
1
;
// 可选:如果你需要重置搜索框的值
// var searchInput = document.querySelector('#superiorMerchantSelect .xm-input');
// if (searchInput) {
// searchInput.value = '';
// }
var
superiorMerchant
=
layui
.
xmSelect
.
get
(
'#superiorMerchantSelect'
,
true
)?.
getValue
();
// // 重新加载数据
loadSuperiorMerchants
(
currentPage
).
then
(
function
(
list
)
{
mySelect
.
update
({
data
:
list
});
if
(
_currentMerchantLevel
!=
1
){
if
(
_currentMerchantLevel
!=
1
&&
superiorMerchant
.
length
!==
0
){
mySelect
.
setValue
([{
name
:
superiorMerchant
[
0
]?.
name
,
value
:
superiorMerchant
[
0
]?.
value
}]);
}
});
...
...
@@ -847,19 +840,18 @@ function resetXmSelectSearch() {
var
debouncedScroll
=
debounce
(
function
()
{
var
scrollContainer
=
document
.
querySelector
(
'#superiorMerchantSelect .scroll-body'
);
if
(
scrollContainer
&&
isScrolledToBottom
(
scrollContainer
))
{
if
(
_xmSelectData
.
length
>=
_searchCount
)
return
;
loadMoreData
();
}
},
100
)
function
loadMoreData
()
{
removeScrollListener
();
currentPage
++
;
loadSuperiorMerchants
(
currentPage
).
then
(
function
(
list
)
{
_xmSelectData
=
_xmSelectData
.
concat
(
list
);
console
.
log
(
_xmSelectData
)
mySelect
.
update
({
data
:
_xmSelectData
});
setTimeout
(
attachScrollListener
,
500
);
});
}
...
...
@@ -913,7 +905,7 @@ form.on('checkbox', function(data) {
selectedValues
.
push
(
$
(
this
).
val
());
}
});
//
console.log("选中的账户类型值: ", selectedValues);
console
.
log
(
"选中的账户类型值: "
,
selectedValues
);
if
(
selectedValues
.
length
===
0
)
{
layer
.
msg
(
'账户类型不能为空'
,
{
icon
:
5
,
anim
:
6
});
$
(
'#accountTypeElRole .accounttypeId'
).
each
(
function
()
{
...
...
@@ -939,6 +931,7 @@ if (!$(data.elem).closest('[id^=project]').length) {
});
function
prepareExecuteFindMenuFun
(){
// 修改check_arr
if
(
_currentMerchantLevel
!=
'1'
&&
!
_superMerchantInfo
)
return
var
rolePageParams
=
{}
...
...
@@ -957,7 +950,8 @@ function prepareExecuteFindMenuFun(){
accountLevel
:
_currentMerchantLevel
}
}
findMenuFunTreeByMerId
(
rolePageParams
)
getById
(
_superMerchantInfo
?.
parentId
,
rolePageParams
)
// findMenuFunTreeByMerId(rolePageParams)
}
function
clearRoleAuthTabContent
()
{
// 清空特定选项卡标题
...
...
@@ -1034,85 +1028,92 @@ function clearRoleAuthTabContent() {
// 监听账户等级下拉框的选择事件
// form.on('select(accountLevelFilter)', function(data) {
// if(data.value == 1 || data.value ==4){
// $('#accountLevelElTab option[value="1"]').prop('disabled',false)
// $('#accountLevelElTab option[value="2"]').prop('disabled',false)
// $('#accountLevelElTab option[value="3"]').prop('disabled',false)
// $('#accountLevelElTab option[value="4"]').prop('disabled',false)
// }
// // 如果选中的是“工厂”
// if (data.value == '1') {
// // 隐藏上级商户的表单项
// $('#superiorMerchantContainer').hide();
// } else {
// // 显示上级商户的表单项
// $('#superiorMerchantContainer').show();
// }
// _currentMerchantLevel = data.value
// if(data.value == 3) $('#accountLevelElTab option[value="2"]').prop('disabled',true)
// if(data.value == 2) $('#accountLevelElTab option[value="3"]').prop('disabled',true)
// if(data.value ==2 && _subMerchantNoList?.length>0 || data.value ==3 && _subMerchantNoList?.length>0 ){
// $("#accountLevelElTab").attr("disabled", "disabled");
// $("#accountLevelElTab").attr("style", "background-color: #EEEEEE;");
// }
// renderAccountTypes(_superMerchantInfo?.accountType?.split(','), merchantForm.accountType, merchantForm.subAccountTypeList,_currentMerchantLevel);
// clearRoleAuthTabContent();
// prepareExecuteFindMenuFun()
// form.render(); // 可选,根据需要重新渲染表单
// });
// Listen for the account level dropdown selection event
form
.
on
(
'select(accountLevelFilter)'
,
function
(
data
)
{
var
$accountLevelElTab
=
$
(
'#accountLevelElTab'
);
var
$options
=
$accountLevelElTab
.
find
(
'option'
);
var
$superiorMerchantContainer
=
$
(
'#superiorMerchantContainer'
);
var
_currentMerchantLevel
=
data
.
value
;
function
setOptionsDisabled
(
disabled
)
{
$options
.
each
(
function
()
{
var
value
=
$
(
this
).
attr
(
'value'
);
$
(
this
).
prop
(
'disabled'
,
disabled
.
includes
(
value
));
form
.
on
(
'select(accountLevelFilter)'
,
function
(
data
)
{
if
(
data
.
value
==
1
||
data
.
value
==
4
){
$
(
'#accountLevelElTab option[value="1"]'
).
prop
(
'disabled'
,
false
)
$
(
'#accountLevelElTab option[value="2"]'
).
prop
(
'disabled'
,
false
)
$
(
'#accountLevelElTab option[value="3"]'
).
prop
(
'disabled'
,
false
)
$
(
'#accountLevelElTab option[value="4"]'
).
prop
(
'disabled'
,
false
)
}
// 如果选中的是“工厂”
if
(
data
.
value
==
'1'
)
{
// 隐藏上级商户的表单项
$
(
'#superiorMerchantContainer'
).
hide
();
}
else
{
// 显示上级商户的表单项
$
(
'#superiorMerchantContainer'
).
show
();
}
_currentMerchantLevel
=
data
.
value
if
(
data
.
value
==
3
)
$
(
'#accountLevelElTab option[value="2"]'
).
prop
(
'disabled'
,
true
)
if
(
data
.
value
==
2
)
$
(
'#accountLevelElTab option[value="3"]'
).
prop
(
'disabled'
,
true
)
if
(
data
.
value
==
2
&&
_subMerchantNoList
?.
length
>
0
||
data
.
value
==
3
&&
_subMerchantNoList
?.
length
>
0
){
$
(
"#accountLevelElTab"
).
attr
(
"disabled"
,
"disabled"
);
$
(
"#accountLevelElTab"
).
attr
(
"style"
,
"background-color: #EEEEEE;"
);
}
console
.
log
(
'账户等级下拉框的渲染账户类型参数'
,
'上级商户类型'
,
_superMerchantInfo
?.
accountType
?.
split
(
','
),
'本身的商户类型'
,
merchantForm
.
accountType
,
'本身的子商户类型'
,
merchantForm
.
subAccountTypeList
,
'页面的账户等级'
,
_currentMerchantLevel
)
renderAccountTypes
(
_superMerchantInfo
?.
accountType
?.
split
(
','
),
merchantForm
.
accountType
,
merchantForm
.
subAccountTypeList
,
_currentMerchantLevel
);
clearRoleAuthTabContent
();
prepareExecuteFindMenuFun
()
loadSuperiorMerchants
()
form
.
render
();
// 可选,根据需要重新渲染表单
});
}
function
toggleMerchantContainerDisplay
(
show
)
{
if
(
show
)
{
$superiorMerchantContainer
.
show
();
}
else
{
$superiorMerchantContainer
.
hide
();
}
}
// form.on('select(accountLevelFilter)', function(data) {
// var $accountLevelElTab = $('#accountLevelElTab');
// var $options = $accountLevelElTab.find('option');
// var $superiorMerchantContainer = $('#superiorMerchantContainer');
// var _currentMerchantLevel = data.value;
// function setOptionsDisabled(disabled) {
// $options.each(function() {
// var value = $(this).attr('value');
// $(this).prop('disabled', disabled.includes(value));
// });
// }
switch
(
_currentMerchantLevel
)
{
case
'1'
:
case
'4'
:
setOptionsDisabled
([]);
toggleMerchantContainerDisplay
(
_currentMerchantLevel
!==
'1'
);
break
;
case
'2'
:
setOptionsDisabled
([
'3'
]);
toggleMerchantContainerDisplay
(
true
);
break
;
case
'3'
:
setOptionsDisabled
([
'2'
]);
toggleMerchantContainerDisplay
(
true
);
break
;
}
// function toggleMerchantContainerDisplay(show) {
// if (show) {
// $superiorMerchantContainer.show();
// } else {
// $superiorMerchantContainer.hide();
// }
// }
// switch (_currentMerchantLevel) {
// case '1':
// case '4':
// setOptionsDisabled([]);
// toggleMerchantContainerDisplay(_currentMerchantLevel !== '1');
// break;
// case '2':
// setOptionsDisabled(['3']);
// toggleMerchantContainerDisplay(true);
// break;
// case '3':
// setOptionsDisabled(['2']);
// toggleMerchantContainerDisplay(true);
// break;
// }
if
((
_currentMerchantLevel
===
'2'
||
_currentMerchantLevel
===
'3'
)
&&
_subMerchantNoList
?.
length
>
0
)
{
$accountLevelElTab
.
prop
(
'disabled'
,
true
).
css
(
'background-color'
,
'#EEEEEE'
);
}
else
{
$accountLevelElTab
.
prop
(
'disabled'
,
false
).
css
(
'background-color'
,
''
);
}
//
if ((_currentMerchantLevel === '2' || _currentMerchantLevel === '3') && _subMerchantNoList?.length > 0) {
//
$accountLevelElTab.prop('disabled', true).css('background-color', '#EEEEEE');
//
} else {
//
$accountLevelElTab.prop('disabled', false).css('background-color', '');
//
}
renderAccountTypes
(
_superMerchantInfo
?.
accountType
?.
split
(
','
),
merchantForm
.
accountType
,
merchantForm
.
subAccountTypeList
,
_currentMerchantLevel
);
clearRoleAuthTabContent
();
prepareExecuteFindMenuFun
();
form
.
render
();
});
//
renderAccountTypes(_superMerchantInfo?.accountType?.split(','), merchantForm.accountType, merchantForm.subAccountTypeList, _currentMerchantLevel);
//
clearRoleAuthTabContent();
//
prepareExecuteFindMenuFun();
//
form.render();
//
});
// 校验
...
...
@@ -1986,9 +1987,12 @@ loadSuperiorMerchants(currentPage).then(function(list) {
parentId
:
merchantForm
.
parentId
,
accountType
:
merchantForm
.
superiorAccountType
}
mySelect
.
setValue
([{
name
:
merchantForm
.
superiorMerchantName
,
value
:
merchantForm
.
superiorMerchantNo
}]);
}
else
{
mySelect
.
setValue
([])
console
.
log
(
merchantForm
)
mySelect
.
setValue
([{
name
:
merchantForm
.
superiorMerchantName
,
value
:
merchantForm
.
superiorMerchantNo
,
accountType
:
merchantForm
.
superiorAccountType
,
parentId
:
merchantForm
.
parentId
}]);
}
});
...
...
@@ -2056,22 +2060,24 @@ loadSuperiorMerchants(currentPage).then(function(list) {
if
(
accountLevel
==
1
){
types
=
[]
for
(
let
i
in
typeMapping
){
types
.
push
(
i
);
}
}
types
.
forEach
(
function
(
type
)
{
var
typeLabel
=
typeMapping
[
type
];
var
isChecked
=
currentMerchantType
.
includes
(
type
);
var
isChecked
=
currentMerchantType
.
split
(
','
).
includes
(
type
);
var
isDisable
=
subAccountTypeList
.
includes
(
type
)
var
checkboxHtml
=
$
(
'<input type="checkbox" class="accounttypeId" name="accountType['
+
type
+
']" value="'
+
type
+
'" title="'
+
typeLabel
+
'">'
);
// 设置为选中和禁用,并添加高亮类
if
(
isChecked
)
{
checkboxHtml
.
attr
(
'checked'
,
true
).
addClass
(
'highlighted'
)
checkboxHtml
.
attr
(
'checked'
,
true
)
// .addClass('highlighted')
}
if
(
isDisable
){
checkboxHtml
.
attr
(
'disabled'
,
true
).
addClass
(
'highlighted-disabled'
)
checkboxHtml
.
attr
(
'disabled'
,
true
)
// .addClass('highlighted-disabled')
}
el
.
append
(
checkboxHtml
);
...
...
@@ -2427,6 +2433,7 @@ loadSuperiorMerchants(currentPage).then(function(list) {
var
str
=
$
(
'<input lay-filter="filter" data-id="'
+
id
+
'" type="checkbox" name="check['
+
id
+
']" value="'
+
i
.
productId
+
'" title="'
+
i
.
productName
+
'" lay-skin="primary" />'
)
$
(
'#project'
+
id
).
append
(
str
)
if
(
productList
)
{
console
.
log
(
'productList'
,
productList
)
productList
.
forEach
(
j
=>
{
if
(
j
.
productId
==
i
.
productId
)
{
str
.
attr
(
'checked'
,
true
)
...
...
@@ -2552,6 +2559,7 @@ loadSuperiorMerchants(currentPage).then(function(list) {
// 查询商户的菜单权限树
function
findMenuFunTreeByMerId
(
rolePageParams
)
{
console
.
log
(
'rolePageParams'
,
rolePageParams
)
var
params
=
{}
if
(
rolePageParams
){
params
=
rolePageParams
...
...
@@ -2579,7 +2587,24 @@ loadSuperiorMerchants(currentPage).then(function(list) {
layer
.
close
(
loadingIndex
);
if
(
res
.
code
==
'0'
)
{
menuFunTreeData
=
res
.
data
check_arr
=
res
.
data
// 插个眼
console
.
log
(
'check_arr'
,
check_arr
)
console
.
log
(
'menuFunTreeData'
,
menuFunTreeData
)
console
.
log
(
'_initFactoryCheckArr'
,
_initFactoryCheckArr
)
if
(
_initFactoryCheckArr
&&
_currentMerchantLevel
==
1
){
menuFunTreeData
.
forEach
(
item
=>
{
if
(
!
_initFactoryCheckArr
.
some
(
initItem
=>
initItem
.
accounttypeId
==
item
.
accounttypeId
)){
const
newItem
=
{...
item
,
products
:[]}
_initFactoryCheckArr
.
push
(
newItem
)
}
})
}
check_arr
=
_currentMerchantLevel
==
1
?
_initFactoryCheckArr
:
check_arr
.
filter
(
item
=>
_currentaccountType
.
includes
(
String
(
item
.
accounttypeId
)))
var
accountType
=
$
(
'#accountType'
)
accountType
.
empty
()
menuFunTreeData
.
forEach
((
item
,
index
)
=>
{
...
...
@@ -2592,9 +2617,9 @@ loadSuperiorMerchants(currentPage).then(function(list) {
var
id
=
item
.
accounttypeId
str
.
attr
(
'checked'
,
true
)
var
obj
=
{
title
:
item
.
accounttypeName
,
value
:
item
.
accounttypeId
}
// console.log(obj, productData.products)
active
.
tabAdd
(
obj
,
productData
.
products
)
if
(
productData
.
products
&&
productData
.
products
.
length
!=
0
)
{
// console.log('进入页面',productData)
productData
.
products
.
forEach
(
j
=>
{
var
products
=
item
.
products
.
find
(
n
=>
n
.
productId
==
j
.
productId
)
if
(
products
)
{
...
...
@@ -2634,18 +2659,26 @@ loadSuperiorMerchants(currentPage).then(function(list) {
}
// 根据id获取角色详情
function
getById
()
{
function
getById
(
parentIdToCheckArr
,
rolePageParams
)
{
console
.
log
(
'parentIdToCheckArr'
,
parentIdToCheckArr
,
'rolePageParams'
,
rolePageParams
)
var
params
=
{
method
:
'merchants.api.merchant.findPermissionsByMerId'
,
id
:
merchantId
id
:
parentIdToCheckArr
?
parentIdToCheckArr
:
merchantId
}
request
(
params
,
function
(
res
)
{
if
(
res
.
code
==
'0'
)
{
var
accounttypeId
=
''
if
(
res
.
data
)
{
check_arr
=
res
.
data
if
(
_currentMerchantLevel
==
1
){
_initFactoryCheckArr
=
check_arr
}
}
findMenuFunTreeByMerId
()
findMenuFunTreeByMerId
(
rolePageParams
)
form
.
val
(
'roleForm'
,
{
roleName
:
res
.
data
.
roleName
,
roleDescription
:
res
.
data
.
roleDescription
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment