Skip to content

Commit

Permalink
fixup! fixup! wip Use ESlint
Browse files Browse the repository at this point in the history
  • Loading branch information
azuki774 committed Sep 9, 2024
1 parent 6f4ebdb commit b24fe13
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 61 deletions.
26 changes: 13 additions & 13 deletions components/History.vue
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
<script setup lang="ts">
import type { Record } from "@/interfaces";
const config = useRuntimeConfig(); // nuxt.config.ts に書いてあるコンフィグを読み出す
import type { Record } from "@/interfaces"
const config = useRuntimeConfig() // nuxt.config.ts に書いてあるコンフィグを読み出す
const recordList = ref<Record[]>()
const asyncData = await useFetch(
"/api/history",
{
key: `/api/history`,
}
);
)
const data = asyncData.data.value as Record[];
const data = asyncData.data.value as Record[]
// fetchデータを整形
if (data != undefined) { // 取得済の場合のみ
for (let d of data) {
d.datetime = d.datetime.slice(0, 19); // 2023-09-23T00:00:00+09:00 -> 2023-09-23T00:00:00
d.datetime = d.datetime.slice(0, 19) // 2023-09-23T00:00:00+09:00 -> 2023-09-23T00:00:00
}
}
recordList.value = data
async function showDeleteDialog(id: number): Promise<void> {
const userResponse: boolean = confirm("このデータを削除しますか");
const userResponse: boolean = confirm("このデータを削除しますか")
if (userResponse == true) {
console.log('delete: id=' + id);
console.log('delete: id=' + id)
const asyncDataBtn = await useAsyncData(
`record`,
(): Promise<any> => {
const param = { 'id': id };
const paramStr = "?id=" + param['id'];
const param = { 'id': id }
const paramStr = "?id=" + param['id']
const localurl = "/api/deleteRecord" + paramStr
const response = $fetch(localurl);
return response;
const response = $fetch(localurl)
return response
}
);
)
location.reload()
}
};
}
</script>

Expand Down
16 changes: 8 additions & 8 deletions components/PostRecord.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<script setup lang="ts">
import type { Category } from "@/interfaces";
const config = useRuntimeConfig(); // nuxt.config.ts に書いてあるコンフィグを読み出す
import type { Category } from "@/interfaces"
const config = useRuntimeConfig() // nuxt.config.ts に書いてあるコンフィグを読み出す
const selector = ref<any>()
const categoryList = ref<Category[]>()
const asyncData = await useFetch(
"/api/getCategories",
{
key: `/api/getCategories`,
}
);
)
const data = asyncData.data.value as Category[];
const data = asyncData.data.value as Category[]
// category 加工
if (data != undefined) { // 取得済の場合のみ
Expand All @@ -36,12 +36,12 @@ const postButton = async (): Promise<void> => {
const param = { 'price': priceBox.value, 'category_id': send_category_id }
const paramStr = "?price=" + param['price'] + "&category_id=" + param['category_id']
const localurl = "/api/postRecord" + paramStr
const response = $fetch(localurl);
return response;
const response = $fetch(localurl)
return response
}
);
)
location.reload()
};
}
</script>

Expand Down
1 change: 0 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export default withNuxt(
},
stylistic.configs.customize({
indent: 2, // インデントはスペース2
quotes: 'single', // クオートはシングル
semi: false, // セミコロンは不要
}),
)
6 changes: 3 additions & 3 deletions pages/index.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import type Year from './summary/[year].vue';
import type Year from './summary/[year].vue'
const today = new Date();
let thisYear = today.getFullYear();
const today = new Date()
let thisYear = today.getFullYear()
</script>


Expand Down
72 changes: 36 additions & 36 deletions pages/summary/[year].vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import type { SummaryOne } from "@/interfaces";
const config = useRuntimeConfig(); // nuxt.config.ts に書いてあるコンフィグを読み出す
import type { SummaryOne } from '@/interfaces'
const config = useRuntimeConfig() // nuxt.config.ts に書いてあるコンフィグを読み出す
const incomeList = ref<SummaryOne[]>()
const incomeSumList = ref<SummaryOne>()
const outgoingList = ref<SummaryOne[]>()
Expand All @@ -16,9 +16,9 @@ const asyncData = await useFetch(
{
key: `/api/summary`,
transform: (data: SummaryOne[]): SummaryOne[][] => {
let incomeArray: SummaryOne[] = [];
let outgoingArray: SummaryOne[] = [];
let investArray: SummaryOne[] = [];
let incomeArray: SummaryOne[] = []
let outgoingArray: SummaryOne[] = []
let investArray: SummaryOne[] = []
for (let d of data) {
if ([100, 101, 110].includes(d.category_id)) {
incomeArray.push(d)
Expand All @@ -34,14 +34,14 @@ const asyncData = await useFetch(
return retArray
}
}
);
)
if (asyncData.data.value != undefined) {
const incomeData = asyncData.data.value[0] as SummaryOne[];
const outgoingData = asyncData.data.value[1] as SummaryOne[];
const investData = asyncData.data.value[2] as SummaryOne[];
const incomeData = asyncData.data.value[0] as SummaryOne[]
const outgoingData = asyncData.data.value[1] as SummaryOne[]
const investData = asyncData.data.value[2] as SummaryOne[]
incomeList.value = incomeData
outgoingList.value = outgoingData
investList.value = investData
Expand All @@ -52,17 +52,17 @@ if (asyncData.data.value != undefined) {
category_name: "収入合計",
price: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
total: 0
};
}
for (let i: number = 0; i < 12; i++) {
let sum: number = 0;
let totalsum: number = 0;
let sum: number = 0
let totalsum: number = 0
for (let d of incomeData) {
sum += d.price[i];
totalsum += d.price[i];
sum += d.price[i]
totalsum += d.price[i]
}
incomeSumData.price[i] = sum;
incomeSumData.total += totalsum;
incomeSumData.price[i] = sum
incomeSumData.total += totalsum
}
incomeSumList.value = incomeSumData
Expand All @@ -72,16 +72,16 @@ if (asyncData.data.value != undefined) {
category_name: "支出合計",
price: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
total: 0
};
}
for (let i: number = 0; i < 12; i++) {
let sum: number = 0;
let totalsum: number = 0;
let sum: number = 0
let totalsum: number = 0
for (let d of outgoingData) {
sum += d.price[i];
totalsum += d.price[i];
sum += d.price[i]
totalsum += d.price[i]
}
outgoingSumData.price[i] = sum;
outgoingSumData.total += totalsum;
outgoingSumData.price[i] = sum
outgoingSumData.total += totalsum
}
outgoingSumList.value = outgoingSumData
Expand All @@ -91,17 +91,17 @@ if (asyncData.data.value != undefined) {
category_name: "投資合計",
price: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
total: 0
};
}
for (let i: number = 0; i < 12; i++) {
let sum: number = 0;
let totalsum: number = 0;
let sum: number = 0
let totalsum: number = 0
for (let d of investData) {
sum += d.price[i];
totalsum += d.price[i];
sum += d.price[i]
totalsum += d.price[i]
}
investSumData.price[i] = sum;
investSumData.total += totalsum;
investSumData.price[i] = sum
investSumData.total += totalsum
}
investSumList.value = investSumData
Expand All @@ -111,25 +111,25 @@ if (asyncData.data.value != undefined) {
category_name: "合計",
price: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
total: 0
};
}
for (let i: number = 0; i < 12; i++) {
AllSumData.price[i] = incomeSumData.price[i] - outgoingSumData.price[i] - investSumData.price[i];
AllSumData.price[i] = incomeSumData.price[i] - outgoingSumData.price[i] - investSumData.price[i]
}
AllSumData.total = incomeSumData.total - outgoingSumData.total - investSumData.total;
AllSumData.total = incomeSumData.total - outgoingSumData.total - investSumData.total
AllSumList.value = AllSumData
let AllSumWithoutInvestData: SummaryOne = {
category_id: 999,
category_name: "合計(投資除く)",
price: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
total: 0
};
}
for (let i: number = 0; i < 12; i++) {
AllSumWithoutInvestData.price[i] = incomeSumData.price[i] - outgoingSumData.price[i];
AllSumWithoutInvestData.price[i] = incomeSumData.price[i] - outgoingSumData.price[i]
}
AllSumWithoutInvestData.total = incomeSumData.total - outgoingSumData.total - investSumData.total;
AllSumWithoutInvestData.total = incomeSumData.total - outgoingSumData.total - investSumData.total
AllSumWithoutInvestList.value = AllSumWithoutInvestData
fetched = true // データ取得後のフラグを立てる
Expand Down

0 comments on commit b24fe13

Please sign in to comment.