mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 01:04:25 +08:00
support pull to refresh in account list page
This commit is contained in:
@@ -26,6 +26,23 @@ function isBoolean(val) {
|
|||||||
return typeof(val) === 'boolean';
|
return typeof(val) === 'boolean';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getCategorizedAccounts(allAccounts) {
|
||||||
|
const ret = {};
|
||||||
|
|
||||||
|
for (let i = 0; i < allAccounts.length; i++) {
|
||||||
|
const account = allAccounts[i];
|
||||||
|
|
||||||
|
if (!ret[account.category]) {
|
||||||
|
ret[account.category] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const accountList = ret[account.category];
|
||||||
|
accountList.push(account);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
isFunction,
|
isFunction,
|
||||||
isObject,
|
isObject,
|
||||||
@@ -33,4 +50,5 @@ export default {
|
|||||||
isString,
|
isString,
|
||||||
isNumber,
|
isNumber,
|
||||||
isBoolean,
|
isBoolean,
|
||||||
|
getCategorizedAccounts,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<f7-page>
|
<f7-page ptr @ptr:refresh="reload">
|
||||||
<f7-navbar>
|
<f7-navbar>
|
||||||
<f7-nav-left :back-link="$t('Back')"></f7-nav-left>
|
<f7-nav-left :back-link="$t('Back')"></f7-nav-left>
|
||||||
<f7-nav-title :title="$t('Account List')" :back-link="$t('Back')"></f7-nav-title>
|
<f7-nav-title :title="$t('Account List')" :back-link="$t('Back')"></f7-nav-title>
|
||||||
@@ -97,18 +97,7 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.accounts = {};
|
self.accounts = self.$utils.getCategorizedAccounts(data.result);
|
||||||
|
|
||||||
for (let i = 0; i < data.result.length; i++) {
|
|
||||||
const account = data.result[i];
|
|
||||||
|
|
||||||
if (!self.accounts[account.category]) {
|
|
||||||
self.accounts[account.category] = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
const accountList = self.accounts[account.category];
|
|
||||||
accountList.push(account);
|
|
||||||
}
|
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
self.loading = false;
|
self.loading = false;
|
||||||
|
|
||||||
@@ -124,6 +113,30 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
reload(done) {
|
||||||
|
const self = this;
|
||||||
|
|
||||||
|
self.$services.getAllAccounts().then(response => {
|
||||||
|
done();
|
||||||
|
|
||||||
|
const data = response.data;
|
||||||
|
|
||||||
|
if (!data || !data.success || !data.result) {
|
||||||
|
self.$toast('Unable to get account list');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.accounts = self.$utils.getCategorizedAccounts(data.result);
|
||||||
|
}).catch(error => {
|
||||||
|
done();
|
||||||
|
|
||||||
|
if (error.response && error.response.data && error.response.data.errorMessage) {
|
||||||
|
self.$toast({ error: error.response.data });
|
||||||
|
} else if (!error.processed) {
|
||||||
|
self.$toast('Unable to get account list');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
edit() {
|
edit() {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user