改造员工页列表和新增入口
This commit is contained in:
@@ -12,11 +12,23 @@ function buildScheduleSummary(item) {
|
||||
}
|
||||
|
||||
function buildRoleText(item) {
|
||||
return Number(item.type) === 2 ? '店长' : '店员'
|
||||
if (Number(item.type) === 2 || item.identity === '店长') {
|
||||
return '店长'
|
||||
}
|
||||
return item.identity || item.roleName || '美甲师'
|
||||
}
|
||||
|
||||
function buildStatusCode(item) {
|
||||
return item.currentStatusCode || (Number(item.status) === 0 ? 'DISABLED' : 'NORMAL')
|
||||
}
|
||||
|
||||
function buildStatusText(item, statusCode) {
|
||||
return item.currentStatusText || (statusCode === 'DISABLED' ? '停用' : statusCode === 'REST' ? '休假' : '正常')
|
||||
}
|
||||
|
||||
function toEmployeeRow(item, index) {
|
||||
const name = item.nickname || item.name || item.artistName || `美甲师${index + 1}`
|
||||
const statusCode = buildStatusCode(item)
|
||||
return {
|
||||
id: item.userId || item.id,
|
||||
name,
|
||||
@@ -25,16 +37,48 @@ function toEmployeeRow(item, index) {
|
||||
color: item.color || EMPLOYEE_COLORS[index % EMPLOYEE_COLORS.length],
|
||||
monthOrders: item.monthOrders || item.orderCount || 0,
|
||||
monthAmount: item.monthAmount || item.turnover || 0,
|
||||
todayOrders: item.todayOrders || item.todayAppointments || item.todayAppointmentCount || 0,
|
||||
avgAmount: item.avgAmount || 0,
|
||||
scheduleSummary: buildScheduleSummary(item),
|
||||
roleText: buildRoleText(item),
|
||||
statusCode,
|
||||
statusText: buildStatusText(item, statusCode),
|
||||
statusClass: statusCode === 'DISABLED' ? 'disabled' : statusCode === 'REST' ? 'rest' : 'normal',
|
||||
isManager: Number(item.type) === 2
|
||||
}
|
||||
}
|
||||
|
||||
function buildStatusFilters(rows) {
|
||||
const countByStatus = rows.reduce((map, item) => {
|
||||
map[item.statusCode] = (map[item.statusCode] || 0) + 1
|
||||
return map
|
||||
}, {})
|
||||
return [
|
||||
{ value: 'ALL', label: '全部', count: rows.length },
|
||||
{ value: 'NORMAL', label: '正常', count: countByStatus.NORMAL || 0 },
|
||||
{ value: 'REST', label: '休假', count: countByStatus.REST || 0 },
|
||||
{ value: 'DISABLED', label: '停用', count: countByStatus.DISABLED || 0 }
|
||||
]
|
||||
}
|
||||
|
||||
function filterEmployees(rows, status) {
|
||||
if (status === 'ALL') {
|
||||
return rows
|
||||
}
|
||||
return rows.filter(item => item.statusCode === status)
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
managers: [],
|
||||
allEmployees: [],
|
||||
employees: [],
|
||||
statusFilters: [
|
||||
{ value: 'ALL', label: '全部', count: 0 },
|
||||
{ value: 'NORMAL', label: '正常', count: 0 },
|
||||
{ value: 'REST', label: '休假', count: 0 },
|
||||
{ value: 'DISABLED', label: '停用', count: 0 }
|
||||
],
|
||||
activeStatus: 'ALL',
|
||||
loadError: '',
|
||||
createModalVisible: false,
|
||||
creating: false,
|
||||
@@ -61,18 +105,28 @@ Page({
|
||||
const rows = list.map(toEmployeeRow)
|
||||
this.setData({
|
||||
loadError: '',
|
||||
managers: rows.filter(item => item.isManager),
|
||||
employees: rows.filter(item => !item.isManager)
|
||||
allEmployees: rows,
|
||||
statusFilters: buildStatusFilters(rows),
|
||||
employees: filterEmployees(rows, this.data.activeStatus)
|
||||
})
|
||||
} catch (error) {
|
||||
this.setData({
|
||||
managers: [],
|
||||
allEmployees: [],
|
||||
employees: [],
|
||||
loadError: error.message || '美甲师列表加载失败'
|
||||
statusFilters: buildStatusFilters([]),
|
||||
loadError: error.message || '员工列表加载失败'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
switchStatus(event) {
|
||||
const status = event.currentTarget.dataset.status
|
||||
this.setData({
|
||||
activeStatus: status,
|
||||
employees: filterEmployees(this.data.allEmployees, status)
|
||||
})
|
||||
},
|
||||
|
||||
openDetail(event) {
|
||||
wx.navigateTo({ url: `/pages/employee-detail/index?id=${event.currentTarget.dataset.id}` })
|
||||
},
|
||||
|
||||
@@ -1,66 +1,68 @@
|
||||
<view class="page">
|
||||
<view class="list-heading">
|
||||
<text>美甲师</text>
|
||||
<button class="compact-btn add-employee-btn" bindtap="addEmployee">+</button>
|
||||
<view class="page employee-page">
|
||||
<view class="employee-header">
|
||||
<text class="employee-page-title">员工</text>
|
||||
</view>
|
||||
|
||||
<view class="list">
|
||||
<scroll-view class="employee-filter-scroll" scroll-x enable-flex>
|
||||
<view class="employee-filters">
|
||||
<view wx:for="{{statusFilters}}" wx:key="value" class="employee-filter {{activeStatus === item.value ? 'active' : ''}}" data-status="{{item.value}}" bindtap="switchStatus">
|
||||
<text>{{item.label}}({{item.count}})</text>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<view class="employee-list">
|
||||
<view wx:if="{{loadError}}" class="empty card">
|
||||
<text>{{loadError}}</text>
|
||||
<button class="secondary-btn retry-btn" bindtap="loadEmployees">重试</button>
|
||||
</view>
|
||||
<view wx:elif="{{managers.length === 0 && employees.length === 0}}" class="empty card">暂无美甲师</view>
|
||||
<view wx:elif="{{employees.length === 0}}" class="empty card">暂无员工</view>
|
||||
|
||||
<view wx:if="{{managers.length}}" class="employee-section">
|
||||
<view class="section-subtitle">店长</view>
|
||||
<view wx:for="{{managers}}" wx:key="id" class="card employee-card manager-card" data-id="{{item.id}}" bindtap="openDetail">
|
||||
<view class="employee-left">
|
||||
<view wx:if="{{item.avatar}}" class="avatar image-avatar">
|
||||
<image src="{{item.avatar}}" mode="aspectFill"></image>
|
||||
<view wx:for="{{employees}}" wx:key="id" class="card employee-card {{item.isManager ? 'manager' : ''}}" data-id="{{item.id}}" bindtap="openDetail">
|
||||
<view class="employee-avatar-wrap">
|
||||
<view wx:if="{{item.avatar}}" class="employee-avatar image-avatar">
|
||||
<image src="{{item.avatar}}" mode="aspectFill"></image>
|
||||
</view>
|
||||
<view wx:else class="employee-avatar" style="background: {{item.color}};">{{item.shortName}}</view>
|
||||
<view class="employee-dot {{item.statusClass}}"></view>
|
||||
</view>
|
||||
<view class="employee-card-body">
|
||||
<view class="employee-title-row">
|
||||
<text class="employee-name">{{item.name}}</text>
|
||||
<text class="role-tag {{item.isManager ? 'manager' : ''}}">{{item.roleText}}</text>
|
||||
</view>
|
||||
<view class="employee-status-row">
|
||||
<text class="employee-state {{item.statusClass}}">{{item.statusText}}</text>
|
||||
<text class="employee-schedule">{{item.scheduleSummary}}</text>
|
||||
</view>
|
||||
<view class="employee-metrics">
|
||||
<view class="employee-metric">
|
||||
<text class="metric-label">今日预约</text>
|
||||
<text class="metric-value">{{item.todayOrders}}</text>
|
||||
</view>
|
||||
<view wx:else class="avatar" style="background: {{item.color}};">{{item.shortName}}</view>
|
||||
<view>
|
||||
<view class="employee-title-row">
|
||||
<text class="employee-name">{{item.name}}</text>
|
||||
<text class="role-tag manager">{{item.roleText}}</text>
|
||||
</view>
|
||||
<text class="employee-schedule">{{item.scheduleSummary}}</text>
|
||||
<text class="employee-meta">本月 {{item.monthOrders}} 单 · ¥{{item.monthAmount}}</text>
|
||||
<view class="employee-metric">
|
||||
<text class="metric-label">本月订单</text>
|
||||
<text class="metric-value">{{item.monthOrders}}</text>
|
||||
</view>
|
||||
<view class="employee-metric strong">
|
||||
<text class="metric-label">本月收入</text>
|
||||
<text class="metric-value">¥{{item.monthAmount}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="employee-state">{{item.scheduleSummary === '未设置' ? '待排班' : '正常'}}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{employees.length}}" class="employee-section">
|
||||
<view class="section-subtitle">店员</view>
|
||||
<view wx:for="{{employees}}" wx:key="id" class="card employee-card" data-id="{{item.id}}" bindtap="openDetail">
|
||||
<view class="employee-left">
|
||||
<view wx:if="{{item.avatar}}" class="avatar image-avatar">
|
||||
<image src="{{item.avatar}}" mode="aspectFill"></image>
|
||||
</view>
|
||||
<view wx:else class="avatar" style="background: {{item.color}};">{{item.shortName}}</view>
|
||||
<view>
|
||||
<view class="employee-title-row">
|
||||
<text class="employee-name">{{item.name}}</text>
|
||||
<text class="role-tag">{{item.roleText}}</text>
|
||||
</view>
|
||||
<text class="employee-schedule">{{item.scheduleSummary}}</text>
|
||||
<text class="employee-meta">本月 {{item.monthOrders}} 单 · ¥{{item.monthAmount}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="employee-state">{{item.scheduleSummary === '未设置' ? '待排班' : '正常'}}</view>
|
||||
</view>
|
||||
<text class="arrow">›</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<button class="fab employee-fab" bindtap="addEmployee" aria-label="新增员工">+</button>
|
||||
|
||||
<view wx:if="{{createModalVisible}}" class="modal-mask" bindtap="closeCreateModal">
|
||||
<view class="employee-modal" catchtap="stopTap">
|
||||
<view class="modal-head">
|
||||
<view>
|
||||
<text class="modal-title">新增美甲师</text>
|
||||
</view>
|
||||
<view class="modal-close" bindtap="closeCreateModal">×</view>
|
||||
<view class="modal-close" bindtap="closeCreateModal"></view>
|
||||
</view>
|
||||
<view class="avatar-upload">
|
||||
<view wx:if="{{createForm.avatarUrl}}" class="avatar-preview image-avatar">
|
||||
|
||||
@@ -1,100 +1,98 @@
|
||||
.list-heading {
|
||||
.employee-page {
|
||||
padding-top: 30rpx;
|
||||
}
|
||||
|
||||
.employee-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
justify-content: space-between;
|
||||
margin: 0 4rpx 22rpx;
|
||||
}
|
||||
|
||||
.employee-page-title {
|
||||
color: #302a25;
|
||||
font-size: 38rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.employee-filter-scroll {
|
||||
width: 100%;
|
||||
margin-bottom: 16rpx;
|
||||
color: #4c4740;
|
||||
font-size: 28rpx;
|
||||
margin-bottom: 22rpx;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.employee-filters {
|
||||
display: flex;
|
||||
gap: 18rpx;
|
||||
width: max-content;
|
||||
min-width: 100%;
|
||||
}
|
||||
|
||||
.employee-filter {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 104rpx;
|
||||
height: 54rpx;
|
||||
padding: 0 18rpx;
|
||||
border-radius: 999rpx;
|
||||
background: rgba(255, 255, 255, 0.72);
|
||||
color: #8f877d;
|
||||
font-size: 22rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.list-heading text {
|
||||
flex: 1;
|
||||
.employee-filter.active {
|
||||
background: #eef7f0;
|
||||
color: #55786d;
|
||||
box-shadow: inset 0 0 0 1rpx rgba(111, 143, 131, 0.16);
|
||||
}
|
||||
|
||||
.list-heading .compact-btn {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.add-employee-btn {
|
||||
width: 84rpx;
|
||||
min-width: 84rpx;
|
||||
max-width: 84rpx;
|
||||
height: 84rpx;
|
||||
min-height: 84rpx;
|
||||
padding: 0;
|
||||
border-radius: 50%;
|
||||
background: #6f8f83;
|
||||
color: #fffdf8;
|
||||
font-size: 42rpx;
|
||||
font-weight: 400;
|
||||
line-height: 84rpx;
|
||||
box-shadow: 0 10rpx 22rpx rgba(111, 143, 131, 0.2);
|
||||
.employee-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 18rpx;
|
||||
}
|
||||
|
||||
.employee-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 22rpx;
|
||||
border-color: rgba(111, 143, 131, 0.1);
|
||||
gap: 18rpx;
|
||||
min-height: 156rpx;
|
||||
padding: 22rpx 18rpx;
|
||||
border-color: rgba(111, 143, 131, 0.08);
|
||||
background: rgba(255, 255, 255, 0.86);
|
||||
box-shadow: 0 8rpx 20rpx rgba(78, 96, 78, 0.045);
|
||||
animation: cardIn 180ms ease both;
|
||||
transition: transform 160ms ease, box-shadow 160ms ease;
|
||||
}
|
||||
|
||||
.employee-card.manager {
|
||||
background: rgba(255, 255, 255, 0.92);
|
||||
}
|
||||
|
||||
.employee-card:active {
|
||||
transform: scale(0.99);
|
||||
box-shadow: 0 6rpx 18rpx rgba(58, 48, 34, 0.08);
|
||||
}
|
||||
|
||||
.employee-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14rpx;
|
||||
.employee-avatar-wrap {
|
||||
position: relative;
|
||||
flex: 0 0 auto;
|
||||
width: 92rpx;
|
||||
height: 92rpx;
|
||||
}
|
||||
|
||||
.employee-section + .employee-section {
|
||||
margin-top: 24rpx;
|
||||
}
|
||||
|
||||
.section-subtitle {
|
||||
color: #6d665f;
|
||||
font-size: 24rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.manager-card {
|
||||
border-color: rgba(111, 143, 131, 0.26);
|
||||
background: #f4faf2;
|
||||
}
|
||||
|
||||
.employee-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 18rpx;
|
||||
}
|
||||
|
||||
.employee-title-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 10rpx;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
.employee-avatar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 78rpx;
|
||||
height: 78rpx;
|
||||
width: 92rpx;
|
||||
height: 92rpx;
|
||||
overflow: hidden;
|
||||
border: 4rpx solid #f5faf3;
|
||||
border-radius: 50%;
|
||||
color: #fff;
|
||||
font-size: 28rpx;
|
||||
font-size: 30rpx;
|
||||
font-weight: 900;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.image-avatar image {
|
||||
@@ -102,27 +100,68 @@
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.employee-name,
|
||||
.employee-schedule,
|
||||
.employee-meta {
|
||||
display: block;
|
||||
.employee-dot {
|
||||
position: absolute;
|
||||
right: 2rpx;
|
||||
bottom: 4rpx;
|
||||
width: 18rpx;
|
||||
height: 18rpx;
|
||||
border: 3rpx solid #fffdf8;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.employee-dot.normal {
|
||||
background: #85b58a;
|
||||
}
|
||||
|
||||
.employee-dot.rest {
|
||||
background: #d7b17d;
|
||||
}
|
||||
|
||||
.employee-dot.disabled {
|
||||
background: #b8afa6;
|
||||
}
|
||||
|
||||
.employee-card-body {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.employee-title-row,
|
||||
.employee-status-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.employee-title-row {
|
||||
gap: 10rpx;
|
||||
}
|
||||
|
||||
.employee-status-row {
|
||||
gap: 12rpx;
|
||||
margin-top: 8rpx;
|
||||
}
|
||||
|
||||
.employee-name {
|
||||
overflow: hidden;
|
||||
color: #25211d;
|
||||
font-size: 28rpx;
|
||||
font-weight: 800;
|
||||
font-size: 29rpx;
|
||||
font-weight: 900;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.role-tag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
min-height: 34rpx;
|
||||
padding: 0 12rpx;
|
||||
flex: 0 0 auto;
|
||||
min-height: 32rpx;
|
||||
padding: 0 10rpx;
|
||||
border-radius: 999rpx;
|
||||
background: #f2ede7;
|
||||
color: #7b7168;
|
||||
font-size: 20rpx;
|
||||
background: #fff0df;
|
||||
color: #bd7a4d;
|
||||
font-size: 18rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
@@ -131,33 +170,80 @@
|
||||
color: #55786d;
|
||||
}
|
||||
|
||||
.employee-meta {
|
||||
margin-top: 8rpx;
|
||||
color: #91897f;
|
||||
font-size: 24rpx;
|
||||
.employee-state {
|
||||
flex: 0 0 auto;
|
||||
min-height: 32rpx;
|
||||
padding: 0 12rpx;
|
||||
border-radius: 999rpx;
|
||||
font-size: 19rpx;
|
||||
font-weight: 900;
|
||||
line-height: 32rpx;
|
||||
}
|
||||
|
||||
.employee-state.normal {
|
||||
background: #eff7ef;
|
||||
color: #5f9070;
|
||||
}
|
||||
|
||||
.employee-state.rest {
|
||||
background: #fff4df;
|
||||
color: #b57935;
|
||||
}
|
||||
|
||||
.employee-state.disabled {
|
||||
background: #f0ece5;
|
||||
color: #8d8379;
|
||||
}
|
||||
|
||||
.employee-schedule {
|
||||
margin-top: 6rpx;
|
||||
color: #55786d;
|
||||
overflow: hidden;
|
||||
color: #9b938a;
|
||||
font-size: 21rpx;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.employee-metrics {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 8rpx;
|
||||
margin-top: 12rpx;
|
||||
}
|
||||
|
||||
.employee-metric {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.metric-label,
|
||||
.metric-value {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.metric-label {
|
||||
color: #a39a90;
|
||||
font-size: 18rpx;
|
||||
}
|
||||
|
||||
.metric-value {
|
||||
margin-top: 4rpx;
|
||||
color: #4c4740;
|
||||
font-size: 23rpx;
|
||||
font-weight: 800;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.color-pill {
|
||||
display: none;
|
||||
.employee-metric.strong .metric-value {
|
||||
color: #2f4d3d;
|
||||
}
|
||||
|
||||
.employee-state {
|
||||
.arrow {
|
||||
flex: 0 0 auto;
|
||||
min-height: 34rpx;
|
||||
padding: 0 12rpx;
|
||||
border-radius: 999rpx;
|
||||
background: #eff7ef;
|
||||
color: #5f9070;
|
||||
font-size: 19rpx;
|
||||
font-weight: 800;
|
||||
line-height: 34rpx;
|
||||
color: #b0a79e;
|
||||
font-size: 46rpx;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.employee-fab {
|
||||
bottom: calc(112rpx + env(safe-area-inset-bottom));
|
||||
}
|
||||
|
||||
.retry-btn {
|
||||
@@ -197,9 +283,6 @@
|
||||
|
||||
.modal-title {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
color: #27211d;
|
||||
font-size: 34rpx;
|
||||
font-weight: 900;
|
||||
@@ -213,22 +296,19 @@
|
||||
width: 48rpx;
|
||||
min-width: 48rpx;
|
||||
height: 48rpx;
|
||||
border-radius: 50%;
|
||||
border: 1rpx solid #e4d8ca;
|
||||
border-radius: 50%;
|
||||
background: #fffaf4;
|
||||
color: transparent;
|
||||
font-size: 0;
|
||||
line-height: 0;
|
||||
}
|
||||
|
||||
.modal-close::before,
|
||||
.modal-close::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
width: 22rpx;
|
||||
height: 3rpx;
|
||||
border-radius: 999rpx;
|
||||
background: #61554c;
|
||||
content: "";
|
||||
}
|
||||
|
||||
.modal-close::before {
|
||||
|
||||
@@ -643,3 +643,10 @@
|
||||
- 处理方式:客户新增弹层增加 200 字以内多行备注输入框;小程序提交 `remark`;后端创建 DTO 校验并写入现有用户 `signature` 字段,详情页可继续复用原备注展示。
|
||||
- 数据库说明:本次不新增 SQL,不修改初始化 SQL,不需要执行数据库迁移。
|
||||
- 验证结果:`AdminManagerControllerTest` 定向测试通过;小程序 JS、WXML、WXSS 和后端 Java 文件静态检查、BOM 检查、`git diff --check` 通过。
|
||||
|
||||
## 2026-07-25 员工页列表 UI 与状态筛选改造
|
||||
|
||||
- 变更原因:用户反馈员工页顶部角色分组块不需要,新增入口应与预约/客户页一致放到右下角,并希望列表视觉贴近参考图。
|
||||
- 处理方式:员工页移除顶部“美甲师/店员”分组块,新增右下角悬浮加号;列表改为头像、姓名、角色、当前状态、排班摘要、今日预约、本月订单和本月收入的卡片;顶部筛选改为按当前状态筛选全部/正常/休假/停用。
|
||||
- 数据库说明:本次不新增 SQL,不修改初始化 SQL,不需要执行数据库迁移。
|
||||
- 验证结果:员工页 JS、WXML、WXSS 静态检查与 BOM 检查通过,`git diff --check` 和 GitNexus staged 变更检测通过,风险 LOW 且 0 个受影响流程。
|
||||
|
||||
Reference in New Issue
Block a user