2020-11-30 20:42:24 +08:00
|
|
|
export const BANK_ACCOUNT_API_PATH = '/api/admin/bank-account'
|
|
|
|
|
|
|
|
const getDefaultListData = () => {
|
|
|
|
return {
|
|
|
|
bankAccounts: [],
|
|
|
|
pagination: {}
|
|
|
|
}
|
|
|
|
}
|
2021-12-28 23:21:47 +08:00
|
|
|
const getDefaultTransactionRecordListData = () => {
|
|
|
|
return {
|
|
|
|
records: [],
|
|
|
|
pagination: {}
|
|
|
|
}
|
|
|
|
}
|
2020-11-30 20:42:24 +08:00
|
|
|
|
|
|
|
export const state = () => {
|
|
|
|
return {
|
|
|
|
list: {
|
|
|
|
fetching: false,
|
|
|
|
data: getDefaultListData()
|
2021-12-28 23:21:47 +08:00
|
|
|
},
|
|
|
|
records: {
|
|
|
|
fetching: false,
|
|
|
|
data: getDefaultTransactionRecordListData()
|
2020-11-30 20:42:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const mutations = {
|
2021-12-28 23:21:47 +08:00
|
|
|
// 消费记录列表
|
|
|
|
updateTransactionRecordListFetching(state, action) {
|
|
|
|
state.records.fetching = action
|
|
|
|
},
|
|
|
|
updateTransactionRecordListData(state, action) {
|
|
|
|
state.records.data = action
|
|
|
|
},
|
2020-11-30 20:42:24 +08:00
|
|
|
updateListFetching(state, action) {
|
|
|
|
state.list.fetching = action
|
|
|
|
},
|
|
|
|
updateListData(state, action) {
|
|
|
|
state.list.data = action
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const actions = {
|
|
|
|
fetchList({commit}, params = {}) {
|
2022-06-21 08:33:33 +08:00
|
|
|
if (params && params.reset === '0') {
|
|
|
|
return true;
|
|
|
|
}
|
2020-11-30 20:42:24 +08:00
|
|
|
// 清空已有数据
|
|
|
|
commit('updateListData', getDefaultListData())
|
|
|
|
commit('updateListFetching', true)
|
|
|
|
let data = {
|
|
|
|
page: params.page || 1
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.$axios
|
|
|
|
.$get(`${BANK_ACCOUNT_API_PATH}/list`, {
|
|
|
|
params: data
|
|
|
|
})
|
|
|
|
.then(response => {
|
|
|
|
commit('updateListFetching', false);
|
|
|
|
commit('updateListData', response);
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
console.log(error);
|
|
|
|
commit('updateListFetching', false);
|
|
|
|
});
|
2021-12-28 23:21:47 +08:00
|
|
|
},
|
|
|
|
// 获取账户交易记录
|
|
|
|
fetchTransactionRecordList({commit}, params = {}) {
|
|
|
|
commit('updateTransactionRecordListFetching', true)
|
|
|
|
return this.$axios
|
|
|
|
.$get(`${BANK_ACCOUNT_API_PATH}/transaction-records`, {
|
|
|
|
params: {
|
|
|
|
bankAccount: params.bankAccount,
|
|
|
|
startDate: params.startDate,
|
|
|
|
endDate: params.endDate,
|
|
|
|
page: params.page || 1
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.then(response => {
|
|
|
|
return new Promise(resolve => {
|
|
|
|
commit('updateTransactionRecordListData', response)
|
|
|
|
commit('updateTransactionRecordListFetching', false)
|
|
|
|
resolve(response)
|
|
|
|
// delay(() => {
|
|
|
|
// resolve(response)
|
|
|
|
// })
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
commit('updateTransactionRecordListFetching', false)
|
|
|
|
return Promise.reject(error)
|
|
|
|
})
|
2020-11-30 20:42:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|