Исправления багов, мелкий рефакторинг
This commit is contained in:
@@ -407,8 +407,9 @@ export default class BaseList {
|
|||||||
//date
|
//date
|
||||||
let dateFound = !s.date;
|
let dateFound = !s.date;
|
||||||
if (!dateFound) {
|
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;
|
let [from = '0000-00-00', to = '9999-99-99'] = date;
|
||||||
|
|
||||||
dateFound = (book.date >= from && book.date <= to);
|
dateFound = (book.date >= from && book.date <= to);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -471,7 +472,7 @@ export default class BaseList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
queryDate(date) {
|
queryDate(date) {
|
||||||
if (!(utils.isDigit(date[0]) && utils.isDigit(date[1]))) {//!manual
|
if (!utils.isManualDate(date)) {//!manual
|
||||||
/*
|
/*
|
||||||
{label: 'сегодня', value: 'today'},
|
{label: 'сегодня', value: 'today'},
|
||||||
{label: 'за 3 дня', value: '3days'},
|
{label: 'за 3 дня', value: '3days'},
|
||||||
|
|||||||
@@ -971,18 +971,14 @@ class Search {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isManualDate(date) {
|
|
||||||
return date && utils.isDigit(date[0]) && utils.isDigit(date[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
updateSearchDate(toLocal) {
|
updateSearchDate(toLocal) {
|
||||||
if (toLocal) {
|
if (toLocal) {
|
||||||
let local = this.search.date || '';
|
let local = this.search.date || '';
|
||||||
|
|
||||||
if (this.isManualDate(local) || !local)
|
if (utils.isManualDate(local) || !local)
|
||||||
this.prevManualDate = local;
|
this.prevManualDate = local;
|
||||||
|
|
||||||
if (this.isManualDate(local))
|
if (utils.isManualDate(local))
|
||||||
local = 'manual';
|
local = 'manual';
|
||||||
|
|
||||||
this.searchDate = local;
|
this.searchDate = local;
|
||||||
@@ -995,7 +991,7 @@ class Search {
|
|||||||
get formatSearchDate() {
|
get formatSearchDate() {
|
||||||
const result = [];
|
const result = [];
|
||||||
const date = this.search.date;
|
const date = this.search.date;
|
||||||
if (this.isManualDate(date)) {
|
if (utils.isManualDate(date)) {
|
||||||
const [from, to] = date.split(',')
|
const [from, to] = date.split(',')
|
||||||
if (from)
|
if (from)
|
||||||
result.push(`<div style="display: inline-block; width: 15px; text-align: right;">от</div> ${utils.sqlDateFormat(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) {
|
dateSelectItemClick(itemValue) {
|
||||||
if (itemValue == 'manual') {
|
if (itemValue == 'manual') {
|
||||||
if (!this.isManualDate(this.search.date)) {
|
if (!utils.isManualDate(this.search.date)) {
|
||||||
this.search.date = this.prevManualDate;
|
this.search.date = this.prevManualDate;
|
||||||
if (!this.search.date)
|
if (!this.search.date)
|
||||||
this.searchDate = '';
|
this.searchDate = '';
|
||||||
|
|||||||
@@ -96,12 +96,8 @@ class SelectDateDialog {
|
|||||||
this.to = this.splitDate.to;
|
this.to = this.splitDate.to;
|
||||||
}
|
}
|
||||||
|
|
||||||
isManualDate(date) {
|
|
||||||
return date && utils.isDigit(date[0]) && utils.isDigit(date[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
get splitDate() {
|
get splitDate() {
|
||||||
if (!this.isManualDate(this.date))
|
if (!utils.isManualDate(this.date))
|
||||||
return {from: '', to: ''};
|
return {from: '', to: ''};
|
||||||
|
|
||||||
const [from = '', to = ''] = (this.date || '').split(',');
|
const [from = '', to = ''] = (this.date || '').split(',');
|
||||||
|
|||||||
@@ -139,3 +139,8 @@ export function dateFormat(date, format = 'DD.MM.YYYY') {
|
|||||||
export function sqlDateFormat(date, format = 'DD.MM.YYYY') {
|
export function sqlDateFormat(date, format = 'DD.MM.YYYY') {
|
||||||
return moment(date, 'YYYY-MM-DD').format(format);
|
return moment(date, 'YYYY-MM-DD').format(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isManualDate(date) {
|
||||||
|
return date && (date[0] == ',' || (isDigit(date[0]) && isDigit(date[1])));
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user