diff --git a/src/api/balance/index.ts b/src/api/balance/index.ts index 4e7fd008..0b071965 100644 --- a/src/api/balance/index.ts +++ b/src/api/balance/index.ts @@ -8,9 +8,9 @@ export async function getIncomeApi( requestData: Balance.BalanceIncomeRequestData ): Promise { const queryParams = objectToQueryParams(requestData) - const response = await fetchGet( - `/balance/income?${queryParams}` - ) + const url = `/balance/income?${queryParams}` + + const response = await fetchGet(url) return response } @@ -19,8 +19,15 @@ export async function getExpenditureApi( requestData: Balance.BalanceExpenditureRequestData ): Promise { const queryParams = objectToQueryParams(requestData) - const response = await fetchGet( - `/balance/expenditure?${queryParams}` - ) + const url = `/balance/expenditure?${queryParams}` + + const response = await fetchGet(url) + return response +} + +// 收支总额 +export async function getPLStatementApi(): Promise { + const url = `/balance/statement` + const response = await fetchGet(url) return response } diff --git a/src/api/balance/types/balance.ts b/src/api/balance/types/balance.ts index f230463a..e78bc27f 100644 --- a/src/api/balance/types/balance.ts +++ b/src/api/balance/types/balance.ts @@ -17,18 +17,35 @@ export interface BalanceExpenditureRequestData { sortOrder: SortOrder } -// income 响应数据 -export type BalanceIncomeResponseData = KUNGalgameResponseData<{ +// 单条收入返回数据 +export interface BalanceIncome { iid: number reason: string time: number amount: number -}> +} -// expenditure 响应数据 -export type BalanceExpenditureResponseData = KUNGalgameResponseData<{ +// 单条支出返回数据 +export interface BalanceExpenditure { eid: number reason: string time: number amount: number -}> +} + +// 收支总额返回数据 +export interface PLStatement { + totalIncome: number + totalExpenditure: number + profitLoss: number +} + +// income 响应数据 +export type BalanceIncomeResponseData = KUNGalgameResponseData + +// expenditure 响应数据 +export type BalanceExpenditureResponseData = KUNGalgameResponseData< + BalanceExpenditure[] +> + +export type BalancePLStatementResponseData = KUNGalgameResponseData diff --git a/src/store/modules/balance.ts b/src/store/modules/balance.ts index 33e84fcc..747899ad 100644 --- a/src/store/modules/balance.ts +++ b/src/store/modules/balance.ts @@ -6,9 +6,10 @@ import type { BalanceExpenditureRequestData, BalanceIncomeResponseData, BalanceExpenditureResponseData, + BalancePLStatementResponseData, } from '@/api' -import { getIncomeApi, getExpenditureApi } from '@/api' +import { getIncomeApi, getExpenditureApi, getPLStatementApi } from '@/api' interface BalanceStore { income: BalanceIncomeRequestData @@ -58,5 +59,10 @@ export const useKUNGalgameBalanceStore = defineStore({ } return await getExpenditureApi(requestData) }, + + // 获取收支总额 + async getPLStatement(): Promise { + return await getPLStatementApi() + }, }, }) diff --git a/src/views/balance/Balance.vue b/src/views/balance/Balance.vue index bfb3735e..d43ddf09 100644 --- a/src/views/balance/Balance.vue +++ b/src/views/balance/Balance.vue @@ -1,8 +1,43 @@