完善店务端员工新增和删除
This commit is contained in:
@@ -30,6 +30,13 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
deleteUser(userId) {
|
||||
return request({
|
||||
url: `/manager/employees/${userId}`,
|
||||
method: 'DELETE'
|
||||
})
|
||||
},
|
||||
|
||||
schedules(params) {
|
||||
return request({
|
||||
url: '/manager/employees/schedules',
|
||||
|
||||
@@ -6,7 +6,8 @@ Page({
|
||||
data: {
|
||||
id: '',
|
||||
employee: {},
|
||||
loadError: ''
|
||||
loadError: '',
|
||||
deletingEmployee: false
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
@@ -44,6 +45,44 @@ Page({
|
||||
wx.navigateTo({ url: `${event.currentTarget.dataset.url}?id=${this.data.id}` })
|
||||
},
|
||||
|
||||
requestDeleteEmployee() {
|
||||
if (this.data.deletingEmployee) {
|
||||
return
|
||||
}
|
||||
wx.showModal({
|
||||
title: '删除员工',
|
||||
content: '确定要删除该员工吗?该操作只移除当前店铺员工关系,不会删除登录账号。',
|
||||
confirmText: '删除',
|
||||
confirmColor: '#BF4949',
|
||||
success: (result) => {
|
||||
if (result.confirm) {
|
||||
this.confirmDeleteEmployee()
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
async confirmDeleteEmployee() {
|
||||
if (!this.data.id) {
|
||||
return
|
||||
}
|
||||
this.setData({ deletingEmployee: true })
|
||||
try {
|
||||
const success = await employeesApi.deleteUser(this.data.id)
|
||||
if (!success) {
|
||||
throw new Error('员工不存在或已被删除')
|
||||
}
|
||||
wx.showToast({ title: '员工已删除', icon: 'success' })
|
||||
setTimeout(() => {
|
||||
wx.navigateBack()
|
||||
}, 600)
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '员工删除失败', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ deletingEmployee: false })
|
||||
}
|
||||
},
|
||||
|
||||
back() {
|
||||
wx.navigateBack()
|
||||
}
|
||||
|
||||
@@ -38,4 +38,12 @@
|
||||
<view class="card menu-card" data-url="/pages/employee-orders/index" bindtap="go">订单记录</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{!loadError}}" class="card delete-card">
|
||||
<view>
|
||||
<text class="delete-title">删除员工</text>
|
||||
<text class="delete-desc">删除后该员工会从当前店铺员工列表移除,登录账号仍会保留。</text>
|
||||
</view>
|
||||
<button class="delete-btn" loading="{{deletingEmployee}}" bindtap="requestDeleteEmployee">删除员工</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -83,3 +83,42 @@
|
||||
font-size: 30rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.delete-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 20rpx;
|
||||
margin-top: 24rpx;
|
||||
padding: 24rpx;
|
||||
}
|
||||
|
||||
.delete-title,
|
||||
.delete-desc {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.delete-title {
|
||||
color: #302c27;
|
||||
font-size: 28rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.delete-desc {
|
||||
margin-top: 8rpx;
|
||||
color: #91897f;
|
||||
font-size: 22rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.delete-btn {
|
||||
flex: 0 0 auto;
|
||||
min-width: 172rpx;
|
||||
margin: 0;
|
||||
border: 0;
|
||||
border-radius: 999rpx;
|
||||
background: #BF4949;
|
||||
color: #fff;
|
||||
font-size: 24rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
@@ -137,8 +137,8 @@ Page({
|
||||
const phone = String(form.phone || '').trim()
|
||||
const account = String(form.account || '').trim()
|
||||
const password = String(form.password || '').trim()
|
||||
const wechatId = String(form.wechatId || '').trim()
|
||||
if (!nickname || !phone || !account || !password || !wechatId) {
|
||||
const wechatId = String(form.wechatId || '').trim() || phone
|
||||
if (!nickname || !phone || !account || !password) {
|
||||
wx.showToast({ title: '请补全美甲师信息', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
<input value="{{createForm.password}}" data-field="password" bindinput="onCreateInput" password placeholder="请输入密码" />
|
||||
</view>
|
||||
<view class="modal-field">
|
||||
<text class="required-label">微信号</text>
|
||||
<text>微信号</text>
|
||||
<input value="{{createForm.wechatId}}" data-field="wechatId" bindinput="onCreateInput" placeholder="请输入微信号" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
Reference in New Issue
Block a user