Commit dfe1dff2 by ext.wangyuman1

Merge branch 'vue3-master' of https://e.coding.net/linkwechat/linkwechat-front/l…

…inkwechat into bs-dev-wangyuman
2 parents 289ac247 0591b55d
......@@ -59,7 +59,7 @@
#loader-wrapper .loader-section {
position: absolute;
top: 0;
width: 51%;
width: 50%;
height: 100%;
background: #07c160;
z-index: 1000;
......@@ -76,24 +76,24 @@
.loaded#loader-wrapper .loader-section.section-left {
transform: translateX(-100%);
transition: all 0.7s 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
transition: all 0.35s 0.15s cubic-bezier(0.645, 0.045, 0.355, 1);
}
.loaded#loader-wrapper .loader-section.section-right {
transform: translateX(100%);
transition: all 0.7s 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
transition: all 0.35s 0.15s cubic-bezier(0.645, 0.045, 0.355, 1);
}
.loaded#loader-wrapper #loader,
.loaded#loader-wrapper .load-title {
opacity: 0;
transition: all 0.3s ease-out;
transition: all 0.15s ease-out;
}
.loaded#loader-wrapper {
visibility: hidden;
transform: translateY(-100%);
transition: all 0.3s 1s ease-out;
transition: all 0.15s 0.5s ease-out;
}
#loader-wrapper .load-title {
......
:root {
--hsl: 149, 93%, 39%; /* 主题色hsl*/
--hsl-dark: 149, 93%, 34%; /* 深主题色hsl*/
/* 主题色hsl*/
--h: 149;
--s: 93%;
--l: 39%;
--l-dark: calc(var(--l) - 5%); /* 深主题色 l */
--hsl: var(--h), var(--s), var(--l); /* 主题色hsl*/
--hsl-dark: var(--h), var(--s), var(--l-dark); /* 深主题色hsl*/
--color: hsl(var(--hsl)); /* 主题色 hsl(149, 93%, 39%)*/
--color-dark: hsl(var(--hsl-dark)); /* 深主题色 */
--color-light: hsl(var(--hsl), 0.12); /* 浅主题色 */
--color-dark: hsl(var(--hsl-dark)); /* 深主题色 hsl(149, 93%, 34%) */
--color-sub: hsl(91, 70%, 57%); /* 主题辅色 */
/* 浅主题色 递浅系列阶梯 */
--color-light: hsl(var(--hsl), 0.12);
--color-light-3: hsl(var(--hsl), 0.7);
--color-light-5: hsl(var(--hsl), 0.5);
--color-light-7: hsl(var(--hsl), 0.3);
--color-light-8: hsl(var(--hsl), 0.2);
--color-light-9: hsl(var(--hsl), 0.1);
/* 功能色 */
--color-success: #07c160;
--color-warning: #faad14;
--color-danger: #eb5e12;
......@@ -18,6 +32,16 @@
--top-nav-heght: 64px; /* 顶部导航条高度 */
--font-black: #1d2129; /* 通用字体黑色 */
--black-: #000;
--black-d2: rgba(0, 0, 0, 0.2); /* 黑色 #ddd*/
--black-d3: rgba(0, 0, 0, 0.3); /* 黑色 #ccc*/
--black-d4: rgba(0, 0, 0, 0.4); /* 黑色 #aaa*/
--black-d5: rgba(0, 0, 0, 0.5); /* 黑色 */
--black-d6: rgba(0, 0, 0, 0.6); /* 黑色 */
--black-d7: rgba(0, 0, 0, 0.7); /* 黑色 */
--black-d8: rgba(0, 0, 0, 0.8); /* 黑色 */
--black-d9: rgba(0, 0, 0, 0.9); /* 黑色 */
--font-white: #fff; /* 通用字体白色 */
/* 背景色,暗黑模式下为黑色 */
......
<script>
import { getDeptTree, getDeptUser } from '@/api/organization'
export default {
name: 'SelectUser',
components: {},
props: {
isWechat: {
type: Boolean,
default: true,
},
// 添加标签显隐
visible: {
type: Boolean,
default: false,
},
title: {
type: String,
default: '组织架构',
},
// 是否 只选择叶子节点(人员节点)/禁止选择父节点(部门节点)
isOnlyLeaf: {
type: Boolean,
default: true,
},
// 是否单选
isSigleSelect: {
type: Boolean,
default: false,
},
// 默认选中的节点
defaultValues: {
type: Array,
default: () => [],
// 必须含有userId和name属性
validator(val) {
return val.every((e) => e.userId && e.name)
import { getDeptTree, getDeptUser } from '@/api/organization'
export default {
name: 'SelectUser',
components: {},
props: {
isWechat: {
type: Boolean,
default: true
},
},
// 禁止选中的节点
disabledValues: {
type: Array,
default: () => [],
},
destroyOnClose: Boolean,
// 选中部门时,是否用部门代替显示该部门下所有人员
departReplaceUser: {
type: Boolean,
default: false,
},
},
data() {
return {
treeData: [],
userList: [],
defaultKeys: [],
deptId: '', //根部门Id
keywords: '',
searchResult: [],
searchState: false,
checked: [],
}
},
watch: {
defaultValues: {
handler(value) {
const checkedUserList = []
if (!Array.isArray(value) || value.length == 0) {
this.userList = []
} else {
value.forEach((i) => {
const id = i.userId || i.id
if (id) {
checkedUserList.push(i)
}
})
this.userList = checkedUserList
}
// 添加标签显隐
visible: {
type: Boolean,
default: false
},
immediate: true,
deep: true,
},
Pvisible(val) {
val && this.$refs.tree && this.$refs.tree.setCheckedKeys(this.defaultValues.map((e) => e.userId || e.id))
if (!this.$refs.tree) {
setTimeout(() => {
this.$refs.tree && this.$refs.tree.setCheckedKeys(this.defaultValues.map((e) => e.userId || e.id))
}, 300)
}
},
},
computed: {
Pvisible: {
get() {
return this.visible
title: {
type: String,
default: '组织架构'
},
// 是否 只选择叶子节点(人员节点)/禁止选择父节点(部门节点)
isOnlyLeaf: {
type: Boolean,
default: true
},
// 是否单选
isSigleSelect: {
type: Boolean,
default: false
},
set(val) {
this.$emit('update:visible', val)
// 默认选中的节点
defaultValues: {
type: Array,
default: () => [],
// 必须含有userId和name属性
validator(val) {
return val.every((e) => e.userId && e.name)
}
},
// 禁止选中的节点
disabledValues: {
type: Array,
default: () => []
},
destroyOnClose: Boolean,
// 选中部门时,是否用部门代替显示该部门下所有人员
departReplaceUser: {
type: Boolean,
default: false
}
},
defaultProps() {
let that = this
data() {
return {
label: 'name',
children: 'children',
disabled(data, node) {
return (that.isOnlyLeaf && data.isParty) || that.disabledValues.some((e) => e == (data.userId || data.id))
},
isLeaf(data, node) {
return !data.id
},
treeData: [],
userList: [],
defaultKeys: [],
deptId: '', //根部门Id
keywords: '',
searchResult: [],
searchState: false,
checked: []
}
},
dealedUserList() {
if (!this.departReplaceUser) {
return this.userList
watch: {
defaultValues: {
handler(value) {
const checkedUserList = []
if (!Array.isArray(value) || value.length == 0) {
this.userList = []
} else {
value.forEach((i) => {
const id = i.userId || i.id
if (id) {
checkedUserList.push(i)
}
})
this.userList = checkedUserList
}
},
immediate: true,
deep: true
},
Pvisible(val) {
val && this.$refs.tree && this.$refs.tree.setCheckedKeys(this.defaultValues.map((e) => e.userId || e.id))
if (!this.$refs.tree) {
setTimeout(() => {
this.$refs.tree && this.$refs.tree.setCheckedKeys(this.defaultValues.map((e) => e.userId || e.id))
}, 300)
}
}
// 提取所有部门
let arr = this.userList.filter((e) => e.isParty)
// 提取所有非选中部门的人员
let userList = this.userList.filter((e) => !e.isParty && !arr.some((e2) => e.userDepts[0]?.deptId == e2.deptId))
// 提取无父级部门
arr = arr.filter((e) => !arr.some((e2) => e.parentId == e2.id))
arr.push(...userList)
return arr
},
},
created() {},
mounted() {},
methods: {
setChange(e) {
if (!e) {
this.searchState = false
this.$refs.tree.setCheckedKeys(this.userList.map((e) => e.userId || e.id))
computed: {
Pvisible: {
get() {
return this.visible
},
set(val) {
this.$emit('update:visible', val)
}
},
defaultProps() {
let that = this
return {
label: 'name',
children: 'children',
disabled(data, node) {
return (that.isOnlyLeaf && data.isParty) || that.disabledValues.some((e) => e == (data.userId || data.id))
},
isLeaf(data, node) {
return !data.id
}
}
},
dealedUserList() {
if (!this.departReplaceUser) {
return this.userList
}
// 提取所有部门
let arr = this.userList.filter((e) => e.isParty)
// 提取所有非选中部门的人员
let userList = this.userList.filter((e) => !e.isParty && !arr.some((e2) => e.userDepts[0]?.deptId == e2.deptId))
// 提取无父级部门
arr = arr.filter((e) => !arr.some((e2) => e.parentId == e2.id))
arr.push(...userList)
return arr
}
},
setSearch() {
if (!this.keywords) return
this.searchResult = []
this.searchState = true
this.checked = this.userList.map((dd) => {
return dd.userId
})
getDeptUser({
deptId: this.deptId,
userName: this.keywords,
}).then((res) => {
this.searchResult = this.handleUser(res.rows)
})
},
setSelectChange(e, index) {
if (e) {
if (this.isSigleSelect) {
this.userList[0] = this.searchResult[index]
} else {
this.userList.push(this.searchResult[index])
created() {},
mounted() {},
methods: {
setChange(e) {
if (!e) {
this.searchState = false
this.$refs.tree.setCheckedKeys(this.userList.map((e) => e.userId || e.id))
}
},
setSearch() {
if (!this.keywords) return
this.searchResult = []
this.searchState = true
this.checked = this.userList.map((dd) => {
return dd.userId
})
// this.$forceUpdate()
} else {
this.cancle(this.searchResult[index].userId)
}
// setTimeout(() => {
// this.keywords = ''
// this.setChange()
// }, 500)
},
treeFormat(list) {
let dealOptions = []
list.forEach((one) => {
let findIndex = list.findIndex((item) => {
return item.id === one.parentId
getDeptUser({
// deptId: this.deptId,
userName: this.keywords
}).then((res) => {
this.searchResult = this.handleUser(res.rows)
})
if ((!one.parentId && one.parentId !== 0 && one.parentId !== false) || findIndex === -1) {
dealOptions.push(one)
} else {
if (!list[findIndex].children) {
list[findIndex].children = []
list[findIndex].children.push(one)
},
setSelectChange(e, index) {
if (e) {
if (this.isSigleSelect) {
this.userList[0] = this.searchResult[index]
} else {
list[findIndex].children.push(one)
this.userList.push(this.searchResult[index])
}
this.checked = this.userList.map((dd) => {
return dd.userId
})
// this.$forceUpdate()
} else {
this.cancle(this.searchResult[index].userId)
}
})
return dealOptions
},
loadNode(node, resolve) {
if (node.level === 0) {
if (!Array.isArray(this.defaultValues) || this.defaultValues.length == 0) {
this.userList = []
// setTimeout(() => {
// this.keywords = ''
// this.setChange()
// }, 500)
},
treeFormat(list) {
let dealOptions = []
list.forEach((one) => {
let findIndex = list.findIndex((item) => {
return item.id === one.parentId
})
if ((!one.parentId && one.parentId !== 0 && one.parentId !== false) || findIndex === -1) {
dealOptions.push(one)
} else {
if (!list[findIndex].children) {
list[findIndex].children = []
list[findIndex].children.push(one)
} else {
list[findIndex].children.push(one)
}
}
})
return dealOptions
},
loadNode(node, resolve) {
if (node.level === 0) {
if (!Array.isArray(this.defaultValues) || this.defaultValues.length == 0) {
this.userList = []
}
getDeptTree().then(({ data }) => {
let _data = this.handleDepart(data)
let value = this.treeFormat(_data)
if (value.length) {
this.deptId = value[0].deptId
}
resolve(value)
})
} else {
getDeptUser({ deptId: node.data.id }).then(({ rows }) => {
let arr = this.handleUser(rows)
node.data.children && arr.push(...node.data.children)
// 懒加载选中状态的子节点不会触发子节点的选中事件,需要手动触发
if (node.checked) {
setTimeout(() => {
arr.forEach((e) => {
this.handleCheckChange(e, true)
})
}, 200)
}
resolve(arr)
})
}
getDeptTree().then(({ data }) => {
let _data = this.handleDepart(data)
let value = this.treeFormat(_data)
if (value.length) {
this.deptId = value[0].deptId
},
handleDepart(data) {
return data.map((i) => {
if (i.deptId) {
i.userId = i.deptId
i.name = i.deptName
i.id = i.deptId
i.isParty = true
}
resolve(value)
return i
})
} else {
getDeptUser({ deptId: node.data.id }).then(({ rows }) => {
let arr = this.handleUser(rows)
node.data.children && arr.push(...node.data.children)
// 懒加载选中状态的子节点不会触发子节点的选中事件,需要手动触发
if (node.checked) {
setTimeout(() => {
arr.forEach((e) => {
this.handleCheckChange(e, true)
})
}, 200)
},
handleUser(data) {
return data.map((i) => {
if (i.userName) {
i.userId = this.isWechat ? i.weUserId : i.userId
i.name = i.userName
}
resolve(arr)
return i
})
}
},
handleDepart(data) {
return data.map((i) => {
if (i.deptId) {
i.userId = i.deptId
i.name = i.deptName
i.id = i.deptId
i.isParty = true
}
return i
})
},
handleUser(data) {
return data.map((i) => {
if (i.userName) {
i.userId = this.isWechat ? i.weUserId : i.userId
i.name = i.userName
}
return i
})
},
// 选择变化
handleCheckChange(data, checked, indeterminate) {
if (checked) {
if (this.isSigleSelect) {
// 单选情况
this.$refs.tree.setCheckedKeys([data.userId])
}
if (this.isOnlyLeaf) {
if (data.userId && !data.isParty) {
this.userList.push(data)
},
// 选择变化
handleCheckChange(data, checked, indeterminate) {
if (checked) {
if (this.isSigleSelect) {
// 单选情况
this.$refs.tree.setCheckedKeys([data.userId])
}
if (this.isOnlyLeaf) {
if (data.userId && !data.isParty) {
this.userList.push(data)
}
} else {
const isExist = this.userList.findIndex((i) => i.userId === data.userId) > -1
!isExist && this.userList.push(data)
}
} else {
const isExist = this.userList.findIndex((i) => i.userId === data.userId) > -1
!isExist && this.userList.push(data)
let index = this.userList.findIndex((i) => i.userId === data.userId)
index > -1 && this.userList.splice(index, 1)
}
} else {
let index = this.userList.findIndex((i) => i.userId === data.userId)
index > -1 && this.userList.splice(index, 1)
}
this.userList = this.unique(this.userList)
},
unique(arr) {
for (var i = 0; i < arr.length; i++) {
for (var j = i + 1; j < arr.length; j++) {
if (arr[i].userId.split('_')[0] == arr[j].userId.split('_')[0]) {
arr.splice(j, 1)
j--
this.userList = this.unique(this.userList)
},
unique(arr) {
for (var i = 0; i < arr.length; i++) {
for (var j = i + 1; j < arr.length; j++) {
if (arr[i].userId.split('_')[0] == arr[j].userId.split('_')[0]) {
arr.splice(j, 1)
j--
}
}
}
return arr
},
// 确 定
submit() {
this.Pvisible = false
this.$emit('success', [...this.dealedUserList])
},
// 取消选择
cancle(key) {
this.$refs.tree.setChecked(key, false)
let index = this.userList.findIndex((i) => i.userId === key)
index > -1 && this.userList.splice(index, 1)
let order = this.defaultValues.findIndex((i) => i.userId === key)
order > -1 && this.defaultValues.slice().splice(order, 1)
}
return arr
},
// 确 定
submit() {
this.Pvisible = false
this.$emit('success', [...this.dealedUserList])
},
// 取消选择
cancle(key) {
this.$refs.tree.setChecked(key, false)
let index = this.userList.findIndex((i) => i.userId === key)
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
......@@ -288,7 +288,8 @@ export default {
:title="title"
v-model="Pvisible"
:close-on-click-modal="false"
:destroy-on-close="destroyOnClose">
:destroy-on-close="destroyOnClose"
>
<div class="content">
<div class="left">
<div class="search-input">
......@@ -297,7 +298,8 @@ export default {
@keyup.enter="setSearch"
placeholder="请输入员工名称"
clearable
@change="setChange">
@change="setChange"
>
<template #append><el-button icon="el-icon-search" @click="setSearch"></el-button></template>
</el-input>
</div>
......@@ -324,7 +326,8 @@ export default {
:load="loadNode"
:props="defaultProps"
:check-strictly="isOnlyLeaf"
@check-change="handleCheckChange"></el-tree>
@check-change="handleCheckChange"
></el-tree>
</div>
</transition>
</div>
......@@ -345,42 +348,42 @@ export default {
</template>
<style lang="scss" scoped>
.content {
display: flex;
justify-content: space-between;
}
.left,
.right {
width: 49%;
max-height: calc(100vh - 170px);
overflow: auto;
}
.search-input {
margin-top: 5px;
margin-bottom: 10px;
}
.user-list {
line-height: 26px;
padding-right: 10px;
.user-name {
margin: 0 5px;
flex: auto;
.content {
display: flex;
justify-content: space-between;
}
.left,
.right {
width: 49%;
max-height: calc(100vh - 170px);
overflow: auto;
}
.search-input {
margin-top: 5px;
margin-bottom: 10px;
}
.user-list {
line-height: 26px;
padding-right: 10px;
.user-name {
margin: 0 5px;
flex: auto;
}
}
.search-list {
line-height: 26px;
padding: 0 10px;
}
.fade-enter-active {
transition: opacity 0.5s;
}
.fade-enter {
opacity: 0;
}
.fade-leave-active {
transition: opacity 0.5s;
}
.fade-leave-to {
opacity: 0;
}
}
.search-list {
line-height: 26px;
padding: 0 10px;
}
.fade-enter-active {
transition: opacity 0.5s;
}
.fade-enter {
opacity: 0;
}
.fade-leave-active {
transition: opacity 0.5s;
}
.fade-leave-to {
opacity: 0;
}
</style>
......@@ -82,11 +82,15 @@ window.lwConfig = Object.assign(config, env, common, lwConfig, project)
// 主题回显
const [h, s, l] = localStorage.hsl?.split(',')?.map((e) => e.trim()) || []
const l1 = l?.slice(0, -1) - 5
// const l1 = l?.slice(0, -1) - 5
if (h) {
const style = document.documentElement.style
style.setProperty('--hsl', localStorage.hsl)
style.setProperty('--hsl-dark', `${h},${s},${l1}%`)
style.setProperty('--h', h)
style.setProperty('--s', s)
style.setProperty('--l', l)
// style.setProperty('--hsl', localStorage.hsl)
// style.setProperty('--hsl-dark', `${h},${s},${l1}%`)
style.setProperty('--color-sub', localStorage.colorSub)
}
......
......@@ -99,10 +99,13 @@ export default {
.slice(4, -1)
.split(',')
.map((e) => e.trim())
let l1 = l.slice(0, -1) - 5 // 主题色明暗度减5%即为深主题色
// let l1 = l.slice(0, -1) - 5 // 主题色明暗度减5%即为深主题色
let style = document.documentElement.style
style.setProperty('--hsl', `${h},${s},${l}`)
l1 && style.setProperty('--hsl-dark', `${h},${s},${l1}%`)
style.setProperty('--h', h)
style.setProperty('--s', s)
style.setProperty('--l', l)
// style.setProperty('--hsl', `${h},${s},${l}`)
// l1 && style.setProperty('--hsl-dark', `${h},${s},${l1}%`)
localStorage.hsl = `${h},${s},${l}`
}
......@@ -118,8 +121,11 @@ export default {
// 恢复默认主题
reset() {
let style = document.documentElement.style
style.removeProperty('--hsl')
style.removeProperty('--hsl-dark')
style.removeProperty('--h')
style.removeProperty('--s')
style.removeProperty('--l')
// style.removeProperty('--hsl')
// style.removeProperty('--hsl-dark')
style.removeProperty('--color-sub')
localStorage.hsl = ''
localStorage.colorSub = ''
......
......@@ -4,15 +4,15 @@
/* element-plus var */
:root,
html.dark {
--el-color-primary: hsl(var(--hsl));
--el-color-primary-light-3: hsl(var(--hsl), 0.7);
--el-color-primary-light-5: hsl(var(--hsl), 0.5);
--el-color-primary-light-7: hsl(var(--hsl), 0.3);
--el-color-primary-light-8: hsl(var(--hsl), 0.2);
--el-color-primary-light-9: hsl(var(--hsl), 0.1);
--el-color-primary: var(--color);
--el-color-primary-light-3: var(--color-light-3);
--el-color-primary-light-5: var(--color-light-5);
--el-color-primary-light-7: var(--color-light-7);
--el-color-primary-light-8: var(--color-light-8);
--el-color-primary-light-9: var(--color-light-9);
--el-color-primary-dark-2: var(--color-dark);
--el-color-success: hsl(var(--hsl));
--el-color-success: var(--color-success);
/* // --el-color-info: #fa7216;
// --el-color-info: #1E1E1E; */
......@@ -25,8 +25,8 @@ html.dark {
/* // --el-color-text-regular: #1f2d3d; */
}
:root {
--el-color-warning: #faad14;
--el-color-danger: #eb5e12;
--el-color-warning: var(--color-warning);
--el-color-danger: var(--color-danger);
--el-border-color-extra-light: #e6f8ef;
--el-border-color-light: #dfe4ed;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!