feat:更新支出单词

This commit is contained in:
2026-07-02 21:44:03 +08:00
parent 98f2842869
commit 0ec0bba2fa
9 changed files with 24 additions and 24 deletions

View File

@@ -67,7 +67,7 @@ const getCalendarAttrDates = () => {
}) })
dailyInfo.attrs.push({ dailyInfo.attrs.push({
dot: 'red', dot: 'red',
dates: getCalendarDateList(billStore.billRecordList, 'expensive') dates: getCalendarDateList(billStore.billRecordList, 'expense')
}) })
dailyInfo.attrs.push({ dailyInfo.attrs.push({
dot: 'green', dot: 'green',

View File

@@ -76,7 +76,7 @@ const updateChart = () => {
billDailyChart.setOption({ billDailyChart.setOption({
series: [{ series: [{
itemStyle: { itemStyle: {
color: billStore.billType === 'expensive' ? '#CA6C65' : '#6FBB69' color: billStore.billType === 'expense' ? '#CA6C65' : '#6FBB69'
}, },
markPoint: { markPoint: {
label: { label: {
@@ -96,7 +96,7 @@ const updateChart = () => {
billBookChart.setOption({ billBookChart.setOption({
series: [{ series: [{
itemStyle: { itemStyle: {
color: billStore.billType === 'expensive' ? '#CA6C65' : '#6FBB69' color: billStore.billType === 'expense' ? '#CA6C65' : '#6FBB69'
}, },
markPoint: { markPoint: {
label: { label: {

View File

@@ -5,7 +5,7 @@
<daily-summary :date="dailyItemInfo.date"> <daily-summary :date="dailyItemInfo.date">
<template #extra> <template #extra>
<span>收入{{ formatAmount(dailyItemInfo.totalIncome, true) }}</span> <span>收入{{ formatAmount(dailyItemInfo.totalIncome, true) }}</span>
<span>支出{{ formatAmount(dailyItemInfo.totalExpensive, true) }}</span> <span>支出{{ formatAmount(dailyItemInfo.totalExpense, true) }}</span>
</template> </template>
</daily-summary> </daily-summary>
@@ -70,7 +70,7 @@ onMounted(() => {
const dailyItemInfo = reactive({ const dailyItemInfo = reactive({
date: '', date: '',
totalExpensive: 0, totalExpense: 0,
totalIncome: 0, totalIncome: 0,
itemList: [] as IBillRecord[] itemList: [] as IBillRecord[]
}) })
@@ -86,7 +86,7 @@ const getBillDailyByDate = (date: string) => {
const calendarDaily = getCalendarDailyCount(billStore.billRecordList, date) const calendarDaily = getCalendarDailyCount(billStore.billRecordList, date)
dailyItemInfo.itemList = calendarDaily.dailyRecordList dailyItemInfo.itemList = calendarDaily.dailyRecordList
dailyItemInfo.totalIncome = calendarDaily.totalIncome dailyItemInfo.totalIncome = calendarDaily.totalIncome
dailyItemInfo.totalExpensive = calendarDaily.totalExpensive dailyItemInfo.totalExpense = calendarDaily.totalExpense
} else { } else {
dailyItemInfo.itemList = [] dailyItemInfo.itemList = []
} }

View File

@@ -2,7 +2,7 @@
<div class="common-statistics"> <div class="common-statistics">
<stats-card <stats-card
title="当前支出" color="#CA6C65" unit="元" icon="fa-solid fa-sack-xmark" title="当前支出" color="#CA6C65" unit="元" icon="fa-solid fa-sack-xmark"
:value="formatAmount(billStats.expensive)" /> :value="formatAmount(billStats.expense)" />
<stats-card <stats-card
title="当前收入" color="#6FBB69" unit="元" icon="fa-solid fa-sack-dollar" title="当前收入" color="#6FBB69" unit="元" icon="fa-solid fa-sack-dollar"
@@ -34,7 +34,7 @@ watch(() => billStore.isRefresh, () => {
const billStats = ref<IBillSummaryStats>({ const billStats = ref<IBillSummaryStats>({
balance: 0, balance: 0,
expensive: 0, expense: 0,
income: 0, income: 0,
rate: 0 rate: 0
}) })

View File

@@ -34,7 +34,7 @@ export const useBillStore = defineStore('bill', {
billPayList: [] as IBillPay[], billPayList: [] as IBillPay[],
billBookList: [] as IBillBook[], billBookList: [] as IBillBook[],
billCategoryList: [] as IBillCategory[], billCategoryList: [] as IBillCategory[],
billType: 'expensive' as IBillType, billType: 'expense' as IBillType,
billDateType: 'month' as IDateType, billDateType: 'month' as IDateType,
billDateList: [] as string[], billDateList: [] as string[],
billImagePath: ImagePathEnum.BILL, billImagePath: ImagePathEnum.BILL,

View File

@@ -1,4 +1,4 @@
export type IBillType = 'expensive' | 'income' | '' export type IBillType = 'expense' | 'income' | ''
/** /**
* 账单记录 * 账单记录
@@ -68,12 +68,12 @@ export interface IBillSearch {
export interface IBillCalendarDaily { export interface IBillCalendarDaily {
dailyRecordList: IBillRecord[]; dailyRecordList: IBillRecord[];
totalExpensive: number; totalExpense: number;
totalIncome: number; totalIncome: number;
} }
export interface IBillSummaryStats { export interface IBillSummaryStats {
expensive: number; expense: number;
income: number; income: number;
balance: number; balance: number;
rate: number; rate: number;

View File

@@ -11,7 +11,7 @@ import { formatDate } from 'vue3-common/utils/dateUtil'
* @param billRecordList 账单记录 * @param billRecordList 账单记录
* @param type 账单类型 * @param type 账单类型
*/ */
export const getCalendarDateList = (billRecordList: IBillRecord[], type: 'expensive' | 'income'): string[] => { export const getCalendarDateList = (billRecordList: IBillRecord[], type: 'expense' | 'income'): string[] => {
const resultSet = new Set() const resultSet = new Set()
billRecordList.forEach((item) => { billRecordList.forEach((item) => {
if (item.type === type) { if (item.type === type) {
@@ -31,7 +31,7 @@ export const getCalendarDailyCount = (billRecordList: IBillRecord[],
date: string): IBillCalendarDaily => { date: string): IBillCalendarDaily => {
const calendarDaily: IBillCalendarDaily = { const calendarDaily: IBillCalendarDaily = {
dailyRecordList: [], dailyRecordList: [],
totalExpensive: 0, totalExpense: 0,
totalIncome: 0 totalIncome: 0
} }
@@ -40,8 +40,8 @@ export const getCalendarDailyCount = (billRecordList: IBillRecord[],
if (formatDate(value.date) === date) { if (formatDate(value.date) === date) {
calendarDaily.dailyRecordList.push(value) calendarDaily.dailyRecordList.push(value)
// 统计当前日期的收入和支出总和 // 统计当前日期的收入和支出总和
if (value.type === 'expensive') { if (value.type === 'expense') {
calendarDaily.totalExpensive += value.amount calendarDaily.totalExpense += value.amount
} else { } else {
calendarDaily.totalIncome += value.amount calendarDaily.totalIncome += value.amount
} }
@@ -58,29 +58,29 @@ export const getCalendarDailyCount = (billRecordList: IBillRecord[],
export const getBillSummaryStats = (billRecordList: IBillRecord[]): IBillSummaryStats => { export const getBillSummaryStats = (billRecordList: IBillRecord[]): IBillSummaryStats => {
const billSummaryStats: IBillSummaryStats = { const billSummaryStats: IBillSummaryStats = {
balance: 0, balance: 0,
expensive: 0, expense: 0,
income: 0, income: 0,
rate: 0 rate: 0
} }
billRecordList.forEach((value) => { billRecordList.forEach((value) => {
// 统计当前日期的支出和收入总和 // 统计当前日期的支出和收入总和
if (value.type === 'expensive') { if (value.type === 'expense') {
billSummaryStats.expensive += value.amount billSummaryStats.expense += value.amount
} else { } else {
billSummaryStats.income += value.amount billSummaryStats.income += value.amount
} }
}) })
billSummaryStats.balance = billSummaryStats.income - billSummaryStats.expensive billSummaryStats.balance = billSummaryStats.income - billSummaryStats.expense
// 计算支出/收入 // 计算支出/收入
if (billSummaryStats.expensive === 0) { if (billSummaryStats.expense === 0) {
billSummaryStats.rate = 0 billSummaryStats.rate = 0
} else if (billSummaryStats.income === 0) { } else if (billSummaryStats.income === 0) {
billSummaryStats.rate = 1 billSummaryStats.rate = 1
} else { } else {
billSummaryStats.rate = Math.min(billSummaryStats.expensive / billSummaryStats.income, 1) billSummaryStats.rate = Math.min(billSummaryStats.expense / billSummaryStats.income, 1)
} }
return billSummaryStats return billSummaryStats

View File

@@ -152,7 +152,7 @@ const initImageFileList = () => {
* @param type 账单类型 * @param type 账单类型
*/ */
const getBillTypeName = (type: string) => { const getBillTypeName = (type: string) => {
return type === 'expensive' ? '支出' : '收入' return type === 'expense' ? '支出' : '收入'
} }
/** /**

View File

@@ -9,7 +9,7 @@
<div v-else class="bill-search-list card-item"> <div v-else class="bill-search-list card-item">
<div class="search-result-title"> <div class="search-result-title">
<span>收入{{ formatAmount(getTotalAmount(billStore.billRecordList, 'income')) }}</span> <span>收入{{ formatAmount(getTotalAmount(billStore.billRecordList, 'income')) }}</span>
<span>支出{{ formatAmount(getTotalAmount(billStore.billRecordList, 'expensive')) }}</span> <span>支出{{ formatAmount(getTotalAmount(billStore.billRecordList, 'expense')) }}</span>
</div> </div>
<daily-card v-for="(item, index) in billStore.billRecordList" <daily-card v-for="(item, index) in billStore.billRecordList"
:key="index" @click="selectBillRecordClick(item)" :key="index" @click="selectBillRecordClick(item)"