大量的代码格式化
Some checks failed
Docker Build & Deploy / Build Docker Image (push) Failing after 1m10s
Docker Build & Deploy / Deploy to Production (push) Has been skipped
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s
Docker Build & Deploy / WeChat Notification (push) Successful in 1s
Some checks failed
Docker Build & Deploy / Build Docker Image (push) Failing after 1m10s
Docker Build & Deploy / Deploy to Production (push) Has been skipped
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s
Docker Build & Deploy / WeChat Notification (push) Successful in 1s
This commit is contained in:
@@ -2,9 +2,16 @@
|
||||
<template>
|
||||
<div class="page-container-flex">
|
||||
<!-- 下拉刷新区域 -->
|
||||
<van-pull-refresh v-model="refreshing" @refresh="onRefresh">
|
||||
<van-pull-refresh
|
||||
v-model="refreshing"
|
||||
@refresh="onRefresh"
|
||||
>
|
||||
<!-- 加载提示 -->
|
||||
<van-loading v-if="loading && !(emailList && emailList.length)" vertical style="padding: 50px 0">
|
||||
<van-loading
|
||||
v-if="loading && !(emailList && emailList.length)"
|
||||
vertical
|
||||
style="padding: 50px 0"
|
||||
>
|
||||
加载中...
|
||||
</van-loading>
|
||||
<!-- 邮件列表 -->
|
||||
@@ -14,7 +21,11 @@
|
||||
finished-text="没有更多了"
|
||||
@load="onLoad"
|
||||
>
|
||||
<van-cell-group v-if="emailList && emailList.length" inset style="margin-top: 10px">
|
||||
<van-cell-group
|
||||
v-if="emailList && emailList.length"
|
||||
inset
|
||||
style="margin-top: 10px"
|
||||
>
|
||||
<van-swipe-cell
|
||||
v-for="email in emailList"
|
||||
:key="email.id"
|
||||
@@ -27,18 +38,22 @@
|
||||
>
|
||||
<template #value>
|
||||
<div class="email-info">
|
||||
<div class="email-date">{{ formatDate(email.receivedDate) }}</div>
|
||||
<div v-if="email.transactionCount > 0" class="bill-count">
|
||||
<span style="font-size: 12px;">已解析{{ email.transactionCount }}条账单</span>
|
||||
<div class="email-date">
|
||||
{{ formatDate(email.receivedDate) }}
|
||||
</div>
|
||||
<div
|
||||
v-if="email.transactionCount > 0"
|
||||
class="bill-count"
|
||||
>
|
||||
<span style="font-size: 12px">已解析{{ email.transactionCount }}条账单</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
</van-cell>
|
||||
<template #right>
|
||||
<van-button
|
||||
<van-button
|
||||
square
|
||||
type="danger"
|
||||
type="danger"
|
||||
text="删除"
|
||||
class="delete-button"
|
||||
@click="handleDelete(email)"
|
||||
@@ -47,26 +62,26 @@
|
||||
</van-swipe-cell>
|
||||
</van-cell-group>
|
||||
|
||||
<van-empty
|
||||
v-if="!loading && !(emailList && emailList.length)"
|
||||
description="暂无邮件记录"
|
||||
<van-empty
|
||||
v-if="!loading && !(emailList && emailList.length)"
|
||||
description="暂无邮件记录"
|
||||
/>
|
||||
</van-list>
|
||||
|
||||
<!-- 底部安全距离 -->
|
||||
<div style="height: calc(50px + env(safe-area-inset-bottom, 0px))"></div>
|
||||
<div style="height: calc(50px + env(safe-area-inset-bottom, 0px))" />
|
||||
</van-pull-refresh>
|
||||
|
||||
<!-- 详情弹出层 -->
|
||||
<PopupContainer
|
||||
v-model="detailVisible"
|
||||
:title="currentEmail ? (currentEmail.Subject || currentEmail.subject || '(无主题)') : ''"
|
||||
:title="currentEmail ? currentEmail.Subject || currentEmail.subject || '(无主题)' : ''"
|
||||
height="75%"
|
||||
>
|
||||
<template #header-actions>
|
||||
<van-button
|
||||
size="small"
|
||||
type="primary"
|
||||
<van-button
|
||||
size="small"
|
||||
type="primary"
|
||||
:loading="refreshingAnalysis"
|
||||
@click="handleRefreshAnalysis"
|
||||
>
|
||||
@@ -75,34 +90,51 @@
|
||||
</template>
|
||||
|
||||
<div v-if="currentEmail">
|
||||
<van-cell-group inset style="margin-top: 12px;">
|
||||
<van-cell title="发件人" :value="currentEmail.From || currentEmail.from || '未知'" />
|
||||
<van-cell title="接收时间" :value="formatDate(currentEmail.ReceivedDate || currentEmail.receivedDate)" />
|
||||
<van-cell title="记录时间" :value="formatDate(currentEmail.CreateTime || currentEmail.createTime)" />
|
||||
<van-cell
|
||||
v-if="(currentEmail.TransactionCount || currentEmail.transactionCount || 0) > 0"
|
||||
title="已解析账单数"
|
||||
<van-cell-group
|
||||
inset
|
||||
style="margin-top: 12px"
|
||||
>
|
||||
<van-cell
|
||||
title="发件人"
|
||||
:value="currentEmail.From || currentEmail.from || '未知'"
|
||||
/>
|
||||
<van-cell
|
||||
title="接收时间"
|
||||
:value="formatDate(currentEmail.ReceivedDate || currentEmail.receivedDate)"
|
||||
/>
|
||||
<van-cell
|
||||
title="记录时间"
|
||||
:value="formatDate(currentEmail.CreateTime || currentEmail.createTime)"
|
||||
/>
|
||||
<van-cell
|
||||
v-if="(currentEmail.TransactionCount || currentEmail.transactionCount || 0) > 0"
|
||||
title="已解析账单数"
|
||||
:value="`${currentEmail.TransactionCount || currentEmail.transactionCount || 0}条`"
|
||||
is-link
|
||||
@click="viewTransactions"
|
||||
/>
|
||||
</van-cell-group>
|
||||
<div class="email-content">
|
||||
<h4 style="margin-left: 10px;">邮件内容</h4>
|
||||
<div
|
||||
v-if="currentEmail.htmlBody"
|
||||
class="content-body html-content"
|
||||
<h4 style="margin-left: 10px">
|
||||
邮件内容
|
||||
</h4>
|
||||
<div
|
||||
v-if="currentEmail.htmlBody"
|
||||
class="content-body html-content"
|
||||
v-html="currentEmail.htmlBody"
|
||||
></div>
|
||||
<div
|
||||
v-else-if="currentEmail.body"
|
||||
/>
|
||||
<div
|
||||
v-else-if="currentEmail.body"
|
||||
class="content-body"
|
||||
>
|
||||
{{ currentEmail.body }}
|
||||
</div>
|
||||
<div v-else class="content-body empty-content">
|
||||
<div
|
||||
v-else
|
||||
class="content-body empty-content"
|
||||
>
|
||||
暂无邮件内容
|
||||
<div style="font-size: 12px; margin-top: 8px; color: var(--van-gray-6);">
|
||||
<div style="font-size: 12px; margin-top: 8px; color: var(--van-gray-6)">
|
||||
Debug: {{ Object.keys(currentEmail).join(', ') }}
|
||||
</div>
|
||||
</div>
|
||||
@@ -139,7 +171,14 @@
|
||||
<script setup>
|
||||
import { ref, onMounted, onBeforeUnmount } from 'vue'
|
||||
import { showToast, showConfirmDialog } from 'vant'
|
||||
import { getEmailList, getEmailDetail, deleteEmail, refreshTransactionRecords, syncEmails, getEmailTransactions } from '@/api/emailRecord'
|
||||
import {
|
||||
getEmailList,
|
||||
getEmailDetail,
|
||||
deleteEmail,
|
||||
refreshTransactionRecords,
|
||||
syncEmails,
|
||||
getEmailTransactions
|
||||
} from '@/api/emailRecord'
|
||||
import { getTransactionDetail } from '@/api/transactionRecord'
|
||||
import TransactionList from '@/components/TransactionList.vue'
|
||||
import TransactionDetail from '@/components/TransactionDetail.vue'
|
||||
@@ -163,8 +202,10 @@ const currentTransaction = ref(null)
|
||||
|
||||
// 加载数据
|
||||
const loadData = async (isRefresh = false) => {
|
||||
if (loading.value) return // 防止重复加载
|
||||
|
||||
if (loading.value) {
|
||||
return
|
||||
} // 防止重复加载
|
||||
|
||||
if (isRefresh) {
|
||||
pageIndex.value = 1
|
||||
emailList.value = []
|
||||
@@ -177,19 +218,19 @@ const loadData = async (isRefresh = false) => {
|
||||
pageIndex: pageIndex.value,
|
||||
pageSize: pageSize
|
||||
}
|
||||
|
||||
|
||||
const response = await getEmailList(params)
|
||||
|
||||
|
||||
if (response.success) {
|
||||
const newList = response.data || []
|
||||
total.value = response.total || 0
|
||||
|
||||
|
||||
if (isRefresh) {
|
||||
emailList.value = newList
|
||||
} else {
|
||||
emailList.value = [...(emailList.value || []), ...newList]
|
||||
}
|
||||
|
||||
|
||||
// 判断是否还有更多数据(返回数据少于pageSize条或为空,说明没有更多了)
|
||||
if (newList.length === 0 || newList.length < pageSize) {
|
||||
finished.value = true
|
||||
@@ -246,7 +287,7 @@ const handleDelete = async (email) => {
|
||||
try {
|
||||
await showConfirmDialog({
|
||||
title: '提示',
|
||||
message: '确定要删除这封邮件吗?',
|
||||
message: '确定要删除这封邮件吗?'
|
||||
})
|
||||
|
||||
const response = await deleteEmail(email.id)
|
||||
@@ -266,17 +307,19 @@ const handleDelete = async (email) => {
|
||||
|
||||
// 重新分析
|
||||
const handleRefreshAnalysis = async () => {
|
||||
if (!currentEmail.value) return
|
||||
|
||||
if (!currentEmail.value) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await showConfirmDialog({
|
||||
title: '提示',
|
||||
message: '确定要重新分析该邮件并刷新交易记录吗?',
|
||||
message: '确定要重新分析该邮件并刷新交易记录吗?'
|
||||
})
|
||||
|
||||
refreshingAnalysis.value = true
|
||||
const response = await refreshTransactionRecords(currentEmail.value.id)
|
||||
|
||||
|
||||
if (response.success) {
|
||||
showToast('重新分析成功')
|
||||
detailVisible.value = false
|
||||
@@ -298,7 +341,7 @@ const handleSync = async () => {
|
||||
try {
|
||||
syncing.value = true
|
||||
const response = await syncEmails()
|
||||
|
||||
|
||||
if (response.success) {
|
||||
showToast(response.message || '同步成功')
|
||||
// 同步成功后刷新列表
|
||||
@@ -316,12 +359,14 @@ const handleSync = async () => {
|
||||
|
||||
// 查看关联的账单列表
|
||||
const viewTransactions = async () => {
|
||||
if (!currentEmail.value) return
|
||||
|
||||
if (!currentEmail.value) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const emailId = currentEmail.value.id
|
||||
const response = await getEmailTransactions(emailId)
|
||||
|
||||
|
||||
if (response.success) {
|
||||
transactionList.value = response.data || []
|
||||
transactionListVisible.value = true
|
||||
@@ -340,18 +385,22 @@ const onGlobalTransactionDeleted = (e) => {
|
||||
// 如果交易列表弹窗打开,尝试重新加载邮箱的交易列表
|
||||
if (transactionListVisible.value && currentEmail.value) {
|
||||
const emailId = currentEmail.value.id || currentEmail.value.Id
|
||||
getEmailTransactions(emailId).then(response => {
|
||||
if (response.success) {
|
||||
transactionList.value = response.data || []
|
||||
}
|
||||
}).catch(() => {})
|
||||
getEmailTransactions(emailId)
|
||||
.then((response) => {
|
||||
if (response.success) {
|
||||
transactionList.value = response.data || []
|
||||
}
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener && window.addEventListener('transaction-deleted', onGlobalTransactionDeleted)
|
||||
window.addEventListener &&
|
||||
window.addEventListener('transaction-deleted', onGlobalTransactionDeleted)
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener && window.removeEventListener('transaction-deleted', onGlobalTransactionDeleted)
|
||||
window.removeEventListener &&
|
||||
window.removeEventListener('transaction-deleted', onGlobalTransactionDeleted)
|
||||
})
|
||||
|
||||
// 监听新增/修改/批量更新事件,刷新弹窗内交易或邮件列表
|
||||
@@ -359,21 +408,25 @@ const onGlobalTransactionsChanged = (e) => {
|
||||
console.log('收到全局交易变更事件:', e)
|
||||
if (transactionListVisible.value && currentEmail.value) {
|
||||
const emailId = currentEmail.value.id || currentEmail.value.Id
|
||||
getEmailTransactions(emailId).then(response => {
|
||||
if (response.success) {
|
||||
transactionList.value = response.data || []
|
||||
}
|
||||
}).catch(() => {})
|
||||
getEmailTransactions(emailId)
|
||||
.then((response) => {
|
||||
if (response.success) {
|
||||
transactionList.value = response.data || []
|
||||
}
|
||||
})
|
||||
.catch(() => {})
|
||||
} else {
|
||||
// 也刷新邮件列表以保持统计一致
|
||||
loadData(true)
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener && window.addEventListener('transactions-changed', onGlobalTransactionsChanged)
|
||||
window.addEventListener &&
|
||||
window.addEventListener('transactions-changed', onGlobalTransactionsChanged)
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener && window.removeEventListener('transactions-changed', onGlobalTransactionsChanged)
|
||||
window.removeEventListener &&
|
||||
window.removeEventListener('transactions-changed', onGlobalTransactionsChanged)
|
||||
})
|
||||
|
||||
// 处理点击账单
|
||||
@@ -394,7 +447,7 @@ const handleTransactionClick = async (transaction) => {
|
||||
|
||||
const handleTransactionDelete = (transactionId) => {
|
||||
// 从当前的交易列表中移除该交易
|
||||
transactionList.value = transactionList.value.filter(t => t.id !== transactionId)
|
||||
transactionList.value = transactionList.value.filter((t) => t.id !== transactionId)
|
||||
|
||||
// 刷新邮件列表
|
||||
loadData(true)
|
||||
@@ -402,16 +455,15 @@ const handleTransactionDelete = (transactionId) => {
|
||||
// 刷新当前邮件详情
|
||||
if (currentEmail.value) {
|
||||
const emailId = currentEmail.value.id
|
||||
getEmailDetail(emailId).then(response => {
|
||||
getEmailDetail(emailId).then((response) => {
|
||||
if (response.success) {
|
||||
currentEmail.value = response.data
|
||||
}
|
||||
})
|
||||
}
|
||||
try {
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('transaction-deleted', { detail: transactionId }))
|
||||
} catch(e) {
|
||||
try {
|
||||
window.dispatchEvent(new CustomEvent('transaction-deleted', { detail: transactionId }))
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
}
|
||||
@@ -426,27 +478,28 @@ const handleTransactionSave = async () => {
|
||||
transactionList.value = response.data || []
|
||||
}
|
||||
}
|
||||
try {
|
||||
try {
|
||||
window.dispatchEvent(
|
||||
new CustomEvent(
|
||||
'transactions-changed',
|
||||
{
|
||||
detail: {
|
||||
emailId: currentEmail.value?.id
|
||||
}
|
||||
}))
|
||||
} catch(e) {
|
||||
new CustomEvent('transactions-changed', {
|
||||
detail: {
|
||||
emailId: currentEmail.value?.id
|
||||
}
|
||||
})
|
||||
)
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
}
|
||||
|
||||
// 格式化日期
|
||||
const formatDate = (dateString) => {
|
||||
if (!dateString) return ''
|
||||
if (!dateString) {
|
||||
return ''
|
||||
}
|
||||
const date = new Date(dateString)
|
||||
return date.toLocaleString('zh-CN', {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
return date.toLocaleString('zh-CN', {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
@@ -454,8 +507,6 @@ const formatDate = (dateString) => {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
loadData(true)
|
||||
})
|
||||
@@ -467,7 +518,6 @@ defineExpose({
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
:deep(.van-pull-refresh) {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
@@ -528,4 +578,4 @@ defineExpose({
|
||||
:deep(.van-nav-bar) {
|
||||
background: transparent !important;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user