添加消息类型枚举和相关字段,优化消息记录服务的添加方法,更新多个组件以支持新增分类对话框
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
type="primary"
|
||||
:loading="classifying"
|
||||
:disabled="selectedCount === 0"
|
||||
round
|
||||
@click="startClassify"
|
||||
class="action-btn"
|
||||
>
|
||||
@@ -41,6 +42,7 @@
|
||||
<van-button
|
||||
type="success"
|
||||
:disabled="!hasChanges || classifying"
|
||||
round
|
||||
@click="saveClassifications"
|
||||
class="action-btn"
|
||||
>
|
||||
|
||||
@@ -49,7 +49,9 @@
|
||||
height="50%"
|
||||
:closeable="true"
|
||||
>
|
||||
<div class="detail-content">
|
||||
<div v-if="currentMessage.messageType === 2" class="detail-content" v-html="currentMessage.content">
|
||||
</div>
|
||||
<div v-else class="detail-content">
|
||||
{{ currentMessage.content }}
|
||||
</div>
|
||||
</PopupContainer>
|
||||
@@ -126,9 +128,6 @@ const onRefresh = () => {
|
||||
};
|
||||
|
||||
const viewDetail = async (item) => {
|
||||
currentMessage.value = item;
|
||||
detailVisible.value = true;
|
||||
|
||||
if (!item.isRead) {
|
||||
try {
|
||||
await markAsRead(item.id);
|
||||
@@ -138,6 +137,18 @@ const viewDetail = async (item) => {
|
||||
console.error('标记已读失败', error);
|
||||
}
|
||||
}
|
||||
|
||||
if (item.messageType === 1) {
|
||||
if (item.content.startsWith('http')) {
|
||||
window.open(item.content, '_blank');
|
||||
} else {
|
||||
showToast('无效的URL');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
currentMessage.value = item;
|
||||
detailVisible.value = true;
|
||||
};
|
||||
|
||||
const handleDelete = (item) => {
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
:title="isEdit ? '编辑周期账单' : '新增周期账单'"
|
||||
height="85%"
|
||||
>
|
||||
<van-form @submit="onSubmit">
|
||||
<van-form>
|
||||
<van-cell-group inset title="周期设置">
|
||||
<van-field
|
||||
v-model="form.periodicTypeText"
|
||||
@@ -198,7 +198,7 @@
|
||||
type="success"
|
||||
size="small"
|
||||
class="classify-btn"
|
||||
@click="showAddClassify = true"
|
||||
@click="addClassifyDialogRef.open()"
|
||||
>
|
||||
+ 新增
|
||||
</van-button>
|
||||
@@ -223,13 +223,12 @@
|
||||
</van-button>
|
||||
</div>
|
||||
</van-cell-group>
|
||||
|
||||
<div style="margin: 16px;">
|
||||
<van-button round block type="primary" native-type="submit" :loading="submitting">
|
||||
{{ isEdit ? '更新' : '确认添加' }}
|
||||
</van-button>
|
||||
</div>
|
||||
</van-form>
|
||||
<template #footer>
|
||||
<van-button round block type="primary" @click="submit" :loading="submitting">
|
||||
{{ isEdit ? '更新' : '确认添加' }}
|
||||
</van-button>
|
||||
</template>
|
||||
</PopupContainer>
|
||||
|
||||
<!-- 周期类型选择器 -->
|
||||
@@ -260,14 +259,10 @@
|
||||
</van-popup>
|
||||
|
||||
<!-- 新增分类对话框 -->
|
||||
<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>
|
||||
|
||||
@@ -284,9 +279,11 @@ import {
|
||||
} from '@/api/transactionPeriodic'
|
||||
import { getCategoryList, createCategory } from '@/api/transactionCategory'
|
||||
import PopupContainer from '@/components/PopupContainer.vue'
|
||||
import AddClassifyDialog from '@/components/AddClassifyDialog.vue'
|
||||
|
||||
const router = useRouter()
|
||||
const navTitle = ref('周期账单')
|
||||
const addClassifyDialogRef = ref()
|
||||
|
||||
const periodicList = ref([])
|
||||
const loading = ref(false)
|
||||
@@ -303,8 +300,6 @@ const submitting = ref(false)
|
||||
const showPeriodicTypePicker = ref(false)
|
||||
const showWeekdaysPicker = ref(false)
|
||||
const showMonthDaysPicker = ref(false)
|
||||
const showAddClassify = ref(false)
|
||||
const newClassify = ref('')
|
||||
|
||||
// 分类列表
|
||||
const classifyColumns = ref([])
|
||||
@@ -626,15 +621,8 @@ const clearClassify = () => {
|
||||
}
|
||||
|
||||
// 新增分类
|
||||
const addNewClassify = async () => {
|
||||
if (!newClassify.value.trim()) {
|
||||
showToast('请输入分类名称')
|
||||
return
|
||||
}
|
||||
|
||||
const handleAddClassify = async (categoryName) => {
|
||||
try {
|
||||
const categoryName = newClassify.value.trim()
|
||||
|
||||
// 调用API创建分类
|
||||
const response = await createCategory({
|
||||
name: categoryName,
|
||||
@@ -652,9 +640,6 @@ const addNewClassify = async () => {
|
||||
} catch (error) {
|
||||
console.error('创建分类出错:', error)
|
||||
showToast('创建分类失败')
|
||||
} finally {
|
||||
newClassify.value = ''
|
||||
showAddClassify.value = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user