Commit d674968d authored by weishengfei's avatar weishengfei

refactor(calendar): 优化日期选择逻辑

- 修改 todayDateString 计算逻辑,使用下个月的第0天(即当前月的最后一天)
- 更新日期选择限制,禁止选择未来日期
- 优化代码结构,移除不必要的注释和冗余代码
parent 3f3577ab
...@@ -338,7 +338,7 @@ const onSave = throttleTap( async () => { ...@@ -338,7 +338,7 @@ const onSave = throttleTap( async () => {
} }
console.log(param, '参数') console.log(param, '参数')
showLoading(); showLoading();
const {success, data} = await getAdd(param); const {success, data } = await getAdd(param);
hideLoading(); hideLoading();
if (success) { if (success) {
uni.showToast({ uni.showToast({
...@@ -364,41 +364,7 @@ const onSeeBtn = () => { ...@@ -364,41 +364,7 @@ const onSeeBtn = () => {
// 获取产检项目列表 // 获取产检项目列表
const getList = async () => { const getList = async () => {
const {success, data, message} = await getExaminationItems() const {success, data, message } = await getExaminationItems()
// const { success, message, data } = {
// success: true,
// message: '',
// data:
// [
// {
// "groupName": "A",
// "list": [{
// id: 'A001',
// itemName: "阿克苏机场",
// introduction: 'NT可以帮助判断胎宝宝是否患有唐氏综合征等染色体异常,或存在畸形的风险,有助于早期发现胎儿异常风险问题。 NT检查通常在孕 1'
// },
// {
// id: 'A002',
// itemName: "阿拉山口机场阿拉山口机场阿拉山口机场",
// introduction: 'NT可以帮助判断胎宝宝是否患有唐氏综合征等染色体异常,或存在畸形的风险,有助于早期发现胎儿异常风险问题。 NT检查通常在孕 1'
// }
// ]
// }, {
// "groupName": "B",
// "list": [{
// id: 'B001',
// itemName: "保山机场",
// introduction: 'NT可以帮助判断胎宝宝是否患有唐氏综合征等染色体异常,或存在畸形的风险,有助于早期发现胎儿异常风险问题。 NT检查通常在孕 1'
// },
// {
// id: 'B002',
// itemName: "包头机场",
// introduction: 'NT可以帮助判断胎宝宝是否患有唐氏综合征等染色体异常,或存在畸形的风险,有助于早期发现胎儿异常风险问题。 NT检查通常在孕 1NT可以帮助判断胎宝宝是否患有唐氏综合征等染色体异常,或存在畸形的风险,有助于早期发现胎儿异常风险问题。 NT检查通常在孕 1NT可以帮助判断胎宝宝是否患有唐氏综合征等染色体异常,或存在畸形的风险,有助于早期发现胎儿异常风险问题。 NT检查通常在孕 1NT可以帮助判断胎宝宝是否患有唐氏综合征等染色体异常,或存在畸形的风险,有助于早期发现胎儿异常风险问题。 NT检查通常在孕 1NT可以帮助判断胎宝宝是否患有唐氏综合征等染色体异常,或存在畸形的风险,有助于早期发现胎儿异常风险问题。 NT检查通常在孕 1NT可以帮助判断胎宝宝是否患有唐氏综合征等染色体异常,或存在畸形的风险,有助于早期发现胎儿异常风险问题。 NT检查通常在孕 1'
// }
// ]
// }
// ]
// }
if (success) { if (success) {
examinationList.value = data examinationList.value = data
} }
......
...@@ -148,12 +148,6 @@ ...@@ -148,12 +148,6 @@
// 删除报告单 // 删除报告单
const getDeleteFn = async (id) => { const getDeleteFn = async (id) => {
const { code, message, data, success } = await getDelete({id}) const { code, message, data, success } = await getDelete({id})
// const { code, message, data, success } = {
// code: 200,
// message: '成功',
// success: true,
// data: {}
// }
if (success) { if (success) {
uni.showToast({ uni.showToast({
title: '删除成功', title: '删除成功',
......
...@@ -199,8 +199,8 @@ function createDateObject(date) { ...@@ -199,8 +199,8 @@ function createDateObject(date) {
// 创建只包含日期部分的Date对象进行比较 // 创建只包含日期部分的Date对象进行比较
const dateOnly = new Date(date.getFullYear(), date.getMonth(), date.getDate()) const dateOnly = new Date(date.getFullYear(), date.getMonth(), date.getDate())
const todayOnly = new Date(today.getFullYear(), today.getMonth(), today.getDate()) // const todayOnly = new Date(today.getFullYear(), today.getMonth(), today.getDate())
const todayOnly = new Date(today.getFullYear(), today.getMonth() + 1, 0); // 下个月的第1天
// 修复:确保正确判断是否为当前月份 // 修复:确保正确判断是否为当前月份
const isCurrentMonth = date.getMonth() === currentMonth && date.getFullYear() === currentYear const isCurrentMonth = date.getMonth() === currentMonth && date.getFullYear() === currentYear
const isToday = isSameDay(date, today) const isToday = isSameDay(date, today)
...@@ -240,11 +240,19 @@ const earliestDateString = computed(() => { ...@@ -240,11 +240,19 @@ const earliestDateString = computed(() => {
// 日期最晚可选日期 // 日期最晚可选日期
const todayDateString = computed(() => { const todayDateString = computed(() => {
const today = new Date() const today = new Date();
const dateStr = formatDateString(today) // 获取下个月的第0天(即当前月的最后一天)
console.log('uni-datetime-picker最大可选日期:', dateStr) const nextMonthLastDay = new Date(today.getFullYear(), today.getMonth() + 1, 0);
return dateStr const dateStr = formatDateString(nextMonthLastDay);
}) console.log('uni-datetime-picker最大可选日期:', dateStr);
return dateStr;
});
// const todayDateString = computed(() => {
// const today = new Date()
// const dateStr = formatDateString(today)
// console.log('uni-datetime-picker最大可选日期:', dateStr)
// return dateStr
// })
function selectDate(dateObj) { function selectDate(dateObj) {
// 只禁止选择未来日期 // 只禁止选择未来日期
if (dateObj.isFuture) { if (dateObj.isFuture) {
...@@ -300,7 +308,8 @@ function onDateChange(event) { ...@@ -300,7 +308,8 @@ function onDateChange(event) {
// 验证选择的日期不能是未来日期 // 验证选择的日期不能是未来日期
const selectedDate = new Date(event) const selectedDate = new Date(event)
const today = new Date() const today = new Date()
const todayOnly = new Date(today.getFullYear(), today.getMonth(), today.getDate()) // const todayOnly = new Date(today.getFullYear(), today.getMonth(), today.getDate())
const todayOnly = new Date(today.getFullYear(), today.getMonth()+1, 0)
const selectedOnly = new Date(selectedDate.getFullYear(), selectedDate.getMonth(), selectedDate.getDate()) const selectedOnly = new Date(selectedDate.getFullYear(), selectedDate.getMonth(), selectedDate.getDate())
if (selectedOnly > todayOnly) { if (selectedOnly > todayOnly) {
...@@ -393,216 +402,6 @@ const getInfoFn = async () => { ...@@ -393,216 +402,6 @@ const getInfoFn = async () => {
console.log('获取信息') console.log('获取信息')
// 获取信息 // 获取信息
const {code,success, message, data } = await getInfo() const {code,success, message, data } = await getInfo()
// const {
// code,
// success,
// message,
// data
// } = {
// code: 200,
// success: true,
// message: '成功',
// data: {
// gestationalWeeks: '8', // 几周
// dueDate: '2025-10-20', // 预产期
// // 轮播数据
// bannerList: [{
// imageUrl: 'https://course.feihe.com/momclub-picture/contentLibrary/1003/banner-cl0.png',
// jumpUrl: `https://www.baidu.com`
// },
// {
// imageUrl: 'https://course.feihe.com/momclub-picture/contentLibrary/1003/banner-cl1.png',
// jumpUrl: `https://www.baidu.com`
// },
// {
// imageUrl: 'https://course.feihe.com/momclub-picture/contentLibrary/1003/banner-cl2.png',
// jumpUrl: `https://www.baidu.com`
// }
// ],
// // 产检记录
// checkupList: [{
// type: 0, // 1 是 0 否
// id: 1,
// checkupDate: '2025-07-22',
// index: '一', // 产检次数
// pregnancyWeek: '5-6', // 周数
// status: '待产检', //待产检、已过期、已产检,
// // 产检项目
// examinationItems: [{
// itemName: '测量胎儿颈部透明层厚度(NT)',
// id: 1
// },
// {
// itemName: '无创产前基因检测(NIPT)(非必查)',
// id: 2
// }
// ]
// },
// {
// type: 0, // 1 是 0 否
// id: 1,
// checkupDate: '2025-07-21',
// index: '一', // 产检次数
// pregnancyWeek: '5-6', // 周数
// status: '待产检', //待产检、已过期、已产检,
// // 产检项目
// examinationItems: [{
// itemName: '测量胎儿颈部透明层厚度(NT)',
// id: 1
// },
// {
// itemName: '无创产前基因检测(NIPT)(非必查)',
// id: 2
// }
// ]
// },
// {
// type: 0, // 1 是 0 否
// id: 1,
// checkupDate: '2025-07-23',
// index: '一', // 产检次数
// pregnancyWeek: '5-6', // 周数
// status: '待产检', //待产检、已过期、已产检,
// // 产检项目
// examinationItems: [{
// itemName: '测量胎儿颈部透明层厚度(NT)',
// id: 1
// },
// {
// itemName: '无创产前基因检测(NIPT)(非必查)',
// id: 2
// }
// ]
// },
// {
// type: 0, // 1 是 0 否
// id: 1,
// checkupDate: '2025-07-23',
// index: '一', // 产检次数
// pregnancyWeek: '5-6', // 周数
// status: '待产检', //待产检、已过期、已产检,
// // 产检项目
// examinationItems: [{
// itemName: '测量胎儿颈部透明层厚度(NT)',
// id: 1
// },
// {
// itemName: '无创产前基因检测(NIPT)(非必查)',
// id: 2
// }
// ]
// },
// {
// type: 0, // 1 是 0 否
// id: 1,
// checkupDate: '2025-07-23',
// index: '一', // 产检次数
// pregnancyWeek: '5-6', // 周数
// status: '待产检', //待产检、已过期、已产检,
// // 产检项目
// examinationItems: [{
// itemName: '测量胎儿颈部透明层厚度(NT)',
// id: 1
// },
// {
// itemName: '无创产前基因检测(NIPT)(非必查)',
// id: 2
// }
// ]
// },
// {
// type: 0, // 1 是 0 否
// id: 1,
// checkupDate: '2025-07-23',
// index: '一', // 产检次数
// pregnancyWeek: '5-6', // 周数
// status: '待产检', //待产检、已过期、已产检,
// // 产检项目
// examinationItems: [{
// itemName: '测量胎儿颈部透明层厚度(NT)',
// id: 1
// },
// {
// itemName: '无创产前基因检测(NIPT)(非必查)',
// id: 2
// }
// ]
// },
// {
// type: 0, // 1 是 0 否
// id: 1,
// checkupDate: '2025-07-23',
// index: '一', // 产检次数
// pregnancyWeek: '5-6', // 周数
// status: '待产检', //待产检、已过期、已产检,
// // 产检项目
// examinationItems: [{
// itemName: '测量胎儿颈部透明层厚度(NT)',
// id: 1
// },
// {
// itemName: '无创产前基因检测(NIPT)(非必查)',
// id: 2
// }
// ]
// },
// {
// type: 0, // 1 是 0 否
// id: 1,
// checkupDate: '2025-07-23',
// index: '一', // 产检次数
// pregnancyWeek: '5-6', // 周数
// status: '待产检', //待产检、已过期、已产检,
// // 产检项目
// examinationItems: [{
// itemName: '测量胎儿颈部透明层厚度(NT)',
// id: 1
// },
// {
// itemName: '无创产前基因检测(NIPT)(非必查)',
// id: 2
// }
// ]
// },
// {
// type: 0, // 1 是 0 否
// id: 1,
// checkupDate: '2025-07-23',
// index: '一', // 产检次数
// pregnancyWeek: '5-6', // 周数
// status: '待产检', //待产检、已过期、已产检,
// // 产检项目
// examinationItems: [{
// itemName: '测量胎儿颈部透明层厚度(NT)',
// id: 1
// },
// {
// itemName: '无创产前基因检测(NIPT)(非必查)',
// id: 2
// }
// ]
// },
// {
// type: 0, // 1 是 0 否
// id: 1,
// checkupDate: '2025-07-23',
// index: '一', // 产检次数
// pregnancyWeek: '5-6', // 周数
// status: '待产检', //待产检、已过期、已产检,
// // 产检项目
// examinationItems: [{
// itemName: '测量胎儿颈部透明层厚度(NT)',
// id: 1
// },
// {
// itemName: '无创产前基因检测(NIPT)(非必查)',
// id: 2
// }
// ]
// }
// ]
// }
// }
if (success) { if (success) {
info.value = data info.value = data
} else { } else {
......
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