修复预约客户与员工管理问题
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
|
||||
|
||||
Reference in New Issue
Block a user