|
@@ -12,21 +12,57 @@
|
|
|
<!-- <i class="el-icon-caret-bottom" /> -->
|
|
|
</div>
|
|
|
<el-dropdown-menu slot="dropdown" class="user-dropdown">
|
|
|
+ <el-dropdown-item @click.native="openPwdDialog">
|
|
|
+ <span style="display:block;">修改密码</span>
|
|
|
+ </el-dropdown-item>
|
|
|
<el-dropdown-item @click.native="logout">
|
|
|
<span style="display:block;">退出</span>
|
|
|
</el-dropdown-item>
|
|
|
</el-dropdown-menu>
|
|
|
</el-dropdown>
|
|
|
</div>
|
|
|
+ <cy-dialog ref="updatePwd" title="修改密码" :top="'20vh'" :append="true">
|
|
|
+ <el-form ref="ruleForm" :key="key" :model="formData" :rules="rules" label-width="150px" label-position="top" class="rule-form-orange">
|
|
|
+ <el-form-item label="新密码:" prop="newPwd" style="width: 100%;">
|
|
|
+ <el-input v-model="formData.newPwd" maxlength="20" type="password" placeholder="请输入新密码" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="确认新密码:" prop="confirmPwd" style="width: 100%;">
|
|
|
+ <el-input v-model="formData.confirmPwd" maxlength="20" type="password" placeholder="请确认新密码" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div class="submit-btn">
|
|
|
+ <el-button @click="$refs.updatePwd.show = false;">关闭</el-button>
|
|
|
+ <el-button type="primary" @click="confirmSubmit">确定</el-button>
|
|
|
+ </div>
|
|
|
+ </cy-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import { mapGetters } from 'vuex'
|
|
|
+import request from '@/utils/request'
|
|
|
+import md5 from 'js-md5'
|
|
|
|
|
|
// import Hamburger from '@/components/Hamburger'
|
|
|
|
|
|
export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ formData: {
|
|
|
+ newPwd: '',
|
|
|
+ confirmPwd: ''
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ newPwd: [
|
|
|
+ { required: true, message: '请输入新密码', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ confirmPwd: [
|
|
|
+ { required: true, message: '请确认新密码', trigger: 'blur' }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ showDialog: false
|
|
|
+ }
|
|
|
+ },
|
|
|
components: {
|
|
|
// Hamburger
|
|
|
},
|
|
@@ -45,6 +81,35 @@ export default {
|
|
|
await this.$store.dispatch('user/logout')
|
|
|
// this.$router.push(`/login?redirect=${this.$route.fullPath}`)
|
|
|
this.$router.push(`/login`)
|
|
|
+ },
|
|
|
+ openPwdDialog() {
|
|
|
+ this.formData.newPwd = ''
|
|
|
+ this.formData.confirmPwd = ''
|
|
|
+ // this.showDialog = true
|
|
|
+ this.$refs.updatePwd.show = true
|
|
|
+ },
|
|
|
+ confirmSubmit() {
|
|
|
+ this.$refs.ruleForm.validate(flag => {
|
|
|
+ if(flag) {
|
|
|
+ this.submitPwd()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ submitPwd() {
|
|
|
+ if(this.formData.confirmPwd !== this.formData.newPwd) {
|
|
|
+ this.$message.error('两次输入的密码不一致')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ request({
|
|
|
+ url: '/user/updatePassword/' + md5(this.formData.newPwd),
|
|
|
+ method: 'put',
|
|
|
+ params: { Loading: true }
|
|
|
+ }).then(() => {
|
|
|
+ this.$message.success('修改成功')
|
|
|
+ // this.showDialog = false
|
|
|
+ this.$refs.updatePwd.show = false
|
|
|
+ this.logout()
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -137,5 +202,6 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
</style>
|