添加消息类型枚举和相关字段,优化消息记录服务的添加方法,更新多个组件以支持新增分类对话框
This commit is contained in:
@@ -87,12 +87,10 @@
|
||||
/>
|
||||
|
||||
<!-- 批量设置对话框 -->
|
||||
<van-dialog
|
||||
v-model:show="showBatchDialog"
|
||||
<PopupContainer
|
||||
v-model="showBatchDialog"
|
||||
title="批量设置分类"
|
||||
:show-cancel-button="true"
|
||||
@confirm="handleConfirmBatchUpdate"
|
||||
@cancel="resetBatchForm"
|
||||
height="60%"
|
||||
>
|
||||
<van-form ref="batchFormRef" class="setting-form">
|
||||
<van-cell-group inset>
|
||||
@@ -137,7 +135,7 @@
|
||||
type="success"
|
||||
size="small"
|
||||
class="classify-btn"
|
||||
@click="showAddClassify = true"
|
||||
@click="addClassifyDialogRef.open()"
|
||||
>
|
||||
+ 新增
|
||||
</van-button>
|
||||
@@ -163,17 +161,23 @@
|
||||
</div>
|
||||
</van-cell-group>
|
||||
</van-form>
|
||||
</van-dialog>
|
||||
<template #footer>
|
||||
<van-button
|
||||
round
|
||||
block
|
||||
type="primary"
|
||||
@click="handleConfirmBatchUpdate"
|
||||
>
|
||||
确定
|
||||
</van-button>
|
||||
</template>
|
||||
</PopupContainer>
|
||||
|
||||
<!-- 新增分类对话框 -->
|
||||
<van-dialog
|
||||
v-model:show="showAddClassify"
|
||||
title="新增交易分类"
|
||||
show-cancel-button
|
||||
@confirm="addNewClassify"
|
||||
>
|
||||
<van-field v-model="newClassify" placeholder="请输入新的交易分类" />
|
||||
</van-dialog>
|
||||
<AddClassifyDialog
|
||||
ref="addClassifyDialogRef"
|
||||
@confirm="handleAddClassify"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -188,6 +192,7 @@ import {
|
||||
} from 'vant'
|
||||
import { getReasonGroups, batchUpdateByReason, getTransactionList } from '@/api/transactionRecord'
|
||||
import { getCategoryList, createCategory } from '@/api/transactionCategory'
|
||||
import AddClassifyDialog from './AddClassifyDialog.vue'
|
||||
import TransactionList from './TransactionList.vue'
|
||||
import TransactionDetail from './TransactionDetail.vue'
|
||||
import PopupContainer from './PopupContainer.vue'
|
||||
@@ -201,7 +206,7 @@ const props = defineProps({
|
||||
// 每页数量
|
||||
pageSize: {
|
||||
type: Number,
|
||||
default: 3 // TODO 测试写小一点
|
||||
default: 20
|
||||
}
|
||||
})
|
||||
|
||||
@@ -232,10 +237,9 @@ const transactionPageSize = ref(20)
|
||||
|
||||
// 批量分类相关状态
|
||||
const showBatchDialog = ref(false)
|
||||
const showAddClassify = ref(false)
|
||||
const batchFormRef = ref(null)
|
||||
const batchGroup = ref(null)
|
||||
const newClassify = ref('')
|
||||
const addClassifyDialogRef = ref()
|
||||
const batchForm = ref({
|
||||
type: null,
|
||||
typeName: '',
|
||||
@@ -380,20 +384,13 @@ const selectClassify = (classify) => {
|
||||
}
|
||||
|
||||
// 新增分类
|
||||
const addNewClassify = async () => {
|
||||
if (!newClassify.value.trim()) {
|
||||
showToast('请输入分类名称')
|
||||
return
|
||||
}
|
||||
|
||||
const handleAddClassify = async (categoryName) => {
|
||||
if (batchForm.value.type === null) {
|
||||
showToast('请先选择交易类型')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const categoryName = newClassify.value.trim()
|
||||
|
||||
// 调用API创建分类
|
||||
const response = await createCategory({
|
||||
name: categoryName,
|
||||
@@ -411,9 +408,6 @@ const addNewClassify = async () => {
|
||||
} catch (error) {
|
||||
console.error('创建分类出错:', error)
|
||||
showToast('创建分类失败')
|
||||
} finally {
|
||||
newClassify.value = ''
|
||||
showAddClassify.value = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -711,6 +705,17 @@ defineExpose({
|
||||
height: 28px;
|
||||
}
|
||||
|
||||
.popup-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.popup-actions .van-button {
|
||||
flex: 1;
|
||||
min-width: auto;
|
||||
}
|
||||
|
||||
.group-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
Reference in New Issue
Block a user