diff --git a/src/components/wordDict/DictCard.vue b/src/components/wordDict/DictCard.vue index 4c2ac0b..3eae3d7 100644 --- a/src/components/wordDict/DictCard.vue +++ b/src/components/wordDict/DictCard.vue @@ -122,6 +122,9 @@ const addCategory = (data) => { : null; const newValue = lastCategory ? lastCategory.value + 1 : 600101; + // console.log('lastCategory', lastCategory); + // console.log('newValue', newValue); + axios.post('worddict/insertCategory', { CMNCODNAM: data }).then(res => { @@ -130,9 +133,15 @@ const addCategory = (data) => { const newCategory = { label: data, value: newValue }; localCateList.value = [newCategory, ...localCateList.value]; selectedCategory.value = newCategory.value; + + // console.log('newCategory', newCategory); + // console.log('localCateList.value', localCateList.value); + // console.log('selectedCategory.value', selectedCategory.value); // 부모에게 전달 emit('update:cateList', localCateList.value); + } else if(res.data.message == '이미 존재하는 카테고리명입니다.') { + toastStore.onToast(res.data.message, 'e'); } }).catch(err => { console.error('카테고리 추가 중 오류:', err); @@ -145,11 +154,11 @@ const addCategory = (data) => { // 용어집 수정 const editWord = (data) => { - console.log('📌 수정할 데이터:', data); - console.log('📌 수정할 데이터:', data.id); - console.log('📌 수정할 데이터:', data.category); - console.log('📌 수정할 데이터:', data.title); - console.log('📌 수정할 데이터:', $common.deltaAsJson(data.content)); + // console.log('📌 수정할 데이터:', data); + // console.log('📌 수정할 데이터:', data.id); + // console.log('📌 수정할 데이터:', data.category); + // console.log('📌 수정할 데이터:', data.title); + // console.log('📌 수정할 데이터:', $common.deltaAsJson(data.content)); if (!data.id) { console.error('❌ 수정할 데이터의 ID가 없습니다.'); @@ -208,7 +217,6 @@ const toggleCheck = (event) => { top: 1.2rem; } - .admin-chk { position: absolute; left: -0.5rem; diff --git a/src/views/wordDict/wordDict.vue b/src/views/wordDict/wordDict.vue index d027485..a4b3a27 100644 --- a/src/views/wordDict/wordDict.vue +++ b/src/views/wordDict/wordDict.vue @@ -48,7 +48,7 @@ v-for="item in wordList" :key="item.WRDDICSEQ" :item="item" - :cateList="cateList" + v-model:cateList="cateList" @refreshWordList="getwordList" @updateChecked="updateCheckedItems" /> @@ -61,7 +61,7 @@ - @@ -209,18 +209,43 @@ const updateCheckedItems = (checked, id, name) => { if (checked) { checkedItems.value.push(id); - checkedNames.value.push(name); + checkedNames.value.push(Number(name)); } else { checkedItems.value = checkedItems.value.filter(item => item !== id); checkedNames.value = checkedNames.value.filter(item => item !== name); } // 콘솔에 현재 체크된 name 값 출력 - console.log("현재 체크된 name 값:", checkedNames.value); + // console.log("현재 체크된 name 값:", checkedNames.value); }; const isAnyChecked = computed(() => checkedItems.value.length > 0); + // 용어집 삭제 + const deleteCheckedItems = () => { + // console.log("현재 체크된 name 값:", Object.values(checkedNames.value)); + + axios.patch('worddict/deleteword', { + idList: Object.values(checkedNames.value) + }) + .then(res => { + if (res.data.status == 'OK') { + toastStore.onToast('용어 삭제가 완료되었습니다.', 's'); + isWriteVisible.value = false; + getwordList(); + + // 삭제 후 초기화 + checkedItems.value = []; + checkedNames.value = []; + } + }) + .catch(error => { + console.error('삭제 요청 중 오류 발생:', error); + toastStore.onToast('오류가 발생했습니다. 다시 시도해주세요.', 'e'); + }); + + }; +