Authored by 李靖

加载更多

... ... @@ -57,6 +57,11 @@
</table>
</div>
</div>
<div class="form-group col-sm-12">
<div class="col-sm-11 col-sm-offset-1" style="text-align: center;">
<a class="btn btn-primary more-list">加载更多记录</a>
</div>
</div>
</div>
</div>
</div>
... ... @@ -65,6 +70,7 @@
<script>
let $uploadList = $('#upload-list tbody');
let marker = '';
let page = 0;
$('#upload').on('click', function() {
var formData = new FormData();
... ... @@ -105,9 +111,12 @@
url: '/files/listlogs',
cache: false,
dataType: 'json',
data: {
page: page++
},
success: function(result) {
if (result && result.data) {
let $uploadList = $('#upload-list tbody');
if (result && result.data && result.data.length > 0) {
let $uploadList = $('#upload-list > tbody');
result.data.forEach(function(item){
$uploadList.append(`
... ... @@ -136,6 +145,8 @@
</tr>
`);
});
} else {
$('.more-list').hide();
}
}
});
... ... @@ -159,7 +170,11 @@
},
success: (result) => {
if (result && result.data &&result.data.items) {
$this.siblings('.get-more').attr('data-marker', result.data.marker);
if ($this.parents('td').find('.get-more').attr('data-marker') === result.data.marker) {
$this.parents('td').find('.get-more').remove();
return false;
}
$this.parents('td').find('.get-more').attr('data-marker', result.data.marker);
result.data.items.forEach(function(item){
detail += `<tr class="detail-list">
<td>${item.key}</td>
... ... @@ -169,11 +184,17 @@
</tr>`;
});
$uploadDetail.next('.detail-c').find('.detail-table tbody').append(detail);
$this.parents('td').find('.get-more').removeClass('hide');
}
}
});
}
// 加载更多列表
$('.more-list').on('click', function() {
getList();
})
// 上传记录详情,插入tr
$uploadList.on('click', '.detail-btn', function(e) {
let $this = $(e.currentTarget);
... ... @@ -185,15 +206,16 @@
$detailC.removeClass('hide');
$('.detail-btn').text('展开详情');
$this.text('关闭详情');
$this.siblings('.get-more').removeClass('hide');
if ($detailList.length <= 0) {
getDetail(e, marker);
} else if ($detailC.find('.detail-list').length > 0) {
$this.siblings('.get-more').removeClass('hide');
}
} else {
$detailC.addClass('hide');
$this.text('展开详情');
$this.siblings('.get-more').addClass('hide');
}
if ($detailList.length <= 0) {
getDetail(e, marker);
}
});
// 加载更多
... ...