diff --git a/components.d.ts b/components.d.ts index 04ca081..0b61c80 100644 --- a/components.d.ts +++ b/components.d.ts @@ -8,7 +8,6 @@ export {} declare module 'vue' { export interface GlobalComponents { ElButton: typeof import('element-plus/es')['ElButton'] - ElCol: typeof import('element-plus/es')['ElCol'] ElDropdown: typeof import('element-plus/es')['ElDropdown'] ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem'] ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu'] @@ -17,7 +16,6 @@ declare module 'vue' { ElIcon: typeof import('element-plus/es')['ElIcon'] ElInput: typeof import('element-plus/es')['ElInput'] ElPopover: typeof import('element-plus/es')['ElPopover'] - ElRow: typeof import('element-plus/es')['ElRow'] ElTable: typeof import('element-plus/es')['ElTable'] ElTableColumn: typeof import('element-plus/es')['ElTableColumn'] ErrorModal: typeof import('./src/components/dialogs/ErrorModal.vue')['default'] diff --git a/src/pages/Index/Settings/Users.vue b/src/pages/Index/Settings/Users.vue index 742d8ad..a252371 100644 --- a/src/pages/Index/Settings/Users.vue +++ b/src/pages/Index/Settings/Users.vue @@ -26,8 +26,8 @@ :message="updatePinMessage" description="您正在更改PIN码,请谨慎操作" confirm-text="确认更新" cancel-text="取消更新" @confirm="handleConfirmUpdatePin" @cancel="handleCancelUpdatePin" /> - + @@ -39,7 +39,7 @@ @@ -190,39 +190,47 @@ const handleConfirmMsgDelete = () => { //更新PIN //定义请求 const handleUpdatePin = async () => { - if (selectedUsers.value.length!== 1) { + if (selectedUsers.value.length !== 1) { ElMessage.warning('请选择一个用户来修改PIN码') return } - const user = tempUser.value + const user = selectedUsers.value[0] const response = await changeUserPassword({ id: user.id, - password: user.password, + oldpasswd: tempUser.value.password, // 旧密码 + password: tempUser.value.password // 新密码 }) if (response && response.success) { ElMessage.success('PIN码更新成功') fetchUserList() } else { - ElMessage.error('修改用户权限失败') + ElMessage.error('修改密码失败') } } //确认更新pin,打开输入框 const handleConfirmUpdatePin = () => { + if (selectedUsers.value.length !== 1) { + ElMessage.warning('请选择一个用户来修改PIN码') + return + } updatePinModal.value = false enterPinModal.value = true } //输入pin,确认,发送请求 -const updatePinConfirm = (val: string) => { +const updatePinConfirm = (parameters: ChangePasswordParams) => { enterPinModal.value = false updatePinLoading.value = true - tempUser.value.password = val - handleUpdatePin().then(() => { + + changeUserPassword(parameters).then(() => { updatePinLoading.value = false updatePinMsgModal.value = true + }).catch(() => { + ElMessage.error('修改密码失败') + updatePinLoading.value = false }) } diff --git a/src/pages/Index/components/Setting/EnterPinModal.vue b/src/pages/Index/components/Setting/EnterPinModal.vue index 7d07e25..cef85ba 100644 --- a/src/pages/Index/components/Setting/EnterPinModal.vue +++ b/src/pages/Index/components/Setting/EnterPinModal.vue @@ -4,16 +4,37 @@ @@ -21,21 +42,49 @@ @@ -80,7 +129,7 @@ const cancel = () => { justify-content: center; position: relative; - .modal-header { + .modal-header { background-color: #528dfe; height: 8px; position: absolute; @@ -89,7 +138,7 @@ const cancel = () => { width: 100%; } - .modal-title { + .modal-title { text-align: center; margin-top: 15px; font-size: 32px; @@ -97,16 +146,16 @@ const cancel = () => { font-weight: bold; } - .modal-body { + .modal-body { display: flex; justify-content: center; padding: 20px; - .input-container { + .input-container { position: relative; width: 100%; - .pin-input { + .pin-input { box-sizing: border-box; width: 100%; font-size: 32px; @@ -124,7 +173,7 @@ const cancel = () => { } } - .modal-footer { + .modal-footer { display: flex; justify-content: space-around; padding: 20px; @@ -138,4 +187,4 @@ const cancel = () => { } } } - + \ No newline at end of file diff --git a/src/types/Index/User.ts b/src/types/Index/User.ts index b0f7829..20b598c 100644 --- a/src/types/Index/User.ts +++ b/src/types/Index/User.ts @@ -19,3 +19,9 @@ export interface CurrentUserInfo { timestamp: number success: boolean } + +export interface ChangePasswordParams { + id: number; // integer($int32) + oldpasswd: string; // string (query) + password: string; // string (query) +}