This commit is contained in:
zhutianqi
2021-07-02 15:33:01 +08:00
parent 988b2cd92c
commit adacd33cb8
7 changed files with 248 additions and 4 deletions
+6 -1
View File
@@ -3,7 +3,12 @@
* @author: xx
* @date: 2018-09-01 15:11:57
*/
/deep/.el-tree-node:focus > .el-tree-node__content {
color: #409EFF !important;
}
.el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content {
color: #409EFF !important;
}
.ellipsis () {
overflow: hidden;
white-space: nowrap;
+1 -1
View File
@@ -385,7 +385,7 @@ export default {
{
title: '我的板块',
path: '/plate',
menuId: '971d576ef9bce3bddd6f0d6bcc55d184'
menuId: 'e4a94f03223df6f4ad70732b96f07221'
}
// {
// title: '个人信息',
@@ -13,7 +13,9 @@
:props="defaultProps"
default-expand-all
:filter-node-method="filterNode"
highlight-current
ref="tree"
:expand-on-click-node="false"
@node-click="handleNodeClick">
</el-tree>
</div>
@@ -109,8 +111,10 @@
:props="props"
:data="postList"
:default-checked-keys="nodeList"
highlight-current
check-strictly
default-expand-all
:expand-on-click-node="false"
show-checkbox>
</el-tree>
<div id="roleFormButton" class="demo-drawer-footer">
@@ -7,6 +7,8 @@
:data="treeData"
:props="defaultProps"
default-expand-all
:expand-on-click-node="false"
highlight-current
ref="tree"
@node-contextmenu="rightHandleNodeClick"
@node-click="handleNodeClick">
@@ -105,9 +105,11 @@
v-if="modalRole"
:props="props"
:data="roleList"
highlight-current
:default-checked-keys="nodeList"
check-strictly
default-expand-all
:expand-on-click-node="false"
show-checkbox>
</el-tree>
<div id="roleFormButton" class="demo-drawer-footer">
+232 -2
View File
@@ -13,6 +13,8 @@
:data="treeData"
:props="defaultProps"
default-expand-all
:expand-on-click-node="false"
highlight-current
:filter-node-method="filterNode"
ref="tree"
@node-click="handleNodeClick">
@@ -35,6 +37,10 @@
class="common-button-primary add-button"
@click="roleAddData"
size="mini">配置数据权限</el-button>
<el-button type="primary"
class="common-button-primary add-button"
@click="RolesAdd(1)"
size="mini">新增角色</el-button>
</div>
<div class="content">
<el-table
@@ -57,7 +63,7 @@
label="角色描述">
</el-table-column>
<el-table-column
prop="phone"
prop="parent"
label="上级角色"
width="170px">
</el-table-column>
@@ -72,10 +78,25 @@
width="140px">
</el-table-column>
<el-table-column
prop="operateTime.data"
prop="operateTime"
width="160px"
label="操作时间">
</el-table-column>
<el-table-column
label="操作"
width="50px">
<template slot-scope="scope">
<div @click.stop style="display: inline-block">
<el-dropdown trigger="click" @command="handleCommand">
<i class="iconfont">&#xe61e;</i>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="[scope.row, '编辑']">编辑</el-dropdown-item>
<el-dropdown-item :command="[scope.row, '删除']">删除</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
</template>
</el-table-column>
</el-table>
</div>
<loading :loading="Loading">加载中...</loading>
@@ -95,7 +116,9 @@
:data="treeData2"
:props="defaultProps2"
:default-checked-keys="nodeList"
:expand-on-click-node="false"
default-expand-all
highlight-current
show-checkbox
check-strictly
ref="tree2">
@@ -121,6 +144,8 @@
:props="defaultProps3"
:default-checked-keys="nodeList2"
default-expand-all
highlight-current
:expand-on-click-node="false"
show-checkbox
check-strictly
ref="tree3">
@@ -131,6 +156,77 @@
<el-button class="common-button-primary" size="mini" icon="el-icon-check" type="primary" @click="confirmDialogData">确定</el-button>
</div>
</el-dialog>
<el-dialog
:title="addRoleTitle"
:visible.sync="addModel"
:wrapperClosable="false"
@close="AddRoleCancel"
size="800px">
<div class="myDialog">
<el-form
ref="addForm"
:model="addForm"
:rules="addFormRules"
class="label-input-form"
>
<el-form-item label="角色名称" prop="name" label-width="80px" class="add-form-item">
<el-input v-model="addForm.name"
placeholder="请输入角色名称"
clearable></el-input>
</el-form-item>
<el-form-item label="上级角色" prop="parentId" label-width="80px" class="add-form-item">
<el-input v-model="addForm.parentId" style="display: none;"
clearable></el-input>
<el-input v-model="addForm.parent"
placeholder="请选择上级角色"
@click.native="SuperiorRole"
clearable></el-input>
</el-form-item>
<el-form-item label="角色描述" prop="remarks" label-width="80px" class="add-form-item">
<el-input v-model="addForm.remarks"
placeholder="请输入上级描述"
clearable></el-input>
</el-form-item>
</el-form>
</div>
<div slot="footer">
<el-button class="common-button-default" size="mini" icon="el-icon-close" @click="AddRoleCancel">取消</el-button>
<el-button class="common-button-primary" size="mini" icon="el-icon-check" type="primary" @click="AddRoleOk">确定</el-button>
</div>
</el-dialog>
<el-drawer
title="选择上级角色"
:visible.sync="SuperiorRoleModel"
:wrapperClosable="false"
@close="SuperiorRoleCancle"
size="800px"
>
<el-tree
v-if="SuperiorRoleModel"
class="filter-tree1"
:data="treeData"
:props="defaultProps"
default-expand-all
check-strictly
node-key="id"
:default-checked-keys="nodeList3"
show-checkbox
highlight-current
@check="drawerCheck"
:expand-on-click-node="false"
ref="tree4">
</el-tree>
<div id="roleFormButton" class="demo-drawer-footer">
<el-button
size="mini"
class="common-button-primary"
icon="el-icon-check"
type="primary"
@click="SuperiorRoleOk"
>确定</el-button>
<el-button size="mini" class="common-button-default" icon="el-icon-close" @click="SuperiorRoleCancle">取消</el-button>
</div>
</el-drawer>
</div>
</template>
@@ -139,6 +235,24 @@ export default {
name: 'role-manage',
data () {
return {
type: '', // 新增/编辑状态
addRoleTitle: '',
SuperiorRoleData: {},
nodeList3: [],
SuperiorRoleModel: false,
addFormRules: {
name: [
{ required: true, message: '请输入角色名称', trigger: 'blur' }
]
},
addForm: {
name: '', // 角色名称
parentId: '', // 上级ID
remarks: '', // 角色描述
parent: '',
id: ''
},
addModel: false,
treeData3: [],
defaultProps3: {
children: 'children',
@@ -167,6 +281,116 @@ export default {
}
},
methods: {
handleCommand (command) {
switch (command[1]) {
case '编辑':
this.RolesAdd(0, command[0])
break
case '删除':
this.deleteRole(command[0])
break
}
},
deleteRole (row) { // 删除角色
this.$confirm('此操作将永久删除该角色, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$http.delete('sarRole/role', {
roleId: row.id
}, {}, res => {
if (res.ok) {
this.$message({
type: 'success',
message: '删除成功!'
});
this.getTree()
}
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
},
drawerCheck (data) {
var getlist = this.$refs.tree4.getCheckedNodes().concat(this.$refs.tree.getHalfCheckedNodes());
if(getlist.length == 1) {
}else {
this.$refs.tree4.setCheckedKeys([data.id]);
}
this.SuperiorRoleData = data
},
SuperiorRoleOk () { // 上级角色确定
this.addForm.parentId = this.SuperiorRoleData.id
this.addForm.parent = this.SuperiorRoleData.name
this.nodeList3 = []
this.nodeList3.push(this.addForm.parentId)
this.SuperiorRoleModel = false
},
SuperiorRoleCancle () { // 上级角色取消
this.SuperiorRoleModel = false
},
AddRoleCancel () { // 新增角色取消
this.$refs['addForm'].resetFields();
this.addModel = false
},
AddRoleOk () { // 新增角色确定
this.$refs['addForm'].validate((valid) => {
if (valid) {
if (this.type === 1) { // 新增
this.$http.postData('sarRole/role',this.addForm , {}, res=> {
if (res.ok) {
this.$message.success('新增角色成功')
this.addModel = false
this.getTree()
} else {
this.$message.warning(res.message)
this.addModel = false
}
})
} else { // 编辑
this.$http.putData('sarRole/role',this.addForm , {}, res=> {
if (res.ok) {
this.$message.success('修改角色信息成功')
this.addModel = false
this.getTree()
} else {
this.$message.warning(res.message)
this.addModel = false
}
})
}
}
})
this.addModel = false
},
SuperiorRole () { // 点击选择上级角色按钮
this.SuperiorRoleModel = true
},
RolesAdd (type, row) { // 新增/编辑角色按钮
this.type = type
if (type === 1) {
this.addRoleTitle = '新增角色'
this.addForm.name = ''
this.addForm.remarks = ''
this.addForm.parentId = ''
this.addForm.parent = ''
this.addForm.id = ''
} else {
this.addRoleTitle = '编辑角色'
this.addForm.name = row.name
this.addForm.remarks = row.remarks
this.addForm.parentId = row.parentId
this.addForm.parent = row.parent
this.addForm.id = row.id
this.nodeList3 = []
this.nodeList3.push(this.addForm.parentId)
}
this.addModel = true
},
getTree3 () {
this.$http.get('sarResource/ts-resource', {}, {}, res=> {
if (res.ok) {
@@ -282,6 +506,12 @@ export default {
.role-manage {
display: flex;
height: 100%;
/deep/.el-form-item__content {
width: 100%;
}
.filter-tree1 {
height: 100%;
}
.tree-close{
.tree{
left: -200px !important;
@@ -174,6 +174,7 @@
check-strictly
@check="drawerCheck"
default-expand-all
:expand-on-click-node="false"
show-checkbox
ref="tree">
</el-tree>