Commit 8e14f9d6 authored by 秦垚玲's avatar 秦垚玲

fix:单位结算查询调整

parent 6587d82f
...@@ -622,6 +622,9 @@ function getTodayYYYYMMDD() { ...@@ -622,6 +622,9 @@ function getTodayYYYYMMDD() {
return `${y}${m}${d}`; return `${y}${m}${d}`;
} }
let startDate = "";
let endDate = "";
// 页面加载默认赋值 // 页面加载默认赋值
window.addEventListener("DOMContentLoaded", () => { window.addEventListener("DOMContentLoaded", () => {
const today = getTodayYYYYMMDD(); const today = getTodayYYYYMMDD();
...@@ -632,14 +635,8 @@ window.addEventListener("DOMContentLoaded", () => { ...@@ -632,14 +635,8 @@ window.addEventListener("DOMContentLoaded", () => {
document.getElementById("dateFrom").value = startDate; document.getElementById("dateFrom").value = startDate;
document.getElementById("dateTo").value = endDate; document.getElementById("dateTo").value = endDate;
}); });
/** /**
* 解析 YYYYMMDD 格式为 Date 对象 * 解析 YYYYMMDD 格式为 Date 对象
* @param {string} dateStr - 8位数字字符串,如 20250101 * @param {string} dateStr - 8位数字字符串,如 20250101
...@@ -665,36 +662,40 @@ window.addEventListener("DOMContentLoaded", () => { ...@@ -665,36 +662,40 @@ window.addEventListener("DOMContentLoaded", () => {
return Math.abs(diffDays) > 365; return Math.abs(diffDays) > 365;
} }
let startDate = ""; /**
let endDate = ""; * 检测 YYYYMMDD 格式的日期间隔是否大于三个月
* @param {string} startStr - 开始日期,如 20250101
* @param {string} endStr - 结束日期,如 20260101
* @returns {boolean}
*/
function isOver90DaysYYYYMMDD(startStr, endStr) {
const start = parseYYYYMMDD(startStr);
const end = parseYYYYMMDD(endStr);
const diffDays = (end - start) / (1000 * 60 * 60 * 24);
return Math.abs(diffDays) > 90;
}
const handleBlur = (dateId) => { const handleBlur = (dateId) => {
console.log( console.log(
"handleBlur", "handleBlur",
startDate, startDate,
endDate, endDate,
isOver365DaysYYYYMMDD(startDate, endDate), isOver90DaysYYYYMMDD(startDate, endDate),
); );
if (startDate && endDate && isOver365DaysYYYYMMDD(startDate, endDate)) { if (startDate && endDate && isOver90DaysYYYYMMDD(startDate, endDate)) {
alert("起止日期间隔不能超过365天"); alert("预约时间段不能超过3个月!");
if (dateId === "dateFrom") { if (dateId === "dateFrom") {
startDate = ""; startDate = "";
document.getElementById(dateId).value = "";
} else { } else {
endDate = ""; endDate = "";
document.getElementById(dateId).value = "";
} }
const checkedQuickDate = document.querySelector( document.getElementById(dateId).value = "";
'input[name="quickDate"]:checked',
);
checkedQuickDate && (checkedQuickDate.checked = false);
return; return;
} }
if (dateId === "dateFrom") { if (dateId === "dateFrom") {
startDate = startDate;
document.getElementById(dateId).value = startDate; document.getElementById(dateId).value = startDate;
} else { } else {
endDate = endDate;
document.getElementById(dateId).value = endDate; document.getElementById(dateId).value = endDate;
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment