|
|
@@ -70,10 +70,10 @@ Component({
|
|
|
dateArrType: 1,
|
|
|
days: [],
|
|
|
dayData: '',
|
|
|
+ isFutureDate: false,
|
|
|
},
|
|
|
observers: {
|
|
|
- "calendar.days": function (newVal) {
|
|
|
- // console.log(newVal, "newVal", this.data.calendar);
|
|
|
+ "calendar.days": function (newVal:any) {
|
|
|
if (newVal.length > 0) {
|
|
|
this.setData({
|
|
|
currentMonth: newVal[0].month,
|
|
|
@@ -122,14 +122,18 @@ Component({
|
|
|
firstDate,
|
|
|
lastDate,
|
|
|
});
|
|
|
- this.getCaRecord(this.data.id, firstDate, lastDate);
|
|
|
+ if (this.data.id) {
|
|
|
+ this.getCaRecord(this.data.id, firstDate, lastDate);
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
},
|
|
|
lifetimes: {
|
|
|
attached: async function () {
|
|
|
this.initComp();
|
|
|
- this.setData({ id: wx.getStorageSync("recordId") || "" });
|
|
|
+ this.setData({
|
|
|
+ id: wx.getStorageSync("recordId") || "",
|
|
|
+ });
|
|
|
},
|
|
|
detached: function () {
|
|
|
initialTasks.flag = "finished";
|
|
|
@@ -140,10 +144,8 @@ Component({
|
|
|
// 补卡
|
|
|
async onPatchCard(e: any) {
|
|
|
try {
|
|
|
- console.log(e, '点击补卡');
|
|
|
const cardId = e.currentTarget.dataset.id;
|
|
|
const { firstDate, lastDate } = this.data;
|
|
|
- console.log(firstDate, lastDate, "获取日期", cardId);
|
|
|
await addPatientOnlineRecord(cardId)
|
|
|
wx.showToast({
|
|
|
title: "补卡成功",
|
|
|
@@ -155,31 +157,43 @@ Component({
|
|
|
getTickleContext.call(this).showWarnMessage(error.errMsg);
|
|
|
}
|
|
|
},
|
|
|
- async getCaRecord(id, startDate, endDate) {
|
|
|
+ async getCaRecord(id: string | number, startDate: string, endDate: string) {
|
|
|
try {
|
|
|
const res = await getPatientOnlineRecord(id, startDate, endDate);
|
|
|
const { currentYear, currentMonth } = this.data;
|
|
|
if (res && res.length > 0) {
|
|
|
// 1. 先筛选出本月的数据
|
|
|
const monthData = (res || []).filter(
|
|
|
- (item) =>
|
|
|
+ (item: any) =>
|
|
|
item.arrangeYear == currentYear && item.arrangeMon == currentMonth
|
|
|
);
|
|
|
// 2. 遍历本月 days,赋值
|
|
|
- (this.data.calendar.days || []).forEach((dayItem) => {
|
|
|
+ (this.data.calendar.days || []).forEach((dayItem: any) => {
|
|
|
// 只处理本月的格子
|
|
|
if (dayItem.year == currentYear && dayItem.month == currentMonth) {
|
|
|
- const match = monthData.find((d) => d.arrangeDay == dayItem.day);
|
|
|
-
|
|
|
- if (match) {
|
|
|
- dayItem.clockIn = [...match.clockIn];
|
|
|
- dayItem.noClockIn = [...match.noClockIn];
|
|
|
- dayItem.type = match.type;
|
|
|
+ // 只给当前日期及之前的日期赋值
|
|
|
+ const currentDate = new Date();
|
|
|
+ const itemDate = new Date(dayItem.year, dayItem.month - 1, dayItem.day);
|
|
|
+
|
|
|
+ // 如果日期是今天或之前,才进行赋值
|
|
|
+ if (itemDate <= currentDate) {
|
|
|
+ const match = monthData.find((d: any) => d.arrangeDay == dayItem.day);
|
|
|
+
|
|
|
+ if (match) {
|
|
|
+ dayItem.clockIn = [...match.clockIn];
|
|
|
+ dayItem.noClockIn = [...match.noClockIn];
|
|
|
+ dayItem.type = match.type;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 未来日期设置空的打卡数据,确保不显示打卡和补卡功能
|
|
|
+ dayItem.clockIn = [];
|
|
|
+ dayItem.noClockIn = [];
|
|
|
+ dayItem.type = null;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- const matchData = monthData.filter((d) => d.arrangeDay ==this.data.dayData );
|
|
|
- console.log(matchData, 'matchData');
|
|
|
+ const matchData = monthData.filter((d: any) => d.arrangeDay ==this.data.dayData );
|
|
|
+
|
|
|
if (matchData.length > 0) {
|
|
|
this.setData({
|
|
|
noClockIn: matchData[0].noClockIn,
|
|
|
@@ -189,17 +203,30 @@ Component({
|
|
|
this.setData({
|
|
|
days: this.data.calendar.days,
|
|
|
});
|
|
|
- console.log(this.data.dayData, 'dayData');
|
|
|
|
|
|
if (this.data.dateArrType == 1) {
|
|
|
const currentDay = this.data.days.find(
|
|
|
- (item) => item.lunar.isToday
|
|
|
+ (item: any) => item.lunar.isToday
|
|
|
);
|
|
|
if (currentDay) {
|
|
|
- this.setData({
|
|
|
- noClockIn: currentDay.noClockIn,
|
|
|
- clockIn: currentDay.clockIn,
|
|
|
- });
|
|
|
+ // 检查当前日期是否为未来日期
|
|
|
+ const currentDate = new Date();
|
|
|
+ const itemDate = new Date(currentDay.year, currentDay.month - 1, currentDay.day);
|
|
|
+ const isCurrentDayFuture = itemDate > currentDate;
|
|
|
+
|
|
|
+ if (!isCurrentDayFuture) {
|
|
|
+ this.setData({
|
|
|
+ noClockIn: currentDay.noClockIn,
|
|
|
+ clockIn: currentDay.clockIn,
|
|
|
+ isFutureDate: false,
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.setData({
|
|
|
+ noClockIn: [],
|
|
|
+ clockIn: [],
|
|
|
+ isFutureDate: true,
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -304,22 +331,29 @@ Component({
|
|
|
selectedDate,
|
|
|
});
|
|
|
const { day, disable, clockIn, noClockIn, type } = date;
|
|
|
- this.setData({
|
|
|
- noClockIn: noClockIn,
|
|
|
- clockIn: clockIn,
|
|
|
- dayData: day,
|
|
|
- });
|
|
|
- console.log(
|
|
|
- this.data.dayData,
|
|
|
- "点击本月的日期",
|
|
|
- day,
|
|
|
- "clockIn",
|
|
|
- clockIn,
|
|
|
- "noClockIn",
|
|
|
- noClockIn,
|
|
|
- "type",
|
|
|
- type,
|
|
|
- );
|
|
|
+
|
|
|
+ // 检查是否为未来日期
|
|
|
+ const currentDate = new Date();
|
|
|
+ const itemDate = new Date(date.year, date.month - 1, date.day);
|
|
|
+ const isFutureDate = itemDate > currentDate;
|
|
|
+
|
|
|
+ // 如果是未来日期,设置空的打卡数据,但仍然可以点击
|
|
|
+ if (isFutureDate) {
|
|
|
+ this.setData({
|
|
|
+ noClockIn: [],
|
|
|
+ clockIn: [],
|
|
|
+ dayData: day,
|
|
|
+ isFutureDate: true,
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.setData({
|
|
|
+ noClockIn: noClockIn || [],
|
|
|
+ clockIn: clockIn || [],
|
|
|
+ dayData: day,
|
|
|
+ isFutureDate: false,
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
if (disable || !day) return;
|
|
|
const config = this.data.calendarConfig || this.config || {};
|
|
|
const { multi, chooseAreaMode } = config;
|