Authored by liuyue

优惠码js修改

... ... @@ -91,9 +91,9 @@ grid.prototype={
},
__getparams:function(){
var g = this, p = this.options;
if (!p.page) p.page = 1;
//if (!p.page) p.page = 1;
var param = {};
//urlArr = location.hash.substring(1).split('&&');
urlArr = location.hash.substring(1).split('&&');
if (p.parms) {
if (typeof (p.parms) == "function") {
... ... @@ -101,28 +101,34 @@ grid.prototype={
}
}
/*$.each(urlArr, function(i, value){
//param.page = p.page;
param.size = p.size;
$.each(urlArr, function(i, value){
var result = value.split('='),
key = result[0],
value = result[1];
if (key !== '') {
if (key !== undefined) {
param[key] = value;
}
});*/
});
if (p.page) {
param.page = p.page;
}
if (p.status !== undefined) {
console.log(p.status);
param.status = p.status;
}
param.page = p.page;
param.size = p.size;
console.log(param);
var html = '';
$.each(param, function(key, value) {
if (value !== '') {
if (value !== '' && !isNaN(value)) {
html += key + '=' + value + '&&';
}
});
... ... @@ -143,6 +149,7 @@ grid.prototype={
onPageClick: function(pageNumber, event) {
p.page = pageNumber;
g.renderBody();
//g.__getparams();
return false;
}
});
... ... @@ -269,11 +276,10 @@ grid.prototype={
p[key] = value;
});
}
//p.page=1;
g.__bodyload();
}
},
}
... ...
... ... @@ -46,7 +46,7 @@ exports.init = function() {
* 优惠码tab卡文字替换及默认选中
* @param: param(请求count接口参数), indexStatus(切换条件时选中的tab卡)
*/
function tabShow(param, indexStatus) {
function tabShow(param, filterStatus) {
var param = param || {};
$.ajax({
type: 'POST',
... ... @@ -54,37 +54,59 @@ exports.init = function() {
url: '/getCodeCount',
data: param,
success: function(res) {
var tpl = Handlebars.compile($('#tab-tpl').html());
var tpl = Handlebars.compile($('#tab-tpl').html()),
$activeTab = null;
$('.list-tabs ul').html(tpl({
data: res.data.data
}));
$('.list-tabs').find('li').each(function() {
var status = $(this).data('status');
var urlArr = location.hash.substring(1).split('&&'),
urlStatus = null;
$(this).find('span').text(statusConvert(status));
$.each(urlArr, function(i, value){
var result = value.split('='),
key = result[0],
value = result[1];
if (status === 'all') {
$(this).addClass('active').siblings().removeClass('active');
if (key === 'status') {
urlStatus = value;
}
});
if (indexStatus === undefined) {
$('.list-tabs').find('[data-status="all"]').addClass('active').siblings().removeClass('active');
} else {
$('.list-tabs').find('[data-status="' + indexStatus + '"]').addClass('active').siblings().removeClass('active');
}
$('.list-tabs').find('li').each(function() {
var status = $(this).data('status');
$(this).find('span').text(statusConvert(status));
});
$activeTab = $('.list-tabs').find('[data-status="all"]');
if (urlStatus) {
$activeTab = $('.list-tabs').find('[data-status="' + urlStatus + '"]');
} else if (filterStatus) {
$activeTab = $('.list-tabs').find('[data-status="' + filterStatus + '"]');
}
if ($activeTab.size() <= 0) {
$activeTab = $('.list-tabs').find('[data-status="all"]');
}
$activeTab.addClass('active').siblings().removeClass('active');
}
})
}
tabShow();
//tab卡切换列表事件
$('.list-tabs').on('click', 'li', function() {
$(this).addClass('active').siblings().removeClass('active');
g.reload();
g.reload({
page: 1,
status: parseInt($('.list-tabs').find('.active').data('status'))
});
});
var btnAuthority = JSON.parse($("#btnAuthority").val());
... ... @@ -150,9 +172,11 @@ exports.init = function() {
batchNo: $.trim($('#filter-id').val()),
name: $.trim($('#filter-name').val()),
reqDepartment:$.trim($('#filter-dep').val())
}, parseInt($('.list-tabs').find('.active').data('status')))
}, $('.list-tabs').find('.active').data('status'));
location.hash = '';
g.reload({
status: 'all',
page: 1
});
});
... ...