2026-01-07 20:31:12 +08:00
|
|
|
|
<template>
|
2026-02-20 14:57:19 +08:00
|
|
|
|
<PopupContainerV2
|
|
|
|
|
|
v-model:show="visible"
|
2026-01-27 15:29:25 +08:00
|
|
|
|
title="设置存款分类"
|
2026-02-20 14:57:19 +08:00
|
|
|
|
:height="'60%'"
|
2026-01-27 15:29:25 +08:00
|
|
|
|
>
|
2026-01-07 20:31:12 +08:00
|
|
|
|
<div class="savings-config-content">
|
|
|
|
|
|
<div class="config-header">
|
2026-01-27 15:29:25 +08:00
|
|
|
|
<p class="subtitle">
|
|
|
|
|
|
这些分类的统计值将计入“存款”中
|
|
|
|
|
|
</p>
|
2026-01-07 20:31:12 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="category-section">
|
2026-01-27 15:29:25 +08:00
|
|
|
|
<div class="section-title">
|
|
|
|
|
|
可多选分类
|
|
|
|
|
|
</div>
|
2026-01-08 14:41:50 +08:00
|
|
|
|
<ClassifySelector
|
2026-02-20 14:57:19 +08:00
|
|
|
|
v-model:show="selectedCategories"
|
2026-01-08 14:41:50 +08:00
|
|
|
|
:type="2"
|
|
|
|
|
|
multiple
|
|
|
|
|
|
:show-add="false"
|
|
|
|
|
|
:show-clear="false"
|
|
|
|
|
|
/>
|
2026-01-07 20:31:12 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2026-01-16 11:15:44 +08:00
|
|
|
|
|
2026-01-07 20:31:12 +08:00
|
|
|
|
<template #footer>
|
2026-01-27 15:29:25 +08:00
|
|
|
|
<van-button
|
|
|
|
|
|
block
|
|
|
|
|
|
round
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
@click="onSubmit"
|
|
|
|
|
|
>
|
|
|
|
|
|
保存配置
|
|
|
|
|
|
</van-button>
|
2026-01-07 20:31:12 +08:00
|
|
|
|
</template>
|
2026-02-20 14:57:19 +08:00
|
|
|
|
</PopupContainerV2>
|
2026-01-07 20:31:12 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
2026-01-08 14:41:50 +08:00
|
|
|
|
import { ref } from 'vue'
|
2026-01-07 20:31:12 +08:00
|
|
|
|
import { showToast, showLoadingToast, closeToast } from 'vant'
|
|
|
|
|
|
import { getConfig, setConfig } from '@/api/config'
|
2026-02-21 10:10:16 +08:00
|
|
|
|
import PopupContainerV2 from '@/components/Common/PopupContainerV2.vue'
|
|
|
|
|
|
import ClassifySelector from '@/components/Common/ClassifySelector.vue'
|
2026-01-07 20:31:12 +08:00
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits(['success'])
|
|
|
|
|
|
|
|
|
|
|
|
const visible = ref(false)
|
|
|
|
|
|
const selectedCategories = ref([])
|
|
|
|
|
|
|
|
|
|
|
|
const open = async () => {
|
|
|
|
|
|
visible.value = true
|
|
|
|
|
|
await fetchConfig()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
defineExpose({
|
|
|
|
|
|
open
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const fetchConfig = async () => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const res = await getConfig('SavingsCategories')
|
|
|
|
|
|
if (res.success && res.data) {
|
2026-01-16 11:15:44 +08:00
|
|
|
|
selectedCategories.value = res.data.split(',').filter((x) => x)
|
2026-01-07 20:31:12 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
selectedCategories.value = []
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
console.error('获取配置失败', err)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const onSubmit = async () => {
|
|
|
|
|
|
showLoadingToast({ message: '保存中...', forbidClick: true })
|
|
|
|
|
|
try {
|
|
|
|
|
|
const value = selectedCategories.value.join(',')
|
|
|
|
|
|
const res = await setConfig('SavingsCategories', value)
|
|
|
|
|
|
if (res.success) {
|
|
|
|
|
|
showToast('配置已保存')
|
|
|
|
|
|
visible.value = false
|
|
|
|
|
|
emit('success')
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
console.error('保存配置失败', err)
|
|
|
|
|
|
showToast('保存失败')
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
closeToast()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.savings-config-content {
|
|
|
|
|
|
padding: 16px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.config-header {
|
|
|
|
|
|
margin-bottom: 20px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.subtitle {
|
|
|
|
|
|
font-size: 14px;
|
2026-01-13 17:00:44 +08:00
|
|
|
|
color: var(--van-text-color-2);
|
2026-01-07 20:31:12 +08:00
|
|
|
|
margin: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.section-title {
|
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
margin-bottom: 12px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.no-data {
|
|
|
|
|
|
text-align: center;
|
2026-01-13 17:00:44 +08:00
|
|
|
|
color: var(--van-text-color-2);
|
2026-01-07 20:31:12 +08:00
|
|
|
|
width: 100%;
|
|
|
|
|
|
padding: 20px 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|