Commit 3602e96f by 胡悦

修改样式

1 parent df3057dd
...@@ -11,7 +11,7 @@ html, body { ...@@ -11,7 +11,7 @@ html, body {
flex-direction: column; flex-direction: column;
height: 100%; height: 100%;
background-color: #F4F5FA; background-color: #F4F5FA;
padding: 0 20px 20px 40px; padding: 0 20px 0 40px;
} }
header { header {
...@@ -100,9 +100,9 @@ main { ...@@ -100,9 +100,9 @@ main {
/* -ms-scroll-chaining: chained; /* -ms-scroll-chaining: chained;
-ms-overflow-style: none; */ -ms-overflow-style: none; */
} }
.context-block { /* .context-block {
height: 100%; height: 100%;
} } */
.search-block { .search-block {
/* padding: 8px 20px; */ /* padding: 8px 20px; */
position: relative; position: relative;
...@@ -157,4 +157,47 @@ footer { ...@@ -157,4 +157,47 @@ footer {
left:0; left:0;
height: 64px; height: 64px;
line-height: 64px; line-height: 64px;
}
.layui-tab-title {
background-color: #F4F6FC;
border-radius: 4px;
border: none;
}
.layui-tab-title .layui-this:after {
border: none;
}
.layui-tab-brief>.layui-tab-title .layui-this,
.layui-tab-title .layui-this {
color: #5850FF;
background-color: #fff;
}
.layui-tab-title .layui-this {
transform: scale(0.97, 0.9);
}
.layui-tab-title,.layui-tree-box .layui-this {
transform: scale(1);
}
.layui-tab-title li {
width: 180px;
}
.layui-tab-content {
/* margin-top: 20px; */
background-color: #fff;
}
.layui-tab-content .layui-form-pane .layui-form-label {
background-color: #fff;
border: none !important;
}
.layui-tree-box {
padding: 10px;
background-color: #F4F6FC;
}
.layui-tab-form {
margin-top: 20px;
}
.layui-top-tab.layui-tab-brief>.layui-tab-title .layui-this {
background-color: #F4F6FC;
}
.m-t-md {
margin-top: 20px;
} }
\ No newline at end of file \ No newline at end of file
...@@ -90,6 +90,8 @@ ...@@ -90,6 +90,8 @@
// if (isDxternal) { // if (isDxternal) {
// $('#addEl').remove() // $('#addEl').remove()
// } // }
var accountInfo = helper.store.get('accountInfo')
console.log('accountInfo', accountInfo)
// 商户名称列表 // 商户名称列表
var merchantName = $('#merchantName') var merchantName = $('#merchantName')
var status = $('#status') var status = $('#status')
...@@ -123,12 +125,11 @@ ...@@ -123,12 +125,11 @@
{ fixed: 'right', title: '操作', width: 220, align: 'left', toolbar: '#employeeBar' }, { fixed: 'right', title: '操作', width: 220, align: 'left', toolbar: '#employeeBar' },
{ field: 'statusName', title: '启用开关', width: 85, templet: '#switchTpl', unresize: true } { field: 'statusName', title: '启用开关', width: 85, templet: '#switchTpl', unresize: true }
] ]
var gl = false
//创建table实例 //创建table实例
var employeeTable = table.render({ var employeeTable = table.render({
elem: '#employeeTable', elem: '#employeeTable',
skin: 'nob', skin: 'nob',
cols: gl ? [cols] : [colums], cols: accountInfo ? [colums] : [cols],
done: function (res, curr, count) { done: function (res, curr, count) {
$('.switch').hover( $('.switch').hover(
function () { function () {
...@@ -234,11 +235,27 @@ ...@@ -234,11 +235,27 @@
//监听性别操作 //监听性别操作
form.on('switch(sexDemo)', function (obj) { form.on('switch(sexDemo)', function (obj) {
console.log(obj, obj.elem.checked)
if (this.value == '-') { if (this.value == '-') {
obj.elem.checked = false obj.elem.checked = !obj.elem.checked
form.render('checkbox') form.render('checkbox')
layer.msg('您还未给该员工设置“角色”!\n\ layer.msg('您还未给该员工设置“角色”!\n\
设置角色:员工账户管理-修改-角色权限', { time: 2000 }) 设置角色:员工账户管理-修改-角色权限', { time: 2000 })
} else {
const param = {
id: obj.elem.dataset.id,
status: obj.elem.checked ? 0 : 2
}
var params = helper.clone(false, { method: 'cn.com.glsx.merchants.staff.updateStatus' }, param)
request(params, function (res) {
if (res.code == '0') {
layer.msg('操作成功', {
icon: 1
})
var searchData = getSearch()
getTabelList(employeeTable, searchData, true)
}
})
} }
}) })
...@@ -363,7 +380,7 @@ ...@@ -363,7 +380,7 @@
</script> </script>
<script type="text/html" id="switchTpl"> <script type="text/html" id="switchTpl">
<!-- 这里的 checked 的状态只是演示 --> <!-- 这里的 checked 的状态只是演示 -->
<div class="switch"><input type="checkbox" name="sex" value="{{d.roleName}}" lay-skin="switch" lay-text="开|关" lay-filter="sexDemo" {{ d.statusName == '1' ? 'checked' : '' }}></div> <div class="switch"><input type="checkbox" name="sex" value="{{d.roleName}}" data-id="{{d.id}}" lay-skin="switch" lay-text="开|关" lay-filter="sexDemo" {{ d.status == 0 ? 'checked' : '' }}></div>
</script> </script>
</body> </body>
</html> </html>
...@@ -134,12 +134,15 @@ ...@@ -134,12 +134,15 @@
.edit-box #accountTypeEl .layui-form-checked span, .edit-box #accountTypeEl .layui-form-checked span,
#accountTypeEl .layui-form-checked:hover span { #accountTypeEl .layui-form-checked:hover span {
background-color: #1989fa !important; background-color: #5850FF !important;
} }
.edit-box #accountTypeEl .layui-form-checked i, .edit-box #accountTypeEl .layui-form-checked i,
#accountTypeEl .layui-form-checked:hover i { #accountTypeEl .layui-form-checked:hover i {
color: #1989fa !important; color: #5850FF !important;
}
.layui-form-radio:hover *, .layui-form-radioed, .layui-form-radioed>i {
color: #5850FF !important;
} }
.pageTitle { .pageTitle {
background-color: #fff; background-color: #fff;
...@@ -186,7 +189,7 @@ ...@@ -186,7 +189,7 @@
line-height: 28px; line-height: 28px;
} }
#basicForm { #basicForm {
margin-bottom: 50px; margin-bottom: 87px;
} }
</style> </style>
<title>商户编辑</title> <title>商户编辑</title>
...@@ -701,6 +704,7 @@ ...@@ -701,6 +704,7 @@
}) })
form.on('submit(handleFirstSubmit)', function (data) { form.on('submit(handleFirstSubmit)', function (data) {
console.log(data)
var formData = data.field var formData = data.field
var params = { var params = {
isloginName: 0 isloginName: 0
...@@ -717,7 +721,8 @@ ...@@ -717,7 +721,8 @@
'merchantLoginAccount', 'merchantLoginAccount',
'merchantLoginPassword', 'merchantLoginPassword',
'merchantAccountLevel', 'merchantAccountLevel',
'effectiveTime' 'effectiveTime',
'merchantModel'
] ]
if (formData.isloginName == 'on') { if (formData.isloginName == 'on') {
params.isloginName = 1 params.isloginName = 1
...@@ -1442,14 +1447,15 @@ ...@@ -1442,14 +1447,15 @@
id: id id: id
}) })
var getTpl = var getTpl =
`<form class="layui-form layui-form-pane" action=""> `<form class="layui-form layui-form-pane layui-tab-form" 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}">
</div> </div>
</div> </div>
</form> </form>
<div class="layui-tab layui-tab-brief" lay-filter="treeTab{{d.id}}"> <div>请选择产品权限</div>
<div class="layui-tab layui-tree-box" lay-filter="treeTab{{d.id}}">
<ul class="layui-tab-title"></ul> <ul class="layui-tab-title"></ul>
<div class="layui-tab-content"> <div class="layui-tab-content">
<div class="layui-no-data show" id="nodata${id}"> <div class="layui-no-data show" id="nodata${id}">
......
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8" />
<meta content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="广联帐户管理中心-员工管理" />
<meta name="author" content="GLSX Web Team" />
<meta name="keywords" itemprop="keywords" content="广联,帐户管理,员工管理" />
<link rel="stylesheet" type="text/css" href="/css/main.css" />
<style>
.clearfix {
zoom: 1;
}
.clearfix::after {
content: "";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
.edit-box {
/* width: 1046px; */
padding: 20px 20px;
color: #333333;
background-color: #ffffff;
margin: 15px auto;
position: relative;
}
.edit-box .grayLine {
position: absolute;
left: 0;
top: 68px;
background-color: #d8d8d8;
width: 100%;
height: 1px;
}
.edit-title {
height: 48px;
line-height: 48px;
padding: 0 10px;
margin-bottom: 15px;
font-size: 16px;
font-weight: 600;
/* background: #f7f7f7; */
}
.edit-box .layui-form-label {
width: 130px;
}
.edit-box .layui-form-item .layui-input-inline {
width: 320px;
}
.edit-box .layui-form-item .layui-input-inline.w-70 {
width: 70%;
}
.edit-box .layui-form-item .layui-input-inline.w-70 #addrEl {
width: calc(100% - 200px);
display: inline-block;
}
.edit-box .btn-no-border {
border: none;
}
.edit-box .upload-img-box {
position: relative;
color: #999999;
border: 1px dashed #d9d9d9;
cursor: pointer;
}
.edit-box .upload-img-box .upload-img {
position: absolute;
top: 0;
left: 0;
}
.edit-box .icon-add {
position: absolute;
top: 45%;
font-size: 40px;
left: 50%;
transform: translate3d(-50%, -50%, 0);
}
.edit-box .m-t-10 {
margin-top: 10px;
}
.edit-box .upload-img-wh {
width: 120px !important;
height: 80px;
}
.show {
display: inline-block;
}
.hide {
display: none;
}
.option-btns {
height: 38px;
}
.wrap-add-signal {
margin-top: 11px;
background-color: #1989fa;
color: #fff;
height: 16px;
line-height: 16px;
text-align: center;
width: 16px;
border-radius: 50%;
}
.tips {
display: inline-block;
font-size: 14px;
color: #999;
margin-left: 160px;
margin-top: 8px;
}
.form-right {
position: absolute;
right: 0;
top: 0;
transform: translateX(110%);
}
.edit-box #accountTypeEl .layui-form-checked span,
#accountTypeEl .layui-form-checked:hover span {
background-color: #5850FF !important;
}
.edit-box #accountTypeEl .layui-form-checked i,
#accountTypeEl .layui-form-checked:hover i {
color: #5850FF !important;
}
.layui-form-radio:hover *, .layui-form-radioed, .layui-form-radioed>i {
color: #5850FF !important;
}
.pageTitle {
background-color: #fff;
height: 78px;
font-size: 20px;
font-weight: bold;
color: #333333;
line-height: 78px;
padding: 0 20px;
width: 100%;
}
/* .Wrap {
margin: 8px auto 0;
width: 1046px;
} */
.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;
}
.layuui-radio {
display: inline-flex;
align-items: center;
margin-right: 20px;
}
.layuui-radio .layui-form-radio {
margin: 0;
}
.layuui-radio span {
line-height: 28px;
}
#basicForm {
margin-bottom: 87px;
}
</style>
<title>商户编辑</title>
</head>
<body>
<div id="app">
<main>
<div class="Wrap">
<div class="pageTitle">
<span id="addUpdateTitle">创建商户</span>
</div>
<!-- <div class="edit-box"> -->
<!-- 基本信息 -->
<div id="basicForm">
<form class="layui-form layui-row" lay-filter="merchantForm">
<div class="edit-box clearfix">
<div class="grayLine"></div>
<div class="layui-form-item edit-title" style="position: relative">
<div class="layui-input-inline">企业基本信息</div>
</div>
<div class="layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label required">商户名称:</label>
<div class="layui-input-inline">
<input class="layui-input" maxlength="50" name="merchantName" required lay-verify="required" placeholder="请输入商户名称" />
</div>
</div>
</div>
<div class="layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">商户简称:</label>
<div class="layui-input-inline">
<input class="layui-input" maxlength="15" name="merchantAbbreviation" placeholder="请输入商户简称" />
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">商户类型:</label>
<div class="layui-input-inline" style="width: 100px; margin: 0">
<select name="merchantType" id="merchantTypeEl" lay-filter="merchantTypeFilter">
<option value="1">个人</option>
<option value="2">企业</option>
</select>
</div>
<div class="layui-input-inline" style="width: 220px">
<input class="layui-input" maxlength="50" lay-verify="merchantOrgcode" name="merchantOrgcode" id="merchantOrgcodeEl" placeholder="请输入身份证号码" />
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">商户地址:</label>
<div class="layui-input-inline w-70">
<input style="color: #333333 !important;" name="merchantAddress" disabled
class="layui-input layui-btn-disabled" id="addrEl" placeholder="请选择商户地址">
<!-- <div class="m-t-10" id="addrEl">请选择商户地址</div> -->
<button type="button" class="layui-btn" data-type="handleSelectAddr">选择地址</button>
</div>
</div>
<!-- <div class="layui-form-item">
<label class="layui-form-label"></label>
<div class="layui-input-inline">
<button type="button" class="layui-btn" data-type="handleSelectAddr">选择地址</button>
</div>
</div> -->
<div class="layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label required">联系电话:</label>
<div class="layui-input-inline">
<input class="layui-input" name="merchantLegalPersonPhone" maxlength="11" required lay-verify="required|phone" placeholder="请输入联系电话" />
<input type="checkbox" name="isloginName" lay-filter="encrypt" lay-skin="primary" title="联系电话同时作为登录账户名" />
</div>
</div>
</div>
<div class="layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">联系人:</label>
<div class="layui-input-inline">
<input class="layui-input" maxlength="15" name="merchantLegalPerson" placeholder="请输入联系人姓名" />
<div style="width: 100%; height: 28px;"></div>
</div>
</div>
</div>
<div class="layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">驻店联系人:</label>
<div class="layui-input-inline">
<input class="layui-input" name="residentContact" maxlength="15" placeholder="请输入驻店联系人" />
</div>
</div>
</div>
<div class="layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">驻店电话:</label>
<div class="layui-input-inline">
<input class="layui-input" name="residentPhone" maxlength="11" placeholder="请输入驻店电话" lay-verify="residentPhone" />
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">营业时间:</label>
<div class="layui-inline">
<div class="layui-input-inline">
<input type="text" id="startDate" class="layui-input" name="bussinessBegintime" placeholder="开始时间" />
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline">
<input type="text" id="endDate" class="layui-input" name="bussinessEndtime" placeholder="结束时间" />
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">营业范围:</label>
<div class="layui-input-inline" id="busiScopeEl"></div>
</div>
<div class="layui-form-item" id="custom-scope">
<div class="layui-form-item">
<label class="layui-form-label"></label>
<div>
<div class="layui-input-inline">
<input id="scopeCus" class="layui-input business-scope-cust" maxlength="15" placeholder="请自定义营业范围,建议不超过10个" />
</div>
<div class="layui-input-inline option-btns">
<button type="button" class="layui-btn btn-no-border" data-type="handleAddScope">
<i class="layui-icon layui-icon-add-circle scope-btn"></i>
</button>
<!-- <div class="wrap-add-signal" data-type="handleAddScope">
<i class="layui-icon">&#xe654</i>
</div> -->
</div>
</div>
</div>
</div>
<div class="layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">主营品牌:</label>
<div class="layui-input-inline">
<input class="layui-input" placeholder="车型品牌" id="brand" />
<div id="carBrandTree" style="height: 200px; overflow-y: scroll"></div>
</div>
</div>
</div>
<div class="layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label">门店照片:</label>
<div class="layui-input-inline upload-img-wh">
<div class="upload-img-box">
<div class="icon-add img-add0 show">+</div>
<img class="upload-img upload-img-wh hide" id="img0" src="" />
<input
type="file"
id="upload0"
name="merhcnatImg0"
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>
</div>
<div class="layui-input-inline upload-img-wh">
<div class="upload-img-box">
<div class="icon-add img-add1 show">+</div>
<img class="upload-img upload-img-wh hide" id="img1" src="" />
<input
type="file"
id="upload1"
name="merhcnatImg1"
ref="file"
class="upload upload-img-box upload-img-wh"
accept="image/png, image/jpeg, image/gif, image/jpg"
data-idx="1"
style="opacity: 0"
/>
</div>
</div>
<div class="layui-input-inline upload-img-wh">
<div class="upload-img-box">
<div class="icon-add img-add2 show">+</div>
<img class="upload-img upload-img-wh hide" id="img2" src="" />
<input
type="file"
id="upload2"
name="merhcnatImg2"
ref="file"
class="upload upload-img-box upload-img-wh"
accept="image/png, image/jpeg, image/gif, image/jpg"
data-idx="2"
style="opacity: 0"
/>
</div>
</div>
<span class="tips">图片格式仅支持JPG,PNG格式,大小1M以内</span>
</div>
</div>
</div>
<div class="edit-box">
<p class="edit-title">账户基本信息</p>
<div class="grayLine"></div>
<div id="subMerchantEl" class="layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label required">上级商户:</label>
<div class="layui-input-inline">
<!-- <input class="layui-input layui-btn-disabled" name="parentName" placeholder="请输入上级商户" disabled> -->
<div class="m-t-10" id="parentName"></div>
</div>
</div>
</div>
<div id="subMerchantModel" class="layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label required">上级商户模式:</label>
<div class="layui-input-inline">
<!-- <input class="layui-input layui-btn-disabled" name="parentName" placeholder="请输入上级商户" disabled> -->
<div class="m-t-10" id="merchantModelName"></div>
</div>
</div>
</div>
<div class="layui-form-item hide" id="effectiveShowEl">
<label class="layui-form-label">账户有效期:</label>
<div class="layui-inline">
<div class="layui-input-inline">
<input type="text" id="effectiveStarttime" class="layui-input" name="effectiveStarttime" placeholder="开始时间" />
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline">
<input type="text" id="expireDate" class="layui-input" name="expireDate" placeholder="结束时间" />
</div>
<button id="sevenday" type="button" class="layui-btn btn-no-border">续7天</button>
<button id="oneyear" type="button" class="layui-btn btn-no-border">续1年</button>
<button id="twoyears" type="button" class="layui-btn btn-no-border">续2年</button>
</div>
</div>
<div class="layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label required">登录账户名:</label>
<div class="layui-input-inline">
<input
class="layui-input"
id="merchantLoginAccountEl"
name="merchantLoginAccount"
maxlength="15"
placeholder="请输入登录账户名"
required
lay-verify="required|merchantLoginAccount"
/>
</div>
</div>
</div>
<div class="layui-col-md6">
<div class="layui-form-item">
<label class="layui-form-label required">登录密码:</label>
<div class="layui-input-inline">
<input
class="layui-input"
type="password"
id="password"
name="merchantLoginPassword"
maxlength="15"
placeholder="请输入登录密码"
required
lay-verify="required|merchantLoginPassword"
/>
<button type="button" class="layui-btn form-right hide" id="resetpsw">重置密码</button>
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label required">账户等级:</label>
<div class="layui-input-inline">
<select id="accountLevelEl" name="merchantAccountLevel" required lay-vertify="required" lay-search></select>
</div>
</div>
<!-- <div class="layui-form-item" id="effectiveShowEl">
<label class="layui-form-label required">账户有效期:</label>
<div class="layui-input-inline">
<select id="validPeriodEl" name="effectiveTime" required lay-vertify="required" lay-search></select>
</div>
</div> -->
<div class="layui-form-item">
<label class="layui-form-label required">账户类型:</label>
<div class="layui-input-inline w-70" id="accountTypeEl"></div>
</div>
<div class="footer-close">
<button id="firstBtn" class="layui-btn" lay-submit lay-filter="handleFirstSubmit">下一步</button>
<button type="reset" class="layui-btn" data-type="handleCancel">取消</button>
</div>
</div>
</form>
</div>
</div>
<!-- 权限树 -->
<div id="authorityTree">
<div class="edit-box">
<!-- 树 -->
<!-- <div class="layui-form-item">
<label class="layui-form-label required">角色权限:</label>
<div class="layui-input-block" id="accountType"> -->
<!-- <input lay-filter="switch" type="checkbox" name="merchantId" value="1" title="引流渠道商" />
<input lay-filter="switch" type="checkbox" name="merchantId" value="2" title="服务商/合作商" /> -->
<!-- </div>
</div> -->
<div class="layui-tab" lay-filter="roleAuth">
<ul class="layui-tab-title"></ul>
<div class="layui-tab-content"></div>
</div>
<div class="footer-close">
<button id="draft" class="layui-btn">存草稿</button>
<button id="preStep" class="layui-btn">上一步</button>
<button id="confirm" class="layui-btn">确定</button>
<button class="layui-btn" data-type="handleCancel">取消</button>
</div>
</div>
</div>
</main>
</div>
<script src="https://www.layuicdn.com/layui/layui.js"></script>
<script src="/js/load.js"></script>
<script src="/js/validator.js"></script>
<script>
layui.use(['gtree', 'request', 'helper', 'layer', 'laydate', 'element', 'xmSelect', 'laytpl', 'validator'], function () {
var tree = layui.gtree
var request = layui.request
var form = layui.form
var laydate = layui.laydate
var $ = layui.$
var validator = layui.validator
var helper = layui.helper
var element = layui.element
var editData = {}
var treeObj = null
var all_nodes = []
// 1-创建新商户;2-创建子商户;3-修改
var editLevel = 1
// 1-基本信息;2-权限树
var step = 1
var merchantId = null
var parentMerchantId = null
var accountTypeVisible = false
// 是否工厂
var isFactory = true
var merchantAccountLevel = qs('merchantAccountLevel')
var parentInfo = {}
var isFreshSecond = true
var scopeNum = 1
var merchantForm = {
channelId: '',
merchantName: '',
merchantAbbreviation: '',
merchantType: '',
merchantOrgcode: '',
merchantLegalPerson: '',
merchantLegalPersonPhone: '',
isloginName: 0,
residentContact: '',
residentPhone: '',
bussinessBegintime: '',
bussinessEndtime: '',
lat: '',
lng: '',
merchantAddress: '',
businessScope: '',
merchantFiles: []
}
var baseData = {
channelList: [],
carBrandTreeList: [],
accountLevelList: [],
validPeriodList: [],
busiScopeList: [],
accountTypeList: []
}
var startDate = laydate.render({
elem: '#startDate', //指定元素
type: 'time',
format: 'HH:mm:ss',
done: function (value, date) {
//监听日期被切换
if (value != '') {
date.month = date.month - 1
endDate.config.min = date
} else {
endDate.config.min = startDate.config.min
}
lay('#startDate').html(value)
}
})
var endDate = laydate.render({
elem: '#endDate', //指定元素
type: 'time',
format: 'HH:mm:ss',
done: function (value, date) {
//监听日期被切换
if (value != '') {
date.month = date.month - 1
startDate.config.max = date
} else {
startDate.config.max = endDate.config.max
}
lay('#endDate').html(value)
}
})
var effectiveStarttime = laydate.render({
elem: '#effectiveStarttime',
format: 'yyyy-MM-dd',
min: '2021-09-30',
done: function (value, date) {
console.log(value, date)
expireDate.config.min = date
lay('#effectiveStarttime').html(value)
}
})
var expireDate = laydate.render({
elem: '#expireDate',
format: 'yyyy-MM-dd'
})
editLevel = qs('editLevel')
isFactory = qs('isFactory') == 'true'
step = qs('step')
var pwd = $('#password') // 密码输入框
var resetpsw = $('#resetpsw')
// pwd.attr('readonly', false)
// 重置密码
resetpsw.on('click', function () {
pwd.attr('readonly', false)
pwd.val('')
})
init()
// 校验
form.verify({
channelId: function (value) {
if (editLevel == 1 && !value) {
return '必填项不能为空'
}
},
merchantOrgcode: function (value) {
var merchantType = $('#merchantTypeEl option:selected').val()
if (value) {
if (merchantType == 1 && !validator.checkIdCard(value)) {
return '请填入正确的身份证'
}
if (value && validator.ISCHINESE2.test(value)) {
return '只能输入数字、字母和符号'
}
}
},
merchantLoginAccount: function (value) {
if (value && value.length < 3) {
return '登录账户名请填入3-15位字符'
}
},
merchantLoginPassword: function (value) {
if (value && value.length < 6) {
return '登录密码请填入6-15位字符'
}
},
residentPhone: function (value) {
if (value && !validator.checkPhoneNumber(value)) {
return '请填入正确的驻店电话'
}
},
otherReq: function(value,item){
var verifyName=$(item).attr('name')
, verifyType=$(item).attr('type')
,formElem=$(item).parents('.layui-form')//获取当前所在的form元素,如果存在的话
,verifyElem=formElem.find('input[name='+verifyName+']')//获取需要校验的元素
,isTrue= verifyElem.is(':checked')//是否命中校验
,focusElem = verifyElem.next().find('i.layui-icon');//焦点元素
if(!isTrue || !value){
//定位焦点
focusElem.css(verifyType=='radio'?{"color":"#FF5722"}:{"border-color":"#FF5722"});
//对非输入框设置焦点
focusElem.first().attr("tabIndex","1").css("outline","0").blur(function() {
focusElem.css(verifyType=='radio'?{"color":""}:{"border-color":""});
}).focus();
return '必填项不能为空';
}
}
})
form.on('select(merchantTypeFilter)', function (data) {
if (data.value == 1) {
$('#merchantOrgcodeEl').attr('placeholder', '请输入身份证号码')
} else {
$('#merchantOrgcodeEl').attr('placeholder', '请输入组织机构号码')
}
})
form.on('submit(handleFirstSubmit)', function (data) {
console.log(data)
var formData = data.field
var params = {
isloginName: 0
}
var fieldToFormNameList = [
'merchantName',
'merchantAbbreviation',
'merchantType',
'merchantOrgcode',
'merchantLegalPerson',
'merchantLegalPersonPhone',
'residentContact',
'residentPhone',
'merchantLoginAccount',
'merchantLoginPassword',
'merchantAccountLevel',
'effectiveTime',
]
if (formData.isloginName == 'on') {
params.isloginName = 1
}
if (formData.bussinessBegintime) {
merchantForm.bussinessBegintime = formData.bussinessBegintime
params.bussinessBegintime = formData.bussinessBegintime
}
if (formData.bussinessEndtime) {
merchantForm.bussinessEndtime = formData.bussinessEndtime
params.bussinessEndtime = formData.bussinessEndtime
}
if (merchantForm.lat) {
params.lat = merchantForm.lat
params.lng = merchantForm.lng
params.merchantAddress = merchantForm.merchantAddress
}
$.each(fieldToFormNameList, function (index, item) {
merchantForm[item] = formData[item] || ''
params[item] = formData[item] || ''
})
if (merchantId) {
params.effectiveTime = merchantForm.effectiveTime
}
if (editLevel == 1) {
merchantForm.channelId = formData.channelId
params.channelId = formData.channelId
} else {
params.channelId = merchantForm.channelId
}
var checkClassNameList = [
{
attr: 'businessScope',
toString: ','
},
{
attr: 'accounttypeId',
toString: ','
}
]
$.each(checkClassNameList, function (index, item) {
var checkedArr = []
$('input[class=' + item.attr + ']:checked').each(function () {
checkedArr.push($(this).val())
})
if (checkedArr.length) {
if (item.toString) {
merchantForm[item.attr] = checkedArr.join(item.toString)
params[item.attr] = checkedArr.join(item.toString)
}
}
})
if (!params.accounttypeId) {
layer.msg('账户类型不能为空', {
icon: 5,
anim: 6
})
return false
}
var elList = $('.business-scope-cust')
var tempList = []
$.each(elList, function (index, item) {
if (item.value) {
tempList.push(item.value)
}
})
merchantForm.businessScopeCustomize = tempList.join(',')
params.businessScopeCustomize = tempList.join(',')
merchantForm.merchantBrand = treeObj.getCheckedNodes(true)
params.merchantBrand = findId(merchantForm.merchantBrand).join(',')
if (merchantForm.merchantFiles.length) {
params.merchantFiles = JSON.stringify(merchantForm.merchantFiles)
}
if (merchantId) {
params.id = merchantId
if (!isFactory) {
params.parentId = parentInfo.parentId
}
params.method = 'cn.com.glsx.merchants.merchant.updateMerchant'
} else if (editLevel == 1) {
params.method = 'cn.com.glsx.merchants.merchant.saveMerchant'
} else if (editLevel == 2) {
if (!isFactory) {
params.parentId = parentInfo.parentId
}
params.method = 'cn.com.glsx.merchants.merchant.saveMerchant'
}
// 保存状态 1.草稿 2.发布 3.注销 4.过期
if (merchantForm.status) {
params.status = merchantForm.status
} else {
params.status = 1
}
request(params, function (res) {
if (res.code == '0') {
if (editLevel == 3) {
layer.msg('操作成功', {
icon: 1
})
go('merchant', 'index')
} else {
if (!merchantId) {
merchantId = res.data
}
merchantForm.merchantAccountLevel = parseInt(merchantForm.merchantAccountLevel)
getMerchantApi(merchantId, function (respone) {
form.val('merchantForm', respone.data)
merchantForm = respone.data
if (merchantForm.merchantAddress) {
$('#addrEl').text(merchantForm.merchantAddress)
}
accountTypeVisible = true
var el = $('#accountTypeEl')
el.empty()
recoveryFile()
getAccountType()
baseIsShow(false)
treeIsShow(true)
if (isFreshSecond) {
getById()
isFreshSecond = false
}
})
}
}
})
return false
})
function findId(nodeList) {
var idList = []
$.each(nodeList, function (index, item) {
idList.push(item.id)
})
return idList
}
// 按钮事件绑定
var btnHandle = {
// 选择地址
handleSelectAddr: function () {
helper.store.set('merchantMapObj', merchantForm)
layer.open({
type: 2,
title: '选择地址',
area: ['900px', '600px'],
btn: ['确定', '取消'],
content: 'map.html',
yes: function (index, layero) {
var body = layer.getChildFrame('body', index)
body.find('#mapBtn').click()
var res = helper.store.get('merchantMapObj')
if (res.lat && res.merchantAddress) {
merchantForm.lat = res.lat
merchantForm.lng = res.lng
merchantForm.merchantAddress = res.merchantAddress
$('#addrEl').val(merchantForm.merchantAddress)
layer.close(index)
} else {
layer.msg('请选择地址', {
icon: 5
})
}
},
end: function () {
helper.store.remove('merchantMapObj')
}
})
},
// 添加范围
handleAddScope: function (txt) {
if (scopeNum < 10) {
scopeNum = scopeNum + 1
var parent = $('#custom-scope')
var subParent = $('<div class="layui-form-item"><label class="layui-form-label"></label></div>')
var child1 = $('<div class="layui-input-inline"></div>')
var inputEl = $('<input class="layui-input business-scope-cust" maxlength="15" placeholder="请自定义营业范围,建议不超过10个">')
var child2 = $('<div class="layui-input-inline"></div>')
var addBtn = $('<button type="button" class="layui-btn btn-no-border"><i class="layui-icon layui-icon-add-circle"></i></button>')
var deleteBtn = $('<button type="button" class="layui-btn btn-no-border"><i class="layui-icon layui-icon-reduce-circle"></i></button>')
if (txt) {
inputEl.val(txt)
}
addBtn.bind('click', function (e) {
btnHandle.handleAddScope()
})
deleteBtn.bind('click', function (e) {
scopeNum = scopeNum - 1
var el = $(this).parent().parent()
el.remove()
})
child1.append(inputEl)
child2.append(addBtn)
child2.append(deleteBtn)
subParent.append(child1)
subParent.append(child2)
parent.append(subParent)
}
},
handleCancel: function () {
go('merchant', 'index')
return false
}
}
$('.layui-btn').on('click', function () {
var type = $(this).data('type')
if (btnHandle[type]) {
btnHandle[type]()
}
})
$('.upload').on('change', function (e) {
var idx = $(this).data('idx')
var imgEl = $('#img' + idx)
var el = $('#upload' + idx)
var addEl = $('.img-add' + idx)
var reader = new FileReader()
var fileInfo = el[0].files[0]
reader.readAsDataURL(fileInfo)
reader.onload = function (e) {
if (e) {
var imgFile = e.target.result
var base64 = fileInfo.name.split('.')[1] + '@' + imgFile.split(',')[1]
var params = {
method: 'glsx.accounts.biz.common.pictureUpload',
file: base64
}
request(
params,
function (result) {
merchantForm.merchantFiles[idx] = {
fileUrl: result.data,
fileName: ''
}
imgEl.attr('src', result.data)
imgEl.removeClass('hide')
imgEl.addClass('show')
addEl.removeClass('show')
addEl.addClass('hide')
},
{},
['file'],
true
)
}
}
reader.onload()
})
$('#sevenday').on('click', function() {
var startTime = new Date(new Date().setHours(0,0,0,0))
var endTime = startTime * 1 + 86400 * 7 * 1000
console.log(helper.dateFormat(startTime), endTime)
$('#effectiveStarttime').val(helper.dateFormat(startTime))
$('#expireDate').val(helper.dateFormat(endTime))
})
$('#oneyear').on('click', function() {
var startTime = new Date(new Date().setHours(0,0,0,0))
var endTime = startTime.setFullYear(startTime.getFullYear() + 1)
console.log(helper.dateFormat(endTime))
$('#effectiveStarttime').val(helper.dateFormat(new Date(new Date().setHours(0,0,0,0))))
$('#expireDate').val(helper.dateFormat(endTime))
})
$('#twoyears').on('click', function() {
var startTime = new Date(new Date().setHours(0,0,0,0))
var endTime = startTime.setFullYear(startTime.getFullYear() + 2)
console.log(helper.dateFormat(endTime))
$('#effectiveStarttime').val(helper.dateFormat(new Date(new Date().setHours(0,0,0,0))))
$('#expireDate').val(helper.dateFormat(endTime))
})
function baseIsShow(isShow) {
if (isShow) {
$('#basicForm').show()
} else {
$('#basicForm').hide()
}
}
function treeIsShow(isShow) {
if (isShow) {
$('#authorityTree').show()
} else {
$('#authorityTree').hide()
}
}
function init() {
// var index = layer.load(2, {
// shade: true,
// time: 10 * 1000
// }); //又换了种风格,并且设定最长等待10秒
//关闭
// layer.close(index);
if (step == 1) {
getPeriod()
baseIsShow(true)
treeIsShow(false)
if (merchantId) {
resetpsw.removeClass('hide')
resetpsw.addClass('show')
}
if (isFactory) {
$('#subMerchantEl').hide()
$('#subMerchantModel').hide()
}
} else {
baseIsShow(false)
treeIsShow(true)
}
// 创建商户
if (editLevel == 1) {
if (!merchantId) {
getChannel()
$('#accountLevelEl').attr('disabled', true)
getBusiScope()
getCarBrandTree()
getAccountLevel()
getAccountType()
} else {
$('#validPeriodEl').attr('disabled', true)
$('#merchantLoginAccountEl').attr('disabled', true)
$('#channelEl').attr('required')
// $('#channelEl').attr('disabled', true)
}
} else {
if (!merchantId) {
merchantId = qs('id')
}
if (merchantId) {
resetpsw.removeClass('hide')
resetpsw.addClass('show')
}
if (editLevel == 3) {
$('#firstBtn').text('确定')
$('#preStep').remove()
if (step == 1) {
$('#validPeriodEl').attr('disabled', true)
$('#merchantLoginAccountEl').attr('disabled', true)
accountTypeVisible = true
$('#accountLevelEl').attr('disabled', true)
}
} else {
if (!merchantId && step == 1) {
getBusiScope()
getCarBrandTree()
}
}
if (isFactory) {
getAccountLevel()
getMerchantInfo()
} else {
// 创建/编辑子商户
if (!parentMerchantId) {
parentMerchantId = qs('parentId')
}
$('#validPeriodEl').attr('disabled', true)
if (merchantAccountLevel == 4) {
$('#effectiveShowEl').removeClass('hide')
$('#effectiveShowEl').addClass('show')
}
// $('#channelEl').attr('disabled', true)
if (editLevel == 3 || (editLevel == 2 && !merchantId)) {
getParentInfo()
} else {
$('#merchantLoginAccountEl').attr('disabled', true)
$('#accountLevelEl').attr('disabled', true)
}
}
}
}
function bindEvent() {
$('#brand').on(
'input',
helper.debounce(function () {
var txt = $(this).val()
if (!txt) {
treeObj.showNodes(all_nodes)
} else {
var nodesList = treeObj.getNodesByParamFuzzy('label', txt)
show_nodes = helper.findShowNode(nodesList, all_nodes)
treeObj.hideNodes(all_nodes)
treeObj.showNodes(show_nodes)
}
}, 500)
)
}
function setCheckbox(checkedStr, attr) {
if (!checkedStr || !checkedStr.length) {
return false
}
var list = []
if (layui._isArray(checkedStr)) {
list = checkedStr
} else {
list = checkedStr.split(',')
}
$.each(list, function (index, item) {
$('input[class=' + attr + ']').attr('checked', true)
})
}
function getMerchantApi(id, fn) {
var params = {
method: 'cn.com.glsx.merchants.merchant.findMerchantDetail',
id: id
}
request(params, function (res) {
fn && fn(res)
})
}
// 子商户 - 获取父商户信息
function getParentInfo() {
getMerchantApi(parentMerchantId, function (res) {
var data = res.data
parentInfo = {
parentId: data.id,
parentName: data.merchantName + '(' + data.merchantNo + ')',
parentAccountType: data.accountType,
parentMerchantAccountLevel: data.merchantAccountLevel,
channelId: data.channelId,
effectiveTime: data.effectiveTime,
merchantModelName: data.merchantModelName
}
merchantForm.channelId = parentInfo.channelId
var attrList = ['parentName', 'merchantModelName']
$.each(attrList, function (index, item) {
$('#' + item).text(parentInfo[item])
})
form.val('merchantForm', parentInfo)
if (editLevel == 3) {
getMerchantInfo()
$('#accountLevelEl').attr('disabled', true)
} else {
if (step == 1) {
getAccountType()
}
}
if (step == 1) {
getAccountLevel()
}
})
}
// 获取商户信息
function getMerchantInfo() {
getMerchantApi(merchantId, function (res) {
form.val('merchantForm', res.data)
merchantForm = res.data
if (!isFactory) {
merchantForm.channelId = parentInfo.channelId
}
if (merchantForm.merchantAddress) {
$('#addrEl').text(merchantForm.merchantAddress)
}
if (merchantForm.status != 1) {
$('#draft').remove()
}
if (merchantForm.merchantType == 2) {
$('#merchantOrgcodeEl').attr('placeholder', '请输入组织机构号码')
}
if (step == 1) {
getBusiScope()
getCarBrandTree()
getAccountType()
recoveryBusiScopeCus()
recoveryFile()
} else {
getById()
}
})
}
// 渠道
function getChannel() {
getDictData('channel', function (res) {
baseData.channelList = res.data
setSelectOption('#channelEl', 'channelList', 'dictValue', 'dictLabel')
})
}
// 品牌
function getCarBrandTree() {
var params = {
method: 'cn.com.glsx.merchants.merchantCommon.getCarbrandTree'
}
request(params, function (res) {
baseData.carBrandTreeList = res.data
var checkedList = []
if (editLevel == 3 && merchantForm.merchantBrand) {
checkedList = merchantForm.merchantBrand.split(',')
$.each(checkedList, function (index, item) {
checkedList[index] = parseInt(item)
})
}
treeObj = tree.create('carBrandTree', res.data, {
checkedList: checkedList
})
if (checkedList) {
treeObj.checkNodes(checkedList)
}
all_nodes = treeObj.transformToArray(treeObj.getNodes())
bindEvent()
})
}
// 获取字典数据
function getDictData(dictType, fn) {
var params = {
method: 'cn.com.glsx.merchants.menu.findAllDictData',
dictType: dictType
}
request(params, function (res) {
fn && fn(res)
})
}
// 设置option
function setSelectOption(elName, listName, optionId, optionLabel) {
var el = $(elName)
$.each(baseData[listName], function (index, item) {
el.append(new Option(item[optionLabel], item[optionId]))
})
form.render('select')
}
// 设置input值
function setInput(elName, value) {
$(elName).val(value)
}
// 账户等级
function getAccountLevel() {
getDictData('account_level', function (res) {
baseData.accountLevelList = res.data
if (!isFactory) {
var tempList = []
$.each(baseData.accountLevelList, function (index, item) {
if (item.dictValue > parentInfo.parentMerchantAccountLevel) {
if (parentInfo.parentMerchantAccountLevel == 1 && item.dictValue == 3) {
} else {
tempList.push(baseData.accountLevelList[index])
}
}
})
baseData.accountLevelList = tempList
}
setSelectOption('#accountLevelEl', 'accountLevelList', 'dictValue', 'dictLabel')
})
}
// 有效期
function getPeriod() {
getDictData('account_validity_period', function (res) {
baseData.validPeriodList = res.data
setSelectOption('#validPeriodEl', 'validPeriodList', 'dictValue', 'dictLabel')
})
}
// 营业范围
function getBusiScope() {
getDictData('business_scope', function (res) {
baseData.busiScopeList = res.data
var checkedList = []
if (editLevel == 3 && merchantForm.businessScope) {
checkedList = merchantForm.businessScope.split(',')
}
var el = $('#busiScopeEl')
$.each(baseData.busiScopeList, function (index, item) {
var optionEl = $(
'<input type="checkbox" class="businessScope" name="businessScope[' + item.dictValue + ']" title=' + item.dictLabel + ' value="' + item.dictValue + '" lay-skin="primary">'
)
// 修改-回显
if (editLevel == 3) {
for (var i = 0; i <= checkedList.length; i++) {
if (checkedList[i] == item.dictValue) {
optionEl.attr('checked', true)
break
}
}
}
el.append(optionEl)
form.render('checkbox')
})
})
}
// 恢复自定义营业范围
function recoveryBusiScopeCus() {
if (merchantForm.businessScopeCustomize) {
var scopeCusList = merchantForm.businessScopeCustomize.split(',')
$.each(scopeCusList, function (index, item) {
if (index != 0) {
btnHandle.handleAddScope(item)
} else {
$('#scopeCus').val(item)
}
})
scopeNum = scopeCusList.length
}
}
// 恢复图片
function recoveryFile() {
merchantForm.merchantFiles = []
$.each(merchantForm.merchantFileResponses, function (index, item) {
var imgEl = $('#img' + index)
var el = $('#upload' + index)
var addEl = $('.img-add' + index)
merchantForm.merchantFiles[index] = {
fileUrl: item.fileUrl,
fileName: item.fileName
}
imgEl.attr('src', item.fileUrl)
imgEl.removeClass('hide')
imgEl.addClass('show')
addEl.removeClass('show')
addEl.addClass('hide')
})
}
// 账户类型
function getAccountType() {
getDictData('account_type', function (res) {
baseData.accountTypeList = res.data
var checkedList = []
if (merchantId && merchantForm.accountType) {
checkedList = merchantForm.accountType.split(',')
}
var el = $('#accountTypeEl')
$.each(baseData.accountTypeList, function (index, item) {
if (parentMerchantId) {
var parentLevelList = parentInfo.parentAccountType.split(',')
for (var k = 0; k <= parentLevelList.length; k++) {
if (item.dictValue == parseInt(parentLevelList[k])) {
var optionEl = $('<input type="checkbox" class="accounttypeId" name="accountType[' + item.dictValue + ']" title=' + item.dictLabel + ' value="' + item.dictValue + '">')
if (accountTypeVisible) {
optionEl.attr('disabled', true)
}
// 修改-回显
if (merchantId) {
for (var i = 0; i <= checkedList.length; i++) {
if (checkedList[i] == item.dictValue) {
optionEl.attr('checked', true)
break
}
}
}
el.append(optionEl)
form.render('checkbox')
break
}
}
} else {
var optionEl = $('<input type="checkbox" class="accounttypeId" name="accountType[' + item.dictValue + ']" title=' + item.dictLabel + ' value="' + item.dictValue + '">')
if (accountTypeVisible) {
optionEl.attr('disabled', true)
}
// 修改-回显
if (merchantId) {
for (var i = 0; i <= checkedList.length; i++) {
if (checkedList[i] == item.dictValue) {
optionEl.attr('checked', true)
break
}
}
}
el.append(optionEl)
form.render('checkbox')
}
})
})
}
// 数 - start
var laytpl = layui.laytpl
var xmSelect = layui.xmSelect
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 layui-tab-form" action="">
<div class="layui-form-item" pane>
<label class="layui-form-label">选择产品:</label>
<div class="layui-input-block" id="project${id}">
</div>
</div>
</form>
<div>请选择产品权限</div>
<div class="layui-tab layui-tree-box" lay-filter="treeTab{{d.id}}">
<ul class="layui-tab-title"></ul>
<div class="layui-tab-content">
<div class="layui-no-data show" id="nodata${id}">
<div class="no-data">
<img src="../../css/img/no-data.png" />
<div>请先选择产品</div>
</div>
</div>
</div>
</div>`
view = document.getElementById('role' + id)
templateData.id = id // 渲染模版的数据
laytpl(getTpl).render(templateData, function (html) {
view.innerHTML = html
})
var products = menuFunTreeData.find(item => item.accounttypeId == id).products
products.forEach(i => {
var str = $('<input lay-filter="filter" data-id="' + id + '" type="checkbox" name="check[' + id + ']" value="' + i.productId + '" title="' + i.productName + '" lay-skin="primary" />')
$('#project' + id).append(str)
if (productList) {
productList.forEach(j => {
if (j.productId == i.productId) {
str.attr('checked', true)
}
})
}
form.render()
})
},
// tab删除
tabDelete: function (name, id) {
element.tabDelete(name, id)
},
// tab Change
tabChange: function (name, id) {
element.tabChange(name, id)
},
/**
* 第二级选项卡
* treeTabAdd 产品的权限添加
* item: {name: 选项卡名称, value: 选项卡值}
* id 第一级选项卡的item.value
* filterName: 过滤器的名称 lay-filter绑定的值
* treeData:渲染模板的数据,和用来存放对应树实例的对象,
* products:产品list数组
* defaultList:编辑时传入,默认勾选中的数组。(举例:[1,2,3])
*/
treeTabAdd: function (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) {
treeView.innerHTML = html
})
var treedom = 'tree_' + productId
if (treeListData && treeListData.length != 0) {
treeData[id][item.value].treeObj = tree.create(treedom, treeListData)
treeData[id][item.value].treeObj.checkAllNodes(true)
$(`#nodata${id}`).removeClass('show')
$(`#nodata${id}`).addClass('hide')
} else {
$(`#nodata${id}`).removeClass('hide')
$(`#nodata${id}`).addClass('show')
}
}
}
// 产品复选框change事件
form.on('checkbox(filter)', function(data) {
console.log(data, '33333333333')
var roleId = +data.elem.dataset.id
var projectId = data.value
var isAdd = data.elem.checked
var filterName = 'treeTab' + roleId
console.log(roleId, projectId, isAdd)
// merchantProTreeResponses
var changeObj = menuFunTreeData.find(item => item.accounttypeId == roleId).products.find(i => i.productId == projectId)
var products = menuFunTreeData.find(item => item.accounttypeId == roleId).products
console.log(changeObj, products, roleId, treeData)
if (isAdd) {
// 新增
active.treeTabAdd(
{
name: changeObj.productName,
value: changeObj.productId
},
roleId,
changeObj.merchantProTreeResponses
)
} else {
// 删除
console.log(treeData, Object.keys(treeData).length)
var productId = 'tab_' + roleId + '_' + changeObj.productId
active.tabDelete(filterName, productId)
if (Object.keys(treeData).length != 0) {
delete treeData[roleId][changeObj.productId]
}
if (Object.keys(treeData).length == 0 || Object.keys(treeData[roleId]).length == 0) {
$(`#nodata${roleId}`).removeClass('hide')
$(`#nodata${roleId}`).addClass('show')
}
}
if (Object.keys(treeData).length != 0) {
var productId = 'tab_' + roleId + '_' + changeObj.productId
active.tabChange(filterName, productId)
}
})
// 查询商户的菜单权限树
function findMenuFunTreeByMerId() {
var params = {}
if (parentMerchantId) {
params = {
method: 'cn.com.glsx.merchants.merchant.findMenuFunTreeByMerId',
id: merchantId,
parentId: parentMerchantId,
accountlevel: merchantForm.merchantAccountLevel
}
} else {
params = {
method: 'cn.com.glsx.merchants.merchant.accountTypeSearchRequest',
ids: merchantForm.accountType,
merchantId: merchantId,
accountLevel: merchantForm.merchantAccountLevel
}
}
request(params, function (res) {
if (res.code == '0') {
menuFunTreeData = res.data
var accountType = $('#accountType')
accountType.empty()
console.log(menuFunTreeData)
menuFunTreeData.forEach((item, index) => {
var str = $('<input lay-filter="switch" type="checkbox" name="accounttypeId" value="' + item.accounttypeId + '" title="' + item.accounttypeName + '" />')
accountType.append(str)
if (merchantId) {
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.products)
// productData.products.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.menuIds
// )
// })
// var filterName = 'treeTab' + item.accounttypeId
// var productId = 'tab_' + item.accounttypeId + '_' + productData.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() {
var params = {
method: 'cn.com.glsx.merchants.merchant.findPermissionsByMerId',
id: merchantId
}
request(params, function (res) {
if (res.code == '0') {
var accounttypeId = ''
if (res.data) {
check_arr = res.data
}
findMenuFunTreeByMerId()
form.val('roleForm', {
roleName: res.data.roleName,
roleDescription: res.data.roleDescription
})
}
})
}
// 获取角色权限数据requestList
function getAuthList() {
requestList = []
for (var key in treeData) {
var accountObj = treeData[key]
var productList = []
for (var i in accountObj) {
var productObj = accountObj[i]
var menuIds = []
var functionIds = []
var functionIdLists = []
var functionValueIdLists = []
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') {
menuIds.push(item.id)
}
}
})
$.each(functionValueIdLists, function (idx, m) {
var findIdx = -1
$.each(functionIds, function (idn, n) {
if (n.functionId == m.parentId) {
findIdx = idn
}
})
if (findIdx != -1) {
functionIds[findIdx].functionValue += ';' + m.id + ':' + m.label
} else {
functionIds.push({
functionId: m.parentId,
mendId: m.superParentId,
functionValue: m.id + ':' + m.label
})
}
})
$.each(functionIdLists, function (idx, m) {
functionIds.push({
functionId: m.parentId,
mendId: m.superParentId
})
})
productList.push({
productId: productObj.productId,
functionIds: functionIds,
menuIds: menuIds
})
}
requestList.push({
accountTypeId: key,
products: productList
})
}
}
$('#draft').on('click', function () {
getAuthList()
var params = {
merchantId: merchantId,
accountTypes: JSON.stringify(requestList),
method: 'cn.com.glsx.merchants.merchant.updatePermissions',
status: merchantForm.status
}
request(params, function (res) {
if (res.code == '0') {
layer.msg('操作成功', {
icon: 1
})
go('merchant', 'index')
}
})
return false
})
$('#preStep').on('click', function () {
step = 1
init()
})
$('#confirm').on('click', function () {
getAuthList()
var params = {
merchantId: merchantId,
accountTypes: JSON.stringify(requestList)
}
params.method = 'cn.com.glsx.merchants.merchant.updatePermissions'
// 草稿
if (merchantForm.status == 1) {
params.status = 2
} else {
params.status = merchantForm.status
}
request(params, function (res) {
if (res.code == '0') {
layer.msg('操作成功', {
icon: 1
})
go('merchant', 'index')
}
})
return false
})
})
</script>
<script type="text/html" id="treeAuth">
<!-- <button class="layui-btn" data-type="d.id" id="checkedAll">全选</button>
<button class="layui-btn" id="cancelCheckedAll">取消全选</button> -->
<ul id="tree_{{d.id}}" class="ztree wrapper-tree"></ul>
</script>
</body>
</html>
...@@ -151,19 +151,20 @@ ...@@ -151,19 +151,20 @@
width: 100%; width: 100%;
height: 1px; height: 1px;
} }
</style> </style>
</head> </head>
<body> <body>
<div id="app"> <div id="app">
<main class="bg-white wrapper detail"> <main class="bg-white wrapper detail">
<div class="layui-tab layui-tab-brief bg-detail"> <div class="layui-tab layui-top-tab layui-tab-brief bg-detail">
<ul class="layui-tab-title"> <ul class="layui-tab-title">
<li class="layui-this">商户信息</li> <li class="layui-this" style="padding: 0;width: 90px;margin-right: 20px;">商户信息</li>
<li>上级/下级商户</li> <li style="padding: 0;width: 90px;margin-right: 20px;">上级/下级商户</li>
<li>修改记录</li> <li style="padding: 0;width: 90px;">修改记录</li>
</ul> </ul>
<div class="layui-tab-content"> <div class="layui-tab-content m-t-md">
<div class="layui-tab-item layui-show"> <div class="layui-tab-item layui-show">
<div class="MsgWrap" get> <div class="MsgWrap" get>
<div class="grayLine"></div> <div class="grayLine"></div>
...@@ -484,6 +485,7 @@ ...@@ -484,6 +485,7 @@
request(params, function (res) { request(params, function (res) {
if (res.code == '0' && res.data && res.data.length != 0) { if (res.code == '0' && res.data && res.data.length != 0) {
var authList = res.data var authList = res.data
console.log(authList)
$.each(authList, function (index, item) { $.each(authList, function (index, item) {
treeTab.tabAdd( treeTab.tabAdd(
{ {
...@@ -507,6 +509,8 @@ ...@@ -507,6 +509,8 @@
var filterName = 'treeTab' + item.accounttypeId var filterName = 'treeTab' + item.accounttypeId
var productId = 'tab_' + item.accounttypeId + '_' + item.products[0].productId var productId = 'tab_' + item.accounttypeId + '_' + item.products[0].productId
treeTab.tabChange(filterName, productId) treeTab.tabChange(filterName, productId)
} else {
} }
}) })
treeTab.tabChange('roleAuth', authList[0].accounttypeId) treeTab.tabChange('roleAuth', authList[0].accounttypeId)
......
...@@ -127,12 +127,15 @@ ...@@ -127,12 +127,15 @@
.edit-box #accountTypeEl .layui-form-checked span, .edit-box #accountTypeEl .layui-form-checked span,
#accountTypeEl .layui-form-checked:hover span { #accountTypeEl .layui-form-checked:hover span {
background-color: #1989fa !important; background-color: #5850FF !important;
} }
.edit-box #accountTypeEl .layui-form-checked i, .edit-box #accountTypeEl .layui-form-checked i,
#accountTypeEl .layui-form-checked:hover i { #accountTypeEl .layui-form-checked:hover i {
color: #1989fa !important; color: #5850FF !important;
}
.layui-form-radio:hover *, .layui-form-radioed, .layui-form-radioed>i {
color: #5850FF !important;
} }
.layui-tab-content { .layui-tab-content {
position: relative; position: relative;
...@@ -165,7 +168,7 @@ ...@@ -165,7 +168,7 @@
line-height: 28px; line-height: 28px;
} }
#basicForm { #basicForm {
margin-bottom: 50px; margin-bottom: 87px;
} }
</style> </style>
<title>商户编辑</title> <title>商户编辑</title>
...@@ -174,12 +177,12 @@ ...@@ -174,12 +177,12 @@
<body> <body>
<div id="app"> <div id="app">
<main> <main>
<div class="layui-tab layui-tab-brief" lay-filter="editTab"> <div class="layui-tab layui-top-tab layui-tab-brief" lay-filter="editTab">
<ul class="layui-tab-title"> <ul class="layui-tab-title">
<li lay-id="2" id="functional">修改功能权限</li> <li lay-id="2" id="functional" style="padding: 0;width: 90px;margin-right: 20px;">修改功能权限</li>
<li lay-id="1" id="basic" class="layui-this">修改基本信息</li> <li lay-id="1" id="basic" style="padding: 0;width: 90px;" class="layui-this">修改基本信息</li>
</ul> </ul>
<div class="layui-tab-content"> <div class="layui-tab-content m-t-md">
<!-- 权限树 --> <!-- 权限树 -->
<div class="layui-tab-item edit-box"> <div class="layui-tab-item edit-box">
<div id="authorityTree"> <div id="authorityTree">
...@@ -1387,14 +1390,15 @@ ...@@ -1387,14 +1390,15 @@
// 选项卡标题的lay-id属性值 // 选项卡标题的lay-id属性值
id: id id: id
}) })
var getTpl = `<form class="layui-form layui-form-pane" action=""> var getTpl = `<form class="layui-form layui-form-pane layui-tab-form" 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}">
</div> </div>
</div> </div>
</form> </form>
<div class="layui-tab layui-tab-brief" lay-filter="treeTab{{d.id}}"> <div>请选择产品权限</div>
<div class="layui-tab layui-tree-box" lay-filter="treeTab{{d.id}}">
<ul class="layui-tab-title"></ul> <ul class="layui-tab-title"></ul>
<div class="layui-tab-content"> <div class="layui-tab-content">
<div class="layui-no-data show" id="nodata${id}"> <div class="layui-no-data show" id="nodata${id}">
......
...@@ -141,7 +141,7 @@ ...@@ -141,7 +141,7 @@
<div class="layui-inline customerStatus"> <div class="layui-inline customerStatus">
<label class="layui-form-label">模式:</label> <label class="layui-form-label">模式:</label>
<div class="layui-input-inline"> <div class="layui-input-inline">
<select name="status" id="searchModelEl"> <select name="merchantModel" id="searchModelEl">
<option value="">全部</option> <option value="">全部</option>
</select> </select>
</div> </div>
...@@ -320,7 +320,7 @@ ...@@ -320,7 +320,7 @@
align: 'left', align: 'left',
title: '操作', title: '操作',
toolbar: '#merchantBtns', toolbar: '#merchantBtns',
width: 220, width: 150,
fixed: 'right' fixed: 'right'
// }, // },
// { // {
...@@ -483,7 +483,7 @@ ...@@ -483,7 +483,7 @@
// 创建子商户/门店 // 创建子商户/门店
case 'handleAddMerchant': case 'handleAddMerchant':
// 1-创建新商户;2-创建子商户;3-修改 // 1-创建新商户;2-创建子商户;3-修改
go('merchant', 'add', { go('merchant', 'addSubMerchant', {
editLevel: 2, editLevel: 2,
parentId: row.id, parentId: row.id,
isFactory: 'false', isFactory: 'false',
......
...@@ -82,10 +82,10 @@ ...@@ -82,10 +82,10 @@
$('#merchantEl').show() $('#merchantEl').show()
$('#storeEl').hide() $('#storeEl').hide()
setText(2) setText(2)
console.log(getQueryString('effectiveTime')) console.log(getQueryString('status'))
vaildData.effectiveTime = getQueryString('effectiveTime') vaildData.effectiveTime = getQueryString('status')
form.val('periodFilter', { form.val('periodFilter', {
effectiveTime: '2' effectiveTime: getQueryString('status')
}) })
} }
......
...@@ -38,25 +38,27 @@ function loadHeaderFooter() { ...@@ -38,25 +38,27 @@ function loadHeaderFooter() {
layui.use(['store'], function () { layui.use(['store'], function () {
var isExternal = isAppend() var isExternal = isAppend()
var store = layui.store var store = layui.store
console.log(qs('merchantId'), qs('merchantAccountLevel')) console.log(qs('merchantId'), qs('accountLevel'))
if (qs('merchantAccountLevel')) {
store.set('accountInfo', {
merchantAccountLevel: qs('merchantAccountLevel'),
merchantId: qs('merchantId'),
model: qs('model')
})
// } else {
// store.set('accountInfo', null)
}
if(isExternal){ //运营平台外部系统 if(isExternal){ //运营平台外部系统
append() append()
}else{//嵌入运营平台 或者是登录页面 } else {//嵌入运营平台 或者是登录页面
if(isLoginPage()){ //如果是登陆页面 直接返回 登录成功会设置token if (qs('sessionId')) {
return // SCRM 系统
} store.set('accountInfo', {
var t = qs('t') //运营平台子系统从 父系统的iframe src获取 TGT. merchantAccountLevel: qs('accountLevel'),
if(t){ merchantId: qs('merchantId'),
store.set('token', t) model: qs('model')
})
store.set('token', qs('sessionId'))
} else {
// 运营平台
if(isLoginPage()){ //如果是登陆页面 直接返回 登录成功会设置token
return
}
var t = qs('t') //运营平台子系统从 父系统的iframe src获取 TGT.
if(t){
store.set('token', t)
}
} }
} }
}) })
...@@ -68,6 +70,7 @@ function append() { ...@@ -68,6 +70,7 @@ function append() {
$(header).load('/html/components/header.html') $(header).load('/html/components/header.html')
$(footer).load('/html/components/footer.html') $(footer).load('/html/components/footer.html')
$('main').before(header).after(footer) $('main').before(header).after(footer)
} }
function isAppend() { function isAppend() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!