This commit is contained in:
benguozakinci@gmail.com 2021-08-27 15:29:43 +03:00
parent d6f285211d
commit 714fd00971

View File

@ -27,7 +27,7 @@
v-model="search" v-model="search"
@input="onInput" @input="onInput"
:ref="'input-item-field-' + _uid" :ref="'input-item-field-' + _uid"
@keydown.enter="onItemCreate" @keydown.enter="inputEnterEvent"
/> />
</div> </div>
</span> </span>
@ -324,6 +324,12 @@ export default {
this.$emit('input', this.search); this.$emit('input', this.search);
}, },
inputEnterEvent(event) {
this.isItemMatched
? this.onItemSelected()
: this.onItemCreate()
},
async fetchMatchedItems() { async fetchMatchedItems() {
await window.axios.get(url + '/common/items?search="' + this.search + '" limit:10') await window.axios.get(url + '/common/items?search="' + this.search + '" limit:10')
.then(response => { .then(response => {
@ -347,7 +353,8 @@ export default {
.catch(error => {}); .catch(error => {});
}, },
onItemSelected(item) { onItemSelected() {
const item = this.item_list[0]
const indexeditem = { ...item, index: this.currentIndex }; const indexeditem = { ...item, index: this.currentIndex };
this.addItem(indexeditem, 'oldItem'); this.addItem(indexeditem, 'oldItem');
@ -381,9 +388,7 @@ export default {
tax_ids: [], tax_ids: [],
}; };
this.item_list.length === 1 this.newItems.push(item)
? item = this.item_list[0]
: this.newItems.push(item)
this.addItem(item, 'newItem'); this.addItem(item, 'newItem');
}, },