Commit d455f31e by chenwq

feat(attendanceList): 实现考勤列表页面基础功能

- 添加 FilterBar 组件和 van-icon 图标组件
- 实现列表页面布局和样式
- 添加搜索、筛选和下拉刷新功能
- 实现模拟数据展示和点击跳转逻辑
1 parent 1f3cefba
// packageWorkspace/pages/attendanceStatis/attendanceList/attendanceList.js // packageWorkspace/pages/attendanceStatis/attendanceList/attendanceList.js
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
searchObj: {
name: "",
attendanceMonth: "",
},
filterConfig: [
{
type: "month",
label: "考勤月份",
key: "attendanceMonth",
},
],
list: [],
triggered: false,
nothing: false,
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
this.search();
}, },
/** /**
* 生命周期函数--监听页面初次渲染完成 * 筛选回调
*/ */
onReady() { onFilterChange(e) {
this.setData({
searchObj: e.detail,
});
this.search();
}, },
/** /**
* 生命周期函数--监听页面显示 * 搜索
*/ */
onShow() { search() {
this.setData({
list: [],
nothing: false,
});
// 模拟接口请求
setTimeout(() => {
this.getList();
}, 500);
}, },
/** /**
* 生命周期函数--监听页面隐藏 * 获取列表数据 (Mock)
*/ */
onHide() { getList() {
// 模拟数据
const mockList = [
{
id: 1,
mobilePhone: "",
name: "张三222222222222222222222222222222dddddddddddddddddd",
merchantId: 1001,
merchantAttendanceListId: 2001,
attendanceMonth: "2026-01",
expectedAttendanceDays: 27,
actualAttendanceDays: 27,
appealAttendanceDays: 0,
attendanceDays: 27,
superiorLeaderMobilePhone: "",
},
{
id: 2,
mobilePhone: "",
name: "张树",
merchantId: 1002,
merchantAttendanceListId: 2002,
attendanceMonth: "2025-12",
expectedAttendanceDays: 27,
actualAttendanceDays: 27,
appealAttendanceDays: 0,
attendanceDays: 27,
superiorLeaderMobilePhone: "",
},
{
id: 3,
mobilePhone: "",
name: "张上分",
merchantId: 1003,
merchantAttendanceListId: 2003,
attendanceMonth: "2025-01",
expectedAttendanceDays: 27,
actualAttendanceDays: 27,
appealAttendanceDays: 0,
attendanceDays: 27,
superiorLeaderMobilePhone: "",
},
];
// 简单的本地过滤模拟
let filteredList = mockList;
// const { name, attendanceMonth } = this.data.searchObj;
this.setData({
list: [filteredList], // 二维数组结构,保持与referralCountList一致的渲染逻辑 if needed, but simple list is better.
// Checking referralCountList.wxml: <block wx:for="{{ list }}" ...><block wx:for="{{ item }}" ...>
// It seems referralCountList uses a 2D array for pagination pages. I will mimic that structure for consistency.
triggered: false,
nothing: true, // Mocking end of list
});
}, },
/** /**
* 生命周期函数--监听页面卸载 * 下拉刷新
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/ */
onPullDownRefresh() { onPullDownRefresh() {
this.search();
}, },
/** /**
* 页面上拉触底事件的处理函数 * 上拉加载
*/ */
onReachBottom() { onReachBottom() {
// Mock no more data
}, },
/** /**
* 用户点击右上角分享 * 跳转详情 (如果有)
*/ */
onShareAppMessage() {
}
})
\ No newline at end of file \ No newline at end of file
handleDetail(e) {
const { item } = e.currentTarget.dataset;
// TODO: Navigate to detail page
console.log("Navigate to detail", item);
},
});
{ {
"usingComponents": {}, "usingComponents": {
"FilterBar": "/components/FilterBar/FilterBar",
"van-icon": "@vant/weapp/icon/index"
},
"navigationBarTitleText": "考勤列表" "navigationBarTitleText": "考勤列表"
}
\ No newline at end of file \ No newline at end of file
}
/* packageWorkspace/pages/attendanceStatis/attendanceList/attendanceList.wxss */
\ No newline at end of file \ No newline at end of file
/* packageWorkspace/pages/attendanceStatis/attendanceList/attendanceList.wxss */
page {
background: #F2F3F7;
}
.list-page {
.top-box {
background: #FFFFFF;
}
.list {
.empty-box {
width: 100%;
height: 24rpx;
}
.item {
margin: 0 24rpx 24rpx;
border-radius: 32rpx;
background: #FFFFFF;
padding: 32rpx;
.item-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 24rpx;
.name {
font-size: 32rpx;
font-weight: 600;
color: #222222;
}
.ellipsis {
overflow: hidden;
display: -webkit-box !important;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
word-break: break-all;
}
.date-row {
display: flex;
align-items: center;
flex-shrink: 0;
margin-left: 20rpx;
.date {
font-size: 28rpx;
color: #333333;
margin-right: 8rpx;
}
}
}
.item-body {
display: flex;
justify-content: space-between;
align-items: center;
.stat-item {
display: flex;
align-items: center;
.label {
font-size: 26rpx;
color: #999999;
margin-right: 16rpx;
}
.value {
font-size: 28rpx;
color: #222222;
font-weight: 500;
}
}
}
}
.list-nothing {
text-align: center;
font-size: 24rpx;
color: #999;
padding: 20rpx 0;
}
}
}
<!--packageWorkspace/pages/attendanceStatis/attendanceList/attendanceList.wxml--> <!--packageWorkspace/pages/attendanceStatis/attendanceList/attendanceList.wxml-->
<text>packageWorkspace/pages/attendanceStatis/attendanceList/attendanceList.wxml</text>
\ No newline at end of file \ No newline at end of file
<view class="list-page">
<view class="top-box">
<FilterBar
searchPlaceholder="员工姓名"
searchKey="name"
filters="{{filterConfig}}"
searchObj="{{searchObj}}"
bind:filterChange="onFilterChange"
></FilterBar>
</view>
<scroll-view
scroll-y
enable-back-to-top
refresher-enabled="{{ true }}"
bindrefresherrefresh="search"
bindscrolltolower="onReachBottom"
class="list"
style="height:calc(100vh - var(--fontSize184));"
refresher-threshold="104"
refresher-triggered="{{ triggered }}"
>
<block wx:if="{{ list.length > 0 }}">
<view class="empty-box"></view>
<block wx:for="{{ list }}" wx:key="index">
<block wx:for="{{ item }}" wx:for-item="li" wx:for-index="ind" wx:key="ind">
<view class="item" bindtap="handleDetail" data-item="{{li}}">
<view class="item-header">
<view class="name ellipsis">{{li.name}}</view>
<view class="date-row">
<text class="date">{{li.attendanceMonth}}</text>
<van-icon name="arrow" color="#ccc" size="16px" />
</view>
</view>
<view class="item-body">
<view class="stat-item">
<text class="label">应出勤天数</text>
<text class="value">{{li.expectedAttendanceDays}}</text>
</view>
<view class="stat-item">
<text class="label">实际出勤天数</text>
<text class="value">{{li.attendanceDays}}</text>
</view>
</view>
</view>
</block>
</block>
<block wx:if="{{ nothing }}">
<view class="list-nothing">到底了~</view>
</block>
</block>
<block wx:else>
<empty-data />
</block>
</scroll-view>
</view>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!