小程序页面视觉对齐二期:预约图片轮播、订单数据预览、微信用户关联与请假管理
新增预约详情作品图片轮播字段与组装;新增订单预览与未关联微信用户候选接口;补齐请假记录查询接口;订单数据预览改为四列;请假管理接入真实排班例外并支持新增;日程、我的、美甲师详情与改派选择器按设计稿微调;注册结果页与申请提交时间对齐设计稿。
This commit is contained in:
@@ -1,11 +1,186 @@
|
||||
const employeesApi = require('../../api/employees')
|
||||
const dateUtil = require('../../utils/date')
|
||||
const { showErrorToast, toUserMessage } = require('../../utils/toast')
|
||||
|
||||
function displayDate(value) {
|
||||
const text = String(value || '').slice(0, 10)
|
||||
return text || '-'
|
||||
}
|
||||
|
||||
function exceptionText(item) {
|
||||
const type = String(item.exceptionType || '').toUpperCase()
|
||||
if (type.includes('FULL')) return '全天请假'
|
||||
const start = String(item.startTime || '').slice(0, 5)
|
||||
const end = String(item.endTime || '').slice(0, 5)
|
||||
if (start || end) return `${start || '-'}-${end || '-'} 请假`
|
||||
return '请假'
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
days: Array.from({ length: 31 }).map((_, index) => ({ day: index + 1, rest: [12, 25].includes(index + 1) })),
|
||||
records: [
|
||||
{ date: '2026-06-12', text: '全天请假' },
|
||||
{ date: '2026-06-25', text: '下午请假' }
|
||||
]
|
||||
days: [],
|
||||
records: [],
|
||||
artists: [],
|
||||
artistNames: {},
|
||||
loading: false,
|
||||
loadError: '',
|
||||
formVisible: false,
|
||||
saving: false,
|
||||
form: {
|
||||
artistIndex: 0,
|
||||
workDate: dateUtil.formatDate(new Date()),
|
||||
exceptionType: 'FULL_DAY',
|
||||
startTime: '09:00',
|
||||
endTime: '18:00',
|
||||
remark: ''
|
||||
}
|
||||
},
|
||||
add() { wx.showToast({ title: '请选择日期后保存', icon: 'none' }) },
|
||||
|
||||
onLoad() {
|
||||
this.month = new Date()
|
||||
this.loadRecords()
|
||||
this.loadArtists()
|
||||
},
|
||||
|
||||
async loadArtists() {
|
||||
try {
|
||||
const data = await employeesApi.list()
|
||||
const list = data.list || data || []
|
||||
const artists = list.map(item => ({
|
||||
id: item.userId || item.id,
|
||||
name: item.nickname || item.name || item.artistName || '美甲师'
|
||||
})).filter(item => item.id)
|
||||
const artistNames = artists.reduce((map, item) => {
|
||||
map[item.id] = item.name
|
||||
return map
|
||||
}, {})
|
||||
this.setData({ artists, artistNames })
|
||||
} catch (error) {
|
||||
// 美甲师列表失败不阻塞请假记录展示。
|
||||
}
|
||||
},
|
||||
|
||||
async loadRecords() {
|
||||
const month = this.month
|
||||
const startDate = `${month.getFullYear()}-${String(month.getMonth() + 1).padStart(2, '0')}-01`
|
||||
const daysInMonth = new Date(month.getFullYear(), month.getMonth() + 1, 0).getDate()
|
||||
const endDate = `${month.getFullYear()}-${String(month.getMonth() + 1).padStart(2, '0')}-${String(daysInMonth).padStart(2, '0')}`
|
||||
this.setData({ loading: true, loadError: '' })
|
||||
try {
|
||||
const list = await employeesApi.scheduleExceptions({ startDate, endDate })
|
||||
const exceptions = Array.isArray(list) ? list : (list && list.list) || []
|
||||
const restDates = new Set(exceptions.map(item => String(item.workDate || '').slice(0, 10)))
|
||||
const days = Array.from({ length: daysInMonth }).map((_, index) => {
|
||||
const date = `${month.getFullYear()}-${String(month.getMonth() + 1).padStart(2, '0')}-${String(index + 1).padStart(2, '0')}`
|
||||
return { date, day: index + 1, rest: restDates.has(date) }
|
||||
})
|
||||
const artistNames = this.data.artistNames || {}
|
||||
const records = exceptions
|
||||
.slice()
|
||||
.sort((left, right) => String(left.workDate).localeCompare(String(right.workDate)))
|
||||
.map(item => ({
|
||||
key: item.id || `${item.workDate}-${item.artistId}`,
|
||||
date: displayDate(item.workDate),
|
||||
text: [exceptionText(item), artistNames[item.artistId]].filter(Boolean).join(' · ')
|
||||
}))
|
||||
this.setData({ days, records })
|
||||
} catch (error) {
|
||||
this.setData({ records: [], loadError: toUserMessage(error, '请假记录加载失败') })
|
||||
} finally {
|
||||
this.setData({ loading: false })
|
||||
}
|
||||
},
|
||||
|
||||
add() {
|
||||
const artists = this.data.artists || []
|
||||
if (!artists.length) {
|
||||
wx.showToast({ title: '暂无可请假的美甲师', icon: 'none' })
|
||||
return
|
||||
}
|
||||
const app = getApp()
|
||||
const userInfo = app.globalData.userInfo || {}
|
||||
const ownIndex = artists.findIndex(item => String(item.id) === String(userInfo.id))
|
||||
this.setData({
|
||||
formVisible: true,
|
||||
form: {
|
||||
artistIndex: ownIndex >= 0 ? ownIndex : 0,
|
||||
workDate: dateUtil.formatDate(new Date()),
|
||||
exceptionType: 'FULL_DAY',
|
||||
startTime: '09:00',
|
||||
endTime: '18:00',
|
||||
remark: ''
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
closeForm() {
|
||||
if (this.data.saving) return
|
||||
this.setData({ formVisible: false })
|
||||
},
|
||||
|
||||
stopTouchMove() {},
|
||||
|
||||
noop() {},
|
||||
|
||||
onArtistChange(event) {
|
||||
this.setData({ 'form.artistIndex': Number(event.detail.value) })
|
||||
},
|
||||
|
||||
onDateChange(event) {
|
||||
this.setData({ 'form.workDate': event.detail.value })
|
||||
},
|
||||
|
||||
selectType(event) {
|
||||
this.setData({ 'form.exceptionType': event.currentTarget.dataset.type })
|
||||
},
|
||||
|
||||
onStartTimeChange(event) {
|
||||
this.setData({ 'form.startTime': event.detail.value })
|
||||
},
|
||||
|
||||
onEndTimeChange(event) {
|
||||
this.setData({ 'form.endTime': event.detail.value })
|
||||
},
|
||||
|
||||
onRemarkInput(event) {
|
||||
this.setData({ 'form.remark': event.detail.value })
|
||||
},
|
||||
|
||||
async save() {
|
||||
if (this.data.saving) return
|
||||
const form = this.data.form
|
||||
const artist = this.data.artists[form.artistIndex]
|
||||
if (!artist) {
|
||||
wx.showToast({ title: '请选择美甲师', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!form.workDate) {
|
||||
wx.showToast({ title: '请选择日期后保存', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (form.exceptionType !== 'FULL_DAY' && dateUtil.minutesOfDay(form.endTime) <= dateUtil.minutesOfDay(form.startTime)) {
|
||||
wx.showToast({ title: '结束时间需晚于开始时间', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.setData({ saving: true })
|
||||
try {
|
||||
await employeesApi.saveScheduleException({
|
||||
artistId: artist.id,
|
||||
workDate: form.workDate,
|
||||
exceptionType: form.exceptionType,
|
||||
startTime: form.exceptionType === 'FULL_DAY' ? undefined : form.startTime,
|
||||
endTime: form.exceptionType === 'FULL_DAY' ? undefined : form.endTime,
|
||||
remark: form.remark || undefined
|
||||
})
|
||||
this.setData({ formVisible: false })
|
||||
wx.showToast({ title: '请假已保存' })
|
||||
this.loadRecords()
|
||||
} catch (error) {
|
||||
showErrorToast(error, '请假保存失败')
|
||||
} finally {
|
||||
this.setData({ saving: false })
|
||||
}
|
||||
},
|
||||
|
||||
back() { wx.navigateBack() }
|
||||
})
|
||||
|
||||
@@ -1,12 +1,72 @@
|
||||
<view class="page no-tab">
|
||||
<view class="card mini-calendar">
|
||||
<view wx:for="{{days}}" wx:key="date" class="mini-day {{item.rest ? 'rest' : ''}}">{{item.day}}</view>
|
||||
<view class="card leave-card">
|
||||
<view class="leave-calendar">
|
||||
<view wx:for="{{days}}" wx:key="date" class="leave-day {{item.rest ? 'rest' : ''}}">{{item.day}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="section">
|
||||
<view class="section-title">请假记录</view>
|
||||
<view class="list">
|
||||
<view wx:for="{{records}}" wx:key="date" class="card list-card">{{item.date}} {{item.text}}</view>
|
||||
<view class="section-head">
|
||||
<text class="section-title">请假记录</text>
|
||||
<text wx:if="{{loading}}" class="section-note">加载中</text>
|
||||
</view>
|
||||
<view wx:if="{{loadError}}" class="card record-empty">{{loadError}}</view>
|
||||
<view wx:elif="{{!records.length}}" class="card record-empty">暂无请假记录</view>
|
||||
<view wx:else class="list">
|
||||
<view wx:for="{{records}}" wx:key="key" class="card record-card">
|
||||
<text class="record-date">{{item.date}}</text>
|
||||
<text class="record-text">{{item.text}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="fixed-bottom"><button class="primary-btn leave-add" bindtap="add">新增请假</button></view>
|
||||
|
||||
<view wx:if="{{formVisible}}" class="sheet-mask" catchtouchmove="stopTouchMove" bindtap="closeForm">
|
||||
<view class="sheet" catchtap="noop">
|
||||
<view class="sheet-head">
|
||||
<text class="sheet-title">新增请假</text>
|
||||
<text class="sheet-close" bindtap="closeForm">×</text>
|
||||
</view>
|
||||
<view class="sheet-body">
|
||||
<view class="sheet-field">
|
||||
<text class="sheet-label">美甲师</text>
|
||||
<picker range="{{artists}}" range-key="name" value="{{form.artistIndex}}" bindchange="onArtistChange">
|
||||
<view class="sheet-value">{{artists[form.artistIndex].name || '请选择'}}</view>
|
||||
</picker>
|
||||
</view>
|
||||
<view class="sheet-field">
|
||||
<text class="sheet-label">请假日期</text>
|
||||
<picker mode="date" value="{{form.workDate}}" bindchange="onDateChange">
|
||||
<view class="sheet-value">{{form.workDate}}</view>
|
||||
</picker>
|
||||
</view>
|
||||
<view class="sheet-field">
|
||||
<text class="sheet-label">请假类型</text>
|
||||
<view class="type-switch">
|
||||
<view class="type-option {{form.exceptionType === 'FULL_DAY' ? 'selected' : ''}}" data-type="FULL_DAY" bindtap="selectType">全天</view>
|
||||
<view class="type-option {{form.exceptionType === 'TIME_RANGE' ? 'selected' : ''}}" data-type="TIME_RANGE" bindtap="selectType">时段</view>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{form.exceptionType !== 'FULL_DAY'}}" class="sheet-field">
|
||||
<text class="sheet-label">请假时段</text>
|
||||
<view class="time-row">
|
||||
<picker mode="time" value="{{form.startTime}}" bindchange="onStartTimeChange">
|
||||
<view class="time-value">{{form.startTime}}</view>
|
||||
</picker>
|
||||
<text class="time-separator">至</text>
|
||||
<picker mode="time" value="{{form.endTime}}" bindchange="onEndTimeChange">
|
||||
<view class="time-value">{{form.endTime}}</view>
|
||||
</picker>
|
||||
</view>
|
||||
</view>
|
||||
<view class="sheet-field">
|
||||
<text class="sheet-label">备注</text>
|
||||
<input class="sheet-input" value="{{form.remark}}" placeholder="选填" bindinput="onRemarkInput" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="sheet-actions">
|
||||
<button class="secondary-btn sheet-btn" bindtap="closeForm">取消</button>
|
||||
<button class="primary-btn sheet-btn" loading="{{saving}}" disabled="{{saving}}" bindtap="save">保存</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="fixed-bottom"><button class="primary-btn" bindtap="add">新增请假</button></view>
|
||||
</view>
|
||||
|
||||
@@ -1,22 +1,192 @@
|
||||
.mini-calendar {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(7, 1fr);
|
||||
gap: 10rpx;
|
||||
padding: 18rpx;
|
||||
.leave-card {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.mini-day {
|
||||
.leave-calendar {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(7, 1fr);
|
||||
gap: 8rpx;
|
||||
}
|
||||
|
||||
.leave-day {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 64rpx;
|
||||
height: 66rpx;
|
||||
border-radius: 10rpx;
|
||||
background: #f3f7f4;
|
||||
color: #71807a;
|
||||
font-size: 29rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.mini-day.rest {
|
||||
.leave-day.rest {
|
||||
background: #e7f0f6;
|
||||
color: #6e9fbd;
|
||||
}
|
||||
|
||||
.section-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.section-note {
|
||||
color: #71807a;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.record-empty {
|
||||
padding: 36rpx 24rpx;
|
||||
color: #71807a;
|
||||
font-size: 24rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.record-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-height: 92rpx;
|
||||
padding: 0 26rpx;
|
||||
}
|
||||
|
||||
.record-date {
|
||||
color: #17211f;
|
||||
font-size: 29rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.record-text {
|
||||
margin-left: 16rpx;
|
||||
color: #71807a;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.leave-add {
|
||||
height: 80rpx;
|
||||
border-radius: 24rpx;
|
||||
font-size: 27rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.sheet-mask {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: 60;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
background: rgba(23, 33, 31, 0.42);
|
||||
}
|
||||
|
||||
.sheet {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
padding: 30rpx 28rpx calc(28rpx + env(safe-area-inset-bottom));
|
||||
border-radius: 28rpx 28rpx 0 0;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.sheet-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 12rpx;
|
||||
}
|
||||
|
||||
.sheet-title {
|
||||
color: #17211f;
|
||||
font-size: 32rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.sheet-close {
|
||||
padding: 0 10rpx;
|
||||
color: #71807a;
|
||||
font-size: 40rpx;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.sheet-field {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
min-height: 88rpx;
|
||||
border-bottom: 1rpx solid #e7ece9;
|
||||
}
|
||||
|
||||
.sheet-label {
|
||||
flex-shrink: 0;
|
||||
color: #71807a;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.sheet-value {
|
||||
min-width: 240rpx;
|
||||
color: #17211f;
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.sheet-input {
|
||||
flex: 1;
|
||||
margin-left: 24rpx;
|
||||
color: #17211f;
|
||||
font-size: 28rpx;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.type-switch {
|
||||
display: flex;
|
||||
gap: 10rpx;
|
||||
}
|
||||
|
||||
.type-option {
|
||||
padding: 10rpx 26rpx;
|
||||
border-radius: 999rpx;
|
||||
background: #f3f7f4;
|
||||
color: #71807a;
|
||||
font-size: 25rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.type-option.selected {
|
||||
background: #e5f4ed;
|
||||
color: #247b63;
|
||||
}
|
||||
|
||||
.time-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14rpx;
|
||||
}
|
||||
|
||||
.time-value {
|
||||
padding: 10rpx 22rpx;
|
||||
border-radius: 12rpx;
|
||||
background: #f3f7f4;
|
||||
color: #17211f;
|
||||
font-size: 27rpx;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.time-separator {
|
||||
color: #71807a;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.sheet-actions {
|
||||
display: flex;
|
||||
gap: 16rpx;
|
||||
margin-top: 28rpx;
|
||||
}
|
||||
|
||||
.sheet-btn {
|
||||
flex: 1;
|
||||
height: 80rpx;
|
||||
border-radius: 20rpx;
|
||||
font-size: 27rpx;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user