Merge remote-tracking branch 'origin/main' into board-comment

This commit is contained in:
kimdaae328 2025-02-18 10:22:14 +09:00
commit ae4f4a807b
4 changed files with 149 additions and 59 deletions

View File

@ -40,26 +40,26 @@ const props = defineProps({
required: true,
},
value: {
type: String,
type: [String, Number],
default: '0',
require: false,
},
isAlert : {
isAlert: {
type: Boolean,
default: false,
required: false,
},
isLabel : {
isLabel: {
type: Boolean,
default: true,
required: false,
},
isRow : {
isRow: {
type: Boolean,
default: true,
required: false,
},
isCommon : {
isCommon: {
type: Boolean,
default: false,
required: false,
@ -69,11 +69,19 @@ const props = defineProps({
const emit = defineEmits(['update:data']);
const selectData = ref(props.value);
// data
// props.value watch
watch(() => props.value, (newValue) => {
selectData.value = newValue;
}, { immediate: true });
// data
watch(() => props.data, (newData) => {
if (props.isCommon && newData.length > 0) {
selectData.value = newData[0].value;
emit('update:data', selectData.value);
// value prop '0'()
if (props.value === '0') {
selectData.value = newData[0].value;
emit('update:data', selectData.value);
}
}
}, { immediate: true });
@ -81,4 +89,4 @@ watch(() => props.data, (newData) => {
watch(selectData, (newValue) => {
emit('update:data', newValue);
});
</script>
</script>

View File

@ -1,69 +1,146 @@
<template>
<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 pe-none">{{ item.category }}</span>
<strong class="mx-2 w-75">{{ item.WRDDICTTL }}</strong>
</div>
<EditBtn />
</div>
<p class="mt-5" v-html="$common.contentToHtml(item.WRDDICCON)"></p>
<div class="d-flex justify-content-between flex-wrap gap-2 mb-2">
<div class="d-flex flex-wrap align-items-center mb-50">
<div class="avatar avatar-sm me-2">
<img
class="rounded-circle user-avatar"
:src="getProfileImage(item.author.profileImage)"
alt="최초 작성자"
:style="{ borderColor: item.author.color}"
/>
<DictWrite
v-if="isWriteVisible"
@close="isWriteVisible = false"
:dataList="cateList"
@addCategory="addCategory"
:formValue="item.WRDDICCAT"
:titleValue="item.WRDDICTTL"
:contentValue="$common.contentToHtml(item.WRDDICCON)"
/>
<div v-else>
<div class="d-flex align-items-center">
<div class="w-100 d-flex align-items-center">
<span class="btn btn-primary pe-none">{{ item.category }}</span>
<strong class="mx-2 w-75">{{ item.WRDDICTTL }}</strong>
</div>
<div>
<p class="mb-0 small fw-medium">{{ formatDate(item.author.createdAt) }}</p>
</div>
<p class="mt-5" v-html="$common.contentToHtml(item.WRDDICCON)"></p>
<div class="d-flex justify-content-between flex-wrap gap-2 mb-2">
<div class="d-flex flex-wrap align-items-center mb-50">
<div class="avatar avatar-sm me-2">
<img
class="rounded-circle user-avatar"
:src="getProfileImage(item.author.profileImage)"
alt="최초 작성자"
:style="{ borderColor: item.author.color}"/>
</div>
<div>
<p class="mb-0 small fw-medium">{{ formatDate(item.author.createdAt) }}</p>
</div>
</div>
</div>
<div class="d-flex justify-content-between flex-wrap gap-2 mb-2">
<div class="d-flex flex-wrap align-items-center mb-50">
<div class="avatar avatar-sm me-2">
<img
class="rounded-circle user-avatar"
:src="getProfileImage(item.lastEditor.profileImage)"
alt="최근 작성자"
:style="{ borderColor: item.lastEditor.color}"/>
</div>
<div>
<p class="mb-0 small fw-medium">{{ formatDate(item.lastEditor.updatedAt) }}</p>
</div>
</div>
</div>
</div>
<div class="d-flex justify-content-between flex-wrap gap-2 mb-2">
<div class="d-flex flex-wrap align-items-center mb-50">
<div class="avatar avatar-sm me-2">
<img
class="rounded-circle user-avatar"
:src="getProfileImage(item.lastEditor.profileImage)"
alt="최근 작성자"
:style="{ borderColor: item.lastEditor.color}"
/>
</div>
<div>
<p class="mb-0 small fw-medium">{{ formatDate(item.lastEditor.updatedAt) }}</p>
</div>
</div>
<div class="edit-btn">
<EditBtn @click="toggleWriteVisible" />
</div>
</li>
</template>
<script setup>
import axios from "@api";
import { useToastStore } from '@s/toastStore';
import { ref, toRefs } from 'vue';
import EditBtn from '@/components/button/EditBtn.vue';
import $api from '@api';
import DictWrite from './DictWrite.vue';
const toastStore = useToastStore();
// Props
const props = defineProps({
item: {
type: Object,
required: true,
required: true
},
cateList: {
type: Array,
required: false,
}
});
//
const localCateList = ref([...props.cateList]);
//
const selectedCategory = ref('');
// cateList emit
const emit = defineEmits(['update:cateList']);
//
const isWriteVisible = ref(false);
// toggle
const toggleWriteVisible = () => {
isWriteVisible.value = !isWriteVisible.value;
};
//
const addCategory = (data) => {
try {
const lastCategory = localCateList.value.length > 0
? localCateList.value[localCateList.value.length - 1]
: null;
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 };
localCateList.value = [newCategory, ...localCateList.value];
selectedCategory.value = newCategory.value;
//
emit('update:cateList', localCateList.value);
}
}).catch(err => {
console.error('카테고리 추가 중 오류:', err);
});
} catch (err) {
console.error('카테고리 추가 함수 오류:', err);
}
}
const baseUrl = $api.defaults.baseURL.replace(/api\/$/, '');
//
//
const formatDate = (dateString) => new Date(dateString).toLocaleString();
//
//
const getProfileImage = (imagePath) =>
imagePath ? `${baseUrl}upload/img/profile/${imagePath}` : '/img/avatars/default-Profile.jpg';
imagePath ? `${baseUrl}upload/img/profile/${imagePath}` : '/img/avatars/default-Profile.jpg';
</script>
<style scoped>
/* 동그란 테두리 설정 */
.user-avatar {
border: 3px solid; /* 테두리 */
padding: 0.1px; /* 테두리와 이미지 사이의 간격 */
border: 3px solid; /* 테두리 */
padding: 0.1px; /* 테두리와 이미지 사이의 간격 */
}
</style>
.edit-btn {
position: absolute;
right: 0.7rem;
top: 1.2rem;
}
</style>

View File

@ -9,6 +9,7 @@
:is-common="true"
@update:data="selectCategory = $event"
@change="onChange"
:value="formValue"
/>
</div>
<div class="col-2 btn-margin">
@ -34,11 +35,13 @@
name="word"
:is-essential="true"
:is-alert="wordTitleAlert"
:modelValue="titleValue"
@update:modelValue="wordTitle = $event"
/>
</div>
<div>
<QEditor @update:data="content = $event" @update:imageUrls="imageUrls = $event" :is-alert="wordContentAlert" />
{{ contentValue }}
<div class="text-end mt-5">
<button class="btn btn-primary" @click="saveWord">
<i class="bx bx-check"></i>
@ -75,17 +78,17 @@ const props = defineProps({
dataList: {
type: Array,
default: () => []
},
formValue : {
type:[String, Number]
},
titleValue : {
type:String,
},contentValue : {
type:String
}
});
//
// const formattedDataList = computed(() =>
// props.dataList.map(item => ({
// label: item.CMNCODNAM,
// value: item.CMNCODVAL
// }))
// );
//
const showInput = ref(false);

View File

@ -48,6 +48,7 @@
v-for="item in wordList"
:key="item.WRDDICSEQ"
:item="item"
:cateList="cateList"
/>
</ul>
@ -91,6 +92,7 @@
const { cateList } = commonApi({
loadCateList: true
});
const selectedCategory = ref('');
const selectCategory = ref('');
@ -167,8 +169,8 @@
if(res.data.data == '1'){
toastStore.onToast('카테고리가 추가 등록 되었습니다.', 's');
const newCategory = { label: data, value: newValue };
cateList.value.unshift(newCategory);
selectCategory.value = newCategory.CMNCODVAL;
cateList.value = [newCategory, ...cateList.value];
selectedCategory.value = newCategory.value;
}
})
}