Jelajahi Sumber

密码修改

Shan9312 9 bulan lalu
induk
melakukan
2b78e74882

+ 10 - 0
src/lang/en/langModule/role.js

@@ -26,5 +26,15 @@ ym: "Page",
 ck: "Check",
 bj: "Edit",
 
+oldPassword: "Old Password:",
+newPassword: "New Password:",
+copyPassword: "Confirm Password",
+edit: "Confirm Edit",
+msgmm1: "Please enter a new password",
+msgmm2: "The password should be 6-18 characters long",
+msgmm3: "Please enter the new password again",
+msgmm4: "Please re-enter the password",
+msgmm5: "The passwords entered do not match",
+
 
 }

+ 12 - 0
src/lang/zn/langModule/role.js

@@ -25,6 +25,18 @@ ym:"页面",
 ck:"查看",
 bj:"编辑",
 
+//
+oldPassword:"旧密码:",
+newPassword:"新密码:",
+copyPassword:"确认密码",
+edit:"确认修改",
+msgmm1:"请输入新密码",
+msgmm2:"密码长度为6-18位",
+msgmm3:"请输入新密码",
+msgmm4:"请再次输入密码",
+msgmm5:"两次输入密码不一致",
+
+
 
 
 

+ 165 - 165
src/views/changpwd/changpwd/index.vue

@@ -1,165 +1,165 @@
-<template>
-  <div class="app-container common-list-page">
-    <el-form
-      ref="temp"
-      :model="temp"
-      :rules="rules"
-      status-icon
-      label-width="100px"
-    >
-      <el-form-item label="旧密码:" prop="oldpassword">
-        <el-input v-model="temp.oldpassword" type="password" auto-complete="off" />
-      </el-form-item>
-      <el-form-item label="新密码:" prop="password">
-        <el-input v-model="temp.password" type="password" auto-complete="off" />
-      </el-form-item>
-      <el-form-item label="确认密码:" prop="password1">
-        <el-input v-model="temp.password1" type="password" auto-complete="off" />
-      </el-form-item>
-      <el-form-item>
-        <el-button type="primary" @click.native.prevent="toAmend">确认修改</el-button>
-      </el-form-item>
-    </el-form>
-  </div>
-</template>
-<script>
-import { ExecDataByConfig } from '@/api/common'
-import Cookies from 'js-cookie'
-export default {
-  data() {
-    var oldPass = (rule, value, callback) => {
-      if (!value) {
-        callback(new Error('请输入旧密码'))
-      } else if (value.toString().length < 6 || value.toString().length > 18) {
-        callback(new Error('密码长度为6-18位'))
-      } else {
-        callback()
-      }
-    }
-    var validatePass = (rule, value, callback) => {
-      console.log(value)
-      if (!value) {
-        callback(new Error('请输入新密码'))
-      } else if (value.toString().length < 6 || value.toString().length > 18) {
-        callback(new Error('密码长度为6-18位'))
-      } else {
-        callback()
-      }
-    }
-    var validatePass2 = (rule, value, callback) => {
-      if (value === '') {
-        callback(new Error('请再次输入密码'))
-      } else if (value !== this.temp.password) {
-        callback(new Error('两次输入密码不一致!'))
-      } else {
-        callback()
-      }
-    }
-    return {
-      resetForm: {
-        // name: 'updatePwd',
-        // returntype: 'Map',
-        // parammaps: {
-        //   password: '',
-        //   username: this.$store.state.user.name
-        // }
-      },
-      temp: {},
-      rules: {
-        oldpassword: [
-          { required: true, validator: oldPass, trigger: 'blur' }
-        ],
-        password: [
-          { required: true, validator: validatePass, trigger: 'blur' }
-        ],
-        password1: [
-          { required: true, validator: validatePass2, trigger: 'blur' }
-        ]
-      }
-    }
-  },
-  methods: {
-    toAmend() {
-      console.log(111)
-      this.$refs['temp'].validate(valid => {
-        if (valid) {
-          this.resetForm.common = { 'returnmap': '0' }
-          this.resetForm.data = []
-          this.resetForm.data[0] = { 'name': 'checkPassword', 'type': 'v', 'parammaps': {
-            'id': Cookies.get('employeid'),
-            'password': this.temp.oldpassword
-          }}
-
-          this.resetForm.data[1] = { 'name': 'updatePwd', 'type': 'e', 'parammaps': {
-            'password': this.temp.password,
-            'username':  Cookies.get('name')
-          }}
-
-          ExecDataByConfig(this.resetForm).then(response => {
-            console.log('保存发送参数', this.resetForm)
-            if (response.msg === 'fail') {
-              this.$notify({
-                title: this.$t('driver.saveFail'),
-                message: response.data,
-                type: 'warning',
-                duration: 2000
-              })
-            } else {
-              setTimeout(() => {
-                this.logout() // 调用跳转到登陆页的方法
-              }, 1000)
-              this.$notify({
-                title: '',
-                message: this.$t('driver.saveSuccess'),
-                type: 'success',
-                duration: 2000
-              })
-            }
-          })
-        }
-      })
-      //     this.resetForm.parammaps.password = this.temp.password
-      //     this.resetForm.parammaps.username = this.$store.state.user.name
-      //     PostDataByName(this.resetForm).then(response => {
-      //       if (response.msg === 'fail') {
-      //         this.$notify({
-      //           title: '失败',
-      //           message: '修改失败',
-      //           type: 'danger',
-      //           duration: 2000
-      //         })
-      //       } else {
-      //         setTimeout(() => {
-      //           this.logout() // 调用跳转到登陆页的方法
-      //         }, 1000)
-      //         this.$notify({
-      //           title: this.$t('common.succes'),
-      //           message: '修改成功',
-      //           type: 'success',
-      //           duration: 2000
-      //         })
-      //       }
-      //       console.log(response)
-      //     })
-      //   }
-      // })
-    },
-    // 这是修改成功后重新返回登陆页的方法,看个人需要自行调整
-    async logout() {
-      await this.$store.dispatch('user/logout')
-      this.$router.push(`/login`)
-    }
-  }
-}
-</script>
-
-<style lang="scss" scoped>
-.el-form {
-  width: 60%;
-  margin: 50px auto 0;
-  text-align: center;
-  button {
-    margin: 20px 0 0;
-  }
-}
-</style>
+<template>
+  <div class="app-container common-list-page">
+    <el-form
+      ref="temp"
+      :model="temp"
+      :rules="rules"
+      status-icon
+      label-width="200px"
+    >
+      <el-form-item :label="$t('role.oldPassword')" prop="oldpassword">
+        <el-input v-model="temp.oldpassword" type="password" auto-complete="off" />
+      </el-form-item>
+      <el-form-item :label="$t('role.newPassword')" prop="password">
+        <el-input v-model="temp.password" type="password" auto-complete="off" />
+      </el-form-item>
+      <el-form-item :label="$t('role.copyPassword')" prop="password1">
+        <el-input v-model="temp.password1" type="password" auto-complete="off" />
+      </el-form-item>
+      <el-form-item>
+        <el-button type="primary" @click.native.prevent="toAmend">{{$t('role.edit')}}</el-button>
+      </el-form-item>
+    </el-form>
+  </div>
+</template>
+<script>
+import { ExecDataByConfig } from '@/api/common'
+import Cookies from 'js-cookie'
+export default {
+  data() {
+    var oldPass = (rule, value, callback) => {
+      if (!value) {
+        callback(new Error(this.$t('role.msgmm1')))
+      } else if (value.toString().length < 6 || value.toString().length > 18) {
+        callback(new Error(this.$t('role.msgmm2')))
+      } else {
+        callback()
+      }
+    }
+    var validatePass = (rule, value, callback) => {
+      console.log(value)
+      if (!value) {
+        callback(new Error(this.$t('role.msgmm3')))
+      } else if (value.toString().length < 6 || value.toString().length > 18) {
+        callback(new Error(this.$t('role.msgmm4')))
+      } else {
+        callback()
+      }
+    }
+    var validatePass2 = (rule, value, callback) => {
+      if (value === '') {
+        callback(new Error(this.$t('role.msgmm4')))
+      } else if (value !== this.temp.password) {
+        callback(new Error(this.$t('role.msgmm5')))
+      } else {
+        callback()
+      }
+    }
+    return {
+      resetForm: {
+        // name: 'updatePwd',
+        // returntype: 'Map',
+        // parammaps: {
+        //   password: '',
+        //   username: this.$store.state.user.name
+        // }
+      },
+      temp: {},
+      rules: {
+        oldpassword: [
+          { required: true, validator: oldPass, trigger: 'blur' }
+        ],
+        password: [
+          { required: true, validator: validatePass, trigger: 'blur' }
+        ],
+        password1: [
+          { required: true, validator: validatePass2, trigger: 'blur' }
+        ]
+      }
+    }
+  },
+  methods: {
+    toAmend() {
+      console.log(111)
+      this.$refs['temp'].validate(valid => {
+        if (valid) {
+          this.resetForm.common = { 'returnmap': '0' }
+          this.resetForm.data = []
+          this.resetForm.data[0] = { 'name': 'checkPassword', 'type': 'v', 'parammaps': {
+            'id': Cookies.get('employeid'),
+            'password': this.temp.oldpassword
+          }}
+
+          this.resetForm.data[1] = { 'name': 'updatePwd', 'type': 'e', 'parammaps': {
+            'password': this.temp.password,
+            'username':  Cookies.get('name')
+          }}
+
+          ExecDataByConfig(this.resetForm).then(response => {
+            // console.log('保存发送参数', this.resetForm)
+            if (response.msg === 'fail') {
+              this.$notify({
+                title: this.$t('driver.saveFail'),
+                message: response.data,
+                type: 'warning',
+                duration: 2000
+              })
+            } else {
+              setTimeout(() => {
+                this.logout() // 调用跳转到登陆页的方法
+              }, 1000)
+              this.$notify({
+                title: '',
+                message: this.$t('driver.saveSuccess'),
+                type: 'success',
+                duration: 2000
+              })
+            }
+          })
+        }
+      })
+      //     this.resetForm.parammaps.password = this.temp.password
+      //     this.resetForm.parammaps.username = this.$store.state.user.name
+      //     PostDataByName(this.resetForm).then(response => {
+      //       if (response.msg === 'fail') {
+      //         this.$notify({
+      //           title: '失败',
+      //           message: '修改失败',
+      //           type: 'danger',
+      //           duration: 2000
+      //         })
+      //       } else {
+      //         setTimeout(() => {
+      //           this.logout() // 调用跳转到登陆页的方法
+      //         }, 1000)
+      //         this.$notify({
+      //           title: this.$t('common.succes'),
+      //           message: '修改成功',
+      //           type: 'success',
+      //           duration: 2000
+      //         })
+      //       }
+      //       console.log(response)
+      //     })
+      //   }
+      // })
+    },
+    // 这是修改成功后重新返回登陆页的方法,看个人需要自行调整
+    async logout() {
+      await this.$store.dispatch('user/logout')
+      this.$router.push(`/login`)
+    }
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+.el-form {
+  width: 60%;
+  margin: 50px auto 0;
+  text-align: center;
+  button {
+    margin: 20px 0 0;
+  }
+}
+</style>