|
@@ -87,7 +87,7 @@
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
- <el-form label-width="100px" class="userinfo-form">
|
|
|
+ <el-form :label-width="labelWidth" class="userinfo-form">
|
|
|
<el-row :gutter="20">
|
|
|
<el-col :span="12">
|
|
|
<el-form-item :label="$t('dialog.username')">
|
|
@@ -122,20 +122,66 @@
|
|
|
</template>
|
|
|
|
|
|
</el-dialog>
|
|
|
+
|
|
|
+ <!-- 修改密码 -->
|
|
|
+ <el-dialog v-model="dialog.changePassword" align-center :append-to-body="true"
|
|
|
+ width="500" class="dialog_class" draggable>
|
|
|
+
|
|
|
+ <template #header="{ titleId, titleClass }">
|
|
|
+ <div class="my-header ">
|
|
|
+ <!-- <el-image :src="icon" fit="contain"></el-image> -->
|
|
|
+ <h4 :id="titleId" :class="titleClass">{{ $t('dialog.changePassword') }}</h4>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <el-card class="userinfo-card" shadow="never">
|
|
|
+
|
|
|
+ <el-form :label-width="labelWidth1">
|
|
|
+ <el-form-item :label="`${$t('dialog.oldPassword')}:`">
|
|
|
+ <el-input v-model="pwd.oldPassword"
|
|
|
+ type="password"
|
|
|
+ show-password
|
|
|
+ :placeholder="$t('dialog.inputOldPassword')" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item :label="`${$t('dialog.newPassword')}:`">
|
|
|
+ <el-input v-model="pwd.newPassword"
|
|
|
+ type="password"
|
|
|
+ show-password
|
|
|
+ :placeholder="$t('dialog.inputNewPassword')" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item :label="`${$t('dialog.confirmNewPassword')}:`">
|
|
|
+ <el-input v-model="pwd.confirmNewPassword"
|
|
|
+ type="password"
|
|
|
+ show-password
|
|
|
+ :placeholder="$t('dialog.inputConfirmNewPassword')" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </el-card>
|
|
|
+
|
|
|
+ <template #footer>
|
|
|
+ <span class="lastbtn">
|
|
|
+ <el-button @click="dialog.changePassword = false">{{ $t('dialog.cancel') }}</el-button>
|
|
|
+ <el-button @click="ChangePassword">
|
|
|
+ {{ $t('dialog.ok') }}
|
|
|
+ </el-button>
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
import myheader from '@/components/layout/header.vue'
|
|
|
import { RouterView, RouterLink,useRouter } from "vue-router"
|
|
|
-import { request, uploadFile } from "@/utils/request";
|
|
|
+import { request, enPassword } from "@/utils/request";
|
|
|
import { ElMessage } from 'element-plus'
|
|
|
import { useUserStore } from '@/store/user'
|
|
|
import { removeToken,removeUserId} from "@/utils/token";
|
|
|
import { ArrowDown,User,Key,SwitchButton } from '@element-plus/icons-vue'
|
|
|
import { useI18n } from 'vue-i18n'
|
|
|
|
|
|
-const { t } = useI18n()
|
|
|
+const { t, locale } = useI18n()
|
|
|
|
|
|
import set from '@/assets/img/set.png'
|
|
|
import ceng from '@/assets/img/ceng.png'
|
|
@@ -148,11 +194,25 @@ const userStore = useUserStore();
|
|
|
|
|
|
const nickName = userStore.userInfo.nickName || 'User';
|
|
|
|
|
|
+const labelWidth = computed(() => {
|
|
|
+ return locale.value === 'zh-CN' ? '80px' : '120px'
|
|
|
+})
|
|
|
+
|
|
|
+const labelWidth1 = computed(() => {
|
|
|
+ return locale.value === 'zh-CN' ? '90px' : '140px'
|
|
|
+})
|
|
|
+
|
|
|
let dialog = ref({
|
|
|
userinfoDialog: false,
|
|
|
changePassword: false,
|
|
|
});
|
|
|
|
|
|
+let pwd = ref({
|
|
|
+ oldPassword: '',
|
|
|
+ newPassword: '',
|
|
|
+ confirmNewPassword: ''
|
|
|
+})
|
|
|
+
|
|
|
const activeIndex = computed(() => {
|
|
|
// 获取当前路由的所有匹配路径
|
|
|
const matched = router.currentRoute.value.matched
|
|
@@ -166,7 +226,41 @@ const handleProfile = () => {
|
|
|
}
|
|
|
|
|
|
const handleChangePassword = () => {
|
|
|
- // router.push('/change-password');
|
|
|
+ dialog.value.changePassword = true;
|
|
|
+ pwd.value.oldPassword = '';
|
|
|
+ pwd.value.newPassword = '';
|
|
|
+ pwd.value.confirmNewPassword = '';
|
|
|
+}
|
|
|
+
|
|
|
+const ChangePassword = () => {
|
|
|
+ if (!pwd.value.oldPassword) {
|
|
|
+ ElMessage.error(t('dialog.inputOldPassword'));
|
|
|
+ return;
|
|
|
+ }else if(!pwd.value.newPassword) {
|
|
|
+ ElMessage.error(t('dialog.inputNewPassword'));
|
|
|
+ return;
|
|
|
+ }else if(!pwd.value.confirmNewPassword) {
|
|
|
+ ElMessage.error(t('dialog.inputConfirmNewPassword'));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (pwd.value.newPassword !== pwd.value.confirmNewPassword) {
|
|
|
+ ElMessage.error(t('dialog.passwordMismatch'));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const params = {
|
|
|
+ transCode: "B00003",
|
|
|
+ oldPassword: enPassword(pwd.value.oldPassword),
|
|
|
+ newPassword: enPassword( pwd.value.newPassword),
|
|
|
+ }
|
|
|
+
|
|
|
+ request(params).then(res => {
|
|
|
+ ElMessage.success(t('dialog.passwordChangeSuccess'));
|
|
|
+ dialog.value.changePassword = false;
|
|
|
+ }).catch(error => {
|
|
|
+ console.error(error);
|
|
|
+ ElMessage.error(t('dialog.passwordChangeFailed'));
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
const handleLogout = () => {
|