diff --git a/client/components/Search/AuthorList/AuthorList.vue b/client/components/Search/AuthorList/AuthorList.vue
index d09ea07..07ada45 100644
--- a/client/components/Search/AuthorList/AuthorList.vue
+++ b/client/components/Search/AuthorList/AuthorList.vue
@@ -360,13 +360,7 @@ class AuthorList extends BaseList {
async refresh() {
//параметры запроса
- let newQuery = _.cloneDeep(this.search);
- newQuery = newQuery.setDefaults(newQuery);
- delete newQuery.setDefaults;
- newQuery.offset = (newQuery.page - 1)*newQuery.limit;
- if (!this.showDeleted)
- newQuery.del = 0;
-
+ const newQuery = this.getQuery();
if (_.isEqual(newQuery, this.prevQuery))
return;
this.prevQuery = newQuery;
diff --git a/client/components/Search/BaseList.js b/client/components/Search/BaseList.js
index df2e934..420f2df 100644
--- a/client/components/Search/BaseList.js
+++ b/client/components/Search/BaseList.js
@@ -1,3 +1,4 @@
+import moment from 'moment';
import _ from 'lodash';
import authorBooksStorage from './authorBooksStorage';
@@ -230,7 +231,7 @@ export default class BaseList {
async expandSeries(seriesItem) {
this.$emit('listEvent', {action: 'ignoreScroll'});
-
+
const expandedSeries = _.cloneDeep(this.expandedSeries);
const key = seriesItem.key;
@@ -406,7 +407,8 @@ export default class BaseList {
//date
let dateFound = !s.date;
if (!dateFound) {
- let [from = '0000-00-00', to = '9999-99-99'] = 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);
}
@@ -467,4 +469,51 @@ export default class BaseList {
return (dserno ? dserno : (dtitle ? dtitle : dext));
});
}
+
+ queryDate(date) {
+ if (!(utils.isDigit(date[0]) && utils.isDigit(date[1]))) {//!manual
+ /*
+ {label: 'сегодня', value: 'today'},
+ {label: 'за 3 дня', value: '3days'},
+ {label: 'за неделю', value: 'week'},
+ {label: 'за 2 недели', value: '2weeks'},
+ {label: 'за месяц', value: 'month'},
+ {label: 'за 3 месяца', value: '3months'},
+ {label: 'указать даты', value: 'manual'},
+ */
+ const sqlFormat = 'YYYY-MM-DD';
+ switch (date) {
+ case 'today': date = utils.dateFormat(moment(), sqlFormat); break;
+ case '3days': date = utils.dateFormat(moment().subtract(3, 'days'), sqlFormat); break;
+ case 'week': date = utils.dateFormat(moment().subtract(1, 'weeks'), sqlFormat); break;
+ case '2weeks': date = utils.dateFormat(moment().subtract(2, 'weeks'), sqlFormat); break;
+ case 'month': date = utils.dateFormat(moment().subtract(1, 'months'), sqlFormat); break;
+ case '3months': date = utils.dateFormat(moment().subtract(3, 'months'), sqlFormat); break;
+ default:
+ date = '';
+ }
+ }
+
+ return date;
+ }
+
+ getQuery() {
+ let newQuery = _.cloneDeep(this.search);
+ newQuery = newQuery.setDefaults(newQuery);
+ delete newQuery.setDefaults;
+
+ //дата
+ if (newQuery.date) {
+ newQuery.date = this.queryDate(newQuery.date);
+ }
+
+ //offset
+ newQuery.offset = (newQuery.page - 1)*newQuery.limit;
+
+ //del
+ if (!this.showDeleted)
+ newQuery.del = 0;
+
+ return newQuery;
+ }
}
\ No newline at end of file
diff --git a/client/components/Search/BookView/BookView.vue b/client/components/Search/BookView/BookView.vue
index 55839f7..e76ac05 100644
--- a/client/components/Search/BookView/BookView.vue
+++ b/client/components/Search/BookView/BookView.vue
@@ -204,8 +204,7 @@ class BookView {
if (!this.book.date)
return '';
- const date = utils.parseDate(this.book.date);
- return utils.formatDate(date, 'noDate');
+ return utils.sqlDateFormat(this.book.date);
}
selectAuthor() {
diff --git a/client/components/Search/Search.vue b/client/components/Search/Search.vue
index 0502ef8..cc10e8b 100644
--- a/client/components/Search/Search.vue
+++ b/client/components/Search/Search.vue
@@ -120,14 +120,35 @@
-
-
- {{ search.date }}
-
-
+
+
+
+ {{ scope.opt.label }}
+
+
+
+
+
+
+
+ {{ scope.opt.label }}
+
+
+
+
+
+
@@ -225,6 +247,7 @@ import PageScroller from './PageScroller/PageScroller.vue';
import SelectGenreDialog from './SelectGenreDialog/SelectGenreDialog.vue';
import SelectLangDialog from './SelectLangDialog/SelectLangDialog.vue';
import SelectLibRateDialog from './SelectLibRateDialog/SelectLibRateDialog.vue';
+import SelectDateDialog from './SelectDateDialog/SelectDateDialog.vue';
import authorBooksStorage from './authorBooksStorage';
import DivBtn from '../share/DivBtn.vue';
@@ -250,6 +273,7 @@ const componentOptions = {
SelectGenreDialog,
SelectLangDialog,
SelectLibRateDialog,
+ SelectDateDialog,
Dialog,
DivBtn
},
@@ -271,6 +295,7 @@ const componentOptions = {
this.makeTitle();
this.updateRouteQueryFromSearch();
+ this.updateSearchDate(true);
},
deep: true,
},
@@ -334,7 +359,10 @@ const componentOptions = {
if (this.getListRoute() != newValue) {
this.updateRouteQueryFromSearch();
}
- }
+ },
+ searchDate() {
+ this.updateSearchDate(false);
+ },
},
};
class Search {
@@ -354,6 +382,7 @@ class Search {
selectGenreDialogVisible = false;
selectLangDialogVisible = false;
selectLibRateDialogVisible = false;
+ selectDateDialogVisible = false;
pageCount = 1;
@@ -378,6 +407,8 @@ class Search {
},
};
+ searchDate = '';
+
//settings
showCounts = true;
showRates = true;
@@ -414,6 +445,16 @@ class Search {
{label: '1000', value: 1000},
];
+ searchDateOptions = [
+ {label: 'сегодня', value: 'today'},
+ {label: 'за 3 дня', value: '3days'},
+ {label: 'за неделю', value: 'week'},
+ {label: 'за 2 недели', value: '2weeks'},
+ {label: 'за месяц', value: 'month'},
+ {label: 'за 3 месяца', value: '3months'},
+ {label: 'выбрать даты', value: 'manual'},
+ ];
+
created() {
this.commit = this.$store.commit;
this.api = this.$root.api;
@@ -928,6 +969,47 @@ class Search {
this.genreTreeUpdating = false;
}
}
+
+ 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 = 'manual';
+
+ this.searchDate = local;
+ } else {
+ if (this.searchDate != 'manual')
+ this.search.date = this.searchDate || '';
+ }
+ }
+
+ get formatSearchDate() {
+ const result = [];
+ const date = this.search.date;
+ if (this.isManualDate(date)) {
+ const [from, to] = date.split(',')
+ if (from)
+ result.push(`от
${utils.sqlDateFormat(from)}`);
+ if (to)
+ result.push(`до
${utils.sqlDateFormat(to)}`);
+ }
+
+ return result.join('
');
+ }
+
+ dateSelectItemClick(itemValue) {
+ if (itemValue == 'manual') {
+ if (!this.isManualDate(this.search.date)) {
+ this.search.date = '';
+ this.searchDate = '';
+ }
+ this.selectDateDialogVisible = true
+ }
+ }
}
export default vueComponent(Search);
diff --git a/client/components/Search/SelectDateDialog/SelectDateDialog.vue b/client/components/Search/SelectDateDialog/SelectDateDialog.vue
new file mode 100644
index 0000000..8db9084
--- /dev/null
+++ b/client/components/Search/SelectDateDialog/SelectDateDialog.vue
@@ -0,0 +1,132 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/client/components/Search/SelectLangDialog/SelectLangDialog.vue b/client/components/Search/SelectLangDialog/SelectLangDialog.vue
index 270fc94..41fa09a 100644
--- a/client/components/Search/SelectLangDialog/SelectLangDialog.vue
+++ b/client/components/Search/SelectLangDialog/SelectLangDialog.vue
@@ -3,7 +3,7 @@
- Выбрать язык
+ Выбрать языки
diff --git a/client/components/Search/SeriesList/SeriesList.vue b/client/components/Search/SeriesList/SeriesList.vue
index e0ae485..e49f9ab 100644
--- a/client/components/Search/SeriesList/SeriesList.vue
+++ b/client/components/Search/SeriesList/SeriesList.vue
@@ -224,13 +224,7 @@ class SeriesList extends BaseList {
async refresh() {
//параметры запроса
- let newQuery = _.cloneDeep(this.search);
- newQuery = newQuery.setDefaults(newQuery);
- delete newQuery.setDefaults;
- newQuery.offset = (newQuery.page - 1)*newQuery.limit;
- if (!this.showDeleted)
- newQuery.del = 0;
-
+ const newQuery = this.getQuery();
if (_.isEqual(newQuery, this.prevQuery))
return;
this.prevQuery = newQuery;
diff --git a/client/components/Search/TitleList/TitleList.vue b/client/components/Search/TitleList/TitleList.vue
index 73bf7f2..0c47009 100644
--- a/client/components/Search/TitleList/TitleList.vue
+++ b/client/components/Search/TitleList/TitleList.vue
@@ -85,13 +85,7 @@ class TitleList extends BaseList {
async refresh() {
//параметры запроса
- let newQuery = _.cloneDeep(this.search);
- newQuery = newQuery.setDefaults(newQuery);
- delete newQuery.setDefaults;
- newQuery.offset = (newQuery.page - 1)*newQuery.limit;
- if (!this.showDeleted)
- newQuery.del = 0;
-
+ const newQuery = this.getQuery();
if (_.isEqual(newQuery, this.prevQuery))
return;
this.prevQuery = newQuery;
diff --git a/client/quasar.js b/client/quasar.js
index 1ae9050..925a20f 100644
--- a/client/quasar.js
+++ b/client/quasar.js
@@ -21,14 +21,15 @@ import {QIcon} from 'quasar/src/components/icon';
//import {QTabPanels, QTabPanel} from 'quasar/src/components/tab-panels';
//import {QSeparator} from 'quasar/src/components/separator';
//import {QList} from 'quasar/src/components/item';
-//import {QItem, QItemSection, QItemLabel} from 'quasar/src/components/item';
+import {QItem, QItemSection, QItemLabel} from 'quasar/src/components/item';
import {QTooltip} from 'quasar/src/components/tooltip';
//import {QSpinner} from 'quasar/src/components/spinner';
//import {QTable, QTh, QTr, QTd} from 'quasar/src/components/table';
import {QCheckbox} from 'quasar/src/components/checkbox';
import {QSelect} from 'quasar/src/components/select';
//import {QColor} from 'quasar/src/components/color';
-//import {QPopupProxy} from 'quasar/src/components/popup-proxy';
+import {QPopupProxy} from 'quasar/src/components/popup-proxy';
+import {QDate} from 'quasar/src/components/date';
import {QDialog} from 'quasar/src/components/dialog';
//import {QChip} from 'quasar/src/components/chip';
import {QTree} from 'quasar/src/components/tree';
@@ -55,14 +56,15 @@ const components = {
//QTabPanels, QTabPanel,
//QSeparator,
//QList,
- //QItem, QItemSection, QItemLabel,
+ QItem, QItemSection, QItemLabel,
QTooltip,
//QSpinner,
//QTable, QTh, QTr, QTd,
QCheckbox,
QSelect,
//QColor,
- //QPopupProxy,
+ QPopupProxy,
+ QDate,
QDialog,
//QChip,
QTree,
@@ -91,12 +93,13 @@ const plugins = {
//import '@quasar/extras/fontawesome-v5/fontawesome-v5.css';
//import fontawesomeV5 from 'quasar/icon-set/fontawesome-v5.js'
+import lang from 'quasar/lang/ru';
import '@quasar/extras/line-awesome/line-awesome.css';
import lineAwesome from 'quasar/icon-set/line-awesome.js'
export default {
quasar: Quasar,
- options: { config, components, directives, plugins },
+ options: { config, components, directives, plugins, lang },
init: () => {
Quasar.iconSet.set(lineAwesome);
}
diff --git a/client/share/utils.js b/client/share/utils.js
index c6d9d86..53ae922 100644
--- a/client/share/utils.js
+++ b/client/share/utils.js
@@ -1,3 +1,4 @@
+import moment from 'moment';
import {Buffer} from 'safe-buffer';
//import _ from 'lodash';
@@ -98,7 +99,7 @@ export function makeValidFilename(filename, repl = '_') {
else
throw new Error('Invalid filename');
}
-
+/*
export function formatDate(d, format = 'normal') {
switch (format) {
case 'normal':
@@ -124,4 +125,17 @@ export function parseDate(sqlDate) {
result.setYear(parseInt(d[0], 10));
return result;
+}
+*/
+
+export function isDigit(c) {
+ return !isNaN(parseInt(c, 10));
+}
+
+export function dateFormat(date, format = 'DD.MM.YYYY') {
+ return moment(date).format(format);
+}
+
+export function sqlDateFormat(date, format = 'DD.MM.YYYY') {
+ return moment(date, 'YYYY-MM-DD').format(format);
}
\ No newline at end of file