修复表格显示不正常的问题
This commit is contained in:
parent
cbcc4f7e23
commit
727b246ba8
108
database/db.js
108
database/db.js
|
|
@ -564,7 +564,6 @@ db.getBookmarksTable = function(params) {
|
||||||
if (err) {
|
if (err) {
|
||||||
reject(err);
|
reject(err);
|
||||||
} else {
|
} else {
|
||||||
var temp = [];
|
|
||||||
var bookmarks = [];
|
var bookmarks = [];
|
||||||
var begin = (params.currentPage - 1) * params.perPageItems;
|
var begin = (params.currentPage - 1) * params.perPageItems;
|
||||||
var end = params.currentPage * params.perPageItems;
|
var end = params.currentPage * params.perPageItems;
|
||||||
|
|
@ -580,51 +579,34 @@ db.getBookmarksTable = function(params) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
temp = result.slice(begin, end);
|
.slice(begin, end)
|
||||||
temp.forEach((b1) => {
|
.forEach((b) => {
|
||||||
var find = false;
|
var bookmark = JSON.parse(JSON.stringify(b));// 执行深度复制
|
||||||
bookmarks.forEach((b2) => {
|
bookmark.type = 1;
|
||||||
if (b1.id == b2.id) {
|
bookmarks.push(bookmark);
|
||||||
find = true;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
if (!find) {
|
|
||||||
bookmarks.push(b1);
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
result.sort((a, b) => a.created_at >= b.created_at ? -1 : 1);
|
result.sort((a, b) => a.created_at >= b.created_at ? -1 : 1)
|
||||||
temp = result.slice(begin, end);
|
.slice(begin, end)
|
||||||
temp.forEach((b1) => {
|
.forEach((b) => {
|
||||||
var find = false;
|
var bookmark = JSON.parse(JSON.stringify(b));// 执行深度复制
|
||||||
bookmarks.forEach((b2) => {
|
bookmark.type = 2;
|
||||||
if (b1.id == b2.id) {
|
bookmarks.push(bookmark);
|
||||||
find = true;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
if (!find) {
|
|
||||||
bookmarks.push(b1);
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
result.sort((a, b) => a.last_click >= b.last_click ? -1 : 1);
|
result.sort((a, b) => a.last_click >= b.last_click ? -1 : 1)
|
||||||
temp = result.slice(begin, end);
|
.slice(begin, end)
|
||||||
temp.forEach((b1) => {
|
.forEach((b) => {
|
||||||
var find = false;
|
var bookmark = JSON.parse(JSON.stringify(b));// 执行深度复制
|
||||||
bookmarks.forEach((b2) => {
|
bookmark.type = 3;
|
||||||
if (b1.id == b2.id) {
|
bookmarks.push(bookmark);
|
||||||
find = true;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
if (!find) {
|
|
||||||
bookmarks.push(b1);
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
var bookmarksData = {
|
var bookmarksData = {
|
||||||
totalItems: result.length,
|
totalItems: result.length,
|
||||||
bookmarks: bookmarks,
|
bookmarks: bookmarks,
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve(bookmarksData);
|
resolve(bookmarksData);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -643,7 +625,6 @@ db.getBookmarksByTag = function(params) {
|
||||||
if (err) {
|
if (err) {
|
||||||
reject(err);
|
reject(err);
|
||||||
} else {
|
} else {
|
||||||
var temp = [];
|
|
||||||
var bookmarks = [];
|
var bookmarks = [];
|
||||||
var begin = (params.currentPage - 1) * params.perPageItems;
|
var begin = (params.currentPage - 1) * params.perPageItems;
|
||||||
var end = params.currentPage * params.perPageItems;
|
var end = params.currentPage * params.perPageItems;
|
||||||
|
|
@ -659,51 +640,34 @@ db.getBookmarksByTag = function(params) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
temp = result.slice(begin, end);
|
.slice(begin, end)
|
||||||
temp.forEach((b1) => {
|
.forEach((b) => {
|
||||||
var find = false;
|
var bookmark = JSON.parse(JSON.stringify(b));// 执行深度复制
|
||||||
bookmarks.forEach((b2) => {
|
bookmark.type = 1;
|
||||||
if (b1.id == b2.id) {
|
bookmarks.push(bookmark);
|
||||||
find = true;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
if (!find) {
|
|
||||||
bookmarks.push(b1);
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
result.sort((a, b) => a.created_at >= b.created_at ? -1 : 1);
|
result.sort((a, b) => a.created_at >= b.created_at ? -1 : 1)
|
||||||
temp = result.slice(begin, end);
|
.slice(begin, end)
|
||||||
temp.forEach((b1) => {
|
.forEach((b) => {
|
||||||
var find = false;
|
var bookmark = JSON.parse(JSON.stringify(b));// 执行深度复制
|
||||||
bookmarks.forEach((b2) => {
|
bookmark.type = 2;
|
||||||
if (b1.id == b2.id) {
|
bookmarks.push(bookmark);
|
||||||
find = true;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
if (!find) {
|
|
||||||
bookmarks.push(b1);
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
result.sort((a, b) => a.last_click >= b.last_click ? -1 : 1);
|
result.sort((a, b) => a.last_click >= b.last_click ? -1 : 1)
|
||||||
temp = result.slice(begin, end);
|
.slice(begin, end)
|
||||||
temp.forEach((b1) => {
|
.forEach((b) => {
|
||||||
var find = false;
|
var bookmark = JSON.parse(JSON.stringify(b));// 执行深度复制
|
||||||
bookmarks.forEach((b2) => {
|
bookmark.type = 3;
|
||||||
if (b1.id == b2.id) {
|
bookmarks.push(bookmark);
|
||||||
find = true;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
if (!find) {
|
|
||||||
bookmarks.push(b1);
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
var bookmarksData = {
|
var bookmarksData = {
|
||||||
totalItems: result.length,
|
totalItems: result.length,
|
||||||
bookmarks: bookmarks,
|
bookmarks: bookmarks,
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve(bookmarksData);
|
resolve(bookmarksData);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -181,17 +181,28 @@ app.controller('bookmarksCtr', ['$scope', '$state', '$stateParams', '$filter', '
|
||||||
}
|
}
|
||||||
$scope.order = $scope.order.map(() => false);
|
$scope.order = $scope.order.map(() => false);
|
||||||
$scope.order[index] = true;
|
$scope.order[index] = true;
|
||||||
var begin = ($scope.currentPage - 1) * perPageItems;
|
$scope.bookmarks = [];
|
||||||
var end = $scope.currentPage * perPageItems;
|
|
||||||
if ($scope.order[0]) {
|
if ($scope.order[0]) {
|
||||||
$scope.bookmarkData.bookmarks.sort(clickCmp)
|
$scope.bookmarkData.bookmarks.sort(clickCmp)
|
||||||
$scope.bookmarks = $scope.bookmarkData.bookmarks.slice(begin, end);
|
$scope.bookmarkData.bookmarks.forEach((bookmark) => {
|
||||||
|
if (bookmark.type == 1) {
|
||||||
|
$scope.bookmarks.push(bookmark);
|
||||||
|
}
|
||||||
|
})
|
||||||
} else if ($scope.order[1]) {
|
} else if ($scope.order[1]) {
|
||||||
$scope.bookmarkData.bookmarks.sort((a, b) => a.created_at >= b.created_at ? -1 : 1);
|
$scope.bookmarkData.bookmarks.sort((a, b) => a.created_at >= b.created_at ? -1 : 1);
|
||||||
$scope.bookmarks = $scope.bookmarkData.bookmarks.slice(begin, end);
|
$scope.bookmarkData.bookmarks.forEach((bookmark) => {
|
||||||
|
if (bookmark.type == 2) {
|
||||||
|
$scope.bookmarks.push(bookmark);
|
||||||
|
}
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
$scope.bookmarkData.bookmarks.sort((a, b) => a.last_click >= b.last_click ? -1 : 1);
|
$scope.bookmarkData.bookmarks.sort((a, b) => a.last_click >= b.last_click ? -1 : 1);
|
||||||
$scope.bookmarks = $scope.bookmarkData.bookmarks.slice(begin, end);
|
$scope.bookmarkData.bookmarks.forEach((bookmark) => {
|
||||||
|
if (bookmark.type == 3) {
|
||||||
|
$scope.bookmarks.push(bookmark);
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
|
|
@ -258,7 +269,11 @@ app.controller('bookmarksCtr', ['$scope', '$state', '$stateParams', '$filter', '
|
||||||
toastr.info('您还没有书签,请点击菜单栏的添加按钮进行添加', "提示");
|
toastr.info('您还没有书签,请点击菜单栏的添加按钮进行添加', "提示");
|
||||||
}
|
}
|
||||||
if (params.showStyle == 'card') {
|
if (params.showStyle == 'card') {
|
||||||
data.bookmarksCreatedAt.forEach(bookmark => {
|
$scope.bookmarkData.bookmarks.sort((a, b) => a.created_at >= b.created_at ? -1 : 1);
|
||||||
|
var begin = ($scope.currentPage - 1) * perPageItems;
|
||||||
|
var end = $scope.currentPage * perPageItems;
|
||||||
|
var bookmarks = $scope.bookmarkData.bookmarks.slice(begin, end);
|
||||||
|
bookmarks.forEach(bookmark => {
|
||||||
bookmark.edit = false;
|
bookmark.edit = false;
|
||||||
$scope.bookmarks.push(bookmark);
|
$scope.bookmarks.push(bookmark);
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -35,18 +35,29 @@ app.controller('tagsCtr', ['$scope', '$filter', '$window', '$stateParams', '$tim
|
||||||
}
|
}
|
||||||
$scope.order = $scope.order.map(() => false);
|
$scope.order = $scope.order.map(() => false);
|
||||||
$scope.order[index] = true;
|
$scope.order[index] = true;
|
||||||
var begin = ($scope.currentPage - 1) * perPageItems;
|
$scope.bookmarks = [];
|
||||||
var end = $scope.currentPage * perPageItems;
|
|
||||||
|
|
||||||
if ($scope.order[0]) {
|
if ($scope.order[0]) {
|
||||||
$scope.bookmarkData.bookmarks.sort(clickCmp)
|
$scope.bookmarkData.bookmarks.sort(clickCmp);
|
||||||
$scope.bookmarks = $scope.bookmarkData.bookmarks.slice(begin, end);;
|
$scope.bookmarkData.bookmarks.forEach((bookmark) => {
|
||||||
|
if (bookmark.type == 1) {
|
||||||
|
$scope.bookmarks.push(bookmark);
|
||||||
|
}
|
||||||
|
})
|
||||||
} else if ($scope.order[1]) {
|
} else if ($scope.order[1]) {
|
||||||
$scope.bookmarkData.bookmarks.sort((a, b) => a.created_at >= b.created_at ? -1 : 1);
|
$scope.bookmarkData.bookmarks.sort((a, b) => a.created_at >= b.created_at ? -1 : 1);
|
||||||
$scope.bookmarks = $scope.bookmarkData.bookmarks.slice(begin, end);;
|
$scope.bookmarkData.bookmarks.forEach((bookmark) => {
|
||||||
|
if (bookmark.type == 2) {
|
||||||
|
$scope.bookmarks.push(bookmark);
|
||||||
|
}
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
$scope.bookmarkData.bookmarks.sort((a, b) => a.last_click >= b.last_click ? -1 : 1);
|
$scope.bookmarkData.bookmarks.sort((a, b) => a.last_click >= b.last_click ? -1 : 1);
|
||||||
$scope.bookmarks = $scope.bookmarkData.bookmarks.slice(begin, end);;
|
$scope.bookmarkData.bookmarks.forEach((bookmark) => {
|
||||||
|
if (bookmark.type == 3) {
|
||||||
|
$scope.bookmarks.push(bookmark);
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
timeagoInstance.cancel();
|
timeagoInstance.cancel();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue