Commit f2aae68e by 怪兽?别跑

组织架构搜索调整

1 parent 7c47ae09
<script> <script>
import { getDeptTree, getDeptUser } from '@/api/organization' import { getDeptTree, getDeptUser } from '@/api/organization'
export default { export default {
name: 'SelectUser', name: 'SelectUser',
components: {}, components: {},
props: { props: {
isWechat: { isWechat: {
type: Boolean, type: Boolean,
default: true, default: true
}, },
// 添加标签显隐 // 添加标签显隐
visible: { visible: {
type: Boolean, type: Boolean,
default: false, default: false
}, },
title: { title: {
type: String, type: String,
default: '组织架构', default: '组织架构'
}, },
// 是否 只选择叶子节点(人员节点)/禁止选择父节点(部门节点) // 是否 只选择叶子节点(人员节点)/禁止选择父节点(部门节点)
isOnlyLeaf: { isOnlyLeaf: {
type: Boolean, type: Boolean,
default: true, default: true
}, },
// 是否单选 // 是否单选
isSigleSelect: { isSigleSelect: {
type: Boolean, type: Boolean,
default: false, default: false
}, },
// 默认选中的节点 // 默认选中的节点
defaultValues: { defaultValues: {
...@@ -34,19 +34,19 @@ export default { ...@@ -34,19 +34,19 @@ export default {
// 必须含有userId和name属性 // 必须含有userId和name属性
validator(val) { validator(val) {
return val.every((e) => e.userId && e.name) return val.every((e) => e.userId && e.name)
}, }
}, },
// 禁止选中的节点 // 禁止选中的节点
disabledValues: { disabledValues: {
type: Array, type: Array,
default: () => [], default: () => []
}, },
destroyOnClose: Boolean, destroyOnClose: Boolean,
// 选中部门时,是否用部门代替显示该部门下所有人员 // 选中部门时,是否用部门代替显示该部门下所有人员
departReplaceUser: { departReplaceUser: {
type: Boolean, type: Boolean,
default: false, default: false
}, }
}, },
data() { data() {
return { return {
...@@ -57,7 +57,7 @@ export default { ...@@ -57,7 +57,7 @@ export default {
keywords: '', keywords: '',
searchResult: [], searchResult: [],
searchState: false, searchState: false,
checked: [], checked: []
} }
}, },
watch: { watch: {
...@@ -77,7 +77,7 @@ export default { ...@@ -77,7 +77,7 @@ export default {
} }
}, },
immediate: true, immediate: true,
deep: true, deep: true
}, },
Pvisible(val) { Pvisible(val) {
val && this.$refs.tree && this.$refs.tree.setCheckedKeys(this.defaultValues.map((e) => e.userId || e.id)) val && this.$refs.tree && this.$refs.tree.setCheckedKeys(this.defaultValues.map((e) => e.userId || e.id))
...@@ -86,7 +86,7 @@ export default { ...@@ -86,7 +86,7 @@ export default {
this.$refs.tree && this.$refs.tree.setCheckedKeys(this.defaultValues.map((e) => e.userId || e.id)) this.$refs.tree && this.$refs.tree.setCheckedKeys(this.defaultValues.map((e) => e.userId || e.id))
}, 300) }, 300)
} }
}, }
}, },
computed: { computed: {
Pvisible: { Pvisible: {
...@@ -95,7 +95,7 @@ export default { ...@@ -95,7 +95,7 @@ export default {
}, },
set(val) { set(val) {
this.$emit('update:visible', val) this.$emit('update:visible', val)
}, }
}, },
defaultProps() { defaultProps() {
let that = this let that = this
...@@ -107,7 +107,7 @@ export default { ...@@ -107,7 +107,7 @@ export default {
}, },
isLeaf(data, node) { isLeaf(data, node) {
return !data.id return !data.id
}, }
} }
}, },
dealedUserList() { dealedUserList() {
...@@ -122,7 +122,7 @@ export default { ...@@ -122,7 +122,7 @@ export default {
arr = arr.filter((e) => !arr.some((e2) => e.parentId == e2.id)) arr = arr.filter((e) => !arr.some((e2) => e.parentId == e2.id))
arr.push(...userList) arr.push(...userList)
return arr return arr
}, }
}, },
created() {}, created() {},
mounted() {}, mounted() {},
...@@ -141,8 +141,8 @@ export default { ...@@ -141,8 +141,8 @@ export default {
return dd.userId return dd.userId
}) })
getDeptUser({ getDeptUser({
deptId: this.deptId, // deptId: this.deptId,
userName: this.keywords, userName: this.keywords
}).then((res) => { }).then((res) => {
this.searchResult = this.handleUser(res.rows) this.searchResult = this.handleUser(res.rows)
}) })
...@@ -278,9 +278,9 @@ export default { ...@@ -278,9 +278,9 @@ export default {
index > -1 && this.userList.splice(index, 1) index > -1 && this.userList.splice(index, 1)
let order = this.defaultValues.findIndex((i) => i.userId === key) let order = this.defaultValues.findIndex((i) => i.userId === key)
order > -1 && this.defaultValues.slice().splice(order, 1) order > -1 && this.defaultValues.slice().splice(order, 1)
}, }
}, }
} }
</script> </script>
<template> <template>
<el-dialog <el-dialog
...@@ -288,7 +288,8 @@ export default { ...@@ -288,7 +288,8 @@ export default {
:title="title" :title="title"
v-model="Pvisible" v-model="Pvisible"
:close-on-click-modal="false" :close-on-click-modal="false"
:destroy-on-close="destroyOnClose"> :destroy-on-close="destroyOnClose"
>
<div class="content"> <div class="content">
<div class="left"> <div class="left">
<div class="search-input"> <div class="search-input">
...@@ -297,7 +298,8 @@ export default { ...@@ -297,7 +298,8 @@ export default {
@keyup.enter="setSearch" @keyup.enter="setSearch"
placeholder="请输入员工名称" placeholder="请输入员工名称"
clearable clearable
@change="setChange"> @change="setChange"
>
<template #append><el-button icon="el-icon-search" @click="setSearch"></el-button></template> <template #append><el-button icon="el-icon-search" @click="setSearch"></el-button></template>
</el-input> </el-input>
</div> </div>
...@@ -324,7 +326,8 @@ export default { ...@@ -324,7 +326,8 @@ export default {
:load="loadNode" :load="loadNode"
:props="defaultProps" :props="defaultProps"
:check-strictly="isOnlyLeaf" :check-strictly="isOnlyLeaf"
@check-change="handleCheckChange"></el-tree> @check-change="handleCheckChange"
></el-tree>
</div> </div>
</transition> </transition>
</div> </div>
...@@ -345,42 +348,42 @@ export default { ...@@ -345,42 +348,42 @@ export default {
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
.content { .content {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
} }
.left, .left,
.right { .right {
width: 49%; width: 49%;
max-height: calc(100vh - 170px); max-height: calc(100vh - 170px);
overflow: auto; overflow: auto;
} }
.search-input { .search-input {
margin-top: 5px; margin-top: 5px;
margin-bottom: 10px; margin-bottom: 10px;
} }
.user-list { .user-list {
line-height: 26px; line-height: 26px;
padding-right: 10px; padding-right: 10px;
.user-name { .user-name {
margin: 0 5px; margin: 0 5px;
flex: auto; flex: auto;
} }
} }
.search-list { .search-list {
line-height: 26px; line-height: 26px;
padding: 0 10px; padding: 0 10px;
} }
.fade-enter-active { .fade-enter-active {
transition: opacity 0.5s; transition: opacity 0.5s;
} }
.fade-enter { .fade-enter {
opacity: 0; opacity: 0;
} }
.fade-leave-active { .fade-leave-active {
transition: opacity 0.5s; transition: opacity 0.5s;
} }
.fade-leave-to { .fade-leave-to {
opacity: 0; opacity: 0;
} }
</style> </style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!