Commit c12d4857 by 胡悦

修复角色和商户

1 parent 15c8c86c
......@@ -12,6 +12,11 @@
<link rel="stylesheet" type="text/css" href="/css/commonResetIndex.css" />
<title>员工管理</title>
</head>
<style>
xm-select > .xm-body .scroll-body {
width: 300px;
}
</style>
<body>
<div id="app">
......@@ -31,7 +36,8 @@
<div class="layui-inline merchantNames" pane>
<label class="layui-form-label">商户名称</label>
<div class="layui-input-block">
<select name="merchantId" id="merchantName" lay-verify="required"></select>
<!-- <select name="merchantId" id="merchantName" lay-verify="required"></select> -->
<div id="merchantNameSelect" style="width: 300px;" class="xm-select-demo"></div>
</div>
</div>
</div>
......@@ -80,12 +86,13 @@
<script src="https://www.layuicdn.com/layui/layui.js"></script>
<script src="/js/load.js"></script>
<script>
layui.use(['table', 'request', 'form', 'helper', 'laypage'], function () {
layui.use(['table', 'request', 'form', 'helper', 'laypage', 'xmSelect'], function () {
var request = layui.request
var table = layui.table
var form = layui.form
var helper = layui.helper
var laypage = layui.laypage
var xmSelect = layui.xmSelect
var $ = layui.$
// var isDxternal = isAppend()
// if (isDxternal) {
......@@ -177,6 +184,17 @@
}
}
var merchantNameSelect = xmSelect.render({
el: '#merchantNameSelect',
prop: {
name: 'merchantName',
value: 'id'
},
filterable: true,
radio: true,
data: []
})
// 初始化
init()
......@@ -265,6 +283,7 @@
// 查询事件
$('#employeeSearch').on('click', function () {
var searchData = getSearch()
console.log(searchData)
getTabelList(employeeTable, searchData, true)
})
......@@ -317,18 +336,20 @@
employeeTable.reload(options)
})
}
// 查询所有商户
function findAllMerchant() {
var params = { method: 'cn.com.glsx.merchants.menu.findAllMerchant' }
request(params, function (result) {
if (result.code == '0') {
var list = result.data
list.unshift('')
$.each(list, function (index, item) {
merchantName.append(new Option(item.merchantName, item.id))
console.log(result.data)
merchantNameSelect.update({
data: result.data,
autoRow: true,
paging: result.data.length > 20
})
form.render('select')
}
})
}
......@@ -347,8 +368,12 @@
searchData.staffName = ''
searchData.staffPhone = ''
}
if (searchData.select) {
searchData.merchantId = searchData.select
}
delete searchData.type
delete searchData.keywords
delete searchData.select
return searchData
}
......
......@@ -1491,28 +1491,6 @@
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')
}
}
})
}
})
}
},
/**
......@@ -1572,6 +1550,23 @@
roleId,
changeObj.merchantProTreeResponses
)
$(`#nodata${roleId}`).removeClass('show')
$(`#nodata${roleId}`).addClass('hide')
menuFunTreeData.forEach(item => {
if (item.accounttypeId == roleId) {
item.products.forEach(i => {
if (i.productId == projectId) {
if (i.merchantProTreeResponses.length == 0) {
$(`#nomenutab_${roleId}_${projectId}`).removeClass('hide')
$(`#nomenutab_${roleId}_${projectId}`).addClass('show')
} else {
$(`#nomenutab_${roleId}_${projectId}`).removeClass('show')
$(`#nomenutab_${roleId}_${projectId}`).addClass('hide')
}
}
})
}
})
} else {
// 删除
console.log(treeData, Object.keys(treeData).length)
......
......@@ -411,21 +411,6 @@
</div>
</div>
</div>
<div class="layui-form-item hide" id="effectiveShowEl">
<label class="layui-form-label required">账户有效期:</label>
<div class="layui-inline">
<div class="layui-input-inline">
<input type="text" id="effectiveStarttime" class="layui-input" name="effectiveStarttime" placeholder="开始时间" />
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline">
<input type="text" id="expireDate" disabled class="layui-input" name="expireDate" placeholder="结束时间" />
</div>
<button id="sevenday" type="button" class="layui-btn btn-no-border">续7天</button>
<button id="oneyear" type="button" class="layui-btn btn-no-border">续1年</button>
<button id="twoyears" type="button" class="layui-btn btn-no-border">续2年</button>
</div>
</div>
<div class="layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label required">登录账户名:</label>
......@@ -460,12 +445,28 @@
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label required">账户等级:</label>
<div class="layui-input-inline">
<select id="accountLevelEl" name="merchantAccountLevel" lay-filter="accountLevel" required lay-vertify="required" lay-search></select>
</div>
</div>
<div class="layui-form-item hide" id="effectiveShowEl">
<label class="layui-form-label required">账户有效期:</label>
<div class="layui-inline">
<div class="layui-input-inline">
<input type="text" id="effectiveStarttime" class="layui-input" name="effectiveStarttime" placeholder="开始时间" />
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline">
<input type="text" id="expireDate" disabled class="layui-input" name="expireDate" placeholder="结束时间" />
</div>
<button id="sevenday" type="button" class="layui-btn btn-no-border">续7天</button>
<button id="oneyear" type="button" class="layui-btn btn-no-border">续1年</button>
<button id="twoyears" type="button" class="layui-btn btn-no-border">续2年</button>
</div>
</div>
<!-- <div class="layui-form-item" id="effectiveShowEl">
<label class="layui-form-label required">账户有效期:</label>
<div class="layui-input-inline">
......@@ -612,8 +613,6 @@
min: helper.dateFormat(new Date()),
done: function (value, date) {
console.log(value, date, helper.dateFormat(new Date()))
// $('#effectiveStarttime').change()
// effectiveStarttime.config.min = helper.dateFormat(new Date())
date.month = date.month - 1
$('#expireDate').val('')
expireDate.config.min = date
......@@ -1510,28 +1509,6 @@
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')
}
}
})
}
})
}
},
/**
......@@ -1591,6 +1568,23 @@
roleId,
changeObj.merchantProTreeResponses
)
$(`#nodata${roleId}`).removeClass('show')
$(`#nodata${roleId}`).addClass('hide')
menuFunTreeData.forEach(item => {
if (item.accounttypeId == roleId) {
item.products.forEach(i => {
if (i.productId == projectId) {
if (i.merchantProTreeResponses.length == 0) {
$(`#nomenutab_${roleId}_${projectId}`).removeClass('hide')
$(`#nomenutab_${roleId}_${projectId}`).addClass('show')
} else {
$(`#nomenutab_${roleId}_${projectId}`).removeClass('show')
$(`#nomenutab_${roleId}_${projectId}`).addClass('hide')
}
}
})
}
})
} else {
// 删除
console.log(treeData, Object.keys(treeData).length)
......
......@@ -1457,32 +1457,9 @@
},
// 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')
}
}
})
}
})
}
},
/**
......@@ -1552,6 +1529,23 @@
roleId,
changeObj.merchantProTreeResponses
)
$(`#nodata${roleId}`).removeClass('show')
$(`#nodata${roleId}`).addClass('hide')
menuFunTreeData.forEach(item => {
if (item.accounttypeId == roleId) {
item.products.forEach(i => {
if (i.productId == projectId) {
if (i.merchantProTreeResponses.length == 0) {
$(`#nomenutab_${roleId}_${projectId}`).removeClass('hide')
$(`#nomenutab_${roleId}_${projectId}`).addClass('show')
} else {
$(`#nomenutab_${roleId}_${projectId}`).removeClass('show')
$(`#nomenutab_${roleId}_${projectId}`).addClass('hide')
}
}
})
}
})
} else {
// 删除
console.log(treeData, Object.keys(treeData).length)
......
......@@ -112,25 +112,26 @@
effectiveTime: getQueryString('status')
})
}
var effectiveStarttime = laydate.render({
elem: '#effectiveStarttime',
format: 'yyyy-MM-dd',
min: '',
min: helper.dateFormat(new Date()),
done: function (value, date) {
effectiveStarttime.config.min = helper.dateFormat(new Date())
// effectiveStarttime.config.min = helper.dateFormat(new Date())
console.log(value, date)
date.month = date.month - 1
expireDate.config.min = date
// expireDate.config.min = date
$('#expireDate').val('')
lay('#effectiveStarttime').html(value)
}
})
var expireDate = laydate.render({
elem: '#expireDate',
format: 'yyyy-MM-dd',
min: $('#effectiveStarttime').val()
min: helper.dateFormat(new Date())
})
$('#sevenday').on('click', function () {
const startDate = getStartTime(vaildData.expireDate).startDate
......
......@@ -456,6 +456,7 @@
accounttypeId: data.elem.value
})
active.tabAdd(obj)
console.log(check_arr)
} else {
for (var i in check_arr) {
var id = check_arr[i].accounttypeId
......@@ -501,6 +502,7 @@
$('#draft').on('click', function() {
var formVal = form.val('roleForm')
if (formVal.roleName || formVal.roleDescription || Object.keys(treeData).length != 0) {
getAuthList()
insert(1, formVal)
} else {
layer.msg('至少填一项')
......@@ -687,74 +689,85 @@
// 获取角色权限数据requestList
function getAuthList() {
requestList = []
console.log(treeData)
for (var key in treeData) {
var accountObj = treeData[key]
var productList = []
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
console.log(treeData, check_arr)
check_arr.forEach(i => {
for (var key in treeData) {
var accountObj = treeData[key]
var productList = []
console.log(treeData)
if (i.accounttypeId == key) {
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
})
} else {
productList.push({
productId: productObj.productId,
functionIdList: [],
menuIdList: []
}
requestList.push({
accountTypeId: key,
productList: productList
})
}
} else {
requestList.push({
accountTypeId: i.accounttypeId,
productList: []
})
}
requestList.push({
accountTypeId: key,
productList: productList
})
}
}
})
}
// 查询所有商户
......
......@@ -80,6 +80,7 @@
var $ = layui.$
// 商户名称列表
var merchantName = $('#merchantName')
var accountInfo = helper.store.get('accountInfo')
var cols = [
//表头
{ field: '', title: '序号', type: 'numbers', width: 60 },
......@@ -105,7 +106,7 @@
elem: '#roleTable',
skin: 'nob',
height: 'full-300',
cols: gl ? [cols] : [colums]
cols: accountInfo && accountInfo.merchantAccountLevel == 4 ? [colums] : [cols]
})
// 分页配置
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!