Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit21de804

Browse files
committed
add: 収支総計を追加
1 parent479f386 commit21de804

File tree

1 file changed

+79
-2
lines changed

1 file changed

+79
-2
lines changed

‎src/views/Home.vue‎

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<v-card>
44
<v-card-title>
55
<!-- 月選択-->
6-
<v-colcols="8">
6+
<v-colcols="8"sm="3">
77
<v-menu
88
ref="menu"
99
v-model="menu"
@@ -44,8 +44,41 @@
4444
<v-icon>mdi-plus</v-icon>
4545
</v-btn>
4646
</v-col>
47+
<!-- 収支総計-->
48+
<v-colclass="overflow-x-auto"cols="12"sm="8">
49+
<divclass="summary">
50+
<divclass="mr-4">
51+
<tableclass="text-right">
52+
<tr>
53+
<td>収入:</td>
54+
<td>{{ separate(sum.income) }}</td>
55+
</tr>
56+
<tr>
57+
<td>支出:</td>
58+
<td>{{ separate(sum.outgo) }}</td>
59+
</tr>
60+
<tr>
61+
<td>収支差:</td>
62+
<td>{{ separate(sum.income - sum.outgo) }}</td>
63+
</tr>
64+
</table>
65+
</div>
66+
<divv-for="category in sum.categories":key="category[0]">
67+
<v-progress-circular
68+
class="mr-2"
69+
:rotate="-90"
70+
:size="60"
71+
:width="5"
72+
:value="category[1]"
73+
color="teal"
74+
>
75+
{{ category[0] }}
76+
</v-progress-circular>
77+
</div>
78+
</div>
79+
</v-col>
4780
<!-- 検索フォーム-->
48-
<v-colcols="12">
81+
<v-colcols="12"sm="4">
4982
<v-text-field
5083
v-model="search"
5184
append-icon="mdi-magnify"
@@ -162,6 +195,41 @@ export default {
162195
/** テーブルのフッター設定*/
163196
footerProps () {
164197
return { itemsPerPageText:'', itemsPerPageOptions: [] }
198+
},
199+
200+
/** 収支総計*/
201+
sum () {
202+
let income=0
203+
let outgo=0
204+
constcategoryOutgo= {}
205+
constcategories= []
206+
207+
// 収支の合計とカテゴリ別の支出を計算
208+
for (constrowofthis.tableData) {
209+
if (row.income!==null) {
210+
income+=row.income
211+
}else {
212+
outgo+=row.outgo
213+
if (categoryOutgo[row.category]) {
214+
categoryOutgo[row.category]+=row.outgo
215+
}else {
216+
categoryOutgo[row.category]=row.outgo
217+
}
218+
}
219+
}
220+
221+
// カテゴリ別の支出を降順にソート
222+
constsorted=Object.entries(categoryOutgo).sort((a,b)=> b[1]- a[1])
223+
for (const [category,value]of sorted) {
224+
constpercent=parseInt((value/ outgo)*100)
225+
categories.push([category, percent])
226+
}
227+
228+
return {
229+
income,
230+
outgo,
231+
categories
232+
}
165233
}
166234
},
167235
@@ -215,3 +283,12 @@ export default {
215283
}
216284
}
217285
</script>
286+
287+
<style>
288+
.summary {
289+
display:flex;
290+
font-size:0.8rem;
291+
white-space:nowrap;
292+
line-height:1.2rem;
293+
}
294+
</style>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp