Commit c9f649d6 by chenwq

feat(attendanceDetail): 添加周末日期样式并优化用户信息显示

- 为日历组件添加周末日期样式,周末日期显示为灰色
- 将用户头像从图标替换为默认头像图片
- 为用户名和职位名称添加省略号样式,防止长文本溢出
- 修复数据格式一致性,使用统一的引号风格
1 parent 62f5d469
......@@ -83,7 +83,8 @@
"pages/performanceRating/ruleNote/ruleNote",
"pages/performanceRating/rateDetail/rateDetail",
"pages/performanceRating/batchOperation/batchOperation",
"pages/validReferralCount/referraCountEdit/referraCountEdit"
"pages/validReferralCount/referraCountEdit/referraCountEdit",
"pages/attendanceStatis/attendanceDetail/attendanceDetail"
]
},
{
......
// packageWorkspace/pages/attendanceStatis/attendanceDetail/attendanceDetail.js
const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/regional-assistant/'
Page({
/**
* 页面的初始数据
*/
......@@ -15,13 +14,21 @@ Page({
totalWorkHours: 0.0,
lateEarlyHours: 0.0,
missingPunchCount: 0,
attendanceDailyInfoDTOs: []
attendanceDailyInfoDTOs: [],
},
formattedMonth: "",
minDate: new Date().getTime(),
maxDate: new Date().getTime(),
selectedDate: '', // YYYY-MM-DD
currentDayInfo: null // { workTime, offWorkTime }
selectedDate: "", // YYYY-MM-DD
currentDayInfo: null, // { workTime, offWorkTime }
formatter(day) {
const date = new Date(day.date);
const dayOfWeek = date.getDay();
if (dayOfWeek === 0 || dayOfWeek === 6) {
day.className = "weekend-day";
}
return day;
},
},
/**
......@@ -38,7 +45,7 @@ Page({
// 模拟接口返回数据
const mockData = {
mobilePhone: "13800138000",
name: "董天天",
name: "董天天22222222222222222222222222222222222222222222222222222222",
positionName: "延保驻店销售",
attendanceMonth: "2026-01",
totalWorkHours: 7.2,
......@@ -49,8 +56,8 @@ Page({
{ date: "2026-01-02", workTime: "08:55", offWorkTime: "18:05" },
{ date: "2026-01-05", workTime: "", offWorkTime: "18:00" }, // 缺卡示例
{ date: "2026-01-06", workTime: "09:00", offWorkTime: "" }, // 缺卡示例
{ date: "2026-01-07", workTime: "", offWorkTime: "" } // 缺卡示例
]
{ date: "2026-01-07", workTime: "", offWorkTime: "" }, // 缺卡示例
],
};
// Calculate min and max date based on attendanceMonth
......@@ -59,7 +66,7 @@ Page({
let defaultDate = new Date().getTime();
if (mockData.attendanceMonth) {
const parts = mockData.attendanceMonth.split('-');
const parts = mockData.attendanceMonth.split("-");
if (parts.length === 2) {
const year = parseInt(parts[0]);
const month = parseInt(parts[1]);
......@@ -67,7 +74,7 @@ Page({
minDate = new Date(year, month - 1, 1).getTime();
// maxDate: Last day of the month
maxDate = new Date(year, month, 0).getTime();
// Default to the 5th for demo purposes as per screenshot, or minDate
defaultDate = new Date(year, month - 1, 5).getTime();
// Ensure defaultDate is within range
......@@ -81,7 +88,7 @@ Page({
formattedMonth: this.formatMonth(mockData.attendanceMonth),
minDate,
maxDate,
defaultDate
defaultDate,
});
// Initialize selection (simulate selecting the default date)
......@@ -92,7 +99,7 @@ Page({
formatMonth(monthStr) {
if (!monthStr) return "";
// 假设 monthStr 格式为 "YYYY-MM"
const parts = monthStr.split('-');
const parts = monthStr.split("-");
if (parts.length === 2) {
return `${parts[0]}年${parseInt(parts[1])}月`; // parseInt 去掉月份前导0
}
......@@ -105,16 +112,18 @@ Page({
handleDateSelect(date) {
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const day = date.getDate().toString().padStart(2, '0');
const month = (date.getMonth() + 1).toString().padStart(2, "0");
const day = date.getDate().toString().padStart(2, "0");
const dateStr = `${year}-${month}-${day}`;
// Find info for this date
const dayInfo = this.data.detail.attendanceDailyInfoDTOs.find(item => item.date === dateStr);
const dayInfo = this.data.detail.attendanceDailyInfoDTOs.find(
(item) => item.date === dateStr,
);
this.setData({
selectedDate: dateStr,
currentDayInfo: dayInfo || null
currentDayInfo: dayInfo || null,
});
}
})
},
});
......@@ -130,6 +130,11 @@ page {
height: 0 !important;
}
/* Weekend Style */
.weekend-day {
color: #C8C9CC !important;
}
.attendance-time {
margin: 24rpx 32rpx 0;
padding-top: 46rpx;
......
......@@ -2,12 +2,10 @@
<view class="container">
<!-- User Info Card -->
<view class="card user-card">
<view class="avatar">
<van-icon name="manager" color="#fff" size="24px" />
</view>
<image class="avatar" src="{{IMG_URL}}default-avatar.png" />
<view class="user-info">
<view class="name">{{detail.name}}</view>
<view class="position">{{detail.positionName}}</view>
<view class="name ellipsis">{{detail.name}}</view>
<view class="position ellipsis">{{detail.positionName}}</view>
</view>
</view>
......@@ -46,6 +44,7 @@
default-date="{{ defaultDate }}"
class="calendar"
row-height="32"
formatter="{{ formatter }}"
bind:select="onSelect"
/>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!