|
|
@@ -32,6 +32,17 @@
|
|
|
</div>
|
|
|
<el-button type="danger" @click="handleModifyPassword">修改</el-button>
|
|
|
</div>
|
|
|
+ <!-- 修改密码(普通) -->
|
|
|
+ <div class="setting-card">
|
|
|
+ <div class="setting-icon">
|
|
|
+ <el-icon :size="20" color="#fff"><Grid /></el-icon>
|
|
|
+ </div>
|
|
|
+ <div class="setting-content">
|
|
|
+ <div class="setting-title">修改密码(普通)</div>
|
|
|
+ <div class="setting-desc">适用于记得原密码时,直接更新登录密码</div>
|
|
|
+ </div>
|
|
|
+ <el-button type="danger" @click="handleChangePassword">修改</el-button>
|
|
|
+ </div>
|
|
|
|
|
|
<!-- 安全手机 -->
|
|
|
<div class="setting-card">
|
|
|
@@ -65,6 +76,25 @@
|
|
|
</template>
|
|
|
</el-dialog>
|
|
|
|
|
|
+ <!-- 普通修改密码弹窗 -->
|
|
|
+ <el-dialog v-model="normalPasswordDialogVisible" title="修改密码" width="450px">
|
|
|
+ <el-form ref="normalPasswordFormRef" :model="normalPasswordForm" :rules="normalPasswordRules" label-width="100px">
|
|
|
+ <el-form-item label="当前密码" prop="oldPassword">
|
|
|
+ <el-input v-model="normalPasswordForm.oldPassword" type="password" show-password placeholder="请输入当前密码" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="新密码" prop="newPassword">
|
|
|
+ <el-input v-model="normalPasswordForm.newPassword" type="password" show-password placeholder="请输入新密码" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="确认密码" prop="confirmPassword">
|
|
|
+ <el-input v-model="normalPasswordForm.confirmPassword" type="password" show-password placeholder="请确认新密码" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <template #footer>
|
|
|
+ <el-button @click="normalPasswordDialogVisible = false">取消</el-button>
|
|
|
+ <el-button type="danger" @click="handleSaveNormalPassword">确认</el-button>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
<!-- 修改手机弹窗 -->
|
|
|
<el-dialog v-model="phoneDialogVisible" title="修改安全手机" width="450px">
|
|
|
<el-form ref="phoneFormRef" :model="phoneForm" :rules="phoneRules" label-width="100px">
|
|
|
@@ -93,6 +123,7 @@ import { ref, reactive } from 'vue';
|
|
|
import { useRouter } from 'vue-router';
|
|
|
import { ArrowLeft, OfficeBuilding, Grid } from '@element-plus/icons-vue';
|
|
|
import { ElMessage } from 'element-plus';
|
|
|
+import { changePwd, normalChangePwd } from '@/api/pc/enterprise/index';
|
|
|
import { getCurrentUserInfo, updateComStaff } from '@/api/pc/organization/index';
|
|
|
|
|
|
const router = useRouter();
|
|
|
@@ -104,6 +135,11 @@ const passwordDialogVisible = ref(false);
|
|
|
const passwordFormRef = ref();
|
|
|
const passwordForm = reactive({ oldPassword: '', newPassword: '', confirmPassword: '' });
|
|
|
|
|
|
+// 普通修改密码弹窗相关
|
|
|
+const normalPasswordDialogVisible = ref(false);
|
|
|
+const normalPasswordFormRef = ref();
|
|
|
+const normalPasswordForm = reactive({ oldPassword: '', newPassword: '', confirmPassword: '' });
|
|
|
+
|
|
|
const validateConfirmPassword = (_rule: any, value: string, callback: any) => {
|
|
|
if (value !== passwordForm.newPassword) {
|
|
|
callback(new Error('两次输入的密码不一致'));
|
|
|
@@ -112,6 +148,14 @@ const validateConfirmPassword = (_rule: any, value: string, callback: any) => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+const validateNormalConfirmPassword = (_rule: any, value: string, callback: any) => {
|
|
|
+ if (value !== normalPasswordForm.newPassword) {
|
|
|
+ callback(new Error('两次输入的密码不一致'));
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
const passwordRules = {
|
|
|
oldPassword: [{ required: true, message: '请输入原密码', trigger: 'blur' }],
|
|
|
newPassword: [
|
|
|
@@ -124,6 +168,18 @@ const passwordRules = {
|
|
|
]
|
|
|
};
|
|
|
|
|
|
+const normalPasswordRules = {
|
|
|
+ oldPassword: [{ required: true, message: '请输入当前密码', trigger: 'blur' }],
|
|
|
+ newPassword: [
|
|
|
+ { required: true, message: '请输入新密码', trigger: 'blur' },
|
|
|
+ { min: 6, max: 20, message: '密码长度为6-20位', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ confirmPassword: [
|
|
|
+ { required: true, message: '请确认新密码', trigger: 'blur' },
|
|
|
+ { validator: validateNormalConfirmPassword, trigger: 'blur' }
|
|
|
+ ]
|
|
|
+};
|
|
|
+
|
|
|
const phoneDialogVisible = ref(false);
|
|
|
const phoneFormRef = ref();
|
|
|
const phoneForm = reactive({ phone: '', code: '' });
|
|
|
@@ -148,6 +204,34 @@ const handleModifyPassword = () => {
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
+const handleChangePassword = () => {
|
|
|
+ normalPasswordDialogVisible.value = true;
|
|
|
+};
|
|
|
+
|
|
|
+const handleSaveNormalPassword = async () => {
|
|
|
+ const valid = await normalPasswordFormRef.value?.validate();
|
|
|
+ if (!valid) return;
|
|
|
+
|
|
|
+ try {
|
|
|
+ const submitData = {
|
|
|
+ oldPassword: normalPasswordForm.oldPassword,
|
|
|
+ password: normalPasswordForm.newPassword,
|
|
|
+ confirmPassword: normalPasswordForm.confirmPassword
|
|
|
+ };
|
|
|
+
|
|
|
+ const res: any = await normalChangePwd(submitData);
|
|
|
+ if (res.code === 200) {
|
|
|
+ ElMessage.success('密码修改成功');
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ // console.error('修改密码失败:', error);
|
|
|
+ }
|
|
|
+ normalPasswordDialogVisible.value = false;
|
|
|
+ normalPasswordForm.oldPassword = '';
|
|
|
+ normalPasswordForm.newPassword = '';
|
|
|
+ normalPasswordForm.confirmPassword = '';
|
|
|
+};
|
|
|
+
|
|
|
const getCurrentUser = async () => {
|
|
|
const res = await getCurrentUserInfo();
|
|
|
companyData.contactName = res.data.contactName;
|