修复预约客户与员工管理问题
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const employeesApi = require('../../api/employees')
|
||||
const systemParameterConfigApi = require('../../api/system-parameter-config')
|
||||
|
||||
const EMPLOYEE_COLORS = ['#7AA9C2', '#8EB99B', '#BDA7D8', '#D7B17D', '#D98D8D']
|
||||
const EMPTY_FIELD_TEXT = '未填写'
|
||||
@@ -18,7 +19,9 @@ Page({
|
||||
employee: {},
|
||||
loadError: '',
|
||||
deleteConfirmVisible: false,
|
||||
deletingEmployee: false
|
||||
deletingEmployee: false,
|
||||
resetConfirmVisible: false,
|
||||
resettingPassword: false
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
@@ -84,6 +87,57 @@ Page({
|
||||
stopTap() {
|
||||
},
|
||||
|
||||
requestResetPassword() {
|
||||
if (this.data.resettingPassword) {
|
||||
return
|
||||
}
|
||||
this.setData({ resetConfirmVisible: true })
|
||||
},
|
||||
|
||||
closeResetConfirm() {
|
||||
if (this.data.resettingPassword) {
|
||||
return
|
||||
}
|
||||
this.setData({ resetConfirmVisible: false })
|
||||
},
|
||||
|
||||
async confirmResetPassword() {
|
||||
if (this.data.resettingPassword || !this.data.id) {
|
||||
return
|
||||
}
|
||||
this.setData({ resettingPassword: true })
|
||||
try {
|
||||
const success = await employeesApi.resetPassword(this.data.id)
|
||||
if (!success) {
|
||||
throw new Error('密码重置失败')
|
||||
}
|
||||
const result = await systemParameterConfigApi.getResetDefaultPassword()
|
||||
const password = String(result && result.password || '').trim()
|
||||
if (!password) {
|
||||
throw new Error('默认密码为空')
|
||||
}
|
||||
this.setData({ resetConfirmVisible: false })
|
||||
wx.showModal({
|
||||
title: '密码已重置',
|
||||
content: `系统默认密码:${password}`,
|
||||
confirmText: '复制密码',
|
||||
cancelText: '关闭',
|
||||
success: (modalResult) => {
|
||||
if (modalResult.confirm) {
|
||||
wx.setClipboardData({
|
||||
data: password,
|
||||
success: () => wx.showToast({ title: '密码已复制', icon: 'success' })
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '密码重置失败', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ resettingPassword: false })
|
||||
}
|
||||
},
|
||||
|
||||
async confirmDeleteEmployee() {
|
||||
if (this.data.deletingEmployee) {
|
||||
return
|
||||
|
||||
@@ -76,6 +76,14 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{!loadError}}" class="card reset-card">
|
||||
<view class="reset-copy">
|
||||
<text class="reset-title">重置登录密码</text>
|
||||
<text class="reset-desc">重置后使用系统默认密码登录,建议员工首次登录后修改。</text>
|
||||
</view>
|
||||
<button class="reset-btn" loading="{{resettingPassword}}" disabled="{{resettingPassword}}" bindtap="requestResetPassword">重置密码</button>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{!loadError}}" class="card delete-card">
|
||||
<view class="delete-shell">
|
||||
<view class="delete-icon">!</view>
|
||||
@@ -121,4 +129,16 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{resetConfirmVisible}}" class="delete-confirm-mask" bindtap="closeResetConfirm">
|
||||
<view class="delete-confirm-panel" catchtap="stopTap">
|
||||
<view class="delete-confirm-icon">!</view>
|
||||
<text class="delete-confirm-title">确认重置密码</text>
|
||||
<text class="delete-confirm-desc">重置后当前员工需要使用系统默认密码登录。</text>
|
||||
<view class="delete-confirm-actions">
|
||||
<button class="delete-confirm-cancel" disabled="{{resettingPassword}}" bindtap="closeResetConfirm">取消</button>
|
||||
<button class="delete-confirm-submit" loading="{{resettingPassword}}" disabled="{{resettingPassword}}" bindtap="confirmResetPassword">确认重置</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -135,6 +135,54 @@
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.reset-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 20rpx;
|
||||
margin-top: 24rpx;
|
||||
padding: 28rpx;
|
||||
}
|
||||
|
||||
.reset-copy {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.reset-title,
|
||||
.reset-desc {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.reset-title {
|
||||
color: #302c27;
|
||||
font-size: 28rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.reset-desc {
|
||||
margin-top: 10rpx;
|
||||
color: #7b6f66;
|
||||
font-size: 22rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.reset-btn {
|
||||
flex: 0 0 auto;
|
||||
min-width: 180rpx;
|
||||
margin: 0;
|
||||
border: 1rpx solid #b9d9c2;
|
||||
border-radius: 14rpx;
|
||||
background: #eef8f0;
|
||||
color: #3f7950;
|
||||
font-size: 24rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.reset-btn::after {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.delete-card {
|
||||
margin-top: 24rpx;
|
||||
padding: 28rpx;
|
||||
|
||||
Reference in New Issue
Block a user