修改校验密码
This commit is contained in:
parent
05a587b178
commit
b707f728f2
|
|
@ -0,0 +1,10 @@
|
|||
import request from '@/utils/request'
|
||||
|
||||
/* 校验当前登录人的密码是否正确 */
|
||||
export function verifyPwd(query) {
|
||||
return request({
|
||||
url: '/background/back/verify/verifyPwd',
|
||||
method: 'post',
|
||||
data: query
|
||||
})
|
||||
}
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
<template>
|
||||
<el-dialog :visible.sync="dialogVisible" :modal-append-to-body="false" :title="title" :width="width"
|
||||
:close-on-click-modal="false" :custom-class="customClass">
|
||||
<el-form ref="dataForm2" :rules="rules2" :model="pwdForm" label-position="right" label-width="80px"
|
||||
style="width: 400px; margin-left: 50px">
|
||||
<el-form-item label="密码" prop="password">
|
||||
<el-input v-model="pwdForm.password" type="password" placeholder="请输入密码" show-password
|
||||
:maxlength="26" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="closeDialog">取 消</el-button>
|
||||
<el-button type="primary" @click="saveData">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script>
|
||||
import { validPwd } from '@/utils/validate'
|
||||
export default {
|
||||
name: 'modulDialog',
|
||||
data() {
|
||||
return {
|
||||
pwdForm: {
|
||||
userId: undefined,
|
||||
password: undefined
|
||||
},
|
||||
rules2: {
|
||||
password: [
|
||||
{ required: true, message: '密码不能为空', trigger: 'blur' },
|
||||
{ min: 8, max: 26, message: '密码长度在8到26个字符', trigger: 'blur' },
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
props: {
|
||||
value: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
width: {
|
||||
type: String,
|
||||
default: '50%'
|
||||
},
|
||||
customClass: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
dialogVisible: {
|
||||
get() {
|
||||
return this.value;
|
||||
},
|
||||
set(val) {
|
||||
this.$emit('input', val);
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
methods: {
|
||||
saveData() {
|
||||
// 触发确认事件
|
||||
this.$refs['dataForm2'].validate((valid) => {
|
||||
if (valid) {
|
||||
const usKey = sessionStorage.getItem('us-key');
|
||||
this.pwdForm.userId = JSON.parse(usKey).userId;
|
||||
this.$parent.verifiersPwd(this.pwdForm);
|
||||
}
|
||||
})
|
||||
},
|
||||
resetForm() {
|
||||
this.pwdForm.userId = undefined
|
||||
this.$refs['dataForm2'].resetFields()
|
||||
},
|
||||
closeDialog() {
|
||||
this.dialogVisible = false
|
||||
this.pwdForm.userId = undefined
|
||||
this.$refs['dataForm2'].resetFields()
|
||||
},
|
||||
},
|
||||
beforeDestroy() {
|
||||
// 重置 visible 变量
|
||||
this.dialogVisible = false;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
@ -1,38 +1,14 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
<div class="filter-container">
|
||||
<el-input
|
||||
v-model="listQuery.userName"
|
||||
placeholder="用户名"
|
||||
style="width: 200px"
|
||||
class="filter-item"
|
||||
:maxlength="30"
|
||||
@keyup.enter.native="handleFilter"
|
||||
/>
|
||||
<el-input
|
||||
v-model="listQuery.loginName"
|
||||
placeholder="用户昵称"
|
||||
style="width: 200px"
|
||||
class="filter-item ml-20"
|
||||
:maxlength="30"
|
||||
@keyup.enter.native="handleFilter"
|
||||
/>
|
||||
<el-input
|
||||
v-model="listQuery.phone"
|
||||
placeholder="手机号"
|
||||
style="width: 200px"
|
||||
class="filter-item ml-20"
|
||||
:maxlength="11"
|
||||
@keyup.enter.native="handleFilter"
|
||||
/>
|
||||
<el-button
|
||||
v-waves
|
||||
style="margin-left: 40px"
|
||||
class="filter-item"
|
||||
type="primary"
|
||||
icon="el-icon-search"
|
||||
@click="handleFilter"
|
||||
>
|
||||
<el-input v-model="listQuery.userName" placeholder="用户名" style="width: 200px" class="filter-item" :maxlength="30"
|
||||
@keyup.enter.native="handleFilter" />
|
||||
<el-input v-model="listQuery.loginName" placeholder="用户昵称" style="width: 200px" class="filter-item ml-20"
|
||||
:maxlength="30" @keyup.enter.native="handleFilter" />
|
||||
<el-input v-model="listQuery.phone" placeholder="手机号" style="width: 200px" class="filter-item ml-20"
|
||||
:maxlength="11" @keyup.enter.native="handleFilter" />
|
||||
<el-button v-waves style="margin-left: 40px" class="filter-item" type="primary" icon="el-icon-search"
|
||||
@click="handleFilter">
|
||||
查询
|
||||
</el-button>
|
||||
<el-button class="filter-item" style="margin-left: 10px" type="primary" icon="el-icon-plus" @click="handleCreate">
|
||||
|
|
@ -40,16 +16,8 @@
|
|||
</el-button>
|
||||
</div>
|
||||
|
||||
<el-table
|
||||
:key="tableKey"
|
||||
v-loading="listLoading"
|
||||
:data="list"
|
||||
border
|
||||
fit
|
||||
highlight-current-row
|
||||
style="width: 100%"
|
||||
:max-height="tableHeight"
|
||||
>
|
||||
<el-table :key="tableKey" v-loading="listLoading" :data="list" border fit highlight-current-row style="width: 100%"
|
||||
:max-height="tableHeight">
|
||||
<el-table-column label="序号" align="center" width="80" type="index">
|
||||
<template scope="scope">
|
||||
<span>{{ (listQuery.pageNum - 1) * 10 + scope.$index + 1 }}</span>
|
||||
|
|
@ -65,45 +33,28 @@
|
|||
<el-table-column key="nickName" label="登录名" prop="loginName" min-width="40px" align="center" />
|
||||
<el-table-column key="phone" label="手机号码" align="center" prop="phone" :show-overflow-tooltip="true" />
|
||||
|
||||
<el-table-column prop="delFlag" label="状态" align="center">
|
||||
<el-table-column prop="delFlag" label="状态" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-tag :type="scope.row.status ==='已注销' || scope.row.status ==='停用' ? 'danger' : 'primary'" disable-transitions>{{ scope.row.status }}</el-tag>
|
||||
<el-tag :type="scope.row.status === '已注销' || scope.row.status === '停用' ? 'danger' : 'primary'"
|
||||
disable-transitions>{{ scope.row.status }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" width="300" class-name="small-padding fixed-width">
|
||||
<template slot-scope="{ row, $index }">
|
||||
<el-button type="primary" size="mini" plain icon="el-icon-edit" title="修改" @click="handleUpdate(row)" />
|
||||
<el-button
|
||||
v-if="row.status != 'deleted'"
|
||||
plain
|
||||
size="mini"
|
||||
type="danger"
|
||||
icon="el-icon-delete"
|
||||
title="删除"
|
||||
@click="handleDelete(row, $index)"
|
||||
/>
|
||||
<el-button v-if="row.status != 'deleted'" plain size="mini" type="danger" icon="el-icon-delete" title="删除"
|
||||
@click="handleDelete(row, $index)" />
|
||||
<el-button size="mini" type="warning" plain icon="el-icon-user" title="重置密码" @click="editPwd(row, $index)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
:page.sync="listQuery.pageNum"
|
||||
:limit.sync="listQuery.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
<pagination v-show="total > 0" :total="total" :page.sync="listQuery.pageNum" :limit.sync="listQuery.pageSize"
|
||||
@pagination="getList" />
|
||||
|
||||
<el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" width="600px">
|
||||
<el-form
|
||||
ref="dataForm"
|
||||
:rules="rules"
|
||||
:model="temp"
|
||||
label-position="right"
|
||||
label-width="80px"
|
||||
style="width: 400px; margin-left: 50px"
|
||||
>
|
||||
<el-form ref="dataForm" :rules="rules" :model="temp" label-position="right" label-width="80px"
|
||||
style="width: 400px; margin-left: 50px">
|
||||
<el-form-item label="用户名" prop="userName">
|
||||
<el-input v-model="temp.userName" placeholder="用户名" :maxlength="30" />
|
||||
</el-form-item>
|
||||
|
|
@ -126,7 +77,8 @@
|
|||
</el-form-item>
|
||||
<el-form-item label="登录权限" prop="loginType">
|
||||
<el-checkbox-group v-model="loginType">
|
||||
<el-checkbox v-for="item in loginTypeArr" :key="item.value" :label="item.value">{{ item.name }}</el-checkbox>
|
||||
<el-checkbox v-for="item in loginTypeArr" :key="item.value" :label="item.value">{{ item.name
|
||||
}}</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="账号类型" prop="userType">
|
||||
|
|
@ -135,13 +87,8 @@
|
|||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="角色类型" prop="roleId">
|
||||
<el-select
|
||||
v-model="temp.roleId"
|
||||
class="filter-item"
|
||||
placeholder="请选择角色类型"
|
||||
style="width: 100%"
|
||||
@change="roleChange"
|
||||
>
|
||||
<el-select v-model="temp.roleId" class="filter-item" placeholder="请选择角色类型" style="width: 100%"
|
||||
@change="roleChange">
|
||||
<el-option v-for="item in roleArr" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
|
@ -160,14 +107,8 @@
|
|||
</el-dialog>
|
||||
|
||||
<el-dialog title="重置密码" :visible.sync="dialogFormVisible2" width="600px">
|
||||
<el-form
|
||||
ref="dataForm2"
|
||||
:rules="rules2"
|
||||
:model="pwdForm"
|
||||
label-position="right"
|
||||
label-width="80px"
|
||||
style="width: 400px; margin-left: 50px"
|
||||
>
|
||||
<el-form ref="dataForm2" :rules="rules2" :model="pwdForm" label-position="right" label-width="80px"
|
||||
style="width: 400px; margin-left: 50px">
|
||||
<el-form-item label="密码" prop="password">
|
||||
<el-input v-model="pwdForm.password" type="password" placeholder="请输入密码" show-password :maxlength="26" />
|
||||
</el-form-item>
|
||||
|
|
@ -179,18 +120,27 @@
|
|||
</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<modul-dialog ref="pwdVerifiersDialog" :title="componentDialog.title" :width="componentDialog.width"
|
||||
v-model="componentDialog.openFalg">
|
||||
<component :is="componentDialog.modulName" />
|
||||
</modul-dialog>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { fetchList, addUser, getUserById, editUser, delUser, editPwd } from '@/api/user'
|
||||
import { fetchOrgList, fetchRoleList, fetchBuildList } from '@/api/select'
|
||||
import { verifyPwd } from '@/api/verifyPwd'
|
||||
import { validPhone, validPwd } from '@/utils/validate'
|
||||
import waves from '@/directive/waves'
|
||||
import { parseTime } from '@/utils'
|
||||
import Pagination from '@/components/Pagination'
|
||||
import Treeselect from '@riophae/vue-treeselect'
|
||||
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||
import modulDialog from '@/components/pwdVerifiers/pwdVerifiers.vue'
|
||||
|
||||
const loginTypeArr = [
|
||||
{
|
||||
|
|
@ -235,10 +185,16 @@ const accountStatusArr = [
|
|||
}
|
||||
]
|
||||
export default {
|
||||
components: { Pagination, Treeselect },
|
||||
components: { Pagination, Treeselect, modulDialog },
|
||||
directives: { waves },
|
||||
data() {
|
||||
return {
|
||||
componentDialog: {
|
||||
modulName: '', //组件名称
|
||||
title: '',
|
||||
width: '',
|
||||
openFalg: false
|
||||
},
|
||||
tableKey: 0,
|
||||
loginTypeArr: loginTypeArr,
|
||||
userTypeArr: userTypeArr,
|
||||
|
|
@ -330,6 +286,29 @@ export default {
|
|||
this.getBuildList()
|
||||
},
|
||||
methods: {
|
||||
openModulDialog(title, modulName, width, openFalg) {
|
||||
this.componentDialog.title = title
|
||||
this.componentDialog.modulName = modulName
|
||||
this.componentDialog.width = width
|
||||
this.componentDialog.openFalg = openFalg
|
||||
},
|
||||
verifiersPwd(data) {
|
||||
verifyPwd(data).then((response) => {
|
||||
this.$message({
|
||||
showClose: true,
|
||||
message: response.msg,
|
||||
type: 'success',
|
||||
duration: 500
|
||||
})
|
||||
// 关闭验证密码页面
|
||||
this.componentDialog.openFalg = false;
|
||||
if (this.$refs.pwdVerifiersDialog) {
|
||||
this.$refs.pwdVerifiersDialog.resetForm();
|
||||
}
|
||||
this.commitUpdateData();
|
||||
})
|
||||
|
||||
},
|
||||
validateLoginType(rule, value, callback) {
|
||||
if (this.loginType.length > 0) {
|
||||
callback()
|
||||
|
|
@ -353,7 +332,7 @@ export default {
|
|||
},
|
||||
roleChange(roleId) {
|
||||
var obj = {}
|
||||
obj = this.roleArr.find(function(i) {
|
||||
obj = this.roleArr.find(function (i) {
|
||||
return i.id === roleId
|
||||
})
|
||||
this.temp.roleName = obj.name
|
||||
|
|
@ -432,25 +411,28 @@ export default {
|
|||
updateData() {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
this.temp.loginType = this.loginType.toString()
|
||||
editUser(this.temp).then((response) => {
|
||||
this.dialogFormVisible = false
|
||||
this.$message({
|
||||
showClose: true,
|
||||
message: response.msg,
|
||||
type: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
this.getList()
|
||||
})
|
||||
this.openModulDialog('验证密码', 'pwdVerifiers', '600px', true)
|
||||
}
|
||||
})
|
||||
},
|
||||
commitUpdateData() {
|
||||
this.temp.loginType = this.loginType.toString()
|
||||
editUser(this.temp).then((response) => {
|
||||
this.dialogFormVisible = false
|
||||
this.$message({
|
||||
showClose: true,
|
||||
message: response.msg,
|
||||
type: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
this.getList()
|
||||
})
|
||||
},
|
||||
handleDelete(row, index) {
|
||||
this.$confirm(`确定要注销该用户吗?`, {
|
||||
type: 'warning',
|
||||
title: '操作提示',
|
||||
beforeClose: async(action, instance, done) => {
|
||||
beforeClose: async (action, instance, done) => {
|
||||
if (action === 'confirm') {
|
||||
delUser({ userId: row.userId }).then((response) => {
|
||||
done()
|
||||
|
|
|
|||
Loading…
Reference in New Issue