补齐店务端改密导出员工订单
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() }
|
||||
})
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
<view class="page no-tab">
|
||||
<view class="list">
|
||||
<view class="card form-card">
|
||||
<view class="field"><text class="field-label">开始日期</text><picker mode="date" value="{{startDate}}" bindchange="onStartDate"><view class="field-value">{{startDate}}</view></picker></view>
|
||||
<view class="field"><text class="field-label">结束日期</text><picker mode="date" value="{{endDate}}" bindchange="onEndDate"><view class="field-value">{{endDate}}</view></picker></view>
|
||||
</view>
|
||||
<view wx:if="{{loading}}" class="empty card">订单加载中...</view>
|
||||
<view wx:elif="{{loadError}}" class="empty card error">{{loadError}}</view>
|
||||
<view wx:elif="{{orders.length === 0}}" class="empty card">当前日期范围内没有订单</view>
|
||||
<view wx:else class="list">
|
||||
<view wx:for="{{orders}}" wx:key="id" class="card list-card order-row">
|
||||
<view>
|
||||
<text class="order-title">{{item.project}}</text>
|
||||
<text class="muted">{{item.date}} · {{item.customer}}</text>
|
||||
<text class="order-meta">{{item.artist}} · {{item.time}} · {{item.status}}</text>
|
||||
</view>
|
||||
<text class="amount">¥{{item.amount}}</text>
|
||||
</view>
|
||||
|
||||
@@ -15,3 +15,10 @@
|
||||
color: #6f8f83;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.order-meta {
|
||||
display: block;
|
||||
margin-top: 6rpx;
|
||||
color: #8b8680;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user