Merge branch 'main' into vacation

This commit is contained in:
dyhj625 2025-03-21 10:16:11 +09:00
commit 8324095bf4
4 changed files with 72 additions and 39 deletions

View File

@ -71,7 +71,8 @@
const editor = ref(null); // DOM const editor = ref(null); // DOM
const font = ref('nanum-gothic'); // const font = ref('nanum-gothic'); //
const fontSize = ref('16px'); // const fontSize = ref('16px'); //
const emit = defineEmits(['update:data']); const emit = defineEmits(['update:data', 'update:uploadedImgList']);
const uploadedImgList = ref([]); //
onMounted(() => { onMounted(() => {
// //
@ -112,6 +113,13 @@
quillInstance.format('size', fontSize.value); quillInstance.format('size', fontSize.value);
}); });
//
watch(uploadedImgList, () => {
console.log(!23);
emit('update:uploadedImgList', uploadedImgList.value);
console.log('uploadedImgList.value: ', uploadedImgList.value);
});
// , HTML // , HTML
if (props.initialData) { if (props.initialData) {
quillInstance.setContents(JSON.parse(props.initialData)); quillInstance.setContents(JSON.parse(props.initialData));
@ -150,7 +158,15 @@
// URL // URL
uploadImageToServer(formData) uploadImageToServer(formData)
.then(serverImageUrl => { .then(data => {
const uploadImgIdx = data?.fileIndex; // DB
const serverImageUrl = data?.fileUrl; // url
// ( )
if (uploadImgIdx) {
uploadedImgList.value = [...uploadedImgList.value, uploadImgIdx];
}
const baseUrl = $api.defaults.baseURL.replace(/api\/$/, ''); const baseUrl = $api.defaults.baseURL.replace(/api\/$/, '');
const fullImageUrl = `${baseUrl}${serverImageUrl.replace(/\\/g, '/')}`; const fullImageUrl = `${baseUrl}${serverImageUrl.replace(/\\/g, '/')}`;
@ -201,7 +217,7 @@
// Throw the error so the caller knows something went wrong // Throw the error so the caller knows something went wrong
throw error; throw error;
} }
} }
// //
function checkForDeletedImages() { function checkForDeletedImages() {
@ -216,4 +232,3 @@
} }
}); });
</script> </script>

View File

@ -14,7 +14,6 @@
:value="computedValue" :value="computedValue"
:disabled="disabled" :disabled="disabled"
:maxLength="maxlength" :maxLength="maxlength"
:minLength="minlength"
:placeholder="title" :placeholder="title"
@blur="$emit('blur')" @blur="$emit('blur')"
/> />
@ -30,7 +29,6 @@
:value="computedValue" :value="computedValue"
:disabled="disabled" :disabled="disabled"
:maxLength="maxlength" :maxLength="maxlength"
:minLength="minlength"
:placeholder="title" :placeholder="title"
@blur="$emit('blur')" @blur="$emit('blur')"
/> />

View File

@ -57,6 +57,7 @@
v-if="contentLoaded" v-if="contentLoaded"
@update:data="content = $event" @update:data="content = $event"
@update:imageUrls="imageUrls = $event" @update:imageUrls="imageUrls = $event"
@update:uploadedImgList="handleUpdateEditorImg"
:initialData="content" :initialData="content"
/> />
</div> </div>
@ -115,7 +116,7 @@
const attachFilesAlert = ref(false); const attachFilesAlert = ref(false);
const isFileValid = ref(true); const isFileValid = ref(true);
const delFileIdx = ref([]); // ID const delFileIdx = ref([]); // ID
const additionalFiles = ref([]); // const editorUploadedImgList = ref([]);
// //
const fetchBoardDetails = async () => { const fetchBoardDetails = async () => {
@ -145,6 +146,10 @@
contentLoaded.value = true; contentLoaded.value = true;
}; };
const handleUpdateEditorImg = item => {
editorUploadedImgList.value = item;
};
// //
const addDisplayFileName = fileInfos => const addDisplayFileName = fileInfos =>
fileInfos.map(file => ({ fileInfos.map(file => ({
@ -247,6 +252,11 @@
boardData.delFileIdx = [...delFileIdx.value]; boardData.delFileIdx = [...delFileIdx.value];
} }
//
if (editorUploadedImgList.value && editorUploadedImgList.value.length > 0) {
boardData.editorUploadedImgList = [...editorUploadedImgList.value];
}
const fileArray = newFileFilter(attachFiles); const fileArray = newFileFilter(attachFiles);
const formData = new FormData(); const formData = new FormData();

View File

@ -92,7 +92,7 @@
<div class="mb-4"> <div class="mb-4">
<label class="col-md-2 col-form-label"> 내용 <span class="text-danger">*</span> </label> <label class="col-md-2 col-form-label"> 내용 <span class="text-danger">*</span> </label>
<div class="col-md-12"> <div class="col-md-12">
<QEditor @update:data="content = $event" /> <QEditor @update:data="content = $event" @update:uploadedImgList="handleUpdateEditorImg" />
</div> </div>
<div class="invalid-feedback mt-1" :class="contentAlert ? 'd-block' : 'd-none'">내용을 입력해주세요.</div> <div class="invalid-feedback mt-1" :class="contentAlert ? 'd-block' : 'd-none'">내용을 입력해주세요.</div>
</div> </div>
@ -138,6 +138,7 @@
const maxFiles = 5; const maxFiles = 5;
const maxSize = 10 * 1024 * 1024; const maxSize = 10 * 1024 * 1024;
const fileError = ref(''); const fileError = ref('');
const editorUploadedImgList = ref([]);
const fetchCategories = async () => { const fetchCategories = async () => {
const response = await axios.get('board/categories'); const response = await axios.get('board/categories');
@ -154,6 +155,10 @@
const fileCount = computed(() => attachFiles.value.length); const fileCount = computed(() => attachFiles.value.length);
const handleUpdateEditorImg = item => {
editorUploadedImgList.value = item;
};
const handleFileUpload = files => { const handleFileUpload = files => {
const validFiles = files.filter(file => file.size <= maxSize); const validFiles = files.filter(file => file.size <= maxSize);
if (files.some(file => file.size > maxSize)) { if (files.some(file => file.size > maxSize)) {
@ -236,6 +241,11 @@
LOCBRDTYP: categoryValue.value, LOCBRDTYP: categoryValue.value,
}; };
//
if (editorUploadedImgList.value && editorUploadedImgList.value.length > 0) {
boardData.editorUploadedImgList = [...editorUploadedImgList.value];
}
const { data: boardResponse } = await axios.post('board', boardData); const { data: boardResponse } = await axios.post('board', boardData);
const boardId = boardResponse.data; const boardId = boardResponse.data;
// ( ) // ( )