imeik-bizui 1.8.6 → 1.8.7
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/dist/bizui/src/CommonDepartmentCascader/index.vue +139 -22
- package/dist/imeik-bizui.common.js +203 -112
- package/dist/imeik-bizui.common.js.gz +0 -0
- package/dist/imeik-bizui.css +1 -1
- package/dist/imeik-bizui.css.gz +0 -0
- package/dist/imeik-bizui.umd.js +203 -112
- package/dist/imeik-bizui.umd.js.gz +0 -0
- package/dist/imeik-bizui.umd.min.js +3 -3
- package/dist/imeik-bizui.umd.min.js.gz +0 -0
- package/package.json +1 -1
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
|
+
<!-- 部门级联选择器组件 -->
|
|
2
3
|
<div :class="!isView ? 'w-full' : 'inline'">
|
|
4
|
+
<!-- 查看模式 -->
|
|
3
5
|
<template v-if="isView">
|
|
6
|
+
<!-- 企业微信移动端展示 -->
|
|
4
7
|
<div v-if="isWxWorkMobile && needShowMore" class="mobile-text-container">
|
|
5
8
|
<span v-if="!plantText">-</span>
|
|
9
|
+
<!-- 展开状态 -->
|
|
6
10
|
<div v-else-if="showAll" :id="`plantText-${random}`" class="show-all-text">
|
|
7
11
|
{{ plantText }}
|
|
8
12
|
<div class="btn-text" @click="showMore">
|
|
@@ -10,6 +14,7 @@
|
|
|
10
14
|
<img class="icon-retract" src="https://imeikud.oss-cn-beijing.aliyuncs.com/pcUploads/1724846415100/icon-retract.png" />
|
|
11
15
|
</div>
|
|
12
16
|
</div>
|
|
17
|
+
<!-- 收起状态 -->
|
|
13
18
|
<div v-else class="show-limit-text">
|
|
14
19
|
{{ plantText }}
|
|
15
20
|
<div class="btn-text show-more" @click="showMore">
|
|
@@ -18,8 +23,11 @@
|
|
|
18
23
|
</div>
|
|
19
24
|
</div>
|
|
20
25
|
</div>
|
|
26
|
+
<!-- PC端展示 -->
|
|
21
27
|
<template v-else-if="plantText">
|
|
22
|
-
|
|
28
|
+
<!-- 展示全部文本 -->
|
|
29
|
+
<span v-if="showAllWhenView" class="viewText showAll">{{ plantText }}</span>
|
|
30
|
+
<!-- 悬浮显示全部文本 -->
|
|
23
31
|
<el-popover v-else trigger="hover">
|
|
24
32
|
<div class="departmentPopover">{{ plantText }}</div>
|
|
25
33
|
<span slot="reference" class="viewText">{{ plantText }}</span>
|
|
@@ -28,6 +36,7 @@
|
|
|
28
36
|
<span v-else>-</span>
|
|
29
37
|
</template>
|
|
30
38
|
|
|
39
|
+
<!-- 编辑模式 - 级联选择器 -->
|
|
31
40
|
<el-cascader
|
|
32
41
|
v-else
|
|
33
42
|
ref="select"
|
|
@@ -36,7 +45,7 @@
|
|
|
36
45
|
class="w-full"
|
|
37
46
|
v-bind="$attrs"
|
|
38
47
|
:props="cascaderProps"
|
|
39
|
-
:options="
|
|
48
|
+
:options="filteredOptions"
|
|
40
49
|
:placeholder="$attrs.placeholder || (optionsLoading ? '加载中...' : '请选择部门')"
|
|
41
50
|
:collapse-tags="$attrs.collapseTags || collapseTags"
|
|
42
51
|
:clearable="$attrs.clearable !== false"
|
|
@@ -50,40 +59,54 @@
|
|
|
50
59
|
<script>
|
|
51
60
|
import emitter from 'element-ui/src/mixins/emitter'
|
|
52
61
|
import { listDepartmentWithVirtual } from '../../api/permission'
|
|
53
|
-
import { tree2Array, getLabelByValue } from '../../utils/index'
|
|
54
62
|
|
|
63
|
+
/**
|
|
64
|
+
* 部门级联选择器组件
|
|
65
|
+
* 支持查看和编辑两种模式
|
|
66
|
+
* 支持企业微信移动端和PC端展示
|
|
67
|
+
* 支持单选和多选
|
|
68
|
+
* 支持展开收起
|
|
69
|
+
*/
|
|
55
70
|
export default {
|
|
56
71
|
name: 'CommonDepartmentCascader',
|
|
57
72
|
mixins: [emitter],
|
|
58
73
|
props: {
|
|
74
|
+
// 选择器的值
|
|
59
75
|
value: {
|
|
60
76
|
type: [String, Number, Array],
|
|
61
77
|
default: undefined
|
|
62
78
|
},
|
|
79
|
+
// 是否多选
|
|
63
80
|
multiple: {
|
|
64
81
|
type: Boolean,
|
|
65
82
|
default: false
|
|
66
83
|
},
|
|
84
|
+
// 多选时是否折叠标签
|
|
67
85
|
collapseTags: {
|
|
68
86
|
type: Boolean,
|
|
69
87
|
default: false
|
|
70
88
|
},
|
|
89
|
+
// 是否返回选中节点的完整路径
|
|
71
90
|
emitPath: {
|
|
72
91
|
type: Boolean,
|
|
73
92
|
default: false
|
|
74
93
|
},
|
|
94
|
+
// 选项的值字段
|
|
75
95
|
propValue: {
|
|
76
96
|
type: String,
|
|
77
97
|
default: 'departmentCode'
|
|
78
98
|
},
|
|
99
|
+
// 次级菜单的展开方式
|
|
79
100
|
expandTrigger: {
|
|
80
101
|
type: String,
|
|
81
102
|
default: 'click'
|
|
82
103
|
},
|
|
104
|
+
// 是否严格的遵守父子节点不互相关联
|
|
83
105
|
checkStrictly: {
|
|
84
106
|
type: Boolean,
|
|
85
107
|
default: false
|
|
86
108
|
},
|
|
109
|
+
// 额外的请求参数
|
|
87
110
|
extra: {
|
|
88
111
|
type: Object,
|
|
89
112
|
default() {
|
|
@@ -96,25 +119,44 @@ export default {
|
|
|
96
119
|
default: false
|
|
97
120
|
},
|
|
98
121
|
// 查看的时候是否展示全部
|
|
99
|
-
|
|
122
|
+
showAllWhenView: {
|
|
100
123
|
type: Boolean,
|
|
101
|
-
default:
|
|
124
|
+
default: false
|
|
102
125
|
},
|
|
103
|
-
//
|
|
126
|
+
// 是否只展示主公司 爱美客信息技术 这个为true可以提高性能,很多数据可以不用处理了
|
|
104
127
|
onlyMainCompany: {
|
|
105
128
|
type: Boolean,
|
|
106
129
|
default: true
|
|
130
|
+
},
|
|
131
|
+
// 指定某个部门节点 如果要制定展示某个部门的数据 通过制定这个属性 比如市场发展中心为virtual-A03
|
|
132
|
+
specificOrgCode: {
|
|
133
|
+
type: String,
|
|
134
|
+
default: ''
|
|
135
|
+
},
|
|
136
|
+
// 指定某个部门节点以后是否展示根节点 有时候根节点只有一项 不想展示可以指定为false
|
|
137
|
+
hasRoot: {
|
|
138
|
+
type: Boolean,
|
|
139
|
+
default: true
|
|
107
140
|
}
|
|
108
141
|
},
|
|
109
142
|
data() {
|
|
110
143
|
return {
|
|
144
|
+
// 组件内部使用的值
|
|
111
145
|
myValue: undefined,
|
|
146
|
+
// 选项列表
|
|
112
147
|
options: [],
|
|
148
|
+
// 是否正在加载选项
|
|
113
149
|
optionsLoading: false,
|
|
150
|
+
// 子节点是否有未选中的
|
|
114
151
|
childHasUnChecked: false,
|
|
152
|
+
// 是否展示全部
|
|
115
153
|
showAll: true,
|
|
154
|
+
// 是否需要展示更多按钮
|
|
116
155
|
needShowMore: true,
|
|
117
|
-
|
|
156
|
+
// 随机数,用于生成唯一id
|
|
157
|
+
random: Math.random() * 100,
|
|
158
|
+
// 选项映射表
|
|
159
|
+
optionMap: {}
|
|
118
160
|
}
|
|
119
161
|
},
|
|
120
162
|
computed: {
|
|
@@ -128,6 +170,10 @@ export default {
|
|
|
128
170
|
// 企业微信移动端
|
|
129
171
|
return result
|
|
130
172
|
},
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* 级联选择器配置
|
|
176
|
+
*/
|
|
131
177
|
cascaderProps() {
|
|
132
178
|
return {
|
|
133
179
|
multiple: this.multiple,
|
|
@@ -139,26 +185,64 @@ export default {
|
|
|
139
185
|
checkStrictly: this.checkStrictly
|
|
140
186
|
}
|
|
141
187
|
},
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* 展示的文本
|
|
191
|
+
* 根据选中的值从optionMap中获取对应的部门名称
|
|
192
|
+
*/
|
|
142
193
|
plantText() {
|
|
143
|
-
const arr = tree2Array(this.options, { key: 'childDepartments' })
|
|
144
|
-
const vals = [].concat(this.myValue) // 单选的时候也转成数组
|
|
145
194
|
const list = []
|
|
146
195
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
196
|
+
if (Array.isArray(this.myValue)) {
|
|
197
|
+
this.myValue.forEach((i) => {
|
|
198
|
+
const item = this.optionMap[i]
|
|
199
|
+
if (item) {
|
|
200
|
+
list.push(item.departmentName)
|
|
201
|
+
}
|
|
202
|
+
})
|
|
203
|
+
} else {
|
|
204
|
+
const item = this.optionMap[this.myValue]
|
|
205
|
+
if (item) {
|
|
206
|
+
list.push(item.departmentName)
|
|
207
|
+
}
|
|
208
|
+
}
|
|
151
209
|
|
|
152
210
|
return list.join(', ')
|
|
211
|
+
},
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* 指定某个部门节点以后展示的选项
|
|
215
|
+
* 如果指定了specificOrgCode,则只展示该部门节点
|
|
216
|
+
*/
|
|
217
|
+
specificOptions() {
|
|
218
|
+
let result = this.options || []
|
|
219
|
+
if (this.specificOrgCode && this.optionMap[this.specificOrgCode]) {
|
|
220
|
+
result = [this.optionMap[this.specificOrgCode]]
|
|
221
|
+
}
|
|
222
|
+
return result || []
|
|
223
|
+
},
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* 通过hasRoot过滤后的选项
|
|
227
|
+
* 如果hasRoot为false且只有一个根节点,则展示其子节点
|
|
228
|
+
*/
|
|
229
|
+
filteredOptions() {
|
|
230
|
+
if (!this.hasRoot && this.specificOptions && this.specificOptions.length === 1 && this.specificOptions[0] && this.specificOptions[0].childDepartments) {
|
|
231
|
+
return this.specificOptions[0].childDepartments || []
|
|
232
|
+
} else {
|
|
233
|
+
return this.specificOptions || []
|
|
234
|
+
}
|
|
153
235
|
}
|
|
154
236
|
},
|
|
155
237
|
watch: {
|
|
238
|
+
// 监听外部value变化
|
|
156
239
|
value: {
|
|
157
240
|
immediate: true,
|
|
158
241
|
handler() {
|
|
159
242
|
this.setMyValue()
|
|
160
243
|
}
|
|
161
244
|
},
|
|
245
|
+
// 监听文本变化,判断是否需要展示更多按钮
|
|
162
246
|
plantText: {
|
|
163
247
|
immediate: true,
|
|
164
248
|
handler(val) {
|
|
@@ -181,14 +265,23 @@ export default {
|
|
|
181
265
|
}
|
|
182
266
|
},
|
|
183
267
|
created() {
|
|
268
|
+
// 组件创建时获取选项
|
|
184
269
|
this.getOptions()
|
|
185
270
|
},
|
|
186
271
|
methods: {
|
|
272
|
+
/**
|
|
273
|
+
* 展开更多
|
|
274
|
+
* 切换展开收起状态并触发showMore事件
|
|
275
|
+
*/
|
|
187
276
|
showMore() {
|
|
188
277
|
this.showAll = !this.showAll
|
|
189
278
|
this.$emit('showMore', this.showAll)
|
|
190
279
|
},
|
|
191
280
|
|
|
281
|
+
/**
|
|
282
|
+
* 设置级联选择器的值
|
|
283
|
+
* 深拷贝外部value值到内部myValue
|
|
284
|
+
*/
|
|
192
285
|
setMyValue() {
|
|
193
286
|
try {
|
|
194
287
|
this.myValue = JSON.parse(JSON.stringify(this.value))
|
|
@@ -197,6 +290,10 @@ export default {
|
|
|
197
290
|
}
|
|
198
291
|
},
|
|
199
292
|
|
|
293
|
+
/**
|
|
294
|
+
* 获取选项
|
|
295
|
+
* 调用接口获取部门列表
|
|
296
|
+
*/
|
|
200
297
|
getOptions() {
|
|
201
298
|
const params = {
|
|
202
299
|
...this.extra
|
|
@@ -210,7 +307,7 @@ export default {
|
|
|
210
307
|
}
|
|
211
308
|
let resData = res.data || []
|
|
212
309
|
if (this.onlyMainCompany) {
|
|
213
|
-
resData = resData.filter(item => {
|
|
310
|
+
resData = resData.filter((item) => {
|
|
214
311
|
return item.orgCode === 'virtual-201'
|
|
215
312
|
})
|
|
216
313
|
}
|
|
@@ -222,17 +319,31 @@ export default {
|
|
|
222
319
|
})
|
|
223
320
|
},
|
|
224
321
|
|
|
322
|
+
/**
|
|
323
|
+
* 处理选项
|
|
324
|
+
* 递归处理部门列表,生成optionMap映射表
|
|
325
|
+
*/
|
|
225
326
|
dealList(arr) {
|
|
226
|
-
return arr.map((
|
|
227
|
-
if (
|
|
228
|
-
this
|
|
327
|
+
return arr.map((item) => {
|
|
328
|
+
if (item.orgCode) {
|
|
329
|
+
this.$set(this.optionMap, item.orgCode, item)
|
|
330
|
+
}
|
|
331
|
+
if (item[this.propValue]) {
|
|
332
|
+
this.$set(this.optionMap, item[this.propValue], item)
|
|
333
|
+
}
|
|
334
|
+
if (item.childDepartments && item.childDepartments.length) {
|
|
335
|
+
this.dealList(item.childDepartments)
|
|
229
336
|
} else {
|
|
230
|
-
delete
|
|
337
|
+
delete item.childDepartments
|
|
231
338
|
}
|
|
232
|
-
return
|
|
339
|
+
return item
|
|
233
340
|
})
|
|
234
341
|
},
|
|
235
342
|
|
|
343
|
+
/**
|
|
344
|
+
* 处理级联选择器值变化
|
|
345
|
+
* 触发input和change事件,并通知表单项值变化
|
|
346
|
+
*/
|
|
236
347
|
handleChange() {
|
|
237
348
|
this.$emit('input', this.myValue)
|
|
238
349
|
this.$emit('change', this.myValue)
|
|
@@ -242,6 +353,7 @@ export default {
|
|
|
242
353
|
}
|
|
243
354
|
</script>
|
|
244
355
|
<style lang="scss" scoped>
|
|
356
|
+
/* 移动端文本容器样式 */
|
|
245
357
|
.mobile-text-container {
|
|
246
358
|
position: relative;
|
|
247
359
|
.show-more {
|
|
@@ -253,7 +365,7 @@ export default {
|
|
|
253
365
|
position: absolute;
|
|
254
366
|
bottom: 0;
|
|
255
367
|
right: 48px;
|
|
256
|
-
background: linear-gradient(
|
|
368
|
+
background: linear-gradient(270deg, #ffffff 0%, rgba(255, 255, 255, 0) 100%);
|
|
257
369
|
width: 60px;
|
|
258
370
|
height: 31px;
|
|
259
371
|
}
|
|
@@ -268,20 +380,23 @@ export default {
|
|
|
268
380
|
font-family: PingFangSC, PingFang SC;
|
|
269
381
|
font-weight: 500;
|
|
270
382
|
font-size: 14px;
|
|
271
|
-
color: #
|
|
383
|
+
color: #3285f6;
|
|
272
384
|
// line-height: 31px;
|
|
273
|
-
.icon-retract,
|
|
385
|
+
.icon-retract,
|
|
386
|
+
.icon-show-more {
|
|
274
387
|
width: 16px;
|
|
275
388
|
height: 16px;
|
|
276
389
|
margin-left: 4px;
|
|
277
390
|
}
|
|
278
391
|
}
|
|
279
392
|
}
|
|
393
|
+
/* 收起状态文本样式 */
|
|
280
394
|
.show-limit-text {
|
|
281
395
|
white-space: nowrap;
|
|
282
396
|
overflow: hidden;
|
|
283
397
|
text-overflow: ellipsis;
|
|
284
398
|
}
|
|
399
|
+
/* 查看模式文本样式 */
|
|
285
400
|
.viewText {
|
|
286
401
|
max-width: max-content;
|
|
287
402
|
overflow: hidden;
|
|
@@ -297,6 +412,7 @@ export default {
|
|
|
297
412
|
}
|
|
298
413
|
}
|
|
299
414
|
|
|
415
|
+
/* 标签项样式 */
|
|
300
416
|
.labelItem {
|
|
301
417
|
display: flex;
|
|
302
418
|
align-items: center;
|
|
@@ -315,6 +431,7 @@ export default {
|
|
|
315
431
|
}
|
|
316
432
|
}
|
|
317
433
|
|
|
434
|
+
/* 部门弹出框样式 */
|
|
318
435
|
.departmentPopover {
|
|
319
436
|
max-width: 300px;
|
|
320
437
|
max-height: 200px;
|