I have a system that registers proyectos
and people who can have 1.n projects, and I need to send the id
of a select
multiple to a query GetMapping
of java to warn that a persona
You have a project assigned.
<el-form-item label="Asignar a:" prop="person">
<el-select v-model="form.persons" multiple value-key="id"
v-on:change="getData(person_id)" id="person_id placeholder="Seleccione personal" class="max-input" filterable>
<el-option v-for="person in orderedPersons"
:label="person.name +' '+ person.last_name"
:key="person.id"
:value="person">
</el-option>
</el-select>
</el-form-item>
Computed
computed: {
orderedPersons: function () {
return _.sortBy(this.persons, 'name')
},
Method java Getmapping
@GetMapping("/person/hasproject/{id}")
public ResponseEntity getIfPersonHasProject(@PathVariable(value = "id") Long person_id) {
try {
HttpStatus status = HttpStatus.OK;
if (!service.findByPersonId(person_id???).isEmpty()) {
return ResponseEntity.status(status).body(new responseMessage(status.value(), null, getLocaleMessage("success.project.exist")));
}
}catch (Exception e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new responseMessage(HttpStatus.INTERNAL_SERVER_ERROR.value(), e.getMessage(), getLocaleMessage("error.internal_error")));
}
return null;
}
Vue method that calls that query (Enhanced)
methods: {
getData(el id de la persona que selecciono?) {
this.$axios.get("/person/hasproject/" + person_id ???).then(response => {
try {
notifications_success(response.data.userMessage);
} catch (error) {
notifications_error('La persona no tiene proyectos');
}
});
},
In summary, how can I pass to that query the id
of the persona
selected in select
multiple