新增不记额收支
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 34s
Docker Build & Deploy / Deploy to Production (push) Successful in 8s
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 0s
Docker Build & Deploy / WeChat Notification (push) Successful in 3s

This commit is contained in:
孙诚
2026-01-15 10:53:05 +08:00
parent 12cf1b6323
commit 65f7316c82
9 changed files with 456 additions and 123 deletions

View File

@@ -14,19 +14,27 @@
placeholder="例如:每月餐饮、年度奖金"
:rules="[{ required: true, message: '请填写预算名称' }]"
/>
<!-- 新增不记额预算复选框 -->
<van-field label="不记额预算">
<template #input>
<van-checkbox v-model="form.noLimit" @update:model-value="onNoLimitChange">不记额预算仅限年度</van-checkbox>
</template>
</van-field>
<van-field name="type" label="统计周期">
<template #input>
<van-radio-group
v-model="form.type"
direction="horizontal"
:disabled="isEdit"
:disabled="isEdit || form.noLimit"
>
<van-radio :name="BudgetPeriodType.Month"></van-radio>
<van-radio :name="BudgetPeriodType.Year"></van-radio>
</van-radio-group>
</template>
</van-field>
<!-- 仅当未选中"不记额预算"时显示预算金额 -->
<van-field
v-if="!form.noLimit"
v-model="form.limit"
type="number"
name="limit"
@@ -83,7 +91,8 @@ const form = reactive({
type: BudgetPeriodType.Month,
category: BudgetCategory.Expense,
limit: '',
selectedCategories: []
selectedCategories: [],
noLimit: false // 新增字段
})
const open = ({
@@ -104,7 +113,8 @@ const open = ({
type: data.type,
category: category,
limit: data.limit,
selectedCategories: data.selectedCategories ? [...data.selectedCategories] : []
selectedCategories: data.selectedCategories ? [...data.selectedCategories] : [],
noLimit: data.noLimit || false // 新增
})
} else {
Object.assign(form, {
@@ -113,7 +123,8 @@ const open = ({
type: BudgetPeriodType.Month,
category: category,
limit: '',
selectedCategories: []
selectedCategories: [],
noLimit: false // 新增
})
}
visible.value = true
@@ -131,8 +142,9 @@ const onSubmit = async () => {
try {
const data = {
...form,
limit: parseFloat(form.limit),
selectedCategories: form.selectedCategories
limit: form.noLimit ? 0 : parseFloat(form.limit), // 不记额时金额为0
selectedCategories: form.selectedCategories,
noLimit: form.noLimit // 新增
}
const res = form.id ? await updateBudget(data) : await createBudget(data)
@@ -159,6 +171,13 @@ const getCategoryName = (category) => {
return ''
}
}
const onNoLimitChange = (value) => {
if (value) {
// 选中不记额时,自动设为年度预算
form.type = BudgetPeriodType.Year
}
}
</script>
<style scoped>