imeik-bizui 2.3.6 → 2.3.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.
@@ -22,4 +22,4 @@ export function listDepartmentWithVirtual(params) {
22
22
  method: 'get',
23
23
  params
24
24
  })
25
- }
25
+ }
@@ -10,6 +10,17 @@ export function courseSelector(data) {
10
10
  })
11
11
  }
12
12
 
13
+ /**
14
+ * 部门列表
15
+ */
16
+ export function qxcollegeDepartmentList(params) {
17
+ return request({
18
+ url: '/qxcollege/admin/department/list',
19
+ method: 'get',
20
+ params
21
+ })
22
+ }
23
+
13
24
  // 部门选择器
14
25
  export function departmentSelector(data) {
15
26
  return request({
@@ -1,5 +1,5 @@
1
1
  <!--
2
- 部门级联选择器组件
2
+ 部门级联选择器组件,默认会有虚拟父节点,方便部门选择器使用,通过noVirtual属性不展示虚拟父节点,方便放在其他场景里使用
3
3
 
4
4
  用途:
5
5
  1. 支持企业微信移动端和PC端展示
@@ -22,6 +22,7 @@
22
22
  onlyMainCompany: 是否只展示主公司 爱美客信息技术 这个为true可以提高性能,很多数据可以不用处理了
23
23
  specificOrgCode: 指定某个部门节点 如果要制定展示某个部门的数据 通过制定这个属性 比如市场发展中心为virtual-A03
24
24
  hasRoot: 指定某个部门节点以后是否展示根节点 有时候根节点只有一项 不想展示可以指定为false
25
+ noVirtual: 不展示虚拟父节点,方便放在其他场景里使用
25
26
 
26
27
  使用示例:
27
28
  <CommonDepartmentCascader
@@ -92,6 +93,7 @@
92
93
  <script>
93
94
  import emitter from 'element-ui/src/mixins/emitter'
94
95
  import { listDepartmentWithVirtual } from '../../api/permission'
96
+ import { qxcollegeDepartmentList } from '../../api/user'
95
97
 
96
98
  /**
97
99
  * 部门级联选择器组件
@@ -193,6 +195,14 @@ export default {
193
195
  }
194
196
  },
195
197
  computed: {
198
+ /**
199
+ * 不展示虚拟父节点
200
+ * 默认展示,方便部门选择器使用,如果不展示虚拟父节点,方便放在其他场景里使用
201
+ */
202
+ noVirtual() {
203
+ return !!this.$attrs.noVirtual
204
+ },
205
+
196
206
  /**
197
207
  * 判断当前环境是否为企业微信移动端,企微移动端禁止了浏览器的下载功能
198
208
  * 这时候不展示下载按钮即可
@@ -204,6 +214,23 @@ export default {
204
214
  return result
205
215
  },
206
216
 
217
+ /**
218
+ * 子节点字段
219
+ */
220
+ childField() {
221
+ return this.noVirtual ? 'childList' : 'childDepartments'
222
+ },
223
+
224
+ /**
225
+ * 值字段
226
+ */
227
+ valueField() {
228
+ if (this.propValue !== 'departmentCode') {
229
+ return this.propValue
230
+ }
231
+ return this.noVirtual ? 'objectCode' : 'departmentCode'
232
+ },
233
+
207
234
  /**
208
235
  * 级联选择器配置
209
236
  */
@@ -211,8 +238,8 @@ export default {
211
238
  return {
212
239
  multiple: this.multiple,
213
240
  label: 'departmentName',
214
- value: this.propValue,
215
- children: 'childDepartments',
241
+ value: this.valueField,
242
+ children: this.childField,
216
243
  emitPath: this.emitPath,
217
244
  expandTrigger: this.expandTrigger,
218
245
  checkStrictly: this.checkStrictly
@@ -260,8 +287,8 @@ export default {
260
287
  * 如果hasRoot为false且只有一个根节点,则展示其子节点
261
288
  */
262
289
  filteredOptions() {
263
- if (!this.hasRoot && this.specificOptions && this.specificOptions.length === 1 && this.specificOptions[0] && this.specificOptions[0].childDepartments) {
264
- return this.specificOptions[0].childDepartments || []
290
+ if (!this.hasRoot && this.specificOptions && this.specificOptions.length === 1 && this.specificOptions[0] && this.specificOptions[0][this.childField]) {
291
+ return this.specificOptions[0][this.childField] || []
265
292
  } else {
266
293
  return this.specificOptions || []
267
294
  }
@@ -332,7 +359,8 @@ export default {
332
359
  ...this.extra
333
360
  }
334
361
  this.optionsLoading = true
335
- listDepartmentWithVirtual(params)
362
+ const requestFn = this.noVirtual ? qxcollegeDepartmentList : listDepartmentWithVirtual
363
+ requestFn(params)
336
364
  .then((res) => {
337
365
  if (res.code === 200) {
338
366
  if (!res.data) {
@@ -341,6 +369,9 @@ export default {
341
369
  let resData = res.data || []
342
370
  if (this.onlyMainCompany) {
343
371
  resData = resData.filter((item) => {
372
+ if (this.noVirtual) {
373
+ return item.orgCode === '201'
374
+ }
344
375
  return item.orgCode === 'virtual-201'
345
376
  })
346
377
  }
@@ -362,13 +393,13 @@ export default {
362
393
  if (item.orgCode) {
363
394
  this.$set(this.optionMap, item.orgCode, item)
364
395
  }
365
- if (item[this.propValue]) {
366
- this.$set(this.optionMap, item[this.propValue], item)
396
+ if (item[this.valueField]) {
397
+ this.$set(this.optionMap, item[this.valueField], item)
367
398
  }
368
- if (item.childDepartments && item.childDepartments.length) {
369
- this.dealList(item.childDepartments)
399
+ if (item && item[this.childField] && item[this.childField].length) {
400
+ this.dealList(item[this.childField])
370
401
  } else {
371
- delete item.childDepartments
402
+ delete item[this.childField]
372
403
  }
373
404
  return item
374
405
  })