Showing
1 changed file
with
28 additions
and
6 deletions
@@ -57,6 +57,11 @@ | @@ -57,6 +57,11 @@ | ||
57 | </table> | 57 | </table> |
58 | </div> | 58 | </div> |
59 | </div> | 59 | </div> |
60 | + <div class="form-group col-sm-12"> | ||
61 | + <div class="col-sm-11 col-sm-offset-1" style="text-align: center;"> | ||
62 | + <a class="btn btn-primary more-list">加载更多记录</a> | ||
63 | + </div> | ||
64 | + </div> | ||
60 | </div> | 65 | </div> |
61 | </div> | 66 | </div> |
62 | </div> | 67 | </div> |
@@ -65,6 +70,7 @@ | @@ -65,6 +70,7 @@ | ||
65 | <script> | 70 | <script> |
66 | let $uploadList = $('#upload-list tbody'); | 71 | let $uploadList = $('#upload-list tbody'); |
67 | let marker = ''; | 72 | let marker = ''; |
73 | + let page = 0; | ||
68 | 74 | ||
69 | $('#upload').on('click', function() { | 75 | $('#upload').on('click', function() { |
70 | var formData = new FormData(); | 76 | var formData = new FormData(); |
@@ -105,9 +111,12 @@ | @@ -105,9 +111,12 @@ | ||
105 | url: '/files/listlogs', | 111 | url: '/files/listlogs', |
106 | cache: false, | 112 | cache: false, |
107 | dataType: 'json', | 113 | dataType: 'json', |
114 | + data: { | ||
115 | + page: page++ | ||
116 | + }, | ||
108 | success: function(result) { | 117 | success: function(result) { |
109 | - if (result && result.data) { | ||
110 | - let $uploadList = $('#upload-list tbody'); | 118 | + if (result && result.data && result.data.length > 0) { |
119 | + let $uploadList = $('#upload-list > tbody'); | ||
111 | 120 | ||
112 | result.data.forEach(function(item){ | 121 | result.data.forEach(function(item){ |
113 | $uploadList.append(` | 122 | $uploadList.append(` |
@@ -136,6 +145,8 @@ | @@ -136,6 +145,8 @@ | ||
136 | </tr> | 145 | </tr> |
137 | `); | 146 | `); |
138 | }); | 147 | }); |
148 | + } else { | ||
149 | + $('.more-list').hide(); | ||
139 | } | 150 | } |
140 | } | 151 | } |
141 | }); | 152 | }); |
@@ -159,7 +170,11 @@ | @@ -159,7 +170,11 @@ | ||
159 | }, | 170 | }, |
160 | success: (result) => { | 171 | success: (result) => { |
161 | if (result && result.data &&result.data.items) { | 172 | if (result && result.data &&result.data.items) { |
162 | - $this.siblings('.get-more').attr('data-marker', result.data.marker); | 173 | + if ($this.parents('td').find('.get-more').attr('data-marker') === result.data.marker) { |
174 | + $this.parents('td').find('.get-more').remove(); | ||
175 | + return false; | ||
176 | + } | ||
177 | + $this.parents('td').find('.get-more').attr('data-marker', result.data.marker); | ||
163 | result.data.items.forEach(function(item){ | 178 | result.data.items.forEach(function(item){ |
164 | detail += `<tr class="detail-list"> | 179 | detail += `<tr class="detail-list"> |
165 | <td>${item.key}</td> | 180 | <td>${item.key}</td> |
@@ -169,11 +184,17 @@ | @@ -169,11 +184,17 @@ | ||
169 | </tr>`; | 184 | </tr>`; |
170 | }); | 185 | }); |
171 | $uploadDetail.next('.detail-c').find('.detail-table tbody').append(detail); | 186 | $uploadDetail.next('.detail-c').find('.detail-table tbody').append(detail); |
187 | + $this.parents('td').find('.get-more').removeClass('hide'); | ||
172 | } | 188 | } |
173 | } | 189 | } |
174 | }); | 190 | }); |
175 | } | 191 | } |
176 | 192 | ||
193 | + // 加载更多列表 | ||
194 | + $('.more-list').on('click', function() { | ||
195 | + getList(); | ||
196 | + }) | ||
197 | + | ||
177 | // 上传记录详情,插入tr | 198 | // 上传记录详情,插入tr |
178 | $uploadList.on('click', '.detail-btn', function(e) { | 199 | $uploadList.on('click', '.detail-btn', function(e) { |
179 | let $this = $(e.currentTarget); | 200 | let $this = $(e.currentTarget); |
@@ -185,15 +206,16 @@ | @@ -185,15 +206,16 @@ | ||
185 | $detailC.removeClass('hide'); | 206 | $detailC.removeClass('hide'); |
186 | $('.detail-btn').text('展开详情'); | 207 | $('.detail-btn').text('展开详情'); |
187 | $this.text('关闭详情'); | 208 | $this.text('关闭详情'); |
209 | + if ($detailList.length <= 0) { | ||
210 | + getDetail(e, marker); | ||
211 | + } else if ($detailC.find('.detail-list').length > 0) { | ||
188 | $this.siblings('.get-more').removeClass('hide'); | 212 | $this.siblings('.get-more').removeClass('hide'); |
213 | + } | ||
189 | } else { | 214 | } else { |
190 | $detailC.addClass('hide'); | 215 | $detailC.addClass('hide'); |
191 | $this.text('展开详情'); | 216 | $this.text('展开详情'); |
192 | $this.siblings('.get-more').addClass('hide'); | 217 | $this.siblings('.get-more').addClass('hide'); |
193 | } | 218 | } |
194 | - if ($detailList.length <= 0) { | ||
195 | - getDetail(e, marker); | ||
196 | - } | ||
197 | }); | 219 | }); |
198 | 220 | ||
199 | // 加载更多 | 221 | // 加载更多 |
-
Please register or login to post a comment