Computed property resource selection

This commit is contained in:
Jiang Yio 2022-09-28 01:28:11 -04:00
parent 93994d5dd7
commit 4477f4b5c7
2 changed files with 11 additions and 10 deletions

View File

@ -62,10 +62,8 @@
client: Object client: Object
}, },
data() { data() {
var resources = state.resources;
var today = dateonly(new Date()); var today = dateonly(new Date());
return { return {
selection: resources ? (resources.split(',').filter(x => x) || []) : [],
patients: [], patients: [],
production: true, production: true,
date_begin: new Date(today.getFullYear() - 1, today.getMonth(), today.getDate()), date_begin: new Date(today.getFullYear() - 1, today.getMonth(), today.getDate()),
@ -74,6 +72,10 @@
}; };
}, },
computed: { computed: {
selection: {
get() { return state.resources ? (state.resources.split(',').filter(x => x) || []) : [] },
set(value) { state.resources = value.join(','); }
},
patients_lost() { patients_lost() {
return this.patients.filter(x => x.TimeLastDiff >= 0).sort((a, b) => b.TimeLastDiff - a.TimeLastDiff); return this.patients.filter(x => x.TimeLastDiff >= 0).sort((a, b) => b.TimeLastDiff - a.TimeLastDiff);
}, },
@ -82,8 +84,9 @@
} }
}, },
watch: { watch: {
selection(value) { selection: {
this.debounced_selection(value); handler(value) { this.$nextTick(() => this.debounced_selection(value)); },
immediate: true
} }
}, },
methods: { methods: {
@ -95,7 +98,6 @@
}, },
created() { created() {
this.debounced_selection = debounce(async function(value) { 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; 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) { for(var i = patients.length - 1; i >= 0; --i) {
group = patients[i]; group = patients[i];

View File

@ -37,16 +37,15 @@
client: Object client: Object
}, },
data() { data() {
var resources = state.resources;
return { return {
selection: resources ? (resources.split(',').filter(x => x) || []) : [],
date: dateonly(new Date()), date: dateonly(new Date()),
date_end: dateonly(new Date()) date_end: dateonly(new Date())
}; };
}, },
watch: { computed: {
selection(value, oldvalue) { selection: {
state.resources = value.join(','); get() { return state.resources ? (state.resources.split(',').filter(x => x) || []) : [] },
set(value) { state.resources = value.join(','); }
} }
} }
}; };