支持店长维护员工账号状态
This commit is contained in:
@@ -18,6 +18,10 @@ Page({
|
||||
id: '',
|
||||
employee: {},
|
||||
loadError: '',
|
||||
statusUpdating: false,
|
||||
statusConfirmVisible: false,
|
||||
pendingStatusValue: 1,
|
||||
pendingStatusText: '',
|
||||
deleteConfirmVisible: false,
|
||||
deletingEmployee: false,
|
||||
resetConfirmVisible: false,
|
||||
@@ -94,6 +98,55 @@ Page({
|
||||
stopTap() {
|
||||
},
|
||||
|
||||
requestToggleStatus() {
|
||||
if (this.data.statusUpdating) {
|
||||
return
|
||||
}
|
||||
const currentStatusCode = String(this.data.employee.currentStatusCode || '').trim()
|
||||
const nextStatus = currentStatusCode === 'DISABLED' ? 1 : 0
|
||||
const pendingStatusText = nextStatus === 1 ? '恢复正常' : '停用账号'
|
||||
this.setData({
|
||||
statusConfirmVisible: true,
|
||||
pendingStatusValue: nextStatus,
|
||||
pendingStatusText
|
||||
})
|
||||
},
|
||||
|
||||
closeStatusConfirm() {
|
||||
if (this.data.statusUpdating) {
|
||||
return
|
||||
}
|
||||
this.setData({
|
||||
statusConfirmVisible: false,
|
||||
pendingStatusValue: 1,
|
||||
pendingStatusText: ''
|
||||
})
|
||||
},
|
||||
|
||||
async confirmToggleStatus() {
|
||||
if (this.data.statusUpdating || !this.data.id) {
|
||||
return
|
||||
}
|
||||
this.setData({ statusUpdating: true })
|
||||
try {
|
||||
const success = await employeesApi.updateStatus(this.data.id, this.data.pendingStatusValue)
|
||||
if (!success) {
|
||||
throw new Error('员工状态更新失败')
|
||||
}
|
||||
this.setData({
|
||||
statusConfirmVisible: false,
|
||||
pendingStatusValue: 1,
|
||||
pendingStatusText: ''
|
||||
})
|
||||
wx.showToast({ title: '状态已更新', icon: 'success' })
|
||||
await this.loadDetail()
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '员工状态更新失败', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ statusUpdating: false })
|
||||
}
|
||||
},
|
||||
|
||||
requestResetPassword() {
|
||||
if (this.data.resettingPassword) {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user