Commit 0e1cbeda by chenwq

feat: 完善考勤详情页并优化申诉表单显示

- 新增考勤汇总与明细 API 接口
- 考勤详情页改为调用真实接口,支持查看每日打卡记录
- 申诉详情页格式化创建时间并调整文案显示
- 有效引荐编辑页根据 updateFlag 控制编辑状态
- 修复组件中未知业务显示为空白的问题
1 parent 5318f190
......@@ -441,6 +441,20 @@ module.exports = {
'/rop-dj-staff-miniprogram/router')
},
/** 考勤明细汇总 */
getStaffAttendSummary(data) {
return api.post('dj.staff.api.attendance.summary', data,
[],
'/rop-dj-staff-miniprogram/router')
},
/** 考勤明细 */
getStaffDailyDetail(data) {
return api.post('dj.staff.api.attendance.daily.detail', data,
[],
'/rop-dj-staff-miniprogram/router')
},
/** 员工工资申诉记录分页查询 */
getSalaryApplyList(data) {
return api.post('dj.api.staff.miniprogram.salaryapply.page', data,
......
......@@ -21,18 +21,21 @@ Page({
this.getDetailInfo()
},
dealInfo(data) {
data.createdDateTxt = new Date(data.createdDate).format("yyyy-MM-dd hh:mm:ss")
return data || {}
},
getDetailInfo() {
const {routerParams } = this.data
console.log(routerParams, '----')
const params = {
id: routerParams.id
}
api.getSalaryApplyDetail(params).then(res => {
let { code, data, message } = res;
console.log(data)
if (code == 0) {
this.setData({
info: data,
info: this.dealInfo(data),
appealTypeStr: this.getAppealTypeStr(data.appealType)
})
}
......
......@@ -3,7 +3,7 @@
<!-- Header Card -->
<view class="card header-card">
<view class="row-between">
<view class="name">{{info.staffName}} <text class="time">{{info.createdDate}}提交申请</text></view>
<view class="name">{{info.staffName}} <text class="time">{{info.createdDateTxt}}提交申请</text></view>
<!-- <view class="status">{{info.dealStatus === 1 ? '已通过' : (info.dealStatus === 2 ? '已驳回' : '待审核')}}</view> -->
</view>
<view class="row mt-20">
......@@ -21,7 +21,7 @@
<text class="value ml-20 bold">{{appealTypeStr}}</text>
</view>
<block wx:if="{{info.appealType == 1 || info.appealType == 3}}">
<block wx:if="{{info.appealType == 1}}">
<view class="row mt-20">
<text class="label">本月实际出勤天数</text>
<text class="value ml-20">{{info.actualAttendanceDays || ''}}天</text>
......@@ -33,13 +33,13 @@
</block>
<!-- Pad Info -->
<block wx:if="{{info.appealType == 2 || info.appealType == 3}}">
<block wx:if="{{info.appealType == 2}}">
<view class="row mt-20">
<text class="label">平板录音数</text>
<text class="label">平板录音完成总数</text>
<text class="value ml-20">{{info.padRecordNum || ''}}条</text>
</view>
<view class="row mt-20">
<text class="label">申诉修改平板录音数</text>
<text class="label">申诉修改录音完成总数</text>
<text class="value ml-20">{{info.applyPadRecordNum || ''}}条</text>
</view>
</block>
......@@ -56,6 +56,7 @@
data-urls="{{info.attachmentList}}"
></image>
</block>
<view wx-if="{{!info.attachmentList.length}}">-</view>
</view>
<view class="row mt-30 align-start">
......@@ -69,7 +70,7 @@
<view class="card reply-card" wx-if="{{info.dealStatus == 2}}">
<view class="card-title">总部回复</view>
<!-- Attendance Reply -->
<block wx:if="{{info.appealType == 1 || info.appealType == 3}}">
<block wx:if="{{info.appealType == 1}}">
<view class="row mt-30">
<text class="label">确认实际出勤天数</text>
<text class="value ml-20">{{info.confirmActualAttendanceDays || ''}}天</text>
......@@ -77,7 +78,7 @@
</block>
<!-- Pad Reply -->
<block wx:if="{{info.appealType == 2 || info.appealType == 3}}">
<block wx:if="{{info.appealType == 2}}">
<view class="row mt-30">
<text class="label">确认平板录音数</text>
<text class="value ml-20">{{info.confirmPadRecordNum || ''}}条</text>
......
// packageWorkspace/pages/attendanceStatis/attendanceDetail/attendanceDetail.js
const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/regional-assistant/'
import api from "../../../api";
// Store daily info at module level to be accessible by formatter
let dailyInfos = [];
Page({
/**
* 页面的初始数据
*/
data: {
IMG_URL,
detail: {
mobilePhone: "",
name: "",
positionName: "延保驻店销售",
attendanceMonth: "",
totalWorkHours: 0.0,
lateEarlyHours: 0.0,
missingPunchCount: 0,
attendanceDailyInfoDTOs: []
},
routerParams: {},
summaryInfo: {},
detail: {},
formattedMonth: "",
minDate: new Date().getTime(),
maxDate: new Date().getTime(),
selectedDate: '', // YYYY-MM-DD
selectedDate: "", // YYYY-MM-DD
currentDayInfo: null, // { workTime, offWorkTime }
formatter(day) {
const date = new Date(day.date);
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const d = date.getDate().toString().padStart(2, '0');
const month = (date.getMonth() + 1).toString().padStart(2, "0");
const d = date.getDate().toString().padStart(2, "0");
const dateStr = `${year}-${month}-${d}`;
// Find info for this date
const info = dailyInfos.find(item => item.date === dateStr);
// Workday style (Has record): workTime OR offWorkTime is present
// Weekend style (No record): Both are missing/empty
const info = dailyInfos.find((item) => item.date === dateStr);
const hasRecord = info && (info.workTime || info.offWorkTime);
if (!hasRecord) {
day.className = 'weekend-day';
day.className = "weekend-day";
}
return day;
}
},
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
// 模拟从上一页传递或接口获取数据
// 实际场景可能需要根据 options.id 去请求详情接口
// 这里直接使用 Mock 数据展示 UI
this.setData({
routerParams: JSON.parse(options.info),
});
this.getSummary();
this.getDetail();
},
getSummary() {
const { mobilePhone, attendanceMonth } = this.data.routerParams;
const params = {
mobilePhone,
attendanceMonth,
};
api.getStaffAttendSummary(params).then((res) => {
console.log(res);
let { code, data, message } = res;
if (code == "0") {
this.setData({
summaryInfo: data,
});
}
});
},
getDetail() {
// 模拟接口返回数据
const mockData = {
mobilePhone: "13800138000",
name: "董天天",
positionName: "延保驻店销售",
attendanceMonth: "2026-01",
totalWorkHours: 7.2,
lateEarlyHours: 0,
missingPunchCount: 0,
attendanceDailyInfoDTOs: [
{ date: "2026-01-01", workTime: "09:00", offWorkTime: "18:00" },
{ date: "2026-01-03", 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: "" } // 缺卡示例
]
const { mobilePhone, attendanceMonth } = this.data.routerParams;
const params = {
mobilePhone,
attendanceMonth,
};
api.getStaffDailyDetail(params).then((res) => {
console.log(res);
let { code, data, message } = res;
if (code == "0") {
// Update module-level variable
data.attendanceDailyInfoDTOs.forEach((item) => {
// 截取不要秒,格式 HH:MM
item.offWorkTime = item.offWorkTime
? item.offWorkTime.slice(0, 5)
: "";
item.workTime = item.workTime ? item.workTime.slice(0, 5) : "";
});
dailyInfos = data.attendanceDailyInfoDTOs || [];
// Update module-level variable
dailyInfos = mockData.attendanceDailyInfoDTOs || [];
// Calculate min and max date based on attendanceMonth
let minDate = new Date().getTime();
let maxDate = new Date().getTime();
let defaultDate = new Date().getTime();
if (mockData.attendanceMonth) {
const parts = mockData.attendanceMonth.split('-');
if (parts.length === 2) {
const year = parseInt(parts[0]);
const month = parseInt(parts[1]);
// minDate: 1st day of the month
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
if (defaultDate < minDate) defaultDate = minDate;
if (defaultDate > maxDate) defaultDate = maxDate;
}
}
// Calculate min and max date based on attendanceMonth
let minDate = new Date().getTime();
let maxDate = new Date().getTime();
let defaultDate = new Date().getTime();
this.setData({
detail: mockData,
formattedMonth: this.formatMonth(mockData.attendanceMonth),
minDate,
maxDate,
defaultDate
});
if (data.attendanceMonth) {
const parts = data.attendanceMonth.split("-");
if (parts.length === 2) {
const year = parseInt(parts[0]);
const month = parseInt(parts[1]);
// minDate: 1st day of the month
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 = minDate;
// Ensure defaultDate is within range
if (defaultDate < minDate) defaultDate = minDate;
if (defaultDate > maxDate) defaultDate = maxDate;
}
}
this.setData({
detail: data,
formattedMonth: this.formatMonth(data.attendanceMonth),
minDate,
maxDate,
defaultDate,
});
// Initialize selection (simulate selecting the default date)
const dateObj = new Date(defaultDate);
this.handleDateSelect(dateObj);
// Initialize selection (simulate selecting the default date)
const dateObj = new Date(defaultDate);
this.handleDateSelect(dateObj);
}
});
},
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
}
......@@ -132,16 +141,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,
});
}
})
},
});
......@@ -4,8 +4,8 @@
<view class="card user-card">
<image class="avatar" src="{{IMG_URL}}default-avatar.png" />
<view class="user-info">
<view class="name ellipsis">{{detail.name}}</view>
<view class="position ellipsis">{{detail.positionName}}</view>
<view class="name ellipsis">{{summaryInfo.name}}</view>
<view class="position ellipsis">{{summaryInfo.positionName}}</view>
</view>
</view>
......@@ -14,15 +14,15 @@
<view class="summary-title">{{formattedMonth}}汇总</view>
<view class="summary-grid">
<view class="grid-item">
<view class="value">{{detail.totalWorkHours}}</view>
<view class="value">{{summaryInfo.totalWorkHours}}</view>
<view class="label">出勤工时 (H)</view>
</view>
<view class="grid-item">
<view class="value">{{detail.lateEarlyHours}}</view>
<view class="value">{{summaryInfo.lateEarlyHours}}</view>
<view class="label">迟到早退 (H)</view>
</view>
<view class="grid-item">
<view class="value">{{detail.missingPunchCount}}</view>
<view class="value">{{summaryInfo.missingPunchCount}}</view>
<view class="label">缺卡 (次数)</view>
</view>
</view>
......
......@@ -121,8 +121,8 @@ Page({
let { target } = e.currentTarget.dataset;
wx.navigateTo({
url:
"/packageWorkspace/pages/attendanceStatis/attendanceDetail/attendanceDetail?id=" +
target.id,
"/packageWorkspace/pages/attendanceStatis/attendanceDetail/attendanceDetail?info=" +
JSON.stringify(target),
});
},
});
......@@ -16,7 +16,7 @@
<view class="header">
<view class="title-bar">
<image src="{{IMG_URL}}title_icon.png" mode=""/>
<text class="title">{{sceneMap[item.sceneType] || '未知业务'}}</text>
<text class="title">{{sceneMap[item.sceneType] || ''}}</text>
</view>
</view>
......@@ -29,12 +29,12 @@
<!-- Column 1: Delivery Count -->
<view class="grid-col">
<view class="label-text">{{utils.formatBrandName(dto.brandName)}}交车数</view>
<view class="value-text">{{dto.deliveryCount}}</view>
<view class="value-text">{{dto.deliveryCount || '-'}}</view>
</view>
<!-- Column 2: Effective Referral Count -->
<view class="grid-col">
<view class="label-text">有效引荐数</view>
<view class="value-text">{{dto.effectiveReferralCount}}</view>
<view class="value-text">{{dto.effectiveReferralCount || '-'}}</view>
</view>
<!-- Column 3: Reviewed Effective Count -->
<view class="grid-col">
......
......@@ -4,7 +4,7 @@
<view class="header">
<view class="title-bar">
<image src="{{IMG_URL}}title_icon.png" mode=""/>
<text class="title">{{sceneMap[item.sceneType] || '未知业务'}}</text>
<text class="title">{{sceneMap[item.sceneType] || ''}}</text>
</view>
</view>
......
......@@ -27,8 +27,9 @@ Page({
defaultFillVal(data) {
data.sceneTypeEffectiveReferrals.forEach(item => {
// updateFlag 是否可编辑:0-不可编辑,1-可编辑(优先级最高)
// 状态:0-未提交,1-草稿,2-已提交
if (item.status == 0) {
if (item.status == 0 && data.updateFlag == 1) {
if (item.effectiveReferralCountDTOS && item.effectiveReferralCountDTOS.length) {
item.effectiveReferralCountDTOS.forEach(k => {
k.effectiveReferralCount = (k.deliveryCount || 0) + ''
......@@ -41,9 +42,10 @@ Page({
// Simulate fetching data from backend
getDetail() {
let { merchantId } = this.data.routerParams
let { merchantId, reviewMonth } = this.data.routerParams
const params = {
merchantId
merchantId,
reviewMonth
}
api.getReferralDetail(params).then(res => {
let { code, data, message } = res;
......
......@@ -3,8 +3,9 @@
<view wx:for="{{detailInfo.sceneTypeEffectiveReferrals}}" class="edit-box">
<view class="merchant-name" wx:if="{{index == 0}}">{{detailInfo.merchantName}}</view>
<!-- Render Detail View if status is 2 (Submitted) -->
<block wx:if="{{item.status == 2}}">
<!-- updateFlag 是否可编辑:0-不可编辑,1-可编辑(优先级最高)
status 状态:0-未提交,1-草稿,2-已提交 -->
<block wx:if="{{item.status == 2 || detailInfo.updateFlag == 0 }}">
<detail-item
item="{{item}}"
class="edit-item-wrapper"
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!