파일 업로드 수정
This commit is contained in:
@@ -211,7 +211,9 @@ uiUtil.uploadFile = (fileUploadType, input) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const inputGroup = $(input).parent('.input-group');
|
|
||||||
|
const inputGroup = $(input).parent().parent().find('.input-group');
|
||||||
|
|
||||||
if (!inputGroup.length) {
|
if (!inputGroup.length) {
|
||||||
alert(
|
alert(
|
||||||
`${input.name} 앨리먼트의 부모가 input-group 클래스를 가져야 uiUtil.uploadFile 메서드를 실행할 수 있습니다.`);
|
`${input.name} 앨리먼트의 부모가 input-group 클래스를 가져야 uiUtil.uploadFile 메서드를 실행할 수 있습니다.`);
|
||||||
@@ -246,11 +248,11 @@ uiUtil.uploadFile = (fileUploadType, input) => {
|
|||||||
inputGroup.find('.invalid-feedback').text('');
|
inputGroup.find('.invalid-feedback').text('');
|
||||||
|
|
||||||
// 기존 mappingId 가 있다면 초기화
|
// 기존 mappingId 가 있다면 초기화
|
||||||
inputGroup.find('input[name=fileMappingId]').remove();
|
/* inputGroup.find('input[name=fileMappingId]').remove();*/
|
||||||
|
|
||||||
// 신규 mappingId 추가
|
/* // 신규 mappingId 추가
|
||||||
inputGroup.append(
|
inputGroup.append(
|
||||||
`<input type="hidden" name="fileMappingId" value="${res.id}"/>`);
|
`<input type="hidden" name="fileMappingId" value="${res.id}"/>`);*/
|
||||||
|
|
||||||
// 업로드 파일 정보 보이기
|
// 업로드 파일 정보 보이기
|
||||||
uiUtil.showFileInfo(input, res, $(input).attr('accept') === 'image/*');
|
uiUtil.showFileInfo(input, res, $(input).attr('accept') === 'image/*');
|
||||||
@@ -274,18 +276,16 @@ uiUtil.uploadFile = (fileUploadType, input) => {
|
|||||||
* @param {boolean} showImg 미리보기 이미지 노출 여부
|
* @param {boolean} showImg 미리보기 이미지 노출 여부
|
||||||
*/
|
*/
|
||||||
uiUtil.showFileInfo = (input, uploadFile, showImg) => {
|
uiUtil.showFileInfo = (input, uploadFile, showImg) => {
|
||||||
const inputGroup = $(input).parent('.input-group');
|
const inputGroup = $(input).parent().parent().find('.input-group');
|
||||||
if (!inputGroup.length) {
|
if (!inputGroup.length) {
|
||||||
alert(
|
alert(
|
||||||
`${input.name} 앨리먼트의 부모가 input-group 클래스를 가져야 showFileInfo 메서드를 실행할 수 있습니다.`);
|
`${input.name} 앨리먼트의 부모가 input-group 클래스를 가져야 showFileInfo 메서드를 실행할 수 있습니다.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
inputGroup.find('.fileInfo').remove();
|
/* inputGroup.find('.fileInfo').remove();*/
|
||||||
|
|
||||||
|
/* inputGroup.append(`
|
||||||
|
|
||||||
inputGroup.append(`
|
|
||||||
<div class="fileInfo row text-muted fw-normal" style="display: none">
|
<div class="fileInfo row text-muted fw-normal" style="display: none">
|
||||||
<img src="${showImg ? uploadFile.referURL : ''}" class="w-75 mt-3 mb-3"/>
|
<img src="${showImg ? uploadFile.referURL : ''}" class="w-75 mt-3 mb-3"/>
|
||||||
<ul class="row" style="margin-left: 10px;">
|
<ul class="row" style="margin-left: 10px;">
|
||||||
@@ -295,31 +295,28 @@ uiUtil.showFileInfo = (input, uploadFile, showImg) => {
|
|||||||
<li class="id">File ID (${uploadFile.id})<span class="btn-sm btn-link fw-bold resetFile" style="cursor:pointer;">삭제</span> </li>
|
<li class="id">File ID (${uploadFile.id})<span class="btn-sm btn-link fw-bold resetFile" style="cursor:pointer;">삭제</span> </li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
`);
|
`);*/
|
||||||
|
|
||||||
|
inputGroup.append(`
|
||||||
|
<li class="fileInfo" style="display: none;">
|
||||||
|
<p><a href="${uploadFile.attachmentURL}">${uploadFile.originName}(${Math.ceil(uploadFile.fileLength / 1024)}KB)</a></p>
|
||||||
|
<button type="button" class="btn-delete resetFile"><span class="hide-txt ">삭제</span></button>
|
||||||
|
<input type="hidden" name="fileMappingId" value="${uploadFile.id}" />
|
||||||
|
</li>`);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const fileInfo = inputGroup.find('.fileInfo');
|
const fileInfo = inputGroup.find('.fileInfo');
|
||||||
if (!showImg) {
|
/* if (!showImg) {
|
||||||
fileInfo.find('img').remove();
|
fileInfo.find('img').remove();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
// 파일 삭제 함수 정의
|
// 파일 삭제 함수 정의
|
||||||
inputGroup.find('.resetFile').on('click', () => {
|
inputGroup.find('.resetFile').on('click', function () {
|
||||||
let fileInput = inputGroup.find('input[type=file]');
|
const $fileInfo = $(this).closest('.fileInfo');
|
||||||
fileInput.replaceWith(`
|
$fileInfo.fadeOut(function () {
|
||||||
<input type="file"
|
$(this).remove();
|
||||||
id="${fileInput.attr('id')}"
|
|
||||||
class="${fileInput.attr('class')}"
|
|
||||||
accept="${fileInput.attr('accept')}"
|
|
||||||
name="${fileInput.attr('name')}"
|
|
||||||
onchange="${fileInput.attr('onchange')}">
|
|
||||||
`);
|
|
||||||
|
|
||||||
inputGroup.find('input[name=fileMappingId]').remove();
|
|
||||||
inputGroup.find('.fileInfo').fadeOut((evt) => {
|
|
||||||
$(evt.target).remove();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -28,20 +28,28 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>첨부파일<i class="ico-required-mark" role="img" aria-label="필수">*</i></th>
|
<th>첨부파일</th>
|
||||||
<td colspan="3">
|
<td colspan="3">
|
||||||
|
<div class="input-file-group">
|
||||||
|
<label for="file" class="input-file-btn">
|
||||||
|
<input type="file" name="multipartAttachments" id="file" onchange="uiUtil.uploadFile('NOTICE', this);" >
|
||||||
|
<span class="file-txt">파일첨부</span>
|
||||||
|
</label>
|
||||||
|
<p class="desc">첨부 가능 파일 형식: 문서(pdf, docx, xlsx, pptx, hwp), 이미지(jpg, jpeg, png, gif), 기타(zip,
|
||||||
|
csv, txt) / 파일당 최대 5MB까지 등록 가능합니다.</p>
|
||||||
|
<ul class="file-list input-group" id="noticeAttachments">
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<!-- <td colspan="3">
|
||||||
<div class="btns-row align-left publicFileInputs">
|
<div class="btns-row align-left publicFileInputs">
|
||||||
<button type="button" class="btn btn-secondary" onclick="addFileInput();">
|
<button type="button" class="btn btn-secondary" onclick="addFileInput();">
|
||||||
<span class="btn-txt">다건 파일 첨부</span>
|
<span class="btn-txt">다건 파일 첨부</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</td>-->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th>게시기간<i class="ico-required-mark" role="img" aria-label="필수">*</i></th>
|
<th>게시기간<i class="ico-required-mark" role="img" aria-label="필수">*</i></th>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
@@ -57,11 +65,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th>노출여부<i class="ico-required-mark" role="img" aria-label="필수">*</i></th>
|
<th>노출여부<i class="ico-required-mark" role="img" aria-label="필수">*</i></th>
|
||||||
<td>
|
<td>
|
||||||
@@ -75,8 +81,6 @@
|
|||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
@@ -102,7 +106,6 @@
|
|||||||
|
|
||||||
<script th:inline="javascript">
|
<script th:inline="javascript">
|
||||||
|
|
||||||
|
|
||||||
$(".flatpickr").flatpickr({
|
$(".flatpickr").flatpickr({
|
||||||
dateFormat: "Y-m-d\\TH:i",
|
dateFormat: "Y-m-d\\TH:i",
|
||||||
// altInput: true,
|
// altInput: true,
|
||||||
@@ -111,6 +114,7 @@
|
|||||||
enableTime: true,
|
enableTime: true,
|
||||||
time_24hr: true
|
time_24hr: true
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script th:inline="javascript">
|
<script th:inline="javascript">
|
||||||
@@ -120,13 +124,11 @@
|
|||||||
history.back();
|
history.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const gotoList = () => {
|
const gotoList = () => {
|
||||||
location.href = '/communication/notices';
|
location.href = '/communication/notices';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* function addFileInput() {
|
||||||
function addFileInput() {
|
|
||||||
const inputGroup = $(`
|
const inputGroup = $(`
|
||||||
<div class="input-group w-50">
|
<div class="input-group w-50">
|
||||||
<input class="form-control mb-2" type="file" name="multipartAttachments"
|
<input class="form-control mb-2" type="file" name="multipartAttachments"
|
||||||
@@ -142,7 +144,7 @@
|
|||||||
return inputGroup;
|
return inputGroup;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
const getNotice = () => {
|
const getNotice = () => {
|
||||||
const f = document.reqForm;
|
const f = document.reqForm;
|
||||||
@@ -167,11 +169,10 @@
|
|||||||
f.visible.value = res.visible;
|
f.visible.value = res.visible;
|
||||||
|
|
||||||
res.uploadFiles.forEach((uploadFile) => {
|
res.uploadFiles.forEach((uploadFile) => {
|
||||||
|
let inputGroup = $('#noticeAttachments');
|
||||||
let inputGroup = addFileInput();
|
/* let inputGroup = addFileInput();
|
||||||
inputGroup.append(`<input type="hidden" name="fileMappingId" value="${uploadFile.id}"/>`);
|
inputGroup.append(`<input type="hidden" name="fileMappingId" value="${uploadFile.id}"/>`);*/
|
||||||
uiUtil.showFileInfo(inputGroup.find('input[type=file]'), uploadFile, false);
|
uiUtil.showFileInfo(inputGroup, uploadFile, false);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -180,9 +181,6 @@
|
|||||||
// 상세정보 얻기
|
// 상세정보 얻기
|
||||||
getNotice();
|
getNotice();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const goSave = () => {
|
const goSave = () => {
|
||||||
const f = document.reqForm;
|
const f = document.reqForm;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user