Commit 593dbda9 by xinla

扩展SelectWeUser

1 parent fda702be
<script>
import { getDeptTree, getDeptUser } from '@/api/organization'
export default {
import { getDeptTree, getDeptUser } from '@/api/organization'
export default {
name: 'SelectWeUser',
components: {},
props: {
// 添加标签显隐
visible: {
type: Boolean,
default: false
default: false,
},
title: {
type: String,
default: '组织架构'
default: '组织架构',
},
// 是否 只选择叶子节点(人员节点)/禁止选择父节点(部门节点)
isOnlyLeaf: {
type: Boolean,
default: true
default: true,
},
// 是否单选
isSigleSelect: {
type: Boolean,
default: false
default: false,
},
// 默认选中的节点
defaultValues: {
......@@ -30,14 +30,14 @@
// 必须含有userId和name属性
validator(val) {
return val.every((e) => e.userId && e.name)
}
},
},
// 禁止选中的节点
disabledValues: {
type: Array,
default: () => []
default: () => [],
},
destroyOnClose: Boolean
destroyOnClose: Boolean,
},
data() {
return {
......@@ -48,7 +48,7 @@
keywords: '',
searchResult: [],
searchState: false,
checked: []
checked: [],
}
},
watch: {
......@@ -67,7 +67,7 @@
this.userList = checkedUserList
}
},
immediate: true
immediate: true,
},
Pvisible(val) {
val && this.$refs.tree && this.$refs.tree.setCheckedKeys(this.defaultValues.map((e) => e.userId || e.id))
......@@ -76,7 +76,7 @@
this.$refs.tree && this.$refs.tree.setCheckedKeys(this.defaultValues.map((e) => e.userId || e.id))
}, 300)
}
}
},
},
computed: {
Pvisible: {
......@@ -85,7 +85,7 @@
},
set(val) {
this.$emit('update:visible', val)
}
},
},
defaultProps() {
let that = this
......@@ -97,9 +97,9 @@
},
isLeaf(data, node) {
return !data.id
},
}
}
}
},
},
created() {},
mounted() {},
......@@ -119,7 +119,7 @@
})
getDeptUser({
deptId: this.deptId,
userName: this.keywords
userName: this.keywords,
}).then((res) => {
this.searchResult = this.handleName(res.rows)
})
......@@ -247,12 +247,17 @@
index > -1 && this.userList.splice(index, 1)
let order = this.defaultValues.findIndex((i) => i.userId === key)
order > -1 && this.defaultValues.slice().splice(order, 1)
}
}
}
},
},
}
</script>
<template>
<el-dialog :title="title" :visible.sync="Pvisible" :close-on-click-modal="false" :destroy-on-close="destroyOnClose">
<el-dialog
v-bind="$attrs"
:title="title"
:visible.sync="Pvisible"
:close-on-click-modal="false"
:destroy-on-close="destroyOnClose">
<el-row :gutter="20" class="content">
<el-col :span="12" :xs="24">
<div class="search-input">
......@@ -262,8 +267,7 @@
@keyup.enter.native="setSearch"
placeholder="请输入员工名称"
clearable
@change="setChange"
>
@change="setChange">
<el-button slot="append" icon="el-icon-search" @click="setSearch"></el-button>
</el-input>
</div>
......@@ -291,8 +295,7 @@
:load="loadNode"
:props="defaultProps"
:check-strictly="isOnlyLeaf"
@check-change="handleCheckChange"
></el-tree>
@check-change="handleCheckChange"></el-tree>
</div>
</transition>
</el-col>
......@@ -313,32 +316,32 @@
</template>
<style lang="scss" scoped>
.content {
.content {
min-height: 400px;
}
.search-input {
}
.search-input {
margin-top: 5px;
margin-bottom: 10px;
}
.user-list {
}
.user-list {
.el-row {
line-height: 26px;
}
}
.search-list {
}
.search-list {
margin-top: 20px;
padding: 0 10px;
}
.fade-enter-active {
}
.fade-enter-active {
transition: opacity 0.5s;
}
.fade-enter {
}
.fade-enter {
opacity: 0;
}
.fade-leave-active {
}
.fade-leave-active {
transition: opacity 0.5s;
}
.fade-leave-to {
}
.fade-leave-to {
opacity: 0;
}
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!