용여집 수정정

This commit is contained in:
khj0414 2025-02-06 10:29:08 +09:00
parent c95a2ae80b
commit 67d5bede32
2 changed files with 69 additions and 16 deletions

View File

@ -1,18 +1,28 @@
<template>
<div class="d-flex">
<FormSelect :isLabel="false" :data="formattedDataList" :isCommon="true" name="용어집 카테고리" title="용어집 카테고리"/>
<button @click="toggleInput">+</button>
<FormSelect name="cate"
title="카테고리"
:data="formattedDataList"
:is-common="true"
@update:data="selectCategory = $event"
/> <button @click="toggleInput">+</button>
<div class="d-flex" v-if="showInput">
<FormInput :isLabel="false" title="용어집 입력" name="용어집 입력"/>
<FormInput :isLabel="false" title="카테고리" name="카테고리" @update:modelValue="addCategory = $event" :is-alert="addCategoryAlert"/>
<button @click="saveInput">저장</button>
</div>
</div>
<div>
<FormInput title="내용" name="용어집 내용 입력"/>
</div>
<FormInput
title="용어"
type="text"
name="word"
:is-essential="true"
:is-alert="wordTitleAlert"
@update:modelValue="wordTitle = $event"
/> </div>
<div>
<QEditor/>
<button>저장</button>
<QEditor @update:data="content = $event" @update:imageUrls="imageUrls = $event" :is-alert="true" />
<button @click="saveWord">저장</button>
<button @click="$emit('close')">취소</button>
</div>
</template>
@ -24,7 +34,20 @@ import QEditor from '@/components/editor/QEditor.vue';
import FormInput from '@/components/input/FormInput.vue';
import FormSelect from '@/components/input/FormSelect.vue';
const emit = defineEmits(['close']);
const emit = defineEmits(['close','addCategory','addWord']);
//
const wordTitle =ref('');
const addCategory =ref('');
const content = ref('');
const imageUrls = ref([]);
// Vaildation
const wordTitleAlert = ref(false);
const addcateAlert =ref(false);
const addCategoryAlert = ref(false);
//
const selectCategory = ref('');
const props = defineProps({
dataList: {
@ -46,12 +69,29 @@ const showInput = ref(false);
//
const toggleInput = () => {
howInput.value = !showInput.value;
showInput.value = !showInput.value;
};
//
const saveInput = () => {
console.log('입력값 저장됨!');
if( addCategory.value == ''){
addCategoryAlert.value = true;
return;
}
console.log('입력값 저장됨!',addCategory.value);
emit('addCategory', addCategory.value);
showInput.value = false;
};
</script>
//
const saveWord = () => {
//validation emit
const wordData = {
title: wordTitle.value,
category: selectCategory.value,
content: content.value,
};
emit('addWord', wordData);
};
</script>

View File

@ -30,7 +30,7 @@
<!-- 작성 -->
<div v-if="isWriteVisible" class="mt-5">
<DictWrite @close="isWriteVisible = false" :dataList="cateList"/>
<DictWrite @close="isWriteVisible = false" :dataList="cateList" @addCategory="addCategory"/>
</div>
</div>
@ -69,7 +69,9 @@
import DictCard from '@/components/wordDict/DictCard.vue';
import DictWrite from '@/components/wordDict/DictWrite.vue';
import DictAlphabetFilter from '@/components/wordDict/DictAlphabetFilter.vue';
import { useToastStore } from '@s/toastStore';
const toastStore = useToastStore();
//
const loading = ref(false);
@ -87,7 +89,7 @@
//
const selectedAlphabet = ref('');
//
const searchText = ref('');
@ -99,12 +101,12 @@
getwordList();
getwordCategory();
});
//
const getwordList = (searchKeyword='', indexKeyword='', category='') => {
axios.get('worddict/getWordList',{
//
params: {
params: {
searchKeyword : searchKeyword,
indexKeyword :indexKeyword,
category : category
@ -157,6 +159,17 @@
isWriteVisible.value = !isWriteVisible.value;
};
//
const addCategory = (data) =>{
axios.post('worddict/insertCategory',{
CMNCODNAM: data
}).then(res=>{
if(res.data.data == '1'){
toastStore.onToast('카테고리가 등록되었습니다.', 's');
}
})
}
//
</script>
@ -172,4 +185,4 @@
margin-bottom: 0.5rem !important;
}
}
</style>
</style>