feat: 优化多个组件的高度设置,确保更好的用户体验;更新交易记录控制器以处理智能分类结果
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 28s
Docker Build & Deploy / Deploy to Production (push) Successful in 9s
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s
Docker Build & Deploy / WeChat Notification (push) Successful in 2s

This commit is contained in:
2026-01-11 11:21:13 +08:00
parent ad21d20751
commit d9e9fa9f53
16 changed files with 138 additions and 70 deletions

View File

@@ -4,6 +4,7 @@
:type="buttonType"
size="small"
:loading="loading || saving"
:loading-text="loadingText"
:disabled="loading || saving"
class="smart-classify-btn"
@click="handleClick"
@@ -12,9 +13,6 @@
<van-icon :name="buttonIcon" />
<span style="margin-left: 4px;">{{ buttonText }}</span>
</template>
<template v-else>
<span>{{ loadingText }}</span>
</template>
</van-button>
</template>
@@ -39,6 +37,7 @@ const emit = defineEmits(['update', 'save', 'notifyDonedTransactionId'])
const loading = ref(false)
const saving = ref(false)
const classifiedResults = ref([])
const lockClassifiedResults = ref(false)
const isAllCompleted = ref(false)
let toastInstance = null
@@ -47,7 +46,8 @@ const hasTransactions = computed(() => {
})
const hasClassifiedResults = computed(() => {
return isAllCompleted.value && classifiedResults.value.length > 0
// Show save state once we have any classified result, even if not all batches finished
return classifiedResults.value.length > 0 && lockClassifiedResults.value === false
})
// 按钮类型
@@ -92,6 +92,8 @@ const handleClick = () => {
* 保存分类结果
*/
const handleSaveClassify = async () => {
if (saving.value || loading.value) return
try {
saving.value = true
showToast({
@@ -145,12 +147,23 @@ const handleSaveClassify = async () => {
}
}
/**
* 处理智能分类
*/
const handleSmartClassify = async () => {
if (loading.value || saving.value) {
showToast('当前有任务正在进行,请稍后再试')
return
}
loading.value = true
if (!props.transactions || props.transactions.length === 0) {
showToast('没有可分类的交易记录')
loading.value = false
return
}
if(lockClassifiedResults.value) {
showToast('当前有分类任务正在进行,请稍后再试')
loading.value = false
return
}
@@ -158,17 +171,12 @@ const handleSmartClassify = async () => {
isAllCompleted.value = false
classifiedResults.value = []
const batchSize = 30
const batchSize = 3
let processedCount = 0
try {
loading.value = true
// 清除之前的Toast
if (toastInstance) {
closeToast()
}
// 等待父组件的 beforeClassify 事件处理完成(如果有返回 Promise TODO 没有生效
lockClassifiedResults.value = true
// 等待父组件的 beforeClassify 事件处理完成(如果有返回 Promise
if (props.onBeforeClassify) {
const shouldContinue = await props.onBeforeClassify()
if (shouldContinue === false) {
@@ -323,6 +331,7 @@ const handleSmartClassify = async () => {
})
} finally {
loading.value = false
lockClassifiedResults.value = false
// 确保Toast被清除
if (toastInstance) {
setTimeout(() => {
@@ -342,6 +351,11 @@ const removeClassifiedTransaction = (transactionId) => {
* 重置组件状态
*/
const reset = () => {
if(lockClassifiedResults.value) {
showToast('当前有分类任务正在进行,无法重置')
return
}
isAllCompleted.value = false
classifiedResults.value = []
loading.value = false