용어집 입력 및 입력 수정 중

This commit is contained in:
Dang 2025-02-04 15:59:28 +09:00
parent 6f78a1e921
commit 69b5216963
5 changed files with 86 additions and 71 deletions

View File

@ -9,17 +9,17 @@
type="button" type="button"
class="btn" class="btn"
:class="{ :class="{
'btn-outline-primary': category !== selectedCategory, 'btn-outline-primary': category.CMNCODVAL !== selectedCategory,
'btn-primary': category === selectedCategory 'btn-primary': category.CMNCODVAL === selectedCategory
}" }"
@click="selectCategory(category)" @click="selectCategory(category.CMNCODVAL)"
>{{ category.CMNCODNAM }}</button> >{{ category.CMNCODNAM }}</button>
</li> </li>
</ul> </ul>
</template> </template>
<script setup> <script setup>
import { defineProps, ref } from 'vue'; import { defineProps, ref } from 'vue';
// lists prop // lists prop
const props = defineProps({ const props = defineProps({
@ -31,9 +31,10 @@ const props = defineProps({
// //
const selectedCategory = ref(null); const selectedCategory = ref(null);
const emit = defineEmits();
const selectCategory = (category) => { const selectCategory = (cate) => {
selectedCategory.value = category; selectedCategory.value = selectedCategory.value === cate ? null : cate;
emit('update:data', selectedCategory.value);
}; };
</script> </script>
@ -42,8 +43,4 @@ const selectCategory = (category) => {
.cate-list { .cate-list {
margin-left: -0.25rem; margin-left: -0.25rem;
} }
@media screen and (max-width:450px) {
}
</style> </style>

View File

@ -49,7 +49,7 @@ const selectAlphabet = (alphabet) => {
@media (max-width: 768px) { @media (max-width: 768px) {
.alphabet-list { .alphabet-list {
overflow: scroll; overflow-x: scroll;
flex-wrap: nowrap !important; flex-wrap: nowrap !important;
} }
} }

View File

@ -2,7 +2,7 @@
<li class="mt-5 card p-5"> <li class="mt-5 card p-5">
<div class="d-flex align-items-center"> <div class="d-flex align-items-center">
<div class="w-100 d-flex align-items-center"> <div class="w-100 d-flex align-items-center">
<span class="btn btn-primary">{{ item.category }}</span> <span class="btn btn-primary pe-none">{{ item.category }}</span>
<strong class="mx-2 w-75">{{ item.WRDDICTTL }}</strong> <strong class="mx-2 w-75">{{ item.WRDDICTTL }}</strong>
</div> </div>
<EditBtn /> <EditBtn />

View File

@ -1,11 +1,14 @@
<template> <template>
<div> <div class="d-flex">
<FormSelect/> <FormSelect :isLabel="false" :data="formattedDataList" :isCommon="true" name="용어집 카테고리" title="용어집 카테고리"/>
<button>쇼핑몰</button> <button @click="toggleInput">+</button>
<button>저장</button> <div class="d-flex" v-if="showInput">
<FormInput :isLabel="false" title="용어집 입력" name="용어집 입력"/>
<button @click="saveInput">저장</button>
</div>
</div> </div>
<div> <div>
<FormInput/> <FormInput title="내용" name="용어집 내용 입력"/>
</div> </div>
<div> <div>
<QEditor/> <QEditor/>
@ -15,7 +18,40 @@
</template> </template>
<script setup> <script setup>
import { defineProps, computed, ref, defineEmits } from 'vue';
import QEditor from '@/components/editor/QEditor.vue'; import QEditor from '@/components/editor/QEditor.vue';
import FormInput from '@/components/input/FormInput.vue'; import FormInput from '@/components/input/FormInput.vue';
import FormSelect from '@/components/input/FormSelect.vue'; import FormSelect from '@/components/input/FormSelect.vue';
const emit = defineEmits(['close']);
const props = defineProps({
dataList: {
type: Array,
default: () => []
}
});
//
const formattedDataList = computed(() =>
props.dataList.map(item => ({
label: item.CMNCODNAM,
value: item.CMNCODVAL
}))
);
//
const showInput = ref(false);
//
const toggleInput = () => {
howInput.value = !showInput.value;
};
//
const saveInput = () => {
console.log('입력값 저장됨!');
showInput.value = false;
};
</script> </script>

View File

@ -25,12 +25,12 @@
<!-- 카테고리 --> <!-- 카테고리 -->
<div v-if="cateList.length" class="mt-5"> <div v-if="cateList.length" class="mt-5">
<CategoryBtn :lists="cateList" /> <CategoryBtn :lists="cateList" @update:data="handleSelectedCategoryChange"/>
</div> </div>
<!-- 작성 --> <!-- 작성 -->
<div v-if="isWriteVisible" class="mt-5"> <div v-if="isWriteVisible" class="mt-5">
<DictWrite @close="isWriteVisible = false" /> <DictWrite @close="isWriteVisible = false" :dataList="cateList"/>
</div> </div>
</div> </div>
@ -50,16 +50,9 @@
:item="item" :item="item"
/> />
</ul> </ul>
<!-- <ul v-if="wordList.length > 0" class="px-0 list-unstyled">
<DictCard
v-for="item in wordList"
:key="item.WRDDICSEQ"
:item="item"
/>
</ul> -->
<!-- 데이터가 없을 --> <!-- 데이터가 없을 -->
<div v-else-if="!loading && !error">용어집의 용어가 없습니다.</div> <div v-else-if="!loading && !error" class="card p-5 text-center">용어집의 용어가 없습니다.</div>
</div> </div>
@ -84,12 +77,17 @@
// //
const wordList = ref([]); const wordList = ref([]);
// //
const total = ref(0); const total = ref(0);
// //
const cateList = ref([]); const cateList = ref([]);
const selectedCategory = ref('');
// //
const selectedAlphabet = ref(''); const selectedAlphabet = ref('');
// //
const searchText = ref(''); const searchText = ref('');
@ -98,77 +96,61 @@
// //
onMounted(() => { onMounted(() => {
getwordList(); // getwordList();
getwordCategory(); // getwordCategory();
}); });
// //
const getwordList = (searchKeyword='',indexKeyword='') => { const getwordList = (searchKeyword='', indexKeyword='', category='') => {
axios.get('worddict/getWordList',{ axios.get('worddict/getWordList',{
// //
params: { searchKeyword: searchKeyword params: {
,indexKeyword:indexKeyword searchKeyword : searchKeyword,
indexKeyword :indexKeyword,
category : category
} }
}) })
.then(res => { .then(res => {
wordList.value = res.data.data.data; // //
total.value = res.data.data.total; // wordList.value = res.data.data.data;
//
total.value = res.data.data.total;
loading.value = false; loading.value = false;
}) })
.catch(err => { .catch(err => {
console.error('데이터 로드 오류:', err); console.error('데이터 로드 오류:', err);
error.value = '데이터를 가져오는 중 문제가 발생했습니다.'; error.value = '데이터를 가져오는 중 문제가 발생했습니다.';
loading.value = false; // loading.value = false;
}); });
}; };
// //
const getwordCategory = () => { const getwordCategory = () => {
axios.get('worddict/getWordCategory') axios.get('worddict/getWordCategory')
.then(res => { .then(res => {
cateList.value = res.data.data; // cateList.value = res.data.data;
}) })
.catch(err => { .catch(err => {
console.error('카테고리 로드 오류:', err); console.error('카테고리 로드 오류:', err);
error.value = '카테고리 데이터를 가져오는 중 문제가 발생했습니다.'; error.value = '카테고리 데이터를 가져오는 중 문제가 발생했습니다.';
}); });
}; };
const handleSelectedAlphabetChange = (newAlphabet) => {
selectedAlphabet.value = newAlphabet;
getwordList(searchText.value,selectedAlphabet.value);
};
// //
const search = (e) => { const search = (e) => {
searchText.value = e.trim(); searchText.value = e.trim();
getwordList(searchText.value,selectedAlphabet.value); getwordList(searchText.value, selectedAlphabet.value, selectedCategory.value);
}; };
//
const handleSelectedAlphabetChange = (newAlphabet) => {
selectedAlphabet.value = newAlphabet;
getwordList(searchText.value, selectedAlphabet.value, selectedCategory.value);
};
// API //
// const fetchAllData = async () => { const handleSelectedCategoryChange = (category) => {
// loading.value = true; selectedCategory.value = category;
// error.value = ''; getwordList(searchText.value, selectedAlphabet.value, selectedCategory.value)
// try { }
// //
// // const wordResponse = await axios.get('worddict/getWordList');
// //wordList.value = wordResponse.data.data.data;
// //console.log(' :', wordList.value);
// //
// const categoryResponse = await axios.get('worddict/getWordCategory');
// cateList.value = categoryResponse.data.data;
// console.log(' :', cateList.value);
// } catch (err) {
// error.value = ' .';
// } finally {
// loading.value = false;
// }
// };
//
// const filteredList = computed(() =>
// wordList.value.filter(item =>
// item.WRDDICTTL.toLowerCase().includes(searchText.value.toLowerCase())
// )
// );
// toggle // toggle
const toggleWriteForm = () => { const toggleWriteForm = () => {