용어어등록수정

This commit is contained in:
khj0414 2025-03-17 13:55:59 +09:00
parent de9c8d5638
commit 4962ff4c92

View File

@ -166,56 +166,40 @@ const saveWord = () => {
} }
const wordData = { const wordData = {
id: props.NumValue || null, id: props.NumValue || null,
title: computedTitle.value, title: computedTitle.value.trim(),
category: selectedCategory.value, category: selectedCategory.value,
content: content.value, content: content.value,
}; };
if(valid){ if(valid){
emit('addWord', wordData, addCategory.value === '' emit('addWord', wordData, addCategory.value.trim() === ''
? (isNaN(selectedCategory.value) ? selectedCategory.value : Number(selectedCategory.value)) ? (isNaN(selectedCategory.value) ? selectedCategory.value : Number(selectedCategory.value))
: addCategory.value); : addCategory.value);
} }
} }
// focusout // focusout
const handleCategoryFocusout = (value) => { const handleCategoryFocusout = (value) => {
if (!value || value.trim() === '') {
return;
}
const valueTrim = value.trim(); const valueTrim = value.trim();
if(value){ const existingCategory = props.dataList.find(item => item.label === valueTrim);
const existingCategory = props.dataList.find(item => item.label === valueTrim);
// if (existingCategory) {
if(valueTrim == ''){ addCategoryAlert.value = true;
addCategoryAlert.value = true;
// focus // focus
setTimeout(() => { setTimeout(() => {
const inputElement = categoryInputRef.value?.$el?.querySelector('input'); const inputElement = categoryInputRef.value?.$el?.querySelector('input');
if (inputElement) { if (inputElement) {
inputElement.focus(); inputElement.focus();
} }
}, 0); }, 0);
} else {
addCategoryAlert.value = false;
}else if (existingCategory) {
addCategoryAlert.value = true;
// focus
setTimeout(() => {
const inputElement = categoryInputRef.value?.$el?.querySelector('input');
if (inputElement) {
inputElement.focus();
}
}, 0);
} else {
addCategoryAlert.value = false;
}
} }
}; };
</script> </script>
<style scoped> <style scoped>