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:
@@ -59,15 +59,14 @@
|
||||
<van-button
|
||||
v-if="budget.description"
|
||||
:icon="showDescription ? 'info' : 'info-o'"
|
||||
size="mini"
|
||||
size="small"
|
||||
:type="showDescription ? 'primary' : 'default'"
|
||||
plain
|
||||
round
|
||||
@click.stop="showDescription = !showDescription"
|
||||
/>
|
||||
<van-button
|
||||
icon="orders-o"
|
||||
size="mini"
|
||||
size="small"
|
||||
plain
|
||||
title="查询关联账单"
|
||||
@click.stop="handleQueryBills"
|
||||
@@ -75,13 +74,13 @@
|
||||
<template v-if="budget.category !== 2">
|
||||
<van-button
|
||||
icon="edit"
|
||||
size="mini"
|
||||
size="small"
|
||||
plain
|
||||
@click.stop="$emit('click', budget)"
|
||||
/>
|
||||
<van-button
|
||||
:icon="budget.isStopped ? 'play' : 'pause'"
|
||||
size="mini"
|
||||
size="small"
|
||||
plain
|
||||
@click.stop="$emit('toggle-stop', budget)"
|
||||
/>
|
||||
|
||||
@@ -333,6 +333,11 @@ const handleSmartClassify = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const removeClassifiedTransaction = (transactionId) => {
|
||||
// 从已分类结果中移除指定ID的项
|
||||
classifiedResults.value = classifiedResults.value.filter(item => item.id !== transactionId)
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置组件状态
|
||||
*/
|
||||
@@ -344,7 +349,8 @@ const reset = () => {
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
reset
|
||||
reset,
|
||||
removeClassifiedTransaction
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
@@ -11,11 +11,21 @@
|
||||
|
||||
<van-form style="margin-top: 12px;">
|
||||
<van-cell-group inset>
|
||||
<van-cell title="交易时间" :value="formatDate(transaction.occurredAt)" />
|
||||
|
||||
<van-cell title="记录时间" :value="formatDate(transaction.createTime)" />
|
||||
</van-cell-group>
|
||||
|
||||
<van-cell-group inset title="交易明细">
|
||||
<van-field
|
||||
v-model="occurredAtLabel"
|
||||
name="occurredAt"
|
||||
label="交易时间"
|
||||
readonly
|
||||
is-link
|
||||
placeholder="请选择交易时间"
|
||||
:rules="[{ required: true, message: '请选择交易时间' }]"
|
||||
@click="showDatePicker = true"
|
||||
/>
|
||||
<van-field
|
||||
v-model="editForm.reason"
|
||||
name="reason"
|
||||
@@ -56,12 +66,27 @@
|
||||
|
||||
<van-field name="classify" label="交易分类">
|
||||
<template #input>
|
||||
<span v-if="!editForm.classify" style="color: #c8c9cc;">请选择交易分类</span>
|
||||
<span v-else>{{ editForm.classify }}</span>
|
||||
<div style="flex: 1;">
|
||||
<div
|
||||
v-if="transaction && transaction.unconfirmedClassify && transaction.unconfirmedClassify !== editForm.classify"
|
||||
class="suggestion-tip"
|
||||
@click="applySuggestion"
|
||||
>
|
||||
<van-icon name="bulb-o" class="suggestion-icon" />
|
||||
<span class="suggestion-text">
|
||||
建议: {{ transaction.unconfirmedClassify }}
|
||||
<span v-if="transaction.unconfirmedType !== null && transaction.unconfirmedType !== undefined && transaction.unconfirmedType !== editForm.type">
|
||||
({{ getTypeName(transaction.unconfirmedType) }})
|
||||
</span>
|
||||
</span>
|
||||
<div class="suggestion-apply">应用</div>
|
||||
</div>
|
||||
<span v-else-if="!editForm.classify" style="color: #c8c9cc;">请选择交易分类</span>
|
||||
<span v-else>{{ editForm.classify }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</van-field>
|
||||
|
||||
<!-- 分类选择组件 -->
|
||||
<ClassifySelector
|
||||
v-model="editForm.classify"
|
||||
:type="editForm.type"
|
||||
@@ -102,11 +127,32 @@
|
||||
<van-empty v-if="offsetCandidates.length === 0" description="暂无匹配的抵账交易" />
|
||||
</van-list>
|
||||
</PopupContainer>
|
||||
|
||||
<!-- 日期选择弹窗 -->
|
||||
<van-popup v-model:show="showDatePicker" position="bottom" round teleport="body">
|
||||
<van-date-picker
|
||||
v-model="currentDate"
|
||||
title="选择日期"
|
||||
@confirm="onConfirmDate"
|
||||
@cancel="showDatePicker = false"
|
||||
/>
|
||||
</van-popup>
|
||||
|
||||
<!-- 时间选择弹窗 -->
|
||||
<van-popup v-model:show="showTimePicker" position="bottom" round teleport="body">
|
||||
<van-time-picker
|
||||
v-model="currentTime"
|
||||
title="选择时间"
|
||||
@confirm="onConfirmTime"
|
||||
@cancel="showTimePicker = false"
|
||||
/>
|
||||
</van-popup>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive, watch, defineProps, defineEmits } from 'vue'
|
||||
import { ref, reactive, watch, defineProps, defineEmits, computed } from 'vue'
|
||||
import { showToast, showConfirmDialog } from 'vant'
|
||||
import dayjs from 'dayjs'
|
||||
import PopupContainer from '@/components/PopupContainer.vue'
|
||||
import ClassifySelector from '@/components/ClassifySelector.vue'
|
||||
import { updateTransaction, getCandidatesForOffset, offsetTransactions } from '@/api/transactionRecord'
|
||||
@@ -127,6 +173,12 @@ const emit = defineEmits(['update:show', 'save'])
|
||||
const visible = ref(false)
|
||||
const submitting = ref(false)
|
||||
|
||||
// 日期选择相关
|
||||
const showDatePicker = ref(false)
|
||||
const showTimePicker = ref(false)
|
||||
const currentDate = ref([])
|
||||
const currentTime = ref([])
|
||||
|
||||
// 编辑表单
|
||||
const editForm = reactive({
|
||||
id: 0,
|
||||
@@ -134,7 +186,13 @@ const editForm = reactive({
|
||||
amount: '',
|
||||
balance: '',
|
||||
type: 0,
|
||||
classify: ''
|
||||
classify: '',
|
||||
occurredAt: ''
|
||||
})
|
||||
|
||||
// 显示用的日期格式化
|
||||
const occurredAtLabel = computed(() => {
|
||||
return formatDate(editForm.occurredAt)
|
||||
})
|
||||
|
||||
// 监听props变化
|
||||
@@ -151,6 +209,14 @@ watch(() => props.transaction, (newVal) => {
|
||||
editForm.balance = String(newVal.balance)
|
||||
editForm.type = newVal.type
|
||||
editForm.classify = newVal.classify || ''
|
||||
|
||||
// 初始化日期时间
|
||||
if (newVal.occurredAt) {
|
||||
editForm.occurredAt = newVal.occurredAt
|
||||
const dt = dayjs(newVal.occurredAt)
|
||||
currentDate.value = dt.format('YYYY-MM-DD').split('-')
|
||||
currentTime.value = dt.format('HH:mm').split(':')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -158,12 +224,48 @@ watch(visible, (newVal) => {
|
||||
emit('update:show', newVal)
|
||||
})
|
||||
|
||||
// 处理日期确认
|
||||
const onConfirmDate = ({ selectedValues }) => {
|
||||
const dateStr = selectedValues.join('-')
|
||||
const timeStr = currentTime.value.join(':')
|
||||
editForm.occurredAt = dayjs(`${dateStr} ${timeStr}`).toISOString()
|
||||
showDatePicker.value = false
|
||||
// 接着选时间
|
||||
showTimePicker.value = true
|
||||
}
|
||||
|
||||
const onConfirmTime = ({ selectedValues }) => {
|
||||
currentTime.value = selectedValues
|
||||
const dateStr = currentDate.value.join('-')
|
||||
const timeStr = selectedValues.join(':')
|
||||
editForm.occurredAt = dayjs(`${dateStr} ${timeStr}`).toISOString()
|
||||
showTimePicker.value = false
|
||||
}
|
||||
|
||||
// 监听交易类型变化,重新加载分类
|
||||
watch(() => editForm.type, (newVal) => {
|
||||
// 清空已选的分类
|
||||
editForm.classify = ''
|
||||
})
|
||||
|
||||
const applySuggestion = () => {
|
||||
if (props.transaction.unconfirmedClassify) {
|
||||
editForm.classify = props.transaction.unconfirmedClassify
|
||||
if (props.transaction.unconfirmedType !== null && props.transaction.unconfirmedType !== undefined) {
|
||||
editForm.type = props.transaction.unconfirmedType
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const getTypeName = (type) => {
|
||||
const typeMap = {
|
||||
0: '支出',
|
||||
1: '收入',
|
||||
2: '不计'
|
||||
}
|
||||
return typeMap[type] || '未知'
|
||||
}
|
||||
|
||||
// 提交编辑
|
||||
const onSubmit = async () => {
|
||||
try {
|
||||
@@ -175,7 +277,8 @@ const onSubmit = async () => {
|
||||
amount: parseFloat(editForm.amount),
|
||||
balance: parseFloat(editForm.balance),
|
||||
type: editForm.type,
|
||||
classify: editForm.classify
|
||||
classify: editForm.classify,
|
||||
occurredAt: editForm.occurredAt
|
||||
}
|
||||
|
||||
const response = await updateTransaction(data)
|
||||
@@ -262,4 +365,53 @@ const handleCandidateSelect = (candidate) => {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.suggestion-tip {
|
||||
font-size: 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 6px 10px;
|
||||
background: #ecf9ff;
|
||||
color: #1989fa;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
transition: opacity 0.2s;
|
||||
border: 1px solid rgba(25, 137, 250, 0.1);
|
||||
width: fit-content;
|
||||
}
|
||||
|
||||
.suggestion-tip:active {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.suggestion-icon {
|
||||
margin-right: 4px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.suggestion-text {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.suggestion-apply {
|
||||
margin-left: 8px;
|
||||
padding: 0 6px;
|
||||
background: #1989fa;
|
||||
color: #fff;
|
||||
border-radius: 4px;
|
||||
font-size: 10px;
|
||||
height: 18px;
|
||||
line-height: 18px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.suggestion-tip {
|
||||
background: rgba(25, 137, 250, 0.15);
|
||||
border-color: rgba(25, 137, 250, 0.2);
|
||||
color: #58a6ff;
|
||||
}
|
||||
.suggestion-apply {
|
||||
background: #58a6ff;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="transaction-list-container">
|
||||
<div class="transaction-list-container transaction-list">
|
||||
<van-list
|
||||
:loading="loading"
|
||||
:finished="finished"
|
||||
@@ -10,6 +10,7 @@
|
||||
<van-swipe-cell
|
||||
v-for="transaction in transactions"
|
||||
:key="transaction.id"
|
||||
class="transaction-item"
|
||||
>
|
||||
<div class="transaction-row">
|
||||
<van-checkbox
|
||||
|
||||
Reference in New Issue
Block a user