fix
This commit is contained in:
@@ -101,6 +101,10 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { showConfirmDialog, showToast } from 'vant'
|
||||
import { deleteTransaction } from '@/api/transactionRecord'
|
||||
|
||||
import { defineEmits } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
@@ -132,6 +136,8 @@ const props = defineProps({
|
||||
|
||||
const emit = defineEmits(['load', 'click', 'delete', 'update:selectedIds'])
|
||||
|
||||
const deletingIds = ref(new Set())
|
||||
|
||||
const onLoad = () => {
|
||||
emit('load')
|
||||
}
|
||||
@@ -140,8 +146,35 @@ const handleClick = (transaction) => {
|
||||
emit('click', transaction)
|
||||
}
|
||||
|
||||
const handleDeleteClick = (transaction) => {
|
||||
emit('delete', transaction)
|
||||
const handleDeleteClick = async (transaction) => {
|
||||
try {
|
||||
await showConfirmDialog({
|
||||
title: '提示',
|
||||
message: '确定要删除这条交易记录吗?'
|
||||
})
|
||||
|
||||
deletingIds.value.add(transaction.id)
|
||||
const response = await deleteTransaction(transaction.id)
|
||||
deletingIds.value.delete(transaction.id)
|
||||
|
||||
if (response && response.success) {
|
||||
showToast('删除成功')
|
||||
emit('delete', transaction.id)
|
||||
try {
|
||||
window.dispatchEvent(new CustomEvent('transaction-deleted', { detail: transaction.id }))
|
||||
} catch (e) {
|
||||
// ignore in non-browser environment
|
||||
}
|
||||
} else {
|
||||
showToast(response.message || '删除失败')
|
||||
}
|
||||
} catch (err) {
|
||||
// 用户取消确认会抛出 'cancel' 或类似错误
|
||||
if (err !== 'cancel') {
|
||||
console.error('删除出错:', err)
|
||||
showToast('删除失败')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const isSelected = (id) => {
|
||||
|
||||
Reference in New Issue
Block a user