修复tags页面table问题

This commit is contained in:
HelloWorld 2020-04-08 21:59:35 +08:00
parent 9121d5da62
commit 33cd8229f9
2 changed files with 27 additions and 12 deletions

View File

@ -9,8 +9,10 @@ app.controller('tagsCtr', ['$scope', '$filter', '$state', '$window', '$statePara
await getTags();
})()
var dialog = null;
var addBookmarkId = -1;
let dialog = null;
let addBookmarkId = -1; // 新增一个书签会重新刷新页面
let timeagoInstance = timeago();
$scope.hoverBookmark = null;
$scope.showType = "createdAt";
$scope.loading = true;
@ -27,7 +29,6 @@ app.controller('tagsCtr', ['$scope', '$filter', '$state', '$window', '$statePara
$scope.waitDelTag = {};
$scope.waitDelBookmark = {};
$scope.bookmarkNormalHover = false;
var timeagoInstance = timeago();
pubSubService.subscribe('MenuCtr.tags', $scope, function (event, data) {
console.log('subscribe MenuCtr.tags', data);
@ -57,7 +58,13 @@ app.controller('tagsCtr', ['$scope', '$filter', '$state', '$window', '$statePara
};
let reply = await get('bookmarksByTag', params);
$scope.bookmarks = reply.data;
let bookmarks = reply.data;
for (bookmark of bookmarks) {
let tag = $scope.tags.find(tag => tag.id == bookmark.tagId);
tag && (bookmark.tagName = tag.name);
}
$scope.bookmarks = bookmarks;
$scope.totalPages = reply.totalPages;
$scope.inputPage = '';
$scope.loading = false;
@ -68,6 +75,14 @@ app.controller('tagsCtr', ['$scope', '$filter', '$state', '$window', '$statePara
}
}
let id = setInterval(() => {
if (document.querySelectorAll('.need_to_be_rendered').length > 0) {
timeagoInstance.cancel();
timeagoInstance.render(document.querySelectorAll('.need_to_be_rendered'), 'zh_CN');
clearInterval(id);
}
}, 10);
pubSubService.publish('Common.menuActive', {
login: true,
index: dataService.LoginIndexTags
@ -78,7 +93,7 @@ app.controller('tagsCtr', ['$scope', '$filter', '$state', '$window', '$statePara
duration: 1000,
});
addBookmarkId = -1;
});
}, 10);
};
$scope.changeCurrentPage = function (currentPage) {

View File

@ -35,7 +35,7 @@
<div class="content" style="cursor: move" sv-handle>
<div class="description">
<p>书签:{{ tag.bookmarkCount || 0 }}个</p>
<p>{{ tag.last_use }}</p>
<p>{{ tag.lastUse }}</p>
</div>
</div>
<div class="extra content">
@ -58,8 +58,8 @@
<tr>
<th class="forbid_sorted">标题</th>
<th class="forbid_sorted">链接</th>
<th style="width:90px;" ng-class="{descending: showType == 'createdAt', sorted:showType == 'createdAt'}" ng-click="getBookmarks(null, 1, 'createdAt')" title="点击可对表格进行排序">点击次数</th>
<th style="width:100px;" ng-class="{descending: showType == 'clickCount', sorted:showType == 'clickCount'}" ng-click="getBookmarks(null, 1, 'clickCount')" title="点击可对表格进行排序">创建日期</th>
<th style="width:90px;" ng-class="{descending: showType == 'clickCount', sorted:showType == 'clickCount'}" ng-click="getBookmarks(null, 1, 'clickCount')" title="点击可对表格进行排序">点击次数</th>
<th style="width:100px;" ng-class="{descending: showType == 'createdAt', sorted:showType == 'createdAt'}" ng-click="getBookmarks(null, 1, 'createdAt')" title="点击可对表格进行排序">添加日期</th>
<th style="width:100px;" ng-class="{descending: showType == 'lastClick', sorted:showType == 'lastClick'}" ng-click="getBookmarks(null, 1, 'lastClick')" title="点击可对表格进行排序">最后点击</th>
<th style="width:150px;" class="forbid_sorted">分类</th>
<th style="width:88px;" class="forbid_sorted">操作</th>
@ -76,16 +76,16 @@
<td>
<span title="{{bookmark.url}} 点击复制链接" ng-click="copy(bookmark.url)" style="cursor:default;">{{ bookmark.url }}</span>
</td>
<td>{{ bookmark.click_count }}</td>
<td>{{ bookmark.clickCount }}</td>
<td>
<span title="{{bookmark.createdAt}}" class="need_to_be_rendered" data-timeago="{{bookmark.createdAt}}"></span>
</td>
<td>
<span id="time{{bookmark.id}}" title="{{bookmark.last_click}}" class="need_to_be_rendered" data-timeago="{{bookmark.last_click}}"></span>
<span id="time{{bookmark.id}}" title="{{bookmark.lastClick}}" class="need_to_be_rendered" data-timeago="{{bookmark.lastClick}}"></span>
</td>
<td>
<div class="ui label" ng-repeat="tag in bookmark.tags" tag-id="{{ tag.id }}" ng-click="getBookmarks(tag.id, 1, null)">
{{ tag.name }}
<div class="ui label">
{{ bookmark.tagName }}
</div>
</td>
<td>