合并分支sso
This commit is contained in:
@@ -20,8 +20,15 @@
|
||||
</div>
|
||||
<ul class="user-info">
|
||||
<li><div style="height: 100%"><svg-icon icon-class="login" /> 登录账号<div class="user-right">{{ user.username }}</div></div></li>
|
||||
<li><svg-icon icon-class="user1" /> 用户姓名 <div class="user-right">{{ user.nickName }}</div></li>
|
||||
<li><svg-icon icon-class="dept" /> 所属部门 <div class="user-right"> {{ user.dept.name }}</div></li>
|
||||
<li><svg-icon icon-class="user1" /> 用户姓名 <div class="user-right">{{ user.personName }}</div></li>
|
||||
<li><svg-icon icon-class="dept" /> 所属部门
|
||||
<el-tooltip effect="dark" placement="top">
|
||||
<div slot="content">
|
||||
<span v-for="item in depts">{{ item.name }} </span>
|
||||
</div>
|
||||
<span class="user-right" v-for="item in depts">{{ item.name }}<span v-if="depts.length>1">...</span></span>
|
||||
</el-tooltip>
|
||||
</li>
|
||||
<li><svg-icon icon-class="phone" /> 手机号码 <div class="user-right">{{ user.phone }}</div></li>
|
||||
<li><svg-icon icon-class="email" /> 用户邮箱 <div class="user-right">{{ user.email }}</div></li>
|
||||
<li>
|
||||
@@ -41,8 +48,8 @@
|
||||
<el-tabs v-model="activeName" @tab-click="handleClick">
|
||||
<el-tab-pane label="用户资料" name="first">
|
||||
<el-form ref="form" :model="form" :rules="rules" style="margin-top: 10px;" size="mini" label-width="65px">
|
||||
<el-form-item label="姓名" prop="nickName">
|
||||
<el-input v-model="form.nickName" style="width: 35%" />
|
||||
<el-form-item label="姓名" prop="personName">
|
||||
<el-input v-model="form.personName" style="width: 35%" />
|
||||
<span style="color: #C0C0C0;margin-left: 10px;">用户姓名不作为登录使用</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号" prop="phone">
|
||||
@@ -116,7 +123,7 @@ import store from '@/store'
|
||||
import { isvalidPhone } from '@/utils/validate'
|
||||
import { parseTime } from '@/utils/index'
|
||||
import crud from '@/mixins/crud'
|
||||
import { editUser } from '@/api/system/user'
|
||||
import { editUser } from '@/views/system/user'
|
||||
import Avatar from '@/assets/images/avatar.png'
|
||||
export default {
|
||||
name: 'Center',
|
||||
@@ -142,8 +149,9 @@ export default {
|
||||
'Authorization': getToken()
|
||||
},
|
||||
form: {},
|
||||
deptsName: '',
|
||||
rules: {
|
||||
nickName: [
|
||||
personName: [
|
||||
{ required: true, message: '请输入用户姓名', trigger: 'blur' },
|
||||
{ min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' }
|
||||
],
|
||||
@@ -156,12 +164,13 @@ export default {
|
||||
computed: {
|
||||
...mapGetters([
|
||||
'user',
|
||||
'depts',
|
||||
'updateAvatarApi',
|
||||
'baseApi'
|
||||
])
|
||||
},
|
||||
created() {
|
||||
this.form = { id: this.user.id, nickName: this.user.nickName, gender: this.user.gender, phone: this.user.phone }
|
||||
this.form = { id: this.user.id, personName: this.user.personName, gender: this.user.gender, phone: this.user.phone }
|
||||
store.dispatch('GetInfo').then(() => {})
|
||||
},
|
||||
methods: {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<script>
|
||||
import store from '@/store'
|
||||
import { validEmail } from '@/utils/validate'
|
||||
import { updateEmail } from '@/api/system/user'
|
||||
import { updateEmail } from '@/views/system/user'
|
||||
import { resetEmail } from '@/api/system/code'
|
||||
export default {
|
||||
props: {
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
<script>
|
||||
import store from '@/store'
|
||||
import { updatePass } from '@/api/system/user'
|
||||
import { updatePass } from '@/views/system/user'
|
||||
export default {
|
||||
data() {
|
||||
const confirmPass = (rule, value, callback) => {
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
title="关联用户"
|
||||
append-to-body
|
||||
:visible.sync="dialogVisible"
|
||||
destroy-on-close
|
||||
width="1000px"
|
||||
@close="close"
|
||||
@open="open"
|
||||
>
|
||||
<el-form
|
||||
:inline="true"
|
||||
class="demo-form-inline"
|
||||
label-position="right"
|
||||
label-width="80px"
|
||||
label-suffix=":"
|
||||
>
|
||||
<el-form-item label="模糊搜索">
|
||||
<el-input
|
||||
v-model="query.name"
|
||||
clearable
|
||||
size="mini"
|
||||
placeholder="输入部门名称搜索"
|
||||
style="width: 200px;"
|
||||
class="filter-item"
|
||||
@keyup.enter.native="crud.toQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<rrOperation />
|
||||
</el-form>
|
||||
|
||||
<!--表格渲染-->
|
||||
<el-table
|
||||
ref="table"
|
||||
v-loading="crud.loading"
|
||||
:data="crud.data"
|
||||
lazy
|
||||
row-key="dept_id"
|
||||
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
||||
:load="getDeptDatas"
|
||||
default-expand-all
|
||||
style="width: 100%;"
|
||||
size="mini"
|
||||
border
|
||||
:header-cell-style="{background:'#f5f7fa',color:'#606266'}"
|
||||
@select="handleSelectionChange"
|
||||
@current-change="clickChange"
|
||||
>
|
||||
<el-table-column v-if="!isSingle" type="selection" width="55" />
|
||||
<el-table-column v-if="isSingle" label="选择" width="55">
|
||||
<template slot-scope="scope">
|
||||
<el-radio v-model="tableRadio" :label="scope.row"><i /></el-radio>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="名称" prop="name" />
|
||||
<el-table-column label="排序" prop="deptSort" />
|
||||
<el-table-column prop="createTime" label="创建日期" />
|
||||
</el-table>
|
||||
<!--分页组件-->
|
||||
<pagination />
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="submit">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import crudDept from '@/views/system/dept/dept'
|
||||
import CRUD, { header, presenter } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
|
||||
export default {
|
||||
name: 'RelevanceDeptDialog',
|
||||
components: { rrOperation, pagination },
|
||||
cruds() {
|
||||
return CRUD({ title: '部门', idField: 'deptId', url: 'api/dept/vo', crudMethod: { ...crudDept }, query: { isUsed: '1' }})
|
||||
},
|
||||
mixins: [presenter(), header()],
|
||||
dicts: ['product_series'],
|
||||
props: {
|
||||
dialogShow: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
isSingle: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
depts: {
|
||||
type: Array
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
classes: [],
|
||||
tableRadio: null,
|
||||
class_idStr: null,
|
||||
checkrow: null,
|
||||
rows: []
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
dialogShow: {
|
||||
handler(newValue) {
|
||||
this.dialogVisible = newValue
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
clickChange(item) {
|
||||
this.tableRadio = item
|
||||
},
|
||||
open() {
|
||||
// 回显
|
||||
this.$nextTick(function() {
|
||||
for (var k = 0; k < this.depts.length; k++) {
|
||||
for (var i = 0; i < this.crud.data.length; i++) {
|
||||
if (this.crud.data[i].deptId == this.depts[k].deptId) {
|
||||
this.$refs.table.toggleRowSelection(this.crud.data[i], true)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
handleSelectionChange(val, row) {
|
||||
if (val.length > 1 && this.isSingle) {
|
||||
this.$refs.table.clearSelection()
|
||||
this.$refs.table.toggleRowSelection(val.pop())
|
||||
} else {
|
||||
this.checkrow = row
|
||||
}
|
||||
},
|
||||
onSelectAll() {
|
||||
this.$refs.table.clearSelection()
|
||||
},
|
||||
close() {
|
||||
this.crud.resetQuery(false)
|
||||
this.$emit('update:dialogShow', false)
|
||||
},
|
||||
submit() {
|
||||
// 处理单选
|
||||
if (this.isSingle && this.tableRadio) {
|
||||
this.$emit('update:dialogShow', false)
|
||||
this.$emit('selectDepts', this.tableRadio)
|
||||
return
|
||||
}
|
||||
this.rows = this.$refs.table.selection
|
||||
if (this.rows.length <= 0) {
|
||||
this.$message('请先勾选用户')
|
||||
return
|
||||
}
|
||||
this.crud.resetQuery(false)
|
||||
this.$emit('update:dialogShow', false)
|
||||
this.$emit('selectDepts', this.rows)
|
||||
// console.log(this.rows)
|
||||
},
|
||||
getDeptDatas(tree, treeNode, resolve) {
|
||||
const params = { pid: tree.deptId }
|
||||
setTimeout(() => {
|
||||
crudDept.getDeptvo(params).then(res => {
|
||||
resolve(res.content)
|
||||
})
|
||||
}, 100)
|
||||
},
|
||||
[CRUD.HOOK.afterRefresh]() {
|
||||
this.open()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||
::v-deep .el-dialog__body {
|
||||
padding-top: 0px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
title="关联用户"
|
||||
append-to-body
|
||||
:visible.sync="dialogVisible"
|
||||
destroy-on-close
|
||||
width="1000px"
|
||||
@close="close"
|
||||
@open="open"
|
||||
>
|
||||
<el-form
|
||||
:inline="true"
|
||||
class="demo-form-inline"
|
||||
label-position="right"
|
||||
label-width="80px"
|
||||
label-suffix=":"
|
||||
>
|
||||
<el-form-item label="模糊搜索">
|
||||
<el-input
|
||||
v-model="query.blurry"
|
||||
clearable
|
||||
size="mini"
|
||||
placeholder="输入账号或者名称"
|
||||
@keyup.enter.native="crud.toQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<rrOperation />
|
||||
</el-form>
|
||||
|
||||
<!--表格渲染-->
|
||||
<el-table
|
||||
ref="table"
|
||||
v-loading="crud.loading"
|
||||
:data="crud.data"
|
||||
style="width: 100%;"
|
||||
size="mini"
|
||||
border
|
||||
:header-cell-style="{background:'#f5f7fa',color:'#606266'}"
|
||||
@select="handleSelectionChange"
|
||||
@current-change="clickChange"
|
||||
>
|
||||
<el-table-column v-if="!isSingle" type="selection" width="55" />
|
||||
<el-table-column v-if="isSingle" label="选择" width="55">
|
||||
<template slot-scope="scope">
|
||||
<el-radio v-model="tableRadio" :label="scope.row"><i /></el-radio>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="username" label="用户名" :min-width="flexWidth('username',crud.data,'用户名')" />
|
||||
<el-table-column
|
||||
prop="personName"
|
||||
label="姓名"
|
||||
:min-width="flexWidth('personName',crud.data,'姓名')"
|
||||
/>
|
||||
<el-table-column show-overflow-tooltip prop="deptnames" label="部门" />
|
||||
<el-table-column label="状态" align="center" prop="enabled">
|
||||
<template slot-scope="scope">
|
||||
{{scope.row.isUsed==1?'启用':'禁用'}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!--分页组件-->
|
||||
<pagination />
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="submit">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import crudUser from '../user'
|
||||
import CRUD, { header, presenter } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
|
||||
export default {
|
||||
name: 'RelevanceUserDialog',
|
||||
components: { rrOperation, pagination },
|
||||
cruds() {
|
||||
return CRUD({ title: '用户', idField: 'userId', url: 'api/users', crudMethod: { ...crudUser }, query: {isUsed: '1'}})
|
||||
},
|
||||
mixins: [presenter(), header()],
|
||||
dicts: ['product_series'],
|
||||
props: {
|
||||
dialogShow: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
isSingle: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
users: {
|
||||
type: Array
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
classes: [],
|
||||
tableRadio: null,
|
||||
class_idStr: null,
|
||||
checkrow: null,
|
||||
rows: []
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
dialogShow: {
|
||||
handler(newValue) {
|
||||
this.dialogVisible = newValue
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
clickChange(item) {
|
||||
this.tableRadio = item
|
||||
},
|
||||
open() {
|
||||
this.$nextTick(function() {
|
||||
console.log(this.crud.data)
|
||||
for (var k = 0; k < this.users.length; k++) {
|
||||
for (var i = 0; i < this.crud.data.length; i++) {
|
||||
if (this.crud.data[i].userId == this.users[k].userId) {
|
||||
this.$refs.table.toggleRowSelection(this.crud.data[i], true)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
handleSelectionChange(val, row) {
|
||||
if (val.length > 1 && this.isSingle) {
|
||||
this.$refs.table.clearSelection()
|
||||
this.$refs.table.toggleRowSelection(val.pop())
|
||||
} else {
|
||||
this.checkrow = row
|
||||
}
|
||||
},
|
||||
onSelectAll() {
|
||||
this.$refs.table.clearSelection()
|
||||
},
|
||||
close() {
|
||||
this.crud.resetQuery(false)
|
||||
this.$emit('update:dialogShow', false)
|
||||
},
|
||||
submit() {
|
||||
// 处理单选
|
||||
if (this.isSingle && this.tableRadio) {
|
||||
this.$emit('update:dialogShow', false)
|
||||
this.$emit('selectUsers', this.tableRadio)
|
||||
return
|
||||
}
|
||||
this.rows = this.$refs.table.selection
|
||||
if (this.rows.length <= 0) {
|
||||
this.$message('请先勾选用户')
|
||||
return
|
||||
}
|
||||
this.crud.resetQuery(false)
|
||||
this.$emit('update:dialogShow', false)
|
||||
this.$emit('selectUsers', this.rows)
|
||||
// console.log(this.rows)
|
||||
},
|
||||
[CRUD.HOOK.afterRefresh]() {
|
||||
this.open()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||
::v-deep .el-dialog__body {
|
||||
padding-top: 0px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
title="数据权限"
|
||||
append-to-body
|
||||
:visible.sync="dialogVisible"
|
||||
destroy-on-close
|
||||
width="1000px"
|
||||
@close="close"
|
||||
@open="open"
|
||||
>
|
||||
<!--表格渲染-->
|
||||
<el-table
|
||||
ref="table"
|
||||
v-loading="crud.loading"
|
||||
:data="crud.data"
|
||||
style="width: 100%;"
|
||||
size="mini"
|
||||
border
|
||||
:header-cell-style="{background:'#f5f7fa',color:'#606266'}"
|
||||
>
|
||||
<el-table-column prop="permission_scope_type" label="权限类型" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column prop="permission_name" label="权限范围" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column prop="dept_name" label="部门名称" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column prop="person_name" label="用户名称" min-width="100" show-overflow-tooltip />
|
||||
</el-table>
|
||||
<!--分页组件-->
|
||||
<pagination />
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="dialogVisible = false">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import CRUD, { header, presenter } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
|
||||
export default {
|
||||
name: 'ShowDataPermissionDialog',
|
||||
components: { rrOperation, pagination },
|
||||
cruds() {
|
||||
return CRUD({ title: '权限明细', idField: 'userId', url: 'api/dataPermission/dataDetail'})
|
||||
},
|
||||
mixins: [presenter(), header()],
|
||||
dicts: ['product_series'],
|
||||
props: {
|
||||
dialogShow: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
currentUserId: {
|
||||
type: Number,
|
||||
default: 0
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
dialogVisible: false,
|
||||
classes: [],
|
||||
tableRadio: null,
|
||||
rows: []
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
dialogShow: {
|
||||
handler(newValue) {
|
||||
this.dialogVisible = newValue
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
clickChange(item) {
|
||||
this.tableRadio = item
|
||||
},
|
||||
open() {
|
||||
console.log(this.currentUserId)
|
||||
},
|
||||
close() {
|
||||
this.crud.resetQuery(false)
|
||||
this.$emit('update:dialogShow', false)
|
||||
},
|
||||
[CRUD.HOOK.afterRefresh]() {
|
||||
this.open()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||
::v-deep .el-dialog__body {
|
||||
padding-top: 0px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="app-container">
|
||||
<el-row :gutter="20">
|
||||
<!--侧边部门数据-->
|
||||
<el-col :xs="9" :sm="6" :md="5" :lg="5" :xl="4">
|
||||
<el-col :span="4">
|
||||
<div class="head-container">
|
||||
<el-input
|
||||
v-model="deptName"
|
||||
@@ -16,15 +16,12 @@
|
||||
</div>
|
||||
<el-tree
|
||||
:data="deptDatas"
|
||||
:load="getDeptDatas"
|
||||
:props="defaultProps"
|
||||
:expand-on-click-node="false"
|
||||
lazy
|
||||
@node-click="handleNodeClick"
|
||||
/>
|
||||
</el-col>
|
||||
<!--用户数据-->
|
||||
<el-col :xs="15" :sm="18" :md="19" :lg="19" :xl="20">
|
||||
<el-col :span="20">
|
||||
<!--工具栏-->
|
||||
<div class="head-container">
|
||||
<div v-if="crud.props.searchToggle">
|
||||
@@ -39,7 +36,7 @@
|
||||
@keyup.enter.native="crud.toQuery"
|
||||
/>
|
||||
<el-select
|
||||
v-model="query.enabled"
|
||||
v-model="query.isUsed"
|
||||
clearable
|
||||
size="mini"
|
||||
placeholder="状态"
|
||||
@@ -58,7 +55,7 @@
|
||||
</div>
|
||||
<crudOperation show="" :permission="permission" />
|
||||
</div>
|
||||
<!--表单渲染-->
|
||||
<!--新增跟修改表单渲染-->
|
||||
<el-dialog
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
@@ -74,24 +71,28 @@
|
||||
<el-form-item label="电话" prop="phone">
|
||||
<el-input v-model.number="form.phone" style="width: 200px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="姓名" prop="nickName">
|
||||
<el-input v-model="form.nickName" style="width: 200px;" />
|
||||
<el-form-item label="姓名" prop="preson_name">
|
||||
<el-input v-model="form.personName" style="width: 200px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="邮箱" prop="email">
|
||||
<el-input v-model="form.email" style="width: 200px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="部门" prop="dept.id" :rules="[{ required: true, message: '请选择部门', trigger: 'change' }]">
|
||||
<br v-if="!crud.status.edit">
|
||||
<el-form-item v-if="crud.status.add" label="部门" prop="depts" :rules="[{ required: true, message: '请选择部门', trigger: 'change' }]">
|
||||
<treeselect
|
||||
v-model="form.dept.id"
|
||||
:options="depts"
|
||||
v-model="form.depts"
|
||||
:load-options="loadDepts"
|
||||
style="width: 200px"
|
||||
placeholder="选择部门"
|
||||
:options="deptDatas"
|
||||
style="width: 370px;"
|
||||
:multiple="true"
|
||||
:flat="true"
|
||||
:normalizer="normalizer"
|
||||
placeholder="选择部门类目"
|
||||
/>
|
||||
</el-form-item>
|
||||
<br v-if="!crud.status.add">
|
||||
<el-form-item label="密码" prop="password" v-if="crud.status.add">
|
||||
<el-input v-model="form.password" style="width: 200px;" show-password auto-complete="new-password"/>
|
||||
<el-form-item v-if="crud.status.add" label="密码" prop="password">
|
||||
<el-input v-model="form.password" style="width: 200px;" show-password auto-complete="new-password" />
|
||||
</el-form-item>
|
||||
<el-form-item label="性别">
|
||||
<el-radio-group v-model="form.gender" style="width: 178px">
|
||||
@@ -99,31 +100,31 @@
|
||||
<el-radio label="女">女</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-radio-group v-model="form.enabled" :disabled="form.id === user.id">
|
||||
<el-radio
|
||||
v-for="item in dict.user_status"
|
||||
:key="item.id"
|
||||
:label="item.value"
|
||||
>{{ item.label }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
<el-form-item label="状态" prop="isUesd">
|
||||
<el-switch
|
||||
v-model="form.isUsed"
|
||||
active-color="#409EFF"
|
||||
inactive-color="#F56C6C"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item style="margin-bottom: 0;" label="角色" prop="roles">
|
||||
<br v-if="!crud.status.edit">
|
||||
<el-form-item v-if="crud.status.add" style="margin-bottom: 0;" label="角色" prop="roles">
|
||||
<el-select
|
||||
v-model="roleDatas"
|
||||
style="width: 512px"
|
||||
multiple
|
||||
active-value="1"
|
||||
inactive-value="0"
|
||||
placeholder="请选择"
|
||||
@remove-tag="deleteTag"
|
||||
@change="changeRole"
|
||||
>
|
||||
<!--:disabled="level !== 1 && item.level <= level"-->
|
||||
<el-option
|
||||
v-for="item in roles"
|
||||
:key="item.name"
|
||||
:disabled="level !== 1 && item.level <= level"
|
||||
:key="item.roleId"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
:value="item.roleId"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@@ -142,55 +143,51 @@
|
||||
@selection-change="crud.selectionChangeHandler"
|
||||
>
|
||||
<el-table-column :selectable="checkboxT" type="selection" width="55" />
|
||||
<el-table-column show-overflow-tooltip prop="username" label="用户名" />
|
||||
<el-table-column show-overflow-tooltip prop="nickName" label="姓名" />
|
||||
<el-table-column prop="gender" label="性别" />
|
||||
<el-table-column show-overflow-tooltip prop="phone" width="100" label="电话" />
|
||||
<el-table-column show-overflow-tooltip width="135" prop="email" label="邮箱" />
|
||||
<el-table-column show-overflow-tooltip prop="dept" label="部门">
|
||||
<el-table-column prop="username" label="用户名" :min-width="flexWidth('username',crud.data,'用户名')" />
|
||||
<el-table-column
|
||||
prop="personName"
|
||||
label="姓名"
|
||||
:min-width="flexWidth('personName',crud.data,'姓名')"
|
||||
/>
|
||||
<el-table-column prop="gender" label="性别" :min-width="flexWidth('personName',crud.data,'性别')" />
|
||||
<el-table-column prop="phone" label="电话" :min-width="flexWidth('phone',crud.data,'电话')" />
|
||||
<el-table-column prop="email" label="邮箱" :min-width="flexWidth('email',crud.data,'邮箱')" />
|
||||
<el-table-column show-overflow-tooltip prop="depts" label="部门">
|
||||
<template slot-scope="scope">
|
||||
<div>{{ scope.row.dept.name }}</div>
|
||||
<span v-for=" item in scope.row.depts" :key="item.index">{{ item.name }} </span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table-column>>
|
||||
<el-table-column label="状态" align="center" prop="enabled">
|
||||
<template slot-scope="scope">
|
||||
<el-switch
|
||||
v-model="scope.row.enabled"
|
||||
:disabled="user.id === scope.row.id"
|
||||
active-color="#409EFF"
|
||||
inactive-color="#F56C6C"
|
||||
@change="changeEnabled(scope.row, scope.row.enabled)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column show-overflow-tooltip prop="createTime" width="135" label="创建日期">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||
<span :style="{'color': caseStatusColorFilter(scope.row.isUsed)}">{{ enabledTypeOptions.find(item => {return item.key == scope.row.isUsed}).display_name }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createTime" label="创建日期" :min-width="flexWidth('createTime',crud.data,'创建日期')" />
|
||||
<el-table-column
|
||||
v-permission="['admin','user:edit','user:del']"
|
||||
label="操作"
|
||||
width="200"
|
||||
align="center"
|
||||
fixed="right"
|
||||
align="center"
|
||||
width="200"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<udOperation
|
||||
style="display: inline"
|
||||
:data="scope.row"
|
||||
:permission="permission"
|
||||
:disabled-dle="scope.row.id === user.id"
|
||||
/>
|
||||
<el-button
|
||||
v-permission="permission.edit"
|
||||
type="text"
|
||||
slot="left"
|
||||
icon="el-icon-refresh-left"
|
||||
@click="resetPassword(scope.row)"
|
||||
>
|
||||
重置密码
|
||||
</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="crud.toEdit(scope.row)">修改</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handdeleted(scope.row)">删除</el-button>
|
||||
<el-dropdown v-hasPermi="['system:user:resetPwd', 'system:user:edit']" size="mini">
|
||||
<el-button size="mini" type="text" icon="el-icon-d-arrow-right">更多</el-button>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item icon="el-icon-refresh-right"><span @click="resetPassword(scope.row)">重置密码</span></el-dropdown-item>
|
||||
<el-dropdown-item icon="el-icon-key">
|
||||
<span @click="openDeptDrawer(scope.row)">部门权限</span>
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item icon="el-icon-key">
|
||||
<span @click="openDataDialog(scope.row)">数据权限</span>
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item icon="el-icon-lock"><span @click="changeEnabled(scope.row)">{{ enabledTypeOptions.find(item => {return item.key !== scope.row.isUsed}).display_name }}账号</span></el-dropdown-item>
|
||||
<el-dropdown-item icon="el-icon-circle-check">
|
||||
<span @click="openRoleDrawer(scope.row)">分配角色</span>
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -198,70 +195,210 @@
|
||||
<pagination />
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-drawer
|
||||
:title="drawerTitle"
|
||||
:visible.sync="syncDrawer"
|
||||
direction="rtl"
|
||||
:before-close="handleClose"
|
||||
:wrapper-closable="false"
|
||||
size="35%"
|
||||
@close="clearCheck"
|
||||
>
|
||||
<div style="margin: 0 20px 0 20px; height: 100%">
|
||||
<div style="height: 90%">
|
||||
<el-tree
|
||||
v-if="flag"
|
||||
ref="deptUser"
|
||||
show-checkbox
|
||||
default-expand-all
|
||||
:data="deptsDatas"
|
||||
:default-checked-keys="depChecked"
|
||||
:props="deptProps"
|
||||
node-key="deptId"
|
||||
highlight-current
|
||||
check-strictly
|
||||
@check="handCheck"
|
||||
@check-change="checkChange"
|
||||
@close="clearCheck"
|
||||
/>
|
||||
<el-table
|
||||
v-if="!flag"
|
||||
ref="roleTable"
|
||||
highlight-current-row
|
||||
style="width: 100%;"
|
||||
:data="rolesDatas"
|
||||
@selection-change="crud.selectionChangeHandler"
|
||||
>
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column prop="name" label="角色名称" min-width="100" show-overflow-tooltip />
|
||||
</el-table>
|
||||
</div>
|
||||
<div style="height: 10%">
|
||||
<el-button @click="cancelForm">取 消</el-button>
|
||||
<el-button type="primary" @click="saveChecked">保 存</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-drawer>
|
||||
<el-dialog
|
||||
:close-on-click-modal="true"
|
||||
:visible.sync="dataPerm"
|
||||
:title="dataPermissionTitle"
|
||||
width="700px"
|
||||
>
|
||||
<el-form ref="form" :inline="true" :model="dataDialog" :rules="rules" size="mini" label-width="100px">
|
||||
<el-form-item label="用户名" prop="username">
|
||||
<el-input v-model="dataDialog.username" disabled style="width: 200px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="姓名" prop="presonName">
|
||||
<el-input v-model="dataDialog.personName" disabled style="width: 200px;" />
|
||||
</el-form-item>
|
||||
<el-table
|
||||
ref="dialogTable"
|
||||
:data="dataDialog.dataScopeType"
|
||||
style="width: 100%;"
|
||||
@selection-change="getRows"
|
||||
>
|
||||
<el-table-column :selectable="checkboxT" type="selection" width="55" />
|
||||
<el-table-column prop="label" label="权限范围" />
|
||||
<el-table-column label="数据权限">
|
||||
<template slot-scope="scope">
|
||||
<el-select
|
||||
v-model="scope.row.permissionId"
|
||||
placeholder="请选择"
|
||||
@change="openRelevance(scope.row, scope.$index)"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in permissions"
|
||||
:key="item.permissionId"
|
||||
:label="item.name"
|
||||
:value="item.permissionId"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="操作"
|
||||
fixed="right"
|
||||
align="center"
|
||||
width="100"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" @click="showDatas(scope.row)">查看明细</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="cancelDataPerm">取消</el-button>
|
||||
<el-button type="primary" @click="savePermise()">确认</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<el-dialog
|
||||
:close-on-click-modal="true"
|
||||
:visible.sync="showData"
|
||||
:title="dataPermissionTitle"
|
||||
width="700px"
|
||||
>
|
||||
<el-table
|
||||
ref="dialogTable"
|
||||
:data="dataPermissions"
|
||||
style="width: 100%; max-height: 500px"
|
||||
>
|
||||
<el-table-column prop="permissionScopeType" label="权限类型" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column prop="permissionName" label="权限范围" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column prop="deptName" label="部门名称" min-width="100" show-overflow-tooltip />
|
||||
<el-table-column prop="personName" label="用户名称" min-width="100" show-overflow-tooltip />
|
||||
</el-table>
|
||||
</el-dialog>
|
||||
<relevance-user-dialog :dialog-show.sync="relevanceUser" :is-single="false" :users="userIds" @selectUsers="selectUsers" />
|
||||
<relevance-dept-dialog :dialog-show.sync="relevanceDept" :is-single="false" :depts="deptIds" @selectDepts="selectDepts" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import crudUser from '@/api/system/user'
|
||||
import { getDepts, getDeptSuperior } from '@/api/system/dept'
|
||||
import { getAll, getLevel } from '@/api/system/role'
|
||||
import crudUser from '@/views/system/user/user'
|
||||
import crudDept from '@/views/system/dept/dept'
|
||||
import crudDataPermission from '@/views/system/dataPermission/dataPermission'
|
||||
import { getAll, getLevel } from '@/views/system/role/role'
|
||||
import CRUD, { crud, form, header, presenter } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import crudOperation from '@crud/CRUD.operation'
|
||||
import udOperation from '@crud/UD.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
import DateRangePicker from '@/components/DateRangePicker'
|
||||
import Treeselect, { LOAD_CHILDREN_OPTIONS } from '@riophae/vue-treeselect'
|
||||
import { mapGetters } from 'vuex'
|
||||
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||
import RelevanceUserDialog from '@/views/system/user/dialog/relevanceUserDialog'
|
||||
import RelevanceDeptDialog from '@/views/system/user/dialog/relevanceDeptDialog'
|
||||
|
||||
let userRoles = []
|
||||
const defaultForm = {
|
||||
id: null,
|
||||
deptId: null,
|
||||
depts: [],
|
||||
username: null,
|
||||
nickName: null,
|
||||
personName: null,
|
||||
gender: '男',
|
||||
email: null,
|
||||
enabled: 'true',
|
||||
isUsed: true,
|
||||
roles: [],
|
||||
dept: { id: null },
|
||||
phone: null,
|
||||
password: null
|
||||
}
|
||||
export default {
|
||||
name: 'User',
|
||||
components: { Treeselect, crudOperation, rrOperation, udOperation, pagination, DateRangePicker },
|
||||
components: { RelevanceDeptDialog, RelevanceUserDialog, Treeselect, crudOperation, rrOperation, udOperation, pagination },
|
||||
cruds() {
|
||||
return CRUD({ title: '用户', url: 'api/users', crudMethod: { ...crudUser }})
|
||||
return CRUD({ title: '用户', idField: 'userId', url: 'api/users', crudMethod: { ...crudUser }})
|
||||
},
|
||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||
// 数据字典
|
||||
dicts: ['user_status'],
|
||||
dicts: ['user_status', 'permission_scope_type'],
|
||||
data() {
|
||||
return {
|
||||
height: document.documentElement.clientHeight - 180 + 'px;',
|
||||
deptName: '', depts: [], deptDatas: [], level: 3, roles: [],
|
||||
roleDatas: [], // 多选时使用
|
||||
defaultProps: { children: 'children', label: 'name', isLeaf: 'leaf' },
|
||||
defaultProps: { children: 'children', label: 'name' },
|
||||
deptProps: { children: 'children', label: 'name' },
|
||||
permission: {
|
||||
add: ['admin', 'user:add'],
|
||||
edit: ['admin', 'user:edit'],
|
||||
del: ['admin', 'user:del']
|
||||
},
|
||||
enabledTypeOptions: [
|
||||
{ key: 'true', display_name: '激活' },
|
||||
{ key: 'false', display_name: '锁定' }
|
||||
{ key: true, display_name: '激活' },
|
||||
{ key: false, display_name: '锁定' }
|
||||
],
|
||||
rules: {
|
||||
username: [
|
||||
{ required: true, message: '请输入用户名', trigger: 'blur' },
|
||||
{ min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' }
|
||||
],
|
||||
nickName: [
|
||||
personName: [
|
||||
{ required: true, message: '请输入用户姓名', trigger: 'blur' },
|
||||
{ min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
},
|
||||
syncDrawer: false,
|
||||
depChecked: [],
|
||||
depCheckedId: '',
|
||||
deptsDatas: [],
|
||||
rolesDatas: [],
|
||||
drawerTitle: '',
|
||||
flag: true,
|
||||
dataPerm: false,
|
||||
dataDialog: {},
|
||||
permissions: [],
|
||||
permissionId: '',
|
||||
multipleSelection: [], // 选中
|
||||
relevanceUser: false, // 关联用户
|
||||
rowData: {}, // 当行数据
|
||||
relevanceDept: false, // 关联部门
|
||||
deptIds: [],
|
||||
userIds: [],
|
||||
showData: false,
|
||||
dataPermissions: [],
|
||||
dataPermissionTitle: '数据权限'
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -269,6 +406,9 @@ export default {
|
||||
'user'
|
||||
])
|
||||
},
|
||||
beforeMount() {
|
||||
this.deptTree()
|
||||
},
|
||||
created() {
|
||||
this.crud.msg.add = '新增成功'
|
||||
},
|
||||
@@ -293,16 +433,33 @@ export default {
|
||||
}
|
||||
})
|
||||
},
|
||||
caseStatusColorFilter(isUsed) {
|
||||
if (isUsed === true) {
|
||||
return '#378be2'
|
||||
}
|
||||
return '#F56C6C'
|
||||
},
|
||||
handdeleted(datas) {
|
||||
this.$confirm(`确认删除选中的1条数据?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.crud.delAllLoading = true
|
||||
this.crud.doDelete(datas)
|
||||
}).catch(() => {
|
||||
})
|
||||
},
|
||||
// 新增与编辑前做的操作
|
||||
[CRUD.HOOK.afterToCU](crud, form) {
|
||||
this.getRoles()
|
||||
if (form.id == null) {
|
||||
this.getDepts()
|
||||
if (form.deptId == null) {
|
||||
crudDept.getDepts()
|
||||
} else {
|
||||
this.getSupDepts(form.dept.id)
|
||||
this.getSupDepts(form.deptId)
|
||||
}
|
||||
this.getRoleLevel()
|
||||
form.enabled = form.enabled.toString()
|
||||
// this.getRoleLevel() 暂时不用
|
||||
form.isUsed = form.enabled.toString()
|
||||
},
|
||||
// 新增前将多选的值设置为空
|
||||
[CRUD.HOOK.beforeToAdd]() {
|
||||
@@ -311,18 +468,21 @@ export default {
|
||||
},
|
||||
// 初始化编辑时候的角色与岗位
|
||||
[CRUD.HOOK.beforeToEdit](crud, form) {
|
||||
crud.status.edit
|
||||
this.roleDatas = []
|
||||
userRoles = []
|
||||
const _this = this
|
||||
form.roles.forEach(function(role, index) {
|
||||
_this.roleDatas.push(role.id)
|
||||
const rol = { id: role.id }
|
||||
userRoles.push(rol)
|
||||
})
|
||||
if (form.roles !== null && form.roles.length > 0) {
|
||||
form.roles.forEach(function(role, index) {
|
||||
_this.roleDatas.push(role)
|
||||
const rol = { id: role }
|
||||
userRoles.push(rol)
|
||||
})
|
||||
}
|
||||
},
|
||||
// 提交前做的操作
|
||||
[CRUD.HOOK.afterValidateCU](crud) {
|
||||
if (!crud.form.dept.id) {
|
||||
if (!crud.form.depts) {
|
||||
this.$message({
|
||||
message: '部门不能为空',
|
||||
type: 'warning'
|
||||
@@ -335,25 +495,22 @@ export default {
|
||||
})
|
||||
return false
|
||||
}
|
||||
crud.form.roles = userRoles
|
||||
const roles = []
|
||||
userRoles.forEach(function(data, index) {
|
||||
roles.push(data.id)
|
||||
})
|
||||
crud.form.roles = roles
|
||||
return true
|
||||
},
|
||||
// 获取左侧部门数据
|
||||
getDeptDatas(node, resolve) {
|
||||
console.log('node', node)
|
||||
console.log('resolve', resolve)
|
||||
const sort = 'id,desc'
|
||||
const params = { sort: sort }
|
||||
if (typeof node !== 'object') {
|
||||
if (node) {
|
||||
params['name'] = node
|
||||
}
|
||||
} else if (node.level !== 0) {
|
||||
params['pid'] = node.data.id
|
||||
}
|
||||
console.log('params', params)
|
||||
setTimeout(() => {
|
||||
getDepts(params).then(res => {
|
||||
var q = {}
|
||||
// eslint-disable-next-line eqeqeq
|
||||
if (node != '') {
|
||||
q = { name: node }
|
||||
}
|
||||
crudDept.getDeptTree(q).then(res => {
|
||||
console.log('res', res)
|
||||
if (resolve) {
|
||||
resolve(res.content)
|
||||
@@ -363,10 +520,19 @@ export default {
|
||||
})
|
||||
}, 100)
|
||||
},
|
||||
|
||||
deptTree() {
|
||||
setTimeout(() => {
|
||||
crudDept.getDeptTree().then(res => {
|
||||
this.deptDatas = res.content
|
||||
})
|
||||
}, 100)
|
||||
},
|
||||
getDepts() {
|
||||
console.log('获取部门')
|
||||
getDepts({ enabled: true }).then(res => {
|
||||
crudDept.getDepts({ isUsed: true }).then(res => {
|
||||
console.log('获取的部门信息', res)
|
||||
|
||||
this.depts = res.content.map(function(obj) {
|
||||
if (obj.hasChildren) {
|
||||
obj.children = null
|
||||
@@ -376,7 +542,7 @@ export default {
|
||||
})
|
||||
},
|
||||
getSupDepts(deptId) {
|
||||
getDeptSuperior(deptId).then(res => {
|
||||
crudDept.getDeptSuperior(deptId).then(res => {
|
||||
console.log('父部门', res)
|
||||
const date = res.content
|
||||
this.buildDepts(date)
|
||||
@@ -396,42 +562,44 @@ export default {
|
||||
// 获取弹窗内部门数据
|
||||
loadDepts({ action, parentNode, callback }) {
|
||||
if (action === LOAD_CHILDREN_OPTIONS) {
|
||||
getDepts({ enabled: true, pid: parentNode.id }).then(res => {
|
||||
crudDept.getDeptvo({ isUsed: true, pid: parentNode.dept_id }).then(res => {
|
||||
parentNode.children = res.content.map(function(obj) {
|
||||
if (obj.hasChildren) {
|
||||
obj.children = null
|
||||
}
|
||||
obj.children = null
|
||||
return obj
|
||||
})
|
||||
setTimeout(() => {
|
||||
callback()
|
||||
}, 200)
|
||||
}, 100)
|
||||
})
|
||||
}
|
||||
},
|
||||
normalizer(node) {
|
||||
return {
|
||||
id: node.deptId,
|
||||
label: node.name,
|
||||
children: node.children
|
||||
}
|
||||
},
|
||||
// 切换部门
|
||||
handleNodeClick(data) {
|
||||
if (data.pid === 0) {
|
||||
this.query.deptId = null
|
||||
} else {
|
||||
this.query.deptId = data.id
|
||||
}
|
||||
this.query.deptId = data.deptId
|
||||
this.query.needAll = true
|
||||
this.crud.toQuery()
|
||||
this.query.deptId = null
|
||||
},
|
||||
// 改变状态
|
||||
changeEnabled(data, val) {
|
||||
this.$confirm('此操作将 "' + this.dict.label.user_status[val] + '" ' + data.username + ', 是否继续?', '提示', {
|
||||
changeEnabled(row) {
|
||||
const satus = this.enabledTypeOptions.find(item => { return item.key !== row.isUsed })
|
||||
this.$confirm('此操作将' + satus.display_name + '账号:' + row.username + ', 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
crudUser.edit(data).then(res => {
|
||||
this.crud.notify(this.dict.label.user_status[val] + '成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
}).catch(() => {
|
||||
data.enabled = !data.enabled
|
||||
row.isUsed = satus.key
|
||||
crudUser.edit(row).then(res => {
|
||||
this.crud.toQuery()
|
||||
this.crud.notify('账号' + row.username + '已' + satus.display_name)
|
||||
})
|
||||
}).catch(() => {
|
||||
data.enabled = !data.enabled
|
||||
})
|
||||
},
|
||||
// 获取弹窗内角色数据
|
||||
@@ -449,29 +617,257 @@ export default {
|
||||
})
|
||||
},
|
||||
checkboxT(row, rowIndex) {
|
||||
return row.id !== this.user.id
|
||||
// return row.id !== this.user.id
|
||||
return true
|
||||
},
|
||||
resetPassword(row) {
|
||||
row.password = null
|
||||
this.$prompt('', '重置密码', {
|
||||
this.$confirm(`确认重置密码?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
inputPlaceholder: '请输入新的密码',
|
||||
inputPattern: /^[A-Z|a-z|0-9|(._~!@#$^&*)]{6,20}$/,
|
||||
inputErrorMessage: '密码格式不正确,只能是6-20位密码',
|
||||
closeOnClickModal: false
|
||||
}).then(({ value }) => {
|
||||
row.password = value
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
row.password = '123456'
|
||||
crudUser.edit(row).then(res => {
|
||||
this.crud.toQuery()
|
||||
this.crud.notify('密码重置成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
})
|
||||
}).catch(() => {
|
||||
this.$message({
|
||||
type: 'info',
|
||||
message: '取消输入'
|
||||
this.crud.notify('密码重置成功,密码:123456', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
})
|
||||
})
|
||||
},
|
||||
// 部门权限
|
||||
openDeptDrawer(row) {
|
||||
crudDept.getDeptTree().then(res => {
|
||||
this.deptsDatas = res.content
|
||||
})
|
||||
this.openDrawer()
|
||||
this.drawerTitle = '分配部门权限'
|
||||
this.flag = true
|
||||
// 默认选中
|
||||
const deptIds = []
|
||||
for (var index in row.depts) {
|
||||
deptIds.push(row.depts[index].deptId)
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
this.$refs.deptUser.setCheckedKeys(deptIds)
|
||||
})
|
||||
this.giveValue(row)
|
||||
},
|
||||
// 角色权限
|
||||
openRoleDrawer(row) {
|
||||
this.rolesDatas = []
|
||||
getAll().then(res => {
|
||||
this.rolesDatas = res
|
||||
// 回显默认选中
|
||||
this.$nextTick(function() {
|
||||
for (let j = 0; j < row.roles.length; j++) {
|
||||
for (let i = 0; i < this.rolesDatas.length; i++) {
|
||||
if (this.rolesDatas[i].roleId == row.roles[j].roleId) {
|
||||
this.$refs.roleTable.toggleRowSelection(this.rolesDatas[i], true)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
this.openDrawer()
|
||||
this.drawerTitle = '分配角色权限'
|
||||
this.flag = false
|
||||
this.giveValue(row)
|
||||
},
|
||||
openDataDialog(row) {
|
||||
// 清空数据 应该需要初始化赋值
|
||||
this.dataDialog = {}
|
||||
this.multipleSelection = []
|
||||
// 获取权限范围
|
||||
crudDataPermission.getDataScopeType().then(res => {
|
||||
this.dataDialog.dataScopeType = res
|
||||
// permissions
|
||||
crudDataPermission.getDataPermissionOption().then(res => {
|
||||
// console.log(res)
|
||||
this.permissions = res
|
||||
this.dataDialog.personName = row.personName
|
||||
this.dataDialog.username = row.username
|
||||
this.dataDialog.userId = row.userId
|
||||
this.dataPermissionTitle = '[' + row.personName + '] 数据权限'
|
||||
this.dataPerm = true
|
||||
// 回显数据
|
||||
crudDataPermission.getDataShow(row.userId).then(res => {
|
||||
this.$nextTick(function() {
|
||||
for (var index = 0; index < res.length; index++) {
|
||||
for (var i = 0; i < this.dataDialog.dataScopeType.length; i++) {
|
||||
if (this.dataDialog.dataScopeType[i].value == res[index].permissionScopeType) {
|
||||
this.dataDialog.dataScopeType[i].permissionId = res[index].permissionId
|
||||
if (res[index].users) this.dataDialog.dataScopeType[i].users = res[index].users
|
||||
if (res[index].depts) this.dataDialog.dataScopeType[i].depts = res[index].depts
|
||||
// 选中
|
||||
this.$refs.dialogTable.toggleRowSelection(this.dataDialog.dataScopeType[i], true)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
},
|
||||
getRows(val) { // 获取行数据
|
||||
this.multipleSelection = val
|
||||
},
|
||||
openRelevance(row, index) {
|
||||
for (var i = 0; i < this.permissions.length; i++) {
|
||||
if (this.permissions[i].permissionId != undefined && this.permissions[i].permissionId && this.permissions[i].permissionId != row.permissionId) {
|
||||
this.$delete(this.dataDialog.dataScopeType[index], this.permissions[i].permissionId.toString())
|
||||
}
|
||||
}
|
||||
this.$set(this.dataDialog.dataScopeType[index], this.dataDialog.dataScopeType[index].permissionId, row.permissionId)
|
||||
this.rowData = {}
|
||||
this.deptIds = []
|
||||
this.userIds = []
|
||||
console.log(row)
|
||||
if (row.permissionId == '1605129738328870912') { // 选择用户
|
||||
this.userIds = this.dataDialog.dataScopeType[index].users
|
||||
this.rowData = row
|
||||
this.relevanceUser = true
|
||||
} else if (row.permissionId == '1605129882164137984') { // 选择部门
|
||||
this.deptIds = this.dataDialog.dataScopeType[index].depts
|
||||
this.rowData = row
|
||||
this.relevanceDept = true
|
||||
} else if (row.permissionId == '1605128919449735168') { // 自身
|
||||
const param = {
|
||||
userId: this.dataDialog.userId
|
||||
}
|
||||
this.dataDialog.dataScopeType[index].users = []
|
||||
this.dataDialog.dataScopeType[index].users.push(param)
|
||||
} else { // 其他应该清空
|
||||
this.dataDialog.dataScopeType[index].depts = []
|
||||
this.dataDialog.dataScopeType[index].users = []
|
||||
}
|
||||
},
|
||||
selectUsers(row) { // row对话框传来的数据
|
||||
for (var i = 0; i < this.dataDialog.dataScopeType.length; i++) {
|
||||
if (this.dataDialog.dataScopeType[i].dictId == this.rowData.dictId) {
|
||||
if (this.dataDialog.dataScopeType[i].depts != undefined && this.dataDialog.dataScopeType[i].depts.length > 0) this.dataDialog.dataScopeType[i].depts = []
|
||||
this.dataDialog.dataScopeType[i].users = row
|
||||
break
|
||||
}
|
||||
}
|
||||
this.rowData = {}
|
||||
},
|
||||
selectDepts(row) {
|
||||
for (var i = 0; i < this.dataDialog.dataScopeType.length; i++) {
|
||||
if (this.dataDialog.dataScopeType[i].dictId == this.rowData.dictId) {
|
||||
if (this.dataDialog.dataScopeType[i].users != undefined && this.dataDialog.dataScopeType[i].users.length > 0) this.dataDialog.dataScopeType[i].users = []
|
||||
this.dataDialog.dataScopeType[i].depts = row
|
||||
break
|
||||
}
|
||||
}
|
||||
this.rowData = {}
|
||||
},
|
||||
cancelDataPerm() {
|
||||
this.dataPerm = false
|
||||
},
|
||||
savePermise() {
|
||||
const param = {
|
||||
userId: this.dataDialog.userId,
|
||||
datas: this.multipleSelection
|
||||
}
|
||||
console.log('param', param)
|
||||
crudDataPermission.saveDataPermission(param).then(res => {
|
||||
this.dataPerm = false
|
||||
this.crud.notify('添加数据权限成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
this.crud.toQuery()
|
||||
})
|
||||
},
|
||||
openDrawer() {
|
||||
this.syncDrawer = true
|
||||
this.depCheckedId = ''
|
||||
this.depChecked = []
|
||||
},
|
||||
giveValue(row) {
|
||||
this.depCheckedId = row.userId
|
||||
},
|
||||
clearCheck() { // 清空选中
|
||||
if (this.flag) this.$refs.deptUser.setCheckedKeys([])
|
||||
},
|
||||
handleClose(done) {
|
||||
this.$confirm('确认关闭?')
|
||||
.then(_ => {
|
||||
done()
|
||||
})
|
||||
.catch(_ => {})
|
||||
},
|
||||
cancelForm() { // 关闭
|
||||
this.syncDrawer = false
|
||||
if (this.flag) this.clearCheck()
|
||||
},
|
||||
saveChecked() {
|
||||
const user = {
|
||||
userId: this.depCheckedId
|
||||
}
|
||||
if (this.flag) {
|
||||
user.deptIds = this.$refs.deptUser.getCheckedKeys()
|
||||
} else {
|
||||
user.rolesIds = this.crud.selections.map(item => (item.roleId))
|
||||
}
|
||||
crudUser.edit(user).then(res => {
|
||||
this.cancelForm()
|
||||
this.crud.notify('保存成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
this.crud.toQuery()
|
||||
})
|
||||
},
|
||||
// 覆盖原有勾选功能,父与子关联,子与父不关联
|
||||
handCheck(data, node) {
|
||||
this.hanleCheck(data, node, 'deptUser')
|
||||
},
|
||||
hanleCheck(data, node, treeName) {
|
||||
const _this = this
|
||||
// 获取当前节点是否被选中
|
||||
const isChecked = _this.$refs[treeName].getNode(data).checked
|
||||
// 如果当前节点被选中,则遍历下级子节点并选中,如果当前节点取消选中,则遍历下级节点并取消
|
||||
if (isChecked) {
|
||||
// 判断该节点是否有下级节点,如果有那么遍历设置下级节点为选中
|
||||
data.children && data.children.length > 0 && setChildreChecked(data.children, true)
|
||||
} else {
|
||||
// 如果节点取消选中,则取消该节点下的子节点选中
|
||||
data.children && data.children.length > 0 && setChildreChecked(data.children, false)
|
||||
}
|
||||
function setChildreChecked(node, isChecked) {
|
||||
node.forEach(item => {
|
||||
item.children && item.children.length > 0 && setChildreChecked(item.children, isChecked)
|
||||
// 修改勾选状态
|
||||
_this.$refs[treeName].setChecked(item.name, isChecked)
|
||||
})
|
||||
}
|
||||
},
|
||||
checkChange(data, checked, indeterminate) {
|
||||
const _this = this
|
||||
// console.log(data, checked, indeterminate);
|
||||
// 选中全部子节点,父节点也默认选中,但是子节点再次取消勾选或者全部子节点取消勾选也不会影响父节点勾选状态
|
||||
const checkNode = _this.$refs.deptUser.getNode(data)// 获取当前节点
|
||||
// 勾选部分子节点,父节点变为半选状态
|
||||
if (checkNode.parent && checkNode.parent.childNodes.some(ele => ele.checked)) {
|
||||
checkNode.parent.indeterminate = true
|
||||
}
|
||||
// 勾选全部子节点,父节点变为全选状态
|
||||
if (checkNode.parent && checkNode.parent.childNodes.every(ele => ele.checked)) {
|
||||
checkNode.parent.checked = true
|
||||
checkNode.parent.indeterminate = false
|
||||
}
|
||||
// 如果取消所有第二节点的勾选状态,则第一层父节点也取消勾选
|
||||
if (checkNode.level == 2 && checkNode.parent.childNodes.every(ele => !ele.checked)) {
|
||||
checkNode.parent.checked = false
|
||||
checkNode.parent.indeterminate = false
|
||||
}
|
||||
},
|
||||
showDatas(row) {
|
||||
const param = {
|
||||
userId: this.dataDialog.userId,
|
||||
permissionScopeType: row.value
|
||||
}
|
||||
crudDataPermission.getDataDetail(param).then(res => {
|
||||
console.log(res)
|
||||
this.dataPermissions = res
|
||||
})
|
||||
this.showData = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
61
lms/nladmin-ui/src/views/system/user/user.js
Normal file
61
lms/nladmin-ui/src/views/system/user/user.js
Normal file
@@ -0,0 +1,61 @@
|
||||
import request from '@/utils/request'
|
||||
import { encrypt } from '@/utils/rsaEncrypt'
|
||||
|
||||
export function add(data) {
|
||||
return request({
|
||||
url: 'api/users',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function del(ids) {
|
||||
return request({
|
||||
url: 'api/users',
|
||||
method: 'delete',
|
||||
data: ids
|
||||
})
|
||||
}
|
||||
|
||||
export function edit(data) {
|
||||
return request({
|
||||
url: 'api/users',
|
||||
method: 'put',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function editUser(data) {
|
||||
return request({
|
||||
url: 'api/users/center',
|
||||
method: 'put',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function updatePass(user) {
|
||||
const data = {
|
||||
oldPass: encrypt(user.oldPass),
|
||||
newPass: encrypt(user.newPass)
|
||||
}
|
||||
return request({
|
||||
url: 'api/users/updatePass/',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function updateEmail(form) {
|
||||
const data = {
|
||||
password: encrypt(form.pass),
|
||||
email: form.email
|
||||
}
|
||||
return request({
|
||||
url: 'api/users/updateEmail/' + form.code,
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del }
|
||||
|
||||
Reference in New Issue
Block a user