대댓글 내용없을때 입력 안되게
This commit is contained in:
parent
08dabf4191
commit
64cb7e30c1
@ -73,6 +73,14 @@ const common = {
|
|||||||
seconds: zeroFormat(date.getSeconds()),
|
seconds: zeroFormat(date.getSeconds()),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
isNotEmpty(obj) {
|
||||||
|
if (obj === null || obj === undefined) return false;
|
||||||
|
if (typeof obj === 'string' && obj.trim() === '') return false;
|
||||||
|
if ((Array.isArray(obj) || obj === Object(obj)) && Object.keys(obj).length === 0) return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|||||||
@ -11,13 +11,9 @@
|
|||||||
</div> -->
|
</div> -->
|
||||||
<!-- 텍스트박스 -->
|
<!-- 텍스트박스 -->
|
||||||
<div class="w-100">
|
<div class="w-100">
|
||||||
<textarea
|
<textarea class="form-control" placeholder="댓글 달기" rows="3" v-model="comment"></textarea>
|
||||||
class="form-control"
|
|
||||||
placeholder="댓글 달기"
|
|
||||||
rows="3"
|
|
||||||
v-model="comment"
|
|
||||||
></textarea>
|
|
||||||
<span v-if="commentAlert" class="invalid-feedback d-block text-start ms-2">{{ commentAlert }}</span>
|
<span v-if="commentAlert" class="invalid-feedback d-block text-start ms-2">{{ commentAlert }}</span>
|
||||||
|
<span v-else class="invalid-feedback d-block text-start ms-2">{{ textAlert }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -26,12 +22,7 @@
|
|||||||
<div class="d-flex flex-wrap align-items-center">
|
<div class="d-flex flex-wrap align-items-center">
|
||||||
<!-- 익명 체크박스 (익명게시판일 경우에만)-->
|
<!-- 익명 체크박스 (익명게시판일 경우에만)-->
|
||||||
<div v-if="unknown" class="form-check form-check-inline mb-0 me-4">
|
<div v-if="unknown" class="form-check form-check-inline mb-0 me-4">
|
||||||
<input
|
<input class="form-check-input" type="checkbox" id="inlineCheckbox1" v-model="isCheck" />
|
||||||
class="form-check-input"
|
|
||||||
type="checkbox"
|
|
||||||
id="inlineCheckbox1"
|
|
||||||
v-model="isCheck"
|
|
||||||
/>
|
|
||||||
<label class="form-check-label" for="inlineCheckbox1">익명</label>
|
<label class="form-check-label" for="inlineCheckbox1">익명</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -59,7 +50,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, defineEmits, defineProps, computed, watch } from 'vue';
|
import { ref, defineEmits, defineProps, computed, watch, inject } from 'vue';
|
||||||
import SaveBtn from '../button/SaveBtn.vue';
|
import SaveBtn from '../button/SaveBtn.vue';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@ -69,25 +60,33 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
parentId: {
|
parentId: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 0
|
default: 0,
|
||||||
},
|
},
|
||||||
passwordAlert: {
|
passwordAlert: {
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: '',
|
||||||
},
|
},
|
||||||
commentAlert: {
|
commentAlert: {
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: '',
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
const $common = inject('common');
|
||||||
const comment = ref('');
|
const comment = ref('');
|
||||||
const password = ref('');
|
const password = ref('');
|
||||||
const isCheck = ref(props.unknown);
|
const isCheck = ref(props.unknown);
|
||||||
|
const textAlert = ref('');
|
||||||
|
|
||||||
const emit = defineEmits(['submitComment']);
|
const emit = defineEmits(['submitComment']);
|
||||||
const LOCBRDTYP = isCheck.value ? '300102' : null;
|
const LOCBRDTYP = isCheck.value ? '300102' : null;
|
||||||
function handleCommentSubmit() {
|
function handleCommentSubmit() {
|
||||||
|
if (!$common.isNotEmpty(comment.value)) {
|
||||||
|
textAlert.value = '댓글을 입력하세요';
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
textAlert.value = '';
|
||||||
|
}
|
||||||
|
|
||||||
emit('submitComment', {
|
emit('submitComment', {
|
||||||
comment: comment.value,
|
comment: comment.value,
|
||||||
password: isCheck.value ? password.value : '',
|
password: isCheck.value ? password.value : '',
|
||||||
@ -96,12 +95,13 @@ function handleCommentSubmit() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(() => props.passwordAlert, () => {
|
watch(
|
||||||
|
() => props.passwordAlert,
|
||||||
|
() => {
|
||||||
if (!props.passwordAlert) {
|
if (!props.passwordAlert) {
|
||||||
comment.value = '';
|
comment.value = '';
|
||||||
password.value = '';
|
password.value = '';
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user