hookehuyr

🐞 fix(日期组件): 最大最小值设置,需要区分日期格式

<!--
* @Date: 2022-08-31 11:45:30
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-08-07 18:13:46
* @LastEditTime: 2024-08-08 18:39:36
* @FilePath: /data-table/src/components/DatePickerField/index.vue
* @Description: 日期选择组件
-->
......@@ -110,12 +110,20 @@ onMounted(() => {
}
// 设置默认最大最小日期
if (data_minvalue.length) {
const min = data_minvalue.split("-")
minDate.value = new Date(+min[0], +min[1] - 1, +min[2])
const min = data_minvalue.split("-");
if (date_format === 'YYYY-MM') {
minDate.value = new Date(+min[0], +min[1] - 1)
} else {
minDate.value = new Date(+min[0], +min[1] - 1, +min[2])
}
}
if (data_maxvalue.length) {
const max = data_maxvalue.split("-")
maxDate.value = new Date(+max[0], +max[1] - 1, +max[2])
const max = data_maxvalue.split("-");
if (date_format === 'YYYY-MM') {
maxDate.value = new Date(+max[0], +max[1] - 1)
} else {
maxDate.value = new Date(+max[0], +max[1] - 1, +max[2])
}
}
});
......