Commit fc2af01a by 胡悦

合并

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