Browse Source

Исправления багов, мелкий рефакторинг

Book Pauk 2 years ago
parent
commit
0e4344995c

+ 3 - 2
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'},

+ 4 - 8
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(`<div style="display: inline-block; width: 15px; text-align: right;">от</div> ${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 = '';

+ 1 - 5
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(',');

+ 6 - 1
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);
-}
+}
+
+export function isManualDate(date) {
+    return date && (date[0] == ',' || (isDigit(date[0]) && isDigit(date[1])));
+}
+