용어집 입력 및 입력 수정 중

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

View File

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

View File

@ -2,7 +2,7 @@
<li class="mt-5 card p-5">
<div class="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>
</div>
<EditBtn />

View File

@ -1,11 +1,14 @@
<template>
<div>
<FormSelect/>
<button>쇼핑몰</button>
<button>저장</button>
<div class="d-flex">
<FormSelect :isLabel="false" :data="formattedDataList" :isCommon="true" name="용어집 카테고리" title="용어집 카테고리"/>
<button @click="toggleInput">+</button>
<div class="d-flex" v-if="showInput">
<FormInput :isLabel="false" title="용어집 입력" name="용어집 입력"/>
<button @click="saveInput">저장</button>
</div>
</div>
<div>
<FormInput/>
<FormInput title="내용" name="용어집 내용 입력"/>
</div>
<div>
<QEditor/>
@ -15,7 +18,40 @@
</template>
<script setup>
import { defineProps, computed, ref, defineEmits } from 'vue';
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 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>

View File

@ -25,12 +25,12 @@
<!-- 카테고리 -->
<div v-if="cateList.length" class="mt-5">
<CategoryBtn :lists="cateList" />
<CategoryBtn :lists="cateList" @update:data="handleSelectedCategoryChange"/>
</div>
<!-- 작성 -->
<div v-if="isWriteVisible" class="mt-5">
<DictWrite @close="isWriteVisible = false" />
<DictWrite @close="isWriteVisible = false" :dataList="cateList"/>
</div>
</div>
@ -50,16 +50,9 @@
:item="item"
/>
</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>
@ -84,12 +77,17 @@
//
const wordList = ref([]);
//
const total = ref(0);
//
const cateList = ref([]);
const selectedCategory = ref('');
//
const selectedAlphabet = ref('');
//
const searchText = ref('');
@ -98,77 +96,61 @@
//
onMounted(() => {
getwordList(); //
getwordCategory(); //
getwordList();
getwordCategory();
});
//
const getwordList = (searchKeyword='',indexKeyword='') => {
const getwordList = (searchKeyword='', indexKeyword='', category='') => {
axios.get('worddict/getWordList',{
//
params: { searchKeyword: searchKeyword
,indexKeyword:indexKeyword
params: {
searchKeyword : searchKeyword,
indexKeyword :indexKeyword,
category : category
}
})
.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;
})
.catch(err => {
console.error('데이터 로드 오류:', err);
error.value = '데이터를 가져오는 중 문제가 발생했습니다.';
loading.value = false; //
loading.value = false;
});
};
//
const getwordCategory = () => {
axios.get('worddict/getWordCategory')
.then(res => {
cateList.value = res.data.data; //
cateList.value = res.data.data;
})
.catch(err => {
console.error('카테고리 로드 오류:', err);
error.value = '카테고리 데이터를 가져오는 중 문제가 발생했습니다.';
});
};
const handleSelectedAlphabetChange = (newAlphabet) => {
selectedAlphabet.value = newAlphabet;
getwordList(searchText.value,selectedAlphabet.value);
};
//
const search = (e) => {
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 () => {
// loading.value = true;
// error.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())
// )
// );
//
const handleSelectedCategoryChange = (category) => {
selectedCategory.value = category;
getwordList(searchText.value, selectedAlphabet.value, selectedCategory.value)
}
// toggle
const toggleWriteForm = () => {
@ -190,4 +172,4 @@
margin-bottom: 0.5rem !important;
}
}
</style>
</style>