Commit 789635c5 by 胡悦

Merge branch 'master' of 192.168.3.233:h5/account

2 parents bb05336d 6782024e
...@@ -81,9 +81,14 @@ ...@@ -81,9 +81,14 @@
<div id="app"> <div id="app">
<main> <main>
<div class="edit-box"> <div class="edit-box">
<p class="edit-title">企业基本信息</p>
<div> <div>
<form class="layui-form"> <form class="layui-form" lay-filter="merchantForm">
<div class="layui-form-item edit-title" style="position: relative;">
<div class="layui-input-inline">企业基本信息</div>
<div class="layui-input-inline" style="position: absolute; right: 0; top: 5px; font-size: normal;">
<select id="channelEl" name="channelId"></select>
</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-inline"> <div class="layui-input-inline">
...@@ -111,8 +116,8 @@ ...@@ -111,8 +116,8 @@
<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-inline"> <div class="layui-input-inline">
<input disabled class="layui-input layui-btn-disabled" name="merchantAbbreviation" <input style="color: #333333 !important;" name="merchantAddress" disabled
placeholder="请选择商户地址"> class="layui-input layui-btn-disabled" id="addrEl" placeholder="请选择商户地址">
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
...@@ -130,7 +135,7 @@ ...@@ -130,7 +135,7 @@
<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-inline"> <div class="layui-input-inline">
<input class="layui-input" name="merchantLegalPersonPhone" required lay-verify="required" <input class="layui-input" name="merchantLegalPersonPhone" required lay-verify="required|phone"
placeholder="请输入联系电话"> placeholder="请输入联系电话">
</div> </div>
</div> </div>
...@@ -149,28 +154,24 @@ ...@@ -149,28 +154,24 @@
<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-inline"> <div class="layui-input-inline">
<input class="layui-input" name="residentPhone" placeholder="请输入驻点电话"> <input class="layui-input" name="residentPhone" placeholder="请输入驻点电话" lay-verify="phone">
</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-inline"> <div class="layui-inline">
<div class="layui-input-inline"> <div class="layui-input-inline">
<input type="text" id="startTime" class="layui-input" name="bussinessBegintime" placeholder="开始时间"> <input type="text" id="startDate" class="layui-input" name="bussinessBegintime" placeholder="开始时间">
</div> </div>
<div class="layui-form-mid">-</div> <div class="layui-form-mid">-</div>
<div class="layui-input-inline"> <div class="layui-input-inline">
<input type="text" id="endTime" class="layui-input" name="bussinessEndtime" placeholder="结束时间"> <input type="text" id="endDate" class="layui-input" name="bussinessEndtime" placeholder="结束时间">
</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-inline"> <div class="layui-input-inline" id="busiScopeEl">
<input type="checkbox" name="businessScope[write]" title="保养" lay-skin="primary">
<input type="checkbox" name="businessScope[read]" title="维修" lay-skin="primary">
<input type="checkbox" name="businessScope[read]" title="清洗" lay-skin="primary">
<input type="checkbox" name="businessScope[read]" title="钣喷" lay-skin="primary">
</div> </div>
</div> </div>
<div class="layui-form-item" id="custom-scope"> <div class="layui-form-item" id="custom-scope">
...@@ -178,7 +179,7 @@ ...@@ -178,7 +179,7 @@
<label class="layui-form-label"></label> <label class="layui-form-label"></label>
<div> <div>
<div class="layui-input-inline"> <div class="layui-input-inline">
<input class="layui-input business-scope" name="businessScopeCustomize1" <input class="layui-input business-scope-cust" name="businessScopeCustomize"
placeholder="请自定义营业范围,建议不超过10个"> placeholder="请自定义营业范围,建议不超过10个">
</div> </div>
<div class="layui-input-inline"> <div class="layui-input-inline">
...@@ -244,11 +245,25 @@ ...@@ -244,11 +245,25 @@
<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-inline"> <div class="layui-input-inline">
<select id="accountLevelEl" name="merchantAccountLevel" 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">
<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" id="accountTypeEl">
</div> </div>
</div> </div>
<div class="layui-form-item" style="text-align: center;"> <div class="layui-form-item" style="text-align: center;">
<button class="layui-btn" lay-submit lay-filter="handleSubmit">下一步</button> <button class="layui-btn" lay-submit lay-filter="handleSubmit">下一步</button>
<button class="layui-btn" lay-submit lay-filter="handleCancel">取消</button> <button class="layui-btn" data-type="handleCancel">取消</button>
</div> </div>
</form> </form>
</div> </div>
...@@ -267,42 +282,64 @@ ...@@ -267,42 +282,64 @@
var helper = layui.helper var helper = layui.helper
var editData = {} var editData = {}
var scopeIdx = 1 var scopeIdx = 1
var treeObj = null
// 1-创建新商户;2-创建子商户;3-修改
var editLevel = 1
var id = null
var merchantForm = { var merchantForm = {
channelId: '',
merchantName: '',
merchantAbbreviation: '',
merchantType: '',
merchantOrgcode: '',
merchantLegalPerson: '',
merchantLegalPersonPhone: '',
isloginName: 0,
residentContact: '',
residentPhone: '',
bussinessBegintime: '',
bussinessEndtime: '',
lat: '', lat: '',
lng: '', lng: '',
merchantAddress: '', merchantAddress: '',
businessScope: '',
merchantFiles: [] merchantFiles: []
} }
var baseData = { var baseData = {
carBrandTreeList: [] channelList: [],
carBrandTreeList: [],
accountLevelList: [],
validPeriodList: [],
busiScopeList: [],
accountTypeList: []
} }
var startTime = laydate.render({ var startDate = laydate.render({
elem: '#startTime', //指定元素 elem: '#startDate', //指定元素
type: 'time', type: 'date',
done: function (value, date) { //监听日期被切换 done: function (value, date) { //监听日期被切换
if (value != "") { if (value != "") {
date.month = date.month - 1 date.month = date.month - 1
endTime.config.min = date endDate.config.min = date
} else { } else {
endTime.config.min = startTime.config.min endDate.config.min = startDate.config.min
} }
lay('#startTime').html(value) lay('#startDate').html(value)
} }
}) })
var endTime = laydate.render({ var endDate = laydate.render({
elem: '#endTime', //指定元素 elem: '#endDate', //指定元素
type: 'time', type: 'date',
done: function (value, date) { //监听日期被切换 done: function (value, date) { //监听日期被切换
if (value != "") { if (value != "") {
date.month = date.month - 1 date.month = date.month - 1
startTime.config.max = date startDate.config.max = date
} else { } else {
startTime.config.max = endTime.config.max startDate.config.max = endDate.config.max
} }
lay('#endTime').html(value) lay('#endDate').html(value)
} }
}) })
...@@ -316,18 +353,107 @@ ...@@ -316,18 +353,107 @@
helper.store.set('merchantMapObj', merchantForm) helper.store.set('merchantMapObj', merchantForm)
form.on('submit(handleSubmit)', function (data) { form.on('submit(handleSubmit)', function (data) {
console.log(data.field) // console.log(data.field)
var elList = $('.business-scope') var formData = data.field
var params = {
isloginName: 0
}
var fieldToFormNameList = ['channelId', 'merchantName', 'merchantAbbreviation', 'merchantType',
'merchantOrgcode',
'merchantLegalPerson', 'merchantLegalPersonPhone', 'residentContact', 'residentPhone',
'merchantLoginAccount', 'merchantLoginPassword',
'merchantAccountLevel', 'effectiveTime'
]
if (formData.isloginName == 'on') {
params.isloginName = 1
}
if (formData.bussinessBegintime) {
merchantForm.bussinessBegintime = new Date(formData.bussinessBegintime)
params.bussinessBegintime = new Date(formData.bussinessBegintime)
}
if (formData.bussinessEndtime) {
merchantForm.bussinessEndtime = new Date(formData.bussinessEndtime)
params.bussinessEndtime = new Date(formData.bussinessEndtime)
}
if (merchantForm.lat) {
params.lat = merchantForm.lat
params.lng = merchantForm.lng
params.merchantAddress = merchantForm.merchantAddress
}
$.each(fieldToFormNameList, function (index, item) {
if (formData[item]) {
merchantForm[item] = formData[item]
params[item] = formData[item]
}
})
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)
}
}
})
var elList = $('.business-scope-cust')
var tempList = []
$.each(elList, function (index, item) { $.each(elList, function (index, item) {
console.log(item.innerText) tempList.push(item.value)
})
merchantForm.businessScopeCustomize = tempList.join(',')
params.businessScopeCustomize = tempList.join(',')
merchantForm.merchantBrand = treeObj.getCheckedNodes(true)
params.merchantBrand = findId(merchantForm.merchantBrand, []).join(',')
params.merchantFiles = JSON.stringify(merchantForm.merchantFiles)
if (editLevel == 1) {
params.method = 'cn.com.glsx.merchants.merchant.saveMerchant'
} else if (editLevel == 2) {
params.method = 'cn.com.glsx.merchants.merchant.saveMerchant'
} else if (editLevel == 3) {
params.method = 'cn.com.glsx.merchants.merchant.updateMerchant'
}
// 保存状态 1.草稿 2.发布 3.注销 4.过期
if (merchantForm.status) {
params.status = merchantForm.status
} else {
params.status = 1
}
// console.log(merchantForm)
console.log(params)
request(params, function (res) {
console.log(res)
go('merchant', 'index')
}) })
return false return false
}) })
function findId(nodeList, idList) {
// var idList = []
$.each(nodeList, function (index, item) {
if (item.children) {
findId(item.children, idList)
} else {
idList.push(item.id)
}
})
return idList
}
// 按钮事件绑定 // 按钮事件绑定
var btnHandle = { var btnHandle = {
// 选择地址 // 选择地址
handleSelectAddr: function () { handleSelectAddr: function () {
helper.store.set('merchantMapObj', merchantForm)
layer.open({ layer.open({
type: 2, type: 2,
title: '选择地址', title: '选择地址',
...@@ -336,7 +462,7 @@ ...@@ -336,7 +462,7 @@
content: 'map.html', content: 'map.html',
success: function (layero, index) { success: function (layero, index) {
//向layer页面传值,传值主要代码 //向layer页面传值,传值主要代码
var body = layer.getChildFrame('body', index) // var body = layer.getChildFrame('body', index)
// console.log(body) // console.log(body)
//得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method(); //得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method();
// var iframeWin = window[layero.find('iframe')[0]['name']] // var iframeWin = window[layero.find('iframe')[0]['name']]
...@@ -352,7 +478,14 @@ ...@@ -352,7 +478,14 @@
var body = layer.getChildFrame('body', index) var body = layer.getChildFrame('body', index)
body.find('#mapBtn').click() body.find('#mapBtn').click()
var res = helper.store.get('merchantMapObj') var res = helper.store.get('merchantMapObj')
console.log(res)
merchantForm.lat = res.lat
merchantForm.lng = res.lng
merchantForm.merchantAddress = res.merchantAddress
setInput('#addrEl', merchantForm.merchantAddress)
layer.close(index) layer.close(index)
},
end: function () {
helper.store.remove('merchantMapObj') helper.store.remove('merchantMapObj')
} }
}) })
...@@ -363,7 +496,7 @@ ...@@ -363,7 +496,7 @@
var parent = $('#custom-scope') var parent = $('#custom-scope')
var subParent = $('<div class="layui-form-item"><label class="layui-form-label"></label></div>') var subParent = $('<div class="layui-form-item"><label class="layui-form-label"></label></div>')
var child1 = $( var child1 = $(
'<div class="layui-input-inline"><input class="layui-input business-scope" name="businessScopeCustomize' + '<div class="layui-input-inline"><input class="layui-input business-scope-cust" name="businessScopeCustomize' +
scopeIdx + '" placeholder="请自定义营业范围,建议不超过10个"></div>' scopeIdx + '" placeholder="请自定义营业范围,建议不超过10个"></div>'
) )
var child2 = $( var child2 = $(
...@@ -389,6 +522,9 @@ ...@@ -389,6 +522,9 @@
subParent.append(child2) subParent.append(child2)
parent.append(subParent) parent.append(subParent)
// console.log(parent) // console.log(parent)
},
handleCancel() {
go('merchant', 'index')
} }
} }
...@@ -407,7 +543,7 @@ ...@@ -407,7 +543,7 @@
var addEl = $('.img-add' + idx) var addEl = $('.img-add' + idx)
var reader = new FileReader() var reader = new FileReader()
var fileInfo = el[0].files[0] var fileInfo = el[0].files[0]
console.log(el) // console.log(el)
reader.readAsDataURL(fileInfo) reader.readAsDataURL(fileInfo)
reader.onload = function (e) { reader.onload = function (e) {
if (e) { if (e) {
...@@ -417,7 +553,10 @@ ...@@ -417,7 +553,10 @@
method: 'glsx.accounts.biz.common.pictureUpload', method: 'glsx.accounts.biz.common.pictureUpload',
file: base64 file: base64
}, function (result) { }, function (result) {
merchantForm.merchantFiles[idx] = result.data merchantForm.merchantFiles[idx] = {
fileUrl: result.data,
fileName: ''
}
imgEl.attr('src', result.data) imgEl.attr('src', result.data)
imgEl.removeClass('hide') imgEl.removeClass('hide')
imgEl.addClass('show') imgEl.addClass('show')
...@@ -430,18 +569,150 @@ ...@@ -430,18 +569,150 @@
}) })
function init() { function init() {
editLevel = qs('editLevel')
id = qs('id')
if (editLevel == 3) {
// merchantName = qs('merchantName')
getMerchantInfo()
} else {
getBusiScope()
getCarBrandTree()
getAccountType()
}
getChannel()
getAccountLevel()
getPeriod()
}
function setCheckbox(checkedStr, attr) {
if (!checkedStr || !checkedStr.length) {
return false
}
var list = []
if (layui._isArray(checkedStr)) {
list = checkedStr
} else {
list = checkedStr.split(',')
}
console.log(list)
$.each(list, function (index, item) {
$('input[class=' + attr + ']').attr("checked", true)
})
}
// 获取商户信息
function getMerchantInfo() {
request({
method: 'cn.com.glsx.merchants.merchant.findMerchantDetail',
id: id
}, function (res) {
console.log(res.data)
form.val('merchantForm', res.data)
merchantForm = res.data
getBusiScope()
getCarBrandTree() getCarBrandTree()
getAccountType()
// if (merchantForm.accountTypes.length) {
// setCheckbox(merchantForm.accountTypes, 'accounttypeId')
// }
})
} }
// 渠道
function getChannel() {
getDictData('channel', function (res) {
baseData.channelList = res.data
setSelectOption('#channelEl', 'channelList', 'dictValue', 'dictLabel')
})
}
// 品牌
function getCarBrandTree() { function getCarBrandTree() {
request({ request({
method: 'cn.com.glsx.merchants.merchantCommon.getCarbrandTree' method: 'cn.com.glsx.merchants.merchantCommon.getCarbrandTree'
}, function (res) { }, function (res) {
console.log(res)
baseData.carBrandTreeList = res.data baseData.carBrandTreeList = res.data
tree.create('carBrandTree', res.data) treeObj = tree.create('carBrandTree', res.data)
})
}
// 获取字典数据
function getDictData(dictType, fn) {
request({
method: 'cn.com.glsx.merchants.menu.findAllDictData',
dictType: dictType
}, function (res) {
fn && fn(res)
})
}
// 设置option
function setSelectOption(elName, listName, optionId, optionLabel) {
var el = $(elName)
$.each(baseData[listName], function (index, item) {
el.append(new Option(item[optionLabel], item[optionId]))
})
form.render('select')
}
// 设置input值
function setInput(elName, value) {
$(elName).val(value)
}
// 账户等级
function getAccountLevel() {
getDictData('account_level', function (res) {
baseData.accountLevelList = res.data
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 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">')
el.append(optionEl)
form.render('checkbox')
// 修改-回显
if (editLevel == 3 && merchantForm.businessScope) {
setCheckbox(merchantForm.businessScope, 'businessScope')
}
})
})
}
// 账户类型
function getAccountType() {
getDictData('account_type', function (res) {
// console.log(res.data)
baseData.accountTypeList = res.data
var el = $('#accountTypeEl')
$.each(baseData.accountTypeList, function (index, item) {
var optionEl = $('<input type="checkbox" class="accounttypeId" name="accountType[' + item
.dictValue + ']" title=' +
item.dictLabel + ' value="' + item.dictValue + '">')
el.append(optionEl)
form.render('checkbox')
// 修改-回显
if (editLevel == 3 && merchantForm.accountTypes.length) {
setCheckbox(merchantForm.accountTypes, 'accounttypeId')
}
})
}) })
// 品牌
} }
}) })
</script> </script>
......
...@@ -26,6 +26,10 @@ ...@@ -26,6 +26,10 @@
white-space: normal; white-space: normal;
} }
.merchant #searchForm .layui-inline {
margin-bottom: 5px;
}
.layui-btn-xs { .layui-btn-xs {
cursor: pointer; cursor: pointer;
} }
...@@ -39,11 +43,34 @@ ...@@ -39,11 +43,34 @@
<!-- <div id="tree"></div> --> <!-- <div id="tree"></div> -->
<div class="context-block"> <div class="context-block">
<div class="search-block"> <div class="search-block">
<button class="layui-btn" id="addBtn" lay-filter="handleAdd">创建商户</button>
<form class="layui-form" lay-filter="searchFilter" id="searchForm"> <form class="layui-form" lay-filter="searchFilter" id="searchForm">
<!-- <div> <div class="layui-inline" id="operateEl">
<button class="layui-btn" lay-filter="handleAdd">创建商户</button> <button class="layui-btn" id="addBtn">创建商户</button>
</div> --> <div class="layui-inline">
<label class="layui-form-label">渠道:</label>
<div class="layui-input-inline">
<select name="channelId" id="channelIdEl">
<option value="">请选择渠道</option>
</select>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">账户等级:</label>
<div class="layui-input-inline">
<select name="merchantAccountLevel" id="accountLevelEl">
<option value="">请选择账户等级</option>
</select>
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">账户类型:</label>
<div class="layui-input-inline">
<select name="accounttypeId" id="accountTypeIdEl">
<option value="">请选择账户类型</option>
</select>
</div>
</div>
</div>
<div class="layui-inline"> <div class="layui-inline">
<div class="layui-input-inline" style="width: 120px;"> <div class="layui-input-inline" style="width: 120px;">
<select name="name" lay-filter="nameFilter"> <select name="name" lay-filter="nameFilter">
...@@ -58,7 +85,7 @@ ...@@ -58,7 +85,7 @@
<div class="layui-inline"> <div class="layui-inline">
<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="searchStatus"> <select name="status" id="searchStatusEl">
<option value="">请选择客户状态</option> <option value="">请选择客户状态</option>
</select> </select>
</div> </div>
...@@ -82,106 +109,37 @@ ...@@ -82,106 +109,37 @@
<script src="/js/load.js"></script> <script src="/js/load.js"></script>
<script type="text/html" id="merchantBtns"> <script type="text/html" id="merchantBtns">
<a class="layui-btn-xs" lay-event="handleDetail">查看</a> <a class="layui-btn-xs" lay-event="handleDetail">查看</a>
{{# if((d.btn.edit)){ }}
<a class="layui-btn-xs" lay-event="handleEdit">修改</a> <a class="layui-btn-xs" lay-event="handleEdit">修改</a>
{{# } }}
{{# if((d.btn.createSubMerchant)){ }}
<a class="layui-btn-xs" lay-event="handleAddMerchant">创建子商户/门店</a> <a class="layui-btn-xs" lay-event="handleAddMerchant">创建子商户/门店</a>
{{# } }}
{{# if((d.btn.createStaff)){ }}
<a class="layui-btn-xs" lay-event="handleAddStaff">创建员工</a> <a class="layui-btn-xs" lay-event="handleAddStaff">创建员工</a>
{{# } }}
{{# if((d.btn.editPeriod)){ }}
<a class="layui-btn-xs" lay-event="handleVaildPeriod">修改账户有效期</a> <a class="layui-btn-xs" lay-event="handleVaildPeriod">修改账户有效期</a>
{{# } }}
</script> </script>
<script> <script>
layui.use(['gtree', 'request', 'store', 'table', 'layer'], function () { layui.use(['gtree', 'request', 'helper', 'table', 'layer'], function () {
var tree = layui.gtree var tree = layui.gtree
var request = layui.request var request = layui.request
var table = layui.table var table = layui.table
var form = layui.form var form = layui.form
var $ = layui.$ var $ = layui.$
var helper = layui.helper
var user = helper.store.get('user')
var isDxternal = helper.store.get('isDxternal')
var baseData = { var baseData = {
statusList: [] statusList: [],
} channelList: [],
// var list = [{ accountLevelList: [],
// confId: '1', accountTypeList: []
// confLabel: '账号登陆名'
// }, {
// confId: '2',
// confLabel: '手机号'
// }]
// var select = $("#searchName")
// $.each(list, function (index, item) {
// select.append(new Option(item.confLabel, item.confId))
// })
// form.render('select')
// request({
// a: 1
// })
var inst = tree.create('tree', [{
id: 1,
label: '一级菜单',
children: [{
id: 4,
label: '二级菜单',
children: [{
id: 9,
label: '三级功能',
children: [
// value: '1,2,3|人保,平安,寿险'
{
id: 111,
label: '人保',
logo: 'PR'
},
{
id: 112,
label: '平安',
logo: 'PR'
},
{
id: 113,
label: '寿险',
logo: 'PR'
}
]
},
{
id: 10,
label: '三级功能-1',
value: null
} }
]
}]
},
{
id: 2,
label: '一级菜单2',
children: [{
id: 5,
label: '二级菜单2',
children: [
// value: '1,2,3|人保,平安,寿险'
{
id: 114,
label: '人保',
logo: 'PR'
},
{
id: 115,
label: '平安',
logo: 'PR'
},
{
id: 116,
label: '寿险',
logo: 'PR'
}
]
},
{
id: 6,
label: '二级菜单2.0'
}
]
}
])
var merchantTable = table.render({ var merchantTable = table.render({
elem: '#merchantTable', elem: '#merchantTable',
page: true, page: true,
...@@ -249,9 +207,10 @@ ...@@ -249,9 +207,10 @@
}) })
table.on('tool(merchant-table-filter)', function (obj) { table.on('tool(merchant-table-filter)', function (obj) {
console.log(obj) // console.log(obj)
var eventName = obj.event var eventName = obj.event
var row = obj.data var row = obj.data
console.log(row)
switch (eventName) { switch (eventName) {
// 查看 // 查看
case 'handleDetail': case 'handleDetail':
...@@ -259,60 +218,65 @@ ...@@ -259,60 +218,65 @@
break break
// 修改 // 修改
case 'handleEdit': case 'handleEdit':
// 1-创建新商户;2-创建子商户;3-修改
go('merchant', 'edit', {
editLevel: 3,
id: row.id
// merchantName: row.merchantName
})
break break
// 创建子商户/门店 // 创建子商户/门店
case 'handleAddMerchant': case 'handleAddMerchant':
go('merchant', 'edit') // 1-创建新商户;2-创建子商户;3-修改
go('merchant', 'edit', {
editLevel: 2,
id: row.id
})
break break
// 创建员工 // 创建员工
case 'handleAddStaff': case 'handleAddStaff':
go('merchant', 'edit') go('employee', 'add')
break break
// 修改账户有效期 // 修改账户有效期
case 'handleVaildPeriod': case 'handleVaildPeriod':
// console.log(row) // console.log(row)
var layerIdx = layer.open({ layer.open({
type: 2, type: 2,
title: '修改账户的有效期', title: '修改账户的有效期',
area: ['700px', '420px'], area: ['700px', '420px'],
fixed: false, //不固定 fixed: false, //不固定
// maxmin: true, // maxmin: true,
btn: ['确定', '取消'], btn: ['确定', '取消'],
content: 'validPeriodForm.html?id=' + row.id + '&validPeriod=' + '365', content: 'validPeriodForm.html?id=' + row.id + '&effectiveTime=' + row.effectiveTime,
yes: function (index, layero) { yes: function (index, layero) {
// console.log(layero)
// var res = window["layui-layer-iframe" + index].callbackdata()
// console.log(res)
// 获取iframe层的body
var body = layer.getChildFrame('body', index) var body = layer.getChildFrame('body', index)
body.contents().find('#isValid').attr('value', 'no') helper.store.set('isRefresh', false)
body.find('#periodVerifyBtn').click() body.find('#periodVerifyBtn').click()
if (body.contents().find('#isValid').val() === 'yes') {
// console.log('+++++++++++')
layer.msg('操作成功', {
icon: 1
})
layer.close(index)
}
}, },
cancel: function (index, layero) { end: function () {
// layer.close(index) var isRefresh = helper.store.get('isRefresh')
if (isRefresh) {
getTabelList()
}
helper.store.remove('isRefresh')
} }
}) })
console.log(layerIdx)
break break
} }
}) })
getVaildPeriod() init()
getTabelList()
// form.on('handleAdd', function () { // form.on('handleAdd', function () {
// console.log('00000') // console.log('00000')
// return false // return false
// }) // })
$('#addBtn').on('click', function() { $('#addBtn').on('click', function () {
go('merchant', 'edit') // 1-创建新商户;2-创建子商户;3-修改
go('merchant', 'edit', {
editLevel: 1
})
return false
}) })
// 搜索绑定事件 // 搜索绑定事件
form.on('submit(searchSubmit)', function () { form.on('submit(searchSubmit)', function () {
...@@ -345,6 +309,61 @@ ...@@ -345,6 +309,61 @@
var data = res.data var data = res.data
$.each(data.data, function (index, item) { $.each(data.data, function (index, item) {
item.index = index + 1 + pageSize * (pageNum - 1) item.index = index + 1 + pageSize * (pageNum - 1)
item.btn = {
edit: false,
createSubMerchant: false,
createStaff: false,
editPeriod: false
}
/** btn
* check - 查看(无需判断,均有)
* edit - 修改
* createSubMerchant - 创建子商户/门店
* createStaff - 创建员工
* editPeriod - 修改账户有效期
* **/
// status(账户状态 - 列表):1-草稿;2-正常;3-注销;4-过期
// merchantAccountLevel(账户等级 - 列表):1-工厂;2-省代;3-市代;4-门店
// 外部系统
if (isDxternal) {
// 状态 - 正常
if (item.status == 2) {
// 本身
if (item.id == user.merchantId) {
item.btn.createStaff = true
if (merchantAccountLevel != 4) {
item.btn.createSubMerchant = true
}
} else { // 下级商户
item.btn.edit = true
item.btn.editPeriod = true
// 直属门店
if (item.merchantAccountLevel == 4) {
if (item.parentId == user.merchantId) {
item.btn.createStaff = true
}
} else {
item.btn.createSubMerchant = true
}
}
} else if (item.status != 3) {
item.btn.edit = true
}
} else {
// 超管登陆
if (item.status != 3) {
item.btn.edit = true
}
if ((item.status == 2)) {
item.btn.createStaff = true
if (item.merchantAccountLevel != 4) {
item.btn.createSubMerchant = true
}
}
if (item.status != 1) {
item.btn.editPeriod = true
}
}
}) })
var options = { var options = {
data: data.data data: data.data
...@@ -358,22 +377,75 @@ ...@@ -358,22 +377,75 @@
}) })
} }
// 获取有效期 // 获取字典数据
function getVaildPeriod() { function getDictData(dictType, fn) {
request({ request({
method: 'cn.com.glsx.merchants.menu.findAllDictData', method: 'cn.com.glsx.merchants.menu.findAllDictData',
dictType: 'merchant_status' dictType: dictType
}, function (res) { }, function (res) {
if (res.code === '0') { fn && fn(res)
baseData.statusList = res.data })
var searchStatus = $("#searchStatus") }
$.each(baseData.statusList, function (index, item) {
searchStatus.append(new Option(item.dictLabel, item.dictValue)) // 设置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') form.render('select')
} }
// 获取有效期
function getVaildPeriod() {
getDictData('merchant_status', function (res) {
baseData.statusList = res.data
setSelectOption('#searchStatusEl', 'statusList', 'dictValue', 'dictLabel')
})
}
// 获取渠道
function getChannel() {
getDictData('channel', function (res) {
baseData.channelList = res.data
setSelectOption('#channelIdEl', 'channelList', 'dictValue', 'dictLabel')
})
}
// 获取账户等级
function getAccountLevel() {
getDictData('account_level', function (res) {
baseData.accountLevelList = res.data
setSelectOption('#accountLevelEl', 'accountLevelList', 'dictValue', 'dictLabel')
}) })
} }
// 获取账户类型
function getAccountType() {
getDictData('account_type', function (res) {
baseData.accountTypeList = res.data
setSelectOption('#accountTypeIdEl', 'accountTypeList', 'dictValue', 'dictLabel')
})
}
// 功能点按需出现
function elRemove() {
$('#operateEl').remove()
}
function init() {
// 运营系统
// if (!isDxternal) {
if (isDxternal) {
getChannel()
getAccountLevel()
getAccountType()
} else {
elRemove()
}
getVaildPeriod()
getTabelList()
}
}) })
</script> </script>
</body> </body>
......
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
</button> </button>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<div align="center" class="layui-input-inline" style="width: 400px; height: 300px;"> <div class="layui-input-inline" style="width: 400px; height: 300px;">
<div id="container"></div> <div id="container"></div>
</div> </div>
<div class="poi-list layui-input-inline poi-list" id="pois"></div> <div class="poi-list layui-input-inline poi-list" id="pois"></div>
...@@ -128,9 +128,9 @@ ...@@ -128,9 +128,9 @@
function init() { function init() {
var __pos = null var __pos = null
mapData = helper.store.get('merchantMapObj') mapData = helper.store.get('merchantMapObj')
// console.log(mapData)
if (mapData.lat && mapData.lng) { if (mapData.lat && mapData.lng) {
__pos = [mapData.lat, mapData.lng] __pos = [mapData.lng, mapData.lat]
modelVal('merchantAddress', mapData.merchantAddress)
} }
marker = new AMap.Marker({ marker = new AMap.Marker({
......
...@@ -26,63 +26,49 @@ ...@@ -26,63 +26,49 @@
<div class="layui-form-item"> <div class="layui-form-item">
<div class="layui-form-label required" style="width: 120px;">账户有效期:</div> <div class="layui-form-label required" style="width: 120px;">账户有效期:</div>
<div class="layui-input-inline" style="width: auto;"> <div class="layui-input-inline" style="width: auto;">
<select name="validPeriod" id="periodSelect" required lay-verify="required"> <select name="effectiveTime" id="periodSelect" required lay-verify="required">
<option value="">请选择</option> <option value="">请选择</option>
</select> </select>
<p>(注:永久有效不超过所属工厂商户的有效期)</p> <p>(注:永久有效不超过所属工厂商户的有效期)</p>
</div> </div>
<button id="periodVerifyBtn" lay-submit lay-filter="periodSubmit" style="display: none;"></button> <button id="periodVerifyBtn" lay-submit lay-filter="periodSubmit" style="display: none;"></button>
<!-- <div class="layui-form-item" style="padding: 40px 20px;">
<div class="layui-input-inline">
<button class="layui-btn layui-btn-sm" lay-submit lay-filter="validSubmit">立即提交</button>
<button type="reset" class="layui-btn layui-btn-sm layui-btn-primary">重置</button>
</div>
</div> -->
</div> </div>
</form> </form>
<input type="text" id="isValid" name="isValid" value="no" style="display: none;" class="layui-input">
</main> </main>
</div> </div>
<script src="https://www.layuicdn.com/layui/layui.js"></script> <script src="https://www.layuicdn.com/layui/layui.js"></script>
<script src="/js/load.js"></script> <script src="/js/load.js"></script>
<script> <script>
layui.use(['form', 'request'], function () { layui.use(['form', 'helper', 'request'], function () {
var form = layui.form var form = layui.form
var request = layui.request var request = layui.request
var $ = layui.$ var $ = layui.$
var helper = layui.helper
var currLayerIdx = parent.layer.getFrameIndex(window.name) var currLayerIdx = parent.layer.getFrameIndex(window.name)
var baseData = {} var baseData = {}
var vaildData = { var vaildData = {
id: getQueryString('id'), id: getQueryString('id'),
validPeriod: getQueryString('validPeriod') effectiveTime: getQueryString('effectiveTime')
} }
getVaildPeriod() getVaildPeriod()
// form.on('submit(validSubmit)', function (data) {
// var params = {
// id: vaildData.id,
// validPeriod: data.field.validPeriod
// }
// console.log(params)
// // layer.msg('操作成功', { time: 2000 })
// parent.layer.close(currLayerIdx)
// return false
// })
form.on('submit(periodSubmit)', function (data) { form.on('submit(periodSubmit)', function (data) {
// console.log(data) var params = {
// console.log('点击啦---') method: 'cn.com.glsx.merchants.merchant.updateValPerByMerId',
// 调接口 id: vaildData.id,
$('#isValid').attr('value', 'yes') effectiveTime: data.field.effectiveTime
}
request(params, function (res) {
if (res.code == '0') {
helper.store.set('isRefresh', true)
parent.layer.close(currLayerIdx)
}
})
return false return false
}) })
// function callbackdata() {
// return vaildData
// }
// 获取参数 // 获取参数
function getQueryString(name) { function getQueryString(name) {
var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i') var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i')
...@@ -100,13 +86,13 @@ ...@@ -100,13 +86,13 @@
dictType: 'account_validity_period' dictType: 'account_validity_period'
}, function (res) { }, function (res) {
if (res.code === '0') { if (res.code === '0') {
baseData.validPeriodList = res.data baseData.effectiveTimeList = res.data
var periodSelect = $('#periodSelect') var periodSelect = $('#periodSelect')
$.each(baseData.validPeriodList, function (index, item) { $.each(baseData.effectiveTimeList, function (index, item) {
periodSelect.append(new Option(item.dictLabel, item.dictValue)) periodSelect.append(new Option(item.dictLabel, item.dictValue))
}) })
form.val('periodFilter', { form.val('periodFilter', {
validPeriod: vaildData.validPeriod effectiveTime: vaildData.effectiveTime
}) })
form.render('select') form.render('select')
} }
......
...@@ -45,6 +45,11 @@ function append() { ...@@ -45,6 +45,11 @@ function append() {
function isAppend() { function isAppend() {
var _href = location.href.split('/') var _href = location.href.split('/')
var _path = _href.slice(_href.length - 1, _href.length).toString() var _path = _href.slice(_href.length - 1, _href.length).toString()
layui.use(['store'], function () {
var store = layui.store
// isDxternal: true - 外部独立系统;false - 运营平台
store.set('isDxternal', _path.split('?')[0] !== 'login.html' && self == top)
})
return _path.split('?')[0] !== 'login.html' && self == top return _path.split('?')[0] !== 'login.html' && self == top
} }
......
...@@ -59,6 +59,7 @@ ...@@ -59,6 +59,7 @@
if (result.code == '0') { if (result.code == '0') {
var sessionId = result.data.sessionId var sessionId = result.data.sessionId
helper.store.set('token', sessionId) helper.store.set('token', sessionId)
helper.store.set('user', result.data)
go('merchant', 'index') go('merchant', 'index')
} }
}) })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!