完善店务员工工时与订单记录

This commit is contained in:
2026-07-24 14:23:13 +08:00
parent 3a543f1d69
commit eff4e73427
20 changed files with 440 additions and 225 deletions
+25 -10
View File
@@ -11,8 +11,29 @@ function buildScheduleSummary(item) {
return time ? `${mode} ${time}` : mode
}
function buildRoleText(item) {
return Number(item.type) === 2 ? '店长' : '店员'
}
function toEmployeeRow(item, index) {
const name = item.nickname || item.name || item.artistName || `美甲师${index + 1}`
return {
id: item.userId || item.id,
name,
shortName: name.slice(-1),
avatar: item.avatar || item.avatarUrl || '',
color: item.color || EMPLOYEE_COLORS[index % EMPLOYEE_COLORS.length],
monthOrders: item.monthOrders || item.orderCount || 0,
monthAmount: item.monthAmount || item.turnover || 0,
scheduleSummary: buildScheduleSummary(item),
roleText: buildRoleText(item),
isManager: Number(item.type) === 2
}
}
Page({
data: {
managers: [],
employees: [],
loadError: '',
createModalVisible: false,
@@ -37,21 +58,15 @@ Page({
try {
const data = await employeesApi.list({ page: 1, size: 50 })
const list = data.list || data || []
const rows = list.map(toEmployeeRow)
this.setData({
loadError: '',
employees: list.map((item, index) => ({
id: item.userId || item.id,
name: item.nickname || item.name || item.artistName || `美甲师${index + 1}`,
shortName: (item.nickname || item.name || '师').slice(-1),
avatar: item.avatar || item.avatarUrl || '',
color: item.color || EMPLOYEE_COLORS[index % EMPLOYEE_COLORS.length],
monthOrders: item.monthOrders || item.orderCount || 0,
monthAmount: item.monthAmount || item.turnover || 0,
scheduleSummary: buildScheduleSummary(item)
}))
managers: rows.filter(item => item.isManager),
employees: rows.filter(item => !item.isManager)
})
} catch (error) {
this.setData({
managers: [],
employees: [],
loadError: error.message || '美甲师列表加载失败'
})
+40 -12
View File
@@ -9,20 +9,48 @@
<text>{{loadError}}</text>
<button class="secondary-btn retry-btn" bindtap="loadEmployees">重试</button>
</view>
<view wx:elif="{{employees.length === 0}}" class="empty card">暂无美甲师</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>
<text class="employee-name">{{item.name}}</text>
<text class="employee-schedule">{{item.scheduleSummary}}</text>
<text class="employee-meta">本月 {{item.monthOrders}} 单 · ¥{{item.monthAmount}}</text>
<view wx:elif="{{managers.length === 0 && 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>
<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>
</view>
<view class="color-pill" style="background: {{item.color}};"></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="color-pill" style="background: {{item.color}};"></view>
</view>
<view class="color-pill" style="background: {{item.color}};"></view>
</view>
</view>
@@ -31,12 +31,39 @@
box-shadow: 0 6rpx 18rpx rgba(58, 48, 34, 0.08);
}
.employee-section {
display: flex;
flex-direction: column;
gap: 14rpx;
}
.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.22);
}
.employee-left {
display: flex;
align-items: center;
gap: 18rpx;
}
.employee-title-row {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 10rpx;
}
.avatar {
display: flex;
align-items: center;
@@ -67,6 +94,23 @@
font-weight: 800;
}
.role-tag {
display: inline-flex;
align-items: center;
min-height: 34rpx;
padding: 0 12rpx;
border-radius: 999rpx;
background: #f2ede7;
color: #7b7168;
font-size: 20rpx;
font-weight: 900;
}
.role-tag.manager {
background: #e5eee9;
color: #55786d;
}
.employee-meta {
margin-top: 8rpx;
color: #91897f;