角色
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
@keyup.enter.native="crud.toQuery"
|
||||
/>
|
||||
<el-select
|
||||
v-model="query.is_used"
|
||||
v-model="query.isUsed"
|
||||
clearable
|
||||
size="mini"
|
||||
placeholder="状态"
|
||||
@@ -63,7 +63,7 @@
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="is_uesd">
|
||||
<el-switch
|
||||
v-model="form.is_used"
|
||||
v-model="form.isUsed"
|
||||
active-color="#409EFF"
|
||||
inactive-color="#F56C6C"
|
||||
active-value="1"
|
||||
@@ -103,10 +103,10 @@
|
||||
<!-- <el-table-column label="编码" prop="code" />-->
|
||||
<el-table-column label="名称" prop="name" />
|
||||
<el-table-column label="排序" prop="dept_sort" />
|
||||
<el-table-column label="状态" align="center" prop="is_used">
|
||||
<el-table-column label="状态" align="center" prop="isUsed">
|
||||
<template slot-scope="scope">
|
||||
<el-switch
|
||||
v-model="scope.row.is_used"
|
||||
v-model="scope.row.isUsed"
|
||||
:disabled="scope.row.id === 1"
|
||||
active-color="#409EFF"
|
||||
inactive-color="#F56C6C"
|
||||
@@ -153,7 +153,7 @@ const defaultForm = {
|
||||
sub_count: 0,
|
||||
pid: null,
|
||||
dept_sort: 999,
|
||||
is_used: '1',
|
||||
isUsed: '1',
|
||||
ext_id: null
|
||||
}
|
||||
export default {
|
||||
@@ -203,7 +203,7 @@ export default {
|
||||
} else {
|
||||
form.isTop = '1'
|
||||
}
|
||||
form.is_used = `${form.is_used}`
|
||||
form.isUsed = `${form.isUsed}`
|
||||
if (form.pid != null) {
|
||||
this.getSupDepts(form.pid)
|
||||
} else {
|
||||
@@ -228,7 +228,7 @@ export default {
|
||||
})
|
||||
},
|
||||
getDepts() {
|
||||
crudDept.getDeptvo({ is_used: '1' }).then(res => {
|
||||
crudDept.getDeptvo({ isUsed: '1' }).then(res => {
|
||||
this.depts = res.content.map(function(obj) {
|
||||
if (obj.hasChildren) {
|
||||
obj.children = null
|
||||
@@ -240,7 +240,7 @@ export default {
|
||||
// 获取弹窗内部门数据
|
||||
loadDepts({ action, parentNode, callback }) {
|
||||
if (action === LOAD_CHILDREN_OPTIONS) {
|
||||
crudDept.getDeptvo({ is_used: '1', pid: parentNode.dept_id }).then(res => {
|
||||
crudDept.getDeptvo({ isUsed: '1', pid: parentNode.dept_id }).then(res => {
|
||||
parentNode.children = res.content.map(function(obj) {
|
||||
obj.children = null
|
||||
return obj
|
||||
|
||||
@@ -138,6 +138,8 @@
|
||||
>
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column label="菜单标题" prop="title" :min-width="flexWidth('title',crud.data,'菜单标题')" />
|
||||
<el-table-column label="菜单标识" prop="menuId" :min-width="flexWidth('title',crud.data,'菜单标识')" />
|
||||
<el-table-column label="菜单标识" prop="menu_id" :min-width="flexWidth('title',crud.data,'菜单标识')" />
|
||||
<el-table-column label="子系统" prop="system_type" :min-width="flexWidth('system_type',crud.data,'子系统')" />
|
||||
<el-table-column prop="icon" label="图标" align="center" :min-width="flexWidth('icon',crud.data,'图标')">
|
||||
<template slot-scope="scope">
|
||||
@@ -185,7 +187,6 @@ import CRUD, { presenter, header, form, crud } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import crudOperation from '@crud/CRUD.operation'
|
||||
import udOperation from '@crud/UD.operation'
|
||||
import DateRangePicker from '@/components/DateRangePicker'
|
||||
|
||||
// crud交由presenter持有
|
||||
const defaultForm = {
|
||||
@@ -208,7 +209,7 @@ const defaultForm = {
|
||||
}
|
||||
export default {
|
||||
name: 'Menu',
|
||||
components: { Treeselect, IconSelect, crudOperation, rrOperation, udOperation, DateRangePicker },
|
||||
components: { Treeselect, IconSelect, crudOperation, rrOperation, udOperation },
|
||||
cruds() {
|
||||
return CRUD({ title: '菜单', idField: 'menuId', url: 'api/sysMenu', crudMethod: { ...crudMenu }})
|
||||
},
|
||||
@@ -260,6 +261,7 @@ export default {
|
||||
}, 100)
|
||||
},
|
||||
getSupDepts(menuId) {
|
||||
debugger
|
||||
crudMenu.getMenuSuperior(menuId).then(res => {
|
||||
const children = res.map(function(obj) {
|
||||
if (!obj.leaf && !obj.children) {
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
</el-col>
|
||||
<!--用户数据-->
|
||||
<el-col :span="20">
|
||||
<!--工具栏1-->
|
||||
<!--工具栏-->
|
||||
<div class="head-container">
|
||||
<div v-if="crud.props.searchToggle">
|
||||
<!-- 搜索 -->
|
||||
@@ -36,7 +36,7 @@
|
||||
@keyup.enter.native="crud.toQuery"
|
||||
/>
|
||||
<el-select
|
||||
v-model="query.is_used"
|
||||
v-model="query.isUsed"
|
||||
clearable
|
||||
size="mini"
|
||||
placeholder="状态"
|
||||
@@ -77,7 +77,8 @@
|
||||
<el-form-item label="邮箱" prop="email">
|
||||
<el-input v-model="form.email" style="width: 200px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="部门" prop="depts" :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.depts"
|
||||
:load-options="loadDepts"
|
||||
@@ -101,14 +102,15 @@
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="is_uesd">
|
||||
<el-switch
|
||||
v-model="form.is_used"
|
||||
v-model="form.isUsed"
|
||||
active-color="#409EFF"
|
||||
inactive-color="#F56C6C"
|
||||
active-value="1"
|
||||
inactive-value="0"
|
||||
/>
|
||||
</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"
|
||||
@@ -147,20 +149,18 @@
|
||||
<el-table-column
|
||||
prop="person_name"
|
||||
label="姓名"
|
||||
:min-width="flexWidth('person_name',crud.data,'姓名')"
|
||||
:min-width="flexWidth('personName',crud.data,'姓名')"
|
||||
/>
|
||||
<el-table-column prop="gender" label="性别" :min-width="flexWidth('person_name',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="deptnames" label="部门" />
|
||||
<el-table-column
|
||||
label="启用"
|
||||
align="center"
|
||||
prop="is_used"
|
||||
:formatter="crud.formatIsOrNot"
|
||||
:min-width="flexWidth('is_used',crud.data,'启用')"
|
||||
/>
|
||||
<el-table-column prop="create_time" label="创建日期" :min-width="flexWidth('create_time',crud.data,'创建日期')" />
|
||||
<el-table-column label="状态" align="center" prop="enabled">
|
||||
<template slot-scope="scope">
|
||||
<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
|
||||
label="操作"
|
||||
fixed="right"
|
||||
@@ -168,16 +168,22 @@
|
||||
width="200"
|
||||
>
|
||||
<template v-if="scope.row.userId !== 1" slot-scope="scope">
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">修改</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
|
||||
<el-dropdown v-hasPermi="['system:user:resetPwd', 'system:user:edit']" size="mini" @command="(command) => handleCommand(command, scope.row)">
|
||||
<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 command="handleResetPwd" icon="el-icon-key">重置密码</el-dropdown-item>
|
||||
<el-dropdown-item command="handleResetPwd" icon="el-icon-key">部门权限</el-dropdown-item>
|
||||
<el-dropdown-item command="handleResetPwd" icon="el-icon-key">数据权限</el-dropdown-item>
|
||||
<el-dropdown-item command="handleResetPwd" icon="el-icon-key">锁定账号</el-dropdown-item>
|
||||
<el-dropdown-item command="handleAuthRole" icon="el-icon-circle-check">分配角色</el-dropdown-item>
|
||||
<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>
|
||||
@@ -187,12 +193,134 @@
|
||||
<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="nodeKey"
|
||||
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="preson_name">
|
||||
<el-input v-model="dataDialog.person_name" 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.permission_id"
|
||||
placeholder="请选择"
|
||||
@change="openRelevance(scope.row, scope.$index)"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in permissions"
|
||||
:key="item.permission_id"
|
||||
:label="item.name"
|
||||
:value="item.permission_id"
|
||||
/>
|
||||
</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="permission_scope_type" label="权限类型" min-width="100" show-overflow-tooltip>
|
||||
<template slot-scope="scope">
|
||||
{{ dict.label.permission_scope_type[scope.row.permission_scope_type] }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<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>
|
||||
</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 '@/views/system/user'
|
||||
import crudDept from '@/api/system/dept'
|
||||
// import crudDataPermission from '@/views/system/permission/dataPermission'
|
||||
import { getAll, getLevel } from '@/api/system/role'
|
||||
import CRUD, { crud, form, header, presenter } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
@@ -202,6 +330,8 @@ import pagination from '@crud/Pagination'
|
||||
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 = {
|
||||
@@ -211,7 +341,7 @@ const defaultForm = {
|
||||
person_name: null,
|
||||
gender: '男',
|
||||
email: null,
|
||||
enabled: 'true',
|
||||
isUsed: '1',
|
||||
roles: [],
|
||||
phone: null,
|
||||
password: null
|
||||
@@ -224,13 +354,14 @@ export default {
|
||||
},
|
||||
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' },
|
||||
deptProps: { children: 'children', label: 'name' },
|
||||
permission: {
|
||||
add: ['admin', 'user:add'],
|
||||
edit: ['admin', 'user:edit'],
|
||||
@@ -249,7 +380,28 @@ export default {
|
||||
{ required: true, message: '请输入用户姓名', trigger: 'blur' },
|
||||
{ min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
},
|
||||
syncDrawer: false,
|
||||
depChecked: [],
|
||||
depCheckedId: '',
|
||||
deptsDatas: [],
|
||||
rolesDatas: [],
|
||||
drawerTitle: '',
|
||||
nodeKey: 'dept_id',
|
||||
flag: true,
|
||||
dataPerm: false,
|
||||
dataDialog: {},
|
||||
permissions: [],
|
||||
permission_id: '',
|
||||
multipleSelection: [], // 选中
|
||||
relevanceUser: false, // 关联用户
|
||||
rowData: {}, // 当行数据
|
||||
relevanceDept: false, // 关联部门
|
||||
deptIds: [],
|
||||
userIds: [],
|
||||
showData: false,
|
||||
dataPermissions: [],
|
||||
dataPermissionTitle: '数据权限'
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -284,6 +436,23 @@ export default {
|
||||
}
|
||||
})
|
||||
},
|
||||
caseStatusColorFilter(isUsed) {
|
||||
if (isUsed === '1') {
|
||||
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()
|
||||
@@ -292,8 +461,8 @@ export default {
|
||||
} else {
|
||||
this.getSupDepts(form.dept_id)
|
||||
}
|
||||
this.getRoleLevel()
|
||||
form.is_used = form.enabled.toString()
|
||||
// this.getRoleLevel() 暂时不用
|
||||
form.isUsed = form.enabled.toString()
|
||||
},
|
||||
// 新增前将多选的值设置为空
|
||||
[CRUD.HOOK.beforeToAdd]() {
|
||||
@@ -302,15 +471,17 @@ export default {
|
||||
},
|
||||
// 初始化编辑时候的角色与岗位
|
||||
[CRUD.HOOK.beforeToEdit](crud, form) {
|
||||
crud.status.edit
|
||||
this.roleDatas = []
|
||||
userRoles = []
|
||||
const _this = this
|
||||
const arr = form.roles.split(',')
|
||||
arr.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) {
|
||||
@@ -331,8 +502,7 @@ export default {
|
||||
userRoles.forEach(function(data, index) {
|
||||
roles.push(data.id)
|
||||
})
|
||||
crud.form.roles = roles.toString()
|
||||
crud.form.depts = crud.form.depts.toString()
|
||||
crud.form.roles = roles
|
||||
return true
|
||||
},
|
||||
// 获取左侧部门数据
|
||||
@@ -358,7 +528,7 @@ export default {
|
||||
},
|
||||
getDepts() {
|
||||
console.log('获取部门')
|
||||
crudDept.getDepts({ is_used: 1 }).then(res => {
|
||||
crudDept.getDepts({ isUsed: 1 }).then(res => {
|
||||
console.log('获取的部门信息', res)
|
||||
|
||||
this.depts = res.content.map(function(obj) {
|
||||
@@ -390,7 +560,7 @@ export default {
|
||||
// 获取弹窗内部门数据
|
||||
loadDepts({ action, parentNode, callback }) {
|
||||
if (action === LOAD_CHILDREN_OPTIONS) {
|
||||
crudDept.getDeptvo({ is_used: '1', pid: parentNode.dept_id }).then(res => {
|
||||
crudDept.getDeptvo({ isUsed: '1', pid: parentNode.dept_id }).then(res => {
|
||||
parentNode.children = res.content.map(function(obj) {
|
||||
obj.children = null
|
||||
return obj
|
||||
@@ -410,24 +580,23 @@ export default {
|
||||
},
|
||||
// 切换部门
|
||||
handleNodeClick(data) {
|
||||
this.query.deptId = data.dept_id
|
||||
this.query.deptId = data.deptId
|
||||
this.query.needAll = true
|
||||
this.crud.toQuery()
|
||||
},
|
||||
// 改变状态
|
||||
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
|
||||
})
|
||||
},
|
||||
// 获取弹窗内角色数据
|
||||
@@ -445,29 +614,245 @@ 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.nodeKey = 'dept_id'
|
||||
this.openDrawer()
|
||||
this.drawerTitle = '分配部门权限'
|
||||
this.flag = true
|
||||
// 默认选中
|
||||
this.depChecked = row.depts
|
||||
this.giveValue(row)
|
||||
},
|
||||
openRoleDrawer(row) {
|
||||
this.rolesDatas = []
|
||||
getAll().then(res => {
|
||||
this.rolesDatas = res
|
||||
// 回显默认选中
|
||||
this.$nextTick(function() {
|
||||
for (let i = 0; i < this.rolesDatas.length; i++) {
|
||||
for (let j = 0; j < row.roles.length; j++) {
|
||||
if (this.rolesDatas[i].role_id == row.roles[j]) {
|
||||
this.$refs.roleTable.toggleRowSelection(this.rolesDatas[i], true)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
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 => {
|
||||
// this.permissions = res
|
||||
// this.dataDialog.person_name = row.person_name
|
||||
// this.dataDialog.username = row.username
|
||||
// this.dataDialog.user_id = row.user_id
|
||||
// this.dataPermissionTitle = '[' + row.person_name + '] 数据权限'
|
||||
// this.dataPerm = true
|
||||
// // 回显数据
|
||||
// crudDataPermission.getDataShow(row.user_id).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].permission_scope_type) {
|
||||
// this.dataDialog.dataScopeType[i].permission_id = res[index].permission_id
|
||||
// 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].permission_id != undefined && this.permissions[i].permission_id && this.permissions[i].permission_id != row.permission_id) {
|
||||
// this.$delete(this.dataDialog.dataScopeType[index], this.permissions[i].permission_id.toString())
|
||||
// }
|
||||
// }
|
||||
// this.$set(this.dataDialog.dataScopeType[index], this.dataDialog.dataScopeType[index].permission_id, row.permission_id)
|
||||
// this.rowData = {}
|
||||
// this.deptIds = []
|
||||
// this.userIds = []
|
||||
// if (row.permission_id == '1601040560293023744') { // 选择用户
|
||||
// this.userIds = this.dataDialog.dataScopeType[index].users
|
||||
// this.rowData = row
|
||||
// this.relevanceUser = true
|
||||
// } else if (row.permission_id == '1601040621190123520') { // 选择部门
|
||||
// this.deptIds = this.dataDialog.dataScopeType[index].depts
|
||||
// this.rowData = row
|
||||
// this.relevanceDept = true
|
||||
// } else if (row.permission_id == '1601038030326599680') { // 自身
|
||||
// const param = {
|
||||
// user_id: this.dataDialog.user_id
|
||||
// }
|
||||
// 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].dict_id == this.rowData.dict_id) {
|
||||
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].dict_id == this.rowData.dict_id) {
|
||||
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 = {
|
||||
// user_id: this.dataDialog.user_id,
|
||||
// datas: this.multipleSelection
|
||||
// }
|
||||
// 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.user_id
|
||||
},
|
||||
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 = {
|
||||
user_id: this.depCheckedId
|
||||
}
|
||||
if (this.flag) {
|
||||
user.depts = this.$refs.deptUser.getCheckedKeys()
|
||||
} else {
|
||||
user.roles = this.crud.selections.map(item => (item.role_id))
|
||||
}
|
||||
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 = {
|
||||
user_id: this.dataDialog.user_id,
|
||||
permission_scope_type: row.value
|
||||
}
|
||||
crudDataPermission.getDataDetail(param).then(res => {
|
||||
this.dataPermissions = res
|
||||
})
|
||||
this.showData = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user