create event
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
<template lang="pug">
|
||||
.flex
|
||||
.flex
|
||||
.col
|
||||
base-input(v-model="fullName", debounce="1000")
|
||||
base-input(v-model="fullName", debounce="500", size="M" )
|
||||
.state(v-if="showMessageBar")
|
||||
.row
|
||||
.col {{ message }}
|
||||
.col
|
||||
q-btn(
|
||||
@click="createPerson"
|
||||
@click="createPerson"
|
||||
)
|
||||
q-icon(name="app:icon-plus", size="12px", left)
|
||||
span Создать
|
||||
.candidates
|
||||
.row.w-full(
|
||||
v-for="candidate in candidates",
|
||||
v-for="candidate in candidates",
|
||||
key="candidate.id",
|
||||
@click="pickPerson(candidate)"
|
||||
)
|
||||
@@ -30,7 +30,7 @@ export default {
|
||||
BaseInput,
|
||||
},
|
||||
mixins: [v_model],
|
||||
emits: ["createPerson", "update:modelValue"],
|
||||
emits: ["createPerson"],
|
||||
data() {
|
||||
return {
|
||||
fullName: "",
|
||||
@@ -39,22 +39,33 @@ export default {
|
||||
candidates: [],
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
pickedFullName() {
|
||||
return (
|
||||
this.value.last_name +
|
||||
" " +
|
||||
this.value.first_name +
|
||||
" " +
|
||||
this.value.patronymic
|
||||
);
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
fullName: {
|
||||
immediate: true,
|
||||
handler(val) {
|
||||
if (!val) return;
|
||||
fetchWrapper.get(`persons/?full_name=${val}`).then((result) => {
|
||||
this.candidates = result;
|
||||
this.showMessageBar = true;
|
||||
this.message = `Нужный ${val} не найден?`;
|
||||
});
|
||||
},
|
||||
fullName(val) {
|
||||
if (!val || val === this.pickedFullName) return;
|
||||
fetchWrapper.get(`persons/?full_name=${val}`).then((result) => {
|
||||
this.candidates = result;
|
||||
this.showMessageBar = true;
|
||||
this.message = `Нужный ${val} не найден?`;
|
||||
});
|
||||
},
|
||||
value() {
|
||||
this.fullName = this.pickedFullName;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
pickPerson(person) {
|
||||
this.$emit("update:modelValue", { ...person });
|
||||
this.value = { ...person };
|
||||
},
|
||||
createPerson() {
|
||||
this.$emit("createPerson");
|
||||
|
||||
Reference in New Issue
Block a user