Commit d7eb4234 by cwq0219

商户管理,分页

1 parent cb1435eb
......@@ -295,7 +295,7 @@
</div>
</div>
<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="handleFirstSubmit">下一步</button>
<button class="layui-btn" data-type="handleCancel">取消</button>
</div>
</form>
......@@ -377,7 +377,7 @@
var startDate = laydate.render({
elem: '#startDate', //指定元素
type: 'date',
type: 'time',
done: function (value, date) { //监听日期被切换
if (value != "") {
date.month = date.month - 1
......@@ -390,7 +390,7 @@
})
var endDate = laydate.render({
elem: '#endDate', //指定元素
type: 'date',
type: 'time',
done: function (value, date) { //监听日期被切换
if (value != "") {
date.month = date.month - 1
......@@ -409,15 +409,9 @@
// lng: '39.90923',
// merchantAddress: '深圳'
// })
helper.store.set('merchantMapObj', merchantForm)
// helper.store.set('merchantMapObj', merchantForm)
form.on('submit(handleSubmit)', function (data) {
//---------------
// baseIsShow(false)
// treeIsShow(true)
// getMenuList()
// findMenuFunTreeByMerId()
//-------------------
form.on('submit(handleFirstSubmit)', function (data) {
// console.log(editLevel)
// console.log(data.field)
var formData = data.field
......@@ -434,12 +428,12 @@
params.isloginName = 1
}
if (formData.bussinessBegintime) {
merchantForm.bussinessBegintime = new Date(formData.bussinessBegintime)
params.bussinessBegintime = new Date(formData.bussinessBegintime)
merchantForm.bussinessBegintime = formData.bussinessBegintime
params.bussinessBegintime = formData.bussinessBegintime
}
if (formData.bussinessEndtime) {
merchantForm.bussinessEndtime = new Date(formData.bussinessEndtime)
params.bussinessEndtime = new Date(formData.bussinessEndtime)
merchantForm.bussinessEndtime = formData.bussinessEndtime
params.bussinessEndtime = formData.bussinessEndtime
}
if (merchantForm.lat) {
params.lat = merchantForm.lat
......@@ -505,16 +499,42 @@
}
console.log(editLevel)
console.log(params)
layer.msg('操作成功', {
icon: 1
})
// merchantId = 58
// merchantForm.merchantAccountLevel = parseInt(merchantForm.merchantAccountLevel)
// getMerchantApi(merchantId, function (res) {
// form.val('merchantForm', res.data)
// merchantForm = res.data
// baseIsShow(false)
// treeIsShow(true)
// getById()
// })
request(params, function (res) {
console.log(res)
// authorityTree
if (res.code == '0') {
if (editLevel == 3) {
layer.msg('操作成功', {
icon: 1
})
go('merchant', 'index')
} else {
merchantId = res.data
merchantForm.merchantAccountLevel = parseInt(merchantForm.merchantAccountLevel)
getMerchantApi(merchantId, function (res) {
form.val('merchantForm', res.data)
merchantForm = res.data
baseIsShow(false)
treeIsShow(true)
getById()
})
}
} else {
// layer.msg('操作成功', {
// icon: 1
// })
}
})
return false
......@@ -668,45 +688,47 @@
function init() {
editLevel = qs('editLevel')
isFactory = (qs('isFactory') == 'true')
// console.log(isFactory)
if (isFactory) {
merchantId = qs('id')
$('#subMerchantEl').hide()
getAccountLevel()
getMerchantInfo()
} else {
// 创建/编辑子商户
parentMerchantId = qs('parentId')
if (editLevel == 3) {
merchantId = qs('id')
}
$('#validPeriodEl').attr('disabled', true)
$('#channelEl').attr('disabled', true)
getParentInfo()
}
step = qs('step')
if (step == 1) {
treeIsShow(false)
} else {
baseIsShow(false)
// getMenuList()
// getById()
// findMenuFunTreeByMerId()
}
// 创建商户
if (editLevel == 1) {
$('#accountLevelEl').attr('disabled', true)
getBusiScope()
getCarBrandTree()
getAccountLevel()
getAccountType()
} else {
merchantId = qs('id')
if (editLevel == 3) {
// merchantName = qs('merchantName')
// getMerchantInfo()
$('#accountLevelEl').attr('disabled', true)
} else {
getBusiScope()
getCarBrandTree()
getAccountType()
}
if (isFactory) {
getAccountLevel()
getMerchantInfo()
} else {
// 创建/编辑子商户
parentMerchantId = qs('parentId')
// $('#validPeriodEl').attr('disabled', true)
$('#channelEl').attr('disabled', true)
getParentInfo()
}
}
if (isFactory) {
$('#subMerchantEl').hide()
}
getChannel()
getPeriod()
bindEvent()
}
function bindEvent() {
......@@ -781,11 +803,11 @@
getAccountType()
recoveryBusiScopeCus()
recoveryFile()
if (merchantForm.status == 1) {
findMenuFunTreeByMerId()
} else {
// if (merchantForm.status == 1) {
// findMenuFunTreeByMerId()
// } else {
getById()
}
// }
})
}
......@@ -813,6 +835,7 @@
treeObj = tree.create('carBrandTree', res.data, {
checkedList: checkedList
})
bindEvent()
})
}
// 获取字典数据
......@@ -843,6 +866,7 @@
function getAccountLevel() {
getDictData('account_level', function (res) {
baseData.accountLevelList = res.data
console.log(baseData.accountLevelList)
if (!isFactory) {
var tempList = []
$.each(baseData.accountLevelList, function (index, item) {
......@@ -955,30 +979,10 @@
})
})
}
// 树--
// function getMenuList() {
// request({
// method: 'cn.com.glsx.merchants.merchant.findPermissionsByMerId',
// id: merchantId
// }, function(res) {
// console.log(res.data)
// menuList = res.data
// })
// }
// 树
// console.log(merchantId)
// if (merchantId) {
// getById()
// } else {
// findMenuFunTreeByMerId()
// }
// start
// 数 - start
var laytpl = layui.laytpl
var xmSelect = layui.xmSelect
// var tree = layui.gtree
// var helper = layui.helper
var check_arr = []
var requestList = []
var templateData = {}
......@@ -1147,7 +1151,8 @@
// 查询商户的菜单权限树
function findMenuFunTreeByMerId() {
// console.log(merchantForm, '查询商户菜单权限树')
console.log(merchantForm, '查询商户菜单权限树')
console.log(parentMerchantId, 'parentMerchantId')
var params = {}
if (parentMerchantId) {
params = {
......@@ -1165,22 +1170,22 @@
accountLevel: merchantForm.merchantAccountLevel
}
}
console.log(params.method)
request(params, function (res) {
if (res.code == '0') {
// callback(res.data)
menuFunTreeData = res.data
console.log(menuFunTreeData)
// console.log(menuFunTreeData)
var accountType = $('#accountType')
$.each(menuFunTreeData, function (index, item) {
// console.log(item)
var str = $('<input lay-filter="switch" type="checkbox" name="accounttypeId" value="' + item
.accounttypeId + '" title="' + item.accounttypeName + '" />')
accountType.append(str)
console.log(check_arr, '0000000000')
// console.log(check_arr, '0000000000')
if (merchantId) {
// 角色权限的check
for (var i = 0; i < check_arr.length; i++) {
console.log(check_arr[i])
if (check_arr[i].accounttypeId == item.accounttypeId) {
var productData = check_arr[i]
str.attr("checked", true)
......@@ -1188,7 +1193,6 @@
title: item.accounttypeName,
value: item.accounttypeId
}
console.log(obj)
active.tabAdd(obj)
var selectArr = []
var menuData = []
......@@ -1202,7 +1206,6 @@
}, item.accounttypeId, item.products, idList)
}
// // 产品的回显
console.log(selectEl[item.accounttypeId], '\\\\\\\\\\\\\\\\\\')
selectEl[item.accounttypeId].setValue(selectArr)
var filterName = 'treeTab' + item.accounttypeId
var productId = 'tab_' + item.accounttypeId + '_' + item.products[0].productId
......@@ -1223,7 +1226,6 @@
// 根据id获取角色详情
function getById() {
console.log('getById---')
var params = {
method: 'cn.com.glsx.merchants.merchant.findPermissionsByMerId',
// method: 'org.ore.api.role.getById',
......
......@@ -106,6 +106,7 @@
</form>
</div>
<table class="layui-table" id="merchantTable" lay-filter="merchant-table-filter"></table>
<div id="merchantPage"></div>
</div>
</main>
</div>
......@@ -131,10 +132,11 @@
{{# } }}
</script>
<script>
layui.use(['gtree', 'request', 'helper', 'table', 'layer'], function () {
layui.use(['gtree', 'request', 'helper', 'table', 'laypage', 'layer'], function () {
var tree = layui.gtree
var request = layui.request
var table = layui.table
var laypage = layui.laypage
var form = layui.form
var $ = layui.$
var helper = layui.helper
......@@ -148,9 +150,33 @@
accountTypeList: []
}
var page = {
pageNum: 1,
pageSize: 10
}
var pageOptions = {
elem: 'merchantPage',
groups: 5,
layout: ['limit', 'count', 'page', 'skip'],
jump: function (obj, first) {
//obj包含了当前分页的所有参数,比如:
console.log(obj.curr); //得到当前页,以便向服务端请求对应页的数据。
console.log(obj.limit); //得到每页显示的条数
page.pageNum = obj.curr
page.pageSize = obj.limit
// getTabelList()
//首次不执行
if (!first) {
//do something
getTabelList()
}
}
}
var merchantTable = table.render({
elem: '#merchantTable',
page: true,
page: false,
// done: function (res, curr, count) {
// console.log(res)
// },
......@@ -222,7 +248,9 @@
switch (eventName) {
// 查看
case 'handleDetail':
go('merchant', 'detail', { merchantId: row.id })
go('merchant', 'detail', {
merchantId: row.id
})
break
// 修改
case 'handleEdit':
......@@ -299,10 +327,6 @@
init()
// form.on('handleAdd', function () {
// console.log('00000')
// return false
// })
$('#addBtn').on('click', function () {
// 1-创建新商户;2-创建子商户;3-修改
go('merchant', 'edit', {
......@@ -325,11 +349,9 @@
// 获取表格数据
function getTabelList(isResetPageNum = false) {
var pageNum = isResetPageNum ? 1 : merchantTable.config.index
var pageSize = merchantTable.config.limit
var params = {
pageNum: pageNum,
pageSize: pageSize,
pageNum: page.pageNum,
pageSize: page.pageSize,
method: 'cn.com.glsx.merchants.menu.findMerchantByPage'
}
var searchData = $('#searchForm [name]').serializeArray()
......@@ -342,7 +364,7 @@
// console.log(res)
var data = res.data
$.each(data.data, function (index, item) {
item.index = index + 1 + pageSize * (pageNum - 1)
item.index = index + 1 + page.pageSize * (page.pageNum - 1)
item.btn = {
edit: false,
createSubMerchant: false,
......@@ -403,11 +425,11 @@
var options = {
data: data.data
}
pageOptions.count = data.count
if (isResetPageNum) {
options.page = {
curr: 1
}
pageOptions.curr = 1
}
laypage.render(pageOptions)
merchantTable.reload(options)
})
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!