重构项目文件夹目录
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
const planningApi = require('../../api/planning')
|
||||
const mock = require('../../utils/mock')
|
||||
const dateUtil = require('../../utils/date')
|
||||
|
||||
Page({
|
||||
data: {
|
||||
id: '',
|
||||
artists: [],
|
||||
selectedArtistId: '',
|
||||
date: dateUtil.formatDate(new Date()),
|
||||
time: '13:00',
|
||||
loading: false
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
this.setData({
|
||||
id: options.id || '',
|
||||
artists: mock.artists.map((item, index) => ({
|
||||
...item,
|
||||
availableStatus: index === 1 ? 'busy' : index === 2 ? 'full' : 'free',
|
||||
availableText: index === 1 ? '有冲突' : index === 2 ? '已满' : '可接'
|
||||
}))
|
||||
})
|
||||
},
|
||||
|
||||
selectArtist(event) {
|
||||
this.setData({ selectedArtistId: event.currentTarget.dataset.id })
|
||||
},
|
||||
|
||||
onDateChange(event) {
|
||||
this.setData({ date: event.detail.value })
|
||||
},
|
||||
|
||||
onTimeChange(event) {
|
||||
this.setData({ time: event.detail.value })
|
||||
},
|
||||
|
||||
async submit() {
|
||||
if (!this.data.selectedArtistId) {
|
||||
wx.showToast({ title: '请选择美甲师', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
await planningApi.moveAppointment(this.data.id, {
|
||||
artistId: Number(this.data.selectedArtistId),
|
||||
appointmentDate: this.data.date,
|
||||
appointmentTime: this.data.time
|
||||
})
|
||||
wx.showToast({ title: '已改派' })
|
||||
setTimeout(() => wx.navigateBack(), 500)
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '改派失败', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ loading: false })
|
||||
}
|
||||
},
|
||||
|
||||
back() {
|
||||
wx.navigateBack()
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"navigationBarTitleText": "改派员工"
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<view class="page no-tab">
|
||||
<view class="list">
|
||||
<view wx:for="{{artists}}" wx:key="id" class="card transfer-card {{selectedArtistId == item.id ? 'active' : ''}}" data-id="{{item.id}}" bindtap="selectArtist">
|
||||
<view class="row between">
|
||||
<view class="row">
|
||||
<view class="chip-dot large" style="background: {{item.color}};"></view>
|
||||
<view>
|
||||
<text class="artist-name">{{item.name}}</text>
|
||||
<text class="artist-status">{{item.statusText}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<text class="tag {{item.availableStatus}}">{{item.availableText}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="card form-card section">
|
||||
<view class="field">
|
||||
<text class="field-label">新日期</text>
|
||||
<picker mode="date" value="{{date}}" bindchange="onDateChange">
|
||||
<view class="field-value">{{date}}</view>
|
||||
</picker>
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label">新时间</text>
|
||||
<picker mode="time" value="{{time}}" start="10:00" end="22:00" bindchange="onTimeChange">
|
||||
<view class="field-value">{{time}}</view>
|
||||
</picker>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="fixed-bottom">
|
||||
<button class="primary-btn" loading="{{loading}}" bindtap="submit">确认改派</button>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,45 @@
|
||||
.transfer-card {
|
||||
padding: 24rpx;
|
||||
}
|
||||
|
||||
.transfer-card.active {
|
||||
outline: 3rpx solid #8fb89a;
|
||||
}
|
||||
|
||||
.chip-dot.large {
|
||||
width: 24rpx;
|
||||
height: 24rpx;
|
||||
margin-right: 16rpx;
|
||||
}
|
||||
|
||||
.artist-name,
|
||||
.artist-status {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.artist-name {
|
||||
color: #25211d;
|
||||
font-size: 30rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.artist-status {
|
||||
margin-top: 6rpx;
|
||||
color: #948c83;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.tag.free {
|
||||
background: #e5eee9;
|
||||
color: #55786d;
|
||||
}
|
||||
|
||||
.tag.busy {
|
||||
background: #fbedd7;
|
||||
color: #a5722a;
|
||||
}
|
||||
|
||||
.tag.full {
|
||||
background: #f8e2e6;
|
||||
color: #b06070;
|
||||
}
|
||||
Reference in New Issue
Block a user