From 0e4344995c936ebf6fb972aa37aa6ece28dff2f4 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Mon, 31 Oct 2022 21:04:36 +0700 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B1=D0=B0=D0=B3=D0=BE=D0=B2,=20?= =?UTF-8?q?=D0=BC=D0=B5=D0=BB=D0=BA=D0=B8=D0=B9=20=D1=80=D0=B5=D1=84=D0=B0?= =?UTF-8?q?=D0=BA=D1=82=D0=BE=D1=80=D0=B8=D0=BD=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/Search/BaseList.js | 5 +++-- client/components/Search/Search.vue | 12 ++++-------- .../Search/SelectDateDialog/SelectDateDialog.vue | 6 +----- client/share/utils.js | 7 ++++++- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/client/components/Search/BaseList.js b/client/components/Search/BaseList.js index 420f2df..ffc1555 100644 --- a/client/components/Search/BaseList.js +++ b/client/components/Search/BaseList.js @@ -407,8 +407,9 @@ export default class BaseList { //date let dateFound = !s.date; if (!dateFound) { - const date = this.queryDate(s.date.split(',')); + const date = this.queryDate(s.date).split(','); let [from = '0000-00-00', to = '9999-99-99'] = date; + dateFound = (book.date >= from && book.date <= to); } @@ -471,7 +472,7 @@ export default class BaseList { } queryDate(date) { - if (!(utils.isDigit(date[0]) && utils.isDigit(date[1]))) {//!manual + if (!utils.isManualDate(date)) {//!manual /* {label: 'сегодня', value: 'today'}, {label: 'за 3 дня', value: '3days'}, diff --git a/client/components/Search/Search.vue b/client/components/Search/Search.vue index d92e151..f512e30 100644 --- a/client/components/Search/Search.vue +++ b/client/components/Search/Search.vue @@ -971,18 +971,14 @@ class Search { } } - isManualDate(date) { - return date && utils.isDigit(date[0]) && utils.isDigit(date[1]); - } - updateSearchDate(toLocal) { if (toLocal) { let local = this.search.date || ''; - if (this.isManualDate(local) || !local) + if (utils.isManualDate(local) || !local) this.prevManualDate = local; - if (this.isManualDate(local)) + if (utils.isManualDate(local)) local = 'manual'; this.searchDate = local; @@ -995,7 +991,7 @@ class Search { get formatSearchDate() { const result = []; const date = this.search.date; - if (this.isManualDate(date)) { + if (utils.isManualDate(date)) { const [from, to] = date.split(',') if (from) result.push(`
от
${utils.sqlDateFormat(from)}`); @@ -1008,7 +1004,7 @@ class Search { dateSelectItemClick(itemValue) { if (itemValue == 'manual') { - if (!this.isManualDate(this.search.date)) { + if (!utils.isManualDate(this.search.date)) { this.search.date = this.prevManualDate; if (!this.search.date) this.searchDate = ''; diff --git a/client/components/Search/SelectDateDialog/SelectDateDialog.vue b/client/components/Search/SelectDateDialog/SelectDateDialog.vue index c4d1746..8020619 100644 --- a/client/components/Search/SelectDateDialog/SelectDateDialog.vue +++ b/client/components/Search/SelectDateDialog/SelectDateDialog.vue @@ -96,12 +96,8 @@ class SelectDateDialog { this.to = this.splitDate.to; } - isManualDate(date) { - return date && utils.isDigit(date[0]) && utils.isDigit(date[1]); - } - get splitDate() { - if (!this.isManualDate(this.date)) + if (!utils.isManualDate(this.date)) return {from: '', to: ''}; const [from = '', to = ''] = (this.date || '').split(','); diff --git a/client/share/utils.js b/client/share/utils.js index 53ae922..f48aeb1 100644 --- a/client/share/utils.js +++ b/client/share/utils.js @@ -138,4 +138,9 @@ export function dateFormat(date, format = 'DD.MM.YYYY') { export function sqlDateFormat(date, format = 'DD.MM.YYYY') { return moment(date, 'YYYY-MM-DD').format(format); -} \ No newline at end of file +} + +export function isManualDate(date) { + return date && (date[0] == ',' || (isDigit(date[0]) && isDigit(date[1]))); +} +