From 507c2a0bbd2b30ec6243b50c8326a3947dff5fad Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Sat, 20 Aug 2022 02:48:50 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20=D0=BD?= =?UTF-8?q?=D0=B0=D0=B4=20=D0=BF=D1=80=D0=BE=D0=B5=D0=BA=D1=82=D0=BE=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/Search/Search.vue | 26 +++++++++++++++++++------- client/share/utils.js | 14 ++++++++++++++ 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/client/components/Search/Search.vue b/client/components/Search/Search.vue index e99836f..57dcb14 100644 --- a/client/components/Search/Search.vue +++ b/client/components/Search/Search.vue @@ -67,7 +67,7 @@
- Найдено {{ totalFound }} авторов + {{ foundAuthorsMessage }}
Ничего не найдено @@ -76,7 +76,7 @@
-
+
Страница
@@ -87,14 +87,17 @@ из {{ totalPages }}
+
+
-
- {{ item.value }} +
+ {{ item.key }} {{ item.name }}
+ -
+
Страница
@@ -105,6 +108,7 @@ из {{ totalPages }}
+
@@ -255,18 +259,26 @@ class Search { this.lastScrollTop = curScrollTop; } + get foundAuthorsMessage() { + return `Найден${utils.wordEnding(this.totalFound, 2)} ${this.totalFound} автор${utils.wordEnding(this.totalFound)}`; + } + updatePageCount() { - this.totalPages = Math.floor(this.totalFound/this.limit); + this.totalPages = Math.ceil(this.totalFound/this.limit); this.totalPages = (this.totalPages < 1 ? 1 : this.totalPages); if (this.page > this.totalPages) this.page = 1; } + authorClick(authorName) { + this.author = `=${authorName}`; + } + async updateTableData() { let result = []; for (const rec of this.searchResult.author) { - result.push({key: rec.id, value: `${rec.id} ${rec.author.replace(/,/g, ', ')}`}); + result.push({key: rec.id, type: 'author', value: rec.author, name: rec.author.replace(/,/g, ', ')}); } this.tableData = result; diff --git a/client/share/utils.js b/client/share/utils.js index 3fe79a0..3b3dbfb 100644 --- a/client/share/utils.js +++ b/client/share/utils.js @@ -28,3 +28,17 @@ export function keyEventToCode(event) { return result.join('+'); } +export function wordEnding(num, type = 0) { + const endings = [ + ['ов', '', 'а', 'а', 'а', 'ов', 'ов', 'ов', 'ов', 'ов'], + ['й', 'я', 'и', 'и', 'и', 'й', 'й', 'й', 'й', 'й'], + ['о', '', 'о', 'о', 'о', 'о', 'о', 'о', 'о', 'о'], + ['ий', 'ие', 'ия', 'ия', 'ия', 'ий', 'ий', 'ий', 'ий', 'ий'] + ]; + const deci = num % 100; + if (deci > 10 && deci < 20) { + return endings[type][0]; + } else { + return endings[type][num % 10]; + } +}