nuVistA/htdocs/RouteSchedule.vue

68 lines
1.8 KiB
Vue
Raw Normal View History

2022-09-22 07:10:08 -04:00
<template>
2023-05-06 12:05:13 -04:00
<Subtitle value="Schedule" />
2023-05-16 22:04:37 -04:00
<div class="card mb-3 shadow">
<div class="card-header d-flex justify-content-between align-items-center">
<span>Schedule</span>
<router-link to="/settings">Select clinics<template v-if="selection.length > 0"> ({{selection.length}})</template></router-link>
2023-05-16 23:23:45 -04:00
<DateRangePicker direction="+1" v-model:date="date" v-model:date_end="date_end" v-model:range="range" />
2022-09-22 07:10:08 -04:00
</div>
2023-05-16 22:04:37 -04:00
<div class="card-body">
<ViewSchedule :client="client" :selection="selection" :date_begin="date" :date_end="new Date(date_end.getTime() - 1)" />
2022-09-22 07:10:08 -04:00
</div>
</div>
</template>
<script>
2023-05-06 12:05:13 -04:00
import Subtitle from './Subtitle.vue';
2022-09-22 07:10:08 -04:00
import DateRangePicker from './DateRangePicker.vue';
import ViewSchedule from './ViewSchedule.vue';
function dateonly(date) {
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
}
2023-05-16 23:23:45 -04:00
function localtime(s) {
var date = new Date(s);
date.setTime(date.getTime() + 60000*date.getTimezoneOffset());
return date;
}
2022-09-22 07:10:08 -04:00
export default {
components: {
2023-05-16 22:04:37 -04:00
Subtitle, DateRangePicker, ViewSchedule
2022-09-22 07:10:08 -04:00
},
props: {
client: Object
},
data() {
return {
date: dateonly(new Date()),
2023-05-16 23:23:45 -04:00
date_end: dateonly(new Date()),
range: '1D'
2022-09-22 07:10:08 -04:00
};
},
2022-09-28 01:28:11 -04:00
computed: {
2023-05-16 22:04:37 -04:00
selection() { return (this.client) && (this.client.remotestate.resources) ? (this.client.remotestate.resources.split(',').filter(x => x) || []) : [] }
2023-05-16 23:23:45 -04:00
},
watch: {
'$route.params.from': {
handler(value) {
this.date = dateonly(value ? localtime(value) : new Date());
}, immediate: true
},
'$route.params.to': {
handler(value) {
if(value) {
var date = localtime(value);
if(isNaN(date)) this.range = value;
else {
this.range = 'Range';
this.date_end = dateonly(date);
}
} else this.range = '1D';
}, immediate: true
}
2022-09-22 07:10:08 -04:00
}
};
</script>