Commit e626a670 by 胡悦

修复角色权限未选产品问题,

1 parent 562503d1
...@@ -255,6 +255,7 @@ ...@@ -255,6 +255,7 @@
}, },
name: 'merchantId', name: 'merchantId',
filterable: true, filterable: true,
clickClose: true,
radio: true, radio: true,
data: [], data: [],
on: function(data) { on: function(data) {
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
<form action="" class="layui-form" lay-filter="employeeForm"> <form action="" class="layui-form" lay-filter="employeeForm">
<div class="layui-form-item"> <div class="layui-form-item">
<div class="twocol"> <div class="twocol">
<div class="layui-inline merchantNames" pane id="addEl"> <div class="layui-inline" pane id="addEl">
<button type="button" class="layui-btn layui-btn-normal createBtn" id="addEmployee"> <button type="button" class="layui-btn layui-btn-normal createBtn" id="addEmployee">
<i class="layui-icon layui-icon-addition"></i> <i class="layui-icon layui-icon-addition"></i>
<span>创建员工</span> <span>创建员工</span>
...@@ -203,6 +203,7 @@ ...@@ -203,6 +203,7 @@
value: 'id' value: 'id'
}, },
name: 'merchantId', name: 'merchantId',
clickClose: true,
filterable: true, filterable: true,
radio: true, radio: true,
data: [] data: []
......
...@@ -197,6 +197,7 @@ ...@@ -197,6 +197,7 @@
name: 'merchantId', name: 'merchantId',
filterable: true, filterable: true,
radio: true, radio: true,
clickClose: true,
data: [], data: [],
on: function(data) { on: function(data) {
console.log(data) console.log(data)
...@@ -472,7 +473,7 @@ ...@@ -472,7 +473,7 @@
// 复选框的change事件 // 复选框的change事件
form.on('checkbox(switch)', function(data) { form.on('checkbox(switch)', function(data) {
console.log(data, '111111111') console.log(data, '111111111', treeData)
if (data.elem.checked) { if (data.elem.checked) {
var obj = { title: data.elem.title, value: data.elem.value } var obj = { title: data.elem.title, value: data.elem.value }
check_arr.push({ check_arr.push({
...@@ -480,7 +481,9 @@ ...@@ -480,7 +481,9 @@
}) })
active.tabAdd(obj) active.tabAdd(obj)
console.log(check_arr) console.log(check_arr)
treeData[+data.elem.value] = {}
} else { } else {
console.log(11222)
for (var i in check_arr) { for (var i in check_arr) {
var id = check_arr[i].accounttypeId var id = check_arr[i].accounttypeId
if (check_arr[i].accounttypeId == data.elem.value) { if (check_arr[i].accounttypeId == data.elem.value) {
...@@ -488,7 +491,9 @@ ...@@ -488,7 +491,9 @@
check_arr.splice(i, 1) check_arr.splice(i, 1)
} }
} }
delete treeData[data.elem.value]
} }
console.log(treeData)
if (check_arr.length != 0) { if (check_arr.length != 0) {
active.tabChange('roleAuth', check_arr[0].accounttypeId) active.tabChange('roleAuth', check_arr[0].accounttypeId)
} }
...@@ -545,14 +550,21 @@ ...@@ -545,14 +550,21 @@
delFlag: delFlag delFlag: delFlag
} }
console.log(requestList) console.log(requestList)
if (delFlag == 1) { let hasProduct = requestList.some(item => item.productList.length != 0)
if (requestList.length != 0) { // 找这个数组里面是否有空值,然后判断是否为草稿,
if (delFlag == 1) { // 草稿
// if (hasProduct) {
otherParams.requestList = JSON.stringify(requestList) otherParams.requestList = JSON.stringify(requestList)
} else { // } else {
otherParams.requestList = JSON.stringify([]) // otherParams.requestList = JSON.stringify([])
} // }
// if (requestList.length != 0) {
// otherParams.requestList = JSON.stringify(requestList)
// } else {
// otherParams.requestList = JSON.stringify([])
// }
} else { } else {
if (requestList.length != 0) { if (hasProduct) {
otherParams.requestList = JSON.stringify(requestList) otherParams.requestList = JSON.stringify(requestList)
} else { } else {
layer.msg('请选择产品', { layer.msg('请选择产品', {
...@@ -560,6 +572,14 @@ ...@@ -560,6 +572,14 @@
}) })
return return
} }
// if (requestList.length != 0) {
// otherParams.requestList = JSON.stringify(requestList)
// } else {
// layer.msg('请选择产品', {
// icon: 2
// })
// return
// }
} }
// otherParams.requestList = JSON.stringify([]) // otherParams.requestList = JSON.stringify([])
if (roleid) { if (roleid) {
...@@ -634,6 +654,8 @@ ...@@ -634,6 +654,8 @@
var productId = 'tab_' + item.accounttypeId + '_' + productData.productList[0].productId var productId = 'tab_' + item.accounttypeId + '_' + productData.productList[0].productId
console.log(filterName, productId) console.log(filterName, productId)
active.tabChange(filterName, productId) active.tabChange(filterName, productId)
} else {
treeData[productData.accounttypeId] = {}
} }
} }
}) })
...@@ -719,7 +741,7 @@ ...@@ -719,7 +741,7 @@
var productList = [] var productList = []
console.log(treeData) console.log(treeData)
// if (i.accounttypeId == key) { // if (i.accounttypeId == key) {
if (Object.keys(accountObj).length != 0) { // if (Object.keys(accountObj).length != 0) {
for (var i in accountObj) { for (var i in accountObj) {
var productObj = accountObj[i] var productObj = accountObj[i]
var menuIdList = [] var menuIdList = []
...@@ -781,7 +803,7 @@ ...@@ -781,7 +803,7 @@
accountTypeId: key, accountTypeId: key,
productList: productList productList: productList
}) })
} // }
// } else { // } else {
// requestList.push({ // requestList.push({
// accountTypeId: i.accounttypeId, // accountTypeId: i.accounttypeId,
......
...@@ -197,8 +197,15 @@ ...@@ -197,8 +197,15 @@
} }
}) })
</script> </script>
<script type="text/html" id="treeAuth"> <!-- <script type="text/html" id="treeAuth">
<ul id="tree_{{d.id}}" class="ztree wrapper-tree"></ul> <ul id="tree_{{d.id}}" class="ztree wrapper-tree"></ul>
</script> <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>
</div>
</script> -->
</body> </body>
</html> </html>
...@@ -159,6 +159,7 @@ ...@@ -159,6 +159,7 @@
}, },
name: 'merchantId', name: 'merchantId',
filterable: true, filterable: true,
clickClose: true,
radio: true, radio: true,
data: [] data: []
}) })
......
...@@ -38,7 +38,7 @@ layui.define(['element', 'laytpl', 'gtree', 'xmSelect'], function (exports) { ...@@ -38,7 +38,7 @@ layui.define(['element', 'laytpl', 'gtree', 'xmSelect'], function (exports) {
var getTpl = `<div class="layui-tab layui-tab-card" lay-filter="treeTab{{d.id}}"> var getTpl = `<div class="layui-tab layui-tab-card" lay-filter="treeTab{{d.id}}">
<ul class="layui-tab-title"></ul> <ul class="layui-tab-title"></ul>
<div class="layui-tab-content"> <div class="layui-tab-content">
<div class="layui-no-data show" id="nodata${id}"> <div class="layui-no-data show" id="nodata{{d.id}}">
<div class="no-data"> <div class="no-data">
<img src="../../css/img/no-data.png" /> <img src="../../css/img/no-data.png" />
<div>暂无数据</div> <div>暂无数据</div>
...@@ -97,6 +97,31 @@ layui.define(['element', 'laytpl', 'gtree', 'xmSelect'], function (exports) { ...@@ -97,6 +97,31 @@ layui.define(['element', 'laytpl', 'gtree', 'xmSelect'], function (exports) {
// tab Change // tab Change
tabChange: function (name, id) { tabChange: function (name, id) {
element.tabChange(name, id) element.tabChange(name, id)
console.log(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')
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')
}
}
})
}
})
}
}, },
/** /**
* 第二级选项卡 * 第二级选项卡
...@@ -117,7 +142,14 @@ layui.define(['element', 'laytpl', 'gtree', 'xmSelect'], function (exports) { ...@@ -117,7 +142,14 @@ layui.define(['element', 'laytpl', 'gtree', 'xmSelect'], function (exports) {
content: '<div id="treeTab' + productId + '"></div>', // 放置模板视图的div content: '<div id="treeTab' + productId + '"></div>', // 放置模板视图的div
id: productId id: productId
}) })
var getTreeTpl = '<ul id="tree_{{d.id}}" class="ztree wrapper-tree"></ul>' var getTreeTpl = `<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>
</div>`
treeView = document.getElementById('treeTab' + productId) // 放置模板视图的div treeView = document.getElementById('treeTab' + productId) // 放置模板视图的div
treeData[id] = treeData[id] || {} treeData[id] = treeData[id] || {}
treeData[id][item.value] = treeData[id][item.value] || {} treeData[id][item.value] = treeData[id][item.value] || {}
...@@ -145,7 +177,14 @@ layui.define(['element', 'laytpl', 'gtree', 'xmSelect'], function (exports) { ...@@ -145,7 +177,14 @@ layui.define(['element', 'laytpl', 'gtree', 'xmSelect'], function (exports) {
content: '<div id="treeTab' + productId + '"></div>', // 放置模板视图的div content: '<div id="treeTab' + productId + '"></div>', // 放置模板视图的div
id: productId id: productId
}) })
var getTreeTpl = '<ul id="tree_{{d.id}}" class="ztree wrapper-tree"></ul>' var getTreeTpl = `<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>
</div>`
treeView = document.getElementById('treeTab' + productId) // 放置模板视图的div treeView = document.getElementById('treeTab' + productId) // 放置模板视图的div
treeData[id] = treeData[id] || {} treeData[id] = treeData[id] || {}
treeData[id][item.value] = treeData[id][item.value] || {} treeData[id][item.value] = treeData[id][item.value] || {}
...@@ -162,11 +201,11 @@ layui.define(['element', 'laytpl', 'gtree', 'xmSelect'], function (exports) { ...@@ -162,11 +201,11 @@ layui.define(['element', 'laytpl', 'gtree', 'xmSelect'], function (exports) {
}) })
console.log(productTreeList) console.log(productTreeList)
if (productTreeList && productTreeList.length != 0) { if (productTreeList && productTreeList.length != 0) {
$(`#nodata${id}`).removeClass('show') $(`#nomenu${productId}`).removeClass('show')
$(`#nodata${id}`).addClass('hide') $(`#nomenu${productId}`).addClass('hide')
} else { // } else {
$(`#nodata${id}`).removeClass('hide') // $(`#nodata${id}`).removeClass('hide')
$(`#nodata${id}`).addClass('show') // $(`#nodata${id}`).addClass('show')
} }
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!