diff --git a/htdocs/RouteRecall.vue b/htdocs/RouteRecall.vue index 0126fa2..3458e11 100644 --- a/htdocs/RouteRecall.vue +++ b/htdocs/RouteRecall.vue @@ -62,10 +62,8 @@ client: Object }, data() { - var resources = state.resources; var today = dateonly(new Date()); return { - selection: resources ? (resources.split(',').filter(x => x) || []) : [], patients: [], production: true, date_begin: new Date(today.getFullYear() - 1, today.getMonth(), today.getDate()), @@ -74,6 +72,10 @@ }; }, computed: { + selection: { + get() { return state.resources ? (state.resources.split(',').filter(x => x) || []) : [] }, + set(value) { state.resources = value.join(','); } + }, patients_lost() { return this.patients.filter(x => x.TimeLastDiff >= 0).sort((a, b) => b.TimeLastDiff - a.TimeLastDiff); }, @@ -82,8 +84,9 @@ } }, watch: { - selection(value) { - this.debounced_selection(value); + selection: { + handler(value) { this.$nextTick(() => this.debounced_selection(value)); }, + immediate: true } }, methods: { @@ -95,7 +98,6 @@ }, created() { this.debounced_selection = debounce(async function(value) { - state.resources = value.join(','); var patients = this.selection.length > 0 ? groupByArray(await this.client.SDEC_CLINLET(this.selection.join('|') + '|', strftime_vista(this.date_begin), strftime_vista(this.date_end)), x => x.HRN) : [], now = new Date(), group, values, appt; for(var i = patients.length - 1; i >= 0; --i) { group = patients[i]; diff --git a/htdocs/RouteSchedule.vue b/htdocs/RouteSchedule.vue index e293560..33f458c 100644 --- a/htdocs/RouteSchedule.vue +++ b/htdocs/RouteSchedule.vue @@ -37,16 +37,15 @@ client: Object }, data() { - var resources = state.resources; return { - selection: resources ? (resources.split(',').filter(x => x) || []) : [], date: dateonly(new Date()), date_end: dateonly(new Date()) }; }, - watch: { - selection(value, oldvalue) { - state.resources = value.join(','); + computed: { + selection: { + get() { return state.resources ? (state.resources.split(',').filter(x => x) || []) : [] }, + set(value) { state.resources = value.join(','); } } } };