Guarantee dfn update with route change

This commit is contained in:
Jiang Yio 2022-09-23 02:20:13 -04:00
parent 2c28b85a10
commit 57e285108e

View File

@ -1,7 +1,7 @@
<template> <template>
<div v-if="info"> <div v-if="info">
<div class="card mb-3 shadow"> <div class="card mb-3 shadow">
<div class="card-header">{{info.name}} #{{$route.params.id}} ${{info.pid}}</div> <div class="card-header">{{info.name}} #{{dfn}} ${{info.pid}}</div>
<div class="card-body row" style="font-family: monospace;"> <div class="card-body row" style="font-family: monospace;">
<div class="col" v-if="info.dob"><strong>DOB:</strong> {{strptime_vista(info.dob).toLocaleDateString('en-CA')}}</div> <div class="col" v-if="info.dob"><strong>DOB:</strong> {{strptime_vista(info.dob).toLocaleDateString('en-CA')}}</div>
<div class="col" v-if="info.age"><strong>Age:</strong> {{info.age}}</div> <div class="col" v-if="info.age"><strong>Age:</strong> {{info.age}}</div>
@ -18,7 +18,7 @@
<DateRangePicker range="1M" direction="-1" v-model:date="vitals_date" v-model:date_end="vitals_date_begin" /> <DateRangePicker range="1M" direction="-1" v-model:date="vitals_date" v-model:date_end="vitals_date_begin" />
</div> </div>
<div class="card-body"> <div class="card-body">
<ViewVitalsLabs :client="client" :dfn="$route.params.id" :date_begin="vitals_date_begin" :date_end="vitals_date" /> <ViewVitalsLabs :client="client" :dfn="dfn" :date_begin="vitals_date_begin" :date_end="vitals_date" />
</div> </div>
</div> </div>
</div> </div>
@ -41,6 +41,7 @@
}, },
data() { data() {
return { return {
dfn: null,
info: null, info: null,
vitals_date: now, vitals_date: now,
vitals_date_begin: now, vitals_date_begin: now,
@ -70,9 +71,13 @@
break; break;
} }
} }
} else this.info = await this.client.ORWPT16_ID_INFO(this.$route.params.id); } else {
this.dfn = this.$route.params.id;
this.info = await this.client.ORWPT16_ID_INFO(this.$route.params.id);
}
}, },
async beforeRouteUpdate(to, from, next) { async beforeRouteUpdate(to, from, next) {
this.dfn = to.params.id;
this.info = await this.client.ORWPT16_ID_INFO(to.params.id); this.info = await this.client.ORWPT16_ID_INFO(to.params.id);
next(); next();
} }