diff --git a/src/components/wordDict/DictAlphabetFilter.vue b/src/components/wordDict/DictAlphabetFilter.vue index feed26e..902ea28 100644 --- a/src/components/wordDict/DictAlphabetFilter.vue +++ b/src/components/wordDict/DictAlphabetFilter.vue @@ -1,56 +1,86 @@ diff --git a/src/components/wordDict/DictWrite.vue b/src/components/wordDict/DictWrite.vue index ceaa999..94a153b 100644 --- a/src/components/wordDict/DictWrite.vue +++ b/src/components/wordDict/DictWrite.vue @@ -11,16 +11,17 @@ @change="onChange" :value="formValue" :disabled="isDisabled" + :isEssential="true" />
- +
- +const computedTitle = computed(() => wordTitle.value === '' ? props.titleValue : wordTitle.value ); // 카테고리 상태 -const selectedCategory = computed(() => +const selectedCategory = computed(() => selectCategory.value === '' ? props.formValue : selectCategory.value + ); // 카테고리 입력 중복 ref @@ -106,7 +108,7 @@ const props = defineProps({ },contentValue : { type:String, }, - isDisabled: { + isDisabled: { type: Boolean, default: false } @@ -132,7 +134,7 @@ const saveWord = () => { if(computedTitle.value != undefined){ computedTitleTrim = computedTitle.value.trim() } - + // 용어 체크 if(computedTitleTrim == undefined || computedTitleTrim == ''){ wordTitleAlert.value = true; @@ -144,7 +146,7 @@ const saveWord = () => { // 내용 확인 let inserts = []; if (inserts.length === 0 && content.value?.ops?.length > 0) { - inserts = content.value.ops.map(op => + inserts = content.value.ops.map(op => typeof op.insert === 'string' ? op.insert.trim() : op.insert ); } @@ -154,16 +156,15 @@ const saveWord = () => { wordContentAlert.value = true; return; } - - const wordData = { id: props.NumValue || null, title: computedTitle.value, category: selectedCategory.value, content: content.value, }; - - emit('addWord', wordData, addCategory.value); + emit('addWord', wordData, addCategory.value === '' + ? (isNaN(selectedCategory.value) ? selectedCategory.value : Number(selectedCategory.value)) + : addCategory.value); } @@ -172,11 +173,11 @@ const handleCategoryFocusout = (value) => { const valueTrim = value.trim(); const existingCategory = props.dataList.find(item => item.label === valueTrim); - + // 카테고리 입력시 공백 if(valueTrim == ''){ addCategoryAlert.value = true; - + // 공백시 강제 focus setTimeout(() => { const inputElement = categoryInputRef.value?.$el?.querySelector('input'); @@ -185,10 +186,10 @@ const handleCategoryFocusout = (value) => { } }, 0); - + }else if (existingCategory) { addCategoryAlert.value = true; - + // 중복시 강제 focus setTimeout(() => { const inputElement = categoryInputRef.value?.$el?.querySelector('input'); @@ -215,4 +216,4 @@ const handleCategoryFocusout = (value) => { margin-top: 2.5rem } } - \ No newline at end of file + diff --git a/src/views/wordDict/wordDict.vue b/src/views/wordDict/wordDict.vue index 3703c01..be95d5b 100644 --- a/src/views/wordDict/wordDict.vue +++ b/src/views/wordDict/wordDict.vue @@ -1,42 +1,31 @@