补齐店务端改密导出员工订单
This commit is contained in:
@@ -1,10 +1,84 @@
|
||||
const dateUtil = require('../../utils/date')
|
||||
const employeesApi = require('../../api/employees')
|
||||
|
||||
function shortDate(value) {
|
||||
return String(value || '').slice(0, 10) || '-'
|
||||
}
|
||||
|
||||
function timeRange(item) {
|
||||
const start = String(item.startTime || '').slice(11, 16)
|
||||
const end = String(item.endTime || '').slice(11, 16)
|
||||
if (!start && !end) return '-'
|
||||
return `${start || '-'}-${end || '-'}`
|
||||
}
|
||||
|
||||
function orderAmount(item) {
|
||||
const value = item.amount !== undefined && item.amount !== null ? item.amount : item.manualProductPrice
|
||||
if (value === undefined || value === null || value === '') return '0'
|
||||
const amount = Number(value)
|
||||
if (Number.isNaN(amount)) return String(value)
|
||||
return amount.toFixed(2).replace(/\.00$/, '')
|
||||
}
|
||||
|
||||
function toOrderRow(item, index) {
|
||||
return {
|
||||
id: item.orderItemId || index,
|
||||
date: item.date || shortDate(item.startTime),
|
||||
project: item.productTitle || '预约作品',
|
||||
customer: item.customerName || '到店客户',
|
||||
artist: item.artistName || '未分配',
|
||||
time: timeRange(item),
|
||||
status: item.statusText || '-',
|
||||
amount: orderAmount(item)
|
||||
}
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
orders: [
|
||||
{ id: 1, date: '2026-06-01', project: '纯色美甲', customer: '王女士', amount: 168 },
|
||||
{ id: 2, date: '2026-05-31', project: '猫眼延长', customer: '陈女士', amount: 268 },
|
||||
{ id: 3, date: '2026-05-30', project: '手部护理', customer: '林女士', amount: 98 }
|
||||
]
|
||||
id: '',
|
||||
startDate: dateUtil.formatDate(dateUtil.startOfMonth(new Date())),
|
||||
endDate: dateUtil.formatDate(new Date()),
|
||||
orders: [],
|
||||
loading: false,
|
||||
loadError: ''
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
this.setData({ id: options.id || '' })
|
||||
this.loadOrders()
|
||||
},
|
||||
|
||||
onStartDate(event) {
|
||||
this.setData({ startDate: event.detail.value }, () => this.loadOrders())
|
||||
},
|
||||
|
||||
onEndDate(event) {
|
||||
this.setData({ endDate: event.detail.value }, () => this.loadOrders())
|
||||
},
|
||||
|
||||
async loadOrders() {
|
||||
if (!this.data.id) {
|
||||
this.setData({ orders: [], loadError: '员工ID不能为空' })
|
||||
return
|
||||
}
|
||||
this.setData({ loading: true, loadError: '' })
|
||||
try {
|
||||
const list = await employeesApi.orders(this.data.id, {
|
||||
startDate: this.data.startDate,
|
||||
endDate: this.data.endDate
|
||||
})
|
||||
this.setData({
|
||||
orders: (Array.isArray(list) ? list : []).map(toOrderRow)
|
||||
})
|
||||
} catch (error) {
|
||||
this.setData({
|
||||
orders: [],
|
||||
loadError: error.message || '员工订单加载失败'
|
||||
})
|
||||
} finally {
|
||||
this.setData({ loading: false })
|
||||
}
|
||||
},
|
||||
|
||||
back() { wx.navigateBack() }
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user