fix
This commit is contained in:
@@ -51,7 +51,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { ref, computed, onMounted, nextTick } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { showToast, showLoadingToast, closeToast, showConfirmDialog } from 'vant'
|
||||
import {
|
||||
@@ -68,6 +68,7 @@ const totalGroups = ref(0)
|
||||
const classifying = ref(false)
|
||||
const hasChanges = ref(false)
|
||||
const classifyBuffer = ref('')
|
||||
const suppressDataChanged = ref(false)
|
||||
|
||||
// 计算已选中的数量
|
||||
const selectedCount = computed(() => {
|
||||
@@ -98,6 +99,11 @@ const handleDataLoaded = ({ groups, total }) => {
|
||||
|
||||
// 处理数据变更
|
||||
const handleDataChanged = async () => {
|
||||
if (suppressDataChanged.value) {
|
||||
suppressDataChanged.value = false
|
||||
return
|
||||
}
|
||||
|
||||
await loadUnclassifiedCount()
|
||||
hasChanges.value = false
|
||||
}
|
||||
@@ -191,6 +197,7 @@ const startClassify = async () => {
|
||||
|
||||
// 处理SSE事件
|
||||
const handleSSEEvent = (eventType, data, classifyResults) => {
|
||||
console.log('收到事件:', eventType, data)
|
||||
if (eventType === 'data') {
|
||||
try {
|
||||
classifyBuffer.value += data
|
||||
@@ -221,27 +228,32 @@ const handleSSEEvent = (eventType, data, classifyResults) => {
|
||||
|
||||
try {
|
||||
const result = JSON.parse(jsonStr)
|
||||
|
||||
if (result.id && groupListRef.value) {
|
||||
classifyResults.set(result.id, {
|
||||
classify: result.classify || '',
|
||||
type: result.type !== undefined ? result.type : null
|
||||
classify: result.Classify || '',
|
||||
type: result.Type !== undefined ? result.Type : null
|
||||
})
|
||||
|
||||
// 更新组件内的分组显示状态
|
||||
const groups = groupListRef.value.getList()
|
||||
for (const group of groups) {
|
||||
if (group.transactionIds.includes(result.id)) {
|
||||
group.sampleClassify = result.classify || ''
|
||||
if (result.type !== undefined && result.type !== null) {
|
||||
group.sampleType = result.type
|
||||
group.sampleClassify = result.Classify || ''
|
||||
if (result.Type !== undefined && result.Type !== null) {
|
||||
group.sampleType = result.Type
|
||||
}
|
||||
hasChanges.value = true
|
||||
break
|
||||
}
|
||||
}
|
||||
// 更新回组件
|
||||
// 更新回组件(内部更新时抑制 data-changed 处理)
|
||||
suppressDataChanged.value = true
|
||||
groupListRef.value.setList(groups)
|
||||
// 确保在子组件内部事件触发后恢复标志并保持 hasChanges
|
||||
nextTick(() => {
|
||||
suppressDataChanged.value = false
|
||||
hasChanges.value = true
|
||||
})
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('JSON解析失败:', e)
|
||||
|
||||
Reference in New Issue
Block a user