imeik-bizui 1.7.6 → 1.7.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/dist/bizui/api/permission.js +12 -0
- package/dist/bizui/src/CommonDepartmentCascader/index.vue +312 -0
- package/dist/bizui/src/CommonEmployeeSelect/SelectShape.vue +110 -0
- package/dist/bizui/src/CommonEmployeeSelect/index.vue +174 -0
- package/dist/bizui/src/CommonEnumShow/index.vue +63 -0
- package/dist/bizui/src/FieldExpertSelect/index.vue +4 -0
- package/dist/bizui/utils/index.js +17 -0
- package/dist/imeik-bizui.common.js +1173 -211
- 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 +1173 -211
- package/dist/imeik-bizui.umd.js.gz +0 -0
- package/dist/imeik-bizui.umd.min.js +16 -16
- package/dist/imeik-bizui.umd.min.js.gz +0 -0
- package/package.json +1 -1
|
@@ -11,3 +11,15 @@ export function departmentSelector(params) {
|
|
|
11
11
|
params
|
|
12
12
|
})
|
|
13
13
|
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 部门列表,包含虚拟节点
|
|
17
|
+
* /permissioncenter-admin/department/listDepartmentWithVirtual
|
|
18
|
+
*/
|
|
19
|
+
export function listDepartmentWithVirtual(params) {
|
|
20
|
+
return request({
|
|
21
|
+
url: '/permissioncenter-admin/department/listDepartmentWithVirtual',
|
|
22
|
+
method: 'get',
|
|
23
|
+
params
|
|
24
|
+
})
|
|
25
|
+
}
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="!isView ? 'w-full' : 'inline'">
|
|
3
|
+
<template v-if="isView">
|
|
4
|
+
<div v-if="isWxWorkMobile && needShowMore" class="mobile-text-container">
|
|
5
|
+
<span v-if="!plantText">-</span>
|
|
6
|
+
<div v-else-if="showAll" :id="`plantText-${random}`" class="show-all-text">
|
|
7
|
+
{{ plantText }}
|
|
8
|
+
<div class="btn-text" @click="showMore">
|
|
9
|
+
收起
|
|
10
|
+
<img class="icon-retract" src="https://imeikud.oss-cn-beijing.aliyuncs.com/pcUploads/1724846415100/icon-retract.png" />
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
<div v-else class="show-limit-text">
|
|
14
|
+
{{ plantText }}
|
|
15
|
+
<div class="btn-text show-more" @click="showMore">
|
|
16
|
+
展开
|
|
17
|
+
<img class="icon-show-more" src="https://imeikud.oss-cn-beijing.aliyuncs.com/pcUploads/1724846420511/icon-show-more.png" />
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
<el-popover v-else-if="plantText" trigger="hover">
|
|
22
|
+
<div class="departmentPopover">{{ plantText }}</div>
|
|
23
|
+
<span slot="reference" class="viewText">{{ plantText }}</span>
|
|
24
|
+
</el-popover>
|
|
25
|
+
<span v-else>-</span>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<el-cascader
|
|
29
|
+
v-else
|
|
30
|
+
ref="select"
|
|
31
|
+
v-model="myValue"
|
|
32
|
+
popper-class="loading"
|
|
33
|
+
class="w-full"
|
|
34
|
+
v-bind="$attrs"
|
|
35
|
+
:props="cascaderProps"
|
|
36
|
+
:options="options"
|
|
37
|
+
:placeholder="$attrs.placeholder || (optionsLoading ? '加载中...' : '请选择部门')"
|
|
38
|
+
:collapse-tags="$attrs.collapseTags || collapseTags"
|
|
39
|
+
:clearable="$attrs.clearable !== false"
|
|
40
|
+
:filterable="$attrs.filterable !== false"
|
|
41
|
+
@change="handleChange"
|
|
42
|
+
>
|
|
43
|
+
</el-cascader>
|
|
44
|
+
</div>
|
|
45
|
+
</template>
|
|
46
|
+
|
|
47
|
+
<script>
|
|
48
|
+
import emitter from 'element-ui/src/mixins/emitter'
|
|
49
|
+
import { listDepartmentWithVirtual } from '../../api/permission'
|
|
50
|
+
import { tree2Array, getLabelByValue } from '../../utils/index'
|
|
51
|
+
|
|
52
|
+
export default {
|
|
53
|
+
name: 'CommonDepartmentCascader',
|
|
54
|
+
mixins: [emitter],
|
|
55
|
+
props: {
|
|
56
|
+
value: {
|
|
57
|
+
type: [String, Number, Array],
|
|
58
|
+
default: undefined
|
|
59
|
+
},
|
|
60
|
+
multiple: {
|
|
61
|
+
type: Boolean,
|
|
62
|
+
default: false
|
|
63
|
+
},
|
|
64
|
+
collapseTags: {
|
|
65
|
+
type: Boolean,
|
|
66
|
+
default: false
|
|
67
|
+
},
|
|
68
|
+
emitPath: {
|
|
69
|
+
type: Boolean,
|
|
70
|
+
default: false
|
|
71
|
+
},
|
|
72
|
+
propValue: {
|
|
73
|
+
type: String,
|
|
74
|
+
default: 'departmentCode'
|
|
75
|
+
},
|
|
76
|
+
expandTrigger: {
|
|
77
|
+
type: String,
|
|
78
|
+
default: 'click'
|
|
79
|
+
},
|
|
80
|
+
checkStrictly: {
|
|
81
|
+
type: Boolean,
|
|
82
|
+
default: false
|
|
83
|
+
},
|
|
84
|
+
extra: {
|
|
85
|
+
type: Object,
|
|
86
|
+
default() {
|
|
87
|
+
return {}
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
// 是否仅展示文字
|
|
91
|
+
isView: {
|
|
92
|
+
type: Boolean,
|
|
93
|
+
default: false
|
|
94
|
+
},
|
|
95
|
+
// 是否仅展示主公司
|
|
96
|
+
onlyMainCompany: {
|
|
97
|
+
type: Boolean,
|
|
98
|
+
default: true
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
data() {
|
|
102
|
+
return {
|
|
103
|
+
myValue: undefined,
|
|
104
|
+
options: [],
|
|
105
|
+
optionsLoading: false,
|
|
106
|
+
childHasUnChecked: false,
|
|
107
|
+
showAll: true,
|
|
108
|
+
needShowMore: true,
|
|
109
|
+
random: Math.random() * 100
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
computed: {
|
|
113
|
+
/**
|
|
114
|
+
* 判断当前环境是否为企业微信移动端,企微移动端禁止了浏览器的下载功能
|
|
115
|
+
* 这时候不展示下载按钮即可
|
|
116
|
+
*/
|
|
117
|
+
isWxWorkMobile() {
|
|
118
|
+
const userAgent = window.navigator.userAgent.toLowerCase()
|
|
119
|
+
const result = /wxwork/i.test(userAgent) && /iphone|android/i.test(userAgent)
|
|
120
|
+
// 企业微信移动端
|
|
121
|
+
return result
|
|
122
|
+
},
|
|
123
|
+
cascaderProps() {
|
|
124
|
+
return {
|
|
125
|
+
multiple: this.multiple,
|
|
126
|
+
label: 'departmentName',
|
|
127
|
+
value: this.propValue,
|
|
128
|
+
children: 'childDepartments',
|
|
129
|
+
emitPath: this.emitPath,
|
|
130
|
+
expandTrigger: this.expandTrigger,
|
|
131
|
+
checkStrictly: this.checkStrictly
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
plantText() {
|
|
135
|
+
const arr = tree2Array(this.options, { key: 'childDepartments' })
|
|
136
|
+
const vals = [].concat(this.myValue) // 单选的时候也转成数组
|
|
137
|
+
const list = []
|
|
138
|
+
|
|
139
|
+
vals.map((i) => {
|
|
140
|
+
list.push(getLabelByValue(arr, i, { labelKey: 'departmentName', valueKey: this.propValue }))
|
|
141
|
+
return i
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
return list.join(', ')
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
watch: {
|
|
148
|
+
value: {
|
|
149
|
+
immediate: true,
|
|
150
|
+
handler() {
|
|
151
|
+
this.setMyValue()
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
plantText: {
|
|
155
|
+
immediate: true,
|
|
156
|
+
handler(val) {
|
|
157
|
+
this.$nextTick(() => {
|
|
158
|
+
const divElement = document.getElementById(`plantText-${this.random}`)
|
|
159
|
+
if (divElement) {
|
|
160
|
+
const style = window.getComputedStyle(divElement, null)
|
|
161
|
+
const height = style.height.replace('px', '')
|
|
162
|
+
const lineHeight = style.lineHeight.replace('px', '')
|
|
163
|
+
if (height / lineHeight >= 2) {
|
|
164
|
+
this.needShowMore = true
|
|
165
|
+
this.showAll = false
|
|
166
|
+
} else {
|
|
167
|
+
this.needShowMore = false
|
|
168
|
+
this.showAll = true
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
})
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
created() {
|
|
176
|
+
this.getOptions()
|
|
177
|
+
},
|
|
178
|
+
methods: {
|
|
179
|
+
showMore() {
|
|
180
|
+
this.showAll = !this.showAll
|
|
181
|
+
this.$emit('showMore', this.showAll)
|
|
182
|
+
},
|
|
183
|
+
|
|
184
|
+
setMyValue() {
|
|
185
|
+
try {
|
|
186
|
+
this.myValue = JSON.parse(JSON.stringify(this.value))
|
|
187
|
+
} catch (error) {
|
|
188
|
+
this.myValue = this.value
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
|
|
192
|
+
getOptions() {
|
|
193
|
+
const params = {
|
|
194
|
+
...this.extra
|
|
195
|
+
}
|
|
196
|
+
this.optionsLoading = true
|
|
197
|
+
listDepartmentWithVirtual(params)
|
|
198
|
+
.then((res) => {
|
|
199
|
+
if (res.code === 200) {
|
|
200
|
+
if (!res.data) {
|
|
201
|
+
return
|
|
202
|
+
}
|
|
203
|
+
let resData = res.data || []
|
|
204
|
+
if (this.onlyMainCompany) {
|
|
205
|
+
resData = resData.filter(item => {
|
|
206
|
+
return item.orgCode === 'virtual-201'
|
|
207
|
+
})
|
|
208
|
+
}
|
|
209
|
+
this.options = this.dealList(resData || [])
|
|
210
|
+
}
|
|
211
|
+
})
|
|
212
|
+
.finally(() => {
|
|
213
|
+
this.optionsLoading = false
|
|
214
|
+
})
|
|
215
|
+
},
|
|
216
|
+
|
|
217
|
+
dealList(arr) {
|
|
218
|
+
return arr.map((i) => {
|
|
219
|
+
if (i.childDepartments && i.childDepartments.length) {
|
|
220
|
+
this.dealList(i.childDepartments)
|
|
221
|
+
} else {
|
|
222
|
+
delete i.childDepartments
|
|
223
|
+
}
|
|
224
|
+
return i
|
|
225
|
+
})
|
|
226
|
+
},
|
|
227
|
+
|
|
228
|
+
handleChange() {
|
|
229
|
+
this.$emit('input', this.myValue)
|
|
230
|
+
this.$emit('change', this.myValue)
|
|
231
|
+
this.dispatch('ElFormItem', 'el.form.change', this.myValue)
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
</script>
|
|
236
|
+
<style lang="scss" scoped>
|
|
237
|
+
.mobile-text-container {
|
|
238
|
+
position: relative;
|
|
239
|
+
.show-more {
|
|
240
|
+
position: absolute;
|
|
241
|
+
bottom: 0 !important;
|
|
242
|
+
right: 0;
|
|
243
|
+
&::before {
|
|
244
|
+
content: '';
|
|
245
|
+
position: absolute;
|
|
246
|
+
bottom: 0;
|
|
247
|
+
right: 48px;
|
|
248
|
+
background: linear-gradient( 270deg, #FFFFFF 0%, rgba(255,255,255,0) 100%);
|
|
249
|
+
width: 60px;
|
|
250
|
+
height: 31px;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
.btn-text {
|
|
254
|
+
position: absolute;
|
|
255
|
+
bottom: -28px;
|
|
256
|
+
right: 0;
|
|
257
|
+
display: flex;
|
|
258
|
+
align-items: center;
|
|
259
|
+
background: #fff;
|
|
260
|
+
font-family: PingFangSC, PingFang SC;
|
|
261
|
+
font-weight: 500;
|
|
262
|
+
font-size: 14px;
|
|
263
|
+
color: #3285F6;
|
|
264
|
+
// line-height: 31px;
|
|
265
|
+
.icon-retract, .icon-show-more {
|
|
266
|
+
width: 16px;
|
|
267
|
+
height: 16px;
|
|
268
|
+
margin-left: 4px;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
.show-limit-text {
|
|
273
|
+
white-space: nowrap;
|
|
274
|
+
overflow: hidden;
|
|
275
|
+
text-overflow: ellipsis;
|
|
276
|
+
}
|
|
277
|
+
.viewText {
|
|
278
|
+
max-width: max-content;
|
|
279
|
+
overflow: hidden;
|
|
280
|
+
display: block;
|
|
281
|
+
white-space: nowrap;
|
|
282
|
+
text-overflow: ellipsis;
|
|
283
|
+
cursor: pointer;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.labelItem {
|
|
287
|
+
display: flex;
|
|
288
|
+
align-items: center;
|
|
289
|
+
gap: 8px;
|
|
290
|
+
transform: translate(6px, 0px);
|
|
291
|
+
justify-content: space-between;
|
|
292
|
+
|
|
293
|
+
.label {
|
|
294
|
+
width: max-content;
|
|
295
|
+
text-overflow: ellipsis;
|
|
296
|
+
white-space: nowrap;
|
|
297
|
+
}
|
|
298
|
+
.selecter {
|
|
299
|
+
font-size: 14px;
|
|
300
|
+
cursor: pointer;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
.departmentPopover {
|
|
305
|
+
max-width: 300px;
|
|
306
|
+
max-height: 200px;
|
|
307
|
+
overflow: auto;
|
|
308
|
+
padding-right: 12px;
|
|
309
|
+
line-height: 24px;
|
|
310
|
+
cursor: pointer;
|
|
311
|
+
}
|
|
312
|
+
</style>
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<label :style="{ width: `${selectWidth}px` }" class="shape-check-box el-checkbox" :class="{'is-checked': checked}">
|
|
3
|
+
<span v-if="multiple" class="el-checkbox__input" :class="{'is-checked': checked}">
|
|
4
|
+
<span class="el-checkbox__inner"></span>
|
|
5
|
+
</span>
|
|
6
|
+
|
|
7
|
+
<span class="el-checkbox__label">
|
|
8
|
+
<slot></slot>
|
|
9
|
+
</span>
|
|
10
|
+
</label>
|
|
11
|
+
|
|
12
|
+
<!-- <span v-else :style="{ width: `${selectWidth}px` }" class="el-checkbox__label">
|
|
13
|
+
<slot></slot>
|
|
14
|
+
</span> -->
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script>
|
|
18
|
+
// 模拟cascader,改变下拉组件多选时的展示样式 - 在每行前面加checkbox
|
|
19
|
+
export default {
|
|
20
|
+
props: {
|
|
21
|
+
// 是否多选
|
|
22
|
+
multiple: {
|
|
23
|
+
type: Boolean,
|
|
24
|
+
default: false
|
|
25
|
+
},
|
|
26
|
+
// 是否 checked
|
|
27
|
+
checked: {
|
|
28
|
+
type: Boolean,
|
|
29
|
+
default: false
|
|
30
|
+
},
|
|
31
|
+
// 下拉框宽度
|
|
32
|
+
selectWidth: {
|
|
33
|
+
type: Number,
|
|
34
|
+
default: undefined
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<style lang="scss">
|
|
41
|
+
.el-select-dropdown.is-multiple {
|
|
42
|
+
.el-select-dropdown__item {
|
|
43
|
+
padding-right: 20px;
|
|
44
|
+
|
|
45
|
+
// &:last-of-type {
|
|
46
|
+
// margin-bottom: 4px;
|
|
47
|
+
// text-overflow: inherit;
|
|
48
|
+
// }
|
|
49
|
+
|
|
50
|
+
.el-checkbox__input {
|
|
51
|
+
transform: translate(0px, 1px);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&.selected {
|
|
55
|
+
.shape-check-box.is-checked {
|
|
56
|
+
width: 100%;
|
|
57
|
+
background: #ECF2FE;
|
|
58
|
+
transform: translate(-8px, 0px);
|
|
59
|
+
padding: 0 8px;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&:has(.shape-check-box)::after {
|
|
63
|
+
display: none;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&.hover {
|
|
67
|
+
background-color: #fff;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
&.is-disabled {
|
|
72
|
+
.shape-check-box {
|
|
73
|
+
cursor: not-allowed;
|
|
74
|
+
color: #c0c4cc;
|
|
75
|
+
}
|
|
76
|
+
.el-checkbox__inner {
|
|
77
|
+
background-color: #f5f7fa;
|
|
78
|
+
border-color: #d1dbe5;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
&.hover {
|
|
83
|
+
background-color: #fff;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.el-select-dropdown {
|
|
89
|
+
.el-select-dropdown__item {
|
|
90
|
+
&:not(:last-of-type) {
|
|
91
|
+
margin-bottom: 2px;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.shape-check-box {
|
|
96
|
+
display: flex;
|
|
97
|
+
align-items: center;
|
|
98
|
+
height: 34px;
|
|
99
|
+
|
|
100
|
+
.el-checkbox__label {
|
|
101
|
+
// width: 100%;
|
|
102
|
+
flex: 1;
|
|
103
|
+
display: inline-block;
|
|
104
|
+
overflow: hidden;
|
|
105
|
+
text-overflow: ellipsis;
|
|
106
|
+
white-space: nowrap;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
</style>
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="!isView ? 'w-full' : 'inline'">
|
|
3
|
+
<ImOneLineDot v-if="isView" :text="plantText || '-'"></ImOneLineDot>
|
|
4
|
+
<el-select
|
|
5
|
+
v-else
|
|
6
|
+
ref="select"
|
|
7
|
+
v-model="myValue"
|
|
8
|
+
class="w-full"
|
|
9
|
+
:placeholder="placeholder"
|
|
10
|
+
:multiple="multiple"
|
|
11
|
+
:filterable="filterable"
|
|
12
|
+
:allow-create="allowCreate"
|
|
13
|
+
reserve-keyword
|
|
14
|
+
clearable
|
|
15
|
+
remote
|
|
16
|
+
:remote-method="remoteMethod"
|
|
17
|
+
:loading="loading"
|
|
18
|
+
popper-class="select-class"
|
|
19
|
+
:collapse-tags="collapseTags"
|
|
20
|
+
v-bind="$attrs"
|
|
21
|
+
@change="onChange"
|
|
22
|
+
@visible-change="visibleChange"
|
|
23
|
+
>
|
|
24
|
+
<el-option v-for="item in options" :key="item[prop.value]" :label="item.name || item.employeeNo" :value="item[prop.value]">
|
|
25
|
+
<slot name="item" :item="item">
|
|
26
|
+
<SelectShape :multiple="multiple" :checked="Array.isArray(myValue) && myValue.includes(item[prop.value])">
|
|
27
|
+
<span>{{ item.name || item.employeeNo }}<span v-if="item.orgName">({{ item.orgName }})</span></span>
|
|
28
|
+
</SelectShape>
|
|
29
|
+
</slot>
|
|
30
|
+
</el-option>
|
|
31
|
+
</el-select>
|
|
32
|
+
</div>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<script>
|
|
36
|
+
import { employeeSelectOption } from '../../api/user'
|
|
37
|
+
import { getLabelByValue } from '../../utils/index'
|
|
38
|
+
import SelectShape from './SelectShape.vue'
|
|
39
|
+
export default {
|
|
40
|
+
name: 'CommonEmployeeSelect',
|
|
41
|
+
components: { SelectShape },
|
|
42
|
+
props: {
|
|
43
|
+
prop: {
|
|
44
|
+
type: Object,
|
|
45
|
+
default() {
|
|
46
|
+
return {
|
|
47
|
+
value: 'objectCode'
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
value: {
|
|
52
|
+
type: [Number, String, Array],
|
|
53
|
+
default: undefined
|
|
54
|
+
},
|
|
55
|
+
placeholder: {
|
|
56
|
+
type: String,
|
|
57
|
+
default: '请选择'
|
|
58
|
+
},
|
|
59
|
+
multiple: {
|
|
60
|
+
type: Boolean,
|
|
61
|
+
default: false
|
|
62
|
+
},
|
|
63
|
+
filterable: {
|
|
64
|
+
type: Boolean,
|
|
65
|
+
default: true
|
|
66
|
+
},
|
|
67
|
+
allowCreate: {
|
|
68
|
+
type: Boolean,
|
|
69
|
+
default: false
|
|
70
|
+
},
|
|
71
|
+
collapseTags: {
|
|
72
|
+
type: Boolean,
|
|
73
|
+
default: false
|
|
74
|
+
},
|
|
75
|
+
extra: {
|
|
76
|
+
type: Object,
|
|
77
|
+
default() {
|
|
78
|
+
return {}
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
// 是否仅展示文字
|
|
82
|
+
isView: {
|
|
83
|
+
type: Boolean,
|
|
84
|
+
default: false
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
data() {
|
|
88
|
+
return {
|
|
89
|
+
myValue: undefined,
|
|
90
|
+
loading: true,
|
|
91
|
+
selectName: undefined,
|
|
92
|
+
options: []
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
computed: {
|
|
96
|
+
plantText() {
|
|
97
|
+
const list = []
|
|
98
|
+
const vals = [].concat(this.myValue) // 单选的时候也转成数组
|
|
99
|
+
vals.map(i => {
|
|
100
|
+
list.push(getLabelByValue(this.options, i, { labelKey: 'name', valueKey: 'objectCode' }))
|
|
101
|
+
return i
|
|
102
|
+
})
|
|
103
|
+
return list.join(',')
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
watch: {
|
|
107
|
+
value: {
|
|
108
|
+
immediate: true,
|
|
109
|
+
handler() {
|
|
110
|
+
if (JSON.stringify(this.value) !== JSON.stringify(this.myValue)) {
|
|
111
|
+
this.getOptions()
|
|
112
|
+
}
|
|
113
|
+
this.setMyValue()
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
created() {
|
|
118
|
+
this.getOptions()
|
|
119
|
+
},
|
|
120
|
+
methods: {
|
|
121
|
+
maskPhoneNumber(phoneNumber) {
|
|
122
|
+
// 假设手机号格式为11位数字
|
|
123
|
+
const maskedNumber = phoneNumber.substring(0, 3) + '****' + phoneNumber.substring(7)
|
|
124
|
+
return maskedNumber
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
setMyValue() {
|
|
128
|
+
try {
|
|
129
|
+
this.myValue = JSON.parse(JSON.stringify(this.value))
|
|
130
|
+
} catch (error) {
|
|
131
|
+
this.myValue = undefined
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
remoteMethod(query) {
|
|
136
|
+
this.loading = true
|
|
137
|
+
this.selectName = query
|
|
138
|
+
this.getOptions()
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
visibleChange(val) {
|
|
142
|
+
if (!val) {
|
|
143
|
+
this.selectName = ''
|
|
144
|
+
this.getOptions()
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
getOptions() {
|
|
148
|
+
const params = {
|
|
149
|
+
name: this.selectName,
|
|
150
|
+
...this.extra
|
|
151
|
+
}
|
|
152
|
+
if (!this.selectName && this.value) {
|
|
153
|
+
params.objectCodeList = Array.isArray(this.value) ? this.value : [this.value]
|
|
154
|
+
params.selectStatus = !this.value || !this.value.length ? '0' : '1'
|
|
155
|
+
}
|
|
156
|
+
this.loading = true
|
|
157
|
+
employeeSelectOption(params).then((res) => {
|
|
158
|
+
if (res.code === 200) {
|
|
159
|
+
this.options = res.data || []
|
|
160
|
+
} else {
|
|
161
|
+
this.$message.error(res.message)
|
|
162
|
+
}
|
|
163
|
+
this.loading = false
|
|
164
|
+
})
|
|
165
|
+
},
|
|
166
|
+
|
|
167
|
+
onChange() {
|
|
168
|
+
console.log('onChange', this.myValue, this.plantText)
|
|
169
|
+
this.$emit('input', this.myValue, this.plantText)
|
|
170
|
+
this.$emit('change', this.myValue, this.plantText)
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
</script>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span class="enum-show">{{ enumLabel }}</span>
|
|
3
|
+
</template>
|
|
4
|
+
<script>
|
|
5
|
+
export default {
|
|
6
|
+
name: 'CommonEnumShow',
|
|
7
|
+
props: {
|
|
8
|
+
enumKey: {
|
|
9
|
+
required: true,
|
|
10
|
+
type: String,
|
|
11
|
+
default: ''
|
|
12
|
+
},
|
|
13
|
+
enumValue: {
|
|
14
|
+
required: true,
|
|
15
|
+
type: [String, Array, Number],
|
|
16
|
+
default: ''
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
computed: {
|
|
20
|
+
enums() {
|
|
21
|
+
return this.$bizui.enums
|
|
22
|
+
},
|
|
23
|
+
enumLabel() {
|
|
24
|
+
if (!this.enumValue) {
|
|
25
|
+
return '-'
|
|
26
|
+
}
|
|
27
|
+
if (Array.isArray(this.enumValue)) {
|
|
28
|
+
const lables = []
|
|
29
|
+
for (let i = 0; i < this.enumValue.length; i++) {
|
|
30
|
+
const value = this.enumValue[i]
|
|
31
|
+
const label = this.getLabelByValue(this.enumKey, value)
|
|
32
|
+
lables.push(label)
|
|
33
|
+
}
|
|
34
|
+
return lables.join(',') || '-'
|
|
35
|
+
} else {
|
|
36
|
+
return this.getLabelByValue(this.enumKey, this.enumValue)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
methods: {
|
|
41
|
+
getLabelByValue(key, value) {
|
|
42
|
+
const item = this.getOptionsItemByValue(key, value)
|
|
43
|
+
return item.label || '-'
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
getOptionsItemByValue(optionKey, value) {
|
|
47
|
+
const enums = this.enums
|
|
48
|
+
let result = {}
|
|
49
|
+
const options = enums[optionKey] || []
|
|
50
|
+
if (!options || options.length === 0) {
|
|
51
|
+
return result
|
|
52
|
+
}
|
|
53
|
+
for (let i = 0; i < options.length; i++) {
|
|
54
|
+
const item = options[i]
|
|
55
|
+
if (item.value === value + '') {
|
|
56
|
+
result = item
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return result
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
</script>
|
|
@@ -41,3 +41,20 @@ export function getLabelByValue(options = [], value, opt = {}) {
|
|
|
41
41
|
|
|
42
42
|
return (el && el[opt.labelKey || 'label']) || ''
|
|
43
43
|
}
|
|
44
|
+
|
|
45
|
+
// tree 转成数组
|
|
46
|
+
export function tree2Array(tree, opt = {}) {
|
|
47
|
+
if (!Array.isArray(tree) || !tree.length) {
|
|
48
|
+
return []
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const res = []
|
|
52
|
+
tree.forEach(v => {
|
|
53
|
+
res.push(v)
|
|
54
|
+
if (v[opt.key || 'children']) {
|
|
55
|
+
res.push(...tree2Array(v[opt.key || 'children'], opt))
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
return res
|
|
60
|
+
}
|