完善店务端员工新增和删除

This commit is contained in:
2026-07-15 17:33:34 +08:00
parent ad1ae376f8
commit 00a435ecfb
12 changed files with 288 additions and 12 deletions
+40 -1
View File
@@ -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()
}