Commit b6aa5d56 by cwq0219

商户管理

1 parent b3900535
<!DOCTYPE html> <!DOCTYPE html>
<html lang="zh"> <html lang="zh">
<head>
<head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta content="IE=edge" /> <meta content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
...@@ -10,8 +11,9 @@ ...@@ -10,8 +11,9 @@
<link rel="stylesheet" type="text/css" href="/css/main.css" /> <link rel="stylesheet" type="text/css" href="/css/main.css" />
<link rel="stylesheet" type="text/css" href="/css/merchant.css" /> <link rel="stylesheet" type="text/css" href="/css/merchant.css" />
<title>商户管理</title> <title>商户管理</title>
</head> </head>
<body>
<body>
<div id="app"> <div id="app">
<main class="bg-white wrapper detail"> <main class="bg-white wrapper detail">
<div class="layui-tab"> <div class="layui-tab">
...@@ -104,16 +106,19 @@ ...@@ -104,16 +106,19 @@
<option value="021">上海</option> <option value="021">上海</option>
<option value="0571">杭州</option> <option value="0571">杭州</option>
</select> </select>
<div class="layui-tab" lay-filter="funAuth">
<ul class="layui-tab-title"></ul>
<div class="layui-tab-content"></div>
</div>
</h3> </h3>
</div> </div>
<div class="layui-tab-item"> <div class="layui-tab-item">
<div class="wrapper-merchant"> <div class="wrapper-merchant">
<div class="merchant-left"> <div class="merchant-left">
<div> <div id="secondmerchantName"></div>
<div>深圳</div> <div id="secondmerchantId">商户号</div>
<div>商户号</div> <div id="">宁接口了接口了就</div>
<div>宁接口了接口了就</div> </form>
</div>
<form class="layui-form" action=""> <form class="layui-form" action="">
<div class="layui-inline"> <div class="layui-inline">
<div class="layui-input-inline"> <div class="layui-input-inline">
...@@ -194,13 +199,15 @@ ...@@ -194,13 +199,15 @@
<script src="https://www.layuicdn.com/layui/layui.js"></script> <script src="https://www.layuicdn.com/layui/layui.js"></script>
<script src="/js/load.js"></script> <script src="/js/load.js"></script>
<script> <script>
layui.use(['request', 'gtree', 'element', 'helper', 'table'], function() { layui.use(['request', 'gtree', 'element', 'helper', 'table', 'form'], function () {
var $ = layui.$ var $ = layui.$
var request = layui.request var request = layui.request
var tree = layui.gtree var tree = layui.gtree
var helper = layui.helper var helper = layui.helper
var table = layui.table var table = layui.table
var id = qs('id') var form = layui.form
var merchantId = qs('merchantId')
var merchantInfo = {}
var basicArr = [ var basicArr = [
'merchantLoginAccount', 'merchantLoginAccount',
'accountTypeNames', 'accountTypeNames',
...@@ -216,10 +223,25 @@ ...@@ -216,10 +223,25 @@
'merchantBrandName' 'merchantBrandName'
] ]
var roleData = {} var roleData = {}
init()
function init() {
getFirstInfo()
getSecondInfo()
getSecondTree()
getSecondTable(subMerchantTable)
}
// 查询角色详情 // 查询角色详情
var params = { id: 31, method: 'cn.com.glsx.merchants.merchant.findMerchantDetail' } function getFirstInfo() {
request(params, function(res) { var params = {
console.log(res) id: merchantId,
method: 'cn.com.glsx.merchants.merchant.findMerchantDetail'
}
request(params, function (res) {
console.log(res, '账户信息')
if (res.code == '0') { if (res.code == '0') {
roleData = helper.clone(true, res.data) roleData = helper.clone(true, res.data)
for (var i in basicArr) { for (var i in basicArr) {
...@@ -227,52 +249,102 @@ ...@@ -227,52 +249,102 @@
} }
} }
}) })
}
// 上下级商户 - 信息
function getSecondInfo() {
request({
method: 'cn.com.glsx.merchants.menu.findSubordinateRelationship',
id: merchantId
}, function (res) {
console.log(res.data)
var data = res.data
var arr = ['merchantName', 'merchantId', '']
$.each(arr, function (index, item) {
console.log(data[item])
$('#second' + item).text(data[item])
})
})
}
// 上下级商户数 // 上下级商户 - 树
var treeParams = { id: 31, method: 'cn.com.glsx.merchants.merchant.findMerchantTree' } function getSecondTree() {
var treeParams = {
id: merchantId,
method: 'cn.com.glsx.merchants.merchant.findMerchantTree'
}
var merchants = {} var merchants = {}
request(treeParams, function(res) { request(treeParams, function (res) {
if (res.code == '0') { if (res.code == '0') {
merchants = tree.create('merchantTree', res.data) merchants = tree.create('merchantTree', res.data)
merchants.expandAll(true) merchants.expandAll(true)
} }
}) })
}
// 列表 // 列表配置
var subMerchantTable = table.render({ var subMerchantTable = table.render({
elem: '#subMerchantTable', elem: '#subMerchantTable',
page: false, page: false,
cols: [ cols: [
[ [{
{ field: '', title: '序号', type: 'numbers', width: 80 }, field: '',
{ field: 'staffName', title: '员工姓名', width: 120 }, title: '序号',
{ field: 'roleName', title: '角色', width: 120 }, type: 'numbers',
{ field: 'merchantName', title: '登录账户', width: 120 }, width: 80
{ field: 'statusName', title: '登录密码', width: 120 }, },
{ field: 'createdAccount ', title: '创建者', width: 100 }, {
{ field: 'createdTime', title: '创建时间', width: 150 } field: 'staffName',
title: '员工姓名',
width: 120
},
{
field: 'roleName',
title: '角色',
width: 120
},
{
field: 'merchantName',
title: '登录账户',
width: 120
},
{
field: 'statusName',
title: '登录密码',
width: 120
},
{
field: 'createdAccount ',
title: '创建者',
width: 100
},
{
field: 'createdTime',
title: '创建时间',
width: 150
}
] ]
] ]
}) })
getTabelList(subMerchantTable)
// 获取table列表接口 // 获取table列表接口
function getTabelList(table, isResetPageNum = false) { function getSecondTable(table, isResetPageNum = false) {
request( request({
{ method: 'cn.com.glsx.merchants.staff.findMerchantStaffList',
method: 'cn.com.glsx.merchants.merchant.findMerchantStaffList', merchantId: merchantId
merchantId: 31
}, },
function(res) { function (res) {
console.log(res) console.log(res)
var data = res.data var data = res.data
var options = { var options = {
data: data data: data
} }
table.reload(options) subMerchantTable.reload(options)
} }
) )
} }
}) })
</script> </script>
</body> </body>
</html> </html>
\ No newline at end of file \ No newline at end of file
...@@ -303,17 +303,19 @@ ...@@ -303,17 +303,19 @@
<!-- 权限树 --> <!-- 权限树 -->
<div id="authorityTree"> <div id="authorityTree">
<!-- 树-- --> <!-- 树-- -->
<div class="layui-form-item"> <!-- <div class="layui-form-item">
<label class="layui-form-label required">角色权限:</label> <label class="layui-form-label required">角色权限:</label>
<div class="layui-input-block" id="accountType"> <div class="layui-input-block" id="accountType"> -->
<!-- <input lay-filter="switch" type="checkbox" name="merchantId" value="1" title="引流渠道商" /> <!-- <input lay-filter="switch" type="checkbox" name="merchantId" value="1" title="引流渠道商" />
<input lay-filter="switch" type="checkbox" name="merchantId" value="2" title="服务商/合作商" /> --> <input lay-filter="switch" type="checkbox" name="merchantId" value="2" title="服务商/合作商" /> -->
</div> <!-- </div>
</div> </div> -->
<div class="layui-tab" lay-filter="roleAuth"> <div class="layui-tab" lay-filter="roleAuth">
<ul class="layui-tab-title"></ul> <ul class="layui-tab-title"></ul>
<div class="layui-tab-content"></div> <div class="layui-tab-content"></div>
</div> </div>
<button id="draft" class="layui-btn">存草稿</button>
<button id="preStep" class="layui-btn">上一步</button>
<button id="confirm" class="layui-btn">确定</button> <button id="confirm" class="layui-btn">确定</button>
<button class="layui-btn" data-type="handleCancel">取消</button> <button class="layui-btn" data-type="handleCancel">取消</button>
</div> </div>
...@@ -666,11 +668,12 @@ ...@@ -666,11 +668,12 @@
function init() { function init() {
editLevel = qs('editLevel') editLevel = qs('editLevel')
isFactory = (qs('isFactory') == 'true') isFactory = (qs('isFactory') == 'true')
console.log(isFactory) // console.log(isFactory)
if (isFactory) { if (isFactory) {
merchantId = qs('id') merchantId = qs('id')
$('#subMerchantEl').hide() $('#subMerchantEl').hide()
getAccountLevel() getAccountLevel()
getMerchantInfo()
} else { } else {
// 创建/编辑子商户 // 创建/编辑子商户
parentMerchantId = qs('parentId') parentMerchantId = qs('parentId')
...@@ -688,11 +691,12 @@ ...@@ -688,11 +691,12 @@
} else { } else {
baseIsShow(false) baseIsShow(false)
// getMenuList() // getMenuList()
findMenuFunTreeByMerId() // getById()
// findMenuFunTreeByMerId()
} }
if (editLevel == 3) { if (editLevel == 3) {
// merchantName = qs('merchantName') // merchantName = qs('merchantName')
getMerchantInfo() // getMerchantInfo()
$('#accountLevelEl').attr('disabled', true) $('#accountLevelEl').attr('disabled', true)
} else { } else {
getBusiScope() getBusiScope()
...@@ -771,14 +775,17 @@ ...@@ -771,14 +775,17 @@
getMerchantApi(merchantId, function (res) { getMerchantApi(merchantId, function (res) {
form.val('merchantForm', res.data) form.val('merchantForm', res.data)
merchantForm = res.data merchantForm = res.data
// console.log(merchantForm) console.log(merchantForm)
getBusiScope() getBusiScope()
getCarBrandTree() getCarBrandTree()
getAccountType() getAccountType()
recoveryBusiScopeCus() recoveryBusiScopeCus()
recoveryFile() recoveryFile()
if (merchantForm.status == 1) {
findMenuFunTreeByMerId()
} else {
getById() getById()
// findMenuFunTreeByMerId() }
}) })
} }
...@@ -902,7 +909,7 @@ ...@@ -902,7 +909,7 @@
// 恢复图片 // 恢复图片
function recoveryFile() { function recoveryFile() {
console.log(merchantForm.merchantFileResponses) // console.log(merchantForm.merchantFileResponses)
merchantForm.merchantFiles = [] merchantForm.merchantFiles = []
$.each(merchantForm.merchantFileResponses, function (index, item) { $.each(merchantForm.merchantFileResponses, function (index, item) {
var imgEl = $('#img' + index) var imgEl = $('#img' + index)
...@@ -993,6 +1000,7 @@ ...@@ -993,6 +1000,7 @@
* products:对应的菜单下的产品list,包含了对应的权限树,原始数据,需作为参数传入treeTabAdd中,在实例化tree时传入的数据使用 * products:对应的菜单下的产品list,包含了对应的权限树,原始数据,需作为参数传入treeTabAdd中,在实例化tree时传入的数据使用
*/ */
tabAdd: function (item) { tabAdd: function (item) {
console.log(item)
// 渠道的id,一层选项卡的id // 渠道的id,一层选项卡的id
var id = item.value var id = item.value
// roleAuth 一层选项卡过滤器的名称 // roleAuth 一层选项卡过滤器的名称
...@@ -1003,7 +1011,9 @@ ...@@ -1003,7 +1011,9 @@
// 选项卡标题的lay-id属性值 // 选项卡标题的lay-id属性值
id: id id: id
}) })
var getTpl = rolesAuth.innerHTML, // 模板内容 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) view = document.getElementById('role' + id)
templateData.id = id // 渲染模版的数据 templateData.id = id // 渲染模版的数据
laytpl(getTpl).render(templateData, function (html) { laytpl(getTpl).render(templateData, function (html) {
...@@ -1045,7 +1055,7 @@ ...@@ -1045,7 +1055,7 @@
} }
} }
}) })
// console.log(selectEl[id]) console.log(selectEl[id])
}, },
// tab删除 // tab删除
tabDelete: function (name, id) { tabDelete: function (name, id) {
...@@ -1066,7 +1076,7 @@ ...@@ -1066,7 +1076,7 @@
* defaultList:编辑时传入,默认勾选中的数组。(举例:[1,2,3]) * defaultList:编辑时传入,默认勾选中的数组。(举例:[1,2,3])
*/ */
treeTabAdd: function (item, id, products, defaultList) { treeTabAdd: function (item, id, products, defaultList) {
// console.log(defaultList) console.log(defaultList)
var productId = 'tab_' + id + '_' + item.value var productId = 'tab_' + id + '_' + item.value
var filterName = 'treeTab' + id // 过滤器的名称 lay-filter var filterName = 'treeTab' + id // 过滤器的名称 lay-filter
element.tabAdd(filterName, { element.tabAdd(filterName, {
...@@ -1090,7 +1100,6 @@ ...@@ -1090,7 +1100,6 @@
} }
}) })
var treedom = 'tree_' + productId var treedom = 'tree_' + productId
// console.log(merchantId)
if (!merchantId) { if (!merchantId) {
treeData[id][item.value].treeObj = tree.create(treedom, treeListData) treeData[id][item.value].treeObj = tree.create(treedom, treeListData)
treeData[id][item.value].treeObj.checkAllNodes(true) treeData[id][item.value].treeObj.checkAllNodes(true)
...@@ -1102,25 +1111,6 @@ ...@@ -1102,25 +1111,6 @@
} }
} }
function getTree() {
var arr = []
if (merchantForm.accountType) {
var labelList = merchantForm.accountTypeNames.split(',')
var valList = merchantForm.accountType.split(',')
$.each(valList, function (index, item) {
var obj = {
title: labelList[index],
value: valList[index]
}
arr.push(obj)
active.tabAdd(obj)
})
if (arr.length != 0) {
active.tabChange('roleAuth', arr[0].value)
}
}
}
// 复选框的change事件 // 复选框的change事件
// form.on('checkbox(switch)', function (data) { // form.on('checkbox(switch)', function (data) {
// var arr = [] // var arr = []
...@@ -1147,27 +1137,23 @@ ...@@ -1147,27 +1137,23 @@
// } // }
// }) // })
// end // end
function toInt(str) { // function toInt(str) {
var arr = str.split(',') // var arr = str.split(',')
$.each(arr, function (index, item) { // $.each(arr, function (index, item) {
arr[index] = parseInt(item) // arr[index] = parseInt(item)
}) // })
return arr // return arr
} // }
// findMenuFunTreeByMerId()
// 查询商户的菜单权限树 // 查询商户的菜单权限树
function findMenuFunTreeByMerId() { function findMenuFunTreeByMerId() {
// console.log(merchantForm.merchantAccountLevel) // console.log(merchantForm, '查询商户菜单权限树')
// var accountType = toInt(merchantForm.accountType)
var params = { var params = {
// method: 'cn.com.glsx.merchants.merchant.findMenuFunTreeByMerId', method: 'cn.com.glsx.merchants.merchant.accountTypeSearchRequest',
method: 'org.ore.api.accountType.getProductTreeList', // method: 'org.ore.api.accountType.getProductTreeList',
// ids: merchantForm.accountType, ids: merchantForm.accountType,
ids: '1,26',
merchantId: merchantId, merchantId: merchantId,
// accountLevel: merchantForm.merchantAccountLevel accountLevel: merchantForm.merchantAccountLevel
accountLevel: 1
} }
request(params, function (res) { request(params, function (res) {
if (res.code == '0') { if (res.code == '0') {
...@@ -1180,10 +1166,11 @@ ...@@ -1180,10 +1166,11 @@
var str = $('<input lay-filter="switch" type="checkbox" name="accounttypeId" value="' + item var str = $('<input lay-filter="switch" type="checkbox" name="accounttypeId" value="' + item
.accounttypeId + '" title="' + item.accounttypeName + '" />') .accounttypeId + '" title="' + item.accounttypeName + '" />')
accountType.append(str) accountType.append(str)
console.log(check_arr, '0000000000')
if (merchantId) { if (merchantId) {
console.log(check_arr, 'check_arr')
// 角色权限的check // 角色权限的check
for (var i = 0; i < check_arr.length; i++) { for (var i = 0; i < check_arr.length; i++) {
console.log(check_arr[i])
if (check_arr[i].accounttypeId == item.accounttypeId) { if (check_arr[i].accounttypeId == item.accounttypeId) {
var productData = check_arr[i] var productData = check_arr[i]
str.attr("checked", true) str.attr("checked", true)
...@@ -1191,6 +1178,7 @@ ...@@ -1191,6 +1178,7 @@
title: item.accounttypeName, title: item.accounttypeName,
value: item.accounttypeId value: item.accounttypeId
} }
console.log(obj)
active.tabAdd(obj) active.tabAdd(obj)
var selectArr = [] var selectArr = []
var menuData = [] var menuData = []
...@@ -1210,7 +1198,6 @@ ...@@ -1210,7 +1198,6 @@
active.tabChange(filterName, productId) active.tabChange(filterName, productId)
// 树的回显 // 树的回显
} }
break
} }
if (check_arr.length != 0) { if (check_arr.length != 0) {
active.tabChange('roleAuth', check_arr[0].accounttypeId) active.tabChange('roleAuth', check_arr[0].accounttypeId)
...@@ -1219,13 +1206,13 @@ ...@@ -1219,13 +1206,13 @@
} }
}) })
form.render('checkbox') form.render('checkbox')
getTree()
} }
}) })
} }
// 根据id获取角色详情 // 根据id获取角色详情
function getById() { function getById() {
console.log('getById---')
var params = { var params = {
method: 'cn.com.glsx.merchants.merchant.findPermissionsByMerId', method: 'cn.com.glsx.merchants.merchant.findPermissionsByMerId',
// method: 'org.ore.api.role.getById', // method: 'org.ore.api.role.getById',
...@@ -1233,12 +1220,12 @@ ...@@ -1233,12 +1220,12 @@
} }
request(params, function (res) { request(params, function (res) {
if (res.code == '0') { if (res.code == '0') {
console.log(res.data, '详情') // console.log(res.data, '角色详情')
var accounttypeId = '' var accounttypeId = ''
if (res.data) { if (res.data) {
check_arr = res.data check_arr = res.data
} }
console.log(check_arr, 'jklj') console.log(check_arr, '角色详情check_arr')
findMenuFunTreeByMerId() findMenuFunTreeByMerId()
form.val('roleForm', { form.val('roleForm', {
roleName: res.data.roleName, roleName: res.data.roleName,
...@@ -1255,52 +1242,88 @@ ...@@ -1255,52 +1242,88 @@
var productList = [] var productList = []
for (var i in accountObj) { for (var i in accountObj) {
var productObj = accountObj[i] var productObj = accountObj[i]
var menuIdList = [] var menuIds = []
var functionIdList = [] var functionIds = []
var functionIdLists = [] var functionIdLists = []
var nodes = productObj.treeObj.getCheckedNodes(true) var nodes = productObj.treeObj.getCheckedNodes(true)
$.each(nodes, function (index, item) { $.each(nodes, function (index, item) {
if (item.logo == 'function') { if (item.logo == 'function') {
functionIdLists.push(item) functionIdLists.push(item)
} else { } else {
menuIdList.push(item.id) menuIds.push(item.id)
} }
}) })
$.each(functionIdLists, function (idx, m) { $.each(functionIdLists, function (idx, m) {
// m.parentId // m.parentId
var findIdx = -1 var findIdx = -1
$.each(functionIdList, function (idn, n) { $.each(functionIds, function (idn, n) {
if (n.id == m.parentId) { if (n.id == m.parentId) {
findIdx = idn findIdx = idn
} }
}) })
if (findIdx != -1) { if (findIdx != -1) {
functionIdList[findIdx].functionValue += ';' + m.id + ':' + m.label functionIds[findIdx].functionValue += ';' + m.id + ':' + m.label
} else { } else {
functionIdList.push({ functionIds.push({
id: m.parentId, functionId: m.parentId,
menuId: m.superParentId, mendId: m.superParentId,
functionValue: m.id + ':' + m.label functionValue: m.id + ':' + m.label
}) })
} }
}) })
productList.push({ productList.push({
productId: productObj.productId, productId: productObj.productId,
functionIdList: functionIdList, functionIds: functionIds,
menuIdList: menuIdList menuIds: menuIds
}) })
} }
requestList.push({ requestList.push({
accountTypeId: key, accountTypeId: key,
productList: productList products: productList
}) })
} }
console.log(requestList) // console.log(requestList)
} }
$('#draft').on('click', function () {
getAuthList()
var params = {
merchantId: merchantId,
accountTypes: JSON.stringify(requestList),
method: 'cn.com.glsx.merchants.merchant.savePermissions',
status: 1
}
request(params, function (res) {
console.log(res.data)
})
return false
})
$('#preStep').on('click', function () {
step = 1
init()
})
$('#confirm').on('click', function () { $('#confirm').on('click', function () {
// console.log(treeData) // console.log(treeData)
getAuthList() getAuthList()
console.log(merchantForm)
console.log(requestList)
// 草稿
var params = {
merchantId: merchantId,
accountTypes: JSON.stringify(requestList)
}
if (merchantForm.status == 1) {
params.method = 'cn.com.glsx.merchants.merchant.savePermissions'
params.status = 2
} else {
params.method = 'cn.com.glsx.merchants.merchant.updatePermissions'
params.status = merchantForm.status
}
request(params, function (res) {
console.log(res.data)
})
return false return false
}) })
}) })
......
...@@ -218,7 +218,7 @@ ...@@ -218,7 +218,7 @@
switch (eventName) { switch (eventName) {
// 查看 // 查看
case 'handleDetail': case 'handleDetail':
go('merchant', 'detail') go('merchant', 'detail', { merchantId: row.id })
break break
// 修改 // 修改
case 'handleEdit': case 'handleEdit':
...@@ -361,7 +361,7 @@ ...@@ -361,7 +361,7 @@
// 本身 // 本身
if (item.id == user.merchantId) { if (item.id == user.merchantId) {
item.btn.createStaff = true item.btn.createStaff = true
if (merchantAccountLevel != 4) { if (item.merchantAccountLevel != 4) {
item.btn.createSubMerchant = true item.btn.createSubMerchant = true
} }
} else { // 下级商户 } else { // 下级商户
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!