Skip to content

Commit

Permalink
Merge branch 'development' into econ-sense-vite-press
Browse files Browse the repository at this point in the history
  • Loading branch information
Chuiantw1212 committed May 10, 2024
2 parents 398ad1a + 9346a86 commit 702de1b
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 19 deletions.
74 changes: 57 additions & 17 deletions components/calculator/benchmark.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
<template>
<el-card>
<el-card v-loading="storyLoading">
<template #header>
<div class="card-header card-header--custom">
<span>回顧與匯出
</span>
<div>
<el-button v-if="!modelValue.profile.story" v-loading="storyLoading"
@click="generatStory">回顧</el-button>
<el-button v-if="!profile.story" @click="generatStory">用15秒產生回顧</el-button>
<el-button v-else @click="generatStory">重新產生回顧</el-button>
<el-button @click="exportUserForm()">匯出</el-button>
</div>
</div>
</template>
<el-form label-width="auto">
<div v-if="modelValue.profile.story" v-html="modelValue.profile.story">
<div v-if="profile.story" v-html="profile.story">

</div>
<div v-else>
Expand All @@ -34,7 +33,7 @@
</el-card>
</template>
<script setup lang="ts">
import { ref, computed, shallowRef, reactive, watch } from 'vue'
import { ref, computed, } from 'vue'
const { VITE_BASE_URL } = import.meta.env
const emits = defineEmits(['update:modelValue', 'export'])
const storyLoading = ref(false)
Expand All @@ -43,16 +42,60 @@ const props = defineProps({
type: Object,
default: () => {
return {}
}
},
required: true
},
config: {
type: Object,
default: () => {
return {}
}
},
required: true
},
career: {
type: Object,
default: () => {
return {}
},
required: true
},
spouse: {
type: Object,
default: () => {
return {}
},
required: true
},
mortgage: {
type: Object,
default: () => {
return {}
},
required: true
},
parenting: {
type: Object,
default: () => {
return {}
},
required: true
},
retirement: {
type: Object,
default: () => {
return {}
},
required: true
},
estatePrice: {
type: Object,
default: () => {
return {}
},
required: true
},
})
const userForm = computed(() => {
const profile = computed(() => {
return props.modelValue
})
Expand All @@ -66,19 +109,16 @@ async function generatStory() {
})
const resJson = await res.text()
storyLoading.value = false
userForm.value.profile.story = resJson
emits('update:modelValue', userForm.value)
profile.value.story = resJson
emits('update:modelValue', profile.value)
}
function getHumanStory() {
const { profile, spouse, parenting, mortgage, estatePrice, career, retirement } = userForm.value
const { spouse, parenting, mortgage, estatePrice, career, retirement } = props
const { counties = [], insuranceTypes = [], townMap = {} } = props.config
const { yearOfBirth, age: profileAge, lifeExpectancy: profilelifeExpectancy, careerInsuranceType } = profile
const { yearOfBirth, age: profileAge, lifeExpectancy: profilelifeExpectancy, careerInsuranceType } = profile.value
const { careerHeadCount, } = career
const { age: retireAge, qualityLevel, futureSeniority, insurance } = retirement
const { age: retireAge, qualityLevel, insurance } = retirement
const { yearOfMarriage } = spouse
const { headCount, independantAge } = parenting
const { downpayYear } = mortgage
Expand All @@ -87,7 +127,7 @@ function getHumanStory() {
const totalAge = profileAge + profilelifeExpectancy
let story = ``
// profile
story += `你於${Math.floor(yearOfBirth)}年,來到個世界上`
story += `你於${Math.floor(yearOfBirth)}年,誕生到個世界上`
story += `於${Math.floor(yearOfBirth + totalAge)}年時,悄悄的離開,`
story += `在這${Math.floor(totalAge)}間,你有著屬於自己的故事。`
// career
Expand Down
6 changes: 4 additions & 2 deletions components/calculator/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@

<h2 id="_試算結果" tabindex="-1">試算結果<a class="header-anchor" href="#試算結果"
aria-label="Permalink to &quot;試算結果&quot;">&ZeroWidthSpace;</a></h2>
<Bechmark v-model="userForm" :config="config" @update:model-value="onProfileChanged()"
@export="exportUserForm()">
<Bechmark v-model="userForm.profile" :config="config" :career="userForm.career"
:retirement="userForm.retirement" :spouse="userForm.spouse" :asset="userForm.asset"
:estateSize="userForm.estateSize" :parenting="userForm.parenting" :estatePrice="userForm.estatePrice"
:mortgage="userForm.mortgage" @update:model-value="onProfileChanged()" @export="exportUserForm()">
</Bechmark>
<br>
</div>
Expand Down

0 comments on commit 702de1b

Please sign in to comment.