mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 01:04:25 +08:00
fix bug
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
|||||||
UPDATE_ACCOUNT_LIST_INVALID_STATE,
|
UPDATE_ACCOUNT_LIST_INVALID_STATE,
|
||||||
|
|
||||||
LOAD_TRANSACTION_LIST,
|
LOAD_TRANSACTION_LIST,
|
||||||
|
COLLAPSE_MONTH_IN_TRANSACTION_LIST,
|
||||||
SAVE_TRANSACTION_IN_TRANSACTION_LIST,
|
SAVE_TRANSACTION_IN_TRANSACTION_LIST,
|
||||||
REMOVE_TRANSACTION_FROM_TRANSACTION_LIST,
|
REMOVE_TRANSACTION_FROM_TRANSACTION_LIST,
|
||||||
UPDATE_TRANSACTION_LIST_INVALID_STATE,
|
UPDATE_TRANSACTION_LIST_INVALID_STATE,
|
||||||
@@ -343,6 +344,11 @@ const stores = {
|
|||||||
state.transactionsNextTimeId = -1;
|
state.transactionsNextTimeId = -1;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
[COLLAPSE_MONTH_IN_TRANSACTION_LIST] (state, { month, collapse }) {
|
||||||
|
if (month) {
|
||||||
|
month.opened = !collapse;
|
||||||
|
}
|
||||||
|
},
|
||||||
[SAVE_TRANSACTION_IN_TRANSACTION_LIST] (state, { transaction, defaultCurrency, accountId }) {
|
[SAVE_TRANSACTION_IN_TRANSACTION_LIST] (state, { transaction, defaultCurrency, accountId }) {
|
||||||
for (let i = 0; i < state.transactions.length; i++) {
|
for (let i = 0; i < state.transactions.length; i++) {
|
||||||
const transactionMonthList = state.transactions[i];
|
const transactionMonthList = state.transactions[i];
|
||||||
@@ -581,6 +587,7 @@ const stores = {
|
|||||||
getTransaction: transaction.getTransaction,
|
getTransaction: transaction.getTransaction,
|
||||||
saveTransaction: transaction.saveTransaction,
|
saveTransaction: transaction.saveTransaction,
|
||||||
deleteTransaction: transaction.deleteTransaction,
|
deleteTransaction: transaction.deleteTransaction,
|
||||||
|
collapseMonthInTransactionList: transaction.collapseMonthInTransactionList,
|
||||||
|
|
||||||
loadAllCategories: transactionCategory.loadAllCategories,
|
loadAllCategories: transactionCategory.loadAllCategories,
|
||||||
getCategory: transactionCategory.getCategory,
|
getCategory: transactionCategory.getCategory,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ export const REMOVE_ACCOUNT_FROM_ACCOUNT_LIST = 'REMOVE_ACCOUNT_FROM_ACCOUNT_LIS
|
|||||||
export const UPDATE_ACCOUNT_LIST_INVALID_STATE = 'UPDATE_ACCOUNT_LIST_INVALID_STATE';
|
export const UPDATE_ACCOUNT_LIST_INVALID_STATE = 'UPDATE_ACCOUNT_LIST_INVALID_STATE';
|
||||||
|
|
||||||
export const LOAD_TRANSACTION_LIST = 'LOAD_TRANSACTION_LIST';
|
export const LOAD_TRANSACTION_LIST = 'LOAD_TRANSACTION_LIST';
|
||||||
|
export const COLLAPSE_MONTH_IN_TRANSACTION_LIST = 'COLLAPSE_MONTH_IN_TRANSACTION_LIST';
|
||||||
export const SAVE_TRANSACTION_IN_TRANSACTION_LIST = 'SAVE_TRANSACTION_IN_TRANSACTION_LIST';
|
export const SAVE_TRANSACTION_IN_TRANSACTION_LIST = 'SAVE_TRANSACTION_IN_TRANSACTION_LIST';
|
||||||
export const REMOVE_TRANSACTION_FROM_TRANSACTION_LIST = 'REMOVE_TRANSACTION_FROM_TRANSACTION_LIST';
|
export const REMOVE_TRANSACTION_FROM_TRANSACTION_LIST = 'REMOVE_TRANSACTION_FROM_TRANSACTION_LIST';
|
||||||
export const UPDATE_TRANSACTION_LIST_INVALID_STATE = 'UPDATE_TRANSACTION_LIST_INVALID_STATE';
|
export const UPDATE_TRANSACTION_LIST_INVALID_STATE = 'UPDATE_TRANSACTION_LIST_INVALID_STATE';
|
||||||
|
|||||||
@@ -6,16 +6,22 @@ import utils from '../lib/utils.js';
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
LOAD_TRANSACTION_LIST,
|
LOAD_TRANSACTION_LIST,
|
||||||
|
COLLAPSE_MONTH_IN_TRANSACTION_LIST,
|
||||||
REMOVE_TRANSACTION_FROM_TRANSACTION_LIST,
|
REMOVE_TRANSACTION_FROM_TRANSACTION_LIST,
|
||||||
UPDATE_TRANSACTION_LIST_INVALID_STATE,
|
UPDATE_TRANSACTION_LIST_INVALID_STATE,
|
||||||
UPDATE_ACCOUNT_LIST_INVALID_STATE,
|
UPDATE_ACCOUNT_LIST_INVALID_STATE,
|
||||||
} from './mutations.js';
|
} from './mutations.js';
|
||||||
|
|
||||||
|
const emptyTransactionResult = {
|
||||||
|
items: [],
|
||||||
|
transactionsNextTimeId: 0
|
||||||
|
};
|
||||||
|
|
||||||
function getTransactions(context, { reload, autoExpand, defaultCurrency, maxTime, minTime, type, categoryId, accountId, keyword }) {
|
function getTransactions(context, { reload, autoExpand, defaultCurrency, maxTime, minTime, type, categoryId, accountId, keyword }) {
|
||||||
let actualMaxTime = context.state.transactionsNextTimeId;
|
let actualMaxTime = context.state.transactionsNextTimeId;
|
||||||
|
|
||||||
if (reload && maxTime > 0) {
|
if (reload && maxTime > 0) {
|
||||||
actualMaxTime = maxTime * 1000 + 999;
|
actualMaxTime = maxTime;
|
||||||
} else if (reload && maxTime <= 0) {
|
} else if (reload && maxTime <= 0) {
|
||||||
actualMaxTime = 0;
|
actualMaxTime = 0;
|
||||||
}
|
}
|
||||||
@@ -32,6 +38,17 @@ function getTransactions(context, { reload, autoExpand, defaultCurrency, maxTime
|
|||||||
const data = response.data;
|
const data = response.data;
|
||||||
|
|
||||||
if (!data || !data.success || !data.result) {
|
if (!data || !data.success || !data.result) {
|
||||||
|
if (reload) {
|
||||||
|
context.commit(LOAD_TRANSACTION_LIST, {
|
||||||
|
transactions: emptyTransactionResult,
|
||||||
|
reload: reload,
|
||||||
|
autoExpand: autoExpand,
|
||||||
|
defaultCurrency: defaultCurrency,
|
||||||
|
accountId: accountId
|
||||||
|
});
|
||||||
|
context.commit(UPDATE_TRANSACTION_LIST_INVALID_STATE, true);
|
||||||
|
}
|
||||||
|
|
||||||
reject({ message: 'Unable to get transaction list' });
|
reject({ message: 'Unable to get transaction list' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -52,6 +69,17 @@ function getTransactions(context, { reload, autoExpand, defaultCurrency, maxTime
|
|||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
logger.error('failed to load transaction list', error);
|
logger.error('failed to load transaction list', error);
|
||||||
|
|
||||||
|
if (reload) {
|
||||||
|
context.commit(LOAD_TRANSACTION_LIST, {
|
||||||
|
transactions: emptyTransactionResult,
|
||||||
|
reload: reload,
|
||||||
|
autoExpand: autoExpand,
|
||||||
|
defaultCurrency: defaultCurrency,
|
||||||
|
accountId: accountId
|
||||||
|
});
|
||||||
|
context.commit(UPDATE_TRANSACTION_LIST_INVALID_STATE, true);
|
||||||
|
}
|
||||||
|
|
||||||
if (error.response && error.response.data && error.response.data.errorMessage) {
|
if (error.response && error.response.data && error.response.data.errorMessage) {
|
||||||
reject({ error: error.response.data });
|
reject({ error: error.response.data });
|
||||||
} else if (!error.processed) {
|
} else if (!error.processed) {
|
||||||
@@ -184,6 +212,13 @@ function deleteTransaction(context, { transaction, defaultCurrency, accountId, b
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function collapseMonthInTransactionList(context, { month, collapse }) {
|
||||||
|
context.commit(COLLAPSE_MONTH_IN_TRANSACTION_LIST, {
|
||||||
|
month: month,
|
||||||
|
collapse: collapse
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function noTransaction(state) {
|
function noTransaction(state) {
|
||||||
for (let i = 0; i < state.transactions.length; i++) {
|
for (let i = 0; i < state.transactions.length; i++) {
|
||||||
const transactionMonthList = state.transactions[i];
|
const transactionMonthList = state.transactions[i];
|
||||||
@@ -263,6 +298,7 @@ export default {
|
|||||||
getTransaction,
|
getTransaction,
|
||||||
saveTransaction,
|
saveTransaction,
|
||||||
deleteTransaction,
|
deleteTransaction,
|
||||||
|
collapseMonthInTransactionList,
|
||||||
noTransaction,
|
noTransaction,
|
||||||
hasMoreTransaction,
|
hasMoreTransaction,
|
||||||
calculateMonthTotalAmount
|
calculateMonthTotalAmount
|
||||||
|
|||||||
@@ -132,8 +132,8 @@
|
|||||||
|
|
||||||
<f7-card v-for="transactionMonthList in transactions" :key="transactionMonthList.yearMonth">
|
<f7-card v-for="transactionMonthList in transactions" :key="transactionMonthList.yearMonth">
|
||||||
<f7-accordion-item :opened="transactionMonthList.opened"
|
<f7-accordion-item :opened="transactionMonthList.opened"
|
||||||
@accordion:open="transactionMonthList.opened = true"
|
@accordion:open="collapseTransactionMonthList(transactionMonthList, false)"
|
||||||
@accordion:close="transactionMonthList.opened = false">
|
@accordion:close="collapseTransactionMonthList(transactionMonthList, true)">
|
||||||
<f7-card-header>
|
<f7-card-header>
|
||||||
<f7-accordion-toggle class="full-line">
|
<f7-accordion-toggle class="full-line">
|
||||||
<small :style="{ opacity: 0.6 }">
|
<small :style="{ opacity: 0.6 }">
|
||||||
@@ -521,6 +521,12 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
collapseTransactionMonthList(month, collapse) {
|
||||||
|
this.$store.dispatch('collapseMonthInTransactionList', {
|
||||||
|
month: month,
|
||||||
|
collapse: collapse
|
||||||
|
});
|
||||||
|
},
|
||||||
changeDateFilter(dateType) {
|
changeDateFilter(dateType) {
|
||||||
if (dateType === 11) { // Custom
|
if (dateType === 11) { // Custom
|
||||||
this.showCustomDateRangeSheet = true;
|
this.showCustomDateRangeSheet = true;
|
||||||
@@ -567,7 +573,6 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.transactions = [];
|
|
||||||
this.query.dateType = dateType;
|
this.query.dateType = dateType;
|
||||||
|
|
||||||
this.showDatePopover = false;
|
this.showDatePopover = false;
|
||||||
@@ -581,7 +586,6 @@ export default {
|
|||||||
this.query.maxTime = maxTime;
|
this.query.maxTime = maxTime;
|
||||||
this.query.minTime = minTime;
|
this.query.minTime = minTime;
|
||||||
|
|
||||||
this.transactions = [];
|
|
||||||
this.query.dateType = 11;
|
this.query.dateType = 11;
|
||||||
|
|
||||||
this.showCustomDateRangeSheet = false;
|
this.showCustomDateRangeSheet = false;
|
||||||
@@ -601,7 +605,6 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.transactions = [];
|
|
||||||
this.query.type = type;
|
this.query.type = type;
|
||||||
this.showTypePopover = false;
|
this.showTypePopover = false;
|
||||||
this.reload(null);
|
this.reload(null);
|
||||||
@@ -611,7 +614,6 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.transactions = [];
|
|
||||||
this.query.categoryId = categoryId;
|
this.query.categoryId = categoryId;
|
||||||
this.showCategoryPopover = false;
|
this.showCategoryPopover = false;
|
||||||
this.reload(null);
|
this.reload(null);
|
||||||
@@ -621,7 +623,6 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.transactions = [];
|
|
||||||
this.query.accountId = accountId;
|
this.query.accountId = accountId;
|
||||||
this.showAccountPopover = false;
|
this.showAccountPopover = false;
|
||||||
this.reload(null);
|
this.reload(null);
|
||||||
@@ -631,7 +632,6 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.transactions = [];
|
|
||||||
this.query.keyword = keyword;
|
this.query.keyword = keyword;
|
||||||
this.reload(null);
|
this.reload(null);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user