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
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:
@@ -211,7 +211,7 @@ public class BudgetService(
|
||||
|
||||
result.Limit = totalLimit;
|
||||
result.Current = totalCurrent;
|
||||
result.Rate = totalLimit > 0 ? (totalCurrent / totalLimit) * 100 : 0;
|
||||
result.Rate = totalLimit > 0 ? totalCurrent / totalLimit * 100 : 0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -119,9 +119,14 @@ public class SmartHandleService(
|
||||
|
||||
输出格式要求(强制):
|
||||
- 请使用 NDJSON(每行一个独立的 JSON 对象,末尾以换行符分隔),不要输出数组。
|
||||
- 每行的JSON格式严格为:{"reason": "交易摘要", "type": 0, "classify": "分类名称"}
|
||||
- 每行的JSON格式严格为:
|
||||
{
|
||||
"reason": "交易摘要",
|
||||
"type": Number, // 交易类型,0=支出,1=收入,2=不计入收支
|
||||
"classify": "分类名称"
|
||||
}
|
||||
- 不要输出任何解释性文字、编号、标点或多余的文本
|
||||
- 如果无法判断分类,请将 "classify" 设为 "其他",并确保仍然输出 JSON 行
|
||||
- 如果无法判断分类,请不要输出改行的JSON对象
|
||||
|
||||
只输出按行的JSON对象(NDJSON),不要有其他文字说明。
|
||||
""";
|
||||
@@ -151,7 +156,12 @@ public class SmartHandleService(
|
||||
{
|
||||
if (sendedIds.Add(id))
|
||||
{
|
||||
var resultJson = JsonSerializer.Serialize(new { id, result.Classify, result.Type });
|
||||
var resultJson = JsonSerializer.Serialize(new
|
||||
{
|
||||
id,
|
||||
result.Classify,
|
||||
result.Type
|
||||
});
|
||||
chunkAction(("data", resultJson));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import axios from 'axios'
|
||||
import { showToast } from 'vant'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
|
||||
/**
|
||||
* 账单导入相关 API
|
||||
@@ -21,7 +22,8 @@ export const uploadBillFile = (file, type) => {
|
||||
method: 'post',
|
||||
data: formData,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
'Content-Type': 'multipart/form-data',
|
||||
Authorization: `Bearer ${useAuthStore().token || ''}`
|
||||
},
|
||||
timeout: 60000 // 文件上传增加超时时间
|
||||
}).then(response => {
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
<!-- 展开状态 -->
|
||||
<Transition v-else :name="transitionName">
|
||||
<div :key="budget.period" class="budget-inner-card">
|
||||
<div class="card-header">
|
||||
<div class="card-header" style="margin-bottom: 0;">
|
||||
<div class="budget-info">
|
||||
<slot name="tag">
|
||||
<van-tag
|
||||
@@ -55,7 +55,7 @@
|
||||
{{ budget.type === BudgetPeriodType.Year ? '年度' : '月度' }}
|
||||
</van-tag>
|
||||
</slot>
|
||||
<h3 class="card-title">{{ budget.name }}</h3>
|
||||
<h3 class="card-title" style="max-width: 120px;">{{ budget.name }}</h3>
|
||||
</div>
|
||||
<div class="header-actions">
|
||||
<slot name="actions">
|
||||
@@ -164,7 +164,7 @@
|
||||
<PopupContainer
|
||||
v-model="showBillListModal"
|
||||
title="关联账单列表"
|
||||
height="80%"
|
||||
height="75%"
|
||||
>
|
||||
<TransactionList
|
||||
:transactions="billList"
|
||||
@@ -452,7 +452,6 @@ const timePercentage = computed(() => {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
flex-shrink: 0;
|
||||
max-width: 120px;
|
||||
}
|
||||
|
||||
.card-subtitle {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<PopupContainer
|
||||
v-model="showAddBill"
|
||||
title="记一笔"
|
||||
height="85%"
|
||||
height="75%"
|
||||
>
|
||||
<van-tabs v-model:active="activeTab" shrink>
|
||||
<van-tab title="一句话录账" name="one">
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
v-model="showTransactionList"
|
||||
:title="selectedGroup?.reason || '交易记录'"
|
||||
:subtitle="groupTransactionsTotal ? `共 ${groupTransactionsTotal} 笔交易` : ''"
|
||||
height="85%"
|
||||
height="75%"
|
||||
>
|
||||
<template #header-actions>
|
||||
<van-button
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<PopupContainer
|
||||
v-model="visible"
|
||||
title="交易详情"
|
||||
height="85%"
|
||||
height="75%"
|
||||
:closeable="false"
|
||||
>
|
||||
<template #header-actions>
|
||||
@@ -111,7 +111,7 @@
|
||||
<PopupContainer
|
||||
v-model="showOffsetPopup"
|
||||
title="选择抵账交易"
|
||||
height="70%"
|
||||
height="75%"
|
||||
>
|
||||
<van-list>
|
||||
<van-cell
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* 表格样式优化 - 撑满宽度并支持独立横向和纵向滚动 */
|
||||
/* 表格样式优化 - 确保表格独立滚动且列对齐 */
|
||||
.rich-html-content table {
|
||||
display: block;
|
||||
width: 100%;
|
||||
@@ -62,55 +62,52 @@
|
||||
background: var(--van-background-2);
|
||||
border-radius: 4px;
|
||||
border: none;
|
||||
overflow-x: auto;
|
||||
overflow-y: auto;
|
||||
max-height: 50vh;
|
||||
overflow-x: auto; /* 仅表格内部横向滚动 */
|
||||
-webkit-overflow-scrolling: touch;
|
||||
overflow-y: auto;
|
||||
max-height: 35vh;
|
||||
}
|
||||
|
||||
.rich-html-content thead,
|
||||
.rich-html-content tbody {
|
||||
display: table;
|
||||
width: 130%;
|
||||
min-width: 400px; /* 确保窄屏下有足够宽度触发滚动 */
|
||||
table-layout: fixed; /* 核心:强制列宽分配逻辑一致 */
|
||||
}
|
||||
|
||||
.rich-html-content tr {
|
||||
display: table-row;
|
||||
}
|
||||
|
||||
.rich-html-content th,
|
||||
.rich-html-content td {
|
||||
padding: 6px 8px;
|
||||
display: table-cell;
|
||||
padding: 8px;
|
||||
text-align: left;
|
||||
border: none;
|
||||
border-bottom: 1px solid var(--van-border-color-light);
|
||||
min-width: 70px; /* 防止内容过于拥挤 */
|
||||
font-size: 12px;
|
||||
white-space: nowrap; /* 防止文字换行 */
|
||||
flex: 1; /* 让单元格按比例撑满宽度 */
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
/* 表格行确保100%撑满 */
|
||||
.rich-html-content tbody,
|
||||
.rich-html-content thead {
|
||||
display: table;
|
||||
width: 100%;
|
||||
table-layout: auto;
|
||||
}
|
||||
|
||||
/* 针对第一列预算项增加最小宽度 - 确保在滑动时有背景遮挡 */
|
||||
/* 针对第一列“名称”分配更多空间,其余平分 */
|
||||
.rich-html-content th:first-child,
|
||||
.rich-html-content td:first-child {
|
||||
min-width: 80px;
|
||||
position: sticky;
|
||||
left: 0;
|
||||
background: var(--van-background-2);
|
||||
z-index: 1;
|
||||
width: 30%;
|
||||
}
|
||||
|
||||
.rich-html-content th:first-child {
|
||||
min-width: 80px;
|
||||
position: sticky;
|
||||
left: 0;
|
||||
background: var(--van-gray-1);
|
||||
z-index: 1;
|
||||
.rich-html-content th:not(:first-child),
|
||||
.rich-html-content td:not(:first-child) {
|
||||
width: 20%;
|
||||
}
|
||||
|
||||
.rich-html-content th {
|
||||
background: var(--van-gray-1);
|
||||
color: var(--van-text-color);
|
||||
font-weight: 600;
|
||||
font-size: 12px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* 业务特定样式:收入、支出、高亮 */
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
v-model="listVisible"
|
||||
:title="selectedDateText"
|
||||
:subtitle="getBalance(dateTransactions)"
|
||||
height="85%"
|
||||
height="75%"
|
||||
>
|
||||
<template #header-actions>
|
||||
<SmartClassifyButton
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
<PopupContainer
|
||||
v-model="showRecordsList"
|
||||
title="交易记录列表"
|
||||
height="80%"
|
||||
height="75%"
|
||||
>
|
||||
<div style="background: var(--van-background, #f7f8fa);">
|
||||
<!-- 批量操作按钮 -->
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
<PopupContainer
|
||||
v-model="detailVisible"
|
||||
:title="currentEmail ? (currentEmail.Subject || currentEmail.subject || '(无主题)') : ''"
|
||||
height="80%"
|
||||
height="75%"
|
||||
>
|
||||
<template #header-actions>
|
||||
<van-button
|
||||
@@ -114,7 +114,7 @@
|
||||
<PopupContainer
|
||||
v-model="transactionListVisible"
|
||||
title="关联账单列表"
|
||||
height="70%"
|
||||
height="75%"
|
||||
>
|
||||
<TransactionList
|
||||
:transactions="transactionList"
|
||||
|
||||
@@ -41,8 +41,7 @@
|
||||
v-model="detailVisible"
|
||||
:title="currentMessage.title"
|
||||
:subtitle="currentMessage.createTime"
|
||||
height="80%"
|
||||
:closeable="true"
|
||||
height="75%"
|
||||
>
|
||||
<div
|
||||
v-if="currentMessage.messageType === 2"
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
<PopupContainer
|
||||
v-model="dialogVisible"
|
||||
:title="isEdit ? '编辑周期账单' : '新增周期账单'"
|
||||
height="85%"
|
||||
height="75%"
|
||||
>
|
||||
<van-form>
|
||||
<van-cell-group inset title="周期设置">
|
||||
|
||||
@@ -281,7 +281,7 @@
|
||||
v-model="billListVisible"
|
||||
:title="selectedCategoryTitle"
|
||||
:subtitle="categoryBillsTotal ? `共 ${categoryBillsTotal} 笔交易` : ''"
|
||||
height="85%"
|
||||
height="75%"
|
||||
>
|
||||
<template #header-actions>
|
||||
<SmartClassifyButton
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
namespace WebApi.Controllers;
|
||||
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Nodes;
|
||||
using Repository;
|
||||
|
||||
[ApiController]
|
||||
@@ -452,12 +454,57 @@ public class TransactionRecordController(
|
||||
await smartHandleService.SmartClassifyAsync(request.TransactionIds.ToArray(), async (chunk) =>
|
||||
{
|
||||
var (eventType, content) = chunk;
|
||||
await TrySetUnconfirmedAsync(eventType, content);
|
||||
await WriteEventAsync(eventType, content);
|
||||
});
|
||||
|
||||
await Response.Body.FlushAsync();
|
||||
}
|
||||
|
||||
private async Task TrySetUnconfirmedAsync(string eventType, string content)
|
||||
{
|
||||
if (eventType != "data")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var jsonObject = JsonSerializer.Deserialize<JsonObject>(content);
|
||||
var id = jsonObject?["id"]?.GetValue<long>() ?? 0;
|
||||
var classify = jsonObject?["Classify"]?.GetValue<string>() ?? string.Empty;
|
||||
var typeValue = jsonObject?["Type"]?.GetValue<int>() ?? -1;
|
||||
|
||||
if(id == 0 || typeValue == -1 || string.IsNullOrEmpty(classify))
|
||||
{
|
||||
logger.LogWarning("解析智能分类结果时,发现无效数据,内容: {Content}", content);
|
||||
return;
|
||||
}
|
||||
|
||||
var record = await transactionRepository.GetByIdAsync(id);
|
||||
if (record == null)
|
||||
{
|
||||
logger.LogWarning("解析智能分类结果时,未找到对应的交易记录,ID: {Id}", id);
|
||||
return;
|
||||
}
|
||||
|
||||
record.UnconfirmedClassify = classify;
|
||||
record.UnconfirmedType = (TransactionType)typeValue;
|
||||
|
||||
var success = await transactionRepository.UpdateAsync(record);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
logger.LogWarning("解析智能分类结果时,更新交易记录失败,ID: {Id}", id);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "解析智能分类结果失败,内容: {Content}", content);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量更新账单分类
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user