Merge branch 'khj'

This commit is contained in:
khj0414 2025-02-24 13:21:20 +09:00
commit 02f0cda3b4
2 changed files with 59 additions and 28 deletions

View File

@ -138,6 +138,14 @@ const onChange = (newValue) => {
// //
const saveWord = () => { const saveWord = () => {
// if(addCategory.value == ''){
// addCategoryAlert.value = true;
// return;
// }else {
// addCategoryAlert.value = false;
// }
//validation //validation
// //
@ -158,8 +166,7 @@ const saveWord = () => {
category: selectedCategory.value, category: selectedCategory.value,
content: content.value, content: content.value,
}; };
emit('addWord', wordData ,addCategory.value );
emit('addWord', wordData);
}; };
</script> </script>

View File

@ -177,34 +177,58 @@
const addCategory = (data) =>{ const addCategory = (data) =>{
const lastCategory = cateList.value[cateList.value.length - 1]; const lastCategory = cateList.value[cateList.value.length - 1];
const newValue = lastCategory ? lastCategory.value + 1 : 600101; const newValue = lastCategory ? lastCategory.value + 1 : 600101;
axios.post('worddict/insertCategory',{ const newCategory = { label: data, value: newValue };
CMNCODNAM: data
}).then(res => {
if(res.data.data == '1'){
toastStore.onToast('카테고리가 추가 등록 되었습니다.', 's');
const newCategory = { label: data, value: newValue };
cateList.value = [newCategory, ...cateList.value]; cateList.value = [newCategory, ...cateList.value];
selectedCategory.value = newCategory.value; selectedCategory.value = newCategory.value;
} else if(res.data.message == '이미 존재하는 카테고리명입니다.') { // axios.post('worddict/insertCategory',{
toastStore.onToast(res.data.message, 'e'); // CMNCODNAM: data
} // }).then(res => {
}) // if(res.data.data == '1'){
// toastStore.onToast(' .', 's');
// const newCategory = { label: data, value: newValue };
// cateList.value = [newCategory, ...cateList.value];
// selectedCategory.value = newCategory.value;
// } else if(res.data.message == ' .') {
// toastStore.onToast(res.data.message, 'e');
// }
// })
} }
// const addWord = (wordData, data) => {
const addWord = (wordData) => { let category = null;
axios.post('worddict/insertWord',{ //
WRDDICCAT : wordData.category, const existingCategory = cateList.value.find(item => item.label === data);
WRDDICTTL : wordData.title, if (existingCategory) {
WRDDICCON : $common.deltaAsJson(wordData.content), //
}).then(res => { category = existingCategory.label == '' ? wordData.category : existingCategory.value;
if(res.data.data == '1'){ } else {
//
console.log('카테고리 없음');
const lastCategory = cateList.value[cateList.value.length - 1];
category = lastCategory ? lastCategory.value + 1 : 600101;
}
sendWordRequest(category, wordData, data, !existingCategory);
};
const sendWordRequest = (category, wordData, data, isNewCategory) => {
const payload = {
WRDDICCAT: category,
WRDDICTTL: wordData.title,
WRDDICCON: $common.deltaAsJson(wordData.content),
};
if (isNewCategory) {
payload.CMNCODNAM = data; //
}
axios.post('worddict/insertWord', payload).then(res => {
if (res.data.status === 'OK') {
toastStore.onToast('용어가 등록 되었습니다.', 's'); toastStore.onToast('용어가 등록 되었습니다.', 's');
isWriteVisible.value = false; isWriteVisible.value = false;
getwordList(); getwordList();
//
} }
}) });
}; };
// //
const updateCheckedItems = (checked, id, name) => { const updateCheckedItems = (checked, id, name) => {
if (checked) { if (checked) {