migrate transaction edit page to composition API and typescript

This commit is contained in:
MaysWind
2025-02-05 00:02:40 +08:00
parent 3e7b3297aa
commit 833e767e6c
12 changed files with 1979 additions and 2264 deletions
+3 -20
View File
@@ -43,7 +43,6 @@ import {
countSplitItems
} from '@/lib/common.ts';
import {
getCurrentUnixTime,
getTimezoneOffsetMinutes,
getBrowserTimezoneOffsetMinutes,
getActualUnixTimeForStore,
@@ -510,21 +509,6 @@ export const useTransactionsStore = defineStore('transactions', () => {
clearUserTransactionDraft();
}
function generateNewTransactionModel(type: string): Transaction {
const now: number = getCurrentUnixTime();
const currentTimezone: string = settingsStore.appSettings.timeZone;
let defaultType: TransactionType = TransactionType.Expense;
if (type === TransactionType.Income.toString()) {
defaultType = TransactionType.Income;
} else if (type === TransactionType.Transfer.toString()) {
defaultType = TransactionType.Transfer;
}
return Transaction.createNewTransaction(defaultType, now, currentTimezone, getTimezoneOffsetMinutes(currentTimezone));
}
function setTransactionSuitableDestinationAmount(transaction: Transaction, oldValue: number, newValue: number): void {
if (transaction.type === TransactionType.Expense || transaction.type === TransactionType.Income) {
transaction.destinationAmount = newValue;
@@ -1133,7 +1117,7 @@ export const useTransactionsStore = defineStore('transactions', () => {
});
}
function uploadTransactionPicture({ pictureFile, clientSessionId }: { pictureFile: File, clientSessionId: string }): Promise<TransactionPictureInfoBasicResponse> {
function uploadTransactionPicture({ pictureFile, clientSessionId }: { pictureFile: File, clientSessionId?: string }): Promise<TransactionPictureInfoBasicResponse> {
return new Promise((resolve, reject) => {
services.uploadTransactionPicture({ pictureFile, clientSessionId }).then(response => {
const data = response.data;
@@ -1183,9 +1167,9 @@ export const useTransactionsStore = defineStore('transactions', () => {
});
}
function getTransactionPictureUrl(pictureInfo?: TransactionPictureInfoBasicResponse | null, disableBrowserCache?: boolean | string): string | null {
function getTransactionPictureUrl(pictureInfo?: TransactionPictureInfoBasicResponse | null, disableBrowserCache?: boolean | string): string | undefined {
if (!pictureInfo || !pictureInfo.originalUrl) {
return null;
return undefined;
}
return services.getTransactionPictureUrlWithToken(pictureInfo.originalUrl, disableBrowserCache);
@@ -1218,7 +1202,6 @@ export const useTransactionsStore = defineStore('transactions', () => {
isTransactionDraftModified,
saveTransactionDraft,
clearTransactionDraft,
generateNewTransactionModel,
setTransactionSuitableDestinationAmount,
updateTransactionListInvalidState,
resetTransactions,