라디오박스수정

This commit is contained in:
dyhj625 2025-01-21 14:04:33 +09:00
parent 10e48404db
commit 05c26f7b7b
2 changed files with 55 additions and 43 deletions

View File

@ -2,7 +2,7 @@
<div class="mb-2 row"> <div class="mb-2 row">
<label :for="name" class="col-md-2 col-form-label" :class="isLabel ? 'd-block' : 'd-none'"> <label :for="name" class="col-md-2 col-form-label" :class="isLabel ? 'd-block' : 'd-none'">
{{ title }} {{ title }}
<span :class="isEssential ? 'text-red' : 'none'">*</span> <span class="text-danger">*</span>
</label> </label>
<div class="col-md-10"> <div class="col-md-10">
<input <input

View File

@ -17,16 +17,32 @@
v-model="title" v-model="title"
/> />
<FormSelect <!-- 카테고리 선택 -->
title="카테고리" <div class="mb-4 d-flex align-items-center">
name="cate" <label class="col-md-2 col-form-label">카테고리 <span class="text-danger">*</span></label>
:is-essential="true" <div class="d-flex flex-wrap align-items-center mt-3 ms-1">
:data="categoryList" <div
@update:data="category = $event" v-for="(categoryName, index) in categoryList"
:key="index"
class="form-check me-3"
>
<input
class="form-check-input"
type="radio"
:id="`category-${index}`"
:value="index"
v-model="category"
/> />
<label class="form-check-label" :for="`category-${index}`">
{{ categoryName }}
</label>
</div>
</div>
</div>
<!-- 비밀번호 필드 -->
<div v-if="category === 1" class="mb-4">
<FormInput <FormInput
v-show="category === 1"
title="비밀번호" title="비밀번호"
name="pw" name="pw"
type="password" type="password"
@ -34,6 +50,7 @@
:is-alert="passwordAlert" :is-alert="passwordAlert"
v-model="password" v-model="password"
/> />
</div>
<FormFile <FormFile
title="첨부파일" title="첨부파일"
@ -66,16 +83,15 @@
<script setup> <script setup>
import QEditor from '@c/editor/QEditor.vue'; import QEditor from '@c/editor/QEditor.vue';
import FormInput from '@c/input/FormInput.vue'; import FormInput from '@c/input/FormInput.vue';
import FormSelect from '@c/input/FormSelect.vue';
import FormFile from '@c/input/FormFile.vue'; import FormFile from '@c/input/FormFile.vue';
import { ref } from 'vue'; import { ref } from 'vue';
import router from '@/router'; import router from '@/router';
import axios from '@api'; import axios from '@api';
const categoryList = ['자유', '익명', '공지사항']; const categoryList = ['자유', '익명', '공지사항']; //
const title = ref(''); const title = ref('');
const password = ref(''); const password = ref('');
const category = ref(0); const category = ref(0); // 0
const content = ref(''); const content = ref('');
const attachFiles = ref(null); const attachFiles = ref(null);
@ -89,12 +105,10 @@ const goList = () => {
}; };
const write = async () => { const write = async () => {
// titleAlert.value = !title.value;
titleAlert.value = !title.value; // true passwordAlert.value = category.value === 1 && !password.value;
passwordAlert.value = category.value === 1 && !password.value; // true contentAlert.value = !content.value;
contentAlert.value = !content.value; // true
//
if (titleAlert.value || passwordAlert.value || contentAlert.value) { if (titleAlert.value || passwordAlert.value || contentAlert.value) {
return; return;
} }
@ -113,16 +127,14 @@ const write = async () => {
if (attachFiles.value && attachFiles.value.length > 0) { if (attachFiles.value && attachFiles.value.length > 0) {
for (const file of attachFiles.value) { for (const file of attachFiles.value) {
const formData = new FormData(); const formData = new FormData();
const fileNameWithoutExt = file.name.replace(/\.[^/.]+$/, '');
//
const fileNameWithoutExt = file.name.replace(/\.[^/.]+$/, ''); //
formData.append('CMNBRDSEQ', boardId); formData.append('CMNBRDSEQ', boardId);
formData.append('CMNFLEORG', fileNameWithoutExt); // formData.append('CMNFLEORG', fileNameWithoutExt);
formData.append('CMNFLEEXT', file.name.split('.').pop()); // formData.append('CMNFLEEXT', file.name.split('.').pop());
formData.append('CMNFLESIZ', file.size); // formData.append('CMNFLESIZ', file.size);
formData.append('CMNFLEPAT', 'boardfile'); // formData.append('CMNFLEPAT', 'boardfile');
formData.append('file', file); // formData.append('file', file);
await axios.post(`board/${boardId}/attachments`, formData, { await axios.post(`board/${boardId}/attachments`, formData, {
headers: { headers: {
@ -131,6 +143,7 @@ const write = async () => {
}); });
} }
} }
alert('게시물이 작성되었습니다.'); alert('게시물이 작성되었습니다.');
goList(); goList();
} catch (error) { } catch (error) {
@ -139,4 +152,3 @@ const write = async () => {
} }
}; };
</script> </script>