feat: 添加待确认分类功能,支持获取和确认未分类交易记录;优化相关组件和服务
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 24s
Docker Build & Deploy / Deploy to Production (push) Successful in 10s
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s
Docker Build & Deploy / WeChat Notification (push) Successful in 1s
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 24s
Docker Build & Deploy / Deploy to Production (push) Successful in 10s
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s
Docker Build & Deploy / WeChat Notification (push) Successful in 1s
This commit is contained in:
148
Web/src/views/UnconfirmedClassification.vue
Normal file
148
Web/src/views/UnconfirmedClassification.vue
Normal file
@@ -0,0 +1,148 @@
|
||||
<template>
|
||||
<div class="page-container-flex unconfirmed-classification">
|
||||
<van-nav-bar
|
||||
title="待确认分类"
|
||||
left-text="返回"
|
||||
left-arrow
|
||||
@click-left="onClickLeft"
|
||||
>
|
||||
<template #right>
|
||||
<van-button
|
||||
v-if="transactions.length > 0"
|
||||
type="primary"
|
||||
size="small"
|
||||
:loading="confirming"
|
||||
@click="handleConfirmAll"
|
||||
>
|
||||
全部确认
|
||||
</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"
|
||||
@click="handleTransactionClick"
|
||||
@delete="handleTransactionDeleted"
|
||||
/>
|
||||
</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)
|
||||
|
||||
const onClickLeft = () => {
|
||||
router.back()
|
||||
}
|
||||
|
||||
const handleConfirmAll = async () => {
|
||||
try {
|
||||
await showConfirmDialog({
|
||||
title: '提示',
|
||||
message: `确定要将这 ${transactions.value.length} 条记录的所有建议分类转为正式分类吗?`
|
||||
})
|
||||
|
||||
confirming.value = true
|
||||
const response = await confirmAllUnconfirmed()
|
||||
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) {
|
||||
transactions.value = response.data || []
|
||||
}
|
||||
} 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)
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user