完善店务员工工时与订单记录
This commit is contained in:
@@ -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 || '美甲师列表加载失败'
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user