Commit fc2af01a by 胡悦

合并

2 parents 4b5c1894 76a46481
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8" />
<meta content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="广联帐户管理中心-员工管理" />
<meta name="author" content="GLSX Web Team" />
<meta name="keywords" itemprop="keywords" content="广联,帐户管理,员工管理" />
<link rel="stylesheet" type="text/css" href="/css/main.css" />
<title>员工管理</title>
<style>
.upload-img-box {
position: relative;
width: 80px;
height: 80px;
color: #999999;
border: 1px dashed #d9d9d9;
cursor: pointer;
}
.upload-img-box .upload-img {
position: absolute;
width: 80px;
top: 0;
left: 0;
}
<head>
<meta charset="utf-8" />
<meta content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="广联帐户管理中心-员工管理" />
<meta name="author" content="GLSX Web Team" />
<meta name="keywords" itemprop="keywords" content="广联,帐户管理,员工管理" />
<link rel="stylesheet" type="text/css" href="/css/main.css" />
<title>员工管理</title>
<style>
.upload-img-box {
position: relative;
width: 80px;
height: 80px;
color: #999999;
border: 1px dashed #d9d9d9;
cursor: pointer;
}
.icon-add {
position: absolute;
top: 50%;
font-size: 40px;
left: 50%;
transform: translate3d(-50%, -50%, 0);
}
.upload-img-box .upload-img {
position: absolute;
width: 80px;
top: 0;
left: 0;
}
.upload-img-wh {
width: 80px !important;
height: 80px;
}
.icon-add {
position: absolute;
top: 50%;
font-size: 40px;
left: 50%;
transform: translate3d(-50%, -50%, 0);
}
.show {
display: inline-block;
/* width: 360px; */
}
.upload-img-wh {
width: 80px !important;
height: 80px;
}
.hide {
display: none;
}
.show {
display: inline-block;
/* width: 360px; */
}
.tips {
font-size: 14px;
color: #999;
}
.hide {
display: none;
}
.form-right {
position: absolute;
right: 0;
top: 0;
transform: translateX(110%);
}
.tips {
font-size: 14px;
color: #999;
}
.sub-bg-white {
background-color: #fff;
}
.form-right {
position: absolute;
right: 0;
top: 0;
transform: translateX(110%);
}
.edit-box {
padding: 0 20px 20px;
box-sizing: border-box;
color: #333333;
background-color: #ffffff;
margin: 15px auto;
position: relative;
.sub-bg-white {
background-color: #fff;
}
margin-bottom: 100px;
}
.edit-box .grayLine {
position: absolute;
left: 0;
top: 48px;
background-color: #d8d8d8;
width: 100%;
height: 1px;
}
.edit-box {
padding: 0 20px 20px;
box-sizing: border-box;
color: #333333;
background-color: #ffffff;
margin: 15px auto;
position: relative;
.edit-title {
height: 48px;
line-height: 48px;
padding: 0 20px;
margin-bottom: 15px;
font-size: 16px;
color: #333333;
font-weight: 600;
}
.hide {
display: none;
}
.show {
display: block;
}
.pageTitle {
background-color: #fff;
height: 78px;
font-size: 20px;
font-weight: bold;
color: #333333;
line-height: 78px;
padding-left: 20px;
}
.Wrap {
margin: 8px 20px 0;
/* height: 100%; */
}
.xm-select-demo,
xm-select > .xm-body .scroll-body {
width: 360px;
}
</style>
</head>
<body>
<div id="app">
<main>
<div class="Wrap">
<div class="pageTitle">
<span id="addUpdateTitle">新增员工</span>
</div>
<div class="sub-bg-white edit-box">
<div class="grayLine"></div>
<form class="layui-form add" lay-filter="employeeForm" action="">
<div class="layui-form-item edit-title" style="position: relative">
<div class="layui-input-inline">员工基本信息</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label required">所属商户:</label>
<div class="layui-input-block" id="merchantBox">
<!-- <div id="merchantSelect" class="hide"> -->
<!-- <select id="merchantName" name="merchantId" lay-filter="merchants" lay-verify="required" autocomplete="off" placeholder="请选择商户名称" required></select> -->
<div id="merchantNameSelect" class="xm-select-demo"></div>
<!-- </div> -->
<div class="hide" id="merchantIdText" style="line-height: 36px"></div>
</div>
margin-bottom: 100px;
}
.edit-box .grayLine {
position: absolute;
left: 0;
top: 48px;
background-color: #d8d8d8;
width: 100%;
height: 1px;
}
.edit-title {
height: 48px;
line-height: 48px;
padding: 0 20px;
margin-bottom: 15px;
font-size: 16px;
color: #333333;
font-weight: 600;
}
.hide {
display: none;
}
.show {
display: block;
}
.pageTitle {
background-color: #fff;
height: 78px;
font-size: 20px;
font-weight: bold;
color: #333333;
line-height: 78px;
padding-left: 20px;
}
.Wrap {
margin: 8px 20px 0;
/* height: 100%; */
}
.xm-select-demo,
xm-select>.xm-body .scroll-body {
width: 360px;
}
</style>
</head>
<body>
<div id="app">
<main>
<div class="Wrap">
<div class="pageTitle">
<span id="addUpdateTitle">新增员工</span>
</div>
<div class="sub-bg-white edit-box">
<div class="grayLine"></div>
<form class="layui-form add" lay-filter="employeeForm" action="">
<div class="layui-form-item edit-title" style="position: relative">
<div class="layui-input-inline">员工基本信息</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label required">所属商户:</label>
<div class="layui-input-block" id="merchantBox">
<!-- <div id="merchantSelect" class="hide"> -->
<!-- <select id="merchantName" name="merchantId" lay-filter="merchants" lay-verify="required" autocomplete="off" placeholder="请选择商户名称" required></select> -->
<div id="merchantNameSelect" class="xm-select-demo"></div>
<!-- </div> -->
<div class="hide" id="merchantIdText" style="line-height: 36px"></div>
</div>
<div class="layui-form-item">
<label class="layui-form-label required">员工姓名:</label>
<div class="layui-input-block">
<input type="text" name="staffName" maxlength="15" required lay-verify="required" placeholder="请输入员工姓名" autocomplete="off" class="layui-input" />
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label required">员工姓名:</label>
<div class="layui-input-block">
<input type="text" name="staffName" maxlength="15" required lay-verify="required" placeholder="请输入员工姓名"
autocomplete="off" class="layui-input" />
</div>
<div class="layui-form-item">
<label class="layui-form-label required">登录手机号:</label>
<div class="layui-input-block">
<input type="text" name="staffPhone" maxlength="11" required lay-verify="required|phone" placeholder="请输入您有效的手机号作为登录账户" autocomplete="off" class="layui-input" />
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label required">登录手机号:</label>
<div class="layui-input-block">
<input type="text" name="staffPhone" maxlength="11" required lay-verify="required|phone"
placeholder="请输入您有效的手机号作为登录账户" autocomplete="off" class="layui-input" />
</div>
<div class="layui-form-item">
<label class="layui-form-label required">登录密码:</label>
<div class="layui-input-block" style="position: relative">
<input type="password" name="password" id="password" maxlength="15" required lay-verify="required|pass" placeholder="请输入登录密码" autocomplete="off" class="layui-input" />
<button type="button" class="layui-btn form-right hide" id="resetpsw">重置密码</button>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label required">登录密码:</label>
<div class="layui-input-block" style="position: relative">
<input type="password" name="password" id="password" maxlength="15" required lay-verify="required|pass"
placeholder="请输入登录密码" autocomplete="off" class="layui-input" />
<button type="button" class="layui-btn form-right hide" id="resetpsw">重置密码</button>
</div>
<div class="layui-form-item">
<label class="layui-form-label required">可见商户:</label>
<div class="layui-input-block">
<input class="layui-input" placeholder="可见商户" id="searchMerchant" />
<ul id="visibleInferiorMerTree" style="max-height: 200px; overflow-y: auto" class="ztree wrapper-tree"></ul>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label required">可见商户:</label>
<div class="layui-input-block">
<input class="layui-input" placeholder="可见商户" id="searchMerchant" />
<ul id="visibleInferiorMerTree" style="max-height: 200px; overflow-y: auto" class="ztree wrapper-tree">
</ul>
</div>
<div class="layui-form-item">
<label class="layui-form-label required">角色权限:</label>
<div class="layui-input-block" style="position: relative">
<select name="roleIds" id="roleAuth" lay-verify="required"></select>
<div id="btnGroup" class="layui-btn-group hide" style="position: absolute; top: 0; right: -170px">
<button type="button" class="layui-btn" id="refresh">刷新</button>
<button type="button" class="layui-btn" id="addRole">创建角色</button>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label required">角色权限:</label>
<div class="layui-input-block" style="position: relative">
<select name="roleIds" id="roleAuth" lay-verify="required"></select>
<div id="btnGroup" class="layui-btn-group hide" style="position: absolute; top: 0; right: -170px">
<button type="button" class="layui-btn" id="refresh">刷新</button>
<button type="button" class="layui-btn" id="addRole">创建角色</button>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">头像:</label>
<div class="layui-input-block">
<div class="upload-img-box">
<div class="icon-add img-add show">+</div>
<img class="upload-img upload-img-wh hide" id="img" />
<input
type="file"
id="upload"
name="merhcnatImg"
ref="file"
class="upload upload-img-box upload-img-wh"
accept="image/png, image/jpeg, image/gif, image/jpg"
data-idx="0"
style="opacity: 0"
/>
</div>
<span class="tips">图片格式仅支持JPG,PNG格式,大小1M以内</span>
</div>
<div class="layui-form-item">
<label class="layui-form-label">头像:</label>
<div class="layui-input-block">
<div class="upload-img-box">
<div class="icon-add img-add show">+</div>
<img class="upload-img upload-img-wh hide" id="img" />
<input type="file" id="upload" name="merhcnatImg" ref="file"
class="upload upload-img-box upload-img-wh" accept="image/png, image/jpeg, image/gif, image/jpg"
data-idx="0" style="opacity: 0" />
</div>
<span class="tips">图片格式仅支持JPG,PNG格式,大小1M以内</span>
</div>
<div class="layui-form-item">
<label class="layui-form-label">邮箱:</label>
<div class="layui-input-block">
<input type="text" name="staffEmail" maxlength="30" lay-verify="" placeholder="请输入邮箱" autocomplete="off" class="layui-input" />
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">邮箱:</label>
<div class="layui-input-block">
<input type="text" name="staffEmail" maxlength="30" lay-verify="" placeholder="请输入邮箱" autocomplete="off"
class="layui-input" />
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">主要职务:</label>
<div class="layui-input-block">
<input type="text" name="staffJob" maxlength="10" placeholder="请输入主要职务" autocomplete="off" class="layui-input" />
</div>
<div class="layui-form-item">
<label class="layui-form-label">主要职务:</label>
<div class="layui-input-block">
<input type="text" name="staffJob" maxlength="10" placeholder="请输入主要职务" autocomplete="off"
class="layui-input" />
</div>
<div class="footer-close">
<button class="layui-btn" lay-submit lay-filter="employeeSubmit">确定</button>
<button type="reset" class="layui-btn" id="return">取消</button>
</div>
</form>
</div>
</div>
<div class="footer-close">
<button class="layui-btn" lay-submit lay-filter="employeeSubmit">确定</button>
<button type="reset" class="layui-btn" id="return">取消</button>
</div>
</form>
</div>
</main>
</div>
<script src="https://www.layuicdn.com/layui/layui.js"></script>
<script src="/js/load.js"></script>
<script>
//Demo
layui.use(['form', 'upload', 'gtree', 'request', 'helper', 'xmSelect'], function () {
// var merchantId = qs('merchantId')
var id = qs('id')
var form = layui.form
var upload = layui.upload
var tree = layui.gtree
var request = layui.request
var helper = layui.helper
var $ = layui.$
var xmSelect = layui.xmSelect
var merchantFileRequest = {}
var all_nodes = []
var employeeForm = {}
var pwd = $('#password') // 密码输入框
var resetpsw = $('#resetpsw')
var roleAuth = $('#roleAuth')
var merchantName = $('#merchantName')
var merchantId = ''
var visibleMerchant = {}
pwd.attr('readonly', false)
var accountInfo = helper.store.get('accountInfo')
// var accountInfo = {
// merchantAccountLevel: 1,
// merchantId: 81
// }
var merchantNameSelect = xmSelect.render({
el: '#merchantNameSelect',
prop: {
name: 'merchantName',
value: 'id'
},
layVerify: `${qs('channel') ? '' : 'required'}`,
model: {
label: {
type: 'text',
text: {}
}
},
name: 'merchantId',
filterable: true,
clickClose: true,
radio: true,
data: [],
on: function(data) {
console.log(data)
merchantId = data.change[0].id
getList(merchantId)
</div>
</main>
</div>
<script src="https://www.layuicdn.com/layui/layui.js"></script>
<script src="/js/load.js"></script>
<script>
//Demo
layui.use(['form', 'upload', 'gtree', 'request', 'helper', 'xmSelect'], function () {
// var merchantId = qs('merchantId')
var id = qs('id')
var form = layui.form
var upload = layui.upload
var tree = layui.gtree
var request = layui.request
var helper = layui.helper
var $ = layui.$
var xmSelect = layui.xmSelect
var merchantFileRequest = {}
var all_nodes = []
var employeeForm = {}
var pwd = $('#password') // 密码输入框
var resetpsw = $('#resetpsw')
var roleAuth = $('#roleAuth')
var merchantName = $('#merchantName')
var merchantId = ''
var visibleMerchant = {}
pwd.attr('readonly', false)
var accountInfo = helper.store.get('accountInfo')
// var accountInfo = {
// merchantAccountLevel: 1,
// merchantId: 81
// }
// 禁用所有input框的回车事件
var inputs = document.getElementsByTagName('input')
for (let i = 0; i < inputs.length; i++) {
var input = inputs[i]
input.onkeydown = function (event) {
if (event.keyCode == 13) {
event.keyCode = 0;
event.returnValue = false;
}
})
if (accountInfo && !id) {
$('#btnGroup').addClass('show')
}
// 判断是从商户过来还是员工
if (qs('channel')) {
getList(qs('merchantId'))
}
var merchantNameSelect = xmSelect.render({
el: '#merchantNameSelect',
prop: {
name: 'merchantName',
value: 'id'
},
layVerify: `${qs('channel') ? '' : 'required'}`,
model: {
label: {
type: 'text',
text: {}
}
},
name: 'merchantId',
filterable: true,
clickClose: true,
radio: true,
data: [],
on: function (data) {
console.log(data)
merchantId = data.change[0].id
getList(merchantId)
}
})
if (accountInfo && !id) {
$('#btnGroup').addClass('show')
}
// 判断是从商户过来还是员工
if (qs('channel')) {
getList(qs('merchantId'))
merchantId = qs('merchantId')
$('#merchantIdText').text(qs('merchantName'))
$('#merchantIdText').removeClass('hide')
$('#merchantIdText').addClass('show')
$('#merchantNameSelect').addClass('hide')
} else {
// var str =
// '<div id="merchantSelect" class="hide"><select id="merchantName" name="merchantId" lay-filter="merchants" lay-verify="required" autocomplete="off" placeholder="请选择商户名称" required></select></div>'
// $('#merchantBox').append(str)
if (qs('id')) {
// 判断是否是编辑
resetpsw.removeClass('hide')
resetpsw.addClass('show')
merchantId = qs('merchantId')
$('#merchantIdText').text(qs('merchantName'))
$('#merchantIdText').removeClass('hide')
$('#merchantIdText').addClass('show')
getList(qs('merchantId'))
$('#addUpdateTitle').text('修改员工')
$('#merchantNameSelect').addClass('hide')
} else {
// var str =
// '<div id="merchantSelect" class="hide"><select id="merchantName" name="merchantId" lay-filter="merchants" lay-verify="required" autocomplete="off" placeholder="请选择商户名称" required></select></div>'
// $('#merchantBox').append(str)
if (qs('id')) {
// 判断是否是编辑
resetpsw.removeClass('hide')
resetpsw.addClass('show')
merchantId = qs('merchantId')
$('#merchantIdText').text(qs('merchantName'))
$('#merchantIdText').removeClass('hide')
$('#merchantIdText').addClass('show')
getList(qs('merchantId'))
$('#addUpdateTitle').text('修改员工')
$('#merchantNameSelect').addClass('hide')
}
findAllMerchant(function (result) {})
}
findAllMerchant(function (result) { })
}
/** 手动触发事件 */
// 上传图片
$('.upload').on('change', function (e) {
var el = $('#upload')
var imgEl = $('#img')
var addEl = $('.img-add')
var reader = new FileReader()
var fileInfo = el[0].files[0]
merchantFileRequest.fileName = fileInfo.name
reader.readAsDataURL(fileInfo)
reader.onload = function (e) {
if (e) {
const imgFile = e.target.result
const base64 = fileInfo.name.split('.')[1] + '@' + imgFile.split(',')[1]
request(
{
method: 'glsx.accounts.biz.common.pictureUpload',
file: base64
},
function (result) {
merchantFileRequest.fileUrl = result.data
imgEl.attr('src', result.data)
imgEl.removeClass('hide')
imgEl.addClass('show')
addEl.removeClass('show')
addEl.addClass('hide')
},
{},
['file'],
true
)
}
/** 手动触发事件 */
// 上传图片
$('.upload').on('change', function (e) {
var el = $('#upload')
var imgEl = $('#img')
var addEl = $('.img-add')
var reader = new FileReader()
var fileInfo = el[0].files[0]
merchantFileRequest.fileName = fileInfo.name
reader.readAsDataURL(fileInfo)
reader.onload = function (e) {
if (e) {
const imgFile = e.target.result
const base64 = fileInfo.name.split('.')[1] + '@' + imgFile.split(',')[1]
request(
{
method: 'glsx.accounts.biz.common.pictureUpload',
file: base64
},
function (result) {
merchantFileRequest.fileUrl = result.data
imgEl.attr('src', result.data)
imgEl.removeClass('hide')
imgEl.addClass('show')
addEl.removeClass('show')
addEl.addClass('hide')
},
{},
['file'],
true
)
}
reader.onload()
})
}
reader.onload()
})
// 返回上个页面
$('#return').on('click', function () {
window.history.back()
})
// 返回上个页面
$('#return').on('click', function () {
window.history.back()
})
// 重置密码
resetpsw.on('click', function () {
pwd.attr('readonly', false)
pwd.val('')
})
// 重置密码
resetpsw.on('click', function () {
pwd.attr('readonly', false)
pwd.val('')
})
// 刷新
$('#refresh').on('click', function () {
if (!merchantId) {
layer.msg('请选择所属商户!')
} else {
findRoleList(merchantId)
}
})
// 刷新
$('#refresh').on('click', function () {
if (!merchantId) {
layer.msg('请选择所属商户!')
} else {
findRoleList(merchantId)
}
})
// 创建角色
$('#addRole').on('click', function () {
go('role', 'add')
// $messenger.emit('route-to', { path: '/settings/role/add' })
})
// 创建角色
$('#addRole').on('click', function () {
go('role', 'add')
// $messenger.emit('route-to', { path: '/settings/role/add' })
})
// 提交表单
form.on('submit(employeeSubmit)', function (data) {
console.log(data)
if (visibleMerchant.getCheckedNodes(true).length == 0) {
layer.msg('可见商户必选', {
icon: 2
})
return false
}
var visibleInferiorMer = visibleMerchant
.getCheckedNodes(true)
.map(function (i) {
return i.id
})
.join(',')
var otherParams = {
visibleInferiorMer: visibleInferiorMer,
merchantId: merchantId
}
if (merchantFileRequest.fileName) {
otherParams.merchantFileRequest = JSON.stringify(merchantFileRequest)
}
if (id) {
otherParams.id = id
otherParams.method = 'cn.com.glsx.merchants.staff.updateStaff'
} else {
otherParams.method = 'cn.com.glsx.merchants.staff.saveStaff'
}
var params = helper.clone(true, data.field, otherParams)
delete params.merhcnatImg
console.log(params)
request(params, function (result) {
if (result.code == '0') {
layer.msg('操作成功', {
icon: 1
})
window.history.back()
}
// 提交表单
form.on('submit(employeeSubmit)', function (data) {
console.log(data)
if (visibleMerchant.getCheckedNodes(true).length == 0) {
layer.msg('可见商户必选', {
icon: 2
})
return false
}
var visibleInferiorMer = visibleMerchant
.getCheckedNodes(true)
.map(function (i) {
return i.id
})
.join(',')
var otherParams = {
visibleInferiorMer: visibleInferiorMer,
merchantId: merchantId
}
if (merchantFileRequest.fileName) {
otherParams.merchantFileRequest = JSON.stringify(merchantFileRequest)
}
if (id) {
otherParams.id = id
otherParams.method = 'cn.com.glsx.merchants.staff.updateStaff'
} else {
otherParams.method = 'cn.com.glsx.merchants.staff.saveStaff'
}
var params = helper.clone(true, data.field, otherParams)
delete params.merhcnatImg
console.log(params)
request(params, function (result) {
if (result.code == '0') {
layer.msg('操作成功', {
icon: 1
})
window.history.back()
}
})
return false
})
// 表单验证
form.verify({
pass: [/^[\S]{6,15}$/, '密码必须6-15位']
})
// 表单验证
form.verify({
pass: [/^[\S]{6,15}$/, '密码必须6-15位']
})
// select 选择触发
form.on('select(merchants)', function (data) {
console.log(data.value)
merchantId = data.value
getList(merchantId)
})
// select 选择触发
form.on('select(merchants)', function (data) {
console.log(data.value)
merchantId = data.value
getList(merchantId)
})
/** 定义方法 */
/** 定义方法 */
function getList(merchantId) {
getVisibleMerchant(merchantId)
findRoleList(merchantId)
}
function getList(merchantId) {
getVisibleMerchant(merchantId)
findRoleList(merchantId)
}
// 可见商户
function getVisibleMerchant(merchantId) {
var visibleMerchantParams = { id: merchantId, method: 'cn.com.glsx.merchants.merchant.findMerchantTree' }
request(visibleMerchantParams, function (res) {
if (res.code == '0') {
if (id) {
findAllMerchant(function (result) {
if (result) {
getById(function (checkedList) {
createMerchant(checkedList, res.data)
})
}
})
} else {
const arr = []
arr.push(+merchantId)
createMerchant(arr, res.data)
}
// 可见商户
function getVisibleMerchant(merchantId) {
var visibleMerchantParams = { id: merchantId, method: 'cn.com.glsx.merchants.merchant.findMerchantTree' }
request(visibleMerchantParams, function (res) {
if (res.code == '0') {
if (id) {
findAllMerchant(function (result) {
if (result) {
getById(function (checkedList) {
createMerchant(checkedList, res.data)
})
}
})
} else {
const arr = []
arr.push(+merchantId)
createMerchant(arr, res.data)
}
})
}
}
})
}
function createMerchant(arr, data) {
visibleMerchant = tree.create('visibleInferiorMerTree', data, null, {
check: {
enable: true,
chkboxType: {
Y: '',
N: ''
}
function createMerchant(arr, data) {
visibleMerchant = tree.create('visibleInferiorMerTree', data, null, {
check: {
enable: true,
chkboxType: {
Y: '',
N: ''
}
})
visibleMerchant.checkNodes(arr)
all_nodes = visibleMerchant.transformToArray(visibleMerchant.getNodes())
bindEvent()
}
}
})
visibleMerchant.checkNodes(arr)
all_nodes = visibleMerchant.transformToArray(visibleMerchant.getNodes())
bindEvent()
}
// 查询所有商户
function findAllMerchant(callback) {
var params = { method: 'cn.com.glsx.merchants.menu.findAllMerchant' }
request(params, function (result) {
if (result.code == '0') {
console.log(result.data)
merchantNameSelect.update({
data: result.data,
autoRow: true,
paging: result.data.length > 20
})
// merchantNameSelect.setValue([merchantId])
// var list = result.data
// list.unshift('')
// $.each(list, function (index, item) {
// merchantName.append(new Option(item.merchantName, item.id))
// })
// form.render('select')
callback(true)
}
})
}
// 查询所有商户
function findAllMerchant(callback) {
var params = { method: 'cn.com.glsx.merchants.menu.findAllMerchant' }
request(params, function (result) {
if (result.code == '0') {
console.log(result.data)
merchantNameSelect.update({
data: result.data,
autoRow: true,
paging: result.data.length > 20
})
// merchantNameSelect.setValue([merchantId])
// var list = result.data
// list.unshift('')
// $.each(list, function (index, item) {
// merchantName.append(new Option(item.merchantName, item.id))
// })
// form.render('select')
callback(true)
}
})
}
// 查询角色权限列表
function findRoleList(merchantId) {
var params = { method: 'org.ore.api.role.list', id: merchantId, delFlag: 0 }
request(params, function (res) {
if (res.code == '0') {
var list = res.data
roleAuth.empty()
list.unshift('')
$.each(list, function (index, item) {
roleAuth.append(new Option(item.roleName, item.id))
})
form.render('select')
// 查询角色权限列表
function findRoleList(merchantId) {
var params = { method: 'org.ore.api.role.list', id: merchantId, delFlag: 0 }
request(params, function (res) {
if (res.code == '0') {
var list = res.data
roleAuth.empty()
list.unshift('')
$.each(list, function (index, item) {
roleAuth.append(new Option(item.roleName, item.id))
})
form.render('select')
}
})
}
function getById(callback) {
// 查询员工详情
var params = { id: id, method: 'cn.com.glsx.merchants.staff.staffSearchRequest' }
pwd.attr('readonly', true)
request(params, function (res) {
console.log(res)
if (res.code == '0') {
var data = res.data
employeeForm = {
id: 8,
merchantId: data.merchantId,
staffName: data.staffName,
staffPhone: data.staffPhone,
password: data.password,
// visibleInferiorMer: "1",
roleIds: data.roleIds ? +data.roleIds.join('') : '',
staffEmail: data.staffEmail,
staffJob: data.staffJob
}
})
}
if (data.merchantFileResponse) {
merchantFileRequest = { fileName: data.merchantFileResponse.fileName, fileUrl: data.merchantFileResponse.fileUrl }
$('#img').attr('src', merchantFileRequest.fileUrl)
$('#img').removeClass('hide')
$('#img').addClass('show')
$('.img-add').removeClass('show')
$('.img-add').addClass('hide')
}
var visibleInferiorMerArr = data.visibleInferiorMer ? data.visibleInferiorMer.split(',') : []
$.each(visibleInferiorMerArr, function (index, item) {
visibleInferiorMerArr[index] = +item
})
// var visibleInferiorMerArr = [32, 38]
callback(visibleInferiorMerArr)
}
console.log(employeeForm, merchantFileRequest)
form.val('employeeForm', employeeForm)
form.render('select')
})
}
function getById(callback) {
// 查询员工详情
var params = { id: id, method: 'cn.com.glsx.merchants.staff.staffSearchRequest' }
pwd.attr('readonly', true)
request(params, function (res) {
console.log(res)
if (res.code == '0') {
var data = res.data
employeeForm = {
id: 8,
merchantId: data.merchantId,
staffName: data.staffName,
staffPhone: data.staffPhone,
password: data.password,
// visibleInferiorMer: "1",
roleIds: data.roleIds ? +data.roleIds.join('') : '',
staffEmail: data.staffEmail,
staffJob: data.staffJob
}
if (data.merchantFileResponse) {
merchantFileRequest = { fileName: data.merchantFileResponse.fileName, fileUrl: data.merchantFileResponse.fileUrl }
$('#img').attr('src', merchantFileRequest.fileUrl)
$('#img').removeClass('hide')
$('#img').addClass('show')
$('.img-add').removeClass('show')
$('.img-add').addClass('hide')
}
var visibleInferiorMerArr = data.visibleInferiorMer ? data.visibleInferiorMer.split(',') : []
$.each(visibleInferiorMerArr, function (index, item) {
visibleInferiorMerArr[index] = +item
})
// var visibleInferiorMerArr = [32, 38]
callback(visibleInferiorMerArr)
function bindEvent() {
$('#searchMerchant').on(
'input',
helper.debounce(function () {
var txt = $(this).val()
if (!txt) {
visibleMerchant.showNodes(all_nodes)
} else {
var nodesList = visibleMerchant.getNodesByParamFuzzy('label', txt)
show_nodes = helper.findShowNode(nodesList, all_nodes)
visibleMerchant.hideNodes(all_nodes)
visibleMerchant.showNodes(show_nodes)
}
console.log(employeeForm, merchantFileRequest)
form.val('employeeForm', employeeForm)
form.render('select')
})
}
}, 500)
)
}
})
</script>
</body>
function bindEvent() {
$('#searchMerchant').on(
'input',
helper.debounce(function () {
var txt = $(this).val()
if (!txt) {
visibleMerchant.showNodes(all_nodes)
} else {
var nodesList = visibleMerchant.getNodesByParamFuzzy('label', txt)
show_nodes = helper.findShowNode(nodesList, all_nodes)
visibleMerchant.hideNodes(all_nodes)
visibleMerchant.showNodes(show_nodes)
}
}, 500)
)
}
})
</script>
</body>
</html>
</html>
\ No newline at end of file
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8" />
<meta content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="广联帐户管理中心-员工管理" />
<meta name="author" content="GLSX Web Team" />
<meta name="keywords" itemprop="keywords" content="广联,帐户管理,员工管理" />
<link rel="stylesheet" type="text/css" href="/css/main.css" />
<style>
.h20 {
height: 20px;
}
.mb5 {
margin-bottom: 5px;
}
.merchant .layui-table {
margin: 0;
width: 100%;
}
.merchant #searchForm .layui-inline {
margin-bottom: 5px;
vertical-align: top;
}
<head>
<meta charset="utf-8" />
<meta content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="广联帐户管理中心-员工管理" />
<meta name="author" content="GLSX Web Team" />
<meta name="keywords" itemprop="keywords" content="广联,帐户管理,员工管理" />
<link rel="stylesheet" type="text/css" href="/css/main.css" />
<style>
.h20 {
height: 20px;
}
.layui-btn-xs {
cursor: pointer;
}
.layui-form-label {
width: 130px;
}
.mb5 {
margin-bottom: 5px;
}
.accountLevel,
.customerState,
.accountType,
.mode {
margin-left: 30px;
}
.input-before-name {
width: 80px;
text-align: right;
display: inline-block;
}
.commonInput {
width: 260px;
}
.merchant .layui-table {
margin: 0;
width: 100%;
}
#relevancyBtn {
display: flex;
align-items: center;
}
.relevancyImg {
width: 20px;
height: 20px;
margin-right: 5px;
}
.hide {
display: none;
}
.show {
display: inline-block;
}
.merchantTable .layui-table-cell {
/* height: auto; */
/* line-height: 88px; */
white-space: normal;
overflow: hidden;
-webkit-line-clamp: 4;
-webkit-box-orient: vertical;
display: -webkit-box;
word-break: break-all;
}
</style>
<title>商户管理</title>
</head>
<body>
<div class="merchant" id="app">
<main>
<div class="context-block">
<div class="search-block">
<div class="h20"></div>
<form class="layui-form" lay-filter="searchFilter" id="searchForm">
<div class="layui-inline hide" id="operateEl">
<button class="layui-btn mb5 createBtn" id="addBtn">
<i class="layui-icon layui-icon-addition"></i>
<span>创建商户</span>
</button>
</div>
<!-- <div class="hide"> -->
<div id="relevancyEl" class="layui-inline hide">
<button class="layui-btn mb5" id="relevancyBtn">
<img class="relevancyImg" src="../../css/img/relevancy.png" alt="" />
<!-- <i class="layui-icon layui-icon-addition"></i> -->
门店账户关联企微
</button>
.merchant #searchForm .layui-inline {
margin-bottom: 5px;
vertical-align: top;
}
.layui-btn-xs {
cursor: pointer;
}
.layui-form-label {
width: 130px;
}
.accountLevel,
.customerState,
.accountType,
.mode {
margin-left: 30px;
}
.input-before-name {
width: 80px;
text-align: right;
display: inline-block;
}
.commonInput {
width: 260px;
}
#relevancyBtn {
display: flex;
align-items: center;
}
.relevancyImg {
width: 20px;
height: 20px;
margin-right: 5px;
}
.hide {
display: none;
}
.show {
display: inline-block;
}
.merchantTable .layui-table-cell {
/* height: auto; */
/* line-height: 88px; */
white-space: normal;
overflow: hidden;
-webkit-line-clamp: 4;
-webkit-box-orient: vertical;
display: -webkit-box;
word-break: break-all;
}
</style>
<title>商户管理</title>
</head>
<body>
<div class="merchant" id="app">
<main>
<div class="context-block">
<div class="search-block">
<div class="h20"></div>
<form class="layui-form" lay-filter="searchFilter" id="searchForm">
<div class="layui-inline hide" id="operateEl">
<button class="layui-btn mb5 createBtn" id="addBtn">
<i class="layui-icon layui-icon-addition"></i>
<span>创建商户</span>
</button>
</div>
<!-- <div class="hide"> -->
<div id="relevancyEl" class="layui-inline hide">
<button class="layui-btn mb5" id="relevancyBtn">
<img class="relevancyImg" src="../../css/img/relevancy.png" alt="" />
门店账户关联企微
</button>
</div>
<div id="relevancySearch" class="layui-inline">
<div class="layui-inline channel">
<label class="layui-form-label">是否已关联企微:</label>
<div class="layui-input-inline">
<select name="isRelevance">
<option value="0">全部</option>
<option value="1">已关联</option>
<option value="2">未关联</option>
</select>
</div>
</div>
<div id="relevancySearch" class="layui-inline">
<div class="layui-inline channel">
<label class="layui-form-label">是否已关联企微:</label>
<div class="layui-input-inline">
<select name="isRelevance">
<option value="0">全部</option>
<option value="1">已关联</option>
<option value="2">未关联</option>
</div>
<!-- </div> -->
<div class="layui-inline singleRow">
<div id="channelBox" class="hide" style="display: inline-block">
<div class="layui-inline">
<label class="input-before-name">渠道:</label>
<div class="layui-input-inline" style="width: 200px">
<select name="channelId" id="channelIdEl">
<option value="">全部</option>
</select>
</div>
</div>
</div>
<!-- </div> -->
<div class="layui-inline singleRow">
<div id="channelBox" class="hide" style="display: inline-block">
<div class="layui-inline">
<label class="input-before-name">渠道:</label>
<div class="layui-input-inline" style="width: 200px">
<select name="channelId" id="channelIdEl">
<option value="">全部</option>
</select>
</div>
</div>
<div class="layui-inline accountLevel">
<label class="input-before-name">账户等级:</label>
<div class="layui-input-inline commonInput">
<select name="merchantAccountLevel" id="accountLevelEl">
<option value="">全部</option>
</select>
</div>
</div>
<div class="layui-inline customerState">
<label class="input-before-name">账户状态:</label>
<div class="layui-input-inline commonInput">
<select name="status" id="searchStatusEl">
<option value="">全部</option>
</select>
</div>
</div>
</div>
<div class="singleRow">
<div class="layui-inline loginName">
<div class="layui-input-inline updateSelectAngle" style="width: 120px">
<select name="accountOrPhone" lay-filter="nameFilter">
<option value="0">登录账号名</option>
<option value="1">手机号</option>
</select>
</div>
<div class="layui-inline accountLevel">
<label class="input-before-name">账户等级:</label>
<!-- margin-left: -5px -->
<div class="layui-input-inline" style="width: 286px; margin-left: -4px">
<input class="layui-input" type="text" placeholder="请输入" name="merchantLoginAccount"
id="updateCircleAngle"
onkeydown="if (event.keyCode == 13) {event.keyCode = 0;event.returnValue = false;}" />
</div>
</div>
<div id="model">
<div class="layui-inline accountType">
<label class="input-before-name">账户类型:</label>
<div class="layui-input-inline commonInput">
<select name="merchantAccountLevel" id="accountLevelEl">
<select name="accounttypeId" id="accountTypeIdEl">
<option value="">全部</option>
</select>
</div>
</div>
<div class="layui-inline customerState">
<label class="input-before-name">账户状态:</label>
<div class="layui-inline mode">
<label class="input-before-name">模式:</label>
<div class="layui-input-inline commonInput">
<select name="status" id="searchStatusEl">
<select name="merchantModel" id="searchModelEl">
<option value="">全部</option>
</select>
</div>
</div>
</div>
<div class="singleRow">
<div class="layui-inline loginName">
<div class="layui-input-inline updateSelectAngle" style="width: 120px">
<select name="accountOrPhone" lay-filter="nameFilter">
<option value="0">登录账号名</option>
<option value="1">手机号</option>
</select>
</div>
<!-- margin-left: -5px -->
<div class="layui-input-inline" style="width: 286px; margin-left: -4px">
<input class="layui-input" type="text" placeholder="请输入" name="merchantLoginAccount" id="updateCircleAngle" />
</div>
</div>
<div id="model">
<div class="layui-inline accountType">
<label class="input-before-name">账户类型:</label>
<div class="layui-input-inline commonInput">
<select name="accounttypeId" id="accountTypeIdEl">
<option value="">全部</option>
</select>
</div>
</div>
<div class="layui-inline mode">
<label class="input-before-name">模式:</label>
<div class="layui-input-inline commonInput">
<select name="merchantModel" id="searchModelEl">
<option value="">全部</option>
</select>
</div>
</div>
</div>
</div>
</div>
<div style="display: flex; justify-content: space-between">
<div class="layui-inline customerStatus">
<div class="layui-input-inline">
<input class="layui-input" type="text" style="width: 404px" name="merchantName" placeholder="请输入商户名称/关联的企业微信名" />
</div>
</div>
<div class="layui-inline searchInputBtn">
<button class="layui-btn" lay-submit lay-filter="searchSubmit">查询</button>
<div style="display: flex; justify-content: space-between">
<div class="layui-inline customerStatus">
<div class="layui-input-inline">
<input class="layui-input" type="text" style="width: 404px" name="merchantName"
placeholder="请输入商户名称/关联的企业微信名"
onkeydown="if (event.keyCode == 13) {event.keyCode = 0;event.returnValue = false;}" />
</div>
</div>
</form>
<div class="table-page merchantTable">
<table class="layui-table" id="merchantTable" lay-filter="merchant-table-filter"></table>
<div id="merchantPage" class="align-left"></div>
<div class="layui-inline searchInputBtn">
<button class="layui-btn" lay-submit lay-filter="searchSubmit">查询</button>
</div>
</div>
</form>
<div class="table-page merchantTable">
<table class="layui-table" id="merchantTable" lay-filter="merchant-table-filter"></table>
<div id="merchantPage" class="align-left"></div>
</div>
</div>
</main>
</div>
</div>
</main>
</div>
<script src="https://www.layuicdn.com/layui/layui.js"></script>
<script src="/js/load.js"></script>
<script src="https://www.layuicdn.com/layui/layui.js"></script>
<script src="/js/load.js"></script>
<script type="text/html" id="accountTypeTpl">
<script type="text/html" id="accountTypeTpl">
<ul>
{{# var accountTypes=d.accountTypeNames.split(",")}} {{# }} {{# if((d.accountTypeNames)){ }} {{# layui.each(accountTypes,function(index,item){ }}
<li><span>{{item}}</span></li>
......@@ -204,7 +217,7 @@
{{# } }}
</ul>
</script>
<script type="text/html" id="merchantBtns">
<script type="text/html" id="merchantBtns">
<div>
<a class="layui-btn-xs" lay-event="handleDetail">查看</a>
{{# if((d.btn.edit)){ }}
......@@ -222,643 +235,643 @@
{{# } }}
</div>
</script>
<script>
layui.use(['gtree', 'request', 'helper', 'table', 'laypage', 'layer'], function () {
var tree = layui.gtree
var request = layui.request
var table = layui.table
var laypage = layui.laypage
var form = layui.form
var $ = layui.$
var helper = layui.helper
var accountInfo = helper.store.get('accountInfo')
console.log('accountInfo', accountInfo)
window.isDxternal = accountInfo ? 1 : 2 // 1 SCRM, default 运营平台
var baseData = {
statusList: [],
channelList: [],
accountLevelList: [],
accountTypeList: [],
modelList: []
}
<script>
layui.use(['gtree', 'request', 'helper', 'table', 'laypage', 'layer'], function () {
var tree = layui.gtree
var request = layui.request
var table = layui.table
var laypage = layui.laypage
var form = layui.form
var $ = layui.$
var helper = layui.helper
var accountInfo = helper.store.get('accountInfo')
console.log('accountInfo', accountInfo)
window.isDxternal = accountInfo ? 1 : 2 // 1 SCRM, default 运营平台
var baseData = {
statusList: [],
channelList: [],
accountLevelList: [],
accountTypeList: [],
modelList: []
}
var page = {
pageNum: 1,
pageSize: 10
}
var pageOptions = {
elem: 'merchantPage',
groups: 5,
layout: ['count', 'page', 'skip'],
jump: function (obj, first) {
//obj包含了当前分页的所有参数,比如:
// console.log(obj.curr); //得到当前页,以便向服务端请求对应页的数据。
// console.log(obj.limit); //得到每页显示的条数
page.pageNum = obj.curr
page.pageSize = obj.limit
//首次不执行
if (!first) {
//do something
getTabelList()
}
var page = {
pageNum: 1,
pageSize: 10
}
var pageOptions = {
elem: 'merchantPage',
groups: 5,
layout: ['count', 'page', 'skip'],
jump: function (obj, first) {
//obj包含了当前分页的所有参数,比如:
// console.log(obj.curr); //得到当前页,以便向服务端请求对应页的数据。
// console.log(obj.limit); //得到每页显示的条数
page.pageNum = obj.curr
page.pageSize = obj.limit
//首次不执行
if (!first) {
//do something
getTabelList()
}
}
var cols = [
{
field: 'index',
title: '序号',
align: 'center',
width: 60
},
{
field: 'merchantNo',
title: '商户号',
align: 'center',
width: 100
},
{
field: 'merchantName',
title: '商户名称',
align: 'center',
width: 130
},
{
field: 'merchantModelName',
title: '模式',
align: 'center',
width: 130
},
{
field: 'accountTypeNames',
title: '账户类型',
align: 'left',
width: 140,
templet: '#accountTypeTpl'
},
{
field: 'merchantLoginAccount',
title: '登录账户',
align: 'center',
width: 108
},
{
field: 'accountLevelName',
title: '账户等级',
align: 'center',
width: 100
},
{
field: 'parentMerchant',
title: '上级商户',
align: 'center',
width: 120
},
{
field: 'statusName',
title: '账户状态',
align: 'center',
width: 100
},
{
field: 'merchantLegalPerson',
title: '联系人',
align: 'center',
width: 100
},
{
field: 'merchantLegalPersonPhone',
title: '手机号',
align: 'center',
width: 120
},
{
field: 'entmicroName',
title: '关联的企业微信',
align: 'center',
width: 130
// }, {
// field: 'merchantAddress',
// title: '商户地址',
// align: 'center',
// width: 160
},
{
field: 'updatedTime',
title: '更新时间',
align: 'center',
width: 90
},
{
align: 'left',
title: '操作',
toolbar: '#merchantBtns',
width: 230,
fixed: 'right'
// },
// {
// align: 'left',
// title: '账户开关',
// toolbar: '#vaildPeriod',
// width: 150,
// fixed: 'right'
}
]
var colums = [
{
field: 'index',
title: '序号',
align: 'center',
width: 60
},
{
field: 'merchantName',
title: '商户名称',
align: 'center'
// width: 150
},
{
field: 'entmicroName',
title: '关联的企业微信',
align: 'center',
width: 130
},
{
field: 'accountTypeNames',
title: '账户类型',
align: 'left',
width: 150,
templet: '#accountTypeTpl'
},
{
field: 'merchantLoginAccount',
title: '登录账户',
align: 'center',
width: 108
},
{
field: 'accountLevelName',
title: '账户等级',
align: 'center',
width: 100
},
{
field: 'parentMerchant',
title: '上级商户',
align: 'center',
width: 100
},
{
field: 'statusName',
title: '账户状态',
align: 'center',
width: 100
},
{
field: 'merchantLegalPerson',
title: '联系人',
align: 'center',
width: 100
},
{
field: 'merchantLegalPersonPhone',
title: '手机号',
align: 'center',
width: 120
},
{
field: 'updatedTime',
title: '更新时间',
align: 'center',
width: 90
},
{
align: 'left',
title: '操作',
toolbar: '#merchantBtns',
width: 150,
fixed: 'right'
}
]
var merchantTable = table.render({
elem: '#merchantTable',
page: false,
skin: 'nob',
height: 'full-300',
cols: window.isDxternal != 1 ? [cols] : [colums],
done: function () {
$("[data-field='lowerHairPath']").css('display', 'none')
$('.layui-table-main tr').each(function (index, val) {
$($('.layui-table-fixed-l .layui-table-body tbody tr')[index]).height($(val).height())
$($('.layui-table-fixed-r .layui-table-body tbody tr')[index]).height($(val).height())
})
//动态监听表头高度变化,冻结行跟着改变高度
$('.layui-table-header tr').resize(function () {
$('.layui-table-header tr').each(function (index, val) {
$($('.layui-table-fixed .layui-table-header table tr')[index]).height($(val).height())
})
})
//初始化高度,使得冻结行表头高度一致
}
var cols = [
{
field: 'index',
title: '序号',
align: 'center',
width: 60
},
{
field: 'merchantNo',
title: '商户号',
align: 'center',
width: 100
},
{
field: 'merchantName',
title: '商户名称',
align: 'center',
width: 130
},
{
field: 'merchantModelName',
title: '模式',
align: 'center',
width: 130
},
{
field: 'accountTypeNames',
title: '账户类型',
align: 'left',
width: 140,
templet: '#accountTypeTpl'
},
{
field: 'merchantLoginAccount',
title: '登录账户',
align: 'center',
width: 108
},
{
field: 'accountLevelName',
title: '账户等级',
align: 'center',
width: 100
},
{
field: 'parentMerchant',
title: '上级商户',
align: 'center',
width: 120
},
{
field: 'statusName',
title: '账户状态',
align: 'center',
width: 100
},
{
field: 'merchantLegalPerson',
title: '联系人',
align: 'center',
width: 100
},
{
field: 'merchantLegalPersonPhone',
title: '手机号',
align: 'center',
width: 120
},
{
field: 'entmicroName',
title: '关联的企业微信',
align: 'center',
width: 130
// }, {
// field: 'merchantAddress',
// title: '商户地址',
// align: 'center',
// width: 160
},
{
field: 'updatedTime',
title: '更新时间',
align: 'center',
width: 90
},
{
align: 'left',
title: '操作',
toolbar: '#merchantBtns',
width: 230,
fixed: 'right'
// },
// {
// align: 'left',
// title: '账户开关',
// toolbar: '#vaildPeriod',
// width: 150,
// fixed: 'right'
}
]
var colums = [
{
field: 'index',
title: '序号',
align: 'center',
width: 60
},
{
field: 'merchantName',
title: '商户名称',
align: 'center',
width: 150
},
{
field: 'entmicroName',
title: '关联的企业微信',
align: 'center',
width: 130
},
{
field: 'accountTypeNames',
title: '账户类型',
align: 'center',
width: 150,
templet: '#accountTypeTpl'
},
{
field: 'merchantLoginAccount',
title: '登录账户',
align: 'center',
width: 108
},
{
field: 'accountLevelName',
title: '账户等级',
align: 'center',
width: 100
},
{
field: 'parentMerchant',
title: '上级商户',
align: 'center',
width: 100
},
{
field: 'statusName',
title: '账户状态',
align: 'center',
width: 100
},
{
field: 'merchantLegalPerson',
title: '联系人',
align: 'center',
width: 100
},
{
field: 'merchantLegalPersonPhone',
title: '手机号',
align: 'center',
width: 120
},
{
field: 'updatedTime',
title: '更新时间',
align: 'center',
width: 90
},
{
align: 'left',
title: '操作',
toolbar: '#merchantBtns',
width: 150,
fixed: 'right'
}
]
var merchantTable = table.render({
elem: '#merchantTable',
page: false,
skin: 'nob',
height: 'full-300',
cols: window.isDxternal != 1 ? [cols] : [colums],
done: function () {
$("[data-field='lowerHairPath']").css('display', 'none')
$('.layui-table-main tr').each(function (index, val) {
$($('.layui-table-fixed-l .layui-table-body tbody tr')[index]).height($(val).height())
$($('.layui-table-fixed-r .layui-table-body tbody tr')[index]).height($(val).height())
})
//动态监听表头高度变化,冻结行跟着改变高度
$('.layui-table-header tr').resize(function () {
$('.layui-table-header tr').each(function (index, val) {
$($('.layui-table-fixed .layui-table-header table tr')[index]).height($(val).height())
})
//动态监听表体高度变化,冻结行跟着改变高度
$('.layui-table-body tr').resize(function () {
$('.layui-table-body tr').each(function (index, val) {
$($('.layui-table-fixed .layui-table-body table tr')[index]).height($(val).height())
})
})
//初始化高度,使得冻结行表体高度一致
})
//初始化高度,使得冻结行表头高度一致
$('.layui-table-header tr').each(function (index, val) {
$($('.layui-table-fixed .layui-table-header table tr')[index]).height($(val).height())
})
//动态监听表体高度变化,冻结行跟着改变高度
$('.layui-table-body tr').resize(function () {
$('.layui-table-body tr').each(function (index, val) {
$($('.layui-table-fixed .layui-table-body table tr')[index]).height($(val).height())
})
}
})
})
//初始化高度,使得冻结行表体高度一致
$('.layui-table-body tr').each(function (index, val) {
$($('.layui-table-fixed .layui-table-body table tr')[index]).height($(val).height())
})
}
})
table.on('tool(merchant-table-filter)', function (obj) {
var eventName = obj.event
var row = obj.data
console.log(row)
switch (eventName) {
// 查看
case 'handleDetail':
go('merchant', 'detail', {
merchantId: row.id
})
break
// 修改
case 'handleEdit':
// editLevel - 1-创建新商户;2-创建子商户;3-修改
// step - 1-基本信息;2-权限树
// merchantAccountLevel 账户等级(1-工厂;2-省代;3-市代;4-门店)
go('merchant', 'edit', {
editLevel: 3,
id: row.id,
parentId: row.parentId,
isFactory: row.merchantAccountLevel == 1,
step: 1,
model: row.merchantModel,
status: row.status,
merchantAccountLevel: row.merchantAccountLevel
})
break
case 'handleAuthority':
// editLevel - 1-创建新商户;2-创建子商户;3-修改
// step - 1-基本信息;2-权限树
// merchantAccountLevel 账户等级
go('merchant', 'edit', {
editLevel: 3,
id: row.id,
parentId: row.parentId,
isFactory: row.merchantAccountLevel == 1,
id: row.id,
step: 2
})
break
// 创建子商户/门店
case 'handleAddMerchant':
// 1-创建新商户;2-创建子商户;3-修改
go('merchant', 'addSubMerchant', {
editLevel: 2,
parentId: row.id,
isFactory: 'false',
step: 1,
merchantAccountLevel: row.merchantAccountLevel
})
break
// 创建员工
case 'handleAddStaff':
go('employee', 'add', {
merchantId: row.id,
merchantName: row.merchantName,
channel: 'merchant'
})
break
// 修改账户有效期
case 'handleVaildPeriod':
// console.log(row)
var area = ['560px', '230px']
if (row.merchantAccountLevel == 4) {
area = ['750px', '450px']
}
layer.open({
type: 2,
title: '',
closeBtn: 0,
area: area,
fixed: false, //不固定
// maxmin: true,
btn: ['确定', '取消'],
content:
'validPeriodForm.html?id=' +
row.id +
'&effectiveStarttime=' +
row.effectiveStarttime +
'&expireDate=' +
row.expireDate +
'&status=' +
row.status +
'&merchantAccountLevel=' +
row.merchantAccountLevel,
yes: function (index, layero) {
var body = layer.getChildFrame('body', index)
helper.store.set('isRefresh', false)
body.find('#periodVerifyBtn').click()
},
end: function () {
var isRefresh = helper.store.get('isRefresh')
if (isRefresh) {
getTabelList()
layer.msg('修改成功', {
icon: 1
})
}
helper.store.remove('isRefresh')
table.on('tool(merchant-table-filter)', function (obj) {
var eventName = obj.event
var row = obj.data
console.log(row.merchantAccountLevel)
switch (eventName) {
// 查看
case 'handleDetail':
go('merchant', 'detail', {
merchantId: row.id
})
break
// 修改
case 'handleEdit':
// editLevel - 1-创建新商户;2-创建子商户;3-修改
// step - 1-基本信息;2-权限树
// merchantAccountLevel 账户等级(1-工厂;2-省代;3-市代;4-门店)
go('merchant', 'edit', {
editLevel: 3,
id: row.id,
parentId: row.parentId,
isFactory: row.merchantAccountLevel == 1,
step: 1,
model: row.merchantModel,
status: row.status,
merchantAccountLevel: row.merchantAccountLevel
})
break
case 'handleAuthority':
// editLevel - 1-创建新商户;2-创建子商户;3-修改
// step - 1-基本信息;2-权限树
// merchantAccountLevel 账户等级
go('merchant', 'edit', {
editLevel: 3,
id: row.id,
parentId: row.parentId,
isFactory: row.merchantAccountLevel == 1,
id: row.id,
step: 2
})
break
// 创建子商户/门店
case 'handleAddMerchant':
// 1-创建新商户;2-创建子商户;3-修改
go('merchant', 'addSubMerchant', {
editLevel: 2,
parentId: row.id,
isFactory: 'false',
step: 1,
merchantAccountLevel: row.merchantAccountLevel
})
break
// 创建员工
case 'handleAddStaff':
go('employee', 'add', {
merchantId: row.id,
merchantName: row.merchantName,
channel: 'merchant'
})
break
// 修改账户有效期
case 'handleVaildPeriod':
// console.log(row)
var area = ['560px', '230px']
if (row.merchantAccountLevel == 4) {
area = ['750px', '450px']
}
layer.open({
type: 2,
title: '',
closeBtn: 0,
area: area,
fixed: false, //不固定
// maxmin: true,
btn: ['确定', '取消'],
content:
'validPeriodForm.html?id=' +
row.id +
'&effectiveStarttime=' +
row.effectiveStarttime +
'&expireDate=' +
row.expireDate +
'&status=' +
row.status +
'&merchantAccountLevel=' +
row.merchantAccountLevel,
yes: function (index, layero) {
var body = layer.getChildFrame('body', index)
helper.store.set('isRefresh', false)
body.find('#periodVerifyBtn').click()
},
end: function () {
var isRefresh = helper.store.get('isRefresh')
if (isRefresh) {
getTabelList()
layer.msg('修改成功', {
icon: 1
})
}
})
break
}
})
init()
document.onkeypress = function(e) {
e.preventDefault()
helper.store.remove('isRefresh')
}
})
break
}
$('#addBtn').on('click', function () {
// 1-创建新商户;2-创建子商户;3-修改
go('merchant', 'add', {
editLevel: 1,
step: 1,
isFactory: 'true'
})
return false
})
})
$('#relevancyBtn').on('click', function () {
$messenger.emit('route-to', { path: '/settings/baseInfo/relevance' })
})
// 搜索绑定事件
form.on('submit(searchSubmit)', function () {
getTabelList(true)
return false
init()
$('#addBtn').on('click', function (e) {
// 1-创建新商户;2-创建子商户;3-修改
// e.target.blur()
go('merchant', 'add', {
editLevel: 1,
step: 1,
isFactory: 'true'
})
return false
})
// 查询
function handleSearch() {
getTabelList(true)
}
$('#relevancyBtn').on('click', function () {
$messenger.emit('route-to', { path: '/settings/baseInfo/relevance' })
})
// 搜索绑定事件
form.on('submit(searchSubmit)', function () {
getTabelList(true)
return false
})
// 查询
function handleSearch() {
getTabelList(true)
}
// 获取表格数据
function getTabelList(isResetPageNum) {
var params = {
pageNum: page.pageNum,
pageSize: page.pageSize,
method: 'cn.com.glsx.merchants.menu.findMerchantByPage'
// 获取表格数据
function getTabelList(isResetPageNum) {
var params = {
pageNum: page.pageNum,
pageSize: page.pageSize,
method: 'cn.com.glsx.merchants.menu.findMerchantByPage'
}
var searchData = $('#searchForm [name]').serializeArray()
// console.log(searchData)
$.each(searchData, function () {
if (this.name == 'merchantLoginAccount') {
var attrName = params.accountOrPhone == '0' ? 'merchantLoginAccount' : 'merchantLegalPersonPhone'
params[attrName] = this.value
} else {
params[this.name] = this.value
}
var searchData = $('#searchForm [name]').serializeArray()
// console.log(searchData)
$.each(searchData, function () {
if (this.name == 'merchantLoginAccount') {
var attrName = params.accountOrPhone == '0' ? 'merchantLoginAccount' : 'merchantLegalPersonPhone'
params[attrName] = this.value
} else {
params[this.name] = this.value
})
// console.log(params)
request(params, function (res) {
var data = helper.formateNullFieldData(res.data)
$.each(data.data, function (index, item) {
item.index = index + 1 + page.pageSize * (page.pageNum - 1)
item.btn = {
edit: false,
createSubMerchant: false,
createStaff: false,
editPeriod: false
}
})
// console.log(params)
request(params, function (res) {
var data = helper.formateNullFieldData(res.data)
$.each(data.data, function (index, item) {
item.index = index + 1 + page.pageSize * (page.pageNum - 1)
item.btn = {
edit: false,
createSubMerchant: false,
createStaff: false,
editPeriod: false
}
/** btn
* check - 查看(无需判断,均有)
* edit - 修改
* createSubMerchant - 创建子商户/门店
* createStaff - 创建员工
* editPeriod - 修改账户有效期
* **/
// status(账户状态 - 列表):1-草稿;2-正常;3-注销;4-过期
// merchantAccountLevel(账户等级 - 列表):1-工厂;2-省代;3-市代;4-门店
// 外部系统
switch (window.isDxternal) {
case 1:
if (item.status == 2) {
// 本身
if (item.merchantNo == accountInfo.merchantId) {
item.btn.createStaff = true
if (item.merchantAccountLevel != 4) {
item.btn.createSubMerchant = true
}
} else {
// 下级商户
// console.log(item)
item.btn.edit = true
item.btn.editPeriod = true
// 直属门店
if (item.merchantAccountLevel == 4) {
if (item.parentId == accountInfo.merchantId) {
item.btn.createStaff = true
}
} else {
item.btn.createSubMerchant = true
}
}
} else if (item.status != 3) {
item.btn.edit = true
if (item.status == 4) {
item.btn.editPeriod = true
}
}
break
default:
// 超管登录
if (item.status != 3) {
item.btn.edit = true
}
if (item.status == 2) {
/** btn
* check - 查看(无需判断,均有)
* edit - 修改
* createSubMerchant - 创建子商户/门店
* createStaff - 创建员工
* editPeriod - 修改账户有效期
* **/
// status(账户状态 - 列表):1-草稿;2-正常;3-注销;4-过期
// merchantAccountLevel(账户等级 - 列表):1-工厂;2-省代;3-市代;4-门店
// 外部系统
switch (window.isDxternal) {
case 1:
if (item.status == 2) {
// 本身
if (item.merchantNo == accountInfo.merchantId) {
item.btn.createStaff = true
if (item.merchantAccountLevel != 4) {
item.btn.createSubMerchant = true
}
} else {
// 下级商户
// console.log(item)
item.btn.edit = true
item.btn.editPeriod = true
// 直属门店
if (item.merchantAccountLevel == 4) {
if (item.parentId == accountInfo.merchantId) {
item.btn.createStaff = true
}
} else {
item.btn.createSubMerchant = true
}
}
if (item.status != 1) {
} else if (item.status != 3) {
item.btn.edit = true
if (item.status == 4) {
item.btn.editPeriod = true
}
}
// if (isDxternal) {
// // 状态 - 正常
// if (item.status == 2) {
// // 本身
// if (item.id == user.merchantId) {
// item.btn.createStaff = true
// if (item.merchantAccountLevel != 4) {
// item.btn.createSubMerchant = true
// }
// } else {
// // 下级商户
// // console.log(item)
// item.btn.edit = true
// item.btn.editPeriod = true
// // 直属门店
// if (item.merchantAccountLevel == 4) {
// if (item.parentId == user.merchantId) {
// item.btn.createStaff = true
// }
// } else {
// item.btn.createSubMerchant = true
// }
// }
// } else if (item.status != 3) {
// item.btn.edit = true
// if (item.status == 4) {
// item.btn.editPeriod = true
// }
// }
// } else {
// // 超管登录
// if (item.status != 3) {
// item.btn.edit = true
// }
// if (item.status == 2) {
// item.btn.createStaff = true
// if (item.merchantAccountLevel != 4) {
// item.btn.createSubMerchant = true
// }
// }
// if (item.status != 1) {
// item.btn.editPeriod = true
// }
// }
})
var options = {
data: data.data
}
pageOptions.count = data.count
if (isResetPageNum) {
pageOptions.curr = 1
}
break
default:
// 超管登录
if (item.status != 3) {
item.btn.edit = true
}
if (item.status == 2) {
item.btn.createStaff = true
if (item.merchantAccountLevel != 4) {
item.btn.createSubMerchant = true
}
}
if (item.status != 1) {
item.btn.editPeriod = true
}
}
laypage.render(pageOptions)
merchantTable.reload(options)
// if (isDxternal) {
// // 状态 - 正常
// if (item.status == 2) {
// // 本身
// if (item.id == user.merchantId) {
// item.btn.createStaff = true
// if (item.merchantAccountLevel != 4) {
// item.btn.createSubMerchant = true
// }
// } else {
// // 下级商户
// // console.log(item)
// item.btn.edit = true
// item.btn.editPeriod = true
// // 直属门店
// if (item.merchantAccountLevel == 4) {
// if (item.parentId == user.merchantId) {
// item.btn.createStaff = true
// }
// } else {
// item.btn.createSubMerchant = true
// }
// }
// } else if (item.status != 3) {
// item.btn.edit = true
// if (item.status == 4) {
// item.btn.editPeriod = true
// }
// }
// } else {
// // 超管登录
// if (item.status != 3) {
// item.btn.edit = true
// }
// if (item.status == 2) {
// item.btn.createStaff = true
// if (item.merchantAccountLevel != 4) {
// item.btn.createSubMerchant = true
// }
// }
// if (item.status != 1) {
// item.btn.editPeriod = true
// }
// }
})
}
var options = {
data: data.data
}
pageOptions.count = data.count
if (isResetPageNum) {
pageOptions.curr = 1
}
laypage.render(pageOptions)
merchantTable.reload(options)
})
}
// 获取字典数据
function getDictData(dictType, fn) {
request(
{
method: 'cn.com.glsx.merchants.menu.findAllDictData',
dictType: dictType
},
function (res) {
fn && fn(res)
}
)
}
// 获取字典数据
function getDictData(dictType, fn) {
request(
{
method: 'cn.com.glsx.merchants.menu.findAllDictData',
dictType: dictType
},
function (res) {
fn && fn(res)
}
)
}
// 设置option
function setSelectOption(elName, listName, optionId, optionLabel) {
var el = $(elName)
$.each(baseData[listName], function (index, item) {
el.append(new Option(item[optionLabel], item[optionId]))
})
form.render('select')
}
// 设置option
function setSelectOption(elName, listName, optionId, optionLabel) {
var el = $(elName)
$.each(baseData[listName], function (index, item) {
el.append(new Option(item[optionLabel], item[optionId]))
})
form.render('select')
}
// 获取有效期
function getVaildPeriod() {
getDictData('merchant_status', function (res) {
baseData.statusList = res.data
setSelectOption('#searchStatusEl', 'statusList', 'dictValue', 'dictLabel')
})
}
// 获取有效期
function getVaildPeriod() {
getDictData('merchant_status', function (res) {
baseData.statusList = res.data
setSelectOption('#searchStatusEl', 'statusList', 'dictValue', 'dictLabel')
})
}
// 获取渠道
function getChannel() {
getDictData('channel', function (res) {
baseData.channelList = res.data
setSelectOption('#channelIdEl', 'channelList', 'dictValue', 'dictLabel')
})
}
// 获取渠道
function getChannel() {
getDictData('channel', function (res) {
baseData.channelList = res.data
setSelectOption('#channelIdEl', 'channelList', 'dictValue', 'dictLabel')
})
}
// 获取账户等级
function getAccountLevel() {
getDictData('account_level', function (res) {
baseData.accountLevelList = res.data
setSelectOption('#accountLevelEl', 'accountLevelList', 'dictValue', 'dictLabel')
})
}
// 获取账户等级
function getAccountLevel() {
getDictData('account_level', function (res) {
baseData.accountLevelList = res.data
setSelectOption('#accountLevelEl', 'accountLevelList', 'dictValue', 'dictLabel')
})
}
// 获取账户类型
function getAccountType() {
getDictData('account_type', function (res) {
baseData.accountTypeList = res.data
setSelectOption('#accountTypeIdEl', 'accountTypeList', 'dictValue', 'dictLabel')
})
}
// 获取账户类型
function getAccountType() {
getDictData('account_type', function (res) {
baseData.accountTypeList = res.data
setSelectOption('#accountTypeIdEl', 'accountTypeList', 'dictValue', 'dictLabel')
})
}
// 获取模式
function getModel() {
getDictData('merchant_model', function (res) {
baseData.modelList = res.data
setSelectOption('#searchModelEl', 'modelList', 'dictValue', 'dictLabel')
})
}
// 获取模式
function getModel() {
getDictData('merchant_model', function (res) {
baseData.modelList = res.data
setSelectOption('#searchModelEl', 'modelList', 'dictValue', 'dictLabel')
})
}
// SCRM系统 搜索加按钮
function glBtn() {
$('#operateEl').remove()
$('#channelBox').remove()
if (accountInfo.model == 1 && accountInfo.merchantAccountLevel == 1) {
$('#relevancyEl').removeClass('hide')
$('#relevancyEl').addClass('show')
}
$('#relevancySearch').addClass('show')
$('#model').remove()
// SCRM系统 搜索加按钮
function glBtn() {
$('#operateEl').remove()
$('#channelBox').remove()
if (accountInfo.model == 1 && accountInfo.merchantAccountLevel == 1) {
$('#relevancyEl').removeClass('hide')
$('#relevancyEl').addClass('show')
}
$('#relevancySearch').addClass('show')
$('#model').remove()
}
// gl功能点
function scrmBtn() {
// $('#channelBox').remove()
$('#operateEl').addClass('show')
$('#channelBox').addClass('show')
// $('#relevancyEl').remove()
$('#relevancySearch').remove()
$('#model').addClass('show')
}
// gl功能点
function scrmBtn() {
// $('#channelBox').remove()
$('#operateEl').addClass('show')
$('#channelBox').addClass('show')
// $('#relevancyEl').remove()
$('#relevancySearch').remove()
$('#model').addClass('show')
}
// 运营平台
function init() {
switch (window.isDxternal) {
// scrm 系统
case 1:
glBtn()
break
// 广联运营系统
default:
getChannel()
getModel()
scrmBtn()
}
// if (!isDxternal) {
// getChannel()
// getAccountLevel()
// getAccountType()
// getModel()
// } else {
// elRemove()
// }
getAccountLevel()
getAccountType()
getVaildPeriod()
getTabelList()
// 运营平台
function init() {
switch (window.isDxternal) {
// scrm 系统
case 1:
glBtn()
break
// 广联运营系统
default:
getChannel()
getModel()
scrmBtn()
}
})
</script>
</body>
</html>
// if (!isDxternal) {
// getChannel()
// getAccountLevel()
// getAccountType()
// getModel()
// } else {
// elRemove()
// }
getAccountLevel()
getAccountType()
getVaildPeriod()
getTabelList()
}
})
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8" />
<meta content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="广联帐户管理中心-员工管理" />
<meta name="author" content="GLSX Web Team" />
<meta name="keywords" itemprop="keywords" content="广联,帐户管理,员工管理" />
<link rel="stylesheet" type="text/css" href="/css/main.css" />
<title>角色管理</title>
<style>
.Wrap {
margin: 8px 0 0;
padding-bottom: 100px;
}
.show {
display: inline-block;
width: 360px;
}
.hide {
display: none;
}
.tabmutiple-content-wrap {
background-color: #f4f6fc;
/* padding-top: 10px; */
/* padding-bottom: 1px; */
}
<head>
<meta charset="utf-8" />
<meta content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="广联帐户管理中心-员工管理" />
<meta name="author" content="GLSX Web Team" />
<meta name="keywords" itemprop="keywords" content="广联,帐户管理,员工管理" />
<link rel="stylesheet" type="text/css" href="/css/main.css" />
<title>角色管理</title>
<style>
.Wrap {
margin: 8px 0 0;
padding-bottom: 100px;
}
.tabmutiple-content {
/* margin: 0 10px; */
background-color: #fff;
}
.contentGrayBg {
/* background-color: #fff; */
/* border: 2px solid red; */
}
.layui-tab-title {
background-color: #f4f6fc;
box-sizing: border-box;
}
.contentGrayBg .layui-this {
background-color: #fff;
border: 2px solid #fff;
margin-left: -3px;
}
.contentGrayBg .layui-tab {
border: 10px solid #f4f6fc;
}
.edit-box {
padding: 0 20px 20px;
color: #333333;
background-color: #ffffff;
margin: 15px auto;
position: relative;
/* height: 100%; */
}
.edit-box .grayLine {
position: absolute;
left: 0;
top: 48px;
background-color: #d8d8d8;
width: 100%;
height: 1px;
}
.edit-title {
height: 78px;
line-height: 78px;
padding: 0 20px;
margin-bottom: 15px;
font-size: 16px;
font-weight: 700;
color: #333333;
background-color: #fff;
}
.baseInfo {
height: 48px;
line-height: 48px;
font-size: 16px;
color: #333333;
font-weight: 600;
}
.show {
display: inline-block;
width: 360px;
}
#roleTitle {
font-size: 20px;
color: #333333;
font-weight: bold;
}
.hide {
display: none;
}
.layui-tab-content {
position: relative;
}
.layui-no-data {
width: 100%;
height: 500px;
}
.layui-no-data .no-data {
position: absolute;
top: 50%;
height: 50%;
width: 100%;
text-align: center;
font-size: 14px;
line-height: 22px;
}
.layui-no-data .no-data div {
margin-top: 12px;
}
.xm-select-demo,
xm-select > .xm-body .scroll-body {
width: 360px;
}
</style>
</head>
<body>
<div id="app">
<main>
<div class="Wrap">
<div class="layui-form-item edit-title" style="position: relative">
<div id="roleTitle" class="layui-input-inline"></div>
</div>
<div class="sub-bg-white edit-box">
<div class="grayLine"></div>
<form class="layui-form add" lay-filter="roleForm" action="">
<div class="layui-form-item">
<div class="layui-input-inline baseInfo">角色基本信息</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label required">所属商户:</label>
<div class="layui-input-block" id="merchantBox">
<!-- <div id="merchantSelect" class="hide">
.tabmutiple-content-wrap {
background-color: #f4f6fc;
/* padding-top: 10px; */
/* padding-bottom: 1px; */
}
.tabmutiple-content {
/* margin: 0 10px; */
background-color: #fff;
}
.contentGrayBg {
/* background-color: #fff; */
/* border: 2px solid red; */
}
.layui-tab-title {
background-color: #f4f6fc;
box-sizing: border-box;
}
.contentGrayBg .layui-this {
background-color: #fff;
border: 2px solid #fff;
margin-left: -3px;
}
.contentGrayBg .layui-tab {
border: 10px solid #f4f6fc;
}
.edit-box {
padding: 0 20px 20px;
color: #333333;
background-color: #ffffff;
margin: 15px auto;
position: relative;
/* height: 100%; */
}
.edit-box .grayLine {
position: absolute;
left: 0;
top: 48px;
background-color: #d8d8d8;
width: 100%;
height: 1px;
}
.edit-title {
height: 78px;
line-height: 78px;
padding: 0 20px;
margin-bottom: 15px;
font-size: 16px;
font-weight: 700;
color: #333333;
background-color: #fff;
}
.baseInfo {
height: 48px;
line-height: 48px;
font-size: 16px;
color: #333333;
font-weight: 600;
}
#roleTitle {
font-size: 20px;
color: #333333;
font-weight: bold;
}
.layui-tab-content {
position: relative;
}
.layui-no-data {
width: 100%;
height: 500px;
}
.layui-no-data .no-data {
position: absolute;
top: 50%;
height: 50%;
width: 100%;
text-align: center;
font-size: 14px;
line-height: 22px;
}
.layui-no-data .no-data div {
margin-top: 12px;
}
.xm-select-demo,
xm-select>.xm-body .scroll-body {
width: 360px;
}
</style>
</head>
<body>
<div id="app">
<main>
<div class="Wrap">
<div class="layui-form-item edit-title" style="position: relative">
<div id="roleTitle" class="layui-input-inline"></div>
</div>
<div class="sub-bg-white edit-box">
<div class="grayLine"></div>
<form class="layui-form add" lay-filter="roleForm" action="">
<div class="layui-form-item">
<div class="layui-input-inline baseInfo">角色基本信息</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label required">所属商户:</label>
<div class="layui-input-block" id="merchantBox">
<!-- <div id="merchantSelect" class="hide">
<select id="merchantName" name="merchantId" lay-filter="merchants" lay-verify="required" autocomplete="off" placeholder="请选择商户名称" required></select>
</div> -->
<div id="merchantNameSelect" class="xm-select-demo"></div>
<div class="hide" id="merchantIdText" style="line-height: 36px"></div>
</div>
<div id="merchantNameSelect" class="xm-select-demo"></div>
<div class="hide" id="merchantIdText" style="line-height: 36px"></div>
</div>
<div class="layui-form-item">
<label class="layui-form-label required">角色名称:</label>
<div class="layui-input-block">
<input type="text" name="roleName" maxlength="15" lay-verify="required" placeholder="请输入角色名称" class="layui-input" />
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label required">角色名称:</label>
<div class="layui-input-block">
<input type="text" name="roleName" maxlength="15" lay-verify="required" placeholder="请输入角色名称"
class="layui-input" />
</div>
<div class="layui-form-item">
<label class="layui-form-label">角色说明:</label>
<div class="layui-input-block">
<input type="text" name="roleDescription" maxlength="50" placeholder="请输入角色说明" class="layui-input" />
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">角色说明:</label>
<div class="layui-input-block">
<input type="text" name="roleDescription" maxlength="50" placeholder="请输入角色说明" class="layui-input" />
</div>
<div class="layui-form-item">
<label class="layui-form-label required">角色权限:</label>
<div class="layui-input-block" id="accountType">
<!-- <input lay-filter="switch" type="checkbox" name="merchantId" value="1" title="引流渠道商" />
</div>
<div class="layui-form-item">
<label class="layui-form-label required">角色权限:</label>
<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="2" title="服务商/合作商" /> -->
</div>
</div>
<div class="tabmutiple-content-wrap removeCheckBg">
<!-- <div id="authorityTree"> -->
<div class="layui-tab tabmutiple-content" lay-filter="roleAuth">
<ul class="layui-tab-title"></ul>
<div class="layui-tab-content contentGrayBg"></div>
</div>
<!-- </div> -->
</div>
<div class="tabmutiple-content-wrap removeCheckBg">
<!-- <div id="authorityTree"> -->
<div class="layui-tab tabmutiple-content" lay-filter="roleAuth">
<ul class="layui-tab-title"></ul>
<div class="layui-tab-content contentGrayBg"></div>
</div>
<!-- </div> -->
</div>
<div class="footer-close">
<button class="layui-btn hide" id="draft">存草稿</button>
<button class="layui-btn" lay-submit lay-filter="roleSubmit">确定</button>
<button type="reset" class="layui-btn" id="return">取消</button>
</div>
</form>
</div>
<div class="footer-close">
<button class="layui-btn hide" id="draft">存草稿</button>
<button class="layui-btn" lay-submit lay-filter="roleSubmit">确定</button>
<button type="reset" class="layui-btn" id="return">取消</button>
</div>
</form>
</div>
</main>
</div>
<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', 'xmSelect'], function() {
// var merchantId = qs('merchantId')
var roleid = qs('id')
var element = layui.element
var form = layui.form
var arr_box = []
var $ = layui.$
var xmSelect = layui.xmSelect
var request = layui.request
var merchantId = ''
var merchantNameSelect = xmSelect.render({
el: '#merchantNameSelect',
prop: {
name: 'merchantName',
value: 'id'
},
layVerify: 'required',
model: {
label: {
type: 'text',
text: {}
}
},
name: 'merchantId',
filterable: true,
radio: true,
clickClose: true,
data: [],
on: function(data) {
console.log(data)
merchantId = data.change[0].id
findMenuFunTreeByMerId(merchantId)
</div>
</main>
</div>
<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', 'xmSelect'], function () {
// var merchantId = qs('merchantId')
var roleid = qs('id')
var element = layui.element
var form = layui.form
var arr_box = []
var $ = layui.$
var xmSelect = layui.xmSelect
var request = layui.request
var merchantId = ''
// 禁用所有input框的回车事件
var inputs = document.getElementsByTagName('input')
for (let i = 0; i < inputs.length; i++) {
var input = inputs[i]
input.onkeydown = function (event) {
if (event.keyCode == 13) {
event.keyCode = 0;
event.returnValue = false;
}
})
if (roleid) {
$('#roleTitle').append('修改角色')
getById(roleid)
$('#merchantIdText').text(qs('merchantName'))
$('#merchantIdText').removeClass('hide')
$('#merchantIdText').addClass('show')
$('#merchantNameSelect').addClass('hide')
} else {
$('#roleTitle').append('新增角色')
$('#draft').removeClass('hide')
$('#draft').addClass('show')
// var str =
// '<div id="merchantSelect" class="hide"><select id="merchantName" name="merchantId" lay-filter="merchants" lay-verify="required" autocomplete="off" placeholder="请选择商户名称" required></select></div>'
// $('#merchantBox').append(str)
findAllMerchant()
$('#merchantSelect').removeClass('hide')
$('#merchantSelect').addClass('show')
// findMenuFunTreeByMerId()
}
var merchantName = $('#merchantName')
// start
var laytpl = layui.laytpl
var xmSelect = layui.xmSelect
var tree = layui.gtree
var helper = layui.helper
var check_arr = []
var requestList = []
var templateData = {}
var selectEl = {}
var treeData = {}
var menuFunTreeData = [] // 商户的菜单权限树数据
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, productList) {
// 渠道的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 = `<form class="layui-form layui-form-pane" action="">\
}
var merchantNameSelect = xmSelect.render({
el: '#merchantNameSelect',
prop: {
name: 'merchantName',
value: 'id'
},
layVerify: 'required',
model: {
label: {
type: 'text',
text: {}
}
},
name: 'merchantId',
filterable: true,
radio: true,
clickClose: true,
data: [],
on: function (data) {
console.log(data)
merchantId = data.change[0].id
findMenuFunTreeByMerId(merchantId)
}
})
if (roleid) {
$('#roleTitle').append('修改角色')
getById(roleid)
$('#merchantIdText').text(qs('merchantName'))
$('#merchantIdText').removeClass('hide')
$('#merchantIdText').addClass('show')
$('#merchantNameSelect').addClass('hide')
} else {
$('#roleTitle').append('新增角色')
$('#draft').removeClass('hide')
$('#draft').addClass('show')
// var str =
// '<div id="merchantSelect" class="hide"><select id="merchantName" name="merchantId" lay-filter="merchants" lay-verify="required" autocomplete="off" placeholder="请选择商户名称" required></select></div>'
// $('#merchantBox').append(str)
findAllMerchant()
$('#merchantSelect').removeClass('hide')
$('#merchantSelect').addClass('show')
// findMenuFunTreeByMerId()
}
var merchantName = $('#merchantName')
// start
var laytpl = layui.laytpl
var xmSelect = layui.xmSelect
var tree = layui.gtree
var helper = layui.helper
var check_arr = []
var requestList = []
var templateData = {}
var selectEl = {}
var treeData = {}
var menuFunTreeData = [] // 商户的菜单权限树数据
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, productList) {
// 渠道的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 = `<form class="layui-form layui-form-pane" action="">\
<div class="layui-form-item" pane>\
<label class="layui-form-label">选择产品:</label>\
<div class="layui-input-block" id="project${id}">
......@@ -288,573 +315,573 @@
</div>
</div>
</div>`
// '<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) {
view.innerHTML = html
})
// var productList = []
// var products = []
console.log(productList)
var products = menuFunTreeData.find(item => item.accounttypeId == id).products
console.log(products)
products.forEach(i => {
var str = $('<input lay-filter="filter" data-id="' + id + '" type="checkbox" name="check[' + id + ']" value="' + i.productId + '" title="' + i.productName + '" lay-skin="primary" />')
$('#project' + id).append(str)
if (productList) {
productList.forEach(j => {
if (j.productId == i.productId) {
str.attr('checked', true)
// '<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) {
view.innerHTML = html
})
// var productList = []
// var products = []
console.log(productList)
var products = menuFunTreeData.find(item => item.accounttypeId == id).products
console.log(products)
products.forEach(i => {
var str = $('<input lay-filter="filter" data-id="' + id + '" type="checkbox" name="check[' + id + ']" value="' + i.productId + '" title="' + i.productName + '" lay-skin="primary" />')
$('#project' + id).append(str)
if (productList) {
productList.forEach(j => {
if (j.productId == i.productId) {
str.attr('checked', true)
}
})
}
form.render()
})
// $.each(menuFunTreeData, function(index, item) {
// if (item.accounttypeId == id) {
// // products = item.products
// $.each(item.products, function(idx, i) {
// var str = $('<input lay-filter="filter" data-id="' + id + '" type="checkbox" name="check[' + id + ']" value="' + i.productId + '" title="' + i.productName + '" lay-skin="primary" />')
// $('#project' + id).append(str)
// })
// }
// })
// console.log('productList', products, id)
// selectEl[id] = xmSelect.render({
// el: '#select' + id,
// data: productList,
// on: function(data) {
// //arr: 当前多选已选中的数据
// var arr = data.arr
// //change, 此次选择变化的数据,数组
// var change = data.change
// //isAdd, 此次操作是新增还是删除
// var isAdd = data.isAdd
// var filterName = 'treeTab' + id
// if (isAdd) {
// active.treeTabAdd(change[0], id, products)
// } else {
// var productId = 'tab_' + id + '_' + change[0].value
// active.tabDelete(filterName, productId)
// delete treeData[id][change[0].value]
// }
// if (arr.length != 0) {
// var productId = 'tab_' + id + '_' + arr[0].value
// active.tabChange(filterName, productId)
// }
// }
// })
// console.log(selectEl[id])
},
// tab删除
tabDelete: function (name, id) {
element.tabDelete(name, id)
},
// 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')
}
}
})
}
form.render()
})
// $.each(menuFunTreeData, function(index, item) {
// if (item.accounttypeId == id) {
// // products = item.products
// $.each(item.products, function(idx, i) {
// var str = $('<input lay-filter="filter" data-id="' + id + '" type="checkbox" name="check[' + id + ']" value="' + i.productId + '" title="' + i.productName + '" lay-skin="primary" />')
// $('#project' + id).append(str)
// })
// }
// })
// console.log('productList', products, id)
// selectEl[id] = xmSelect.render({
// el: '#select' + id,
// data: productList,
// on: function(data) {
// //arr: 当前多选已选中的数据
// var arr = data.arr
// //change, 此次选择变化的数据,数组
// var change = data.change
// //isAdd, 此次操作是新增还是删除
// var isAdd = data.isAdd
// var filterName = 'treeTab' + id
// if (isAdd) {
// active.treeTabAdd(change[0], id, products)
// } else {
// var productId = 'tab_' + id + '_' + change[0].value
// active.tabDelete(filterName, productId)
// delete treeData[id][change[0].value]
// }
// if (arr.length != 0) {
// var productId = 'tab_' + id + '_' + arr[0].value
// active.tabChange(filterName, productId)
// }
// }
// })
// console.log(selectEl[id])
},
// tab删除
tabDelete: function(name, id) {
element.tabDelete(name, id)
},
// tab Change
tabChange: function(name, id) {
console.log(name, id)
element.tabChange(name, id)
if (name == 'roleAuth') {
$(`#nomenu${id}`).html('请选择产品')
}
},
/**
* 第二级选项卡
* treeTabAdd 产品的权限添加
* item: {name: 选项卡名称, value: 选项卡值}
* id 第一级选项卡的item.value
* filterName: 过滤器的名称 lay-filter绑定的值
* treeData:渲染模板的数据,和用来存放对应树实例的对象,
* products:产品list数组
* defaultList:编辑时传入,默认勾选中的数组。(举例:[1,2,3])
*/
treeTabAdd: function (item, id, treeListData, defaultList) {
console.log(item, id, treeListData, 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的内容
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) {
console.log(treeView)
treeView.innerHTML = html
})
// var treeListData = []
// $.each(products, function(index, i) {
// if (item.value == i.productId) {
// treeListData = i.merchantProTreeResponses
// }
// })
var treedom = 'tree_' + productId
if (treeListData && treeListData.length != 0) {
if (!roleid) {
treeData[id][item.value].treeObj = tree.create(treedom, treeListData)
treeData[id][item.value].treeObj.checkAllNodes(true)
} 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')
}
}
})
}
})
}
},
/**
* 第二级选项卡
* treeTabAdd 产品的权限添加
* item: {name: 选项卡名称, value: 选项卡值}
* id 第一级选项卡的item.value
* filterName: 过滤器的名称 lay-filter绑定的值
* treeData:渲染模板的数据,和用来存放对应树实例的对象,
* products:产品list数组
* defaultList:编辑时传入,默认勾选中的数组。(举例:[1,2,3])
*/
treeTabAdd: function(item, id, treeListData, defaultList) {
console.log(item, id, treeListData, 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的内容
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) {
console.log(treeView)
treeView.innerHTML = html
})
// var treeListData = []
// $.each(products, function(index, i) {
// if (item.value == i.productId) {
// treeListData = i.merchantProTreeResponses
// }
// })
var treedom = 'tree_' + productId
if (treeListData && treeListData.length != 0) {
if (!roleid) {
treeData[id][item.value].treeObj = tree.create(treedom, treeListData)
treeData[id][item.value].treeObj.checkAllNodes(true)
treeData[id][item.value].treeObj = tree.create(treedom, treeListData)
if (defaultList) {
treeData[id][item.value].treeObj.checkNodes(defaultList)
} else {
treeData[id][item.value].treeObj = tree.create(treedom, treeListData)
if (defaultList) {
treeData[id][item.value].treeObj.checkNodes(defaultList)
} else {
treeData[id][item.value].treeObj.checkAllNodes(true)
}
treeData[id][item.value].treeObj.checkAllNodes(true)
}
// $(`#nodata${id}`).removeClass('show')
// $(`#nodata${id}`).addClass('hide')
} else {
// $(`#nodata${id}`).removeClass('hide')
// $(`#nodata${id}`).addClass('show')
}
}
}
// 产品复选框change事件
form.on('checkbox(filter)', function(data) {
console.log(data, '33333333333')
var roleId = +data.elem.dataset.id
var projectId = data.value
var isAdd = data.elem.checked
var filterName = 'treeTab' + roleId
console.log(roleId, projectId, isAdd)
// merchantProTreeResponses
var changeObj = menuFunTreeData.find(item => item.accounttypeId == roleId).products.find(i => i.productId == projectId)
var products = menuFunTreeData.find(item => item.accounttypeId == roleId).products
console.log(changeObj, products, roleId, treeData)
if (isAdd) {
// 新增
active.treeTabAdd(
{
name: changeObj.productName,
value: changeObj.productId
},
roleId,
changeObj.merchantProTreeResponses
)
// $(`#nodata${id}`).removeClass('show')
// $(`#nodata${id}`).addClass('hide')
} else {
// 删除
console.log(treeData, Object.keys(treeData).length)
var productId = 'tab_' + roleId + '_' + changeObj.productId
active.tabDelete(filterName, productId)
if (Object.keys(treeData).length != 0) {
delete treeData[roleId][changeObj.productId]
}
if (Object.keys(treeData).length == 0 || Object.keys(treeData[roleId]).length == 0) {
$(`#nodata${roleId}`).removeClass('hide')
$(`#nodata${roleId}`).addClass('show')
}
// $(`#nodata${id}`).removeClass('hide')
// $(`#nodata${id}`).addClass('show')
}
}
}
// 产品复选框change事件
form.on('checkbox(filter)', function (data) {
console.log(data, '33333333333')
var roleId = +data.elem.dataset.id
var projectId = data.value
var isAdd = data.elem.checked
var filterName = 'treeTab' + roleId
console.log(roleId, projectId, isAdd)
// merchantProTreeResponses
var changeObj = menuFunTreeData.find(item => item.accounttypeId == roleId).products.find(i => i.productId == projectId)
var products = menuFunTreeData.find(item => item.accounttypeId == roleId).products
console.log(changeObj, products, roleId, treeData)
if (isAdd) {
// 新增
active.treeTabAdd(
{
name: changeObj.productName,
value: changeObj.productId
},
roleId,
changeObj.merchantProTreeResponses
)
} else {
// 删除
console.log(treeData, Object.keys(treeData).length)
var productId = 'tab_' + roleId + '_' + changeObj.productId
active.tabDelete(filterName, productId)
if (Object.keys(treeData).length != 0) {
var productId = 'tab_' + roleId + '_' + changeObj.productId
active.tabChange(filterName, productId)
delete treeData[roleId][changeObj.productId]
}
})
if (Object.keys(treeData).length == 0 || Object.keys(treeData[roleId]).length == 0) {
$(`#nodata${roleId}`).removeClass('hide')
$(`#nodata${roleId}`).addClass('show')
}
}
if (Object.keys(treeData).length != 0) {
var productId = 'tab_' + roleId + '_' + changeObj.productId
active.tabChange(filterName, productId)
}
})
// 复选框的change事件
form.on('checkbox(switch)', function(data) {
console.log(data, '111111111', treeData)
if (data.elem.checked) {
var obj = { title: data.elem.title, value: data.elem.value }
check_arr.push({
accounttypeId: data.elem.value
})
active.tabAdd(obj)
console.log(check_arr)
treeData[+data.elem.value] = {}
} else {
console.log(11222)
for (var i in check_arr) {
var id = check_arr[i].accounttypeId
if (check_arr[i].accounttypeId == data.elem.value) {
active.tabDelete('roleAuth', id)
check_arr.splice(i, 1)
}
// 复选框的change事件
form.on('checkbox(switch)', function (data) {
console.log(data, '111111111', treeData)
if (data.elem.checked) {
var obj = { title: data.elem.title, value: data.elem.value }
check_arr.push({
accounttypeId: data.elem.value
})
active.tabAdd(obj)
console.log(check_arr)
treeData[+data.elem.value] = {}
} else {
console.log(11222)
for (var i in check_arr) {
var id = check_arr[i].accounttypeId
if (check_arr[i].accounttypeId == data.elem.value) {
active.tabDelete('roleAuth', id)
check_arr.splice(i, 1)
}
delete treeData[data.elem.value]
}
console.log(treeData)
if (check_arr.length != 0) {
active.tabChange('roleAuth', check_arr[0].accounttypeId)
}
})
// end
delete treeData[data.elem.value]
}
console.log(treeData)
if (check_arr.length != 0) {
active.tabChange('roleAuth', check_arr[0].accounttypeId)
}
})
// end
// 表单提交
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()
insert(0, data.field)
// 表单提交
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()
insert(0, data.field)
return false
})
// select 选择触发
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)
// select 选择触发
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() {
var formVal = form.val('roleForm')
console.log(formVal)
if (!formVal.merchantId ) {
layer.msg('请选择所属商户', {
icon: 2
})
return false
}
if (formVal.roleName || formVal.roleDescription || Object.keys(treeData).length != 0) {
getAuthList()
insert(1, formVal)
} else {
layer.msg('至少填一项', {
icon: 2
})
}
// 存草稿
$('#draft').on('click', function () {
var formVal = form.val('roleForm')
console.log(formVal)
if (!formVal.merchantId) {
layer.msg('请选择所属商户', {
icon: 2
})
return false
})
}
if (formVal.roleName || formVal.roleDescription || Object.keys(treeData).length != 0) {
getAuthList()
insert(1, formVal)
} else {
layer.msg('至少填一项', {
icon: 2
})
}
return false
})
// 返回上个页面
$('#return').on('click', function() {
window.history.back()
})
// 返回上个页面
$('#return').on('click', function () {
window.history.back()
})
// 调用新增接口
function insert(delFlag, formVal) {
var otherParams = {
merchantId: merchantId,
delFlag: delFlag
}
console.log(requestList)
let hasProduct = requestList.some(item => item.productList.length != 0)
// 找这个数组里面是否有空值,然后判断是否为草稿,
if (delFlag == 1) { // 草稿
// if (hasProduct) {
otherParams.requestList = JSON.stringify(requestList)
// } else {
// otherParams.requestList = JSON.stringify([])
// }
// if (requestList.length != 0) {
// otherParams.requestList = JSON.stringify(requestList)
// } else {
// otherParams.requestList = JSON.stringify([])
// }
} else {
if (hasProduct) {
otherParams.requestList = JSON.stringify(requestList)
} else {
layer.msg('请选择产品', {
icon: 2
})
return
}
// if (requestList.length != 0) {
// otherParams.requestList = JSON.stringify(requestList)
// } else {
// layer.msg('请选择产品', {
// icon: 2
// })
// return
// }
}
// 调用新增接口
function insert(delFlag, formVal) {
var otherParams = {
merchantId: merchantId,
delFlag: delFlag
}
console.log(requestList)
let hasProduct = requestList.some(item => item.productList.length != 0)
// 找这个数组里面是否有空值,然后判断是否为草稿,
if (delFlag == 1) { // 草稿
// if (hasProduct) {
otherParams.requestList = JSON.stringify(requestList)
// } else {
// otherParams.requestList = JSON.stringify([])
if (roleid) {
otherParams.id = roleid
otherParams.method = 'org.ore.api.role.update'
// }
// if (requestList.length != 0) {
// otherParams.requestList = JSON.stringify(requestList)
// } else {
// otherParams.requestList = JSON.stringify([])
// }
} else {
if (hasProduct) {
otherParams.requestList = JSON.stringify(requestList)
} else {
otherParams.method = 'org.ore.api.role.insert'
layer.msg('请选择产品', {
icon: 2
})
return
}
var params = helper.clone(true, formVal, otherParams)
delete params.select
console.log(params)
request(params, function(res) {
if (res.code == '0') {
layer.msg('操作成功', {
icon: 1
})
window.history.back()
}
})
// if (requestList.length != 0) {
// otherParams.requestList = JSON.stringify(requestList)
// } else {
// layer.msg('请选择产品', {
// icon: 2
// })
// return
// }
}
// 查询商户的菜单权限树
function findMenuFunTreeByMerId(merchantId) {
var params = {
method: 'cn.com.glsx.merchants.merchant.findMenuFunTreeByMerId',
id: merchantId
}
request(params, function(res) {
if (res.code == '0') {
// callback(res.data)
menuFunTreeData = res.data
console.log(res.data)
var accountType = $('#accountType')
accountType.empty()
menuFunTreeData.forEach((item, index) => {
var str = $('<input lay-filter="switch" type="checkbox" name="accounttypeId" value="' + item.accounttypeId + '" title="' + item.accounttypeName + '" />')
accountType.append(str)
if (roleid) {
console.log(check_arr)
check_arr.forEach(i => {
if (i.accounttypeId == item.accounttypeId) {
var productData = i
var id = item.accounttypeId
console.log('productData', productData)
str.attr('checked', true)
var obj = { title: item.accounttypeName, value: item.accounttypeId }
active.tabAdd(obj, productData.productList)
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)
} else {
treeData[productData.accounttypeId] = {}
}
}
})
}
})
if (check_arr.length != 0) {
active.tabChange('roleAuth', check_arr[0].accounttypeId)
}
// $.each(menuFunTreeData, function(index, item) {
// if (roleid) {
// 角色权限的check
// for (var i = 0; i < check_arr.length; i++) {
// if (check_arr[i].accounttypeId == item.accounttypeId) {
// var productData = check_arr[i]
// str.attr('checked', true)
// var obj = { title: item.accounttypeName, value: item.accounttypeId }
// active.tabAdd(obj)
// var selectArr = []
// var menuData = []
// if (productData.productList) {
// for (var j = 0; j < productData.productList.length; j++) {
// menuData = productData.productList[j]
// selectArr.push(menuData.productId)
// active.treeTabAdd(
// {
// name: menuData.productName,
// value: menuData.productId
// },
// item.accounttypeId,
// item.products,
// menuData.idList
// )
// }
// selectEl[item.accounttypeId].setValue(selectArr)
// var filterName = 'treeTab' + item.accounttypeId
// var productId = 'tab_' + item.accounttypeId + '_' + item.products[0].productId
// console.log(filterName, productId)
// active.tabChange(filterName, productId)
// }
// }
// }
// if (check_arr.length != 0) {
// active.tabChange('roleAuth', check_arr[0].accounttypeId)
// }
// }
// })
form.render('checkbox')
}
})
// otherParams.requestList = JSON.stringify([])
if (roleid) {
otherParams.id = roleid
otherParams.method = 'org.ore.api.role.update'
} else {
otherParams.method = 'org.ore.api.role.insert'
}
// 根据id获取角色详情
function getById(id) {
var params = {
method: 'org.ore.api.role.getById',
id: id
var params = helper.clone(true, formVal, otherParams)
delete params.select
console.log(params)
request(params, function (res) {
if (res.code == '0') {
layer.msg('操作成功', {
icon: 1
})
window.history.back()
}
request(params, function(res) {
if (res.code == '0') {
var data = res.data
var accounttypeId = ''
if (data.responseList) {
check_arr = data.responseList
}
merchantId = data.merchantId
findMenuFunTreeByMerId(data.merchantId)
form.val('roleForm', {
roleName: data.roleName,
roleDescription: data.roleDescription,
merchantId: data.merchantId
})
}
})
}
})
}
// 获取角色权限数据requestList
function getAuthList() {
requestList = []
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
// 查询商户的菜单权限树
function findMenuFunTreeByMerId(merchantId) {
var params = {
method: 'cn.com.glsx.merchants.merchant.findMenuFunTreeByMerId',
id: merchantId
}
request(params, function (res) {
if (res.code == '0') {
// callback(res.data)
menuFunTreeData = res.data
console.log(res.data)
var accountType = $('#accountType')
accountType.empty()
menuFunTreeData.forEach((item, index) => {
var str = $('<input lay-filter="switch" type="checkbox" name="accounttypeId" value="' + item.accounttypeId + '" title="' + item.accounttypeName + '" />')
accountType.append(str)
if (roleid) {
console.log(check_arr)
check_arr.forEach(i => {
if (i.accounttypeId == item.accounttypeId) {
var productData = i
var id = item.accounttypeId
console.log('productData', productData)
str.attr('checked', true)
var obj = { title: item.accounttypeName, value: item.accounttypeId }
active.tabAdd(obj, productData.productList)
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 {
functionIdList.push({
id: m.parentId,
menuId: m.superParentId,
functionValue: m.id + ':' + m.label
})
$(`#nomenutab_${id}_${j.productId}`).removeClass('show')
$(`#nomenutab_${id}_${j.productId}`).addClass('hide')
}
})
$.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
})
var filterName = 'treeTab' + item.accounttypeId
var productId = 'tab_' + item.accounttypeId + '_' + productData.productList[0].productId
console.log(filterName, productId)
active.tabChange(filterName, productId)
} else {
productList.push({
productId: productObj.productId,
functionIdList: [],
menuIdList: []
})
treeData[productData.accounttypeId] = {}
}
}
requestList.push({
accountTypeId: key,
productList: productList
})
// }
// } else {
// requestList.push({
// accountTypeId: i.accounttypeId,
// productList: []
// })
// }
})
}
})
if (check_arr.length != 0) {
active.tabChange('roleAuth', check_arr[0].accounttypeId)
}
// })
// $.each(menuFunTreeData, function(index, item) {
// if (roleid) {
// 角色权限的check
// for (var i = 0; i < check_arr.length; i++) {
// if (check_arr[i].accounttypeId == item.accounttypeId) {
// var productData = check_arr[i]
// str.attr('checked', true)
// var obj = { title: item.accounttypeName, value: item.accounttypeId }
// active.tabAdd(obj)
// var selectArr = []
// var menuData = []
// if (productData.productList) {
// for (var j = 0; j < productData.productList.length; j++) {
// menuData = productData.productList[j]
// selectArr.push(menuData.productId)
// active.treeTabAdd(
// {
// name: menuData.productName,
// value: menuData.productId
// },
// item.accounttypeId,
// item.products,
// menuData.idList
// )
// }
// selectEl[item.accounttypeId].setValue(selectArr)
// var filterName = 'treeTab' + item.accounttypeId
// var productId = 'tab_' + item.accounttypeId + '_' + item.products[0].productId
// console.log(filterName, productId)
// active.tabChange(filterName, productId)
// }
// }
// }
// if (check_arr.length != 0) {
// active.tabChange('roleAuth', check_arr[0].accounttypeId)
// }
// }
// })
form.render('checkbox')
}
})
}
// 根据id获取角色详情
function getById(id) {
var params = {
method: 'org.ore.api.role.getById',
id: id
}
request(params, function (res) {
if (res.code == '0') {
var data = res.data
var accounttypeId = ''
if (data.responseList) {
check_arr = data.responseList
}
merchantId = data.merchantId
findMenuFunTreeByMerId(data.merchantId)
form.val('roleForm', {
roleName: data.roleName,
roleDescription: data.roleDescription,
merchantId: data.merchantId
})
}
})
}
// 查询所有商户
function findAllMerchant() {
var params = { method: 'cn.com.glsx.merchants.menu.findAllMerchant' }
request(params, function(result) {
if (result.code == '0') {
console.log(result)
merchantNameSelect.update({
data: result.data,
autoRow: true,
paging: result.data.length > 20
// 获取角色权限数据requestList
function getAuthList() {
requestList = []
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 {
productList.push({
productId: productObj.productId,
functionIdList: [],
menuIdList: []
})
merchantNameSelect.setValue([merchantId])
// var list = result.data
// list.unshift('')
// $.each(list, function(index, item) {
// merchantName.append(new Option(item.merchantName, item.id))
// })
// form.render('select')
}
}
requestList.push({
accountTypeId: key,
productList: productList
})
// }
// } else {
// requestList.push({
// accountTypeId: i.accounttypeId,
// productList: []
// })
// }
}
})
</script>
<script type="text/html" id="rolesAuth">
// })
}
// 查询所有商户
function findAllMerchant() {
var params = { method: 'cn.com.glsx.merchants.menu.findAllMerchant' }
request(params, function (result) {
if (result.code == '0') {
console.log(result)
merchantNameSelect.update({
data: result.data,
autoRow: true,
paging: result.data.length > 20
})
merchantNameSelect.setValue([merchantId])
// var list = result.data
// list.unshift('')
// $.each(list, function(index, item) {
// merchantName.append(new Option(item.merchantName, item.id))
// })
// form.render('select')
}
})
}
})
</script>
<script type="text/html" id="rolesAuth">
`
<div id="select{{d.id}}"></div>
<div class="layui-tab layui-tab-brief" lay-filter="treeTab{{d.id}}">
......@@ -863,16 +890,17 @@
</div>
`
</script>
<script type="text/html" id="treeAuth">
<script type="text/html" id="treeAuth">
<!-- <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>
<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>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!