fix: date select
This commit is contained in:
@@ -75,14 +75,15 @@
|
|||||||
</v-col>
|
</v-col>
|
||||||
|
|
||||||
<v-col cols="12" sm="6">
|
<v-col cols="12" sm="6">
|
||||||
<v-text-field
|
<v-date-input
|
||||||
v-model="profileForm.birthday"
|
v-model="birthdayDate"
|
||||||
class="mb-3"
|
class="mb-3"
|
||||||
color="primary"
|
color="primary"
|
||||||
density="comfortable"
|
density="comfortable"
|
||||||
hide-details="auto"
|
hide-details="auto"
|
||||||
label="生日"
|
label="生日"
|
||||||
type="date"
|
prepend-icon=""
|
||||||
|
prepend-inner-icon="mdi-calendar"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
/>
|
/>
|
||||||
</v-col>
|
</v-col>
|
||||||
@@ -350,7 +351,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { reactive, ref } from 'vue'
|
import { computed, reactive, ref } from 'vue'
|
||||||
import Layout from '@/components/layout/DefaultLayout.vue'
|
import Layout from '@/components/layout/DefaultLayout.vue'
|
||||||
import { useAppStore } from '@/stores/app'
|
import { useAppStore } from '@/stores/app'
|
||||||
|
|
||||||
@@ -380,6 +381,34 @@ const resultLevel = ref(store.selfAssessment.scoreLevel)
|
|||||||
const improvementsOptions = ['肌力', '平衡', '心肺', '柔軟度', '敏捷', '體脂/BMI']
|
const improvementsOptions = ['肌力', '平衡', '心肺', '柔軟度', '敏捷', '體脂/BMI']
|
||||||
const diseaseOptions = ['高血壓', '糖尿病', '高血脂', '心臟病', '關節退化', '骨質疏鬆']
|
const diseaseOptions = ['高血壓', '糖尿病', '高血脂', '心臟病', '關節退化', '骨質疏鬆']
|
||||||
|
|
||||||
|
const birthdayDate = computed<Date | null>({
|
||||||
|
get: () => parseDateString(profileForm.birthday),
|
||||||
|
set: value => {
|
||||||
|
profileForm.birthday = formatDateString(value)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
function parseDateString (value: string) {
|
||||||
|
const [year, month, day] = value.split('-').map(Number)
|
||||||
|
if (!year || !month || !day) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Date(year, month - 1, day)
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDateString (value: Date | null) {
|
||||||
|
if (!value) {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
|
const year = value.getFullYear()
|
||||||
|
const month = String(value.getMonth() + 1).padStart(2, '0')
|
||||||
|
const day = String(value.getDate()).padStart(2, '0')
|
||||||
|
|
||||||
|
return `${year}-${month}-${day}`
|
||||||
|
}
|
||||||
|
|
||||||
function getImprovementIcon (imp: string) {
|
function getImprovementIcon (imp: string) {
|
||||||
switch (imp) {
|
switch (imp) {
|
||||||
case '肌力': {
|
case '肌力': {
|
||||||
@@ -392,7 +421,7 @@ function getImprovementIcon (imp: string) {
|
|||||||
return 'mdi-heart-pulse'
|
return 'mdi-heart-pulse'
|
||||||
}
|
}
|
||||||
case '柔軟度': {
|
case '柔軟度': {
|
||||||
return 'mdi-human-stretching'
|
return 'mdi-human-handsup'
|
||||||
}
|
}
|
||||||
case '敏捷': {
|
case '敏捷': {
|
||||||
return 'mdi-run-fast'
|
return 'mdi-run-fast'
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
// Composables
|
// Composables
|
||||||
import { createVuetify, type ThemeDefinition } from 'vuetify'
|
import { createVuetify, type ThemeDefinition } from 'vuetify'
|
||||||
|
import { zhHant } from 'vuetify/locale'
|
||||||
// Styles
|
// Styles
|
||||||
import '@mdi/font/css/materialdesignicons.css'
|
import '@mdi/font/css/materialdesignicons.css'
|
||||||
import 'vuetify/styles'
|
import 'vuetify/styles'
|
||||||
@@ -29,6 +30,16 @@ const HPTheme: ThemeDefinition = {
|
|||||||
|
|
||||||
// https://vuetifyjs.com/en/introduction/why-vuetify/#feature-guides
|
// https://vuetifyjs.com/en/introduction/why-vuetify/#feature-guides
|
||||||
export default createVuetify({
|
export default createVuetify({
|
||||||
|
locale: {
|
||||||
|
locale: 'zhHant',
|
||||||
|
fallback: 'zhHant',
|
||||||
|
messages: { zhHant },
|
||||||
|
},
|
||||||
|
date: {
|
||||||
|
locale: {
|
||||||
|
zhHant: 'zh-TW',
|
||||||
|
},
|
||||||
|
},
|
||||||
theme: {
|
theme: {
|
||||||
defaultTheme: 'HPTheme',
|
defaultTheme: 'HPTheme',
|
||||||
themes: { HPTheme },
|
themes: { HPTheme },
|
||||||
|
|||||||
Reference in New Issue
Block a user