diff --git a/src/lib/services.js b/src/lib/services.js index 50428336..60b8db3a 100644 --- a/src/lib/services.js +++ b/src/lib/services.js @@ -172,7 +172,7 @@ export default { getAccount: ({ id }) => { return axios.get('v1/accounts/get.json?id=' + id); }, - addAccount: ({ category, type, name, icon, color, currency, comment, subAccounts }) => { + addAccount: ({ category, type, name, icon, color, currency, balance, comment, subAccounts }) => { return axios.post('v1/accounts/add.json', { category, type, @@ -180,6 +180,7 @@ export default { icon, color, currency, + balance, comment, subAccounts }); diff --git a/src/locales/en.js b/src/locales/en.js index 1adad589..efb957cf 100644 --- a/src/locales/en.js +++ b/src/locales/en.js @@ -470,6 +470,8 @@ export default { 'Account Color': 'Account Color', 'Sub Account Color': 'Sub Account Color', 'Currency': 'Currency', + 'Account Balance': 'Account Balance', + 'Sub Account Balance': 'Sub Account Balance', 'Description': 'Description', 'Your account description (optional)': 'Your account description (optional)', 'Your sub account description (optional)': 'Your sub account description (optional)', diff --git a/src/locales/zh_Hans.js b/src/locales/zh_Hans.js index 3cd18206..6fa31df1 100644 --- a/src/locales/zh_Hans.js +++ b/src/locales/zh_Hans.js @@ -470,6 +470,8 @@ export default { 'Account Color': '账户颜色', 'Sub Account Color': '子账户颜色', 'Currency': '货币', + 'Account Balance': '账户余额', + 'Sub Account Balance': '子账户余额', 'Description': '描述', 'Your account description (optional)': '你的账户描述 (可选)', 'Your sub account description (optional)': '你的子账户描述 (可选)', diff --git a/src/views/mobile/accounts/Edit.vue b/src/views/mobile/accounts/Edit.vue index 710bf5fb..e0e35a5e 100644 --- a/src/views/mobile/accounts/Edit.vue +++ b/src/views/mobile/accounts/Edit.vue @@ -52,6 +52,7 @@ + @@ -91,6 +92,14 @@ + + + + + + @@ -236,6 +259,7 @@ export default { icon: self.$constants.icons.defaultAccountIconId, color: self.$constants.colors.defaultAccountColor, currency: self.$user.getUserInfo() ? self.$user.getUserInfo().defaultCurrency : self.$t('default.currency'), + balance: 0, comment: '', visible: true }, @@ -243,9 +267,11 @@ export default { iconCountPerRow: 7, accountChoosingIcon: null, accountChoosingColor: null, + accountInputingBalance: null, submitting: false, showIconSelection: false, - showColorSelection: false + showColorSelection: false, + showBalanceInput: false }; }, computed: { @@ -298,6 +324,7 @@ export default { self.account.icon = account.icon; self.account.color = account.color; self.account.currency = account.currency; + self.account.balance = account.balance; self.account.comment = account.comment; self.account.visible = !account.hidden; @@ -313,6 +340,7 @@ export default { icon: subAccount.icon, color: subAccount.color, currency: subAccount.currency, + balance: subAccount.balance, comment: subAccount.comment, visible: !subAccount.hidden }); @@ -350,6 +378,7 @@ export default { icon: this.account.icon, color: this.account.color, currency: self.$user.getUserInfo() ? self.$user.getUserInfo().defaultCurrency : self.$t('default.currency'), + balance: 0, comment: '' }); }, @@ -394,6 +423,23 @@ export default { this.accountChoosingColor = null; this.showColorSelection = false; }, + showBalanceInputSheet(account) { + this.accountInputingBalance = account; + this.showBalanceInput = true; + }, + onBalanceChanged(amount) { + if (!this.accountInputingBalance) { + return; + } + + this.accountInputingBalance.balance = amount; + this.accountInputingBalance = null; + this.showBalanceInput = false; + }, + onBalanceInputSheetClosed() { + this.accountInputingBalance = null; + this.showBalanceInput = false; + }, save() { const self = this; const router = self.$f7router; @@ -430,6 +476,7 @@ export default { icon: subAccount.icon, color: subAccount.color, currency: subAccount.currency, + balance: subAccount.balance, comment: subAccount.comment }; @@ -449,6 +496,7 @@ export default { icon: self.account.icon, color: self.account.color, currency: self.account.type === self.$constants.account.allAccountTypes.SingleAccount.toString() ? self.account.currency : self.$constants.currency.parentAccountCurrencyPlaceholder, + balance: self.account.balance, comment: self.account.comment, subAccounts: self.account.type === self.$constants.account.allAccountTypes.SingleAccount.toString() ? null : subAccounts, };