feat: 更新确认待确认分类的接口,支持批量确认功能;调整前端逻辑以处理选中的交易记录
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 20s
Docker Build & Deploy / Deploy to Production (push) Successful in 6s
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 20s
Docker Build & Deploy / Deploy to Production (push) Successful in 6s
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s
Docker Build & Deploy / WeChat Notification (push) Successful in 2s
This commit is contained in:
@@ -188,7 +188,7 @@ public interface ITransactionRecordRepository : IBaseRepository<TransactionRecor
|
||||
/// 全部确认待确认的分类
|
||||
/// </summary>
|
||||
/// <returns>影响行数</returns>
|
||||
Task<int> ConfirmAllUnconfirmedAsync();
|
||||
Task<int> ConfirmAllUnconfirmedAsync(long[] ids);
|
||||
|
||||
/// <summary>
|
||||
/// 更新分类名称
|
||||
@@ -698,7 +698,7 @@ public class TransactionRecordRepository(IFreeSql freeSql) : BaseRepository<Tran
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<int> ConfirmAllUnconfirmedAsync()
|
||||
public async Task<int> ConfirmAllUnconfirmedAsync(long[] ids)
|
||||
{
|
||||
return await FreeSql.Update<TransactionRecord>()
|
||||
.Set(t => t.Classify == t.UnconfirmedClassify)
|
||||
@@ -706,6 +706,7 @@ public class TransactionRecordRepository(IFreeSql freeSql) : BaseRepository<Tran
|
||||
.Set(t => t.UnconfirmedClassify, null)
|
||||
.Set(t => t.UnconfirmedType, null)
|
||||
.Where(t => t.UnconfirmedClassify != null && t.UnconfirmedClassify != "")
|
||||
.Where(t => ids.Contains(t.Id))
|
||||
.ExecuteAffrowsAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,10 +34,11 @@ export const getUnconfirmedTransactionList = () => {
|
||||
* 全部确认待确认的交易分类
|
||||
* @returns {Promise<{success: boolean, data: number}>}
|
||||
*/
|
||||
export const confirmAllUnconfirmed = () => {
|
||||
export const confirmAllUnconfirmed = (ids) => {
|
||||
return request({
|
||||
url: '/TransactionRecord/ConfirmAllUnconfirmed',
|
||||
method: 'post'
|
||||
method: 'post',
|
||||
data: { ids }
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
>
|
||||
<template #right>
|
||||
<van-button
|
||||
v-if="transactions.length > 0"
|
||||
v-if="selectedIds.size > 0"
|
||||
type="primary"
|
||||
size="small"
|
||||
:loading="confirming"
|
||||
@click="handleConfirmAll"
|
||||
@click="handleConfirmSelected"
|
||||
>
|
||||
全部确认
|
||||
确认所选 ({{ selectedIds.size }})
|
||||
</van-button>
|
||||
</template>
|
||||
</van-nav-bar>
|
||||
@@ -29,8 +29,11 @@
|
||||
:transactions="displayTransactions"
|
||||
:loading="loading"
|
||||
:finished="true"
|
||||
show-checkbox
|
||||
:selected-ids="selectedIds"
|
||||
@click="handleTransactionClick"
|
||||
@delete="handleTransactionDeleted"
|
||||
@update:selected-ids="updateSelectedIds"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -57,12 +60,13 @@ const confirming = ref(false)
|
||||
const transactions = ref([])
|
||||
const showDetail = ref(false)
|
||||
const currentTransaction = ref(null)
|
||||
const selectedIds = ref(new Set())
|
||||
|
||||
const onClickLeft = () => {
|
||||
router.back()
|
||||
}
|
||||
|
||||
const handleConfirmAll = async () => {
|
||||
const handleConfirmSelected = async () => {
|
||||
try {
|
||||
await showConfirmDialog({
|
||||
title: '提示',
|
||||
@@ -70,7 +74,7 @@ const handleConfirmAll = async () => {
|
||||
})
|
||||
|
||||
confirming.value = true
|
||||
const response = await confirmAllUnconfirmed()
|
||||
const response = await confirmAllUnconfirmed(Array.from(selectedIds.value))
|
||||
if (response && response.success) {
|
||||
showToast(`成功确认 ${response.data} 条记录`)
|
||||
loadData()
|
||||
@@ -100,7 +104,13 @@ const loadData = async () => {
|
||||
try {
|
||||
const response = await getUnconfirmedTransactionList()
|
||||
if (response && response.success) {
|
||||
transactions.value = response.data || []
|
||||
transactions.value = (response.data || [])
|
||||
.map(t => ({
|
||||
...t,
|
||||
upsetedClassify: t.unconfirmedClassify,
|
||||
upsetedType: t.unconfirmedType
|
||||
}))
|
||||
selectedIds.value = new Set(response.data.map(t => t.id))
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取待确认列表失败:', error)
|
||||
@@ -118,6 +128,10 @@ const handleTransactionDeleted = (id) => {
|
||||
transactions.value = transactions.value.filter(t => t.id !== id)
|
||||
}
|
||||
|
||||
const updateSelectedIds = (ids) => {
|
||||
selectedIds.value = new Set(ids)
|
||||
}
|
||||
|
||||
const handleDetailSave = () => {
|
||||
loadData()
|
||||
}
|
||||
|
||||
@@ -95,11 +95,11 @@ public class TransactionRecordController(
|
||||
/// 全部确认待确认的交易分类
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public async Task<BaseResponse<int>> ConfirmAllUnconfirmedAsync()
|
||||
public async Task<BaseResponse<int>> ConfirmAllUnconfirmedAsync([FromBody] ConfirmAllUnconfirmedRequestDto request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var count = await transactionRepository.ConfirmAllUnconfirmedAsync();
|
||||
var count = await transactionRepository.ConfirmAllUnconfirmedAsync(request.Ids);
|
||||
return count.Ok();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -527,6 +527,14 @@ public class TransactionRecordController(
|
||||
{
|
||||
record.Type = item.Type.Value;
|
||||
}
|
||||
if(!string.IsNullOrEmpty(record.Classify))
|
||||
{
|
||||
record.UnconfirmedClassify = null;
|
||||
}
|
||||
if(record.Type == item.Type)
|
||||
{
|
||||
record.UnconfirmedType = TransactionType.None;
|
||||
}
|
||||
var success = await transactionRepository.UpdateAsync(record);
|
||||
if (success)
|
||||
successCount++;
|
||||
@@ -767,3 +775,7 @@ public record OffsetTransactionDto(
|
||||
public record ParseOneLineRequestDto(
|
||||
string Text
|
||||
);
|
||||
|
||||
public record ConfirmAllUnconfirmedRequestDto(
|
||||
long[] Ids
|
||||
);
|
||||
Reference in New Issue
Block a user