Commit 95ea0eb4 by 李长胜

Merge branch 'master' of http://192.168.3.233:8090/h5/account

2 parents 56e52a5b 8760ffbd
......@@ -1487,7 +1487,33 @@
},
// tab Change
tabChange: function (name, id) {
console.log(name, id)
element.tabChange(name, id)
if (name == 'roleAuth') {
$(`#nomenu${id}`).html('请选择产品')
} else {
const accounttypeId = id.split('_')[1]
const productId = id.split('_')[2]
$(`#nodata${accounttypeId}`).removeClass('show')
$(`#nodata${accounttypeId}`).addClass('hide')
$(`#nomenu${accounttypeId}`).html('暂无可选择的菜单功能')
console.log(menuFunTreeData)
menuFunTreeData.forEach(item => {
if (item.accounttypeId == accounttypeId) {
item.products.forEach(i => {
if (i.productId == productId) {
if (i.merchantProTreeResponses.length == 0) {
$(`#nomenutab_${accounttypeId}_${productId}`).removeClass('hide')
$(`#nomenutab_${accounttypeId}_${productId}`).addClass('show')
} else {
$(`#nomenutab_${accounttypeId}_${productId}`).removeClass('show')
$(`#nomenutab_${accounttypeId}_${productId}`).addClass('hide')
}
}
})
}
})
}
},
/**
* 第二级选项卡
......@@ -1520,11 +1546,6 @@
if (treeListData && treeListData.length != 0) {
treeData[id][item.value].treeObj = tree.create(treedom, treeListData)
treeData[id][item.value].treeObj.checkAllNodes(true)
$(`#nodata${id}`).removeClass('show')
$(`#nodata${id}`).addClass('hide')
} else {
$(`#nodata${id}`).removeClass('hide')
$(`#nodata${id}`).addClass('show')
}
}
}
......@@ -1664,82 +1685,95 @@
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 functionValueIdLists = []
var nodes = productObj.treeObj.getCheckedNodes(true)
$.each(nodes, function (index, item) {
if (item.logo == 'function') {
functionIdLists.push(item)
} else if (item.logo == 'functionValue') {
functionValueIdLists.push(item)
} else {
if (item.logo != 'neglect') {
menuIds.push(item.id)
}
}
})
$.each(functionValueIdLists, function (idx, m) {
var findIdx = -1
$.each(functionIds, function (idn, n) {
if (n.functionId == m.parentId) {
findIdx = idn
}
})
if (findIdx != -1) {
functionIds[findIdx].functionValue += ';' + m.id + ':' + m.label
console.log(accountObj)
if (Object.keys(accountObj).length != 0) {
for (var i in accountObj) {
var productObj = accountObj[i]
var menuIds = []
var functionIds = []
var functionIdLists = []
var functionValueIdLists = []
if (productObj.treeObj) {
var nodes = productObj.treeObj.getCheckedNodes(true)
$.each(nodes, function (index, item) {
if (item.logo == 'function') {
functionIdLists.push(item)
} else if (item.logo == 'functionValue') {
functionValueIdLists.push(item)
} else {
if (item.logo != 'neglect') {
menuIds.push(item.id)
}
}
})
$.each(functionValueIdLists, function (idx, m) {
var findIdx = -1
$.each(functionIds, function (idn, n) {
if (n.functionId == m.parentId) {
findIdx = idn
}
})
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) {
functionIds.push({
functionId: m.parentId,
mendId: m.superParentId
})
})
productList.push({
productId: productObj.productId,
functionIds: functionIds,
menuIds: menuIds
})
} else {
functionIds.push({
functionId: m.parentId,
mendId: m.superParentId,
functionValue: m.id + ':' + m.label
productList.push({
productId: productObj.productId,
functionIdList: [],
menuIdList: []
})
}
})
$.each(functionIdLists, function (idx, m) {
functionIds.push({
functionId: m.parentId,
mendId: m.superParentId
})
})
productList.push({
productId: productObj.productId,
functionIds: functionIds,
menuIds: menuIds
}
requestList.push({
accountTypeId: key,
products: productList
})
}
requestList.push({
accountTypeId: key,
products: productList
})
}
}
$('#draft').on('click', function () {
getAuthList()
var params = {
merchantId: merchantId,
// accountTypes: JSON.stringify(requestList),
method: 'cn.com.glsx.merchants.merchant.updatePermissions',
status: merchantForm.status
}
if (requestList.length != 0) {
var params = {
merchantId: merchantId,
accountTypes: JSON.stringify(requestList),
method: 'cn.com.glsx.merchants.merchant.updatePermissions',
status: merchantForm.status
}
request(params, function (res) {
if (res.code == '0') {
layer.msg('操作成功', {
icon: 1
})
go('merchant', 'index')
}
})
params.accountTypes = JSON.stringify(requestList)
} else {
layer.msg('请选择产品', {
icon: 5
})
params.accountTypes = JSON.stringify([])
}
request(params, function (res) {
if (res.code == '0') {
layer.msg('操作成功', {
icon: 1
})
go('merchant', 'index')
}
})
// layer.msg('请选择产品', {
// icon: 5
// })
return false
})
......@@ -1784,6 +1818,12 @@
<!-- <button class="layui-btn" data-type="d.id" id="checkedAll">全选</button>
<button class="layui-btn" id="cancelCheckedAll">取消全选</button> -->
<ul id="tree_{{d.id}}" class="ztree wrapper-tree"></ul>
<div class="layui-no-data show" id="nomenu{{d.id}}">
<div class="no-data">
<img src="../../css/img/no-data.png" />
<div>暂无可选择的菜单功能</div>
</div>
</div>
</script>
</body>
</html>
......@@ -737,8 +737,8 @@
'merchantLoginPassword',
'merchantAccountLevel',
'effectiveTime',
'effectiveStarttime',
'expireDate'
// 'effectiveStarttime',
// 'expireDate'
]
if (formData.isloginName == 'on') {
params.isloginName = 1
......@@ -760,8 +760,8 @@
merchantForm[item] = formData[item] || ''
params[item] = formData[item] || ''
})
params.effectiveStarttime = new Date(params.effectiveStarttime )
params.expireDate = new Date(params.expireDate )
if (formData.effectiveStarttime) params.effectiveStarttime = new Date(formData.effectiveStarttime )
if (formData.expireDate) params.expireDate = new Date(formData.expireDate )
if (merchantId) {
params.effectiveTime = merchantForm.effectiveTime
}
......@@ -1501,7 +1501,33 @@
},
// tab Change
tabChange: function (name, id) {
console.log(name, id)
element.tabChange(name, id)
if (name == 'roleAuth') {
$(`#nomenu${id}`).html('请选择产品')
} else {
const accounttypeId = id.split('_')[1]
const productId = id.split('_')[2]
$(`#nodata${accounttypeId}`).removeClass('show')
$(`#nodata${accounttypeId}`).addClass('hide')
$(`#nomenu${accounttypeId}`).html('暂无可选择的菜单功能')
console.log(menuFunTreeData)
menuFunTreeData.forEach(item => {
if (item.accounttypeId == accounttypeId) {
item.products.forEach(i => {
if (i.productId == productId) {
if (i.merchantProTreeResponses.length == 0) {
$(`#nomenutab_${accounttypeId}_${productId}`).removeClass('hide')
$(`#nomenutab_${accounttypeId}_${productId}`).addClass('show')
} else {
$(`#nomenutab_${accounttypeId}_${productId}`).removeClass('show')
$(`#nomenutab_${accounttypeId}_${productId}`).addClass('hide')
}
}
})
}
})
}
},
/**
* 第二级选项卡
......@@ -1534,11 +1560,6 @@
if (treeListData && treeListData.length != 0) {
treeData[id][item.value].treeObj = tree.create(treedom, treeListData)
treeData[id][item.value].treeObj.checkAllNodes(true)
$(`#nodata${id}`).removeClass('show')
$(`#nodata${id}`).addClass('hide')
} else {
$(`#nodata${id}`).removeClass('hide')
$(`#nodata${id}`).addClass('show')
}
}
}
......@@ -1678,57 +1699,67 @@
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 functionValueIdLists = []
var nodes = productObj.treeObj.getCheckedNodes(true)
$.each(nodes, function (index, item) {
if (item.logo == 'function') {
functionIdLists.push(item)
} else if (item.logo == 'functionValue') {
functionValueIdLists.push(item)
} else {
if (item.logo != 'neglect') {
menuIds.push(item.id)
}
}
})
$.each(functionValueIdLists, function (idx, m) {
var findIdx = -1
$.each(functionIds, function (idn, n) {
if (n.functionId == m.parentId) {
findIdx = idn
}
})
if (findIdx != -1) {
functionIds[findIdx].functionValue += ';' + m.id + ':' + m.label
if (Object.keys(accountObj).length != 0) {
for (var i in accountObj) {
var productObj = accountObj[i]
var menuIds = []
var functionIds = []
var functionIdLists = []
var functionValueIdLists = []
if (productObj.treeObj) {
var nodes = productObj.treeObj.getCheckedNodes(true)
$.each(nodes, function (index, item) {
if (item.logo == 'function') {
functionIdLists.push(item)
} else if (item.logo == 'functionValue') {
functionValueIdLists.push(item)
} else {
if (item.logo != 'neglect') {
menuIds.push(item.id)
}
}
})
$.each(functionValueIdLists, function (idx, m) {
var findIdx = -1
$.each(functionIds, function (idn, n) {
if (n.functionId == m.parentId) {
findIdx = idn
}
})
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) {
functionIds.push({
functionId: m.parentId,
mendId: m.superParentId
})
})
productList.push({
productId: productObj.productId,
functionIds: functionIds,
menuIds: menuIds
})
} else {
functionIds.push({
functionId: m.parentId,
mendId: m.superParentId,
functionValue: m.id + ':' + m.label
productList.push({
productId: productObj.productId,
functionIdList: [],
menuIdList: []
})
}
})
$.each(functionIdLists, function (idx, m) {
functionIds.push({
functionId: m.parentId,
mendId: m.superParentId
})
})
productList.push({
productId: productObj.productId,
functionIds: functionIds,
menuIds: menuIds
}
requestList.push({
accountTypeId: key,
products: productList
})
}
requestList.push({
accountTypeId: key,
products: productList
})
}
}
......@@ -1736,10 +1767,15 @@
getAuthList()
var params = {
merchantId: merchantId,
accountTypes: JSON.stringify(requestList),
// accountTypes: JSON.stringify(requestList),
method: 'cn.com.glsx.merchants.merchant.updatePermissions',
status: merchantForm.status
}
if (requestList.length != 0) {
params.accountTypes = JSON.stringify(requestList)
} else {
params.accountTypes = JSON.stringify([])
}
request(params, function (res) {
if (res.code == '0') {
layer.msg('操作成功', {
......@@ -1758,25 +1794,31 @@
$('#confirm').on('click', function () {
getAuthList()
var params = {
merchantId: merchantId,
accountTypes: JSON.stringify(requestList)
}
params.method = 'cn.com.glsx.merchants.merchant.updatePermissions'
// 草稿
if (merchantForm.status == 1) {
params.status = 2
if (requestList.length != 0) {
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) {
if (res.code == '0') {
layer.msg('操作成功', {
icon: 1
})
go('merchant', 'index')
}
})
} else {
params.status = merchantForm.status
layer.msg('请选择产品', {
icon: 5
})
}
request(params, function (res) {
if (res.code == '0') {
layer.msg('操作成功', {
icon: 1
})
go('merchant', 'index')
}
})
return false
})
})
......@@ -1785,6 +1827,12 @@
<!-- <button class="layui-btn" data-type="d.id" id="checkedAll">全选</button>
<button class="layui-btn" id="cancelCheckedAll">取消全选</button> -->
<ul id="tree_{{d.id}}" class="ztree wrapper-tree"></ul>
<div class="layui-no-data show" id="nomenu{{d.id}}">
<div class="no-data">
<img src="../../css/img/no-data.png" />
<div>暂无可选择的菜单功能</div>
</div>
</div>
</script>
</body>
</html>
......@@ -466,7 +466,7 @@
</div>
<div class="merchant-right">
<div>
<span class="companyName">员工列表</span>
<span id="companyName" class="companyName"></span>
<div class="layui-input-inline">
<input class="layui-input" placeholder="请输入员工姓名/手机号" id="tableSearchForm" />
</div>
......@@ -692,6 +692,7 @@
$('#secondmerchantId').text(data.merchantNo)
$('#numberOfSubMerchants').text(data.numberOfSubMerchants)
$('#numberOfStores').text(data.numberOfStores)
$('#companyName').html(data.merchantName)
}
)
}
......
......@@ -1457,7 +1457,33 @@
},
// tab Change
tabChange: function (name, id) {
console.log(name, id)
element.tabChange(name, id)
if (name == 'roleAuth') {
$(`#nomenu${id}`).html('请选择产品')
} else {
const accounttypeId = id.split('_')[1]
const productId = id.split('_')[2]
$(`#nodata${accounttypeId}`).removeClass('show')
$(`#nodata${accounttypeId}`).addClass('hide')
$(`#nomenu${accounttypeId}`).html('暂无可选择的菜单功能')
console.log(menuFunTreeData, accounttypeId, productId)
menuFunTreeData.forEach(item => {
if (item.accounttypeId == accounttypeId) {
item.products.forEach(i => {
if (i.productId == productId) {
if (i.merchantProTreeResponses.length == 0) {
$(`#nomenutab_${accounttypeId}_${productId}`).removeClass('hide')
$(`#nomenutab_${accounttypeId}_${productId}`).addClass('show')
} else {
$(`#nomenutab_${accounttypeId}_${productId}`).removeClass('show')
$(`#nomenutab_${accounttypeId}_${productId}`).addClass('hide')
}
}
})
}
})
}
},
/**
* 第二级选项卡
......@@ -1499,11 +1525,6 @@
} else {
treeData[id][item.value].treeObj.checkAllNodes(true)
}
$(`#nodata${id}`).removeClass('show')
$(`#nodata${id}`).addClass('hide')
} else {
$(`#nodata${id}`).removeClass('hide')
$(`#nodata${id}`).addClass('show')
}
// }
}
......@@ -1600,6 +1621,13 @@
products.merchantProTreeResponses,
j.menuIds
)
if (products.merchantProTreeResponses.length == 0) {
$(`#nomenutab_${id}_${j.productId}`).removeClass('hide')
$(`#nomenutab_${id}_${j.productId}`).addClass('show')
} else {
$(`#nomenutab_${id}_${j.productId}`).removeClass('show')
$(`#nomenutab_${id}_${j.productId}`).addClass('hide')
}
})
var filterName = 'treeTab' + item.accounttypeId
var productId = 'tab_' + item.accounttypeId + '_' + productData.products[0].productId
......@@ -1642,79 +1670,97 @@
// 获取角色权限数据requestList
function getAuthList() {
requestList = []
console.log(treeData)
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 functionValueIdLists = []
var nodes = productObj.treeObj.getCheckedNodes(true)
$.each(nodes, function (index, item) {
if (item.logo == 'function') {
functionIdLists.push(item)
} else if (item.logo == 'functionValue') {
functionValueIdLists.push(item)
} else {
if (item.logo != 'neglect') {
menuIds.push(item.id)
}
}
})
$.each(functionValueIdLists, function (idx, m) {
var findIdx = -1
$.each(functionIds, function (idn, n) {
if (n.functionId == m.parentId) {
findIdx = idn
}
})
if (findIdx != -1) {
functionIds[findIdx].functionValue += ';' + m.id + ':' + m.label
console.log(accountObj) // 判断是否为空
if (Object.keys(accountObj).length != 0) {
for (var i in accountObj) {
var productObj = accountObj[i]
var menuIds = []
var functionIds = []
var functionIdLists = []
var functionValueIdLists = []
if (productObj.treeObj) {
var nodes = productObj.treeObj.getCheckedNodes(true)
$.each(nodes, function (index, item) {
if (item.logo == 'function') {
functionIdLists.push(item)
} else if (item.logo == 'functionValue') {
functionValueIdLists.push(item)
} else {
if (item.logo != 'neglect') {
menuIds.push(item.id)
}
}
})
$.each(functionValueIdLists, function (idx, m) {
var findIdx = -1
$.each(functionIds, function (idn, n) {
if (n.functionId == m.parentId) {
findIdx = idn
}
})
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) {
functionIds.push({
functionId: m.parentId,
mendId: m.superParentId
})
})
productList.push({
productId: productObj.productId,
functionIds: functionIds,
menuIds: menuIds
})
} else {
functionIds.push({
functionId: m.parentId,
mendId: m.superParentId,
functionValue: m.id + ':' + m.label
productList.push({
productId: productObj.productId,
functionIdList: [],
menuIdList: []
})
}
})
$.each(functionIdLists, function (idx, m) {
functionIds.push({
functionId: m.parentId,
mendId: m.superParentId
})
})
productList.push({
productId: productObj.productId,
functionIds: functionIds,
menuIds: menuIds
}
requestList.push({
accountTypeId: key,
products: productList
})
}
requestList.push({
accountTypeId: key,
products: productList
})
}
}
$('#draft').on('click', function () {
getAuthList()
var params = {
merchantId: merchantId,
accountTypes: JSON.stringify(requestList),
method: 'cn.com.glsx.merchants.merchant.updatePermissions',
status: merchantForm.status
}
request(params, function (res) {
if (res.code == '0') {
layer.msg('操作成功', {
icon: 1
})
go('merchant', 'index')
if (requestList.length != 0) {
var params = {
merchantId: merchantId,
accountTypes: JSON.stringify(requestList),
method: 'cn.com.glsx.merchants.merchant.updatePermissions',
status: merchantForm.status
}
})
request(params, function (res) {
if (res.code == '0') {
layer.msg('操作成功', {
icon: 1
})
go('merchant', 'index')
}
})
} else {
layer.msg('请选择产品', {
icon: 2
})
}
return false
})
......@@ -1764,6 +1810,12 @@
</script>
<script type="text/html" id="treeAuth">
<ul id="tree_{{d.id}}" class="ztree wrapper-tree"></ul>
<div class="layui-no-data show" id="nomenu{{d.id}}">
<div class="no-data">
<img src="../../css/img/no-data.png" />
<div>暂无可选择的菜单功能</div>
</div>
</div>
</script>
</body>
</html>
......@@ -173,7 +173,7 @@
<script src="https://www.layuicdn.com/layui/layui.js"></script>
<script src="/js/load.js"></script>
<script>
layui.use(['form', 'element', 'request', 'laytpl', 'xmSelect', 'gtree', 'helper'], function () {
layui.use(['form', 'element', 'request', 'laytpl', 'xmSelect', 'gtree', 'helper'], function() {
// var merchantId = qs('merchantId')
var roleid = qs('id')
var element = layui.element
......@@ -226,7 +226,7 @@
* productList:复选下拉框的list,修改过的数据{name: '', value: ''}
* products:对应的菜单下的产品list,包含了对应的权限树,原始数据,需作为参数传入treeTabAdd中,在实例化tree时传入的数据使用
*/
tabAdd: function (item, productList) {
tabAdd: function(item, productList) {
// 渠道的id,一层选项卡的id
var id = item.value
// roleAuth 一层选项卡过滤器的名称
......@@ -260,7 +260,7 @@
// '<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>'
view = document.getElementById('role' + id)
templateData.id = id // 渲染模版的数据
laytpl(getTpl).render(templateData, function (html) {
laytpl(getTpl).render(templateData, function(html) {
view.innerHTML = html
})
// var productList = []
......@@ -317,12 +317,38 @@
// console.log(selectEl[id])
},
// tab删除
tabDelete: function (name, id) {
tabDelete: function(name, id) {
element.tabDelete(name, id)
},
// tab Change
tabChange: function (name, id) {
tabChange: function(name, id) {
console.log(name, id)
element.tabChange(name, id)
if (name == 'roleAuth') {
$(`#nomenu${id}`).html('请选择产品')
} else {
const accounttypeId = id.split('_')[1]
const productId = id.split('_')[2]
$(`#nodata${accounttypeId}`).removeClass('show')
$(`#nodata${accounttypeId}`).addClass('hide')
$(`#nomenu${accounttypeId}`).html('暂无可选择的菜单功能')
console.log(menuFunTreeData)
menuFunTreeData.forEach(item => {
if (item.accounttypeId == accounttypeId) {
item.products.forEach(i => {
if (i.productId == productId) {
if (i.merchantProTreeResponses.length == 0) {
$(`#nomenutab_${accounttypeId}_${productId}`).removeClass('hide')
$(`#nomenutab_${accounttypeId}_${productId}`).addClass('show')
} else {
$(`#nomenutab_${accounttypeId}_${productId}`).removeClass('show')
$(`#nomenutab_${accounttypeId}_${productId}`).addClass('hide')
}
}
})
}
})
}
},
/**
* 第二级选项卡
......@@ -334,7 +360,7 @@
* products:产品list数组
* defaultList:编辑时传入,默认勾选中的数组。(举例:[1,2,3])
*/
treeTabAdd: function (item, id, treeListData, defaultList) {
treeTabAdd: function(item, id, treeListData, defaultList) {
console.log(item, id, treeListData, defaultList)
var productId = 'tab_' + id + '_' + item.value
var filterName = 'treeTab' + id // 过滤器的名称 lay-filter
......@@ -349,7 +375,7 @@
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) {
laytpl(getTreeTpl).render(treeData[id][item.value], function(html) {
console.log(treeView)
treeView.innerHTML = html
})
......@@ -372,16 +398,16 @@
treeData[id][item.value].treeObj.checkAllNodes(true)
}
}
$(`#nodata${id}`).removeClass('show')
$(`#nodata${id}`).addClass('hide')
// $(`#nodata${id}`).removeClass('show')
// $(`#nodata${id}`).addClass('hide')
} else {
$(`#nodata${id}`).removeClass('hide')
$(`#nodata${id}`).addClass('show')
// $(`#nodata${id}`).removeClass('hide')
// $(`#nodata${id}`).addClass('show')
}
}
}
// 产品复选框change事件
form.on('checkbox(filter)', function (data) {
form.on('checkbox(filter)', function(data) {
console.log(data, '33333333333')
var roleId = +data.elem.dataset.id
var projectId = data.value
......@@ -422,7 +448,7 @@
})
// 复选框的change事件
form.on('checkbox(switch)', function (data) {
form.on('checkbox(switch)', function(data) {
console.log(data, '111111111')
if (data.elem.checked) {
var obj = { title: data.elem.title, value: data.elem.value }
......@@ -446,9 +472,12 @@
// end
// 表单提交
form.on('submit(roleSubmit)', function (data) {
if (Object.keys(treeData).length == 0) {
layer.msg('请选择角色权限')
form.on('submit(roleSubmit)', function(data) {
console.log(data.value, check_arr, treeData)
if (check_arr.length == 0) {
layer.msg('请选择角色权限', {
icon: 2
})
return false
}
getAuthList()
......@@ -457,17 +486,21 @@
})
// select 选择触发
form.on('select(merchants)', function (data) {
console.log(data.value)
form.on('select(merchants)', function(data) {
console.log(data.value, check_arr, treeData)
check_arr.forEach(item => {
active.tabDelete('roleAuth', item.accounttypeId)
})
// check_arr = []
// treeData = {}
merchantId = data.value
findMenuFunTreeByMerId(merchantId)
})
// 存草稿
$('#draft').on('click', function () {
$('#draft').on('click', function() {
var formVal = form.val('roleForm')
if (formVal.roleName || formVal.roleDescription || Object.keys(treeData).length != 0) {
console.log('baocun')
insert(1, formVal)
} else {
layer.msg('至少填一项')
......@@ -476,7 +509,7 @@
})
// 返回上个页面
$('#return').on('click', function () {
$('#return').on('click', function() {
window.history.back()
})
......@@ -486,11 +519,24 @@
merchantId: merchantId,
delFlag: delFlag
}
if (requestList.length != 0) {
otherParams.requestList = JSON.stringify(requestList)
console.log(requestList)
if (delFlag == 1) {
if (requestList.length != 0) {
otherParams.requestList = JSON.stringify(requestList)
} else {
otherParams.requestList = JSON.stringify([])
}
} else {
otherParams.requestList = JSON.stringify([])
if (requestList.length != 0) {
otherParams.requestList = JSON.stringify(requestList)
} else {
layer.msg('请选择产品', {
icon: 2
})
return
}
}
// otherParams.requestList = JSON.stringify([])
if (roleid) {
otherParams.id = roleid
otherParams.method = 'org.ore.api.role.update'
......@@ -499,7 +545,8 @@
}
var params = helper.clone(true, formVal, otherParams)
delete params.select
request(params, function (res) {
console.log(params)
request(params, function(res) {
if (res.code == '0') {
layer.msg('操作成功', {
icon: 1
......@@ -515,7 +562,7 @@
method: 'cn.com.glsx.merchants.merchant.findMenuFunTreeByMerId',
id: merchantId
}
request(params, function (res) {
request(params, function(res) {
if (res.code == '0') {
// callback(res.data)
menuFunTreeData = res.data
......@@ -535,24 +582,34 @@
str.attr('checked', true)
var obj = { title: item.accounttypeName, value: item.accounttypeId }
active.tabAdd(obj, productData.productList)
productData.productList.forEach(j => {
console.log(j, item)
var products = item.products.find(n => n.productId == j.productId)
console.log(products)
active.treeTabAdd(
{
name: j.productName,
value: j.productId
},
item.accounttypeId,
products.merchantProTreeResponses,
j.idList
)
})
var filterName = 'treeTab' + item.accounttypeId
var productId = 'tab_' + item.accounttypeId + '_' + productData.productList[0].productId
console.log(filterName, productId)
active.tabChange(filterName, productId)
console.log(productData.productList)
if (productData.productList && productData.productList.length != 0) {
productData.productList.forEach(j => {
console.log(j, item)
var products = item.products.find(n => n.productId == j.productId)
console.log(products)
active.treeTabAdd(
{
name: j.productName,
value: j.productId
},
item.accounttypeId,
products.merchantProTreeResponses,
j.idList
)
if (products.merchantProTreeResponses.length == 0) {
$(`#nomenutab_${id}_${j.productId}`).removeClass('hide')
$(`#nomenutab_${id}_${j.productId}`).addClass('show')
} else {
$(`#nomenutab_${id}_${j.productId}`).removeClass('show')
$(`#nomenutab_${id}_${j.productId}`).addClass('hide')
}
})
var filterName = 'treeTab' + item.accounttypeId
var productId = 'tab_' + item.accounttypeId + '_' + productData.productList[0].productId
console.log(filterName, productId)
active.tabChange(filterName, productId)
}
}
})
}
......@@ -609,7 +666,7 @@
method: 'org.ore.api.role.getById',
id: id
}
request(params, function (res) {
request(params, function(res) {
if (res.code == '0') {
var data = res.data
var accounttypeId = ''
......@@ -630,74 +687,85 @@
// 获取角色权限数据requestList
function getAuthList() {
requestList = []
console.log(treeData)
for (var key in treeData) {
var accountObj = treeData[key]
var productList = []
for (var i in accountObj) {
var productObj = accountObj[i]
var menuIdList = []
var functionIdList = []
var functionIdLists = []
var functionValueIdLists = []
var nodes = productObj.treeObj.getCheckedNodes(true)
$.each(nodes, function (index, item) {
if (item.logo == 'function') {
functionIdLists.push(item)
} else if (item.logo == 'functionValue') {
functionValueIdLists.push(item)
} else {
if (item.logo != 'neglect') {
menuIdList.push(item.id)
}
}
})
$.each(functionValueIdLists, function (idx, m) {
// m.parentId
var findIdx = -1
$.each(functionIdList, function (idn, n) {
if (n.id == m.parentId) {
findIdx = idn
}
})
if (findIdx != -1) {
functionIdList[findIdx].functionValue += ';' + m.id + ':' + m.label
if (Object.keys(accountObj).length != 0) {
for (var i in accountObj) {
var productObj = accountObj[i]
var menuIdList = []
var functionIdList = []
var functionIdLists = []
var functionValueIdLists = []
if (productObj.treeObj) {
var nodes = productObj.treeObj.getCheckedNodes(true)
$.each(nodes, function(index, item) {
if (item.logo == 'function') {
functionIdLists.push(item)
} else if (item.logo == 'functionValue') {
functionValueIdLists.push(item)
} else {
if (item.logo != 'neglect') {
menuIdList.push(item.id)
}
}
})
$.each(functionValueIdLists, function(idx, m) {
// m.parentId
var findIdx = -1
$.each(functionIdList, function(idn, n) {
if (n.id == m.parentId) {
findIdx = idn
}
})
if (findIdx != -1) {
functionIdList[findIdx].functionValue += ';' + m.id + ':' + m.label
} else {
functionIdList.push({
id: m.parentId,
menuId: m.superParentId,
functionValue: m.id + ':' + m.label
})
}
})
$.each(functionIdLists, function(idx, m) {
// console.log(m)
functionIdList.push({
id: m.parentId,
menuId: m.superParentId
})
})
productList.push({
productId: productObj.productId,
functionIdList: functionIdList,
menuIdList: menuIdList
})
} else {
functionIdList.push({
id: m.parentId,
menuId: m.superParentId,
functionValue: m.id + ':' + m.label
productList.push({
productId: productObj.productId,
functionIdList: [],
menuIdList: []
})
}
})
$.each(functionIdLists, function (idx, m) {
// console.log(m)
functionIdList.push({
id: m.parentId,
menuId: m.superParentId
})
})
productList.push({
productId: productObj.productId,
functionIdList: functionIdList,
menuIdList: menuIdList
}
requestList.push({
accountTypeId: key,
productList: productList
})
}
requestList.push({
accountTypeId: key,
productList: productList
})
}
}
// 查询所有商户
function findAllMerchant() {
var params = { method: 'cn.com.glsx.merchants.menu.findAllMerchant' }
request(params, function (result) {
request(params, function(result) {
if (result.code == '0') {
console.log(result)
var list = result.data
list.unshift('')
$.each(list, function (index, item) {
$.each(list, function(index, item) {
merchantName.append(new Option(item.merchantName, item.id))
})
form.render('select')
......@@ -719,6 +787,12 @@
<!-- <button class="layui-btn" data-type="{{d.id}}" id="checkedAll">全选</button>
<button class="layui-btn" id="cancelCheckedAll">取消全选</button> -->
<ul id="tree_{{d.id}}" class="ztree wrapper-tree"></ul>
<div class="layui-no-data show" id="nomenu{{d.id}}">
<div class="no-data">
<img src="../../css/img/no-data.png" />
<div>暂无可选择的菜单功能</div>
</div>
</div>
</script>
</body>
</html>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!