Commit cd4e658f by 胡悦

提交角色详情、商户详情、角色新增

1 parent 5fac67ad
......@@ -104,7 +104,7 @@
<div id="merchantBox" class="hide">
<select id="merchantName" name="merchantId" lay-filter="merchants" lay-verify="required" autocomplete="off" placeholder="请选择商户名称" required></select>
</div>
<div class="hide" id="merchantId" style="line-height: 36px;"></div>
<div class="hide" id="merchantIdText" style="line-height: 36px;"></div>
</div>
</div>
<div class="layui-form-item">
......@@ -215,10 +215,10 @@
}
// 判断是从商户过来还是员工
if (qs('channel')) {
$('#merchantId').text(qs('merchantName'))
$('#merchantIdText').text(qs('merchantName'))
getList(qs('merchantId'))
$('#merchantId').removeClass('hide')
$('#merchantId').addClass('show')
$('#merchantIdText').removeClass('hide')
$('#merchantIdText').addClass('show')
} else {
$('#merchantBox').removeClass('hide')
$('#merchantBox').addClass('show')
......@@ -341,7 +341,7 @@
getById(function(checkedList) {
visibleMerchant = tree.create('visibleInferiorMerTree', res.data, { checkedList: checkedList })
var node = visibleMerchant.getNodesByParam('id', merchantId)
visibleMerchant.checkNode(node, true, false)
visibleMerchant.checkNode(node, true, true)
all_nodes = visibleMerchant.getNodes()
bindEvent()
})
......
......@@ -27,14 +27,14 @@
<div>
<h3 class="content-title">
员工基本信息
<!-- <div class="title-right" id="merchantName"></div> -->
<div class="title-right" id="merchantName"></div>
</h3>
<div class="layui-form-item">
<label class="layui-form-label required">所属商户:</label>
<!-- <div class="layui-form-item">
<label class="layui-form-label required">所属企业:</label>
<div class="layui-input-block">
<div class="layui-form-mid layui-word-aux" id="merchantName"></div>
</div>
</div>
</div> -->
<div class="layui-form-item">
<label class="layui-form-label required">姓名:</label>
<div class="layui-input-block">
......@@ -83,11 +83,10 @@
<script src="https://www.layuicdn.com/layui/layui.js"></script>
<script src="/js/load.js"></script>
<script>
layui.use(['request', 'gtree', 'helper', 'treeTab'], function() {
layui.use(['request', 'helper', 'treeTab'], function() {
/** 变量 */
var $ = layui.$
var request = layui.request
var tree = layui.gtree
var helper = layui.helper
var id = qs('id')
var treeTab = layui.treeTab
......@@ -119,7 +118,6 @@
console.log(i)
visibleInferiorMerName.append('<li class="visibleMerchant">' + i + '</li>')
})
// getMerchant()
// 账户权限
var authList = employeeData.accountTypeTreeResponseList
console.log(authList)
......@@ -150,20 +148,6 @@
})
}
// 下级商户树
function getMerchant() {
var treeParams = { id: merchantId, method: 'cn.com.glsx.merchants.merchant.findMerchantTree' }
var merchants = {}
request(treeParams, function(res) {
if (res.code == '0') {
var arr = employeeData.visibleInferiorMer.split(',')
$.each(arr, function (index, item) {
arr[index] = +item
})
merchants = tree.create('merchantTree', res.data, {checkedList: arr, chkDisabled: true})
}
})
}
})
</script>
</body>
......
......@@ -45,9 +45,14 @@
<form class="layui-form add" lay-filter="roleForm" action="">
<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;">
<select id="merchantName" name="merchantId" lay-verify="required" autocomplete="off" placeholder="请选择商户名称" required></select>
</div> -->
</div>
<div class="layui-form-item">
<label class="layui-form-label required">所属商户:</label>
<div class="layui-input-block">
<div id="merchantBox">
<select id="merchantName" name="merchantId" lay-filter="merchants" lay-verify="required" autocomplete="off" placeholder="请选择商户名称" required></select>
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label required">角色名称:</label>
......@@ -87,19 +92,20 @@
<script src="/js/load.js"></script>
<script>
layui.use(['form', 'element', 'request', 'laytpl', 'xmSelect', 'gtree', 'helper'], function() {
var merchantId = qs('merchantId')
// var merchantId = qs('merchantId')
var roleid = qs('id')
var element = layui.element
var form = layui.form
var arr_box = []
var $ = layui.$
var request = layui.request
var merchantId = ''
if (roleid) {
getById(roleid)
} else {
$('#draft').removeClass('hide')
$('#draft').addClass('show')
findMenuFunTreeByMerId()
// findMenuFunTreeByMerId()
}
var merchantName = $('#merchantName')
findAllMerchant()
......@@ -271,6 +277,13 @@
return false
})
// select 选择触发
form.on('select(merchants)', function (data) {
console.log(data.value)
merchantId = data.value
findMenuFunTreeByMerId(merchantId)
})
// 存草稿
$('#draft').on('click', function() {
var formVal = form.val('roleForm')
......@@ -291,11 +304,9 @@
// 调用新增接口
function insert(delFlag, formVal) {
var otherParams = {
merchantId: merchantId,
// merchantId: merchantId,
delFlag: delFlag
// requestList: JSON.stringify(requestList)
}
console.log(requestList.length)
if (requestList.length != 0) {
otherParams.requestList = JSON.stringify(requestList)
} else {
......@@ -321,7 +332,7 @@
}
// 查询商户的菜单权限树
function findMenuFunTreeByMerId() {
function findMenuFunTreeByMerId(merchantId) {
var params = {
method: 'cn.com.glsx.merchants.merchant.findMenuFunTreeByMerId',
id: merchantId
......@@ -390,7 +401,7 @@
check_arr = res.data.responseList
}
console.log(check_arr, 'jklj')
findMenuFunTreeByMerId()
// findMenuFunTreeByMerId()
form.val('roleForm', {
roleName: res.data.roleName,
roleDescription: res.data.roleDescription
......
......@@ -64,15 +64,13 @@
<script src="https://www.layuicdn.com/layui/layui.js"></script>
<script src="/js/load.js"></script>
<script>
layui.use(['request', 'gtree', 'element', 'helper', 'form', 'laytpl'], function() {
layui.use(['request', 'helper', 'form', 'treeTab'], function() {
var request = layui.request
var tree = layui.gtree
var helper = layui.helper
var form = layui.form
var element = layui.element
var laytpl = layui.laytpl
var xmSelect = layui.xmSelect
var $ = layui.$
var treeTab = layui.treeTab
var roleid = qs('id')
var merchantId = qs('merchantId')
var basicArr = ['roleName', 'roleCode', 'roleDescription', 'merchantName']
......@@ -81,95 +79,14 @@
var templateData = {}
var treeData = {}
// 查询角色详情
// getById()
findMenuFunTreeByMerId()
getById()
findMenuFunTreeByRoleId()
$('#return').on('click', function() {
window.history.back()
})
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) {
// 渠道的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 class="layui-tab layui-tab-card" 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) {
console.log(html)
view.innerHTML = html
})
},
// 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的内容
var getTreeTpl = '<ul id="tree_{{d.id}}" class="ztree wrapper-tree"></ul>'
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
treeData[id][item.value].treeObj = tree.create(treedom, treeListData, {checkedList: defaultList, chkDisabled: true})
}
}
function getById(callback) {
function getById() {
var params = { id: roleid, method: 'org.ore.api.role.getById'}
request(params, function(res) {
if (res.code == '0') {
......@@ -178,54 +95,43 @@
for (var i in basicArr) {
$('#' + [basicArr[i]]).text(roleData[basicArr[i]] || '')
}
callback(roleData.responseList)
// callback(roleData.responseList)
}
})
}
function findMenuFunTreeByMerId() {
function findMenuFunTreeByRoleId () {
var params = {
method: 'cn.com.glsx.merchants.merchant.findMenuFunTreeByMerId',
id: merchantId
method: 'cn.com.glsx.merchants.merchant.findMenuFunTreeByRoleId',
id: roleid
}
request(params, function(res) {
if (res.code == '0') {
menuFunTreeData = res.data
getById(function(responseList) {
console.log('responseList:', responseList)
if (responseList && responseList.length != 0) {
$.each(menuFunTreeData, function(index, item) {
for (var i = 0; i < responseList.length; i++) {
var productData = responseList[i]
console.log(productData, '===')
if (item.accounttypeId == productData.accounttypeId) {
active.tabAdd({
title: item.accounttypeName,
value: item.accounttypeId
})
var menuData = []
if (productData.productList && productData.productList.length != 0) {
for(var j = 0; j < productData.productList.length; j++) {
menuData = productData.productList[j]
active.treeTabAdd({
name: menuData.productName,
value: menuData.productId
}, item.accounttypeId, item.products, menuData.idList)
}
var filterName = 'treeTab' + item.accounttypeId
var productId = 'tab_' + item.accounttypeId + '_' + item.products[0].productId
active.tabChange(filterName, productId)
}
}
// break
}
})
active.tabChange('roleAuth', responseList[0].accounttypeId)
}
})
if (res.code == '0' && res.data && res.data.length != 0) {
var authList = res.data
$.each(authList, function (index, item) {
treeTab.tabAdd({
title: item.accounttypeName,
value: item.accounttypeId
}, true)
var menuData = []
if (item.products && item.products.length != 0) {
$.each(item.products, function (idx, m) {
treeTab.treeTabDetail({
name: m.productName,
value: m.productId
}, item.accounttypeId, m.merchantProTreeResponses)
})
var filterName = 'treeTab' + item.accounttypeId
var productId = 'tab_' + item.accounttypeId + '_' + item.products[0].productId
treeTab.tabChange(filterName, productId)
}
})
console.log(authList)
treeTab.tabChange('roleAuth', authList[0].accounttypeId)
}
})
}
})
</script>
<script type="text/html" id="treeAuth">
......
......@@ -178,13 +178,14 @@
})
// 新增点击事件
$('#addRole').on('click', function() {
var value = merchantName.val()
var params = { merchantId: value }
if (value) {
go('role', 'add', params)
} else {
layer.msg('请选择商户')
}
go('role', 'add')
// var value = merchantName.val()
// var params = { merchantId: value }
// if (value) {
// go('role', 'add', params)
// } else {
// layer.msg('请选择商户')
// }
})
// 查询事件
$('#roleSearch').on('click', function() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!