feat:更新支出单词
This commit is contained in:
@@ -67,7 +67,7 @@ const getCalendarAttrDates = () => {
|
||||
})
|
||||
dailyInfo.attrs.push({
|
||||
dot: 'red',
|
||||
dates: getCalendarDateList(billStore.billRecordList, 'expensive')
|
||||
dates: getCalendarDateList(billStore.billRecordList, 'expense')
|
||||
})
|
||||
dailyInfo.attrs.push({
|
||||
dot: 'green',
|
||||
|
||||
@@ -76,7 +76,7 @@ const updateChart = () => {
|
||||
billDailyChart.setOption({
|
||||
series: [{
|
||||
itemStyle: {
|
||||
color: billStore.billType === 'expensive' ? '#CA6C65' : '#6FBB69'
|
||||
color: billStore.billType === 'expense' ? '#CA6C65' : '#6FBB69'
|
||||
},
|
||||
markPoint: {
|
||||
label: {
|
||||
@@ -96,7 +96,7 @@ const updateChart = () => {
|
||||
billBookChart.setOption({
|
||||
series: [{
|
||||
itemStyle: {
|
||||
color: billStore.billType === 'expensive' ? '#CA6C65' : '#6FBB69'
|
||||
color: billStore.billType === 'expense' ? '#CA6C65' : '#6FBB69'
|
||||
},
|
||||
markPoint: {
|
||||
label: {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<daily-summary :date="dailyItemInfo.date">
|
||||
<template #extra>
|
||||
<span>收入:{{ formatAmount(dailyItemInfo.totalIncome, true) }}</span>
|
||||
<span>支出:{{ formatAmount(dailyItemInfo.totalExpensive, true) }}</span>
|
||||
<span>支出:{{ formatAmount(dailyItemInfo.totalExpense, true) }}</span>
|
||||
</template>
|
||||
</daily-summary>
|
||||
|
||||
@@ -70,7 +70,7 @@ onMounted(() => {
|
||||
|
||||
const dailyItemInfo = reactive({
|
||||
date: '',
|
||||
totalExpensive: 0,
|
||||
totalExpense: 0,
|
||||
totalIncome: 0,
|
||||
itemList: [] as IBillRecord[]
|
||||
})
|
||||
@@ -86,7 +86,7 @@ const getBillDailyByDate = (date: string) => {
|
||||
const calendarDaily = getCalendarDailyCount(billStore.billRecordList, date)
|
||||
dailyItemInfo.itemList = calendarDaily.dailyRecordList
|
||||
dailyItemInfo.totalIncome = calendarDaily.totalIncome
|
||||
dailyItemInfo.totalExpensive = calendarDaily.totalExpensive
|
||||
dailyItemInfo.totalExpense = calendarDaily.totalExpense
|
||||
} else {
|
||||
dailyItemInfo.itemList = []
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="common-statistics">
|
||||
<stats-card
|
||||
title="当前支出" color="#CA6C65" unit="元" icon="fa-solid fa-sack-xmark"
|
||||
:value="formatAmount(billStats.expensive)" />
|
||||
:value="formatAmount(billStats.expense)" />
|
||||
|
||||
<stats-card
|
||||
title="当前收入" color="#6FBB69" unit="元" icon="fa-solid fa-sack-dollar"
|
||||
@@ -34,7 +34,7 @@ watch(() => billStore.isRefresh, () => {
|
||||
|
||||
const billStats = ref<IBillSummaryStats>({
|
||||
balance: 0,
|
||||
expensive: 0,
|
||||
expense: 0,
|
||||
income: 0,
|
||||
rate: 0
|
||||
})
|
||||
|
||||
@@ -34,7 +34,7 @@ export const useBillStore = defineStore('bill', {
|
||||
billPayList: [] as IBillPay[],
|
||||
billBookList: [] as IBillBook[],
|
||||
billCategoryList: [] as IBillCategory[],
|
||||
billType: 'expensive' as IBillType,
|
||||
billType: 'expense' as IBillType,
|
||||
billDateType: 'month' as IDateType,
|
||||
billDateList: [] as string[],
|
||||
billImagePath: ImagePathEnum.BILL,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export type IBillType = 'expensive' | 'income' | ''
|
||||
export type IBillType = 'expense' | 'income' | ''
|
||||
|
||||
/**
|
||||
* 账单记录
|
||||
@@ -68,12 +68,12 @@ export interface IBillSearch {
|
||||
|
||||
export interface IBillCalendarDaily {
|
||||
dailyRecordList: IBillRecord[];
|
||||
totalExpensive: number;
|
||||
totalExpense: number;
|
||||
totalIncome: number;
|
||||
}
|
||||
|
||||
export interface IBillSummaryStats {
|
||||
expensive: number;
|
||||
expense: number;
|
||||
income: number;
|
||||
balance: number;
|
||||
rate: number;
|
||||
|
||||
@@ -11,7 +11,7 @@ import { formatDate } from 'vue3-common/utils/dateUtil'
|
||||
* @param billRecordList 账单记录
|
||||
* @param type 账单类型
|
||||
*/
|
||||
export const getCalendarDateList = (billRecordList: IBillRecord[], type: 'expensive' | 'income'): string[] => {
|
||||
export const getCalendarDateList = (billRecordList: IBillRecord[], type: 'expense' | 'income'): string[] => {
|
||||
const resultSet = new Set()
|
||||
billRecordList.forEach((item) => {
|
||||
if (item.type === type) {
|
||||
@@ -31,7 +31,7 @@ export const getCalendarDailyCount = (billRecordList: IBillRecord[],
|
||||
date: string): IBillCalendarDaily => {
|
||||
const calendarDaily: IBillCalendarDaily = {
|
||||
dailyRecordList: [],
|
||||
totalExpensive: 0,
|
||||
totalExpense: 0,
|
||||
totalIncome: 0
|
||||
}
|
||||
|
||||
@@ -40,8 +40,8 @@ export const getCalendarDailyCount = (billRecordList: IBillRecord[],
|
||||
if (formatDate(value.date) === date) {
|
||||
calendarDaily.dailyRecordList.push(value)
|
||||
// 统计当前日期的收入和支出总和
|
||||
if (value.type === 'expensive') {
|
||||
calendarDaily.totalExpensive += value.amount
|
||||
if (value.type === 'expense') {
|
||||
calendarDaily.totalExpense += value.amount
|
||||
} else {
|
||||
calendarDaily.totalIncome += value.amount
|
||||
}
|
||||
@@ -58,29 +58,29 @@ export const getCalendarDailyCount = (billRecordList: IBillRecord[],
|
||||
export const getBillSummaryStats = (billRecordList: IBillRecord[]): IBillSummaryStats => {
|
||||
const billSummaryStats: IBillSummaryStats = {
|
||||
balance: 0,
|
||||
expensive: 0,
|
||||
expense: 0,
|
||||
income: 0,
|
||||
rate: 0
|
||||
}
|
||||
|
||||
billRecordList.forEach((value) => {
|
||||
// 统计当前日期的支出和收入总和
|
||||
if (value.type === 'expensive') {
|
||||
billSummaryStats.expensive += value.amount
|
||||
if (value.type === 'expense') {
|
||||
billSummaryStats.expense += value.amount
|
||||
} else {
|
||||
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
|
||||
} else if (billSummaryStats.income === 0) {
|
||||
billSummaryStats.rate = 1
|
||||
} else {
|
||||
billSummaryStats.rate = Math.min(billSummaryStats.expensive / billSummaryStats.income, 1)
|
||||
billSummaryStats.rate = Math.min(billSummaryStats.expense / billSummaryStats.income, 1)
|
||||
}
|
||||
|
||||
return billSummaryStats
|
||||
|
||||
@@ -152,7 +152,7 @@ const initImageFileList = () => {
|
||||
* @param type 账单类型
|
||||
*/
|
||||
const getBillTypeName = (type: string) => {
|
||||
return type === 'expensive' ? '支出' : '收入'
|
||||
return type === 'expense' ? '支出' : '收入'
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<div v-else class="bill-search-list card-item">
|
||||
<div class="search-result-title">
|
||||
<span>收入:{{ formatAmount(getTotalAmount(billStore.billRecordList, 'income')) }}</span>
|
||||
<span>支出:{{ formatAmount(getTotalAmount(billStore.billRecordList, 'expensive')) }}</span>
|
||||
<span>支出:{{ formatAmount(getTotalAmount(billStore.billRecordList, 'expense')) }}</span>
|
||||
</div>
|
||||
<daily-card v-for="(item, index) in billStore.billRecordList"
|
||||
:key="index" @click="selectBillRecordClick(item)"
|
||||
|
||||
Reference in New Issue
Block a user