Skip to content

Commit fdb720f

Browse files
authored
fix: datepicker (#432) #428
* feat: add datepicker * fix: 修复datepicker问题 * fix: datepicker解决导入相关问题 * fix: picker 联动bug * fix: picker bug * fix: picker props * fix: datepicker bug * fix: 修改datepicker 月份问题 * fix: datepicker
1 parent 239d09c commit fdb720f

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

src/packages/datepicker/index.vue

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export default create({
192192
});
193193
194194
const changeHandler = (val: string[]) => {
195-
if (props.type == 'datetime') {
195+
if (['date', 'datetime'].includes(props.type)) {
196196
let formatDate = [];
197197
if (props.isShowChinese) {
198198
formatDate = val.map((res: string) => {
@@ -201,16 +201,32 @@ export default create({
201201
} else {
202202
formatDate = val;
203203
}
204-
console.log(formatDate);
205-
state.currentDate = formatValue(
206-
new Date(
207-
formatDate[0],
208-
formatDate[1] - 1,
209-
formatDate[2],
210-
formatDate[3],
211-
formatDate[4]
212-
)
213-
);
204+
let date: Date;
205+
if (props.type === 'date') {
206+
state.currentDate = formatValue(
207+
new Date(
208+
formatDate[0],
209+
formatDate[1] - 1,
210+
Math.min(
211+
formatDate[2],
212+
getMonthEndDay(formatDate[0], formatDate[1])
213+
)
214+
)
215+
);
216+
} else if (props.type === 'datetime') {
217+
state.currentDate = formatValue(
218+
new Date(
219+
formatDate[0],
220+
formatDate[1] - 1,
221+
Math.min(
222+
formatDate[2],
223+
getMonthEndDay(formatDate[0], formatDate[1])
224+
),
225+
formatDate[3],
226+
formatDate[4]
227+
)
228+
);
229+
}
214230
}
215231
};
216232

0 commit comments

Comments
 (0)