支持店长维护员工账号状态
This commit is contained in:
@@ -51,6 +51,14 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
updateStatus(userId, status) {
|
||||
return request({
|
||||
url: `/manager/employees/${userId}/status`,
|
||||
method: 'PUT',
|
||||
data: { status }
|
||||
})
|
||||
},
|
||||
|
||||
schedules(params) {
|
||||
return request({
|
||||
url: '/manager/employees/schedules',
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -71,6 +71,16 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{!loadError}}" class="card status-card">
|
||||
<view class="status-copy">
|
||||
<text class="status-title">账号状态</text>
|
||||
<text class="status-desc">停用会同步账号管理中的停用状态,并使该员工账号无法登录;休假仍通过请假/排班管理控制。</text>
|
||||
</view>
|
||||
<button class="status-btn {{employee.currentStatusCode === 'DISABLED' ? 'enable' : 'disable'}}" loading="{{statusUpdating}}" disabled="{{statusUpdating}}" bindtap="requestToggleStatus">
|
||||
{{employee.currentStatusCode === 'DISABLED' ? '恢复正常' : '停用账号'}}
|
||||
</button>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{!loadError}}" class="section">
|
||||
<view class="menu-grid">
|
||||
<view class="card menu-card" data-url="/pages/schedule-setting/index" bindtap="go">排班设置</view>
|
||||
@@ -145,4 +155,16 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{statusConfirmVisible}}" class="delete-confirm-mask" bindtap="closeStatusConfirm">
|
||||
<view class="delete-confirm-panel" catchtap="stopTap">
|
||||
<view class="delete-confirm-icon">!</view>
|
||||
<text class="delete-confirm-title">确认修改账号状态</text>
|
||||
<text class="delete-confirm-desc">{{pendingStatusValue === 0 ? '停用后该员工账号将无法登录店务系统。' : '恢复后该员工账号将重新可登录。'}}</text>
|
||||
<view class="delete-confirm-actions">
|
||||
<button class="delete-confirm-cancel" disabled="{{statusUpdating}}" bindtap="closeStatusConfirm">取消</button>
|
||||
<button class="delete-confirm-submit" loading="{{statusUpdating}}" disabled="{{statusUpdating}}" bindtap="confirmToggleStatus">{{pendingStatusText}}</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -186,6 +186,69 @@
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.status-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 24rpx;
|
||||
margin-top: 24rpx;
|
||||
padding: 28rpx;
|
||||
}
|
||||
|
||||
.status-copy {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.status-title,
|
||||
.status-desc {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.status-title {
|
||||
color: #302c27;
|
||||
font-size: 28rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.status-desc {
|
||||
margin-top: 10rpx;
|
||||
color: #7b6f66;
|
||||
font-size: 22rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.status-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-sizing: border-box;
|
||||
width: 70%;
|
||||
max-width: 360rpx;
|
||||
min-width: 0;
|
||||
min-height: 78rpx;
|
||||
margin: 0 auto;
|
||||
padding: 0;
|
||||
border-radius: 14rpx;
|
||||
font-size: 26rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.status-btn::after {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.status-btn.disable {
|
||||
border: 1rpx solid #e3b7b7;
|
||||
background: #fff2f2;
|
||||
color: #b55454;
|
||||
}
|
||||
|
||||
.status-btn.enable {
|
||||
border: 1rpx solid #b9d9c2;
|
||||
background: #eef8f0;
|
||||
color: #3f7950;
|
||||
}
|
||||
|
||||
.reset-btn::after {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user