feat: 实现核心应用结构、全局命令面板和初步交易相关页面及服务。
This commit is contained in:
@@ -7,6 +7,7 @@ import api from './api';
|
||||
import type {
|
||||
Transaction,
|
||||
TransactionFormInput,
|
||||
TransactionFilter,
|
||||
ApiResponse,
|
||||
PaginatedResponse,
|
||||
TransactionType,
|
||||
@@ -16,27 +17,7 @@ import type {
|
||||
RefundStatus,
|
||||
} from '../types';
|
||||
|
||||
/**
|
||||
* Transaction filter parameters
|
||||
*/
|
||||
export interface TransactionFilter {
|
||||
/** Filter by start date (inclusive) */
|
||||
startDate?: string;
|
||||
/** Filter by end date (inclusive) */
|
||||
endDate?: string;
|
||||
/** Filter by category ID */
|
||||
categoryId?: number;
|
||||
/** Filter by account ID */
|
||||
accountId?: number;
|
||||
/** Filter by transaction type */
|
||||
type?: TransactionType;
|
||||
/** Search in notes */
|
||||
search?: string;
|
||||
/** Page number (1-based) */
|
||||
page?: number;
|
||||
/** Items per page */
|
||||
pageSize?: number;
|
||||
}
|
||||
// TransactionFilter is imported from types/index.ts
|
||||
|
||||
/**
|
||||
* Transform API response transaction to frontend Transaction type
|
||||
@@ -79,6 +60,8 @@ export async function getTransactions(
|
||||
if (filter.categoryId) params.category_id = filter.categoryId;
|
||||
if (filter.accountId) params.account_id = filter.accountId;
|
||||
if (filter.type) params.type = filter.type;
|
||||
if (filter.currency) params.currency = filter.currency;
|
||||
if (filter.ledgerId) params.ledger_id = filter.ledgerId;
|
||||
if (filter.search) params.note_search = filter.search;
|
||||
if (filter.page) params.offset = ((filter.page - 1) * (filter.pageSize || 20)).toString();
|
||||
if (filter.pageSize) params.limit = filter.pageSize;
|
||||
@@ -153,6 +136,7 @@ export async function createTransaction(data: TransactionFormInput): Promise<Tra
|
||||
transaction_date: data.transactionDate,
|
||||
note: data.note,
|
||||
tag_ids: data.tagIds,
|
||||
ledger_id: data.ledgerId,
|
||||
};
|
||||
const response = await api.post<ApiResponse<Transaction>>('/transactions', payload);
|
||||
if (!response.data) {
|
||||
@@ -178,6 +162,7 @@ export async function updateTransaction(
|
||||
if (data.transactionDate !== undefined) payload.transaction_date = data.transactionDate;
|
||||
if (data.note !== undefined) payload.note = data.note;
|
||||
if (data.tagIds !== undefined) payload.tag_ids = data.tagIds;
|
||||
if (data.ledgerId !== undefined) payload.ledger_id = data.ledgerId;
|
||||
|
||||
const response = await api.put<ApiResponse<Transaction>>(`/transactions/${id}`, payload);
|
||||
if (!response.data) {
|
||||
|
||||
Reference in New Issue
Block a user