This commit is contained in:
宋伟佳
2021-06-29 17:52:51 +08:00
5 changed files with 585 additions and 1856 deletions
@@ -9,7 +9,6 @@
v-model="filterText">
</el-input>
<el-tree
class="filter-tree"
:data="treeData"
:props="defaultProps"
default-expand-all
@@ -65,7 +64,7 @@
label="所属部门">
</el-table-column>
<el-table-column
prop="positionName"
prop="NameList"
label="所属岗位">
</el-table-column>
<el-table-column
@@ -83,6 +82,7 @@
<el-dropdown-menu slot="dropdown">
<el-dropdown-item v-if="scope.row.disableFlag === '1'" :command="[scope.row, '启用']">启用</el-dropdown-item>
<el-dropdown-item v-if="scope.row.disableFlag === '0'" :command="[scope.row, '禁用']">禁用</el-dropdown-item>
<el-dropdown-item :command="[scope.row, '配置岗位']">配置岗位</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
@@ -94,6 +94,36 @@
<pagination :page="page" :total="total" @pageChange="pageChange" @pageSizeChange="pageSizeChange"></pagination>
</div>
<loading style="z-index: 2099;" :loading="treeLoading">导入中...</loading>
<el-drawer
title="配置岗位"
:visible.sync="modalPost"
:wrapperClosable="false"
size="800px"
@close="resetFormPost"
>
<el-tree
ref="tree2"
node-key="id"
class="filter-tree"
v-if="modalPost"
:props="props"
:data="postList"
:default-checked-keys="nodeList"
check-strictly
default-expand-all
show-checkbox>
</el-tree>
<div id="roleFormButton" class="demo-drawer-footer">
<el-button
size="mini"
class="common-button-primary"
icon="el-icon-check"
type="primary"
@click="PostSubmit"
>确定</el-button>
<el-button size="mini" class="common-button-default" icon="el-icon-close" @click="resetFormPost">取消</el-button>
</div>
</el-drawer>
</div>
</template>
@@ -102,6 +132,14 @@ export default {
name: 'MechanismManage',
data () {
return {
userId: '',
postList: [],
props: {
children: 'children',
label: 'name'
},
nodeList: [],
modalPost: false,
filterText: '', // 树结构检索条件
defaultProps: {
children: 'children',
@@ -119,6 +157,21 @@ export default {
}
},
methods: {
resetFormPost () {
this.modalPost= false
},
PostSubmit () {
this.$http.postData('sarUser/user/position', {
positionIds: this.$refs.tree2.getCheckedKeys(),
userId: this.userId
}, {}, res => {
if (res.ok) {
this.$message.success('配置岗位成功')
this.modalPost = false
this.getData()
}
})
},
handleCommand (command) {
switch (command[1]) {
case '启用':
@@ -127,8 +180,27 @@ export default {
case '禁用':
this.disableFlagEdit(command[0], 1)
break
case '配置岗位':
this.postsConfigure(command[0])
break
}
},
getTree2 () {
this.$http.get('sarPosition/position', {}, {
_this: this,
}, res=> {
this.postList = res.data
})
},
postsConfigure (row) {
var arr = []
this.userId = row.userId
row.positions.forEach((item) => {
arr.push(item.id)
})
this.nodeList = arr
this.modalPost= true
},
disableFlagEdit (row, type) {
let json = {}
json.userId = row.userId
@@ -173,6 +245,16 @@ export default {
_this: this,
loading: 'Loading'
}, res => {
res.data.forEach((item) => {
var NameList = ''
item.positions.forEach((items) => {
if (NameList.length > 0) {
NameList += ','
}
NameList += items.name
})
item.NameList = NameList
})
this.data = res.data
})
},
@@ -188,13 +270,13 @@ export default {
computed: {},
watch: {
filterText(val) {
console.log(val);
this.$refs.tree.filter(val);
}
},
mounted () {
// 获取组织结构树
this.getTree()
this.getTree2()
}
}
</script>
@@ -264,6 +346,9 @@ export default {
/deep/.width-all{
width: 100%;
}
.filter-tree {
height: calc(~'100% - 50px')
}
.laws-tree{
/deep/.clearable {
top: 20px;
+107 -427
View File
@@ -2,89 +2,67 @@
<template>
<div id="permission-menu-manage">
<div class="permission-menu-manage-left">
<laws-tree
ref="permissionManage"
treeDivId="permissionManage"
:zNodes="zNodes"
autoSelect
deptSelect
showRMenu
@treeClick="(treeId, treeNode) => handleClick(treeId, treeNode)"
@treeAdd="(treeId, treeNode) => handleAdd(treeId, treeNode)"
@treeEdit="(treeId, treeNode) => handleEdit(treeId, treeNode)"
@treeRightClick="(treeId, treeNode) => treeRightClick(treeId, treeNode)"
@treeRemove="(treeId, treeNode) => handleRemove(treeId, treeNode)"
></laws-tree>
<el-tree
class="filter-tree"
:data="treeData"
:props="defaultProps"
default-expand-all
ref="tree"
@node-contextmenu="rightHandleNodeClick"
@node-click="handleNodeClick">
</el-tree>
</div>
<div class="permission-menu-manage-right" v-if="showSarMenuInfoFlag">
<div class="permission-content">
<el-form ref="sarMenuForm" :model="sarMenuEO" :rules="sarMenuRules" class="label-input-form">
<el-row>
<el-col :span="6">
<span style="color: #fff">1</span>
</el-col>
<el-col :span="18">
<el-form-item label="ID" prop="id" label-width="130px" class="standards-info-item">
<el-input v-model="sarMenuEO.id" :disabled="formdisableflag" class="permission-input"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="6">
<span style="color: #fff">1</span>
</el-col>
<el-col :span="18">
<el-form-item label="名称" prop="name" label-width="130px" class="standards-info-item">
<el-input v-model="sarMenuEO.name" class="permission-input"></el-input>
</el-form-item>
</el-col>
</el-row>
<Row>
<el-col :span="6">
<span style="color: #fff">1</span>
</el-col>
<el-col :span="18">
<el-form-item label="父节点ID" prop="pId" label-width="130px" class="standards-info-item">
<el-input v-model="sarMenuEO.pId" :disabled="formdisableflag" class="permission-input"></el-input>
</el-form-item>
</el-col>
</Row>
<Row>
<el-col :span="6">
<span style="color: #fff">1</span>
</el-col>
<el-col :span="18">
<el-form-item label="前台页面地址" prop="href" label-width="130px" class="standards-info-item">
<el-input v-model="sarMenuEO.href" class="permission-input"></el-input>
</el-form-item>
</el-col>
</Row>
<Row>
<el-col :span="6">
<span style="color: #fff">1</span>
</el-col>
<el-col :span="18">
<el-form-item label="排序号" prop="isShow" label-width="130px" class="standards-info-item">
<el-input v-model="sarMenuEO.isShow" maxlength="2" class="permission-input"></el-input>
</el-form-item>
</el-col>
</Row>
<Row>
<el-col :span="6">
<span style="color: #fff">1</span>
</el-col>
<el-col :span="18">
<el-form-item label="后台接口权限" prop="permission" label-width="130px" class="standards-info-item">
<el-input v-model="sarMenuEO.permission" class="permission-input"></el-input>
</el-form-item>
</el-col>
</Row>
</el-form>
</div>
<div class="permission-btn" v-if="submitBtnFlag">
<el-button type="primary" :loading="isSubmit" @click="saveMenuInfo">提交</el-button>
</div>
<el-row>
<el-col :span="12">
<el-button type="primary"
class="common-button-primary add-button"
@click="Add"
size="mini">新增</el-button>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form
ref="sarStandardsInfoForm"
:model="form"
label-width="100px"
class="label-input-form"
>
<el-form-item label="Id" class="search-item">
<el-input v-model="form.id" clearable disabled/>
</el-form-item>
<el-form-item label="名称" class="search-item">
<el-input v-model="form.menuName" clearable disabled/>
</el-form-item>
<el-form-item label="父节点Id" class="search-item">
<el-input v-model="form.parentId" clearable disabled/>
</el-form-item>
</el-form>
</el-col>
</el-row>
</div>
<el-dialog
title="新增"
:visible.sync="modalshowflag"
:wrapperClosable="false"
:before-close="closeDialog"
size="800px">
<el-form
ref="sarStandardsInfoForm"
:model="NewForm"
label-width="100px"
class="label-input-form"
>
<el-form-item label="名称" class="search-item">
<el-input v-model="NewForm.menuName" clearable/>
</el-form-item>
</el-form>
<div slot="footer">
<el-button class="common-button-default" size="mini" icon="el-icon-close" @click="closeDialog">取消</el-button>
<el-button class="common-button-primary" size="mini" icon="el-icon-check" type="primary" @click="confirmDialog">提交</el-button>
</div>
</el-dialog>
</div>
</template>
@@ -96,212 +74,62 @@ export default {
name: 'permission-menu-manage',
data () {
return {
formdisableflag: true,
zNodes: [],
sarMenuEO: {
modalshowflag: false,
showSarMenuInfoFlag: false,
treeData: [],
defaultProps: {
children: 'children',
label: 'menuName'
},
form: {
id: '',
name: '',
pId: '',
href: '',
isShow: '',
permission: '',
menuName: '',
parentId: ''
},
sarMenuRules: {
name: [
{ required: true, message: '不能为空', trigger: 'blur' }
]
// isShow: [
// { type: 'string', required: true, message: '不能为空', trigger: 'blur' }
// ]
},
isSubmit: false,
showSarMenuInfoFlag: false,
submitBtnFlag: false,
saveClickNodeInfo: '',
clickType: '' // 1为新增,2为修改
NewForm: {
menuName: '',
}
}
},
methods: {
getTree () {
return new Promise((resolve, reject) => {
this.$http.get('sys/menu/listAllMenu', {}, {
_this: this
}, res => {
if (res.ok) {
let zNodes = []
for (let i = 0; i < res.data.length; i++) {
let zObj = {}
zObj.id = res.data[i].id
zObj.pId = res.data[i].parentId
zObj.name = res.data[i].name
zObj.href = res.data[i].href
zObj.isShow = res.data[i].isShow
zObj.permission = res.data[i].permission
zObj.remarks = res.data[i].remarks
zNodes[i] = zObj
if (res.data[i].parentIds !== null) {}
}
this.zNodes = zNodes
}
resolve()
}, e => {
reject(e)
})
})
},
/**
* @description: 树节点点击
* @author: chenxiaoxi
* @date: 2018-09-25 16:13:25
*/
handleClick (treeId, treeNode) {
this.submitBtnFlag = false
this.showSarMenuInfoFlag = true
this.sarMenuEO = treeNode
if (treeNode.href == null || treeNode.href === '' || treeNode.href === 'null') {
this.sarMenuEO.href = ''
}
if (treeNode.permission == null || treeNode.permission === '' || treeNode.permission === 'null') {
this.sarMenuEO.permission = ''
}
},
/**
* @description: 树节点添加
* @author: chenxiaoxi
* @date: 2018/12/26 15:39:22
*/
handleAdd (treeId, treeNode) {
this.resetForm()
this.submitBtnFlag = true
this.clickType = '1'
this.showSarMenuInfoFlag = true
this.sarMenuEO.pId = treeNode.id
},
/**
* @description: 树节点删除
* @author: chenxiaoxi
* @date: 2018-09-25 14:05:25
*/
handleRemove (treeId, treeNode) {
if (treeNode.pId == null || treeNode.pId === '') {
this.$Message.error('不能删除根级节点')
} else {
this.$http.get('sys/menu/judgeContentChild', {
id: treeNode.id
}, {
_this: this
}, res => {
if (res.data != null && res.data.length > 0) {
this.$message.error('该节点包含子节点,不能删除')
} else {
this.sureDeleteMenu(treeNode)
}
}, e => {})
}
},
sureDeleteMenu (treeNode) {
this.$confirm('确认删除该条数据?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
confirmButtonClass: 'common-button-primary',
roundButton: true
}).then(() => {
if (treeNode.id != null && treeNode.id !== '') {
this.$http.put('sys/menu/deleteMenuById', {
id: treeNode.id
}, {
_this: this
}, res => {
if (res.data != null) {
this.getTree()
this.showSarMenuInfoFlag = false
this.resetForm()
}
}, e => {
})
confirmDialog () {
var form = {}
form.parentId = this.form.id
form.menuName = this.NewForm.menuName
this.$http.postData('lawss/sarMenu/add', form, {}, res=> {
if (res.ok) {
this.getTree()
this.modalshowflag = false
this.$message.success('成功')
} else {
this.$message.warning('没有获取到所选节点id')
this.$message.warning(res.message)
}
})
},
/**
* @description: 节点编辑
* @author: chenxiaoxi
* @date: 2018/12/26 15:29:46
*/
handleEdit (treeId, treeNode) {
this.submitBtnFlag = true
this.clickType = '2'
Add () {
this.NewForm.menuName = ''
this.modalshowflag = true
},
closeDialog () {
this.modalshowflag = false
this.NewForm.menuName = ''
},
rightHandleNodeClick (e, data) {},
handleNodeClick (data) {
this.form.id = data.id
this.form.menuName = data.menuName
this.form.parentId = data.parentId
this.showSarMenuInfoFlag = true
this.saveClickNodeInfo = treeNode
this.sarMenuEO = treeNode
if (treeNode.href == null || treeNode.href === '' || treeNode.href === 'null') {
this.sarMenuEO.href = ''
}
if (treeNode.permission == null || treeNode.permission === '' || treeNode.permission === 'null') {
this.sarMenuEO.permission = ''
}
},
treeRightClick (treeId, treeNode) {
},
resetForm () {
this.sarMenuEO.id = ''
this.sarMenuEO.pId = ''
this.sarMenuEO.name = ''
this.sarMenuEO.href = ''
this.sarMenuEO.isShow = ''
this.sarMenuEO.permission = ''
},
saveMenuInfo () {
if (this.sarMenuEO.isShow != null && this.sarMenuEO.isShow !== '') {
this.isSubmit = true
this.$refs['sarMenuForm'].validate((valid) => {
if (valid) {
this.sarMenuEO.parentId = this.sarMenuEO.pId
let menuEO = JSON.parse(JSON.stringify(this.sarMenuEO))
if (this.clickType === '1') {
this.$http.post('sys/menu/addMenu', menuEO, {
_this: this,
loading: 'isSubmit'
}, res => {
if (res.ok) {
this.isSubmit = false
this.submitBtnFlag = false
this.getTree()
}
}, e => {
this.isSubmit = false
})
} else {
this.$http.put('sys/menu/updateMenu', this.sarMenuEO, {
_this: this,
loading: 'isSubmit'
}, res => {
this.isSubmit = false
this.submitBtnFlag = false
this.getTree()
}, e => {
this.isSubmit = false
})
}
} else {
this.isSubmit = false
this.$message.error('请检查表单是否填写正确!')
}
})
} else {
this.$message.warning('排序号不能为空!')
}
}
},
props: {
sideClose: {
type: Boolean
getTree () {
this.$http.get('lawss/sarMenu', {}, {}, res=> {
if (res.ok) {
this.treeData = res.data
}
})
}
},
props: {},
computed: {},
watch: {},
mounted () {
@@ -312,177 +140,29 @@ export default {
<style lang="less">
//@import '~styles/mixins';
#permission-menu-manage{
#permission-menu-manage {
display: flex;
//.flex();
background: #FFF;
.permission-menu-manage-left{
height: 100%;
.permission-menu-manage-left {
width: 240px;
height: 100%;
border-right: 1px solid #DDD;
position: relative;
overflow-x: auto;
padding: 5px;
.node_name{
display: inline-block;
max-width: 200px;
//.ellipsis();
}
}
.permission-menu-manage-right{
.permission-menu-manage-right {
width: calc(~'100% - 240px');
display: inline-block;
height: 100%;
padding: 10px;
position: relative;
.content{
.content {
height: calc(~'100% - 150px');
background: #CCC;
.hasNoData{
background: #FFF;
width: 100%;
height: 100%;
.no-data-icon{
width: 150px;
}
}
}
.ivu-table-overflowX{
overflow-x: auto;
}
.pagination{
.ivu-divider{
margin-bottom: 0;
}
}
.syncInfo{
padding-bottom: 0.2rem;
//.flex();
flex: 1;
align-items: center;
}
.permission-content{
padding-top: 30px;
.permission-input{
width: 300px;
}
}
.permission-btn{
text-align: center;
}
}
.ivu-tree-children{
.ivu-tree-arrow{
margin-right: 5px;
}
}
.content .btn-group{
margin-bottom: 0.5rem;
}
.permission-menu-manage-right-search{
.ivu-form-item-label{
padding: 0;
}
.ivu-form-item-content{
width: calc(~'100% - 60px');
.ivu-select{
width: 100%;
}
}
.ivu-form-item{
margin: 0;
}
.ivu-btn{
position: relative;
top: 1px;
}
}
.ivu-divider-horizontal{
margin: 8px 0;
}
.ivu-table-body{
overflow-x: auto;
}
.ivu-table-tip{
width: 100%;
height: calc(~'100% - 41px');
table{
display: block;
tbody,tr,td{
display: block;
width: 100% !important;
height: 100%;
}
td{
//.flex();
justify-content: center;
align-items: center;
}
}
}
.hasNoData{
background: #FFF;
.no-data-icon{
width: 85px;
}
}
.ivu-table-fixed,
.ivu-table-fixed-right{
height: 100%;
.ivu-table-fixed-body{
height: calc(~'100% - 41px');
}
}
.ivu-select-item{
max-width: 200px;
//.ellipsis();
}
.demo-drawer-footer{
width: 100%;
position: absolute;
bottom: 0;
left: 0;
border-top: 1px solid #e8e8e8;
padding: 10px 16px;
text-align: right;
background: #fff;
}
.btn-show{
display: inline-block !important;
}
.btn-hide{
display: none !important;
}
.ivu-tag{
cursor: default;
}
}
.role-setting-form{
.ivu-modal-body{
overflow-y: inherit;
}
}
.demo-drawer-profile{
font-size: 14px;
}
.demo-drawer-profile .ivu-col{
margin-bottom: 12px;
}
.user-info-text{
color: #A59D9D;
}
.mechanism-tree-modal{
.ivu-modal{
width: 350px !important;
.form-content{
width: 300px;
margin: 0 auto;
.ivu-form-item{
//.flex();
.ivu-form-item-content{
flex: 1;
}
}
}
}
}
+138 -32
View File
@@ -34,7 +34,7 @@
width="170px">
</el-table-column>
<el-table-column
prop=""
prop="NameList"
label="绑定角色">
</el-table-column>
<el-table-column
@@ -47,11 +47,26 @@
label="操作时间"
width="170px">
</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>
<el-dialog
title="新增岗位"
:title="dialogTitle"
:visible.sync="modalshowflag"
:wrapperClosable="false"
size="800px"
@@ -88,10 +103,22 @@
v-if="modalRole"
:props="props"
:data="roleList"
show-checkbox
@check="handleCheckChange">
:default-checked-keys="nodeList"
check-strictly
default-expand-all
show-checkbox>
</el-tree>
<el-button @click="add"></el-button>
<div id="roleFormButton" class="demo-drawer-footer">
<el-button
size="mini"
class="common-button-primary"
icon="el-icon-check"
type="primary"
@click="RoleSubmit"
:loading="submitLoading"
>确定</el-button>
<el-button size="mini" class="common-button-default" icon="el-icon-close" @click="resetFormRole">取消</el-button>
</div>
</el-drawer>
</div>
</template>
@@ -101,6 +128,11 @@
name: 'PostManage',
data () {
return {
editId: '',
type: '', // 1为新增 2为编辑
dialogTitle: '',
nodeList: [],
submitLoading: false,
selectList: [],
data: [],
Loading: false,
@@ -122,15 +154,52 @@
}
},
methods: {
add () {
console.log(this.$refs.tree.getCheckedKeys().concat(this.$refs.tree.getHalfCheckedKeys()));
},
handleCheckChange (checkedNodes, checkedKeys) {
var list = []
for (var a = 0; a < checkedKeys.checkedNodes.length; a++) {
list.push(checkedKeys.checkedNodes[a].id)
handleCommand (command) {
switch (command[1]) {
case '删除':
this.deleteData(command[0])
break
case '编辑':
this.editData(command[0])
break
}
},
deleteData (row) {
this.$http.delete('sarPosition/position', {
positionId: row.id
}, {}, res => {
if (res.ok) {
this.$message.success('删除成功')
this.getData()
}
})
},
editData (row) {
this.type = 2
this.editId = row.id
this.sarStandardsInfoEO.name = row.name
this.dialogTitle = '修改岗位信息'
this.modalshowflag = true
},
RoleSubmit () { // 配置角色提交
this.submitLoading = true
this.$http.postData('sarPosition/position/role', {
positionId: this.selectList[0].id,
roleIds: this.$refs.tree.getCheckedKeys().concat(this.$refs.tree.getHalfCheckedKeys())
}, {}, res=> {
if (res.ok) {
this.$message.success('配置成功')
this.modalRole = false
this.getData()
} else {
this.$message.warning(res.message)
}
this.submitLoading = false
})
},
resetFormRole () { // 配置角色关闭事件
this.modalRole = false
},
getRole () {
this.$http.get('sarRole/role', {}, {}, res=> {
this.roleList = res.data
@@ -140,10 +209,13 @@
this.selectList = val
},
addRole () { // 点击配置角色按钮
if (this.selectList.length > 0) {
if (this.selectList.length === 1) {
this.modalRole = true
} else {
this.nodeList = this.selectList[0].idList
} else if (this.selectList.length === 0) {
this.$message.warning('请选择要配置角色的岗位')
} else {
this.$message.warning('请选择一条岗位')
}
},
getData () { // 获取岗位数据
@@ -151,37 +223,68 @@
_this: this,
loading: 'Loading'
}, res=> {
res.data.forEach((item)=>{
var idList = []
var NameList = ''
item.roles.forEach((items)=>{
if (NameList.length > 0) {
NameList += ','
}
idList.push(items.id)
NameList += items.name
})
item.idList = idList
item.NameList = NameList
})
this.data = res.data
})
},
addModal () { // 点击新增按钮
this.type = 1
this.dialogTitle = '新增岗位'
this.modalshowflag = true
},
resetForm () { // 新增岗位关闭事件
this.$refs['sarStandardsInfoForm'].resetFields();
this.modalshowflag = false
},
resetFormRole () { // 配置角色关闭事件
},
submit () { // 新增角色确认
this.$refs['sarStandardsInfoForm'].validate((valid) => {
if (valid) {
this.$http.post('sarPosition/position', {
createById: this.$store.getters.userInfo.userId,
operator: this.$store.getters.userInfo.account,
name: this.sarStandardsInfoEO.name
}, {
_this: this,
loading: 'Loading'
}, res=> {
if (res.ok) {
this.$message.success('新增成功')
this.modalshowflag = false
this.getData()
} else {
this.$message.warning('新增失败')
}
})
if (this.type === 1) {
this.$http.post('sarPosition/position', {
createById: this.$store.getters.userInfo.userId,
operator: this.$store.getters.userInfo.account,
name: this.sarStandardsInfoEO.name
}, {
_this: this,
loading: 'Loading'
}, res=> {
if (res.ok) {
this.$message.success('新增成功')
this.modalshowflag = false
this.getData()
} else {
this.$message.warning(res.message)
}
})
} else {
this.$http.put('sarPosition/position', {
id: this.editId,
name: this.sarStandardsInfoEO.name
}, {
_this: this,
loading: 'Loading'
}, res=> {
if (res.ok) {
this.$message.success('修改成功')
this.modalshowflag = false
this.getData()
} else {
this.$message.warning(res.message)
}
})
}
} else {
return false;
}
@@ -204,5 +307,8 @@
.content {
height: calc(~'100% - 53px')
}
.filter-tree {
height: calc(~'100% - 50px')
}
}
</style>
File diff suppressed because it is too large Load Diff