工作组架构
This commit is contained in:
@@ -0,0 +1,352 @@
|
||||
<template>
|
||||
<div class="roleTree">
|
||||
<el-drawer
|
||||
:title="isTitle"
|
||||
:visible.sync="isVisible2"
|
||||
:wrapperClosable="false"
|
||||
@close="handleTreeDrawerCancel"
|
||||
size="400px">
|
||||
<el-form
|
||||
ref="attributeEO"
|
||||
class="label-input-form"
|
||||
:inline="true"
|
||||
@submit.native.prevent
|
||||
>
|
||||
<el-form-item class="form-item-disabled" style="margin: 10px;">
|
||||
<el-input
|
||||
v-model="filterText"
|
||||
placeholder="请输入姓名"
|
||||
@input="changeInput"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-tree
|
||||
v-if="open1 && isVisible2"
|
||||
node-key="id"
|
||||
style="height: 100%; overflow: auto;"
|
||||
class="filter-tree tree-line"
|
||||
icon-class="icon-tree"
|
||||
@check-change="checkChange"
|
||||
:data="treeData"
|
||||
:props="defaultProps"
|
||||
:default-checked-keys="nodeList"
|
||||
highlight-current
|
||||
check-strictly
|
||||
@check="drawerCheck"
|
||||
:expand-on-click-node="true"
|
||||
show-checkbox
|
||||
ref="tree"
|
||||
:load="loadNode"
|
||||
lazy>
|
||||
<span class="custom-tree-node" slot-scope="{ node, data }">
|
||||
<span :class="node.disabled ? 'is-show' : 'is-leaf-none'"></span>
|
||||
<span> {{ node.label }} </span>
|
||||
</span>
|
||||
</el-tree>
|
||||
<el-tree
|
||||
v-if="!open1 && isVisible2"
|
||||
node-key="id"
|
||||
style="height: 100%; overflow: auto;"
|
||||
class="filter-tree tree-line"
|
||||
icon-class="icon-tree"
|
||||
:data="treeData1"
|
||||
:props="defaultProps"
|
||||
@check-change="checkChange2"
|
||||
:default-checked-keys="nodeList"
|
||||
highlight-current
|
||||
check-strictly
|
||||
@check="drawerCheck"
|
||||
:expand-on-click-node="true"
|
||||
default-expand-all
|
||||
show-checkbox
|
||||
ref="tree">
|
||||
<span class="custom-tree-node" slot-scope="{ node, data }">
|
||||
<span :class="node.disabled ? 'is-show' : 'is-leaf-none'"></span>
|
||||
<span> {{ node.label }} </span>
|
||||
</span>
|
||||
</el-tree>
|
||||
<div id="roleFormButton" class="demo-drawer-footer">
|
||||
<el-button class="common-button-primary" size="mini" icon="el-icon-check" type="primary" @click="saveUserInfo">确定</el-button>
|
||||
|
||||
<el-button class="common-button-default" size="mini" icon="el-icon-close" @click="handleTreeDrawerCancel">取消</el-button>
|
||||
</div>
|
||||
<loading style="z-index: 2099;" :loading="treeLoading">导入中...</loading>
|
||||
</el-drawer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
function debounce(func, wait = 500){
|
||||
let timeout;
|
||||
return function(event){
|
||||
clearTimeout(timeout)
|
||||
timeout = setTimeout(()=>{
|
||||
func.call(this, event)
|
||||
},wait)
|
||||
}
|
||||
}
|
||||
export default {
|
||||
name: "workTree",
|
||||
props: {
|
||||
checkBox: { // 单选/多选
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
isTitle: { // 标题
|
||||
type: String
|
||||
},
|
||||
isVisible: { // drawer开关
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
nodeList: { // 回显
|
||||
type: Array,
|
||||
default: () => {
|
||||
return []
|
||||
}
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
roleList: [],
|
||||
isVisible2: false,
|
||||
filterText: '',
|
||||
defaultProps: {
|
||||
children: 'children',
|
||||
label: 'name',
|
||||
isLeaf: (data, node) => {
|
||||
if (!node.disabled) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
},
|
||||
treeData1: [],
|
||||
treeData: [],
|
||||
open1: true,
|
||||
treeLoading: false,
|
||||
roleRow: {}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
changeInput:debounce(function (val) {
|
||||
if (val.length) {
|
||||
this.open1 = false
|
||||
this.treeLoading = true
|
||||
this.$http.get('SarInstitution/institution/institutionAndUser', {
|
||||
userName: val
|
||||
}, {}, res => {
|
||||
this.treeData1 = res.data
|
||||
this.treeLoading = false
|
||||
})
|
||||
} else {
|
||||
this.open1 = true
|
||||
}
|
||||
}),
|
||||
checkChange2 (row, type, c) {
|
||||
if (this.checkBox) {
|
||||
} else {
|
||||
if (type) {
|
||||
this.nodeList.push(row.id)
|
||||
} else {
|
||||
for (let a = 0; a < this.nodeList.length; a ++) {
|
||||
if (row.id === this.nodeList[a]) {
|
||||
this.nodeList.splice(a, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
checkChange (row, type, c) {
|
||||
if (this.checkBox) {
|
||||
} else {
|
||||
if (type) {
|
||||
this.nodeList.push(row.id)
|
||||
} else {
|
||||
for (let a = 0; a < this.nodeList.length; a ++) {
|
||||
if (row.id === this.nodeList[a]) {
|
||||
this.nodeList.splice(a, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
handleTreeDrawerCancel () {
|
||||
this.filterText = ''
|
||||
this.isVisible2 = false
|
||||
this.open1 = true
|
||||
},
|
||||
saveUserInfo () {
|
||||
if (this.checkBox) {
|
||||
this.isVisible2 = false
|
||||
this.$emit('checkedRole', this.roleList)
|
||||
} else {
|
||||
if (this.nodeList.length > 0 && this.nodeList[0].length !== 0) {
|
||||
let ids = ''
|
||||
this.nodeList.forEach(item => {
|
||||
if (ids.length > 0) {
|
||||
ids += ','
|
||||
ids += item
|
||||
} else {
|
||||
ids = item
|
||||
}
|
||||
})
|
||||
this.$http.get('SarInstitution/institution/getNextById', {
|
||||
ids: ids
|
||||
}, {
|
||||
_this: this
|
||||
}, res => {
|
||||
this.isVisible2 = false
|
||||
this.$emit('checkedRole', res)
|
||||
})
|
||||
} else {
|
||||
this.isVisible2 = false
|
||||
this.$emit('checkedRole', this.roleList)
|
||||
}
|
||||
}
|
||||
this.open1 = true
|
||||
},
|
||||
drawerCheck (data) {
|
||||
if (this.checkBox) { // 单选
|
||||
// 单选判断
|
||||
let getlist = this.$refs.tree.getCheckedNodes()
|
||||
if (getlist.length > 1) {
|
||||
this.$refs.tree.setCheckedKeys([])
|
||||
this.$refs.tree.setCheckedKeys([data.id])
|
||||
this.roleList = [data]
|
||||
} else if (getlist.length === 0) {
|
||||
this.roleList = [{}]
|
||||
} else if (getlist.length === 1) {
|
||||
this.roleList = [data]
|
||||
}
|
||||
// var getlist = this.$refs.tree.getCheckedNodes().concat(this.$refs.tree.getHalfCheckedNodes());
|
||||
// if(getlist.length == 1) {
|
||||
// this.roleRow = getlist[0]
|
||||
// } else {
|
||||
// this.$refs.tree.setCheckedKeys([data.id])
|
||||
// this.roleRow = this.$refs.tree.getCheckedNodes()[0]
|
||||
// }
|
||||
// this.roleList = [this.roleRow]
|
||||
} else { // 多选
|
||||
this.roleList = this.$refs.tree.getCheckedNodes().concat(this.$refs.tree.getHalfCheckedNodes())
|
||||
}
|
||||
},
|
||||
loadNode(node, resolve) {
|
||||
if (node.level === 0) {
|
||||
return resolve(this.treeData);
|
||||
}
|
||||
this.getChildren(node, resolve)
|
||||
},
|
||||
getChildren (node, resolve) {
|
||||
this.$http.get('SarInstitution/institution/getNext', {
|
||||
institutionId: node.key,
|
||||
userName: this.filterText
|
||||
}, {}, res => {
|
||||
resolve(res)
|
||||
})
|
||||
},
|
||||
getTree () {
|
||||
this.treeLoading = true
|
||||
this.$http.get('SarInstitution/institution/getFirstInstitution', {}, {}, res=> {
|
||||
this.treeData = res
|
||||
this.treeLoading = false
|
||||
})
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
isVisible (val) {
|
||||
this.isVisible2 = val
|
||||
},
|
||||
isVisible2 (val) {
|
||||
this.$emit('update:isVisible', val)
|
||||
},
|
||||
},
|
||||
mounted () {
|
||||
this.getTree()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
/deep/ .icon-tree {
|
||||
margin: 0 5px 0 10px;
|
||||
position: relative;
|
||||
background: url('~@/assets/images/shangqi/img/tree-add.png');
|
||||
background-size: 100% 100%;
|
||||
}
|
||||
/deep/.el-tree-node__content {
|
||||
padding-left: 0px !important;
|
||||
}
|
||||
/deep/ .is-leaf{
|
||||
background-image:none;
|
||||
background-size:100% 100%;
|
||||
}
|
||||
/deep/ .is-leaf-none{
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
background:url('~@/assets/images/shangqi/img/personnel.png');
|
||||
background-size:100% 100%;
|
||||
}
|
||||
/deep/ .is-show{
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
background:url('~@/assets/images/shangqi/img/mechanism.png');
|
||||
background-size:100% 100%;
|
||||
}
|
||||
/deep/.tree-line{
|
||||
.el-tree-node {
|
||||
position: relative;
|
||||
padding-left: 0px; // 缩进量
|
||||
line-height: 30px;
|
||||
}
|
||||
.el-tree-node__children {
|
||||
padding-left: 16px; // 缩进量
|
||||
}
|
||||
// 竖线
|
||||
.el-tree-node::before {
|
||||
content: "";
|
||||
height: 100%;
|
||||
width: 1px;
|
||||
position: absolute;
|
||||
left: -3px;
|
||||
top: -26px;
|
||||
border-width: 1px;
|
||||
border-left: 1px dashed #858990e0;
|
||||
}
|
||||
// 当前层最后一个节点的竖线高度固定
|
||||
.el-tree-node:last-child::before {
|
||||
height: 38px; // 可以自己调节到合适数值
|
||||
}
|
||||
// 横线
|
||||
.el-tree-node::after {
|
||||
content: "";
|
||||
width: 11px;
|
||||
height: 20px;
|
||||
position: absolute;
|
||||
left: -3px;
|
||||
top: 12px;
|
||||
border-width: 1px;
|
||||
border-top: 1px dashed #858990e0;
|
||||
}
|
||||
// 去掉最顶层的虚线,放最下面样式才不会被上面的覆盖了
|
||||
& > .el-tree-node::after {
|
||||
border-top: none;
|
||||
}
|
||||
& > .el-tree-node::before {
|
||||
border-left: none;
|
||||
}
|
||||
// 展开关闭的icon
|
||||
.el-tree-node__expand-icon{
|
||||
font-size: 16px;
|
||||
// 叶子节点(无子节点)
|
||||
&.is-leaf{
|
||||
color: transparent;
|
||||
// display: none; // 也可以去掉
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user