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>
|
/// </summary>
|
||||||
/// <returns>影响行数</returns>
|
/// <returns>影响行数</returns>
|
||||||
Task<int> ConfirmAllUnconfirmedAsync();
|
Task<int> ConfirmAllUnconfirmedAsync(long[] ids);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新分类名称
|
/// 更新分类名称
|
||||||
@@ -698,7 +698,7 @@ public class TransactionRecordRepository(IFreeSql freeSql) : BaseRepository<Tran
|
|||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> ConfirmAllUnconfirmedAsync()
|
public async Task<int> ConfirmAllUnconfirmedAsync(long[] ids)
|
||||||
{
|
{
|
||||||
return await FreeSql.Update<TransactionRecord>()
|
return await FreeSql.Update<TransactionRecord>()
|
||||||
.Set(t => t.Classify == t.UnconfirmedClassify)
|
.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.UnconfirmedClassify, null)
|
||||||
.Set(t => t.UnconfirmedType, null)
|
.Set(t => t.UnconfirmedType, null)
|
||||||
.Where(t => t.UnconfirmedClassify != null && t.UnconfirmedClassify != "")
|
.Where(t => t.UnconfirmedClassify != null && t.UnconfirmedClassify != "")
|
||||||
|
.Where(t => ids.Contains(t.Id))
|
||||||
.ExecuteAffrowsAsync();
|
.ExecuteAffrowsAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,10 +34,11 @@ export const getUnconfirmedTransactionList = () => {
|
|||||||
* 全部确认待确认的交易分类
|
* 全部确认待确认的交易分类
|
||||||
* @returns {Promise<{success: boolean, data: number}>}
|
* @returns {Promise<{success: boolean, data: number}>}
|
||||||
*/
|
*/
|
||||||
export const confirmAllUnconfirmed = () => {
|
export const confirmAllUnconfirmed = (ids) => {
|
||||||
return request({
|
return request({
|
||||||
url: '/TransactionRecord/ConfirmAllUnconfirmed',
|
url: '/TransactionRecord/ConfirmAllUnconfirmed',
|
||||||
method: 'post'
|
method: 'post',
|
||||||
|
data: { ids }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,13 +8,13 @@
|
|||||||
>
|
>
|
||||||
<template #right>
|
<template #right>
|
||||||
<van-button
|
<van-button
|
||||||
v-if="transactions.length > 0"
|
v-if="selectedIds.size > 0"
|
||||||
type="primary"
|
type="primary"
|
||||||
size="small"
|
size="small"
|
||||||
:loading="confirming"
|
:loading="confirming"
|
||||||
@click="handleConfirmAll"
|
@click="handleConfirmSelected"
|
||||||
>
|
>
|
||||||
全部确认
|
确认所选 ({{ selectedIds.size }})
|
||||||
</van-button>
|
</van-button>
|
||||||
</template>
|
</template>
|
||||||
</van-nav-bar>
|
</van-nav-bar>
|
||||||
@@ -29,8 +29,11 @@
|
|||||||
:transactions="displayTransactions"
|
:transactions="displayTransactions"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
:finished="true"
|
:finished="true"
|
||||||
|
show-checkbox
|
||||||
|
:selected-ids="selectedIds"
|
||||||
@click="handleTransactionClick"
|
@click="handleTransactionClick"
|
||||||
@delete="handleTransactionDeleted"
|
@delete="handleTransactionDeleted"
|
||||||
|
@update:selected-ids="updateSelectedIds"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -57,12 +60,13 @@ const confirming = ref(false)
|
|||||||
const transactions = ref([])
|
const transactions = ref([])
|
||||||
const showDetail = ref(false)
|
const showDetail = ref(false)
|
||||||
const currentTransaction = ref(null)
|
const currentTransaction = ref(null)
|
||||||
|
const selectedIds = ref(new Set())
|
||||||
|
|
||||||
const onClickLeft = () => {
|
const onClickLeft = () => {
|
||||||
router.back()
|
router.back()
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleConfirmAll = async () => {
|
const handleConfirmSelected = async () => {
|
||||||
try {
|
try {
|
||||||
await showConfirmDialog({
|
await showConfirmDialog({
|
||||||
title: '提示',
|
title: '提示',
|
||||||
@@ -70,7 +74,7 @@ const handleConfirmAll = async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
confirming.value = true
|
confirming.value = true
|
||||||
const response = await confirmAllUnconfirmed()
|
const response = await confirmAllUnconfirmed(Array.from(selectedIds.value))
|
||||||
if (response && response.success) {
|
if (response && response.success) {
|
||||||
showToast(`成功确认 ${response.data} 条记录`)
|
showToast(`成功确认 ${response.data} 条记录`)
|
||||||
loadData()
|
loadData()
|
||||||
@@ -100,7 +104,13 @@ const loadData = async () => {
|
|||||||
try {
|
try {
|
||||||
const response = await getUnconfirmedTransactionList()
|
const response = await getUnconfirmedTransactionList()
|
||||||
if (response && response.success) {
|
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) {
|
} catch (error) {
|
||||||
console.error('获取待确认列表失败:', error)
|
console.error('获取待确认列表失败:', error)
|
||||||
@@ -118,6 +128,10 @@ const handleTransactionDeleted = (id) => {
|
|||||||
transactions.value = transactions.value.filter(t => t.id !== id)
|
transactions.value = transactions.value.filter(t => t.id !== id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const updateSelectedIds = (ids) => {
|
||||||
|
selectedIds.value = new Set(ids)
|
||||||
|
}
|
||||||
|
|
||||||
const handleDetailSave = () => {
|
const handleDetailSave = () => {
|
||||||
loadData()
|
loadData()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,11 +95,11 @@ public class TransactionRecordController(
|
|||||||
/// 全部确认待确认的交易分类
|
/// 全部确认待确认的交易分类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<BaseResponse<int>> ConfirmAllUnconfirmedAsync()
|
public async Task<BaseResponse<int>> ConfirmAllUnconfirmedAsync([FromBody] ConfirmAllUnconfirmedRequestDto request)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var count = await transactionRepository.ConfirmAllUnconfirmedAsync();
|
var count = await transactionRepository.ConfirmAllUnconfirmedAsync(request.Ids);
|
||||||
return count.Ok();
|
return count.Ok();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -527,6 +527,14 @@ public class TransactionRecordController(
|
|||||||
{
|
{
|
||||||
record.Type = item.Type.Value;
|
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);
|
var success = await transactionRepository.UpdateAsync(record);
|
||||||
if (success)
|
if (success)
|
||||||
successCount++;
|
successCount++;
|
||||||
@@ -766,4 +774,8 @@ public record OffsetTransactionDto(
|
|||||||
|
|
||||||
public record ParseOneLineRequestDto(
|
public record ParseOneLineRequestDto(
|
||||||
string Text
|
string Text
|
||||||
|
);
|
||||||
|
|
||||||
|
public record ConfirmAllUnconfirmedRequestDto(
|
||||||
|
long[] Ids
|
||||||
);
|
);
|
||||||
Reference in New Issue
Block a user