용어집 수정정
This commit is contained in:
parent
fe00b53e4f
commit
213329198f
@ -138,6 +138,14 @@ const onChange = (newValue) => {
|
||||
|
||||
//용어 등록
|
||||
const saveWord = () => {
|
||||
|
||||
// if(addCategory.value == ''){
|
||||
// addCategoryAlert.value = true;
|
||||
// return;
|
||||
// }else {
|
||||
// addCategoryAlert.value = false;
|
||||
// }
|
||||
|
||||
//validation
|
||||
|
||||
// 용어 체크
|
||||
@ -158,8 +166,7 @@ const saveWord = () => {
|
||||
category: selectedCategory.value,
|
||||
content: content.value,
|
||||
};
|
||||
|
||||
emit('addWord', wordData);
|
||||
emit('addWord', wordData ,addCategory.value );
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
@ -177,34 +177,58 @@
|
||||
const addCategory = (data) =>{
|
||||
const lastCategory = cateList.value[cateList.value.length - 1];
|
||||
const newValue = lastCategory ? lastCategory.value + 1 : 600101;
|
||||
axios.post('worddict/insertCategory',{
|
||||
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');
|
||||
// axios.post('worddict/insertCategory',{
|
||||
// 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) => {
|
||||
let category = null;
|
||||
// 카테고리 체크
|
||||
const existingCategory = cateList.value.find(item => item.label === data);
|
||||
if (existingCategory) {
|
||||
//카테고리 있을시 그냥 저장
|
||||
category = existingCategory.label == '' ? wordData.category : existingCategory.value;
|
||||
} else {
|
||||
//카테고리 없을시 카테고리 와 용어 둘다 저장
|
||||
console.log('카테고리 없음');
|
||||
const lastCategory = cateList.value[cateList.value.length - 1];
|
||||
category = lastCategory ? lastCategory.value + 1 : 600101;
|
||||
}
|
||||
//용어 등록
|
||||
const addWord = (wordData) => {
|
||||
axios.post('worddict/insertWord',{
|
||||
WRDDICCAT : wordData.category,
|
||||
sendWordRequest(category, wordData, data, !existingCategory);
|
||||
};
|
||||
const sendWordRequest = (category, wordData, data, isNewCategory) => {
|
||||
const payload = {
|
||||
WRDDICCAT: category,
|
||||
WRDDICTTL: wordData.title,
|
||||
WRDDICCON: $common.deltaAsJson(wordData.content),
|
||||
}).then(res => {
|
||||
if(res.data.data == '1'){
|
||||
};
|
||||
|
||||
if (isNewCategory) {
|
||||
payload.CMNCODNAM = data; // 새로운 카테고리 추가 시 포함
|
||||
}
|
||||
axios.post('worddict/insertWord', payload).then(res => {
|
||||
if (res.data.status === 'OK') {
|
||||
toastStore.onToast('용어가 등록 되었습니다.', 's');
|
||||
isWriteVisible.value = false;
|
||||
getwordList();
|
||||
//카테고리 리스트 다시 조회 해야야함
|
||||
}
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
// 체크 상태 업데이트
|
||||
const updateCheckedItems = (checked, id, name) => {
|
||||
if (checked) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user