
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
export default {
data() {
return {
searchDate: {
startDt: this.startDt(),
endDt: this.endDt()
},
}
},
methods: {
// 날짜 포맷 변경
dateFormat(date) {
return (
date.getFullYear() +
"-" +
(date.getMonth() + 1 < 10
? "0" + (date.getMonth() + 1)
: date.getMonth() + 1) +
"-" +
(date.getDate() < 10 ? "0" + date.getDate() : date.getDate())
);
},
// 기본 시작일 (현재로부터 30일 이전)
startDt() {
let today = new Date();
let date = new Date(today);
date.setDate(today.getDate() - 30);
return this.dateFormat(date);
},
// 기본 종료일 (현재)
endDt() {
let today = new Date();
return this.dateFormat(today);
},
// 조회기간 유효성 검사
validateDate(event, cate) {
const val = event.target.value; // 변경된 날짜 값
// 시작일 변경 시
if (cate === "startDt") {
if (this.searchDate.endDt !== null && this.searchDate.endDt < val) {
alert("시작일은 종료일보다 클 수 없습니다.");
this.searchDate.startDt = null; // 유효하지 않은 경우, 시작일을 초기화
} else {
this.searchDate.startDt = val;
}
}
// 종료일 변경 시
else if (cate === "endDt") {
if (this.searchDate.startDt !== null && this.searchDate.startDt > val) {
alert("종료일은 시작일보다 작을 수 없습니다.");
this.searchDate.endDt = null; // 유효하지 않은 경우, 종료일을 초기화
} else {
this.searchDate.endDt = val;
}
}
},
}
}