Skip to content

Commit d5cf144

Browse files
committed
get export
1 parent 3e2af3e commit d5cf144

File tree

4 files changed

+90
-1
lines changed

4 files changed

+90
-1
lines changed

components/sumNutrients.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,19 @@
116116
<td style="width: 100%;"></td>
117117
</tr>
118118
</table>
119+
120+
<Button :label="$t('getExport')" @click="router.push('/export-text')"/>
121+
119122
</div>
120123
</template>
121124

122125
<script setup lang="ts">
123126
import {useNutrients} from "~/composables/nutrients/useNutrients";
124127
import numberWithCommas from "~/utils/numberWithCommas";
125128
import {useTdee} from "~/composables/tdee/useTdee";
129+
import {useRouter} from "#app";
130+
131+
const router = useRouter()
126132
127133
const {
128134
totalNutrients,

i18n.config.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ export default defineI18nConfig(() => ({
3636
excess:"excess",
3737
lack:"lack",
3838
reset:"reset",
39+
export:"export",
40+
getExport:"export",
41+
kcl:"kilocalories",
3942

4043
},
4144
fa: {
@@ -71,7 +74,10 @@ export default defineI18nConfig(() => ({
7174
required:"موردنیاز",
7275
excess:"مازاد",
7376
lack:"کمبود",
74-
reset:"ریست"
77+
reset:"ریست",
78+
export:"خروجی",
79+
getExport:"دریافت خروجی",
80+
kcl:"کیلوکاری",
7581
}
7682
}
7783
}))

layouts/empty.vue

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<template>
2+
<div>
3+
<slot/>
4+
</div>
5+
</template>
6+
7+
<script setup lang="ts">
8+
9+
</script>
10+
11+
<style scoped lang="scss">
12+
13+
</style>

pages/export-text.vue

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<template>
2+
<div>
3+
<SelectButton v-model="locale" :options="['fa', 'en']" aria-labelledby="lang" class="select-lang"/>
4+
<div style="user-select: text; margin: 20px 0 0 0">
5+
<div v-if="requiredCalories > 0">
6+
<span>{{ $t('dailyRequiredCalories') }}: {{ numberWithCommas(requiredCalories) }} {{ $t('kcl') }}</span>
7+
</div>
8+
9+
<div v-if="requiredPortion[0] > 0">
10+
<span>{{ $t('dailyRequiredPortions') }}: {{ numberWithCommas(requiredPortion[0]) }} {{ $t('to') }} {{ numberWithCommas(requiredPortion[1]) }} {{ $t('gram') }}</span>
11+
</div>
12+
13+
<br/>
14+
15+
<div v-for="(meal, index) in meals">
16+
{{ meal.mealName }} =>
17+
<span v-for="(food, iFood) in meal.foods">
18+
<span>
19+
{{ foods.find(i => i.fdc_id == food.fdc_id)?.[`name_${locale}`] }}
20+
</span>
21+
<span> ({{ numberWithCommas(food.amount) }} {{ $t('gram') }}) </span>
22+
<span v-if="iFood !== meal.foods.length-1"> - </span>
23+
</span>
24+
</div>
25+
26+
<br/>
27+
28+
29+
<div>
30+
<div v-if="totalNutrients.energy >0">{{ $t('total') }} {{ $t('energy') }}: {{numberWithCommas(totalNutrients.energy)}} {{ $t('kcl') }}</div>
31+
<div v-if="totalNutrients.portion >0">{{ $t('total') }} {{ $t('portion') }}: {{numberWithCommas(totalNutrients.portion)}} {{ $t('gram') }}</div>
32+
<div v-if="totalNutrients.carbohydrate >0">{{ $t('total') }} {{ $t('carbohydrate') }}: {{numberWithCommas(totalNutrients.carbohydrate)}} {{ $t('gram') }}</div>
33+
<div v-if="totalNutrients.sugar >0">{{ $t('total') }} {{ $t('sugar') }}: {{numberWithCommas(totalNutrients.sugar)}} {{ $t('gram') }}</div>
34+
<div v-if="totalNutrients.fiber >0">{{ $t('total') }} {{ $t('fiber') }}: {{numberWithCommas(totalNutrients.fiber)}} {{ $t('gram') }}</div>
35+
</div>
36+
37+
38+
</div>
39+
</div>
40+
</template>
41+
42+
<script setup lang="ts">
43+
import foods from "~/consts/foods";
44+
45+
definePageMeta({
46+
layout: "empty"
47+
})
48+
49+
const {locale} = useI18n()
50+
import {useNutrients} from "~/composables/nutrients/useNutrients";
51+
import {useTdee} from "~/composables/tdee/useTdee";
52+
import numberWithCommas from "~/utils/numberWithCommas";
53+
54+
const {
55+
meals,
56+
totalNutrients
57+
} = useNutrients()
58+
const {requiredCalories, requiredPortion} = useTdee()
59+
60+
</script>
61+
62+
<style scoped lang="scss">
63+
64+
</style>

0 commit comments

Comments
 (0)