Authored by liuyue

优惠码js修改

@@ -91,9 +91,9 @@ grid.prototype={ @@ -91,9 +91,9 @@ grid.prototype={
91 }, 91 },
92 __getparams:function(){ 92 __getparams:function(){
93 var g = this, p = this.options; 93 var g = this, p = this.options;
94 - if (!p.page) p.page = 1; 94 + //if (!p.page) p.page = 1;
95 var param = {}; 95 var param = {};
96 - //urlArr = location.hash.substring(1).split('&&'); 96 + urlArr = location.hash.substring(1).split('&&');
97 97
98 if (p.parms) { 98 if (p.parms) {
99 if (typeof (p.parms) == "function") { 99 if (typeof (p.parms) == "function") {
@@ -101,28 +101,34 @@ grid.prototype={ @@ -101,28 +101,34 @@ grid.prototype={
101 } 101 }
102 } 102 }
103 103
104 - /*$.each(urlArr, function(i, value){ 104 + //param.page = p.page;
  105 + param.size = p.size;
  106 +
  107 + $.each(urlArr, function(i, value){
105 var result = value.split('='), 108 var result = value.split('='),
106 key = result[0], 109 key = result[0],
107 value = result[1]; 110 value = result[1];
108 111
109 - if (key !== '') { 112 + if (key !== undefined) {
110 param[key] = value; 113 param[key] = value;
  114 +
111 } 115 }
112 116
113 - });*/ 117 + });
114 118
115 - 119 + if (p.page) {
  120 + param.page = p.page;
  121 + }
116 122
  123 + if (p.status !== undefined) {
  124 + console.log(p.status);
  125 + param.status = p.status;
  126 + }
117 127
118 128
119 -  
120 - param.page = p.page;  
121 - param.size = p.size;  
122 - console.log(param);  
123 var html = ''; 129 var html = '';
124 $.each(param, function(key, value) { 130 $.each(param, function(key, value) {
125 - if (value !== '') { 131 + if (value !== '' && !isNaN(value)) {
126 html += key + '=' + value + '&&'; 132 html += key + '=' + value + '&&';
127 } 133 }
128 }); 134 });
@@ -143,6 +149,7 @@ grid.prototype={ @@ -143,6 +149,7 @@ grid.prototype={
143 onPageClick: function(pageNumber, event) { 149 onPageClick: function(pageNumber, event) {
144 p.page = pageNumber; 150 p.page = pageNumber;
145 g.renderBody(); 151 g.renderBody();
  152 + //g.__getparams();
146 return false; 153 return false;
147 } 154 }
148 }); 155 });
@@ -269,11 +276,10 @@ grid.prototype={ @@ -269,11 +276,10 @@ grid.prototype={
269 p[key] = value; 276 p[key] = value;
270 }); 277 });
271 } 278 }
272 -  
273 279
274 //p.page=1; 280 //p.page=1;
275 g.__bodyload(); 281 g.__bodyload();
276 - } 282 + },
277 283
278 } 284 }
279 285
@@ -46,7 +46,7 @@ exports.init = function() { @@ -46,7 +46,7 @@ exports.init = function() {
46 * 优惠码tab卡文字替换及默认选中 46 * 优惠码tab卡文字替换及默认选中
47 * @param: param(请求count接口参数), indexStatus(切换条件时选中的tab卡) 47 * @param: param(请求count接口参数), indexStatus(切换条件时选中的tab卡)
48 */ 48 */
49 - function tabShow(param, indexStatus) { 49 + function tabShow(param, filterStatus) {
50 var param = param || {}; 50 var param = param || {};
51 $.ajax({ 51 $.ajax({
52 type: 'POST', 52 type: 'POST',
@@ -54,37 +54,59 @@ exports.init = function() { @@ -54,37 +54,59 @@ exports.init = function() {
54 url: '/getCodeCount', 54 url: '/getCodeCount',
55 data: param, 55 data: param,
56 success: function(res) { 56 success: function(res) {
57 - var tpl = Handlebars.compile($('#tab-tpl').html());  
58 - 57 + var tpl = Handlebars.compile($('#tab-tpl').html()),
  58 + $activeTab = null;
  59 +
59 $('.list-tabs ul').html(tpl({ 60 $('.list-tabs ul').html(tpl({
60 data: res.data.data 61 data: res.data.data
61 })); 62 }));
62 63
63 - $('.list-tabs').find('li').each(function() {  
64 - var status = $(this).data('status'); 64 + var urlArr = location.hash.substring(1).split('&&'),
  65 + urlStatus = null;
65 66
66 - $(this).find('span').text(statusConvert(status)); 67 + $.each(urlArr, function(i, value){
  68 + var result = value.split('='),
  69 + key = result[0],
  70 + value = result[1];
67 71
68 - if (status === 'all') {  
69 - $(this).addClass('active').siblings().removeClass('active'); 72 + if (key === 'status') {
  73 + urlStatus = value;
70 } 74 }
  75 +
71 }); 76 });
  77 +
72 78
73 - if (indexStatus === undefined) {  
74 - $('.list-tabs').find('[data-status="all"]').addClass('active').siblings().removeClass('active');  
75 - } else {  
76 - $('.list-tabs').find('[data-status="' + indexStatus + '"]').addClass('active').siblings().removeClass('active');  
77 - } 79 + $('.list-tabs').find('li').each(function() {
  80 + var status = $(this).data('status');
  81 + $(this).find('span').text(statusConvert(status));
  82 +
  83 + });
  84 +
  85 + $activeTab = $('.list-tabs').find('[data-status="all"]');
  86 + if (urlStatus) {
  87 + $activeTab = $('.list-tabs').find('[data-status="' + urlStatus + '"]');
  88 + } else if (filterStatus) {
  89 + $activeTab = $('.list-tabs').find('[data-status="' + filterStatus + '"]');
  90 + }
  91 + if ($activeTab.size() <= 0) {
  92 + $activeTab = $('.list-tabs').find('[data-status="all"]');
  93 + }
  94 + $activeTab.addClass('active').siblings().removeClass('active');
78 } 95 }
79 }) 96 })
80 } 97 }
81 98
  99 +
  100 +
82 tabShow(); 101 tabShow();
83 102
84 //tab卡切换列表事件 103 //tab卡切换列表事件
85 $('.list-tabs').on('click', 'li', function() { 104 $('.list-tabs').on('click', 'li', function() {
86 $(this).addClass('active').siblings().removeClass('active'); 105 $(this).addClass('active').siblings().removeClass('active');
87 - g.reload(); 106 + g.reload({
  107 + page: 1,
  108 + status: parseInt($('.list-tabs').find('.active').data('status'))
  109 + });
88 }); 110 });
89 111
90 var btnAuthority = JSON.parse($("#btnAuthority").val()); 112 var btnAuthority = JSON.parse($("#btnAuthority").val());
@@ -150,9 +172,11 @@ exports.init = function() { @@ -150,9 +172,11 @@ exports.init = function() {
150 batchNo: $.trim($('#filter-id').val()), 172 batchNo: $.trim($('#filter-id').val()),
151 name: $.trim($('#filter-name').val()), 173 name: $.trim($('#filter-name').val()),
152 reqDepartment:$.trim($('#filter-dep').val()) 174 reqDepartment:$.trim($('#filter-dep').val())
153 - }, parseInt($('.list-tabs').find('.active').data('status'))) 175 + }, $('.list-tabs').find('.active').data('status'));
  176 +
154 location.hash = ''; 177 location.hash = '';
155 g.reload({ 178 g.reload({
  179 + status: 'all',
156 page: 1 180 page: 1
157 }); 181 });
158 }); 182 });