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 1ea2864a
authored
Aug 11, 2021
by
cwq0219
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
商户管理
1 parent
b1670f61
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1071 additions
and
943 deletions
html/merchant/edit.html
js/validator.js
html/merchant/edit.html
View file @
1ea2864
...
...
@@ -99,7 +99,7 @@
<div
class=
"edit-box"
>
<!-- 基本信息 -->
<div
id=
"basicForm"
>
<form
class=
"layui-form"
lay-filter=
"merchantForm"
lay-verify=
"merchantVerify"
>
<form
class=
"layui-form"
lay-filter=
"merchantForm"
>
<div
class=
"layui-form-item edit-title"
style=
"position: relative;"
>
<div
class=
"layui-input-inline"
>
企业基本信息
</div>
<div
class=
"layui-input-inline"
style=
"position: absolute; right: 0; top: 5px; font-size: normal;"
>
...
...
@@ -128,7 +128,7 @@
</select>
</div>
<div
class=
"layui-input-inline"
style=
"width: 220px;"
>
<input
class=
"layui-input"
maxlength=
"50"
name=
"merchantOrgcode"
placeholder=
"请输入组织机构号码"
>
<input
class=
"layui-input"
maxlength=
"50"
lay-verify=
"merchantOrgcode"
name=
"merchantOrgcode"
placeholder=
"请输入组织机构号码"
>
</div>
</div>
<div
class=
"layui-form-item"
>
...
...
@@ -164,7 +164,7 @@
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
驻
点
联系人:
</label>
<label
class=
"layui-form-label"
>
驻
店
联系人:
</label>
<div
class=
"layui-input-inline"
>
<input
class=
"layui-input"
name=
"residentContact"
maxlength=
"15"
placeholder=
"请输入驻点联系人"
>
</div>
...
...
@@ -172,7 +172,8 @@
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
驻店电话:
</label>
<div
class=
"layui-input-inline"
>
<input
class=
"layui-input"
name=
"residentPhone"
maxlength=
"11"
placeholder=
"请输入驻点电话"
>
<input
class=
"layui-input"
name=
"residentPhone"
maxlength=
"11"
placeholder=
"请输入驻点电话"
lay-verify=
"residentPhone"
>
</div>
</div>
<div
class=
"layui-form-item"
>
...
...
@@ -326,1046 +327,1048 @@
</div>
<script
src=
"https://www.layuicdn.com/layui/layui.js"
></script>
<script
src=
"/js/load.js"
></script>
<script
src=
"/js/validator.js"
></script>
<script>
layui
.
use
([
'gtree'
,
'request'
,
'helper'
,
'layer'
,
'laydate'
,
'element'
,
'xmSelect'
,
'laytpl'
],
function
()
{
var
tree
=
layui
.
gtree
var
request
=
layui
.
request
var
form
=
layui
.
form
var
laydate
=
layui
.
laydate
var
$
=
layui
.
$
var
helper
=
layui
.
helper
var
element
=
layui
.
element
var
editData
=
{}
var
treeObj
=
null
var
all_nodes
=
[]
// 1-创建新商户;2-创建子商户;3-修改
var
editLevel
=
1
// 1-基本信息;2-权限树
var
step
=
1
var
merchantId
=
null
var
parentMerchantId
=
null
// 是否工厂
var
isFactory
=
true
var
parentInfo
=
{}
layui
.
use
([
'gtree'
,
'request'
,
'helper'
,
'layer'
,
'laydate'
,
'element'
,
'xmSelect'
,
'laytpl'
,
'validator'
],
function
()
{
var
tree
=
layui
.
gtree
var
request
=
layui
.
request
var
form
=
layui
.
form
var
laydate
=
layui
.
laydate
var
$
=
layui
.
$
var
validator
=
layui
.
validator
var
helper
=
layui
.
helper
var
element
=
layui
.
element
var
editData
=
{}
var
treeObj
=
null
var
all_nodes
=
[]
// 1-创建新商户;2-创建子商户;3-修改
var
editLevel
=
1
// 1-基本信息;2-权限树
var
step
=
1
var
merchantId
=
null
var
parentMerchantId
=
null
// 是否工厂
var
isFactory
=
true
var
parentInfo
=
{}
var
merchantForm
=
{
channelId
:
''
,
merchantName
:
''
,
merchantAbbreviation
:
''
,
merchantType
:
''
,
merchantOrgcode
:
''
,
merchantLegalPerson
:
''
,
merchantLegalPersonPhone
:
''
,
isloginName
:
0
,
residentContact
:
''
,
residentPhone
:
''
,
bussinessBegintime
:
''
,
bussinessEndtime
:
''
,
lat
:
''
,
lng
:
''
,
merchantAddress
:
''
,
businessScope
:
''
,
merchantFiles
:
[]
}
var
baseData
=
{
channelList
:
[],
carBrandTreeList
:
[],
accountLevelList
:
[],
validPeriodList
:
[],
busiScopeList
:
[],
accountTypeList
:
[]
}
var
startDate
=
laydate
.
render
({
elem
:
'#startDate'
,
//指定元素
type
:
'time'
,
format
:
'HH:mm:ss'
,
done
:
function
(
value
,
date
)
{
//监听日期被切换
if
(
value
!=
""
)
{
date
.
month
=
date
.
month
-
1
endDate
.
config
.
min
=
date
}
else
{
endDate
.
config
.
min
=
startDate
.
config
.
min
}
lay
(
'#startDate'
).
html
(
value
)
var
merchantForm
=
{
channelId
:
''
,
merchantName
:
''
,
merchantAbbreviation
:
''
,
merchantType
:
''
,
merchantOrgcode
:
''
,
merchantLegalPerson
:
''
,
merchantLegalPersonPhone
:
''
,
isloginName
:
0
,
residentContact
:
''
,
residentPhone
:
''
,
bussinessBegintime
:
''
,
bussinessEndtime
:
''
,
lat
:
''
,
lng
:
''
,
merchantAddress
:
''
,
businessScope
:
''
,
merchantFiles
:
[]
}
})
var
endDate
=
laydate
.
render
({
elem
:
'#endDate'
,
//指定元素
type
:
'time'
,
format
:
'HH:mm:ss'
,
done
:
function
(
value
,
date
)
{
//监听日期被切换
if
(
value
!=
""
)
{
date
.
month
=
date
.
month
-
1
startDate
.
config
.
max
=
date
}
else
{
startDate
.
config
.
max
=
endDate
.
config
.
max
}
lay
(
'#endDate'
).
html
(
value
)
}
})
init
()
// helper.store.set('merchantMapObj', {
// lat: '116.397428',
// lng: '39.90923',
// merchantAddress: '深圳'
// })
// helper.store.set('merchantMapObj', merchantForm)
// 校验
// form.vertify({
// merchantVerify: []
// })
form
.
on
(
'submit(handleFirstSubmit)'
,
function
(
data
)
{
// console.log(editLevel)
// console.log(data.field)
var
formData
=
data
.
field
var
params
=
{
isloginName
:
0
}
var
fieldToFormNameList
=
[
'channelId'
,
'merchantName'
,
'merchantAbbreviation'
,
'merchantType'
,
'merchantOrgcode'
,
'merchantLegalPerson'
,
'merchantLegalPersonPhone'
,
'residentContact'
,
'residentPhone'
,
'merchantLoginAccount'
,
'merchantLoginPassword'
,
'merchantAccountLevel'
,
'effectiveTime'
]
if
(
formData
.
isloginName
==
'on'
)
{
params
.
isloginName
=
1
}
if
(
formData
.
bussinessBegintime
)
{
merchantForm
.
bussinessBegintime
=
formData
.
bussinessBegintime
params
.
bussinessBegintime
=
formData
.
bussinessBegintime
var
baseData
=
{
channelList
:
[],
carBrandTreeList
:
[],
accountLevelList
:
[],
validPeriodList
:
[],
busiScopeList
:
[],
accountTypeList
:
[]
}
if
(
formData
.
bussinessEndtime
)
{
merchantForm
.
bussinessEndtime
=
formData
.
bussinessEndtime
params
.
bussinessEndtime
=
formData
.
bussinessEndtime
}
if
(
merchantForm
.
lat
)
{
params
.
lat
=
merchantForm
.
lat
params
.
lng
=
merchantForm
.
lng
params
.
merchantAddress
=
merchantForm
.
merchantAddress
}
$
.
each
(
fieldToFormNameList
,
function
(
index
,
item
)
{
if
(
formData
[
item
])
{
merchantForm
[
item
]
=
formData
[
item
]
params
[
item
]
=
formData
[
item
]
}
})
var
checkClassNameList
=
[{
attr
:
'businessScope'
,
toString
:
','
},
{
attr
:
'accounttypeId'
,
toString
:
','
}]
$
.
each
(
checkClassNameList
,
function
(
index
,
item
)
{
var
checkedArr
=
[]
$
(
'input[class='
+
item
.
attr
+
']:checked'
).
each
(
function
()
{
checkedArr
.
push
(
$
(
this
).
val
())
})
if
(
checkedArr
.
length
)
{
if
(
item
.
toString
)
{
merchantForm
[
item
.
attr
]
=
checkedArr
.
join
(
item
.
toString
)
params
[
item
.
attr
]
=
checkedArr
.
join
(
item
.
toString
)
var
startDate
=
laydate
.
render
({
elem
:
'#startDate'
,
//指定元素
type
:
'time'
,
format
:
'HH:mm:ss'
,
done
:
function
(
value
,
date
)
{
//监听日期被切换
if
(
value
!=
""
)
{
date
.
month
=
date
.
month
-
1
endDate
.
config
.
min
=
date
}
else
{
endDate
.
config
.
min
=
startDate
.
config
.
min
}
lay
(
'#startDate'
).
html
(
value
)
}
})
var
elList
=
$
(
'.business-scope-cust'
)
var
tempList
=
[]
$
.
each
(
elList
,
function
(
index
,
item
)
{
tempList
.
push
(
item
.
value
)
})
merchantForm
.
businessScopeCustomize
=
tempList
.
join
(
','
)
params
.
businessScopeCustomize
=
tempList
.
join
(
','
)
merchantForm
.
merchantBrand
=
treeObj
.
getCheckedNodes
(
true
)
params
.
merchantBrand
=
findId
(
merchantForm
.
merchantBrand
).
join
(
','
)
if
(
merchantForm
.
merchantFiles
.
length
)
{
params
.
merchantFiles
=
JSON
.
stringify
(
merchantForm
.
merchantFiles
)
}
if
(
editLevel
==
1
)
{
params
.
method
=
'cn.com.glsx.merchants.merchant.saveMerchant'
}
else
if
(
editLevel
==
2
)
{
if
(
!
isFactory
)
{
params
.
parentId
=
parentInfo
.
parentId
}
params
.
method
=
'cn.com.glsx.merchants.merchant.saveMerchant'
}
else
if
(
editLevel
==
3
)
{
params
.
id
=
merchantId
if
(
!
isFactory
)
{
params
.
parentId
=
parentInfo
.
parentId
}
params
.
method
=
'cn.com.glsx.merchants.merchant.updateMerchant'
}
// 保存状态 1.草稿 2.发布 3.注销 4.过期
if
(
merchantForm
.
status
)
{
params
.
status
=
merchantForm
.
status
}
else
{
params
.
status
=
1
}
console
.
log
(
editLevel
)
console
.
log
(
params
)
layer
.
msg
(
'操作成功'
,
{
icon
:
1
})
// merchantId = 58
// merchantForm.merchantAccountLevel = parseInt(merchantForm.merchantAccountLevel)
// getMerchantApi(merchantId, function (res) {
// form.val('merchantForm', res.data)
// merchantForm = res.data
// baseIsShow(false)
// treeIsShow(true)
// getById()
// })
request
(
params
,
function
(
res
)
{
console
.
log
(
res
)
// authorityTree
if
(
res
.
code
==
'0'
)
{
if
(
editLevel
==
3
)
{
layer
.
msg
(
'操作成功'
,
{
icon
:
1
})
go
(
'merchant'
,
'index'
)
var
endDate
=
laydate
.
render
({
elem
:
'#endDate'
,
//指定元素
type
:
'time'
,
format
:
'HH:mm:ss'
,
done
:
function
(
value
,
date
)
{
//监听日期被切换
if
(
value
!=
""
)
{
date
.
month
=
date
.
month
-
1
startDate
.
config
.
max
=
date
}
else
{
merchantId
=
res
.
data
merchantForm
.
merchantAccountLevel
=
parseInt
(
merchantForm
.
merchantAccountLevel
)
getMerchantApi
(
merchantId
,
function
(
respone
)
{
form
.
val
(
'merchantForm'
,
respone
.
data
)
merchantForm
=
respone
.
data
baseIsShow
(
false
)
treeIsShow
(
true
)
getById
()
})
startDate
.
config
.
max
=
endDate
.
config
.
max
}
lay
(
'#endDate'
).
html
(
value
)
}
})
return
false
})
function
findId
(
nodeList
)
{
var
idList
=
[]
$
.
each
(
nodeList
,
function
(
index
,
item
)
{
idList
.
push
(
item
.
id
)
})
return
idList
}
init
()
// 按钮事件绑定
var
btnHandle
=
{
// 选择地址
handleSelectAddr
:
function
()
{
helper
.
store
.
set
(
'merchantMapObj'
,
merchantForm
)
layer
.
open
({
type
:
2
,
title
:
'选择地址'
,
area
:
[
'900px'
,
'600px'
],
btn
:
[
'确定'
,
'取消'
],
content
:
'map.html'
,
success
:
function
(
layero
,
index
)
{
//向layer页面传值,传值主要代码
// var body = layer.getChildFrame('body', index)
// console.log(body)
//得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method();
// var iframeWin = window[layero.find('iframe')[0]['name']]
// console.log(iframeWin)
// helper.store.set('merchantMapObj', {
// lat: '116.397428',
// lng: '39.90923',
// merchantAddress: '深圳'
// })
// helper.store.set('merchantMapObj', merchantForm)
//将弹窗页面中属性名id="merchantAddress"的标签赋值
// body.find("[id='merchantAddress']").val('fhdskfls')
},
yes
:
function
(
index
,
layero
)
{
// console.log(window["layui-layer-iframe" + index])
// var res = window["layui-layer-iframe" + index].callbackdata()
// console.log(res)
var
body
=
layer
.
getChildFrame
(
'body'
,
index
)
body
.
find
(
'#mapBtn'
).
click
()
var
res
=
helper
.
store
.
get
(
'merchantMapObj'
)
// console.log(res)
merchantForm
.
lat
=
res
.
lat
merchantForm
.
lng
=
res
.
lng
merchantForm
.
merchantAddress
=
res
.
merchantAddress
setInput
(
'#addrEl'
,
merchantForm
.
merchantAddress
)
layer
.
close
(
index
)
},
end
:
function
()
{
helper
.
store
.
remove
(
'merchantMapObj'
)
// console.log(validator.PHONEREG)
// 校验
form
.
verify
({
// merchantOrgcode: function(value) {
// },
residentPhone
:
function
(
value
)
{
if
(
!
validator
.
checkPhoneNumber
(
value
))
{
return
'请填入正确的驻店电话'
}
})
},
// 添加范围
handleAddScope
(
txt
)
{
var
parent
=
$
(
'#custom-scope'
)
var
subParent
=
$
(
'<div class="layui-form-item"><label class="layui-form-label"></label></div>'
)
var
child1
=
$
(
'<div class="layui-input-inline"></div>'
)
var
inputEl
=
$
(
'<input class="layui-input business-scope-cust" maxlength="15" placeholder="请自定义营业范围,建议不超过10个">'
)
var
child2
=
$
(
'<div class="layui-input-inline"></div>'
)
}
})
var
addBtn
=
$
(
'<button type="button" class="layui-btn btn-no-border"><i class="layui-icon layui-icon-add-circle"></i></button>'
)
var
deleteBtn
=
$
(
'<button type="button" class="layui-btn btn-no-border"><i class="layui-icon layui-icon-reduce-circle"></i></button>'
)
if
(
txt
)
{
inputEl
.
val
(
txt
)
form
.
on
(
'submit(handleFirstSubmit)'
,
function
(
data
)
{
// console.log(editLevel)
// console.log(data.field)
var
formData
=
data
.
field
var
params
=
{
isloginName
:
0
}
var
fieldToFormNameList
=
[
'channelId'
,
'merchantName'
,
'merchantAbbreviation'
,
'merchantType'
,
'merchantOrgcode'
,
'merchantLegalPerson'
,
'merchantLegalPersonPhone'
,
'residentContact'
,
'residentPhone'
,
'merchantLoginAccount'
,
'merchantLoginPassword'
,
'merchantAccountLevel'
,
'effectiveTime'
]
if
(
formData
.
isloginName
==
'on'
)
{
params
.
isloginName
=
1
}
if
(
formData
.
bussinessBegintime
)
{
merchantForm
.
bussinessBegintime
=
formData
.
bussinessBegintime
params
.
bussinessBegintime
=
formData
.
bussinessBegintime
}
if
(
formData
.
bussinessEndtime
)
{
merchantForm
.
bussinessEndtime
=
formData
.
bussinessEndtime
params
.
bussinessEndtime
=
formData
.
bussinessEndtime
}
if
(
merchantForm
.
lat
)
{
params
.
lat
=
merchantForm
.
lat
params
.
lng
=
merchantForm
.
lng
params
.
merchantAddress
=
merchantForm
.
merchantAddress
}
$
.
each
(
fieldToFormNameList
,
function
(
index
,
item
)
{
if
(
formData
[
item
])
{
merchantForm
[
item
]
=
formData
[
item
]
params
[
item
]
=
formData
[
item
]
}
})
var
checkClassNameList
=
[{
attr
:
'businessScope'
,
toString
:
','
},
{
attr
:
'accounttypeId'
,
toString
:
','
}]
$
.
each
(
checkClassNameList
,
function
(
index
,
item
)
{
var
checkedArr
=
[]
$
(
'input[class='
+
item
.
attr
+
']:checked'
).
each
(
function
()
{
checkedArr
.
push
(
$
(
this
).
val
())
})
if
(
checkedArr
.
length
)
{
if
(
item
.
toString
)
{
merchantForm
[
item
.
attr
]
=
checkedArr
.
join
(
item
.
toString
)
params
[
item
.
attr
]
=
checkedArr
.
join
(
item
.
toString
)
}
}
})
var
elList
=
$
(
'.business-scope-cust'
)
var
tempList
=
[]
$
.
each
(
elList
,
function
(
index
,
item
)
{
tempList
.
push
(
item
.
value
)
})
merchantForm
.
businessScopeCustomize
=
tempList
.
join
(
','
)
params
.
businessScopeCustomize
=
tempList
.
join
(
','
)
merchantForm
.
merchantBrand
=
treeObj
.
getCheckedNodes
(
true
)
params
.
merchantBrand
=
findId
(
merchantForm
.
merchantBrand
).
join
(
','
)
if
(
merchantForm
.
merchantFiles
.
length
)
{
params
.
merchantFiles
=
JSON
.
stringify
(
merchantForm
.
merchantFiles
)
}
addBtn
.
bind
(
'click'
,
function
(
e
)
{
btnHandle
.
handleAddScope
()
if
(
editLevel
==
1
)
{
params
.
method
=
'cn.com.glsx.merchants.merchant.saveMerchant'
}
else
if
(
editLevel
==
2
)
{
if
(
!
isFactory
)
{
params
.
parentId
=
parentInfo
.
parentId
}
params
.
method
=
'cn.com.glsx.merchants.merchant.saveMerchant'
}
else
if
(
editLevel
==
3
)
{
params
.
id
=
merchantId
if
(
!
isFactory
)
{
params
.
parentId
=
parentInfo
.
parentId
}
params
.
method
=
'cn.com.glsx.merchants.merchant.updateMerchant'
}
// 保存状态 1.草稿 2.发布 3.注销 4.过期
if
(
merchantForm
.
status
)
{
params
.
status
=
merchantForm
.
status
}
else
{
params
.
status
=
1
}
console
.
log
(
editLevel
)
console
.
log
(
params
)
layer
.
msg
(
'操作成功'
,
{
icon
:
1
})
deleteBtn
.
bind
(
'click'
,
function
(
e
)
{
var
el
=
$
(
this
).
parent
().
parent
()
el
.
remove
()
request
(
params
,
function
(
res
)
{
console
.
log
(
res
)
// authorityTree
if
(
res
.
code
==
'0'
)
{
if
(
editLevel
==
3
)
{
layer
.
msg
(
'操作成功'
,
{
icon
:
1
})
go
(
'merchant'
,
'index'
)
}
else
{
merchantId
=
res
.
data
merchantForm
.
merchantAccountLevel
=
parseInt
(
merchantForm
.
merchantAccountLevel
)
getMerchantApi
(
merchantId
,
function
(
respone
)
{
form
.
val
(
'merchantForm'
,
respone
.
data
)
merchantForm
=
respone
.
data
baseIsShow
(
false
)
treeIsShow
(
true
)
getById
()
})
}
}
})
child1
.
append
(
inputEl
)
child2
.
append
(
addBtn
)
child2
.
append
(
deleteBtn
)
subParent
.
append
(
child1
)
subParent
.
append
(
child2
)
parent
.
append
(
subParent
)
},
handleCancel
()
{
go
(
'merchant'
,
'index'
)
return
false
}
}
})
$
(
'.layui-btn'
).
on
(
'click'
,
function
()
{
var
type
=
$
(
this
).
data
(
'type'
)
if
(
btnHandle
[
type
])
{
btnHandle
[
type
]()
function
findId
(
nodeList
)
{
var
idList
=
[]
$
.
each
(
nodeList
,
function
(
index
,
item
)
{
idList
.
push
(
item
.
id
)
})
return
idList
}
})
$
(
'.upload'
).
on
(
'change'
,
function
(
e
)
{
// console.log(e)
var
idx
=
$
(
this
).
data
(
'idx'
)
var
imgEl
=
$
(
'#img'
+
idx
)
var
el
=
$
(
'#upload'
+
idx
)
var
addEl
=
$
(
'.img-add'
+
idx
)
var
reader
=
new
FileReader
()
var
fileInfo
=
el
[
0
].
files
[
0
]
// console.log(el)
reader
.
readAsDataURL
(
fileInfo
)
reader
.
onload
=
function
(
e
)
{
if
(
e
)
{
const
imgFile
=
e
.
target
.
result
const
base64
=
fileInfo
.
name
.
split
(
'.'
)[
1
]
+
'@'
+
imgFile
.
split
(
','
)[
1
]
request
({
method
:
'glsx.accounts.biz.common.pictureUpload'
,
file
:
base64
},
function
(
result
)
{
merchantForm
.
merchantFiles
[
idx
]
=
{
fileUrl
:
result
.
data
,
fileName
:
''
// 按钮事件绑定
var
btnHandle
=
{
// 选择地址
handleSelectAddr
:
function
()
{
helper
.
store
.
set
(
'merchantMapObj'
,
merchantForm
)
layer
.
open
({
type
:
2
,
title
:
'选择地址'
,
area
:
[
'900px'
,
'600px'
],
btn
:
[
'确定'
,
'取消'
],
content
:
'map.html'
,
success
:
function
(
layero
,
index
)
{
//向layer页面传值,传值主要代码
// var body = layer.getChildFrame('body', index)
// console.log(body)
//得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method();
// var iframeWin = window[layero.find('iframe')[0]['name']]
// console.log(iframeWin)
//将弹窗页面中属性名id="merchantAddress"的标签赋值
// body.find("[id='merchantAddress']").val('fhdskfls')
},
yes
:
function
(
index
,
layero
)
{
// console.log(window["layui-layer-iframe" + index])
// var res = window["layui-layer-iframe" + index].callbackdata()
// console.log(res)
var
body
=
layer
.
getChildFrame
(
'body'
,
index
)
body
.
find
(
'#mapBtn'
).
click
()
var
res
=
helper
.
store
.
get
(
'merchantMapObj'
)
// console.log(res)
merchantForm
.
lat
=
res
.
lat
merchantForm
.
lng
=
res
.
lng
merchantForm
.
merchantAddress
=
res
.
merchantAddress
setInput
(
'#addrEl'
,
merchantForm
.
merchantAddress
)
layer
.
close
(
index
)
},
end
:
function
()
{
helper
.
store
.
remove
(
'merchantMapObj'
)
}
imgEl
.
attr
(
'src'
,
result
.
data
)
imgEl
.
removeClass
(
'hide'
)
imgEl
.
addClass
(
'show'
)
addEl
.
removeClass
(
'show'
)
addEl
.
addClass
(
'hide'
)
},
{},
[
'file'
],
true
)
})
},
// 添加范围
handleAddScope
(
txt
)
{
var
parent
=
$
(
'#custom-scope'
)
var
subParent
=
$
(
'<div class="layui-form-item"><label class="layui-form-label"></label></div>'
)
var
child1
=
$
(
'<div class="layui-input-inline"></div>'
)
var
inputEl
=
$
(
'<input class="layui-input business-scope-cust" maxlength="15" placeholder="请自定义营业范围,建议不超过10个">'
)
var
child2
=
$
(
'<div class="layui-input-inline"></div>'
)
var
addBtn
=
$
(
'<button type="button" class="layui-btn btn-no-border"><i class="layui-icon layui-icon-add-circle"></i></button>'
)
var
deleteBtn
=
$
(
'<button type="button" class="layui-btn btn-no-border"><i class="layui-icon layui-icon-reduce-circle"></i></button>'
)
if
(
txt
)
{
inputEl
.
val
(
txt
)
}
addBtn
.
bind
(
'click'
,
function
(
e
)
{
btnHandle
.
handleAddScope
()
})
deleteBtn
.
bind
(
'click'
,
function
(
e
)
{
var
el
=
$
(
this
).
parent
().
parent
()
el
.
remove
()
})
child1
.
append
(
inputEl
)
child2
.
append
(
addBtn
)
child2
.
append
(
deleteBtn
)
subParent
.
append
(
child1
)
subParent
.
append
(
child2
)
parent
.
append
(
subParent
)
},
handleCancel
()
{
go
(
'merchant'
,
'index'
)
return
false
}
}
reader
.
onload
()
})
function
baseIsShow
(
isShow
)
{
if
(
isShow
)
{
$
(
'#basicForm'
).
show
()
}
else
{
$
(
'#basicForm'
).
hide
()
$
(
'.layui-btn'
).
on
(
'click'
,
function
()
{
var
type
=
$
(
this
).
data
(
'type'
)
if
(
btnHandle
[
type
])
{
btnHandle
[
type
]()
}
})
$
(
'.upload'
).
on
(
'change'
,
function
(
e
)
{
// console.log(e)
var
idx
=
$
(
this
).
data
(
'idx'
)
var
imgEl
=
$
(
'#img'
+
idx
)
var
el
=
$
(
'#upload'
+
idx
)
var
addEl
=
$
(
'.img-add'
+
idx
)
var
reader
=
new
FileReader
()
var
fileInfo
=
el
[
0
].
files
[
0
]
// console.log(el)
reader
.
readAsDataURL
(
fileInfo
)
reader
.
onload
=
function
(
e
)
{
if
(
e
)
{
const
imgFile
=
e
.
target
.
result
const
base64
=
fileInfo
.
name
.
split
(
'.'
)[
1
]
+
'@'
+
imgFile
.
split
(
','
)[
1
]
request
({
method
:
'glsx.accounts.biz.common.pictureUpload'
,
file
:
base64
},
function
(
result
)
{
merchantForm
.
merchantFiles
[
idx
]
=
{
fileUrl
:
result
.
data
,
fileName
:
''
}
imgEl
.
attr
(
'src'
,
result
.
data
)
imgEl
.
removeClass
(
'hide'
)
imgEl
.
addClass
(
'show'
)
addEl
.
removeClass
(
'show'
)
addEl
.
addClass
(
'hide'
)
},
{},
[
'file'
],
true
)
}
}
reader
.
onload
()
})
function
baseIsShow
(
isShow
)
{
if
(
isShow
)
{
$
(
'#basicForm'
).
show
()
}
else
{
$
(
'#basicForm'
).
hide
()
}
}
}
function
treeIsShow
(
isShow
)
{
if
(
isShow
)
{
$
(
'#authorityTree'
).
show
()
}
else
{
$
(
'#authorityTree'
).
hide
()
function
treeIsShow
(
isShow
)
{
if
(
isShow
)
{
$
(
'#authorityTree'
).
show
()
}
else
{
$
(
'#authorityTree'
).
hide
()
}
}
}
function
init
()
{
editLevel
=
qs
(
'editLevel'
)
isFactory
=
(
qs
(
'isFactory'
)
==
'true'
)
step
=
qs
(
'step'
)
function
init
()
{
editLevel
=
qs
(
'editLevel'
)
isFactory
=
(
qs
(
'isFactory'
)
==
'true'
)
step
=
qs
(
'step'
)
if
(
step
==
1
)
{
treeIsShow
(
false
)
}
else
{
baseIsShow
(
false
)
}
if
(
step
==
1
)
{
treeIsShow
(
false
)
}
else
{
baseIsShow
(
false
)
}
// 创建商户
if
(
editLevel
==
1
)
{
$
(
'#accountLevelEl'
).
attr
(
'disabled'
,
true
)
getBusiScope
()
getCarBrandTree
()
getAccountLevel
()
getAccountType
()
}
else
{
merchantId
=
qs
(
'id'
)
$
(
'#preStep'
).
remove
()
if
(
editLevel
==
3
)
{
$
(
'#firstBtn'
).
text
(
'确定'
)
// 创建商户
if
(
editLevel
==
1
)
{
$
(
'#accountLevelEl'
).
attr
(
'disabled'
,
true
)
}
else
{
getBusiScope
()
getCarBrandTree
()
getAccountLevel
()
getAccountType
()
}
else
{
merchantId
=
qs
(
'id'
)
$
(
'#preStep'
).
remove
()
if
(
editLevel
==
3
)
{
$
(
'#firstBtn'
).
text
(
'确定'
)
$
(
'#accountLevelEl'
).
attr
(
'disabled'
,
true
)
}
else
{
getBusiScope
()
getCarBrandTree
()
getAccountType
()
}
if
(
isFactory
)
{
getAccountLevel
()
getMerchantInfo
()
}
else
{
// 创建/编辑子商户
parentMerchantId
=
qs
(
'parentId'
)
// $('#validPeriodEl').attr('disabled', true)
$
(
'#channelEl'
).
attr
(
'disabled'
,
true
)
getParentInfo
()
}
}
if
(
isFactory
)
{
getAccountLevel
()
getMerchantInfo
()
}
else
{
// 创建/编辑子商户
parentMerchantId
=
qs
(
'parentId'
)
// $('#validPeriodEl').attr('disabled', true)
$
(
'#channelEl'
).
attr
(
'disabled'
,
true
)
getParentInfo
()
$
(
'#subMerchantEl'
).
hide
()
}
}
if
(
isFactory
)
{
$
(
'#subMerchantEl'
).
hide
()
getChannel
()
getPeriod
()
}
getChannel
()
getPeriod
()
}
function
bindEvent
()
{
$
(
'#brand'
).
on
(
'input'
,
helper
.
debounce
(
function
()
{
var
txt
=
$
(
this
).
val
()
if
(
!
txt
)
{
treeObj
.
showNodes
(
all_nodes
)
}
else
{
var
show_nodes
=
treeObj
.
getNodesByParamFuzzy
(
'label'
,
txt
)
treeObj
.
hideNodes
(
all_nodes
)
treeObj
.
showNodes
(
show_nodes
)
}
},
500
))
}
function
bindEvent
()
{
$
(
'#brand'
).
on
(
'input'
,
helper
.
debounce
(
function
()
{
var
txt
=
$
(
this
).
val
()
if
(
!
txt
)
{
treeObj
.
showNodes
(
all_nodes
)
function
setCheckbox
(
checkedStr
,
attr
)
{
if
(
!
checkedStr
||
!
checkedStr
.
length
)
{
return
false
}
var
list
=
[]
if
(
layui
.
_isArray
(
checkedStr
))
{
list
=
checkedStr
}
else
{
var
show_nodes
=
treeObj
.
getNodesByParamFuzzy
(
'label'
,
txt
)
treeObj
.
hideNodes
(
all_nodes
)
treeObj
.
showNodes
(
show_nodes
)
list
=
checkedStr
.
split
(
','
)
}
},
500
))
}
function
setCheckbox
(
checkedStr
,
attr
)
{
if
(
!
checkedStr
||
!
checkedStr
.
length
)
{
return
false
}
var
list
=
[]
if
(
layui
.
_isArray
(
checkedStr
))
{
list
=
checkedStr
}
else
{
list
=
checkedStr
.
split
(
','
)
// console.log(list)
$
.
each
(
list
,
function
(
index
,
item
)
{
$
(
'input[class='
+
attr
+
']'
).
attr
(
"checked"
,
true
)
})
}
// console.log(list)
$
.
each
(
list
,
function
(
index
,
item
)
{
$
(
'input[class='
+
attr
+
']'
).
attr
(
"checked"
,
true
)
})
}
function
getMerchantApi
(
id
,
fn
)
{
request
({
method
:
'cn.com.glsx.merchants.merchant.findMerchantDetail'
,
id
:
id
},
function
(
res
)
{
fn
&&
fn
(
res
)
})
}
function
getMerchantApi
(
id
,
fn
)
{
request
({
method
:
'cn.com.glsx.merchants.merchant.findMerchantDetail'
,
id
:
id
},
function
(
res
)
{
fn
&&
fn
(
res
)
})
}
// 子商户 - 获取父商户信息
function
getParentInfo
()
{
// console.log(parentMerchantId)
getMerchantApi
(
parentMerchantId
,
function
(
res
)
{
// console.log(res.data)
var
data
=
res
.
data
parentInfo
=
{
parentId
:
data
.
id
,
parentName
:
data
.
merchantName
,
parentAccountTypeName
:
data
.
accountTypeNames
,
parentAccountType
:
data
.
merchantType
,
channelId
:
data
.
channelId
,
effectiveTime
:
data
.
effectiveTime
}
form
.
val
(
'merchantForm'
,
parentInfo
)
if
(
editLevel
==
3
)
{
getMerchantInfo
()
$
(
'#accountLevelEl'
).
attr
(
'disabled'
,
true
)
}
getAccountLevel
()
})
}
// 子商户 - 获取父商户信息
function
getParentInfo
()
{
// console.log(parentMerchantId)
getMerchantApi
(
parentMerchantId
,
function
(
res
)
{
// console.log(res.data)
var
data
=
res
.
data
parentInfo
=
{
parentId
:
data
.
id
,
parentName
:
data
.
merchantName
,
parentAccountTypeName
:
data
.
accountTypeNames
,
parentAccountType
:
data
.
merchantType
,
channelId
:
data
.
channelId
,
effectiveTime
:
data
.
effectiveTime
}
form
.
val
(
'merchantForm'
,
parentInfo
)
if
(
editLevel
==
3
)
{
getMerchantInfo
()
$
(
'#accountLevelEl'
).
attr
(
'disabled'
,
true
)
}
getAccountLevel
()
})
}
// 获取商户信息
function
getMerchantInfo
()
{
getMerchantApi
(
merchantId
,
function
(
res
)
{
form
.
val
(
'merchantForm'
,
res
.
data
)
merchantForm
=
res
.
data
if
(
merchantForm
.
status
!=
1
)
{
$
(
'#draft'
).
remove
()
}
console
.
log
(
merchantForm
)
getBusiScope
()
getCarBrandTree
()
getAccountType
()
recoveryBusiScopeCus
()
recoveryFile
()
// if (merchantForm.status == 1) {
// findMenuFunTreeByMerId()
// } else {
getById
()
// }
})
}
// 获取商户信息
function
getMerchantInfo
()
{
getMerchantApi
(
merchantId
,
function
(
res
)
{
form
.
val
(
'merchantForm'
,
res
.
data
)
merchantForm
=
res
.
data
if
(
merchantForm
.
status
!=
1
)
{
$
(
'#draft'
).
remove
()
}
console
.
log
(
merchantForm
)
getBusiScope
()
getCarBrandTree
()
getAccountType
()
recoveryBusiScopeCus
()
recoveryFile
()
// if (merchantForm.status == 1) {
// findMenuFunTreeByMerId()
// } else {
getById
()
// }
})
}
// 渠道
function
getChannel
()
{
getDictData
(
'channel'
,
function
(
res
)
{
baseData
.
channelList
=
res
.
data
setSelectOption
(
'#channelEl'
,
'channelList'
,
'dictValue'
,
'dictLabel'
)
})
}
// 渠道
function
getChannel
()
{
getDictData
(
'channel'
,
function
(
res
)
{
baseData
.
channelList
=
res
.
data
setSelectOption
(
'#channelEl'
,
'channelList'
,
'dictValue'
,
'dictLabel'
)
})
}
// 品牌
function
getCarBrandTree
()
{
request
({
method
:
'cn.com.glsx.merchants.merchantCommon.getCarbrandTree'
},
function
(
res
)
{
baseData
.
carBrandTreeList
=
res
.
data
var
checkedList
=
[]
if
(
editLevel
==
3
&&
merchantForm
.
merchantBrand
)
{
checkedList
=
merchantForm
.
merchantBrand
.
split
(
','
)
$
.
each
(
checkedList
,
function
(
index
,
item
)
{
checkedList
[
index
]
=
parseInt
(
item
)
// 品牌
function
getCarBrandTree
()
{
request
({
method
:
'cn.com.glsx.merchants.merchantCommon.getCarbrandTree'
},
function
(
res
)
{
baseData
.
carBrandTreeList
=
res
.
data
var
checkedList
=
[]
if
(
editLevel
==
3
&&
merchantForm
.
merchantBrand
)
{
checkedList
=
merchantForm
.
merchantBrand
.
split
(
','
)
$
.
each
(
checkedList
,
function
(
index
,
item
)
{
checkedList
[
index
]
=
parseInt
(
item
)
})
}
treeObj
=
tree
.
create
(
'carBrandTree'
,
res
.
data
,
{
checkedList
:
checkedList
})
}
treeObj
=
tree
.
create
(
'carBrandTree'
,
res
.
data
,
{
checkedList
:
checkedList
all_nodes
=
treeObj
.
getNodes
()
bindEvent
()
})
all_nodes
=
treeObj
.
getNodes
()
bindEvent
()
})
}
// 获取字典数据
function
getDictData
(
dictType
,
fn
)
{
request
({
method
:
'cn.com.glsx.merchants.menu.findAllDictData'
,
dictType
:
dictType
},
function
(
res
)
{
fn
&&
fn
(
res
)
})
}
// 设置option
function
setSelectOption
(
elName
,
listName
,
optionId
,
optionLabel
)
{
var
el
=
$
(
elName
)
$
.
each
(
baseData
[
listName
],
function
(
index
,
item
)
{
el
.
append
(
new
Option
(
item
[
optionLabel
],
item
[
optionId
]))
})
form
.
render
(
'select'
)
}
// 设置input值
function
setInput
(
elName
,
value
)
{
$
(
elName
).
val
(
value
)
}
}
// 获取字典数据
function
getDictData
(
dictType
,
fn
)
{
request
({
method
:
'cn.com.glsx.merchants.menu.findAllDictData'
,
dictType
:
dictType
},
function
(
res
)
{
fn
&&
fn
(
res
)
})
}
// 账户等级
function
getAccountLevel
()
{
getDictData
(
'account_level'
,
function
(
res
)
{
baseData
.
accountLevelList
=
res
.
data
console
.
log
(
baseData
.
accountLevelList
)
if
(
!
isFactory
)
{
var
tempList
=
[]
$
.
each
(
baseData
.
accountLevelList
,
function
(
index
,
item
)
{
if
(
item
.
dictValue
>
parentInfo
.
parentAccountType
)
{
tempList
.
push
(
baseData
.
accountLevelList
[
index
])
}
})
baseData
.
accountLevelList
=
tempList
}
setSelectOption
(
'#accountLevelEl'
,
'accountLevelList'
,
'dictValue'
,
'dictLabel'
)
})
}
// 设置option
function
setSelectOption
(
elName
,
listName
,
optionId
,
optionLabel
)
{
var
el
=
$
(
elName
)
$
.
each
(
baseData
[
listName
],
function
(
index
,
item
)
{
el
.
append
(
new
Option
(
item
[
optionLabel
],
item
[
optionId
]))
})
form
.
render
(
'select'
)
}
// 有效期
function
getPeriod
()
{
getDictData
(
'account_validity_period'
,
function
(
res
)
{
baseData
.
validPeriodList
=
res
.
data
setSelectOption
(
'#validPeriodEl'
,
'validPeriodList'
,
'dictValue'
,
'dictLabel'
)
})
}
// 设置input值
function
setInput
(
elName
,
value
)
{
$
(
elName
).
val
(
value
)
}
// 营业范围
function
getBusiScope
()
{
getDictData
(
'business_scope'
,
function
(
res
)
{
baseData
.
busiScopeList
=
res
.
data
var
checkedList
=
[]
if
(
editLevel
==
3
&&
merchantForm
.
businessScope
)
{
checkedList
=
merchantForm
.
businessScope
.
split
(
','
)
}
var
el
=
$
(
'#busiScopeEl'
)
$
.
each
(
baseData
.
busiScopeList
,
function
(
index
,
item
)
{
var
optionEl
=
$
(
'<input type="checkbox" class="businessScope" name="businessScope['
+
item
.
dictValue
+
']" title='
+
item
.
dictLabel
+
' value="'
+
item
.
dictValue
+
'" lay-skin="primary">'
)
// 修改-回显
if
(
editLevel
==
3
)
{
for
(
var
i
=
0
;
i
<=
checkedList
.
length
;
i
++
)
{
if
(
checkedList
[
i
]
==
item
.
dictValue
)
{
optionEl
.
attr
(
"checked"
,
true
)
break
// 账户等级
function
getAccountLevel
()
{
getDictData
(
'account_level'
,
function
(
res
)
{
baseData
.
accountLevelList
=
res
.
data
// console.log(baseData.accountLevelList)
if
(
!
isFactory
)
{
var
tempList
=
[]
$
.
each
(
baseData
.
accountLevelList
,
function
(
index
,
item
)
{
if
(
item
.
dictValue
>
parentInfo
.
parentAccountType
)
{
tempList
.
push
(
baseData
.
accountLevelList
[
index
])
}
}
})
baseData
.
accountLevelList
=
tempList
}
el
.
append
(
optionEl
)
form
.
render
(
'checkbox'
)
setSelectOption
(
'#accountLevelEl'
,
'accountLevelList'
,
'dictValue'
,
'dictLabel'
)
})
})
}
}
// 恢复自定义营业范围
function
recoveryBusiScopeCus
()
{
// console.log(merchantForm.businessScopeCustomize)
if
(
merchantForm
.
businessScopeCustomize
)
{
var
scopeCusList
=
merchantForm
.
businessScopeCustomize
.
split
(
','
)
$
.
each
(
scopeCusList
,
function
(
index
,
item
)
{
if
(
index
!=
0
)
{
btnHandle
.
handleAddScope
(
item
)
}
else
{
$
(
'#scopeCus'
).
val
(
item
)
}
// 有效期
function
getPeriod
()
{
getDictData
(
'account_validity_period'
,
function
(
res
)
{
baseData
.
validPeriodList
=
res
.
data
setSelectOption
(
'#validPeriodEl'
,
'validPeriodList'
,
'dictValue'
,
'dictLabel'
)
})
}
}
// 恢复图片
function
recoveryFile
()
{
// console.log(merchantForm.merchantFileResponses)
merchantForm
.
merchantFiles
=
[]
$
.
each
(
merchantForm
.
merchantFileResponses
,
function
(
index
,
item
)
{
var
imgEl
=
$
(
'#img'
+
index
)
var
el
=
$
(
'#upload'
+
index
)
var
addEl
=
$
(
'.img-add'
+
index
)
merchantForm
.
merchantFiles
[
index
]
=
{
fileUrl
:
item
.
fileUrl
,
fileName
:
item
.
fileName
}
imgEl
.
attr
(
'src'
,
item
.
fileUrl
)
imgEl
.
removeClass
(
'hide'
)
imgEl
.
addClass
(
'show'
)
addEl
.
removeClass
(
'show'
)
addEl
.
addClass
(
'hide'
)
})
}
// 账户类型
function
getAccountType
()
{
getDictData
(
'account_type'
,
function
(
res
)
{
// console.log(res.data)
baseData
.
accountTypeList
=
res
.
data
var
checkedList
=
[]
if
(
editLevel
==
3
&&
merchantForm
.
accountType
)
{
checkedList
=
merchantForm
.
accountType
.
split
(
','
)
}
var
el
=
$
(
'#accountTypeEl'
)
$
.
each
(
baseData
.
accountTypeList
,
function
(
index
,
item
)
{
var
optionEl
=
$
(
'<input type="checkbox" class="accounttypeId" name="accountType['
+
item
.
dictValue
+
']" title='
+
item
.
dictLabel
+
' value="'
+
item
.
dictValue
+
'">'
)
// 修改-回显
if
(
editLevel
==
3
)
{
for
(
var
i
=
0
;
i
<=
checkedList
.
length
;
i
++
)
{
if
(
checkedList
[
i
]
==
item
.
dictValue
)
{
optionEl
.
attr
(
"checked"
,
true
)
break
// 营业范围
function
getBusiScope
()
{
getDictData
(
'business_scope'
,
function
(
res
)
{
baseData
.
busiScopeList
=
res
.
data
var
checkedList
=
[]
if
(
editLevel
==
3
&&
merchantForm
.
businessScope
)
{
checkedList
=
merchantForm
.
businessScope
.
split
(
','
)
}
var
el
=
$
(
'#busiScopeEl'
)
$
.
each
(
baseData
.
busiScopeList
,
function
(
index
,
item
)
{
var
optionEl
=
$
(
'<input type="checkbox" class="businessScope" name="businessScope['
+
item
.
dictValue
+
']" title='
+
item
.
dictLabel
+
' value="'
+
item
.
dictValue
+
'" lay-skin="primary">'
)
// 修改-回显
if
(
editLevel
==
3
)
{
for
(
var
i
=
0
;
i
<=
checkedList
.
length
;
i
++
)
{
if
(
checkedList
[
i
]
==
item
.
dictValue
)
{
optionEl
.
attr
(
"checked"
,
true
)
break
}
}
}
}
el
.
append
(
optionEl
)
form
.
render
(
'checkbox'
)
el
.
append
(
optionEl
)
form
.
render
(
'checkbox'
)
}
)
})
})
}
}
// 数 - start
var
laytpl
=
layui
.
laytpl
var
xmSelect
=
layui
.
xmSelect
var
check_arr
=
[]
var
requestList
=
[]
var
templateData
=
{}
var
selectEl
=
{}
var
treeData
=
{}
var
menuFunTreeData
=
[]
// 商户的菜单权限树数据
var
active
=
{
/**
* 第一级tab添加
* item: {name: 选项卡名称, value: 选项卡值}
* roleAuth: 选项卡过滤器的名称 lay-filter绑定的名字
* content: 一个放置模板的视图容器,用于呈现渲染结果 带有id的div
* id:选项卡标题的lay-id属性值
* 需要引入laytpl 模块
* rolesAuth:模板的id
* view 放置模板的视图容器的dom
* templateData:用于渲染模板的数据
* productList:复选下拉框的list,修改过的数据{name: '', value: ''}
* products:对应的菜单下的产品list,包含了对应的权限树,原始数据,需作为参数传入treeTabAdd中,在实例化tree时传入的数据使用
*/
tabAdd
:
function
(
item
)
{
// console.log(item)
// 渠道的id,一层选项卡的id
var
id
=
item
.
value
// roleAuth 一层选项卡过滤器的名称
element
.
tabAdd
(
'roleAuth'
,
{
title
:
item
.
title
,
// 放置模板视图的上一级div
content
:
'<div id="role'
+
id
+
'"></div>'
,
// 选项卡标题的lay-id属性值
id
:
id
})
var
getTpl
=
'<div id="select{{d.id}}"></div> <div class="layui-tab layui-tab-brief" lay-filter="treeTab{{d.id}}"><ul class="layui-tab-title"></ul> <div class="layui-tab-content"></div></div>'
// var getTpl = tpl//rolesAuth.innerHTML, // 模板内容
view
=
document
.
getElementById
(
'role'
+
id
)
templateData
.
id
=
id
// 渲染模版的数据
laytpl
(
getTpl
).
render
(
templateData
,
function
(
html
)
{
view
.
innerHTML
=
html
})
var
productList
=
[]
var
products
=
[]
$
.
each
(
menuFunTreeData
,
function
(
index
,
item
)
{
if
(
item
.
accounttypeId
==
id
)
{
products
=
item
.
products
$
.
each
(
item
.
products
,
function
(
idx
,
i
)
{
productList
.
push
({
name
:
i
.
productName
,
value
:
i
.
productId
})
})
}
})
selectEl
[
id
]
=
xmSelect
.
render
({
el
:
'#select'
+
id
,
data
:
productList
,
on
:
function
(
data
)
{
//arr: 当前多选已选中的数据
var
arr
=
data
.
arr
//change, 此次选择变化的数据,数组
var
change
=
data
.
change
//isAdd, 此次操作是新增还是删除
var
isAdd
=
data
.
isAdd
var
filterName
=
'treeTab'
+
id
if
(
isAdd
)
{
active
.
treeTabAdd
(
change
[
0
],
id
,
products
)
// 恢复自定义营业范围
function
recoveryBusiScopeCus
()
{
// console.log(merchantForm.businessScopeCustomize)
if
(
merchantForm
.
businessScopeCustomize
)
{
var
scopeCusList
=
merchantForm
.
businessScopeCustomize
.
split
(
','
)
$
.
each
(
scopeCusList
,
function
(
index
,
item
)
{
if
(
index
!=
0
)
{
btnHandle
.
handleAddScope
(
item
)
}
else
{
var
productId
=
'tab_'
+
id
+
'_'
+
change
[
0
].
value
active
.
tabDelete
(
filterName
,
productId
)
}
if
(
arr
.
length
!=
0
)
{
var
productId
=
'tab_'
+
id
+
'_'
+
arr
[
0
].
value
active
.
tabChange
(
filterName
,
productId
)
$
(
'#scopeCus'
).
val
(
item
)
}
}
})
console
.
log
(
selectEl
[
id
])
},
// tab删除
tabDelete
:
function
(
name
,
id
)
{
element
.
tabDelete
(
name
,
id
)
},
// tab Change
tabChange
:
function
(
name
,
id
)
{
element
.
tabChange
(
name
,
id
)
},
/**
* 第二级选项卡
* treeTabAdd 产品的权限添加
* item: {name: 选项卡名称, value: 选项卡值}
* id 第一级选项卡的item.value
* filterName: 过滤器的名称 lay-filter绑定的值
* treeData:渲染模板的数据,和用来存放对应树实例的对象,
* products:产品list数组
* defaultList:编辑时传入,默认勾选中的数组。(举例:[1,2,3])
*/
treeTabAdd
:
function
(
item
,
id
,
products
,
defaultList
)
{
console
.
log
(
defaultList
)
var
productId
=
'tab_'
+
id
+
'_'
+
item
.
value
var
filterName
=
'treeTab'
+
id
// 过滤器的名称 lay-filter
element
.
tabAdd
(
filterName
,
{
title
:
item
.
name
,
content
:
'<div id="treeTab'
+
productId
+
'"></div>'
,
// 放置模板视图的div
id
:
productId
})
var
getTreeTpl
=
treeAuth
.
innerHTML
,
// 获取的模板的id的内容
treeView
=
document
.
getElementById
(
'treeTab'
+
productId
)
// 放置模板视图的div
treeData
[
id
]
=
treeData
[
id
]
||
{}
treeData
[
id
][
item
.
value
]
=
treeData
[
id
][
item
.
value
]
||
{}
treeData
[
id
][
item
.
value
].
id
=
productId
// 渲染模版的数据
treeData
[
id
][
item
.
value
].
productId
=
item
.
value
laytpl
(
getTreeTpl
).
render
(
treeData
[
id
][
item
.
value
],
function
(
html
)
{
treeView
.
innerHTML
=
html
})
var
treeListData
=
[]
$
.
each
(
products
,
function
(
index
,
i
)
{
if
(
item
.
value
==
i
.
productId
)
{
treeListData
=
i
.
merchantProTreeResponses
}
})
var
treedom
=
'tree_'
+
productId
if
(
!
merchantId
)
{
treeData
[
id
][
item
.
value
].
treeObj
=
tree
.
create
(
treedom
,
treeListData
)
treeData
[
id
][
item
.
value
].
treeObj
.
checkAllNodes
(
true
)
}
else
{
treeData
[
id
][
item
.
value
].
treeObj
=
tree
.
create
(
treedom
,
treeListData
,
{
checkedList
:
defaultList
})
}
}
}
// 复选框的change事件
// form.on('checkbox(switch)', function (data) {
// var arr = []
// if (data.elem.checked) {
// var obj = {
// title: data.elem.title,
// value: data.elem.value
// }
// arr.push({
// accounttypeId: data.elem.value
// })
// active.tabAdd(obj)
// } else {
// for (var i in arr) {
// var id = arr[i].accounttypeId
// if (arr[i].accounttypeId == data.elem.value) {
// active.tabDelete('roleAuth', id)
// arr.splice(i, 1)
// }
// }
// }
// if (arr.length != 0) {
// active.tabChange('roleAuth', arr[0].accounttypeId)
// }
// })
// end
// function toInt(str) {
// var arr = str.split(',')
// $.each(arr, function (index, item) {
// arr[index] = parseInt(item)
// })
// return arr
// }
// 恢复图片
function
recoveryFile
()
{
// console.log(merchantForm.merchantFileResponses)
merchantForm
.
merchantFiles
=
[]
$
.
each
(
merchantForm
.
merchantFileResponses
,
function
(
index
,
item
)
{
var
imgEl
=
$
(
'#img'
+
index
)
var
el
=
$
(
'#upload'
+
index
)
var
addEl
=
$
(
'.img-add'
+
index
)
merchantForm
.
merchantFiles
[
index
]
=
{
fileUrl
:
item
.
fileUrl
,
fileName
:
item
.
fileName
}
imgEl
.
attr
(
'src'
,
item
.
fileUrl
)
imgEl
.
removeClass
(
'hide'
)
imgEl
.
addClass
(
'show'
)
addEl
.
removeClass
(
'show'
)
addEl
.
addClass
(
'hide'
)
})
}
// 查询商户的菜单权限树
function
findMenuFunTreeByMerId
()
{
console
.
log
(
merchantForm
,
'查询商户菜单权限树'
)
console
.
log
(
parentMerchantId
,
'parentMerchantId'
)
var
params
=
{}
if
(
parentMerchantId
)
{
params
=
{
method
:
'cn.com.glsx.merchants.merchant.findMenuFunTreeByMerId'
,
id
:
merchantId
,
parentId
:
parentMerchantId
,
accountLevel
:
merchantForm
.
merchantAccountLevel
}
}
else
{
params
=
{
method
:
'cn.com.glsx.merchants.merchant.accountTypeSearchRequest'
,
// method: 'org.ore.api.accountType.getProductTreeList',
ids
:
merchantForm
.
accountType
,
merchantId
:
merchantId
,
accountLevel
:
merchantForm
.
merchantAccountLevel
}
// 账户类型
function
getAccountType
()
{
getDictData
(
'account_type'
,
function
(
res
)
{
// console.log(res.data)
baseData
.
accountTypeList
=
res
.
data
var
checkedList
=
[]
if
(
editLevel
==
3
&&
merchantForm
.
accountType
)
{
checkedList
=
merchantForm
.
accountType
.
split
(
','
)
}
var
el
=
$
(
'#accountTypeEl'
)
$
.
each
(
baseData
.
accountTypeList
,
function
(
index
,
item
)
{
var
optionEl
=
$
(
'<input type="checkbox" class="accounttypeId" name="accountType['
+
item
.
dictValue
+
']" title='
+
item
.
dictLabel
+
' value="'
+
item
.
dictValue
+
'">'
)
// 修改-回显
if
(
editLevel
==
3
)
{
for
(
var
i
=
0
;
i
<=
checkedList
.
length
;
i
++
)
{
if
(
checkedList
[
i
]
==
item
.
dictValue
)
{
optionEl
.
attr
(
"checked"
,
true
)
break
}
}
}
el
.
append
(
optionEl
)
form
.
render
(
'checkbox'
)
})
})
}
console
.
log
(
params
.
method
)
request
(
params
,
function
(
res
)
{
if
(
res
.
code
==
'0'
)
{
// callback(res.data)
menuFunTreeData
=
res
.
data
// console.log(menuFunTreeData)
var
accountType
=
$
(
'#accountType'
)
// 数 - start
var
laytpl
=
layui
.
laytpl
var
xmSelect
=
layui
.
xmSelect
var
check_arr
=
[]
var
requestList
=
[]
var
templateData
=
{}
var
selectEl
=
{}
var
treeData
=
{}
var
menuFunTreeData
=
[]
// 商户的菜单权限树数据
var
active
=
{
/**
* 第一级tab添加
* item: {name: 选项卡名称, value: 选项卡值}
* roleAuth: 选项卡过滤器的名称 lay-filter绑定的名字
* content: 一个放置模板的视图容器,用于呈现渲染结果 带有id的div
* id:选项卡标题的lay-id属性值
* 需要引入laytpl 模块
* rolesAuth:模板的id
* view 放置模板的视图容器的dom
* templateData:用于渲染模板的数据
* productList:复选下拉框的list,修改过的数据{name: '', value: ''}
* products:对应的菜单下的产品list,包含了对应的权限树,原始数据,需作为参数传入treeTabAdd中,在实例化tree时传入的数据使用
*/
tabAdd
:
function
(
item
)
{
// console.log(item)
// 渠道的id,一层选项卡的id
var
id
=
item
.
value
// roleAuth 一层选项卡过滤器的名称
element
.
tabAdd
(
'roleAuth'
,
{
title
:
item
.
title
,
// 放置模板视图的上一级div
content
:
'<div id="role'
+
id
+
'"></div>'
,
// 选项卡标题的lay-id属性值
id
:
id
})
var
getTpl
=
'<div id="select{{d.id}}"></div> <div class="layui-tab layui-tab-brief" lay-filter="treeTab{{d.id}}"><ul class="layui-tab-title"></ul> <div class="layui-tab-content"></div></div>'
// var getTpl = tpl//rolesAuth.innerHTML, // 模板内容
view
=
document
.
getElementById
(
'role'
+
id
)
templateData
.
id
=
id
// 渲染模版的数据
laytpl
(
getTpl
).
render
(
templateData
,
function
(
html
)
{
view
.
innerHTML
=
html
})
var
productList
=
[]
var
products
=
[]
$
.
each
(
menuFunTreeData
,
function
(
index
,
item
)
{
// console.log(item)
var
str
=
$
(
'<input lay-filter="switch" type="checkbox" name="accounttypeId" value="'
+
item
.
accounttypeId
+
'" title="'
+
item
.
accounttypeName
+
'" />'
)
accountType
.
append
(
str
)
// console.log(check_arr, '0000000000')
if
(
merchantId
)
{
// 角色权限的check
for
(
var
i
=
0
;
i
<
check_arr
.
length
;
i
++
)
{
if
(
check_arr
[
i
].
accounttypeId
==
item
.
accounttypeId
)
{
var
productData
=
check_arr
[
i
]
str
.
attr
(
"checked"
,
true
)
var
obj
=
{
title
:
item
.
accounttypeName
,
value
:
item
.
accounttypeId
}
active
.
tabAdd
(
obj
)
var
selectArr
=
[]
var
menuData
=
[]
for
(
var
j
=
0
;
j
<
productData
.
products
.
length
;
j
++
)
{
menuData
=
productData
.
products
[
j
]
selectArr
.
push
(
menuData
.
productId
)
var
idList
=
menuData
.
menuIds
.
concat
(
menuData
.
functionIds
)
active
.
treeTabAdd
({
name
:
menuData
.
productName
,
value
:
menuData
.
productId
},
item
.
accounttypeId
,
item
.
products
,
idList
)
}
// // 产品的回显
selectEl
[
item
.
accounttypeId
].
setValue
(
selectArr
)
var
filterName
=
'treeTab'
+
item
.
accounttypeId
var
productId
=
'tab_'
+
item
.
accounttypeId
+
'_'
+
item
.
products
[
0
].
productId
active
.
tabChange
(
filterName
,
productId
)
// 树的回显
}
if
(
item
.
accounttypeId
==
id
)
{
products
=
item
.
products
$
.
each
(
item
.
products
,
function
(
idx
,
i
)
{
productList
.
push
({
name
:
i
.
productName
,
value
:
i
.
productId
})
})
}
})
selectEl
[
id
]
=
xmSelect
.
render
({
el
:
'#select'
+
id
,
data
:
productList
,
on
:
function
(
data
)
{
//arr: 当前多选已选中的数据
var
arr
=
data
.
arr
//change, 此次选择变化的数据,数组
var
change
=
data
.
change
//isAdd, 此次操作是新增还是删除
var
isAdd
=
data
.
isAdd
var
filterName
=
'treeTab'
+
id
if
(
isAdd
)
{
active
.
treeTabAdd
(
change
[
0
],
id
,
products
)
}
else
{
var
productId
=
'tab_'
+
id
+
'_'
+
change
[
0
].
value
active
.
tabDelete
(
filterName
,
productId
)
}
if
(
check_arr
.
length
!=
0
)
{
active
.
tabChange
(
'roleAuth'
,
check_arr
[
0
].
accounttypeId
)
if
(
arr
.
length
!=
0
)
{
var
productId
=
'tab_'
+
id
+
'_'
+
arr
[
0
].
value
active
.
tabChange
(
filterName
,
productId
)
}
}
})
form
.
render
(
'checkbox'
)
console
.
log
(
selectEl
[
id
])
},
// tab删除
tabDelete
:
function
(
name
,
id
)
{
element
.
tabDelete
(
name
,
id
)
},
// tab Change
tabChange
:
function
(
name
,
id
)
{
element
.
tabChange
(
name
,
id
)
},
/**
* 第二级选项卡
* treeTabAdd 产品的权限添加
* item: {name: 选项卡名称, value: 选项卡值}
* id 第一级选项卡的item.value
* filterName: 过滤器的名称 lay-filter绑定的值
* treeData:渲染模板的数据,和用来存放对应树实例的对象,
* products:产品list数组
* defaultList:编辑时传入,默认勾选中的数组。(举例:[1,2,3])
*/
treeTabAdd
:
function
(
item
,
id
,
products
,
defaultList
)
{
console
.
log
(
defaultList
)
var
productId
=
'tab_'
+
id
+
'_'
+
item
.
value
var
filterName
=
'treeTab'
+
id
// 过滤器的名称 lay-filter
element
.
tabAdd
(
filterName
,
{
title
:
item
.
name
,
content
:
'<div id="treeTab'
+
productId
+
'"></div>'
,
// 放置模板视图的div
id
:
productId
})
var
getTreeTpl
=
treeAuth
.
innerHTML
,
// 获取的模板的id的内容
treeView
=
document
.
getElementById
(
'treeTab'
+
productId
)
// 放置模板视图的div
treeData
[
id
]
=
treeData
[
id
]
||
{}
treeData
[
id
][
item
.
value
]
=
treeData
[
id
][
item
.
value
]
||
{}
treeData
[
id
][
item
.
value
].
id
=
productId
// 渲染模版的数据
treeData
[
id
][
item
.
value
].
productId
=
item
.
value
laytpl
(
getTreeTpl
).
render
(
treeData
[
id
][
item
.
value
],
function
(
html
)
{
treeView
.
innerHTML
=
html
})
var
treeListData
=
[]
$
.
each
(
products
,
function
(
index
,
i
)
{
if
(
item
.
value
==
i
.
productId
)
{
treeListData
=
i
.
merchantProTreeResponses
}
})
var
treedom
=
'tree_'
+
productId
if
(
!
merchantId
)
{
treeData
[
id
][
item
.
value
].
treeObj
=
tree
.
create
(
treedom
,
treeListData
)
treeData
[
id
][
item
.
value
].
treeObj
.
checkAllNodes
(
true
)
}
else
{
treeData
[
id
][
item
.
value
].
treeObj
=
tree
.
create
(
treedom
,
treeListData
,
{
checkedList
:
defaultList
})
}
}
})
}
// 根据id获取角色详情
function
getById
()
{
var
params
=
{
method
:
'cn.com.glsx.merchants.merchant.findPermissionsByMerId'
,
// method: 'org.ore.api.role.getById',
id
:
merchantId
}
request
(
params
,
function
(
res
)
{
if
(
res
.
code
==
'0'
)
{
// console.log(res.data, '角色详情')
var
accounttypeId
=
''
if
(
res
.
data
)
{
check_arr
=
res
.
data
// 复选框的change事件
// form.on('checkbox(switch)', function (data) {
// var arr = []
// if (data.elem.checked) {
// var obj = {
// title: data.elem.title,
// value: data.elem.value
// }
// arr.push({
// accounttypeId: data.elem.value
// })
// active.tabAdd(obj)
// } else {
// for (var i in arr) {
// var id = arr[i].accounttypeId
// if (arr[i].accounttypeId == data.elem.value) {
// active.tabDelete('roleAuth', id)
// arr.splice(i, 1)
// }
// }
// }
// if (arr.length != 0) {
// active.tabChange('roleAuth', arr[0].accounttypeId)
// }
// })
// end
// function toInt(str) {
// var arr = str.split(',')
// $.each(arr, function (index, item) {
// arr[index] = parseInt(item)
// })
// return arr
// }
// 查询商户的菜单权限树
function
findMenuFunTreeByMerId
()
{
// console.log(merchantForm, '查询商户菜单权限树')
// console.log(parentMerchantId, 'parentMerchantId')
var
params
=
{}
if
(
parentMerchantId
)
{
params
=
{
method
:
'cn.com.glsx.merchants.merchant.findMenuFunTreeByMerId'
,
id
:
merchantId
,
parentId
:
parentMerchantId
,
accountLevel
:
merchantForm
.
merchantAccountLevel
}
}
else
{
params
=
{
method
:
'cn.com.glsx.merchants.merchant.accountTypeSearchRequest'
,
// method: 'org.ore.api.accountType.getProductTreeList',
ids
:
merchantForm
.
accountType
,
merchantId
:
merchantId
,
accountLevel
:
merchantForm
.
merchantAccountLevel
}
console
.
log
(
check_arr
,
'角色详情check_arr'
)
findMenuFunTreeByMerId
()
form
.
val
(
'roleForm'
,
{
roleName
:
res
.
data
.
roleName
,
roleDescription
:
res
.
data
.
roleDescription
})
}
})
}
// console.log(params.method)
request
(
params
,
function
(
res
)
{
if
(
res
.
code
==
'0'
)
{
// callback(res.data)
menuFunTreeData
=
res
.
data
// console.log(menuFunTreeData)
var
accountType
=
$
(
'#accountType'
)
$
.
each
(
menuFunTreeData
,
function
(
index
,
item
)
{
// console.log(item)
var
str
=
$
(
'<input lay-filter="switch" type="checkbox" name="accounttypeId" value="'
+
item
.
accounttypeId
+
'" title="'
+
item
.
accounttypeName
+
'" />'
)
accountType
.
append
(
str
)
// console.log(check_arr, '0000000000')
if
(
merchantId
)
{
// 角色权限的check
for
(
var
i
=
0
;
i
<
check_arr
.
length
;
i
++
)
{
if
(
check_arr
[
i
].
accounttypeId
==
item
.
accounttypeId
)
{
var
productData
=
check_arr
[
i
]
str
.
attr
(
"checked"
,
true
)
var
obj
=
{
title
:
item
.
accounttypeName
,
value
:
item
.
accounttypeId
}
active
.
tabAdd
(
obj
)
var
selectArr
=
[]
var
menuData
=
[]
for
(
var
j
=
0
;
j
<
productData
.
products
.
length
;
j
++
)
{
menuData
=
productData
.
products
[
j
]
selectArr
.
push
(
menuData
.
productId
)
var
idList
=
menuData
.
menuIds
.
concat
(
menuData
.
functionIds
)
active
.
treeTabAdd
({
name
:
menuData
.
productName
,
value
:
menuData
.
productId
},
item
.
accounttypeId
,
item
.
products
,
idList
)
}
// // 产品的回显
selectEl
[
item
.
accounttypeId
].
setValue
(
selectArr
)
var
filterName
=
'treeTab'
+
item
.
accounttypeId
var
productId
=
'tab_'
+
item
.
accounttypeId
+
'_'
+
item
.
products
[
0
].
productId
active
.
tabChange
(
filterName
,
productId
)
// 树的回显
}
}
if
(
check_arr
.
length
!=
0
)
{
active
.
tabChange
(
'roleAuth'
,
check_arr
[
0
].
accounttypeId
)
}
// 获取角色权限数据requestList
function
getAuthList
()
{
requestList
=
[]
for
(
var
key
in
treeData
)
{
var
accountObj
=
treeData
[
key
]
var
productList
=
[]
for
(
var
i
in
accountObj
)
{
var
productObj
=
accountObj
[
i
]
var
menuIds
=
[]
var
functionIds
=
[]
var
functionIdLists
=
[]
var
nodes
=
productObj
.
treeObj
.
getCheckedNodes
(
true
)
$
.
each
(
nodes
,
function
(
index
,
item
)
{
if
(
item
.
logo
==
'function'
)
{
functionIdLists
.
push
(
item
)
}
else
{
menuIds
.
push
(
item
.
id
)
}
})
form
.
render
(
'checkbox'
)
}
})
}
// 根据id获取角色详情
function
getById
()
{
var
params
=
{
method
:
'cn.com.glsx.merchants.merchant.findPermissionsByMerId'
,
// method: 'org.ore.api.role.getById',
id
:
merchantId
}
request
(
params
,
function
(
res
)
{
if
(
res
.
code
==
'0'
)
{
// console.log(res.data, '角色详情')
var
accounttypeId
=
''
if
(
res
.
data
)
{
check_arr
=
res
.
data
}
})
$
.
each
(
functionIdLists
,
function
(
idx
,
m
)
{
// m.parentId
var
findIdx
=
-
1
$
.
each
(
functionIds
,
function
(
idn
,
n
)
{
if
(
n
.
mendId
==
m
.
parentId
)
{
findIdx
=
idn
// console.log(check_arr, '角色详情check_arr')
findMenuFunTreeByMerId
()
form
.
val
(
'roleForm'
,
{
roleName
:
res
.
data
.
roleName
,
roleDescription
:
res
.
data
.
roleDescription
})
}
})
}
// 获取角色权限数据requestList
function
getAuthList
()
{
requestList
=
[]
for
(
var
key
in
treeData
)
{
var
accountObj
=
treeData
[
key
]
var
productList
=
[]
for
(
var
i
in
accountObj
)
{
var
productObj
=
accountObj
[
i
]
var
menuIds
=
[]
var
functionIds
=
[]
var
functionIdLists
=
[]
var
nodes
=
productObj
.
treeObj
.
getCheckedNodes
(
true
)
$
.
each
(
nodes
,
function
(
index
,
item
)
{
if
(
item
.
logo
==
'function'
)
{
functionIdLists
.
push
(
item
)
}
else
{
menuIds
.
push
(
item
.
id
)
}
})
if
(
findIdx
!=
-
1
)
{
functionIds
[
findIdx
].
functionValue
+=
';'
+
m
.
id
+
':'
+
m
.
label
}
else
{
functionIds
.
push
(
{
functionId
:
m
.
parentId
,
mendId
:
m
.
superParentId
,
functionValue
:
m
.
id
+
':'
+
m
.
label
$
.
each
(
functionIdLists
,
function
(
idx
,
m
)
{
// m.parentId
var
findIdx
=
-
1
$
.
each
(
functionIds
,
function
(
idn
,
n
)
{
if
(
n
.
mendId
==
m
.
parentId
)
{
findIdx
=
idn
}
})
}
})
productList
.
push
({
productId
:
productObj
.
productId
,
functionIds
:
functionIds
,
menuIds
:
menuIds
if
(
findIdx
!=
-
1
)
{
functionIds
[
findIdx
].
functionValue
+=
';'
+
m
.
id
+
':'
+
m
.
label
}
else
{
functionIds
.
push
({
functionId
:
m
.
parentId
,
mendId
:
m
.
superParentId
,
functionValue
:
m
.
id
+
':'
+
m
.
label
})
}
})
productList
.
push
({
productId
:
productObj
.
productId
,
functionIds
:
functionIds
,
menuIds
:
menuIds
})
}
requestList
.
push
({
accountTypeId
:
key
,
products
:
productList
})
}
requestList
.
push
({
accountTypeId
:
key
,
products
:
productList
})
// console.log(requestList)
}
// console.log(requestList)
}
$
(
'#draft'
).
on
(
'click'
,
function
()
{
getAuthList
()
console
.
log
(
requestList
)
var
params
=
{
merchantId
:
merchantId
,
accountTypes
:
JSON
.
stringify
(
requestList
),
method
:
'cn.com.glsx.merchants.merchant.updatePermissions'
,
status
:
merchantForm
.
status
}
request
(
params
,
function
(
res
)
{
console
.
log
(
res
.
data
)
if
(
res
.
code
==
'0'
)
{
layer
.
msg
(
'操作成功'
,
{
icon
:
1
})
go
(
'merchant'
,
'index'
)
$
(
'#draft'
).
on
(
'click'
,
function
()
{
getAuthList
()
console
.
log
(
requestList
)
var
params
=
{
merchantId
:
merchantId
,
accountTypes
:
JSON
.
stringify
(
requestList
),
method
:
'cn.com.glsx.merchants.merchant.updatePermissions'
,
status
:
merchantForm
.
status
}
request
(
params
,
function
(
res
)
{
console
.
log
(
res
.
data
)
if
(
res
.
code
==
'0'
)
{
layer
.
msg
(
'操作成功'
,
{
icon
:
1
})
go
(
'merchant'
,
'index'
)
}
})
return
false
})
return
false
})
$
(
'#preStep'
).
on
(
'click'
,
function
()
{
step
=
1
init
()
})
$
(
'#preStep'
).
on
(
'click'
,
function
()
{
step
=
1
init
()
})
$
(
'#confirm'
).
on
(
'click'
,
function
()
{
// console.log(treeData)
getAuthList
()
console
.
log
(
merchantForm
)
console
.
log
(
requestList
)
// 草稿
var
params
=
{
merchantId
:
merchantId
,
accountTypes
:
JSON
.
stringify
(
requestList
)
}
params
.
method
=
'cn.com.glsx.merchants.merchant.updatePermissions'
if
(
merchantForm
.
status
==
1
)
{
params
.
status
=
2
}
else
{
params
.
status
=
merchantForm
.
status
}
request
(
params
,
function
(
res
)
{
console
.
log
(
res
.
data
)
if
(
res
.
code
==
'0'
)
{
layer
.
msg
(
'操作成功'
,
{
icon
:
1
})
go
(
'merchant'
,
'index'
)
$
(
'#confirm'
).
on
(
'click'
,
function
()
{
// console.log(treeData)
getAuthList
()
console
.
log
(
merchantForm
)
console
.
log
(
requestList
)
// 草稿
var
params
=
{
merchantId
:
merchantId
,
accountTypes
:
JSON
.
stringify
(
requestList
)
}
params
.
method
=
'cn.com.glsx.merchants.merchant.updatePermissions'
if
(
merchantForm
.
status
==
1
)
{
params
.
status
=
2
}
else
{
params
.
status
=
merchantForm
.
status
}
request
(
params
,
function
(
res
)
{
console
.
log
(
res
.
data
)
if
(
res
.
code
==
'0'
)
{
layer
.
msg
(
'操作成功'
,
{
icon
:
1
})
go
(
'merchant'
,
'index'
)
}
})
return
false
})
return
false
})
})
</script>
<script
type=
"text/html"
id=
"rolesAuth"
>
<
div
id
=
"select{{d.id}}"
><
/div
>
...
...
js/validator.js
0 → 100644
View file @
1ea2864
layui
.
define
([
'store'
],
function
(
exports
)
{
var
validator
=
{
/* 手机号码格式校验正则 */
PHONEREG
:
/^
(
13
[
0-9
]
|15
[
0-9
]
|16
[
0-9
]
|17
[
0-9
]
|18
[
0-9
]
|19
[
0-9
]
|14
[
0-9
])[
0-9
]{8}
$/
,
/* 同时包含字母和数字 */
ISNUMANDLETTERS
:
/^
[
a-zA-Z0-9
]
+$/
,
/* 特殊字符正则 */
SPECIALLETTER
:
new
RegExp
(
"[`~!@#$^&*=|{}':;',\\[\\]<>?~!@#¥……&*——|{}【】‘;:”“'。,、? ]"
),
/* 邮箱地址格式正则 */
// EMAILREG:/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/,
EMAILREG
:
/^
\w
+
([
-+.
]\w
+
)
*@
\w
+
([
-.
]\w
+
)
*
\.\w
+
([
-.
]\w
+
)
*$/
,
/* 判断是否为中文 */
ISCHINESE
:
/^
[\u
0391-
\u
FFE5
]
+$/
,
/* 判断是否为英文字母 */
ISENGLISH
:
/^
[
a-zA-Z
]
+$/
,
/* 是否包含空格 */
ISHAVENULL
:
/^
[^\s]
*$/
,
/* 保留两位小数 */
TWODECIMAL
:
/^
(([
1-9
][
0-9
]
*
)
|
(([
0
]\.\d{1,2}
|
[
1-9
][
0-9
]
*
\.\d{1,2})))
$/
,
/* 判断是否为正整数 */
ISDECIMAL
:
/^
[
0-9
]
*$/
,
/**
* 账号管理-手机号码校验
*/
checkPhoneNumber
:
function
(
str
)
{
return
validator
.
PHONEREG
.
test
(
str
)
},
// 判断是否含有数字或字母
checkNumOrLetters
:
function
(
str
)
{
return
validator
.
ISNUMANDLETTERS
.
test
(
str
)
},
// 身份证验证
// checkIdCard: function (code) {
// var city = {
// 11: '北京',
// 12: '天津',
// 13: '河北',
// 14: '山西',
// 15: '内蒙古',
// 21: '辽宁',
// 22: '吉林',
// 23: '黑龙江',
// 31: '上海',
// 32: '江苏',
// 33: '浙江',
// 34: '安徽',
// 35: '福建',
// 36: '江西',
// 37: '山东',
// 41: '河南',
// 42: '湖北',
// 43: '湖南',
// 44: '广东',
// 45: '广西',
// 46: '海南',
// 50: '重庆',
// 51: '四川',
// 52: '贵州',
// 53: '云南',
// 54: '西藏',
// 61: '陕西',
// 62: '甘肃',
// 63: '青海',
// 64: '宁夏',
// 65: '新疆',
// 71: '台湾',
// 81: '香港',
// 82: '澳门',
// 91: '国外 '
// }
// // var tip = ''
// var pass = true
// // 身份证位数为15或18位
// // if (![15, 18].includes(code.length)) {
// if ((code.length != 15) || (code.length != 18)) {
// pass = false
// } else if (!code || (code.length === 18 && !/^\d{6}(18|19|20)\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(code))) {
// // tip = '身份证号格式错误'
// pass = false
// } else if (code.length === 15 && !/^\d{6}\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}$/i.test(code)) {
// pass = false
// } else if (!city[code.substr(0, 2)]) {
// // tip = '地址编码错误'
// pass = false
// } else {
// // 18位身份证需要验证最后一位校验位
// if (code.length === 18) {
// code = code.split('')
// // ∑(ai×Wi)(mod 11)
// // 加权因子
// var factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
// // 校验位
// var parity = [1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2]
// var sum = 0
// var ai = 0
// var wi = 0
// for (var i = 0; i < 17; i++) {
// ai = code[i]
// wi = factor[i]
// sum += ai * wi
// }
// // var last = parity[sum % 11]
// if (parity[sum % 11] != code[17]) {
// // tip = '校验位错误'
// pass = false
// }
// }
// }
// // if (!pass) alert(tip)
// return pass
// }
}
exports
(
'validator'
,
validator
)
})
\ No newline at end of file
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