transaction list page supports filtering and searching, transaction add page supports setting default value by query parameters

This commit is contained in:
MaysWind
2021-01-02 23:30:18 +08:00
parent 67808bd4af
commit efaf411902
11 changed files with 616 additions and 31 deletions
+2 -2
View File
@@ -219,8 +219,8 @@ export default {
id
});
},
getTransactions: ({ maxTime, type, categoryId, accountId }) => {
return axios.get(`v1/transactions/list.json?max_time=${maxTime}&type=${type}&category_id=${categoryId}&account_id=${accountId}&count=20`);
getTransactions: ({ maxTime, minTime, type, categoryId, accountId, keyword }) => {
return axios.get(`v1/transactions/list.json?max_time=${maxTime}&min_time=${minTime}&type=${type}&category_id=${categoryId}&account_id=${accountId}&keyword=${keyword}&count=20`);
},
getTransaction: ({ id }) => {
return axios.get('v1/transactions/get.json?id=' + id);
+61 -2
View File
@@ -33,7 +33,7 @@ function isBoolean(val) {
return typeof(val) === 'boolean';
}
function parseDateFromUnixtime(unixTime) {
function parseDateFromUnixTime(unixTime) {
return moment.unix(unixTime);
}
@@ -76,6 +76,54 @@ function getDayOfWeek(date) {
return moment(date).format('dddd');
}
function getUnixTimeBeforeUnixTime(unixTime, amount, unit) {
return moment.unix(unixTime).subtract(amount, unit).unix();
}
function getMinuteFirstUnixTime(date) {
const datetime = moment(date);
return datetime.set({ second: 0, millisecond: 0 }).unix();
}
function getMinuteLastUnixTime(date) {
return moment.unix(getMinuteFirstUnixTime(date)).add(1, 'minutes').subtract(1, 'seconds').unix();
}
function getTodayFirstUnixTime() {
return moment({ hour: 0, minute: 0, second: 0, millisecond: 0 }).unix();
}
function getTodayLastUnixTime() {
return moment.unix(getTodayFirstUnixTime()).add(1, 'days').subtract(1, 'seconds').unix();
}
function getThisWeekFirstUnixTime() {
const today = moment.unix(getTodayFirstUnixTime());
return today.subtract(today.day(), 'days').unix();
}
function getThisWeekLastUnixTime() {
return moment.unix(getThisWeekFirstUnixTime()).add(7, 'days').subtract(1, 'seconds').unix();
}
function getThisMonthFirstUnixTime() {
const today = moment.unix(getTodayFirstUnixTime());
return today.subtract(today.date() - 1, 'days').unix();
}
function getThisMonthLastUnixTime() {
return moment.unix(getThisMonthFirstUnixTime()).add(1, 'months').subtract(1, 'seconds').unix();
}
function getThisYearFirstUnixTime() {
const today = moment.unix(getTodayFirstUnixTime());
return today.subtract(today.dayOfYear() - 1, 'days').unix();
}
function getThisYearLastUnixTime() {
return moment.unix(getThisYearFirstUnixTime()).add(1, 'years').subtract(1, 'seconds').unix();
}
function copyObjectTo(fromObject, toObject) {
if (!isObject(fromObject)) {
return toObject;
@@ -433,7 +481,7 @@ export default {
isString,
isNumber,
isBoolean,
parseDateFromUnixtime,
parseDateFromUnixTime,
formatDate,
formatUnixTime,
getUnixTime,
@@ -442,6 +490,17 @@ export default {
getYearAndMonth,
getDay,
getDayOfWeek,
getUnixTimeBeforeUnixTime,
getMinuteFirstUnixTime,
getMinuteLastUnixTime,
getTodayFirstUnixTime,
getTodayLastUnixTime,
getThisWeekFirstUnixTime,
getThisWeekLastUnixTime,
getThisMonthFirstUnixTime,
getThisMonthLastUnixTime,
getThisYearFirstUnixTime,
getThisYearLastUnixTime,
copyObjectTo,
copyArrayTo,
appendThousandsSeparator,