mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 01:04:25 +08:00
do not update the list if no delete action is performed
This commit is contained in:
@@ -57,14 +57,16 @@ const showState = ref<boolean>(false);
|
|||||||
const deleting = ref<boolean>(false);
|
const deleting = ref<boolean>(false);
|
||||||
const deleteIds = ref<string[]>([]);
|
const deleteIds = ref<string[]>([]);
|
||||||
const currentPassword = ref<string>('');
|
const currentPassword = ref<string>('');
|
||||||
|
const tryDeleted = ref<boolean>(false);
|
||||||
|
|
||||||
let resolveFunc: ((response: number) => void) | null = null;
|
let resolveFunc: ((response: number) => void) | null = null;
|
||||||
let rejectFunc: ((reason?: unknown) => void) | null = null;
|
let rejectFunc: ((tryDeleted: boolean) => void) | null = null;
|
||||||
|
|
||||||
function open(options: { updateIds: string[] }): Promise<number> {
|
function open(options: { updateIds: string[] }): Promise<number> {
|
||||||
deleteIds.value = options.updateIds;
|
deleteIds.value = options.updateIds;
|
||||||
currentPassword.value = '';
|
currentPassword.value = '';
|
||||||
deleting.value = false;
|
deleting.value = false;
|
||||||
|
tryDeleted.value = false;
|
||||||
showState.value = true;
|
showState.value = true;
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@@ -75,6 +77,7 @@ function open(options: { updateIds: string[] }): Promise<number> {
|
|||||||
|
|
||||||
function confirm(): void {
|
function confirm(): void {
|
||||||
deleting.value = true;
|
deleting.value = true;
|
||||||
|
tryDeleted.value = true;
|
||||||
|
|
||||||
transactionsStore.batchDeleteTransactions({
|
transactionsStore.batchDeleteTransactions({
|
||||||
transactionIds: deleteIds.value,
|
transactionIds: deleteIds.value,
|
||||||
@@ -93,7 +96,7 @@ function confirm(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function cancel(): void {
|
function cancel(): void {
|
||||||
rejectFunc?.();
|
rejectFunc?.(tryDeleted.value);
|
||||||
showState.value = false;
|
showState.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -412,11 +412,10 @@ function batchDeleteTransactions(): void {
|
|||||||
}
|
}
|
||||||
selectedTransactions.value = {};
|
selectedTransactions.value = {};
|
||||||
emit('update:transactions');
|
emit('update:transactions');
|
||||||
}).catch(error => {
|
}).catch(tryDeleted => {
|
||||||
if (error) {
|
if (tryDeleted) {
|
||||||
snackbar.value?.showError(error);
|
emit('update:transactions');
|
||||||
}
|
}
|
||||||
emit('update:transactions');
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user