용어집 수정정
This commit is contained in:
parent
fe00b53e4f
commit
213329198f
@ -17,7 +17,7 @@
|
|||||||
<PlusBtn v-if="userStore.user.role == 'ROLE_ADMIN'" @click="toggleInput"/>
|
<PlusBtn v-if="userStore.user.role == 'ROLE_ADMIN'" @click="toggleInput"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row" v-if="showInput">
|
<div class="row" v-if="showInput">
|
||||||
<div class="col-10">
|
<div class="col-10">
|
||||||
<FormInput title="카테고리 입력" name="카테고리" @update:modelValue="addCategory = $event" :is-alert="addCategoryAlert"/>
|
<FormInput title="카테고리 입력" name="카테고리" @update:modelValue="addCategory = $event" :is-alert="addCategoryAlert"/>
|
||||||
@ -83,12 +83,12 @@ const addCategoryAlert = ref(false);
|
|||||||
const selectCategory = ref('');
|
const selectCategory = ref('');
|
||||||
|
|
||||||
// 제목 상태
|
// 제목 상태
|
||||||
const computedTitle = computed(() =>
|
const computedTitle = computed(() =>
|
||||||
wordTitle.value === '' ? props.titleValue : wordTitle.value
|
wordTitle.value === '' ? props.titleValue : wordTitle.value
|
||||||
);
|
);
|
||||||
|
|
||||||
// 카테고리 상태
|
// 카테고리 상태
|
||||||
const selectedCategory = computed(() =>
|
const selectedCategory = computed(() =>
|
||||||
selectCategory.value === '' ? props.formValue : selectCategory.value
|
selectCategory.value === '' ? props.formValue : selectCategory.value
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -138,8 +138,16 @@ const onChange = (newValue) => {
|
|||||||
|
|
||||||
//용어 등록
|
//용어 등록
|
||||||
const saveWord = () => {
|
const saveWord = () => {
|
||||||
|
|
||||||
|
// if(addCategory.value == ''){
|
||||||
|
// addCategoryAlert.value = true;
|
||||||
|
// return;
|
||||||
|
// }else {
|
||||||
|
// addCategoryAlert.value = false;
|
||||||
|
// }
|
||||||
|
|
||||||
//validation
|
//validation
|
||||||
|
|
||||||
// 용어 체크
|
// 용어 체크
|
||||||
if(computedTitle.value == '' || computedTitle.length == 0){
|
if(computedTitle.value == '' || computedTitle.length == 0){
|
||||||
wordTitleAlert.value = true;
|
wordTitleAlert.value = true;
|
||||||
@ -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>
|
||||||
|
|
||||||
@ -173,4 +180,4 @@ const saveWord = () => {
|
|||||||
margin-top: 2.5rem
|
margin-top: 2.5rem
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -102,14 +102,14 @@
|
|||||||
const { cateList } = commonApi({
|
const { cateList } = commonApi({
|
||||||
loadCateList: true
|
loadCateList: true
|
||||||
});
|
});
|
||||||
|
|
||||||
const selectedCategory = ref('');
|
const selectedCategory = ref('');
|
||||||
const selectCategory = ref('');
|
const selectCategory = ref('');
|
||||||
|
|
||||||
// 체크박스 체크된 갯수
|
// 체크박스 체크된 갯수
|
||||||
const checkedItems = ref([]);
|
const checkedItems = ref([]);
|
||||||
// 체크박스의 name
|
// 체크박스의 name
|
||||||
const checkedNames = ref([]);
|
const checkedNames = ref([]);
|
||||||
|
|
||||||
|
|
||||||
//선택된 알파벳
|
//선택된 알파벳
|
||||||
@ -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) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user