2026-01-10 12:22:37 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="page-container-flex unconfirmed-classification">
|
|
|
|
|
|
<van-nav-bar
|
|
|
|
|
|
title="待确认分类"
|
|
|
|
|
|
left-text="返回"
|
|
|
|
|
|
left-arrow
|
|
|
|
|
|
@click-left="onClickLeft"
|
|
|
|
|
|
>
|
|
|
|
|
|
<template #right>
|
|
|
|
|
|
<van-button
|
2026-01-11 12:02:20 +08:00
|
|
|
|
v-if="selectedIds.size > 0"
|
2026-01-10 12:22:37 +08:00
|
|
|
|
type="primary"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
:loading="confirming"
|
2026-01-11 12:02:20 +08:00
|
|
|
|
@click="handleConfirmSelected"
|
2026-01-10 12:22:37 +08:00
|
|
|
|
>
|
2026-01-11 12:02:20 +08:00
|
|
|
|
确认所选 ({{ selectedIds.size }})
|
2026-01-10 12:22:37 +08:00
|
|
|
|
</van-button>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</van-nav-bar>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="scroll-content">
|
|
|
|
|
|
<div v-if="loading && transactions.length === 0" class="loading-container">
|
|
|
|
|
|
<van-loading vertical>加载中...</van-loading>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<TransactionList
|
|
|
|
|
|
v-else
|
|
|
|
|
|
:transactions="displayTransactions"
|
|
|
|
|
|
:loading="loading"
|
|
|
|
|
|
:finished="true"
|
2026-01-11 12:02:20 +08:00
|
|
|
|
show-checkbox
|
|
|
|
|
|
:selected-ids="selectedIds"
|
2026-01-10 12:22:37 +08:00
|
|
|
|
@click="handleTransactionClick"
|
|
|
|
|
|
@delete="handleTransactionDeleted"
|
2026-01-11 12:02:20 +08:00
|
|
|
|
@update:selected-ids="updateSelectedIds"
|
2026-01-10 12:22:37 +08:00
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 交易详情弹窗 -->
|
|
|
|
|
|
<TransactionDetail
|
|
|
|
|
|
v-model:show="showDetail"
|
|
|
|
|
|
:transaction="currentTransaction"
|
|
|
|
|
|
@save="handleDetailSave"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
|
import { ref, onMounted, computed } from 'vue'
|
|
|
|
|
|
import { useRouter } from 'vue-router'
|
|
|
|
|
|
import { showToast, showConfirmDialog } from 'vant'
|
|
|
|
|
|
import { getUnconfirmedTransactionList, confirmAllUnconfirmed } from '@/api/transactionRecord'
|
|
|
|
|
|
import TransactionList from '@/components/TransactionList.vue'
|
|
|
|
|
|
import TransactionDetail from '@/components/TransactionDetail.vue'
|
|
|
|
|
|
|
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
|
const loading = ref(false)
|
|
|
|
|
|
const confirming = ref(false)
|
|
|
|
|
|
const transactions = ref([])
|
|
|
|
|
|
const showDetail = ref(false)
|
|
|
|
|
|
const currentTransaction = ref(null)
|
2026-01-11 12:02:20 +08:00
|
|
|
|
const selectedIds = ref(new Set())
|
2026-01-10 12:22:37 +08:00
|
|
|
|
|
|
|
|
|
|
const onClickLeft = () => {
|
|
|
|
|
|
router.back()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-11 12:02:20 +08:00
|
|
|
|
const handleConfirmSelected = async () => {
|
2026-01-10 12:22:37 +08:00
|
|
|
|
try {
|
|
|
|
|
|
await showConfirmDialog({
|
|
|
|
|
|
title: '提示',
|
|
|
|
|
|
message: `确定要将这 ${transactions.value.length} 条记录的所有建议分类转为正式分类吗?`
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
confirming.value = true
|
2026-01-11 12:02:20 +08:00
|
|
|
|
const response = await confirmAllUnconfirmed(Array.from(selectedIds.value))
|
2026-01-10 12:22:37 +08:00
|
|
|
|
if (response && response.success) {
|
|
|
|
|
|
showToast(`成功确认 ${response.data} 条记录`)
|
|
|
|
|
|
loadData()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
showToast(response.message || '确认失败')
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
if (err !== 'cancel') {
|
|
|
|
|
|
console.error('批量确认出错:', err)
|
|
|
|
|
|
}
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
confirming.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 转换数据格式以适配 TransactionList 组件
|
|
|
|
|
|
const displayTransactions = computed(() => {
|
|
|
|
|
|
return transactions.value.map(t => ({
|
|
|
|
|
|
...t,
|
|
|
|
|
|
upsetedClassify: t.unconfirmedClassify,
|
|
|
|
|
|
upsetedType: t.unconfirmedType
|
|
|
|
|
|
}))
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const loadData = async () => {
|
|
|
|
|
|
loading.value = true
|
|
|
|
|
|
try {
|
|
|
|
|
|
const response = await getUnconfirmedTransactionList()
|
|
|
|
|
|
if (response && response.success) {
|
2026-01-11 12:02:20 +08:00
|
|
|
|
transactions.value = (response.data || [])
|
|
|
|
|
|
.map(t => ({
|
|
|
|
|
|
...t,
|
|
|
|
|
|
upsetedClassify: t.unconfirmedClassify,
|
|
|
|
|
|
upsetedType: t.unconfirmedType
|
|
|
|
|
|
}))
|
|
|
|
|
|
selectedIds.value = new Set(response.data.map(t => t.id))
|
2026-01-10 12:22:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('获取待确认列表失败:', error)
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
loading.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const handleTransactionClick = (transaction) => {
|
|
|
|
|
|
currentTransaction.value = transaction
|
|
|
|
|
|
showDetail.value = true
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const handleTransactionDeleted = (id) => {
|
|
|
|
|
|
transactions.value = transactions.value.filter(t => t.id !== id)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-11 12:02:20 +08:00
|
|
|
|
const updateSelectedIds = (ids) => {
|
|
|
|
|
|
selectedIds.value = new Set(ids)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-10 12:22:37 +08:00
|
|
|
|
const handleDetailSave = () => {
|
|
|
|
|
|
loadData()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
|
loadData()
|
|
|
|
|
|
})
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.unconfirmed-classification {
|
|
|
|
|
|
height: 100vh;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.scroll-content {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
overflow-y: auto;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.loading-container {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
height: 200px;
|
|
|
|
|
|
}
|
2026-01-13 19:11:37 +08:00
|
|
|
|
|
|
|
|
|
|
/* 设置页面容器背景色 */
|
|
|
|
|
|
:deep(.van-nav-bar) {
|
|
|
|
|
|
background: transparent !important;
|
|
|
|
|
|
}
|
2026-01-10 12:22:37 +08:00
|
|
|
|
</style>
|