agilebuilder-ui 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/super-ui.css +1 -1
- package/lib/super-ui.js +46396 -38431
- package/lib/super-ui.umd.cjs +90 -90
- package/package.json +2 -1
- package/packages/department-tree-mobile/index.js +6 -0
- package/packages/department-tree-mobile/src/department-tree-app.vue +120 -0
- package/packages/department-tree-mobile/src/department-tree-inline-app.vue +373 -0
- package/packages/department-tree-mobile/src/department-tree-service.ts +101 -0
- package/packages/department-tree-mobile/src/dept-path.vue +36 -0
- package/packages/department-tree-mobile/src/dept-result.vue +51 -0
- package/packages/department-user-tree-mobile/index.js +6 -0
- package/packages/department-user-tree-mobile/src/department-user-tree-app.vue +119 -0
- package/packages/department-user-tree-mobile/src/department-user-tree-inline-app.vue +397 -0
- package/packages/department-user-tree-mobile/src/department-user-tree-service.ts +75 -0
- package/packages/department-user-tree-mobile/src/dept-path.vue +36 -0
- package/packages/department-user-tree-mobile/src/dept-result.vue +58 -0
- package/packages/index.js +14 -0
- package/packages/super-icon/index.js +6 -0
- package/packages/super-icon/src/index.vue +37 -0
- package/packages/utils/organization.ts +157 -0
- package/src/i18n/langs/cn.js +7 -0
- package/src/i18n/langs/en.js +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agilebuilder-ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "./lib/super-ui.js",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"@tinymce/tinymce-vue": "4.0.4",
|
|
13
13
|
"@zxing/library": "^0.20.0",
|
|
14
14
|
"async-validator": "^4.2.5",
|
|
15
|
+
"font-awesome": "^4.7.0",
|
|
15
16
|
"js-base64": "^3.7.7",
|
|
16
17
|
"js-cookie": "^3.0.5",
|
|
17
18
|
"mitt": "^3.0.1",
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-drawer v-model="isShowForm" direction="btt" size="100%" class="organization-tree">
|
|
3
|
+
<template #header>
|
|
4
|
+
<div style="text-align: center;">
|
|
5
|
+
{{$t('imatrixUIMessage.pleaseSelect')}}
|
|
6
|
+
</div>
|
|
7
|
+
</template>
|
|
8
|
+
<template #default>
|
|
9
|
+
<InlineDepartmentTreeApp v-if="isShowForm" :multiple="multiple" :departmentInfo="departmentInfo" :selectDepartmentInfo="selectDepartmentInfo" :searchField="searchField" :separator="separator" @close="closeTree"/>
|
|
10
|
+
</template>
|
|
11
|
+
</el-drawer>
|
|
12
|
+
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script lang="ts">
|
|
16
|
+
export default {
|
|
17
|
+
name: 'DepartmentTreeMobile'
|
|
18
|
+
}
|
|
19
|
+
</script>
|
|
20
|
+
<script setup lang="ts">
|
|
21
|
+
import InlineDepartmentTreeApp from './department-tree-inline-app.vue'
|
|
22
|
+
import { reactive,ref,onMounted, defineEmits } from 'vue'
|
|
23
|
+
const props = defineProps<{
|
|
24
|
+
// 是否是多选树,默认是true
|
|
25
|
+
multiple: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
default: true,
|
|
28
|
+
},
|
|
29
|
+
// 显示指定部门节点及其子节点,不传该属性,表示显示整个组织结构树
|
|
30
|
+
departmentInfo: {
|
|
31
|
+
type: Array<any>,
|
|
32
|
+
default: null,
|
|
33
|
+
},
|
|
34
|
+
// 多选部门树时,已选择部门id或部门名称或编码集合,多个之间以逗号隔开
|
|
35
|
+
selectDepartmentInfo: {
|
|
36
|
+
type: [String, Number],
|
|
37
|
+
default: null,
|
|
38
|
+
},
|
|
39
|
+
// 移除部门时,部门属性名称:id、name、code,默认是id
|
|
40
|
+
searchField: {
|
|
41
|
+
type: String,
|
|
42
|
+
default: 'id',
|
|
43
|
+
},
|
|
44
|
+
// 多选树时结果之间的分隔符,默认是逗号分隔
|
|
45
|
+
separator: {
|
|
46
|
+
type: String,
|
|
47
|
+
default: ','
|
|
48
|
+
}
|
|
49
|
+
}>()
|
|
50
|
+
const emits = defineEmits(['close'])
|
|
51
|
+
let isShowForm = ref(false)
|
|
52
|
+
function showTree() {
|
|
53
|
+
isShowForm.value = true
|
|
54
|
+
}
|
|
55
|
+
function closeTree(selectNodeInfo) {
|
|
56
|
+
emits('close', selectNodeInfo)
|
|
57
|
+
isShowForm.value = false
|
|
58
|
+
}
|
|
59
|
+
function selectDepartment() {
|
|
60
|
+
// this.$refs.inlineDeparmentTree.selectDepartment()
|
|
61
|
+
}
|
|
62
|
+
defineExpose({showTree})
|
|
63
|
+
</script>
|
|
64
|
+
<style>
|
|
65
|
+
.organization-tree, .organization-tree .el-checkbox__label,.organization-tree .el-breadcrumb__inner,.organization-tree .el-tree {
|
|
66
|
+
font-size: 17px;
|
|
67
|
+
font-weight: 700;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.organization-tree .el-breadcrumb__item:last-child .el-breadcrumb__inner, .el-breadcrumb__item:last-child .el-breadcrumb__inner a, .el-breadcrumb__item:last-child .el-breadcrumb__inner a:hover, .el-breadcrumb__item:last-child .el-breadcrumb__inner:hover {
|
|
71
|
+
font-size: 17px;
|
|
72
|
+
font-weight: 700;
|
|
73
|
+
}
|
|
74
|
+
.organization-tree .el-card__body {
|
|
75
|
+
padding-top: 10px;
|
|
76
|
+
}
|
|
77
|
+
.organization-tree .card-content {
|
|
78
|
+
margin-top: 10px;
|
|
79
|
+
}
|
|
80
|
+
.organization-tree .item-row-all {
|
|
81
|
+
margin-bottom: 10px;
|
|
82
|
+
}
|
|
83
|
+
.organization-tree .item-row {
|
|
84
|
+
display: flex;
|
|
85
|
+
width: 100%;
|
|
86
|
+
}
|
|
87
|
+
.organization-tree .item-label {
|
|
88
|
+
flex: 0 0 90%;
|
|
89
|
+
text-align: left;
|
|
90
|
+
}
|
|
91
|
+
.organization-tree .item-side {
|
|
92
|
+
flex: 0 0 10%;
|
|
93
|
+
text-align: right;
|
|
94
|
+
}
|
|
95
|
+
.organization-tree .el-tree-node {
|
|
96
|
+
margin-bottom: 10px;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.organization-tree .el-tree-node__content>.el-tree-node__expand-icon {
|
|
100
|
+
padding: 0;
|
|
101
|
+
display: none;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.organization-tree .card-footer {
|
|
105
|
+
padding: 20px;
|
|
106
|
+
}
|
|
107
|
+
.organization-tree .card-footer .select-result {
|
|
108
|
+
color: #409EFF;
|
|
109
|
+
flex:1 1 75%;
|
|
110
|
+
text-align: left;
|
|
111
|
+
}
|
|
112
|
+
.organization-tree .card-footer .button-area {
|
|
113
|
+
flex:0 0 20%;
|
|
114
|
+
text-align: right;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.organization-tree .dept-path .breadcrumb-label-link{
|
|
118
|
+
color:#409EFF
|
|
119
|
+
}
|
|
120
|
+
</style>
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<el-card class="card-content" style="height: 50px">
|
|
4
|
+
<el-row class="item-row item-row-all">
|
|
5
|
+
<el-col style="width: 100%;">
|
|
6
|
+
<div style="display: flex">
|
|
7
|
+
<div style="flex: 0 0 20%;text-align:left">
|
|
8
|
+
<el-checkbox v-if="multiple" v-model="checkAll" :label="$t('departmentTreeInline.allCheck')" value="all" @change="changeAllCheck" />
|
|
9
|
+
</div>
|
|
10
|
+
<div style="flex: 0 0 80%;text-align:right">
|
|
11
|
+
<el-input v-model="searchParam.searchValue" :placeholder="$t('departmentTreeInline.pleaseInputNameOrCode')" @clear="filterAppendNodes" @keyup.enter="filterAppendNodes" @blur="filterAppendNodes" clearable>
|
|
12
|
+
<template v-slot:suffix>
|
|
13
|
+
<el-icon @click="filterAppendNodes"><Search /></el-icon>
|
|
14
|
+
</template>
|
|
15
|
+
</el-input>
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
</el-col>
|
|
19
|
+
</el-row>
|
|
20
|
+
</el-card>
|
|
21
|
+
<el-card v-if="tenantName" class="card-content" style="height: 40px">
|
|
22
|
+
<el-row class="item-row item-row-all">
|
|
23
|
+
<el-col class="item-label dept-path"><deptPath :tenantName="tenantName" :clickDepts="clickDepts" @clickBreadcrumb="clickBreadcrumb"/></el-col>
|
|
24
|
+
</el-row>
|
|
25
|
+
</el-card>
|
|
26
|
+
<el-card class="card-content org-tree" style="overflow: auto;">
|
|
27
|
+
<el-tree
|
|
28
|
+
ref="orgTreeRef"
|
|
29
|
+
:data="departments"
|
|
30
|
+
:show-checkbox="multiple"
|
|
31
|
+
node-key="nodeId"
|
|
32
|
+
check-on-click-node
|
|
33
|
+
:default-checked-keys="defaultCheckedKeys"
|
|
34
|
+
@check-change="handleCheckNode"
|
|
35
|
+
@node-click="handleClickNode"
|
|
36
|
+
>
|
|
37
|
+
<template #default="{ node, data }">
|
|
38
|
+
<div class="item-row">
|
|
39
|
+
<div class="item-label">{{ data.showName }}</div>
|
|
40
|
+
<div v-if="!data.leaf" class="item-side" @click="loadChildren(data,false)">
|
|
41
|
+
<el-icon><ArrowRight /></el-icon>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
</template>
|
|
45
|
+
</el-tree>
|
|
46
|
+
</el-card>
|
|
47
|
+
<el-card class="card-footer" style="height: 40px">
|
|
48
|
+
<div style="display: flex;">
|
|
49
|
+
<div class="select-result" @click="showResult">
|
|
50
|
+
<!-- 已选择:6人,其中有一个部门(含子部门) -->
|
|
51
|
+
<span v-if="multiple" @click="showResult">
|
|
52
|
+
<span v-if="selectDepts.length > 0">
|
|
53
|
+
{{$t('departmentTreeInline.selectResultInfoHasSelect')}}{{$t('departmentTreeInline.selectResultInfo',{num: selectDepts.length })}}
|
|
54
|
+
<span style="padding-left: 10px"><el-icon><ArrowUpBold /></el-icon></span>
|
|
55
|
+
</span>
|
|
56
|
+
</span>
|
|
57
|
+
<span v-else-if="selectDepts.length > 0">
|
|
58
|
+
{{$t('departmentTreeInline.selectResultInfoHasSelect')}}{{selectDepts[0].showName }}<span v-if="selectDepts[0].parentNodeId !== '-1' && getDeptNamePath(selectDepts[0])" style="color:#999">({{ getDeptNamePath(selectDepts[0]) }})</span>
|
|
59
|
+
</span>
|
|
60
|
+
</div>
|
|
61
|
+
<div class="button-area">
|
|
62
|
+
<el-button size="large" type="primary" @click="saveDept">{{$t('imatrixUIPublicModel.sure')}}</el-button>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
</el-card>
|
|
66
|
+
<deptResult ref="deptResultRef" :selectDepts="selectDepts" @removeDept="removeResultDept"/>
|
|
67
|
+
</div>
|
|
68
|
+
</template>
|
|
69
|
+
|
|
70
|
+
<script setup lang="ts">
|
|
71
|
+
import { reactive,ref,onMounted, defineEmits,Ref } from 'vue'
|
|
72
|
+
import {
|
|
73
|
+
ArrowRight,
|
|
74
|
+
Search,
|
|
75
|
+
ArrowUpBold
|
|
76
|
+
} from '@element-plus/icons-vue'
|
|
77
|
+
import {getTenant, getTenantChildren, checkedDeptDefault, loadDepartment, initSelectDepts} from './department-tree-service.ts'
|
|
78
|
+
import {resizeScrollTargetHeightUtil, getDeptNamePath} from '../../utils/organization.ts'
|
|
79
|
+
import deptPath from './dept-path.vue'
|
|
80
|
+
import deptResult from './dept-result.vue'
|
|
81
|
+
import {ElMessage} from 'element-plus'
|
|
82
|
+
import {useI18n} from "vue-i18n"
|
|
83
|
+
const props = defineProps<{
|
|
84
|
+
// 是否是多选树,默认是true
|
|
85
|
+
multiple: {
|
|
86
|
+
type: Boolean,
|
|
87
|
+
default: true,
|
|
88
|
+
},
|
|
89
|
+
// 显示指定部门节点及其子节点,不传该属性,表示显示整个组织结构树
|
|
90
|
+
departmentInfo: {
|
|
91
|
+
type: Array<any>,
|
|
92
|
+
default: null,
|
|
93
|
+
},
|
|
94
|
+
// 多选部门树时,已选择部门id或部门名称或编码集合,多个之间以逗号隔开
|
|
95
|
+
selectDepartmentInfo: {
|
|
96
|
+
type: [String, Number],
|
|
97
|
+
default: null,
|
|
98
|
+
},
|
|
99
|
+
// 移除部门时,部门属性名称:id、name、code,默认是id
|
|
100
|
+
searchField: {
|
|
101
|
+
type: String,
|
|
102
|
+
default: 'id',
|
|
103
|
+
},
|
|
104
|
+
// 多选树时结果之间的分隔符,默认是逗号分隔
|
|
105
|
+
separator: {
|
|
106
|
+
type: String,
|
|
107
|
+
default: ','
|
|
108
|
+
}
|
|
109
|
+
}>()
|
|
110
|
+
const emits = defineEmits(["close"])
|
|
111
|
+
const orgTreeRef = ref(null)
|
|
112
|
+
let tenantInfo = ref(null)
|
|
113
|
+
let containBranch = ref(false)
|
|
114
|
+
let tenantName = ref(null)
|
|
115
|
+
let tenantNodeId = -1
|
|
116
|
+
let departments = ref([])
|
|
117
|
+
let checkedKeys = ref([])
|
|
118
|
+
let selectDepts = ref([])
|
|
119
|
+
let selectDeptNodeIds = ref([])
|
|
120
|
+
let clickDepts = ref([])
|
|
121
|
+
let defaultCheckedKeys = ref([])
|
|
122
|
+
let deptResultRef:Ref<any> = ref(null)
|
|
123
|
+
let checkAll = ref(false)
|
|
124
|
+
let searchParam = ref({
|
|
125
|
+
userField: 'name',
|
|
126
|
+
searchValue: null,
|
|
127
|
+
treeType: 'DEPARTMENT_TREE',
|
|
128
|
+
departmentInfo: null
|
|
129
|
+
})
|
|
130
|
+
const {t} = useI18n()
|
|
131
|
+
onMounted(()=>{
|
|
132
|
+
initSelectDepts(props.selectDepartmentInfo, tenantNodeId, props.searchField, props.separator ).then((departments)=>{
|
|
133
|
+
selectDepts.value = departments
|
|
134
|
+
getTenantInfo()
|
|
135
|
+
})
|
|
136
|
+
resizeScrollTargetHeight()
|
|
137
|
+
})
|
|
138
|
+
function getTenantInfo() {
|
|
139
|
+
getTenant().then(data=>{
|
|
140
|
+
const tenantData = data[0].data
|
|
141
|
+
tenantInfo.value = JSON.parse(tenantData)
|
|
142
|
+
containBranch.value = data[0].containBranch
|
|
143
|
+
tenantName.value = data[0].name
|
|
144
|
+
getTenantChildrenDept()
|
|
145
|
+
})
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function getTenantChildrenDept() {
|
|
149
|
+
getTenantChildren(props.departmentInfo, tenantNodeId).then(children=>{
|
|
150
|
+
departments.value = children
|
|
151
|
+
checkedDeptDefault(selectDepts.value, defaultCheckedKeys.value)
|
|
152
|
+
})
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function resizeScrollTargetHeight () {
|
|
156
|
+
const scrollTarget = document.querySelector('.org-tree')
|
|
157
|
+
let height = resizeScrollTargetHeightUtil(scrollTarget)
|
|
158
|
+
const titleArea = 110
|
|
159
|
+
const deptPathArea = 60
|
|
160
|
+
const allCheckArea = 60
|
|
161
|
+
const buttonArea = 60
|
|
162
|
+
height = height - titleArea - deptPathArea - allCheckArea - buttonArea
|
|
163
|
+
scrollTarget['style'].height = height + 'px'
|
|
164
|
+
scrollTarget['style'].minHeight = '300px'
|
|
165
|
+
// scrollTarget.style.maxHeight = height + 'px'
|
|
166
|
+
}
|
|
167
|
+
// 点击复选框时处理
|
|
168
|
+
function handleCheckNode(data, check, isChildrenCheck) {
|
|
169
|
+
if(check) {
|
|
170
|
+
// 表示选择节点时
|
|
171
|
+
addToSelectDept(data)
|
|
172
|
+
} else {
|
|
173
|
+
// 表示取消选择
|
|
174
|
+
removeSelectDept(data)
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function handleClickNode(data, node, treenode, events) {
|
|
179
|
+
if(data.nodeType && data.nodeType === 'DEPARTMENT') {
|
|
180
|
+
selectDepts.value = [data]
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
function addToSelectDept(dept) {
|
|
186
|
+
if(dept.nodeType && dept.nodeType === 'DEPARTMENT') {
|
|
187
|
+
const filterValue = selectDepts.value.filter(item=> item.nodeId === dept.nodeId)
|
|
188
|
+
if(!filterValue || filterValue.length === 0) {
|
|
189
|
+
// 表示集合中没有该记录,需要记录到结果集合中
|
|
190
|
+
selectDepts.value.push(JSON.parse(JSON.stringify(dept)))
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function removeSelectDept(dept) {
|
|
196
|
+
const index = selectDepts.value.findIndex(selectItem=> selectItem.nodeId === dept.nodeId)
|
|
197
|
+
// 删除指定元素
|
|
198
|
+
selectDepts.value.splice(index, 1)
|
|
199
|
+
checkAll.value =false
|
|
200
|
+
}
|
|
201
|
+
function changeAllCheck(value: boolean) {
|
|
202
|
+
console.log('changeCheck====value=', value)
|
|
203
|
+
if(props.multiple) {
|
|
204
|
+
// 表示是复选组织树
|
|
205
|
+
if(value){
|
|
206
|
+
// 表示全选时
|
|
207
|
+
const allNodeIds = departments.value.map((item)=>{
|
|
208
|
+
return item['nodeId'];
|
|
209
|
+
})
|
|
210
|
+
orgTreeRef.value.setCheckedKeys(allNodeIds, false)
|
|
211
|
+
departments.value.forEach(item=>{
|
|
212
|
+
addToSelectDept(item)
|
|
213
|
+
})
|
|
214
|
+
} else {
|
|
215
|
+
// 表示取消全选时
|
|
216
|
+
departments.value.forEach(item=>{
|
|
217
|
+
removeSelectDept(item)
|
|
218
|
+
})
|
|
219
|
+
orgTreeRef.value.setCheckedKeys([], false)
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function loadChildrenDept(dept) {
|
|
225
|
+
loadDepartment(dept.id).then(children=>{
|
|
226
|
+
departments.value = children
|
|
227
|
+
checkedDeptDefault(selectDepts.value, defaultCheckedKeys.value)
|
|
228
|
+
|
|
229
|
+
})
|
|
230
|
+
}
|
|
231
|
+
function loadChildren (dept, isBreadcrumb) {
|
|
232
|
+
clickDepts.value.push(dept)
|
|
233
|
+
loadChildrenDept(dept)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function clickBreadcrumb(item, isTenant, index) {
|
|
237
|
+
if(isTenant) {
|
|
238
|
+
// 表示点击的时公司节点
|
|
239
|
+
clickDepts.value = []
|
|
240
|
+
getTenantChildrenDept()
|
|
241
|
+
} else {
|
|
242
|
+
// 表示点击的是部门节点
|
|
243
|
+
// 删除指定元素
|
|
244
|
+
clickDepts.value.splice(index+1, clickDepts.value.length - (index + 1) )
|
|
245
|
+
loadChildrenDept(item)
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function showResult() {
|
|
250
|
+
deptResultRef.value.showResult()
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function removeResultDept(dept) {
|
|
254
|
+
const removeDeptInDepts = departments.value.filter(item=>item.nodeId === dept.nodeId)
|
|
255
|
+
if(removeDeptInDepts && removeDeptInDepts.length > 0) {
|
|
256
|
+
// departments结果存在当前移除的节点时,check-change事件会走removeSelectDept的逻辑
|
|
257
|
+
const selectNodeIds = []
|
|
258
|
+
selectDepts.value.forEach(item=>{
|
|
259
|
+
if(item.nodeId !== dept.nodeId) {
|
|
260
|
+
selectNodeIds.push(item.nodeId)
|
|
261
|
+
}
|
|
262
|
+
})
|
|
263
|
+
orgTreeRef.value.setCheckedKeys(selectNodeIds, true)
|
|
264
|
+
} else {
|
|
265
|
+
// departments结果不存在当前移除的节点时
|
|
266
|
+
removeSelectDept(dept)
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function saveDept() {
|
|
271
|
+
if (props.multiple) {
|
|
272
|
+
let leafSelectNodeInfo = {
|
|
273
|
+
ids: [],
|
|
274
|
+
names: [],
|
|
275
|
+
zhNames: [],
|
|
276
|
+
enNames: [],
|
|
277
|
+
codes: [],
|
|
278
|
+
departments: []
|
|
279
|
+
}
|
|
280
|
+
// const parentIds = []
|
|
281
|
+
selectDepts.value.forEach(node => {
|
|
282
|
+
// node.data是部门对象的json字符串信息,通过JSON.parse(node.data)将json字符串转为对象
|
|
283
|
+
let departmentData
|
|
284
|
+
// 点开initSelectDepts 查询的数据只有一层
|
|
285
|
+
if (node.data !== null && node.data !== undefined) {
|
|
286
|
+
departmentData = JSON.parse(node.data)
|
|
287
|
+
} else {
|
|
288
|
+
departmentData = node
|
|
289
|
+
}
|
|
290
|
+
addSelectedDepartmentInfo(leafSelectNodeInfo, node, departmentData)
|
|
291
|
+
})
|
|
292
|
+
let selectNodeInfo = {
|
|
293
|
+
ids: [],
|
|
294
|
+
names: [],
|
|
295
|
+
zhNames: [],
|
|
296
|
+
enNames: [],
|
|
297
|
+
codes: [],
|
|
298
|
+
departments: []
|
|
299
|
+
}
|
|
300
|
+
Object.assign(selectNodeInfo, leafSelectNodeInfo)
|
|
301
|
+
if (selectNodeInfo.ids.length > 0) {
|
|
302
|
+
emits('close', selectNodeInfo)
|
|
303
|
+
} else {
|
|
304
|
+
ElMessage({
|
|
305
|
+
message: t('imatrixUIMessage.pleaseSelectDepartment'),
|
|
306
|
+
type: 'warning',
|
|
307
|
+
})
|
|
308
|
+
}
|
|
309
|
+
} else {
|
|
310
|
+
const dept = selectDepts.value[0]
|
|
311
|
+
const department = JSON.parse(dept.data)
|
|
312
|
+
const showName = dept.showName
|
|
313
|
+
// if (this.containBranch && dept.branchName) {
|
|
314
|
+
// // 如果包含分支机构,则拼接分支机构名称
|
|
315
|
+
// name = name + '(' + dept.branchName + ')'
|
|
316
|
+
// }
|
|
317
|
+
department.tenantName = tenantInfo.value.tenantName
|
|
318
|
+
department.tenantCode = tenantInfo.value.code
|
|
319
|
+
const selectNodeInfo = {
|
|
320
|
+
id: dept.id,
|
|
321
|
+
name: showName,
|
|
322
|
+
zhName: department.name,
|
|
323
|
+
enName: department.enName,
|
|
324
|
+
code: department.code,
|
|
325
|
+
containBranch: containBranch.value,
|
|
326
|
+
department: department
|
|
327
|
+
}
|
|
328
|
+
emits('close', selectNodeInfo)
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
// 将选中的部门节点添加到结果集合中
|
|
332
|
+
function addSelectedDepartmentInfo (result, node, department) {
|
|
333
|
+
result.ids.push(node.id)
|
|
334
|
+
result.codes.push(department.code)
|
|
335
|
+
result.containBranch = containBranch.value
|
|
336
|
+
department.tenantCode = tenantInfo.value.code
|
|
337
|
+
department.tenantName = tenantInfo.value.tenantName
|
|
338
|
+
result.departments.push(department)
|
|
339
|
+
const showName = department.showName
|
|
340
|
+
// if (this.containBranch && node.branchName) {
|
|
341
|
+
// // 如果包含分支机构,则拼接分支机构名称
|
|
342
|
+
// name = name + '(' + node.branchName + ')'
|
|
343
|
+
// }
|
|
344
|
+
result.names.push(showName)
|
|
345
|
+
result.zhNames.push(department.name)
|
|
346
|
+
result.enNames.push(department.enName ? department.enName : '')
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
function filterAppendNodes ( ) {
|
|
350
|
+
if (searchParam.value.searchValue) {
|
|
351
|
+
searchParam.value.searchValue = searchParam.value.searchValue.trim()
|
|
352
|
+
searchParam.value.departmentInfo = props.departmentInfo
|
|
353
|
+
window['$vueApp'].config.globalProperties.$http.post(window['$vueApp'].config.globalProperties.baseAPI + '/component/organization-trees/search-depts', searchParam.value).then(result => {
|
|
354
|
+
if (result) {
|
|
355
|
+
if (result.length === 0) {
|
|
356
|
+
ElMessage({
|
|
357
|
+
message: t('imatrixUIMessage.queryResultIsEmpty'),
|
|
358
|
+
type: 'warning',
|
|
359
|
+
})
|
|
360
|
+
}
|
|
361
|
+
departments.value = result
|
|
362
|
+
} else {
|
|
363
|
+
ElMessage({
|
|
364
|
+
message: t('imatrixUIMessage.queryResultIsEmpty'),
|
|
365
|
+
type: 'warning',
|
|
366
|
+
})
|
|
367
|
+
}
|
|
368
|
+
})
|
|
369
|
+
} else {
|
|
370
|
+
getTenantChildrenDept()
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
</script>
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
export function getTenant () {
|
|
2
|
+
const parentId = 0
|
|
3
|
+
return window['$vueApp'].config.globalProperties.$http.get(window['$vueApp'].config.globalProperties.baseAPI + '/component/organization-trees/departments/' + parentId)
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
// 获得公司节点的孩子节点
|
|
7
|
+
export function getTenantChildren (departmentInfo, tenantNodeId) {
|
|
8
|
+
if (departmentInfo && departmentInfo.length > 0) {
|
|
9
|
+
// 加载指定部门时,展开公司节点
|
|
10
|
+
return loadPointDepartments(departmentInfo)
|
|
11
|
+
} else {
|
|
12
|
+
// 加载整个组织结构树时,展开公司节点
|
|
13
|
+
return loadDepartment(tenantNodeId)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
// 加载指定部门节点
|
|
20
|
+
export function loadPointDepartments (departmentInfo) {
|
|
21
|
+
return new Promise((resolve,reject)=>{
|
|
22
|
+
window['$vueApp'].config.globalProperties.$http.post(window['$vueApp'].config.globalProperties.baseAPI + '/component/organization-trees/point-departments', departmentInfo).then(children => {
|
|
23
|
+
resolve(children)
|
|
24
|
+
})
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
// 加载当前节点的子节点
|
|
30
|
+
export function loadDepartment (parentId) {
|
|
31
|
+
return new Promise((resolve,reject)=>{
|
|
32
|
+
window['$vueApp'].config.globalProperties.$http.get(window['$vueApp'].config.globalProperties.baseAPI + '/component/organization-trees/departments/' + parentId)
|
|
33
|
+
.then(children => {
|
|
34
|
+
resolve(children)
|
|
35
|
+
})
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
export function checkedDeptDefault (selectDepts, defaultCheckedKeys) {
|
|
39
|
+
defaultCheckedKeys = []
|
|
40
|
+
selectDepts.forEach(dept => {
|
|
41
|
+
defaultCheckedKeys.push(dept.nodeId)
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
// 获得所有指定父部门的子部门信息
|
|
45
|
+
export function getChildDepts (parentDept) {
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
const parentIds = [parentDept.id]
|
|
48
|
+
window['$vueApp'].config.globalProperties.$http.post(window['$vueApp'].config.globalProperties.baseAPI + '/component/organization-trees/department-children', parentIds).then(departments => {
|
|
49
|
+
resolve(departments)
|
|
50
|
+
}).catch(error => {
|
|
51
|
+
reject(error)
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
function getSelectDepts (searchField, selectDeptInfo, separator) {
|
|
56
|
+
return new Promise((resolve, reject) => {
|
|
57
|
+
if (!searchField) {
|
|
58
|
+
resolve([])
|
|
59
|
+
} else if (!selectDeptInfo) {
|
|
60
|
+
resolve([])
|
|
61
|
+
} else {
|
|
62
|
+
window['$vueApp'].config.globalProperties.$http.get(window['$vueApp'].config.globalProperties.baseAPI + '/component/organization-trees/select-departments?searchField=' + searchField + '&selectDeptInfo=' + selectDeptInfo + '&separator=' + separator).then(departments => {
|
|
63
|
+
resolve(departments)
|
|
64
|
+
}).catch(error => {
|
|
65
|
+
reject(error)
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function initSelectDepts (selectDepartmentInfo, tenantNodeId, searchField, separator) {
|
|
72
|
+
return new Promise((resolve, reject) => {
|
|
73
|
+
const selectDepts = []
|
|
74
|
+
if (selectDepartmentInfo) {
|
|
75
|
+
if (selectDepartmentInfo === tenantNodeId || selectDepartmentInfo === '所有部门') {
|
|
76
|
+
// 表示已选择所有用户
|
|
77
|
+
selectDepts.push(packageAllDept(tenantNodeId))
|
|
78
|
+
resolve(selectDepts)
|
|
79
|
+
} else {
|
|
80
|
+
// 表示不是选择的所有用户
|
|
81
|
+
getSelectDepts(searchField, selectDepartmentInfo, separator).then(departments => {
|
|
82
|
+
resolve(departments)
|
|
83
|
+
}).catch(error => {
|
|
84
|
+
reject(error)
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
} else {
|
|
88
|
+
resolve(selectDepts)
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// 选中了组织结构树的根节点
|
|
94
|
+
function packageAllDept (tenantNodeId) {
|
|
95
|
+
// 表示集合中不存在该用户,则封装该用户
|
|
96
|
+
var allDept = {
|
|
97
|
+
id: tenantNodeId,
|
|
98
|
+
name: '所有部门'
|
|
99
|
+
}
|
|
100
|
+
return allDept
|
|
101
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
|
|
2
|
+
<template>
|
|
3
|
+
<el-breadcrumb separator="/">
|
|
4
|
+
<el-breadcrumb-item>
|
|
5
|
+
<span class="breadcrumb-label-link" v-if="clickDepts.length > 0" @click="clickBreadcrumb(null, true)">{{myTenantName}}</span>
|
|
6
|
+
<span v-else>{{myTenantName}}</span>
|
|
7
|
+
</el-breadcrumb-item>
|
|
8
|
+
<el-breadcrumb-item
|
|
9
|
+
v-for="(dept,index) in clickDepts"
|
|
10
|
+
:key="dept.id"
|
|
11
|
+
>
|
|
12
|
+
<span class="breadcrumb-label-link" v-if="index < clickDepts.length - 1" @click="clickBreadcrumb(dept,false, index )" >{{dept.showName}}</span>
|
|
13
|
+
<span v-else>{{dept.showName}}</span>
|
|
14
|
+
</el-breadcrumb-item>
|
|
15
|
+
</el-breadcrumb>
|
|
16
|
+
</template>
|
|
17
|
+
<script setup lang="ts">
|
|
18
|
+
import { reactive,ref,onMounted, defineEmits } from 'vue'
|
|
19
|
+
const props = defineProps({
|
|
20
|
+
tenantName:{
|
|
21
|
+
type: String,
|
|
22
|
+
default: null
|
|
23
|
+
},
|
|
24
|
+
clickDepts: {
|
|
25
|
+
type: Array<any>,
|
|
26
|
+
default: null
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
const emits = defineEmits(['clickBreadcrumb'])
|
|
30
|
+
|
|
31
|
+
let myTenantName = ref(props.tenantName)
|
|
32
|
+
|
|
33
|
+
function clickBreadcrumb (item, isTenant, index) {
|
|
34
|
+
emits('clickBreadcrumb', item, isTenant, index )
|
|
35
|
+
}
|
|
36
|
+
</script>
|