Commit f949b4c6 by 前端

Merge branch 'v3.4.0' into 'develop'

V3.4.0

See merge request !41
2 parents 8f2ab6d2 1290ca4d
<!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;
}
<head> .upload-img-box .upload-img {
<meta charset="utf-8" /> position: absolute;
<meta content="IE=edge" /> width: 80px;
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> top: 0;
<meta name="description" content="广联帐户管理中心-员工管理" /> left: 0;
<meta name="author" content="GLSX Web Team" /> }
<meta name="keywords" itemprop="keywords" content="广联,帐户管理,员工管理" />
<link rel="stylesheet" type="text/css" href="/css/main.css" /> .icon-add {
<title>员工管理</title> position: absolute;
<style> top: 50%;
.upload-img-box { font-size: 40px;
position: relative; left: 50%;
width: 80px; transform: translate3d(-50%, -50%, 0);
height: 80px; }
color: #999999;
border: 1px dashed #d9d9d9; .upload-img-wh {
cursor: pointer; width: 80px !important;
} height: 80px;
}
.upload-img-box .upload-img {
position: absolute; .show {
width: 80px; display: inline-block;
top: 0; /* width: 360px; */
left: 0; }
}
.hide {
.icon-add { display: none;
position: absolute; }
top: 50%;
font-size: 40px; .tips {
left: 50%; font-size: 14px;
transform: translate3d(-50%, -50%, 0); color: #999;
} }
.upload-img-wh { .form-right {
width: 80px !important; position: absolute;
height: 80px; right: 0;
} top: 0;
transform: translateX(110%);
.show { }
display: inline-block;
/* width: 360px; */ .sub-bg-white {
} background-color: #fff;
}
.hide {
display: none; .edit-box {
} padding: 0 20px 20px;
box-sizing: border-box;
.tips { color: #333333;
font-size: 14px; background-color: #ffffff;
color: #999; margin: 15px auto;
} position: relative;
.form-right { margin-bottom: 100px;
position: absolute; }
right: 0;
top: 0; .edit-box .grayLine {
transform: translateX(110%); position: absolute;
} left: 0;
top: 48px;
.sub-bg-white { background-color: #d8d8d8;
background-color: #fff; width: 100%;
} height: 1px;
}
.edit-box {
padding: 0 20px 20px; .edit-title {
box-sizing: border-box; height: 48px;
color: #333333; line-height: 48px;
background-color: #ffffff; padding: 0 20px;
margin: 15px auto; margin-bottom: 15px;
position: relative; font-size: 16px;
color: #333333;
margin-bottom: 100px; font-weight: 600;
} }
.edit-box .grayLine { .hide {
position: absolute; display: none;
left: 0; }
top: 48px;
background-color: #d8d8d8; .show {
width: 100%; display: block;
height: 1px; }
}
.pageTitle {
.edit-title { background-color: #fff;
height: 48px; height: 78px;
line-height: 48px; font-size: 20px;
padding: 0 20px; font-weight: bold;
margin-bottom: 15px; color: #333333;
font-size: 16px; line-height: 78px;
color: #333333; padding-left: 20px;
font-weight: 600; }
}
.Wrap {
.hide { margin: 8px 20px 0;
display: none; /* height: 100%; */
} }
.show { .xm-select-demo,
display: block; xm-select > .xm-body .scroll-body {
} width: 360px;
}
.pageTitle {
background-color: #fff; xm-select:hover {
height: 78px; border: 1px solid #5850ff !important;
font-size: 20px; }
font-weight: bold; </style>
color: #333333; </head>
line-height: 78px;
padding-left: 20px; <body>
} <div id="app">
<main>
.Wrap { <div class="Wrap">
margin: 8px 20px 0; <div class="pageTitle">
/* height: 100%; */ <span id="addUpdateTitle">新增员工</span>
} </div>
<div class="sub-bg-white edit-box">
.xm-select-demo, <div class="grayLine"></div>
xm-select>.xm-body .scroll-body { <form class="layui-form add" lay-filter="employeeForm" action="">
width: 360px; <div class="layui-form-item edit-title" style="position: relative">
} <div class="layui-input-inline">员工基本信息</div>
xm-select:hover {
border: 1px solid #5850ff !important;
}
</style>
</head>
<body>
<div id="app">
<main>
<div class="Wrap">
<div class="pageTitle">
<span id="addUpdateTitle">新增员工</span>
</div>
<div class="sub-bg-white edit-box">
<div class="grayLine"></div>
<form class="layui-form add" lay-filter="employeeForm" action="">
<div class="layui-form-item edit-title" style="position: relative">
<div class="layui-input-inline">员工基本信息</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label required">所属商户:</label>
<div class="layui-input-block" id="merchantBox">
<!-- <div id="merchantSelect" class="hide"> -->
<!-- <select id="merchantName" name="merchantId" lay-filter="merchants" lay-verify="required" autocomplete="off" placeholder="请选择商户名称" required></select> -->
<div id="merchantNameSelect" class="xm-select-demo"></div>
<!-- </div> -->
<div class="hide" id="merchantIdText" style="line-height: 32px"></div>
</div> </div>
</div> <div class="layui-form-item">
<div class="layui-form-item"> <label class="layui-form-label required">所属商户:</label>
<label class="layui-form-label required">员工姓名:</label> <div class="layui-input-block" id="merchantBox">
<div class="layui-input-block"> <!-- <div id="merchantSelect" class="hide"> -->
<input type="text" name="staffName" maxlength="15" required lay-verify="required" placeholder="请输入员工姓名" <!-- <select id="merchantName" name="merchantId" lay-filter="merchants" lay-verify="required" autocomplete="off" placeholder="请选择商户名称" required></select> -->
autocomplete="off" class="layui-input" /> <div id="merchantNameSelect" class="xm-select-demo"></div>
<!-- </div> -->
<div class="hide" id="merchantIdText" style="line-height: 32px"></div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label required">员工姓名:</label>
<div class="layui-input-block">
<input type="text" name="staffName" maxlength="15" required lay-verify="required" placeholder="请输入员工姓名" autocomplete="off" class="layui-input" />
</div>
</div> </div>
</div> <div class="layui-form-item">
<div class="layui-form-item"> <label class="layui-form-label required">登录手机号:</label>
<label class="layui-form-label required">登录手机号:</label> <div class="layui-input-block">
<div class="layui-input-block"> <input
<input id="staffPhone" type="text" name="staffPhone" maxlength="11" required lay-verify="required|phone" id="staffPhone"
placeholder="请输入您有效的手机号作为登录账户" autocomplete="off" class="layui-input" /> type="text"
name="staffPhone"
maxlength="11"
required
lay-verify="required|phone"
placeholder="请输入您有效的手机号作为登录账户"
autocomplete="off"
class="layui-input"
/>
</div>
</div> </div>
</div> <div class="layui-form-item">
<div class="layui-form-item"> <label class="layui-form-label required">登录密码:</label>
<label class="layui-form-label required">登录密码:</label> <div class="layui-input-block" style="position: relative">
<div class="layui-input-block" style="position: relative"> <input
<input type="password" name="password" id="password" maxlength="20" required type="password"
lay-verify="required|merchantLoginPassword" placeholder="请输入密码(必须包含6-20个字母+数字)" autocomplete="off" name="password"
class="layui-input" /> id="password"
<button type="button" class="layui-btn form-right hide" id="resetpsw">重置密码</button> maxlength="20"
required
lay-verify="required|merchantLoginPassword"
placeholder="请输入密码(必须包含6-20个字母+数字)"
autocomplete="off"
class="layui-input"
/>
<button type="button" class="layui-btn form-right hide" id="resetpsw">重置密码</button>
</div>
</div> </div>
</div> <div class="layui-form-item">
<div class="layui-form-item"> <label class="layui-form-label required">可见商户:</label>
<label class="layui-form-label required">可见商户:</label> <div class="hide" id="allMerchant" style="line-height: 32px">全部商户</div>
<div class="hide" id="allMerchant" style="line-height: 32px;">全部商户</div> <div class="layui-input-block" id="otherMerchant">
<div class="layui-input-block" id="otherMerchant"> <input class="layui-input" placeholder="可见商户" id="searchMerchant" />
<input class="layui-input" placeholder="可见商户" id="searchMerchant" /> <div style="position: absolute; top: 0; left: 380px">
<div style="position: absolute; top: 0; left: 380px"> <button type="button" class="layui-btn" id="checkAll">全选</button>
<button type="button" class="layui-btn" id="checkAll">全选</button> </div>
<ul id="visibleInferiorMerTree" style="max-height: 200px; overflow-y: auto" class="ztree wrapper-tree"></ul>
</div> </div>
<ul id="visibleInferiorMerTree" style="max-height: 200px; overflow-y: auto" class="ztree wrapper-tree">
</ul>
</div> </div>
</div> <div class="layui-form-item">
<div class="layui-form-item"> <label class="layui-form-label required">角色权限:</label>
<label class="layui-form-label required">角色权限:</label> <div class="layui-input-block" style="position: relative">
<div class="layui-input-block" style="position: relative"> <select name="roleIds" id="roleAuth" lay-verify="required"></select>
<select name="roleIds" id="roleAuth" lay-verify="required"></select> <div id="btnGroup" class="layui-btn-group hide" style="position: absolute; top: 0; right: -170px">
<div id="btnGroup" class="layui-btn-group hide" style="position: absolute; top: 0; right: -170px"> <button type="button" class="layui-btn" id="refresh">刷新</button>
<button type="button" class="layui-btn" id="refresh">刷新</button> <button type="button" class="layui-btn" id="addRole">创建角色</button>
<button type="button" class="layui-btn" id="addRole">创建角色</button> </div>
</div> </div>
</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"> <div class="upload-img-box">
<div class="upload-img-box"> <div class="icon-add img-add show">+</div>
<div class="icon-add img-add show">+</div> <img class="upload-img upload-img-wh hide" id="img" />
<img class="upload-img upload-img-wh hide" id="img" /> <input
<input type="file" id="upload" name="merhcnatImg" ref="file" type="file"
class="upload upload-img-box upload-img-wh" accept="image/png, image/jpeg, image/gif, image/jpg" id="upload"
data-idx="0" style="opacity: 0" /> name="merhcnatImg"
ref="file"
class="upload upload-img-box upload-img-wh"
accept="image/png, image/jpeg, image/gif, image/jpg"
data-idx="0"
style="opacity: 0"
/>
</div>
<span class="tips">图片格式仅支持JPG,PNG格式,大小1M以内</span>
</div> </div>
<span class="tips">图片格式仅支持JPG,PNG格式,大小1M以内</span>
</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="staffEmail" maxlength="30" lay-verify="" placeholder="请输入邮箱" autocomplete="off" class="layui-input" />
<input type="text" name="staffEmail" maxlength="30" lay-verify="" placeholder="请输入邮箱" autocomplete="off" </div>
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" <input type="text" name="staffJob" maxlength="10" placeholder="请输入主要职务" autocomplete="off" class="layui-input" />
class="layui-input" /> </div>
</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"> <select name="department" id="departmentAuth">
<select name="department" id="departmentAuth"> <option value="0">其他</option>
<option value="0">其他</option> <option value="1">销售部</option>
<option value="1">销售部</option> <option value="2">售后部</option>
<option value="2">售后部</option> <option value="3">客服部</option>
<option value="3">客服部</option> <option value="4">续保部</option>
<option value="4">续保部</option> </select>
</select> </div>
</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"> <div id="tagAuth" name="staffLabel" class="xm-select-demo"></div>
<div id="tagAuth" name="staffLabel" class="xm-select-demo"></div> <!-- <select name="staffLabel" id="tagAuth" xm-select="selectId">
<!-- <select name="staffLabel" id="tagAuth" xm-select="selectId">
<option value="0">1.0新车权益销售</option> <option value="0">1.0新车权益销售</option>
<option value="1">1.1次新车精品升级</option> <option value="1">1.1次新车精品升级</option>
<option value="2">1.2次新车线上转化</option> <option value="2">1.2次新车线上转化</option>
<option value="3">1.3存量用户众筹</option> <option value="3">1.3存量用户众筹</option>
</select> --> </select> -->
</div>
</div> </div>
</div>
<div class="layui-form-item hide" id="wechatNick"> <div class="layui-form-item hide" id="wechatNick">
<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="weChatNickName" readonly <input type="text" name="weChatNickName" readonly class="layui-input" />
class="layui-input" /> </div>
</div> </div>
</div> <div class="layui-form-item hide" id="wechatPhone">
<div class="layui-form-item hide" id="wechatPhone"> <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="weChatPhone" readonly class="layui-input" />
<input type="text" name="weChatPhone" readonly </div>
class="layui-input" />
</div> </div>
</div> <div class="layui-form-item hide" id="wechatId">
<div class="layui-form-item hide" id="wechatId"> <label class="layui-form-label">微信openid:</label>
<label class="layui-form-label">微信openid:</label> <div class="layui-input-block">
<div class="layui-input-block"> <input type="text" name="weChatOpenId" readonly class="layui-input" />
<input type="text" name="weChatOpenId" readonly </div>
class="layui-input" />
</div> </div>
</div>
<div class="footer-close"> <div class="footer-close">
<button class="layui-btn" lay-submit lay-filter="employeeSubmit">确定</button> <button class="layui-btn" lay-submit lay-filter="employeeSubmit">确定</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>
</div> </main>
</main> </div>
</div> <script src="https://img02.glsx.com.cn/layui/layui.js"></script>
<script src="https://img02.glsx.com.cn/layui/layui.js"></script> <script src="/js/load.js"></script>
<script src="/js/load.js"></script> <script>
<script> //Demo
//Demo layui.use(['form', 'upload', 'gtree', 'request', 'helper', 'xmSelect'], function () {
layui.use(['form', 'upload', 'gtree', 'request', 'helper', 'xmSelect'], function () { var id = qs('id')
var id = qs('id') var form = layui.form
var form = layui.form var upload = layui.upload
var upload = layui.upload var tree = layui.gtree
var tree = layui.gtree var request = layui.request
var request = layui.request var helper = layui.helper
var helper = layui.helper var $ = layui.$
var $ = layui.$ var xmSelect = layui.xmSelect
var xmSelect = layui.xmSelect var merchantFileRequest = {}
var merchantFileRequest = {} var all_nodes = []
var all_nodes = [] var employeeForm = {}
var employeeForm = {} var pwd = $('#password') // 密码输入框
var pwd = $('#password') // 密码输入框 var resetpsw = $('#resetpsw')
var resetpsw = $('#resetpsw') var roleAuth = $('#roleAuth')
var roleAuth = $('#roleAuth') var wechatNick = $('#wechatNick')
var wechatNick = $('#wechatNick') var wechatPhone = $('#wechatPhone')
var wechatPhone = $('#wechatPhone') var wechatId = $('#wechatId')
var wechatId = $('#wechatId') var merchantName = $('#merchantName')
var merchantName = $('#merchantName') var merchantId = ''
var merchantId = '' var visibleMerchant = {}
var visibleMerchant = {} pwd.attr('readonly', false)
pwd.attr('readonly', false) var accountInfo = helper.store.get('accountInfo')
var accountInfo = helper.store.get('accountInfo') // 是否是特殊商户
// 是否是特殊商户 var specialVisible = ''
var specialVisible = '' // 禁用所有input框的回车事件
// 禁用所有input框的回车事件 var inputs = document.getElementsByTagName('input')
var inputs = document.getElementsByTagName('input') for (let i = 0; i < inputs.length; i++) {
for (let i = 0; i < inputs.length; i++) { var input = inputs[i]
var input = inputs[i] input.onkeydown = function (event) {
input.onkeydown = function (event) { if (event.keyCode == 13) {
if (event.keyCode == 13) { event.keyCode = 0
event.keyCode = 0; event.returnValue = false
event.returnValue = false; }
} }
} }
}
// 员工标签 // 员工标签
var tagAuth = xmSelect.render({ var tagAuth = xmSelect.render({
el: '#tagAuth', el: '#tagAuth',
prop: { prop: {
name: 'name', name: 'name',
value: 'value' value: 'value'
},
// layVerify: `${qs('channel') ? '' : 'required'}`,
// model: {
// label: {
// type: 'text',
// text: {}
// }
// },
name: 'staffLabel',
selected: true,
data: [
{
name: '1.0新车权益销售',
value: '0'
},
{
name: '1.1次新车精品升级',
value: '1'
}, },
{ // layVerify: `${qs('channel') ? '' : 'required'}`,
name: '1.2次新车线上转化', // model: {
value: '2' // label: {
}, // type: 'text',
{ // text: {}
name: '1.3存量用户众筹', // }
value: '3' // },
name: 'staffLabel',
selected: true,
data: [
{
name: '1.0车损升级',
value: '0'
},
{
name: '1.1精品升级',
value: '1'
},
{
name: '1.2膨胀金活动',
value: '2'
},
{
name: '1.3众筹活动',
value: '3'
}
],
on: function (data) {
staffLabel = data.change[0].value
} }
], })
on: function (data) {
staffLabel = data.change[0].value
}
})
var merchantNameSelect = xmSelect.render({ var merchantNameSelect = xmSelect.render({
el: '#merchantNameSelect', el: '#merchantNameSelect',
prop: { prop: {
name: 'merchantName', name: 'merchantName',
value: 'id' value: 'id'
}, },
layVerify: `${qs('channel') ? '' : 'required'}`, layVerify: `${qs('channel') ? '' : 'required'}`,
model: { model: {
label: { label: {
type: 'text', type: 'text',
text: {} text: {}
}
},
name: 'merchantId',
filterable: true,
clickClose: true,
radio: true,
data: [],
on: function (data) {
merchantId = data.change[0].id
getList(merchantId)
} }
}, })
name: 'merchantId', if (accountInfo && !id) {
filterable: true, $('#btnGroup').addClass('show')
clickClose: true,
radio: true,
data: [],
on: function (data) {
merchantId = data.change[0].id
getList(merchantId)
} }
}) // 判断是从商户过来还是员工
if (accountInfo && !id) { if (qs('channel')) {
$('#btnGroup').addClass('show') getList(qs('merchantId'))
} merchantId = qs('merchantId')
// 判断是从商户过来还是员工
if (qs('channel')) {
getList(qs('merchantId'))
merchantId = qs('merchantId')
$('#merchantIdText').text(decodeURIComponent(qs('merchantName')))
$('#merchantIdText').removeClass('hide')
$('#merchantIdText').addClass('show')
$('#merchantNameSelect').addClass('hide')
$('#staffPhone').removeAttr('disabled')
} else {
if (qs('id')) {
// 判断是否是编辑
resetpsw.removeClass('hide')
resetpsw.addClass('show')
wechatNick.removeClass('hide')
wechatNick.addClass('show')
wechatPhone.removeClass('hide')
wechatPhone.addClass('show')
wechatId.removeClass('hide')
wechatId.addClass('show')
merchantId = encodeURI(qs('merchantId'))
$('#merchantIdText').text(decodeURIComponent(qs('merchantName'))) $('#merchantIdText').text(decodeURIComponent(qs('merchantName')))
$('#merchantIdText').removeClass('hide') $('#merchantIdText').removeClass('hide')
$('#merchantIdText').addClass('show') $('#merchantIdText').addClass('show')
$('#staffPhone').attr('disabled', true) $('#merchantNameSelect').addClass('hide')
getList(qs('merchantId')) $('#staffPhone').removeAttr('disabled')
$('#addUpdateTitle').text('修改员工') } else {
$('#merchantNameSelect').remove() if (qs('id')) {
} // 判断是否是编辑
findAllMerchant(function (result) { resetpsw.removeClass('hide')
if (accountInfo && accountInfo.merchantAccountLevel == 4) { resetpsw.addClass('show')
const merchantName = result[0].merchantName wechatNick.removeClass('hide')
$('#merchantIdText').text(merchantName) wechatNick.addClass('show')
merchantId = result[0].id wechatPhone.removeClass('hide')
form.render() wechatPhone.addClass('show')
wechatId.removeClass('hide')
wechatId.addClass('show')
merchantId = encodeURI(qs('merchantId'))
$('#merchantIdText').text(decodeURIComponent(qs('merchantName')))
$('#merchantIdText').removeClass('hide') $('#merchantIdText').removeClass('hide')
$('#merchantIdText').addClass('show') $('#merchantIdText').addClass('show')
$('#staffPhone').attr('disabled', true)
getList(qs('merchantId'))
$('#addUpdateTitle').text('修改员工')
$('#merchantNameSelect').remove() $('#merchantNameSelect').remove()
getList(merchantId)
} }
}) findAllMerchant(function (result) {
} if (accountInfo && accountInfo.merchantAccountLevel == 4) {
const merchantName = result[0].merchantName
$('#merchantIdText').text(merchantName)
merchantId = result[0].id
form.render()
$('#merchantIdText').removeClass('hide')
$('#merchantIdText').addClass('show')
$('#merchantNameSelect').remove()
getList(merchantId)
}
})
}
/** 手动触发事件 */ /** 手动触发事件 */
// 上传图片 // 上传图片
$('.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('')
}) })
var checkAll = false var checkAll = false
var checkBtn = $('#checkAll') var checkBtn = $('#checkAll')
// 全选可见商户 // 全选可见商户
checkBtn.on('click', function () { checkBtn.on('click', function () {
if (!merchantId) { if (!merchantId) {
layer.msg('请选择所属商户!') layer.msg('请选择所属商户!')
} else {
checkAll = !checkAll
visibleMerchant.checkAllNodes(checkAll)
if (checkAll) {
checkBtn.html('全不选')
} else { } else {
checkBtn.html('全选') checkAll = !checkAll
visibleMerchant.checkAllNodes(checkAll)
if (checkAll) {
checkBtn.html('全不选')
} else {
checkBtn.html('全选')
}
} }
} })
})
// 刷新 // 刷新
$('#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) {
if (specialVisible != '-1' && visibleMerchant.getCheckedNodes(true).length == 0) { if (specialVisible != '-1' && visibleMerchant.getCheckedNodes(true).length == 0) {
layer.msg('可见商户必选', { layer.msg('可见商户必选', {
icon: 2 icon: 2
})
return false
}
var visibleInferiorMer = ''
if (specialVisible == '-1') {
visibleInferiorMer = '-1'
} else {
visibleInferiorMer = visibleMerchant
.getCheckedNodes(true)
.map(function (i) {
return i.id
}) })
.join(',') return false
} }
var visibleInferiorMer = ''
if (specialVisible == '-1') {
visibleInferiorMer = '-1'
} else {
visibleInferiorMer = visibleMerchant
.getCheckedNodes(true)
.map(function (i) {
return i.id
})
.join(',')
}
var otherParams = { var otherParams = {
visibleInferiorMer: visibleInferiorMer, visibleInferiorMer: visibleInferiorMer,
merchantId: merchantId merchantId: merchantId
} }
if (merchantFileRequest.fileName) { if (merchantFileRequest.fileName) {
otherParams.merchantFileRequest = JSON.stringify(merchantFileRequest) otherParams.merchantFileRequest = JSON.stringify(merchantFileRequest)
}
if (id) {
otherParams.id = id
otherParams.method = 'merchants.api.staff.updateStaff'
} else {
otherParams.method = 'merchants.api.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()
} }
if (id) {
otherParams.id = id
otherParams.method = 'merchants.api.staff.updateStaff'
} else {
otherParams.method = 'merchants.api.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
})
// 表单验证 // 表单验证
form.verify({ form.verify({
merchantLoginPassword: function (value) { merchantLoginPassword: function (value) {
if (value) { if (value) {
if (value.length < 6 || value.length > 20) { if (value.length < 6 || value.length > 20) {
return '登录密码请填入6-20位字符' return '登录密码请填入6-20位字符'
} }
if (!/^(?=.*\d)(?=.*[a-zA-Z])[\s\S]{6,20}$/.test(value)) { if (!/^(?=.*\d)(?=.*[a-zA-Z])[\s\S]{6,20}$/.test(value)) {
return '您输入的密码格式不正确,必须同时包含字母、数字。' return '您输入的密码格式不正确,必须同时包含字母、数字。'
}
} }
} }
}, })
})
// select 选择触发 // select 选择触发
form.on('select(merchants)', function (data) { form.on('select(merchants)', function (data) {
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: 'merchants.api.merchant.findMerchantTree' } var visibleMerchantParams = { id: merchantId, method: 'merchants.api.merchant.findMerchantTree' }
request(visibleMerchantParams, function (res) { request(visibleMerchantParams, function (res) {
if (res.code == '0') { if (res.code == '0') {
const data = res.data const data = res.data
if (id) { if (id) {
findAllMerchant(function (result) { findAllMerchant(function (result) {
if (result) { if (result) {
getById(function (checkedList) { getById(function (checkedList) {
if (data.length == 1 && data[0].id == -1) { if (data.length == 1 && data[0].id == -1) {
$('#allMerchant').removeClass('hide') $('#allMerchant').removeClass('hide')
specialVisible = data[0].id specialVisible = data[0].id
// createMerchant(data[0].id, data) // createMerchant(data[0].id, data)
$('#otherMerchant').addClass('hide') $('#otherMerchant').addClass('hide')
} else { } else {
createMerchant(checkedList, res.data)
createMerchant(checkedList, res.data) }
} })
}) }
} })
})
} else {
if (data.length == 1 && data[0].id == -1) {
$('#allMerchant').removeClass('hide')
specialVisible = data[0].id
// createMerchant(data[0].id, data)
$('#otherMerchant').addClass('hide')
} else { } else {
const arr = [] if (data.length == 1 && data[0].id == -1) {
arr.push(+merchantId) $('#allMerchant').removeClass('hide')
createMerchant(arr, res.data) specialVisible = data[0].id
specialVisible = '' // createMerchant(data[0].id, data)
$('#otherMerchant').removeClass('hide') $('#otherMerchant').addClass('hide')
$('#allMerchant').addClass('hide') } else {
const arr = []
arr.push(+merchantId)
createMerchant(arr, res.data)
specialVisible = ''
$('#otherMerchant').removeClass('hide')
$('#allMerchant').addClass('hide')
}
} }
} }
} })
}) }
}
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)
visibleMerchant.checkNodes(arr) all_nodes = visibleMerchant.transformToArray(visibleMerchant.getNodes())
all_nodes = visibleMerchant.transformToArray(visibleMerchant.getNodes()) bindEvent()
bindEvent() }
}
// 查询所有商户
function findAllMerchant(callback) {
var params = { method: 'merchants.api.menu.findAllMerchant' }
request(params, function (result) {
if (result.code == '0') {
merchantNameSelect.update({
data: result.data,
autoRow: true,
paging: result.data.length > 20
})
// merchantNameSelect.setValue([merchantId])
// var list = result.data
// list.unshift('')
// $.each(list, function (index, item) {
// merchantName.append(new Option(item.merchantName, item.id))
// })
// form.render('select')
callback(result.data)
}
})
}
// 查询角色权限列表
function findRoleList(merchantId) {
var params = { method: 'merchants.api.role.list', id: merchantId, delFlag: 0 }
request(params, function (res) {
if (res.code == '0') {
var list = res.data
roleAuth.empty()
list.unshift('')
$.each(list, function (index, item) {
roleAuth.append(new Option(item.roleName, item.id))
})
form.render('select')
}
})
}
function getById(callback) { // 查询所有商户
// 查询员工详情 function findAllMerchant(callback) {
var params = { id: id, method: 'merchants.api.staff.staffSearchRequest' } var params = { method: 'merchants.api.menu.findAllMerchant' }
pwd.attr('readonly', true) request(params, function (result) {
request(params, function (res) { if (result.code == '0') {
if (res.code == '0') { merchantNameSelect.update({
var data = res.data data: result.data,
employeeForm = { autoRow: true,
id: 8, paging: result.data.length > 20
merchantId: data.merchantId, })
staffName: data.staffName, // merchantNameSelect.setValue([merchantId])
staffPhone: data.staffPhone, // var list = result.data
password: data.password, // list.unshift('')
// visibleInferiorMer: "1", // $.each(list, function (index, item) {
roleIds: data.roleIds ? +data.roleIds.join('') : '', // merchantName.append(new Option(item.merchantName, item.id))
staffEmail: data.staffEmail, // })
staffJob: data.staffJob, // form.render('select')
department: data.department, callback(result.data)
weChatNickName: data.weChatNickName,
weChatPhone: data.weChatPhone,
weChatOpenId: data.weChatOpenId
}
if (data.staffLabel) {
var item = data.staffLabel.split(','.toString())
tagAuth.setValue(item)
} }
if (data.merchantFileResponse) { })
merchantFileRequest = { fileName: data.merchantFileResponse.fileName, fileUrl: data.merchantFileResponse.fileUrl } }
$('#img').attr('src', merchantFileRequest.fileUrl)
$('#img').removeClass('hide') // 查询角色权限列表
$('#img').addClass('show') function findRoleList(merchantId) {
$('.img-add').removeClass('show') var params = { method: 'merchants.api.role.list', id: merchantId, delFlag: 0 }
$('.img-add').addClass('hide') request(params, function (res) {
if (res.code == '0') {
var list = res.data
roleAuth.empty()
list.unshift('')
$.each(list, function (index, item) {
roleAuth.append(new Option(item.roleName, item.id))
})
form.render('select')
} }
var visibleInferiorMerArr = data.visibleInferiorMer ? data.visibleInferiorMer.split(',') : [] })
$.each(visibleInferiorMerArr, function (index, item) { }
visibleInferiorMerArr[index] = +item
})
// var visibleInferiorMerArr = [32, 38]
callback(visibleInferiorMerArr)
}
form.val('employeeForm', employeeForm)
form.render('select')
if (!$('#staffPhone').val()) {
$('#staffPhone').removeAttr('disabled')
}
})
}
function bindEvent() { function getById(callback) {
$('#searchMerchant').on( // 查询员工详情
'input', var params = { id: id, method: 'merchants.api.staff.staffSearchRequest' }
helper.debounce(function () { pwd.attr('readonly', true)
var txt = $(this).val() request(params, function (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,
department: data.department,
weChatNickName: data.weChatNickName,
weChatPhone: data.weChatPhone,
weChatOpenId: data.weChatOpenId
}
if (data.staffLabel) {
var item = data.staffLabel.split(','.toString())
tagAuth.setValue(item)
}
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)
} }
}, 500) form.val('employeeForm', employeeForm)
) form.render('select')
} if (!$('#staffPhone').val()) {
}) $('#staffPhone').removeAttr('disabled')
</script> }
</body> })
}
</html>
\ No newline at end of file \ No newline at end of file
function bindEvent() {
$('#searchMerchant').on(
'input',
helper.debounce(function () {
var txt = $(this).val()
if (!txt) {
visibleMerchant.showNodes(all_nodes)
} else {
var nodesList = visibleMerchant.getNodesByParamFuzzy('label', txt)
show_nodes = helper.findShowNode(nodesList, all_nodes)
visibleMerchant.hideNodes(all_nodes)
visibleMerchant.showNodes(show_nodes)
}
}, 500)
)
}
})
</script>
</body>
</html>
...@@ -411,16 +411,16 @@ ...@@ -411,16 +411,16 @@
employeeData.staffLabel.map((item, index) => { employeeData.staffLabel.map((item, index) => {
switch (item) { switch (item) {
case '0': case '0':
employeeData.staffLabel[index] = '1.0新车权益销售' employeeData.staffLabel[index] = '1.0车损升级'
break break
case '1': case '1':
employeeData.staffLabel[index] = '1.1次新车精品升级' employeeData.staffLabel[index] = '1.1精品升级'
break break
case '2': case '2':
employeeData.staffLabel[index] = '1.2次新车线上转化' employeeData.staffLabel[index] = '1.2膨胀金活动'
break break
case '3': case '3':
employeeData.staffLabel[index] = '1.3存量用户众筹' employeeData.staffLabel[index] = '1.3众筹活动'
break break
default: default:
employeeData.staffLabel[index] = '无' employeeData.staffLabel[index] = '无'
......
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.
...@@ -55,26 +55,33 @@ layui.define(['sha1', 'md5', 'helper'], function (exports) { ...@@ -55,26 +55,33 @@ layui.define(['sha1', 'md5', 'helper'], function (exports) {
function request(params, success, config, noSignAttr, isOtherUrl) { function request(params, success, config, noSignAttr, isOtherUrl) {
noSignAttr = noSignAttr || [] noSignAttr = noSignAttr || []
params = params || {} params = params || {}
params.sessionAuth = 'st'
config = config || {} config = config || {}
var common = store.getEx('external') var common = store.getEx('external')
var settings = helper.clone(true, defaultSettings) var settings = helper.clone(true, defaultSettings)
var data = helper.clone(true, { var data = helper.clone(
timestamp: new Date().getTime() true,
}, common.params, params) {
timestamp: new Date().getTime()
},
common.params,
params
)
if (isOtherUrl) { if (isOtherUrl) {
data.app_key = data.appKey data.app_key = data.appKey
delete settings.beforeSend delete settings.beforeSend
delete data.appKey delete data.appKey
} }
data.sign = sign(data, common.secret, noSignAttr, isOtherUrl) data.sign = sign(data, common.secret, noSignAttr, isOtherUrl)
settings.url = isOtherUrl ? (common.fileUploadURL + '?method=' + params.method) : common.baseURL settings.url = isOtherUrl ? common.fileUploadURL + '?method=' + params.method : common.baseURL
settings.data = data settings.data = data
settings.success = function (result) { settings.success = function (result) {
if (result.code == '0' || result.returnCode == '0') { if (result.code == '0' || result.returnCode == '0') {
success && success(result) success && success(result)
} else { } else {
msg(result.message) msg(result.message)
if (result.errId == '21') { //TGT失效 if (result.errId == '21') {
//TGT失效
goLogin && goLogin() goLogin && goLogin()
} }
} }
...@@ -133,4 +140,4 @@ layui.define(['sha1', 'md5', 'helper'], function (exports) { ...@@ -133,4 +140,4 @@ layui.define(['sha1', 'md5', 'helper'], function (exports) {
layer.msg(msg) layer.msg(msg)
} }
exports('request', request) exports('request', request)
})
\ 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!