eoss-ui 0.6.18 → 0.6.20

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.
Files changed (101) hide show
  1. package/lib/eoss-ui.common.js +761 -657
  2. package/lib/flow.js +619 -515
  3. package/lib/index.js +1 -1
  4. package/lib/main.js +132 -132
  5. package/lib/qr-code.js +13 -13
  6. package/lib/theme-chalk/index.css +1 -1
  7. package/lib/theme-chalk/login.css +1 -1
  8. package/package.json +157 -157
  9. package/packages/button/src/main.vue +418 -418
  10. package/packages/button-group/src/main.vue +298 -298
  11. package/packages/checkbox-group/src/main.vue +333 -333
  12. package/packages/clients/src/main.vue +144 -144
  13. package/packages/data-table/src/children.vue +39 -39
  14. package/packages/data-table/src/column.vue +983 -983
  15. package/packages/data-table/src/main.vue +1812 -1812
  16. package/packages/data-table/src/sizer.vue +195 -195
  17. package/packages/date-picker/src/main.vue +236 -236
  18. package/packages/flow/src/component/CustomPreset.vue +1 -1
  19. package/packages/flow/src/component/Preset.vue +1 -1
  20. package/packages/flow/src/component/SendMsg.vue +3 -1
  21. package/packages/flow/src/component/taskUnionExamine.vue +38 -20
  22. package/packages/flow/src/main.vue +2731 -2711
  23. package/packages/flow/src/processForm.vue +13 -2
  24. package/packages/flow/src/processReject.vue +14 -3
  25. package/packages/flow/src/startTaskRead.vue +23 -5
  26. package/packages/flow-group/src/main.vue +684 -684
  27. package/packages/form/src/main.vue +3582 -3582
  28. package/packages/form/src/table.vue +1420 -1420
  29. package/packages/handle-user/src/main.vue +134 -134
  30. package/packages/handler/src/main.vue +374 -374
  31. package/packages/icon/src/main.vue +101 -101
  32. package/packages/input/src/main.vue +356 -356
  33. package/packages/login/src/main.vue +1851 -1851
  34. package/packages/login/src/resetPassword.vue +557 -557
  35. package/packages/main/src/default/message.vue +249 -249
  36. package/packages/main/src/default/notice.vue +157 -157
  37. package/packages/main/src/default/userinfo.vue +494 -494
  38. package/packages/main/src/public/online.vue +89 -89
  39. package/packages/main/src/public/search.vue +454 -454
  40. package/packages/main/src/public/settings.vue +221 -221
  41. package/packages/main/src/simplicity/apps.vue +388 -388
  42. package/packages/main/src/simplicity/avatar.vue +82 -82
  43. package/packages/main/src/simplicity/handler.vue +183 -183
  44. package/packages/main/src/simplicity/index.vue +1930 -1930
  45. package/packages/main/src/simplicity/lists.vue +84 -84
  46. package/packages/main/src/simplicity/menu-list.vue +128 -128
  47. package/packages/main/src/simplicity/message.vue +259 -259
  48. package/packages/main/src/simplicity/notice.vue +190 -190
  49. package/packages/main/src/simplicity/router-page.vue +45 -45
  50. package/packages/main/src/simplicity/sub-menu.vue +241 -241
  51. package/packages/main/src/simplicity/user.vue +248 -248
  52. package/packages/main/src/simplicity/userinfo.vue +304 -304
  53. package/packages/menu/src/main.vue +536 -536
  54. package/packages/pagination/src/main.vue +96 -96
  55. package/packages/qr-code/src/main.vue +170 -170
  56. package/packages/radio-group/src/main.vue +319 -319
  57. package/packages/select/src/main.vue +761 -761
  58. package/packages/selector/src/main.vue +677 -677
  59. package/packages/selector-panel/src/main.vue +1020 -1020
  60. package/packages/selector-panel/src/selection.vue +160 -160
  61. package/packages/tabs/src/main.vue +788 -788
  62. package/packages/theme-chalk/lib/index.css +1 -1
  63. package/packages/theme-chalk/lib/login.css +1 -1
  64. package/packages/theme-chalk/src/base.scss +260 -260
  65. package/packages/theme-chalk/src/button-group.scss +175 -175
  66. package/packages/theme-chalk/src/calendar.scss +113 -113
  67. package/packages/theme-chalk/src/clients.scss +87 -87
  68. package/packages/theme-chalk/src/common/var.scss +1 -4
  69. package/packages/theme-chalk/src/data-table.scss +276 -276
  70. package/packages/theme-chalk/src/dialog.scss +77 -77
  71. package/packages/theme-chalk/src/flow-group.scss +110 -110
  72. package/packages/theme-chalk/src/form.scss +496 -496
  73. package/packages/theme-chalk/src/handler.scss +133 -133
  74. package/packages/theme-chalk/src/icon.scss +1745 -1745
  75. package/packages/theme-chalk/src/icons.scss +99 -99
  76. package/packages/theme-chalk/src/login.scss +917 -926
  77. package/packages/theme-chalk/src/main.scss +632 -632
  78. package/packages/theme-chalk/src/menu.scss +222 -222
  79. package/packages/theme-chalk/src/nav.scss +125 -125
  80. package/packages/theme-chalk/src/pagination.scss +29 -29
  81. package/packages/theme-chalk/src/selector-panel.scss +204 -204
  82. package/packages/theme-chalk/src/simplicity.scss +1246 -1246
  83. package/packages/theme-chalk/src/tabs.scss +87 -87
  84. package/packages/theme-chalk/src/toolbar.scss +179 -179
  85. package/packages/theme-chalk/src/tree-group.scss +72 -72
  86. package/packages/theme-chalk/src/tree.scss +165 -165
  87. package/packages/upload/src/main.vue +1313 -1313
  88. package/packages/wujie/src/main.vue +145 -145
  89. package/src/config/api.js +236 -236
  90. package/src/config/image.js +2 -2
  91. package/src/index.js +157 -157
  92. package/packages/.DS_Store +0 -0
  93. package/packages/checkbox-group/.DS_Store +0 -0
  94. package/packages/data-table/.DS_Store +0 -0
  95. package/packages/dialog/.DS_Store +0 -0
  96. package/packages/handler/.DS_Store +0 -0
  97. package/packages/login/.DS_Store +0 -0
  98. package/packages/main/.DS_Store +0 -0
  99. package/packages/main/src/.DS_Store +0 -0
  100. package/packages/theme-chalk/src/.DS_Store +0 -0
  101. package/src/.DS_Store +0 -0
@@ -1,1020 +1,1020 @@
1
- <template>
2
- <es-tabs
3
- v-model="activeName"
4
- class="es-selector-panel"
5
- mold="border-card"
6
- :style="style"
7
- @tab-click="handleClick"
8
- >
9
- <el-tab-pane
10
- v-for="items in trees"
11
- :key="items.label"
12
- :label="items.label"
13
- :name="items.name"
14
- class="es-selector-content"
15
- >
16
- <div class="es-selector-view">
17
- <tree
18
- v-if="isShowTree"
19
- :data="items.data"
20
- :loading="loading"
21
- @loadsub="loadsub"
22
- @search="searchTree"
23
- ></tree>
24
- <div class="es-selector-selection">
25
- <el-form
26
- ref="form"
27
- @submit.native.prevent
28
- :inline="true"
29
- :model="form"
30
- class="es-selector-selection-toolbar"
31
- v-if="multiple || isShowTree"
32
- >
33
- <el-form-item>
34
- <es-switch v-model="showDisabled" :data="options"></es-switch>
35
- </el-form-item>
36
- <el-form-item>
37
- <el-checkbox
38
- v-show="multiple && !max"
39
- v-model="checkAll"
40
- @change="handleCheckAll"
41
- >
42
- 全选
43
- </el-checkbox>
44
- </el-form-item>
45
- <div class="es-float-right" v-if="isShowTree">
46
- <el-form-item v-if="showSelect && activeName == 'enterprise'">
47
- <es-select
48
- v-model="selectValue"
49
- placeholder="请选择"
50
- @change="handleSelect"
51
- >
52
- <el-option
53
- v-for="item in filtrate.options"
54
- :key="item.value"
55
- :label="item.name"
56
- :value="item.value"
57
- ></el-option>
58
- </es-select>
59
- </el-form-item>
60
- <el-form-item>
61
- <el-input
62
- v-model="search"
63
- placeholder="请输入搜索关键字"
64
- @change="handleChangeSearch"
65
- >
66
- <template slot="append">
67
- <el-button
68
- icon="el-icon-search"
69
- type="primary"
70
- @click="handleSearch"
71
- ></el-button>
72
- </template>
73
- </el-input>
74
- </el-form-item>
75
- </div>
76
- </el-form>
77
- <selection
78
- v-model="checkeds"
79
- :data="checkboxs"
80
- :value-key="valueKey"
81
- :label-key="labelKey"
82
- :multiple="mix ? mix : multiple"
83
- :max="max"
84
- :showDisabled="showDisabled"
85
- ></selection>
86
- <selection
87
- v-model="checkeds"
88
- genre="delete"
89
- :data="Array.isArray(checkeds) ? checkeds : [checkeds]"
90
- :value-key="valueKey"
91
- :label-key="labelKey"
92
- :multiple="multiple"
93
- :max="max"
94
- :mix="mix"
95
- :isSort="true"
96
- @sort="handleSort"
97
- ></selection>
98
- </div>
99
- </div>
100
- <div class="es-selector-handle">
101
- <el-button type="primary" size="small" @click="handleConfirm"
102
- >确定</el-button
103
- >
104
- <el-button size="small" @click="handleCancel">取消</el-button>
105
- </div>
106
- </el-tab-pane>
107
- </es-tabs>
108
- </template>
109
- <script>
110
- import tree from './tree.vue';
111
- import selection from './selection.vue';
112
- import {
113
- getSelectorOrgTree,
114
- getSelectorOrgDetail
115
- } from 'eoss-ui/src/config/api.js';
116
- import { debounce } from 'throttle-debounce';
117
- import util from 'eoss-ui/src/utils/util.js';
118
- export default {
119
- name: 'EsSelectorPanel',
120
- inheritAttrs: false,
121
- components: {
122
- tree,
123
- selection
124
- },
125
- props: {
126
- isShowLevel3: {
127
- type: Boolean,
128
- default: true
129
- },
130
- method: {
131
- type: String,
132
- default: 'get'
133
- },
134
- host: {
135
- type: String,
136
- default: ''
137
- },
138
- value: [Array, Object, String],
139
- width: {
140
- type: String,
141
- default: '900px'
142
- },
143
- height: {
144
- type: String,
145
- default: '560px'
146
- },
147
- //树结构
148
- tree: {
149
- type: Boolean,
150
- default: true
151
- },
152
- type: {
153
- type: Array,
154
- default() {
155
- return ['enterprise', 'person'];
156
- }
157
- },
158
- active: String,
159
- //是否替换页签
160
- replace: {
161
- type: Boolean,
162
- default: false
163
- },
164
- //页签
165
- tabs: Object,
166
- filtrate: {
167
- type: [Boolean, Object],
168
- default() {
169
- return {
170
- show: true,
171
- value: '1',
172
- options: [
173
- {
174
- value: '1',
175
- name: '直接下级'
176
- },
177
- {
178
- value: '2',
179
- name: '所有下级'
180
- }
181
- ]
182
- };
183
- }
184
- },
185
- selection: {
186
- type: [String, Array],
187
- default: getSelectorOrgDetail
188
- },
189
- param: {
190
- type: Object,
191
- default() {
192
- return {};
193
- }
194
- },
195
- valueKey: {
196
- type: String,
197
- default: 'showid'
198
- },
199
- labelKey: {
200
- type: String,
201
- default: 'showname'
202
- },
203
- form: {
204
- type: Object,
205
- default() {
206
- return {};
207
- }
208
- },
209
- multiple: {
210
- type: Boolean,
211
- default: true
212
- },
213
- max: Number,
214
- mix: Boolean
215
- },
216
- data() {
217
- return {
218
- style: { width: this.width, height: this.height },
219
- loading: true,
220
- search: '',
221
- defaults: '',
222
- trees: '',
223
- checkAll: false,
224
- selectValue: this.filtrate.value,
225
- orgpath: false,
226
- nodeData: '',
227
- activeName: '',
228
- selections: [],
229
- checkboxs: [],
230
- checkeds: null,
231
- showDisabled: true,
232
- options: [
233
- {
234
- value: true,
235
- name: '展示'
236
- },
237
- {
238
- value: false,
239
- name: '过滤'
240
- }
241
- ]
242
- };
243
- },
244
- computed: {
245
- //是否显示树结构
246
- isShowTree() {
247
- if (typeof this.selection === 'object' && Array.isArray(this.selection)) {
248
- return false;
249
- } else {
250
- return this.tree;
251
- }
252
- },
253
- showSelect() {
254
- if (typeof this.filtrate === 'object') {
255
- return this.filtrate.show;
256
- } else {
257
- return false;
258
- }
259
- },
260
- actived: {
261
- get() {
262
- return this.active ? this.active : this.type[0];
263
- },
264
- set(val) {
265
- return val;
266
- }
267
- },
268
- newTabs() {
269
- const orgId = util.getStorage('orgId');
270
- const tabs = {
271
- enterprise: {
272
- label: '选择单位',
273
- name: 'enterprise',
274
- url: getSelectorOrgTree,
275
- data: [],
276
- nodeData: '',
277
- selection: [],
278
- value: [],
279
- param: {
280
- showarea: 1,
281
- id: 0,
282
- filid: 'all'
283
- }
284
- },
285
- department: {
286
- label: '选择部门',
287
- name: 'department',
288
- url: getSelectorOrgTree,
289
- data: [],
290
- nodeData: '',
291
- selection: [],
292
- value: [],
293
- param: {
294
- showarea: 0,
295
- id: 0,
296
- filid: 'all'
297
- }
298
- },
299
- employee: {
300
- label: '选择用户',
301
- name: 'employee',
302
- url: getSelectorOrgTree,
303
- data: [],
304
- nodeData: '',
305
- selection: [],
306
- value: [],
307
- param: {
308
- showarea: 0,
309
- id: 0,
310
- filid: 'all'
311
- }
312
- },
313
- myemployee: {
314
- label: '本单位用户',
315
- name: 'myemployee',
316
- url: getSelectorOrgTree,
317
- data: [],
318
- nodeData: '',
319
- selection: [],
320
- value: [],
321
- param: {
322
- showarea: 2,
323
- id: 0,
324
- filid: orgId
325
- }
326
- },
327
- otheremployee: {
328
- label: '外单位用户',
329
- name: 'otheremployee',
330
- url: getSelectorOrgTree,
331
- data: [],
332
- nodeData: '',
333
- selection: [],
334
- value: [],
335
- param: {
336
- showarea: 2,
337
- id: 0,
338
- filid: 'all'
339
- }
340
- },
341
- person: {
342
- label: '选择人员',
343
- name: 'person',
344
- url: getSelectorOrgTree,
345
- data: [],
346
- nodeData: '',
347
- selection: [],
348
- value: [],
349
- param: {
350
- showarea: 0,
351
- id: 0,
352
- filid: 'all'
353
- }
354
- },
355
- otherperson: {
356
- label: '外单位人员',
357
- name: 'otherperson',
358
- url: getSelectorOrgTree,
359
- data: [],
360
- nodeData: '',
361
- selection: [],
362
- value: [],
363
- param: {
364
- showarea: 2,
365
- id: 0,
366
- filid: 'all'
367
- }
368
- },
369
- persongroup: {
370
- label: '选择群组成员',
371
- name: 'persongroup',
372
- url: getSelectorOrgTree,
373
- data: [],
374
- nodeData: '',
375
- selection: [],
376
- value: [],
377
- param: {
378
- showarea: 3,
379
- id: 0,
380
- filid: 'all'
381
- }
382
- },
383
- filgroup: {
384
- label: '单位群组成员',
385
- data: [],
386
- nodeData: '',
387
- selection: [],
388
- value: [],
389
- name: 'filgroup',
390
- url: getSelectorOrgTree,
391
- param: {
392
- showarea: 3,
393
- id: 0,
394
- filid: 'all'
395
- }
396
- },
397
- depgroup: {
398
- label: '部门群组成员',
399
- name: 'depgroup',
400
- url: getSelectorOrgTree,
401
- data: [],
402
- nodeData: '',
403
- selection: [],
404
- value: [],
405
- param: {
406
- showarea: 4,
407
- id: 0,
408
- filid: 'all'
409
- }
410
- },
411
- persongroupobj: {
412
- label: '人员群组',
413
- name: 'persongroupobj',
414
- url: getSelectorOrgTree,
415
- data: [],
416
- nodeData: '',
417
- selection: [],
418
- value: [],
419
- param: {
420
- showarea: 11,
421
- id: 0,
422
- filid: 'all'
423
- }
424
- },
425
- filgroupobj: {
426
- label: '单位群组',
427
- name: 'filgroupobj',
428
- url: getSelectorOrgTree,
429
- data: [],
430
- nodeData: '',
431
- selection: [],
432
- value: [],
433
- param: {
434
- showarea: 13,
435
- id: 0,
436
- filid: 'all'
437
- }
438
- },
439
- depgroupobj: {
440
- label: '部门群组',
441
- name: 'depgroupobj',
442
- url: getSelectorOrgTree,
443
- data: [],
444
- nodeData: '',
445
- selection: [],
446
- value: [],
447
- param: {
448
- showarea: 13,
449
- id: 0,
450
- filid: 'all'
451
- }
452
- },
453
- role: {
454
- label: '选择角色',
455
- name: 'role',
456
- url: getSelectorOrgTree,
457
- data: [],
458
- nodeData: '',
459
- selection: [],
460
- value: [],
461
- param: {
462
- showarea: 6,
463
- id: 0,
464
- filid: 'all'
465
- }
466
- },
467
- post: {
468
- label: '选择岗位',
469
- name: 'post',
470
- url: getSelectorOrgTree,
471
- data: [],
472
- nodeData: '',
473
- selection: [],
474
- value: [],
475
- param: {
476
- showarea: 8,
477
- id: 0,
478
- filid: 'all'
479
- }
480
- },
481
- codetable: {
482
- label: '代码表',
483
- name: 'codetable',
484
- url: getSelectorOrgTree,
485
- data: [],
486
- nodeData: '',
487
- selection: [],
488
- value: [],
489
- param: {
490
- showarea: 10,
491
- id: 0,
492
- filid: 'all'
493
- }
494
- },
495
- topcontacts: {
496
- label: '常用联系人',
497
- name: 'topcontacts',
498
- url: getSelectorOrgTree,
499
- data: [],
500
- nodeData: '',
501
- selection: [],
502
- value: [],
503
- param: {
504
- showarea: 9,
505
- id: 0,
506
- filid: 'all'
507
- }
508
- }
509
- };
510
- if (this.tabs) {
511
- if (this.replace) {
512
- return this.tabs;
513
- } else {
514
- return util.extend(true, tabs, this.tabs);
515
- }
516
- }
517
- return tabs;
518
- }
519
- },
520
- watch: {
521
- type: {
522
- immediate: true,
523
- deep: true,
524
- handler(val, old) {
525
- if (
526
- old === undefined ||
527
- new Set([...val, ...old]).size !== val.length
528
- ) {
529
- var obj = {};
530
- this.activeName = this.actived;
531
- if (this.isShowTree) {
532
- for (let i in val) {
533
- obj[val[i]] = this.newTabs[val[i]];
534
- }
535
- } else {
536
- obj[this.activeName] = this.newTabs[this.activeName];
537
- }
538
- this.trees = obj;
539
- this.defaults = JSON.parse(JSON.stringify(obj));
540
- }
541
- }
542
- },
543
- activeName: {
544
- handler(val) {
545
- this.ajaxActive(val);
546
- }
547
- },
548
- tabs: {
549
- deep: true,
550
- handler() {
551
- this.loading = true;
552
- this.getTreeData(
553
- this.host + this.newTabs[this.activeName].url,
554
- this.newTabs[this.activeName].param
555
- );
556
- }
557
- },
558
- value: {
559
- immediate: true,
560
- handler(val) {
561
- if (val !== undefined) {
562
- this.trees[this.activeName].value = JSON.parse(JSON.stringify(val));
563
- } else {
564
- this.trees[this.activeName].value = '';
565
- }
566
- this.checkeds = this.trees[this.activeName].value || [];
567
- }
568
- },
569
- checkboxs(val) {
570
- let flag = this.checkboxs.length ? true : false;
571
- this.checkboxs.forEach((item) => {
572
- if (util.isObject(item)) {
573
- if (util.indexOfObj(this.checkeds, item) === -1) {
574
- flag = false;
575
- return;
576
- }
577
- } else {
578
- if (this.checkeds.indexOf(item) === -1) {
579
- flag = false;
580
- return;
581
- }
582
- }
583
- });
584
- this.checkAll = flag;
585
- },
586
- checkeds(res, old) {
587
- let val = res;
588
- // if (!Array.isArray(val)) {
589
- // this.checkeds = [res];
590
- // return;
591
- // }
592
- if (old.length > 0) {
593
- if (val.length < old.length) {
594
- this.checkAll = false;
595
- } else {
596
- let flag = true;
597
- this.checkboxs.forEach((item) => {
598
- if (util.isObject(item)) {
599
- if (util.indexOfObj(val, item) === -1) {
600
- flag = false;
601
- return;
602
- }
603
- } else {
604
- if (val.indexOf(item) === -1) {
605
- flag = false;
606
- return;
607
- }
608
- }
609
- });
610
- this.checkAll = flag;
611
- }
612
- }
613
- this.trees[this.activeName].value = val;
614
- }
615
- },
616
- beforeCreate() {
617
- this.ajaxActive = debounce(500, (active) => {
618
- this.getAjaxActive(active);
619
- });
620
- },
621
- created() {},
622
- mounted() {
623
- this.ajaxActive(this.activeName);
624
- },
625
- methods: {
626
- getAjaxActive(active) {
627
- if (this.isShowTree) {
628
- if (
629
- (!this.trees[active].data ||
630
- (this.trees[active].data &&
631
- this.trees[active].data.length === 0)) &&
632
- this.newTabs[active].url
633
- ) {
634
- this.loading = true;
635
- this.getTreeData(
636
- this.host + this.newTabs[active].url,
637
- this.newTabs[active].param
638
- );
639
- }
640
- if (
641
- !this.trees[active].value ||
642
- (this.trees[active].value && this.trees[active].value.length === 0)
643
- ) {
644
- if (this.value !== undefined) {
645
- this.trees[active].value = JSON.parse(JSON.stringify(this.value));
646
- }
647
- }
648
- this.checkboxs = this.trees[active].selection || [];
649
- if (!this.mix) {
650
- this.checkeds = this.trees[active].value || [];
651
- }
652
- this.nodeData = this.trees[active].nodeData;
653
- } else {
654
- if (typeof this.selection === 'string') {
655
- let params = this.param[this.activeName]
656
- ? this.param[this.activeName]
657
- : this.param;
658
- util
659
- .ajax({
660
- method: this.method,
661
- url: this.host + this.selection,
662
- params: params,
663
- data: params
664
- })
665
- .then((res) => {
666
- if (res.rCode === 0) {
667
- this.selections = JSON.parse(JSON.stringify(res.results));
668
- this.checkboxs = JSON.parse(JSON.stringify(res.results)) || [];
669
- }
670
- })
671
- .catch((err) => {
672
- if (err.message && err.message !== 'canceled') {
673
- this.$message.error(err.message);
674
- }
675
- });
676
- } else {
677
- this.selections = this.selection;
678
- this.checkboxs = this.selection || [];
679
- }
680
- }
681
- },
682
- getTreeData(url, params, id) {
683
- let data = util.extend(
684
- {},
685
- params,
686
- this.param[this.activeName] ? this.param[this.activeName] : this.param
687
- );
688
- if (id !== undefined) {
689
- data.id = id;
690
- }
691
- util
692
- .ajax({ method: this.method, url: url, params: data, data: data })
693
- .then((res) => {
694
- if (res.rCode === 0) {
695
- this.loading = false;
696
- if (!Object.prototype.hasOwnProperty.call(params, 'seachkey')) {
697
- this.$set(
698
- this.defaults[this.activeName],
699
- 'data',
700
- JSON.parse(JSON.stringify(res.results))
701
- );
702
- }
703
- if (res.results.length && res.results[0].name === '无搜索数据') {
704
- this.$set(this.trees[this.activeName], 'data', null);
705
- } else {
706
- this.$set(
707
- this.trees[this.activeName],
708
- 'data',
709
- JSON.parse(JSON.stringify(res.results))
710
- );
711
- }
712
- }
713
- })
714
- .catch((err) => {
715
- if (err.message && err.message !== 'canceled') {
716
- this.$message.error(err.message);
717
- }
718
- });
719
- },
720
- loadsub(data, node, flag) {
721
- node;
722
- if (flag) {
723
- if (data.selection === undefined || data.selection.length === 0) {
724
- this.checkAll = false;
725
- let params = util.extend(
726
- {},
727
- this.param[this.activeName]
728
- ? this.param[this.activeName]
729
- : this.param
730
- );
731
- params.type = this.activeName;
732
- params.mid = data.id;
733
- if (this.activeName === 'enterprise') {
734
- params.querymode = this.selectValue;
735
- if (this.selectValue === '2' || this.selectValue === 2) {
736
- params.orgpath =
737
- data.attributes && data.attributes.orgpath
738
- ? data.attributes.orgpath
739
- : '';
740
- }
741
- }
742
- // if (this.activeName === 'department') {
743
- // params.querymode = 0;
744
- // }
745
- util
746
- .ajax({
747
- method: this.method,
748
- url: this.host + this.selection,
749
- params: params,
750
- data: params
751
- })
752
- .then((res) => {
753
- if (res.rCode === 0) {
754
- data.selection = JSON.parse(JSON.stringify(res.results));
755
- this.$set(
756
- this.trees[this.activeName],
757
- 'selection',
758
- JSON.parse(JSON.stringify(res.results))
759
- );
760
- this.$set(this.trees[this.activeName], 'nodeData', data);
761
- this.nodeData = this.trees[this.activeName].nodeData;
762
- this.checkboxs = this.trees[this.activeName].selection;
763
- }
764
- })
765
- .catch((err) => {
766
- if (err.message && err.message !== 'canceled') {
767
- this.$message.error(err.message);
768
- }
769
- });
770
- } else {
771
- this.trees[this.activeName].selection = data.selection;
772
- this.trees[this.activeName].nodeData = data;
773
- this.nodeData = this.trees[this.activeName].nodeData;
774
- this.checkboxs = this.trees[this.activeName].selection;
775
- }
776
- } else {
777
- if (!this.isShowLevel3) {
778
- data.state = '';
779
- }
780
- if (
781
- data.state !== '' &&
782
- (!data.children || data.children.length === 0)
783
- ) {
784
- let params = util.extend(
785
- {},
786
- this.newTabs[this.activeName].param,
787
- this.param[this.activeName]
788
- ? this.param[this.activeName]
789
- : this.param
790
- );
791
- params.id = data.id;
792
- util
793
- .ajax({
794
- method: this.method,
795
- url: this.host + this.newTabs[this.activeName].url,
796
- data: params,
797
- params: params
798
- })
799
- .then((res) => {
800
- if (res.rCode === 0) {
801
- this.loading = false;
802
- this.$set(
803
- data,
804
- 'children',
805
- JSON.parse(JSON.stringify(res.results))
806
- );
807
- this.$set(
808
- this.defaults[this.activeName],
809
- 'data',
810
- JSON.parse(JSON.stringify(this.trees[this.activeName].data))
811
- );
812
- }
813
- })
814
- .catch((err) => {
815
- if (err.message && err.message !== 'canceled') {
816
- this.$message.error(err.message);
817
- }
818
- });
819
- }
820
- }
821
- },
822
- searchTree(res) {
823
- if (res) {
824
- this.loading = true;
825
- let params = util.extend({}, this.newTabs[this.activeName].param, {
826
- seachkey: res
827
- });
828
- this.getTreeData(this.host + this.newTabs[this.activeName].url, params);
829
- } else {
830
- this.$set(
831
- this.trees[this.activeName],
832
- 'data',
833
- this.defaults[this.activeName].data
834
- );
835
- }
836
- },
837
- handleCheckAll(res) {
838
- if (this.checkboxs.length > 0) {
839
- let isObject = util.isObject(this.checkboxs[0]);
840
- if (res) {
841
- if (this.isShowTree) {
842
- this.nodeData.checkAll = true;
843
- let checkeds = this.checkeds.concat(
844
- this.checkboxs.filter((item) => {
845
- return item.disabled !== true;
846
- })
847
- );
848
- if (checkeds.length > 0) {
849
- this.checkeds = util.arrUnique(
850
- checkeds,
851
- isObject ? this.valueKey : undefined
852
- );
853
- }
854
- } else {
855
- this.checkeds = this.checkboxs;
856
- }
857
- } else {
858
- if (this.isShowTree) {
859
- this.nodeData.checkAll = false;
860
- this.checkboxs.forEach((element) => {
861
- for (let i in this.checkeds) {
862
- if (
863
- (isObject &&
864
- this.checkeds[i][this.valueKey] ===
865
- element[this.valueKey]) ||
866
- this.checkeds[i] === element
867
- ) {
868
- this.checkeds.splice(i, 1);
869
- break;
870
- }
871
- }
872
- });
873
- } else {
874
- this.checkeds = [];
875
- }
876
- }
877
- }
878
- },
879
- handleSelect(res) {
880
- if (this.nodeData) {
881
- this.nodeData.selection = '';
882
- this.loadsub(this.nodeData, '', true);
883
- }
884
- this.$emit('filtratechage', this.trees, this.activeName);
885
- },
886
- handleChangeSearch() {
887
- if (this.search === '') {
888
- if (this.isShowTree) {
889
- this.checkboxs = this.nodeData.selection;
890
- } else {
891
- this.checkboxs = this.selections;
892
- }
893
- } else {
894
- if (this.isShowTree) {
895
- if (this.nodeData && this.nodeData.selection) {
896
- let arry = [];
897
- this.nodeData.selection.forEach((item) => {
898
- if (util.isObject(item)) {
899
- if (item[this.labelKey].indexOf(this.search) > -1) {
900
- arry.push(item);
901
- }
902
- } else {
903
- if (item.indexOf(this.search) > -1) {
904
- arry.push(item);
905
- }
906
- }
907
- });
908
- this.checkboxs = arry;
909
- }
910
- } else {
911
- let arry = [];
912
- this.selections.forEach((item) => {
913
- if (util.isObject(item)) {
914
- if (item[this.labelKey].indexOf(this.search) > -1) {
915
- arry.push(item);
916
- }
917
- } else {
918
- if (item.indexOf(this.search) > -1) {
919
- arry.push(item);
920
- }
921
- }
922
- });
923
- this.checkboxs = arry;
924
- }
925
- }
926
- },
927
- handleSearch() {
928
- if (this.isShowTree) {
929
- if (this.nodeData && this.nodeData.selection) {
930
- if (this.search !== '') {
931
- let arry = [];
932
- this.nodeData.selection.forEach((item) => {
933
- if (util.isObject(item)) {
934
- if (item[this.labelKey].indexOf(this.search) > -1) {
935
- arry.push(item);
936
- }
937
- } else {
938
- if (item.indexOf(this.search) > -1) {
939
- arry.push(item);
940
- }
941
- }
942
- });
943
- this.checkboxs = arry;
944
- }
945
- } else {
946
- let mid = '0-0-0-0-0';
947
- if (this.nodeData) {
948
- mid = this.nodeData.id;
949
- }
950
- util
951
- .ajax({
952
- url: this.selection,
953
- params: {
954
- mid: mid,
955
- querymode: this.selectValue,
956
- type: this.activeName,
957
- namelike: this.search
958
- }
959
- })
960
- .then((res) => {
961
- if (res.rCode === 0) {
962
- this.checkboxs = JSON.parse(JSON.stringify(res.results));
963
- }
964
- })
965
- .catch((err) => {
966
- if (err.message && err.message !== 'canceled') {
967
- this.$message.error(err.message);
968
- }
969
- });
970
- }
971
- } else {
972
- if (this.search !== '') {
973
- let arry = [];
974
- this.selections.forEach((item) => {
975
- if (util.isObject(item)) {
976
- if (item[this.labelKey].indexOf(this.search) > -1) {
977
- arry.push(item);
978
- }
979
- } else {
980
- if (item.indexOf(this.search) > -1) {
981
- arry.push(item);
982
- }
983
- }
984
- });
985
- this.checkboxs = arry;
986
- }
987
- }
988
- },
989
- handleClick() {
990
- this.$emit('tabschage', this.trees, this.activeName);
991
- },
992
- handleChange() {},
993
- handleConfirm() {
994
- if (!this.checkeds || (this.multiple && this.checkeds.length === 0)) {
995
- this.$message({
996
- message: '请选择',
997
- type: 'warning'
998
- });
999
- } else {
1000
- this.$emit('input', this.checkeds);
1001
- this.$emit('confirm', this.checkeds);
1002
- }
1003
- },
1004
- handleCancel() {
1005
- this.$emit('cancel', false);
1006
- },
1007
- handleSort(res) {
1008
- let oldIndex = res.oldIndex;
1009
- let newIndex = res.newIndex;
1010
-
1011
- this.checkeds.splice(newIndex, 0, this.checkeds[oldIndex]);
1012
- if (oldIndex > newIndex) {
1013
- this.checkeds.splice(oldIndex + 1, 1);
1014
- } else {
1015
- this.checkeds.splice(oldIndex, 1);
1016
- }
1017
- }
1018
- }
1019
- };
1020
- </script>
1
+ <template>
2
+ <es-tabs
3
+ v-model="activeName"
4
+ class="es-selector-panel"
5
+ mold="border-card"
6
+ :style="style"
7
+ @tab-click="handleClick"
8
+ >
9
+ <el-tab-pane
10
+ v-for="items in trees"
11
+ :key="items.label"
12
+ :label="items.label"
13
+ :name="items.name"
14
+ class="es-selector-content"
15
+ >
16
+ <div class="es-selector-view">
17
+ <tree
18
+ v-if="isShowTree"
19
+ :data="items.data"
20
+ :loading="loading"
21
+ @loadsub="loadsub"
22
+ @search="searchTree"
23
+ ></tree>
24
+ <div class="es-selector-selection">
25
+ <el-form
26
+ ref="form"
27
+ @submit.native.prevent
28
+ :inline="true"
29
+ :model="form"
30
+ class="es-selector-selection-toolbar"
31
+ v-if="multiple || isShowTree"
32
+ >
33
+ <el-form-item>
34
+ <es-switch v-model="showDisabled" :data="options"></es-switch>
35
+ </el-form-item>
36
+ <el-form-item>
37
+ <el-checkbox
38
+ v-show="multiple && !max"
39
+ v-model="checkAll"
40
+ @change="handleCheckAll"
41
+ >
42
+ 全选
43
+ </el-checkbox>
44
+ </el-form-item>
45
+ <div class="es-float-right" v-if="isShowTree">
46
+ <el-form-item v-if="showSelect && activeName == 'enterprise'">
47
+ <es-select
48
+ v-model="selectValue"
49
+ placeholder="请选择"
50
+ @change="handleSelect"
51
+ >
52
+ <el-option
53
+ v-for="item in filtrate.options"
54
+ :key="item.value"
55
+ :label="item.name"
56
+ :value="item.value"
57
+ ></el-option>
58
+ </es-select>
59
+ </el-form-item>
60
+ <el-form-item>
61
+ <el-input
62
+ v-model="search"
63
+ placeholder="请输入搜索关键字"
64
+ @change="handleChangeSearch"
65
+ >
66
+ <template slot="append">
67
+ <el-button
68
+ icon="el-icon-search"
69
+ type="primary"
70
+ @click="handleSearch"
71
+ ></el-button>
72
+ </template>
73
+ </el-input>
74
+ </el-form-item>
75
+ </div>
76
+ </el-form>
77
+ <selection
78
+ v-model="checkeds"
79
+ :data="checkboxs"
80
+ :value-key="valueKey"
81
+ :label-key="labelKey"
82
+ :multiple="mix ? mix : multiple"
83
+ :max="max"
84
+ :showDisabled="showDisabled"
85
+ ></selection>
86
+ <selection
87
+ v-model="checkeds"
88
+ genre="delete"
89
+ :data="Array.isArray(checkeds) ? checkeds : [checkeds]"
90
+ :value-key="valueKey"
91
+ :label-key="labelKey"
92
+ :multiple="multiple"
93
+ :max="max"
94
+ :mix="mix"
95
+ :isSort="true"
96
+ @sort="handleSort"
97
+ ></selection>
98
+ </div>
99
+ </div>
100
+ <div class="es-selector-handle">
101
+ <el-button type="primary" size="small" @click="handleConfirm"
102
+ >确定</el-button
103
+ >
104
+ <el-button size="small" @click="handleCancel">取消</el-button>
105
+ </div>
106
+ </el-tab-pane>
107
+ </es-tabs>
108
+ </template>
109
+ <script>
110
+ import tree from './tree.vue';
111
+ import selection from './selection.vue';
112
+ import {
113
+ getSelectorOrgTree,
114
+ getSelectorOrgDetail
115
+ } from 'eoss-ui/src/config/api.js';
116
+ import { debounce } from 'throttle-debounce';
117
+ import util from 'eoss-ui/src/utils/util.js';
118
+ export default {
119
+ name: 'EsSelectorPanel',
120
+ inheritAttrs: false,
121
+ components: {
122
+ tree,
123
+ selection
124
+ },
125
+ props: {
126
+ isShowLevel3: {
127
+ type: Boolean,
128
+ default: true
129
+ },
130
+ method: {
131
+ type: String,
132
+ default: 'get'
133
+ },
134
+ host: {
135
+ type: String,
136
+ default: ''
137
+ },
138
+ value: [Array, Object, String],
139
+ width: {
140
+ type: String,
141
+ default: '900px'
142
+ },
143
+ height: {
144
+ type: String,
145
+ default: '560px'
146
+ },
147
+ //树结构
148
+ tree: {
149
+ type: Boolean,
150
+ default: true
151
+ },
152
+ type: {
153
+ type: Array,
154
+ default() {
155
+ return ['enterprise', 'person'];
156
+ }
157
+ },
158
+ active: String,
159
+ //是否替换页签
160
+ replace: {
161
+ type: Boolean,
162
+ default: false
163
+ },
164
+ //页签
165
+ tabs: Object,
166
+ filtrate: {
167
+ type: [Boolean, Object],
168
+ default() {
169
+ return {
170
+ show: true,
171
+ value: '1',
172
+ options: [
173
+ {
174
+ value: '1',
175
+ name: '直接下级'
176
+ },
177
+ {
178
+ value: '2',
179
+ name: '所有下级'
180
+ }
181
+ ]
182
+ };
183
+ }
184
+ },
185
+ selection: {
186
+ type: [String, Array],
187
+ default: getSelectorOrgDetail
188
+ },
189
+ param: {
190
+ type: Object,
191
+ default() {
192
+ return {};
193
+ }
194
+ },
195
+ valueKey: {
196
+ type: String,
197
+ default: 'showid'
198
+ },
199
+ labelKey: {
200
+ type: String,
201
+ default: 'showname'
202
+ },
203
+ form: {
204
+ type: Object,
205
+ default() {
206
+ return {};
207
+ }
208
+ },
209
+ multiple: {
210
+ type: Boolean,
211
+ default: true
212
+ },
213
+ max: Number,
214
+ mix: Boolean
215
+ },
216
+ data() {
217
+ return {
218
+ style: { width: this.width, height: this.height },
219
+ loading: true,
220
+ search: '',
221
+ defaults: '',
222
+ trees: '',
223
+ checkAll: false,
224
+ selectValue: this.filtrate.value,
225
+ orgpath: false,
226
+ nodeData: '',
227
+ activeName: '',
228
+ selections: [],
229
+ checkboxs: [],
230
+ checkeds: null,
231
+ showDisabled: true,
232
+ options: [
233
+ {
234
+ value: true,
235
+ name: '展示'
236
+ },
237
+ {
238
+ value: false,
239
+ name: '过滤'
240
+ }
241
+ ]
242
+ };
243
+ },
244
+ computed: {
245
+ //是否显示树结构
246
+ isShowTree() {
247
+ if (typeof this.selection === 'object' && Array.isArray(this.selection)) {
248
+ return false;
249
+ } else {
250
+ return this.tree;
251
+ }
252
+ },
253
+ showSelect() {
254
+ if (typeof this.filtrate === 'object') {
255
+ return this.filtrate.show;
256
+ } else {
257
+ return false;
258
+ }
259
+ },
260
+ actived: {
261
+ get() {
262
+ return this.active ? this.active : this.type[0];
263
+ },
264
+ set(val) {
265
+ return val;
266
+ }
267
+ },
268
+ newTabs() {
269
+ const orgId = util.getStorage('orgId');
270
+ const tabs = {
271
+ enterprise: {
272
+ label: '选择单位',
273
+ name: 'enterprise',
274
+ url: getSelectorOrgTree,
275
+ data: [],
276
+ nodeData: '',
277
+ selection: [],
278
+ value: [],
279
+ param: {
280
+ showarea: 1,
281
+ id: 0,
282
+ filid: 'all'
283
+ }
284
+ },
285
+ department: {
286
+ label: '选择部门',
287
+ name: 'department',
288
+ url: getSelectorOrgTree,
289
+ data: [],
290
+ nodeData: '',
291
+ selection: [],
292
+ value: [],
293
+ param: {
294
+ showarea: 0,
295
+ id: 0,
296
+ filid: 'all'
297
+ }
298
+ },
299
+ employee: {
300
+ label: '选择用户',
301
+ name: 'employee',
302
+ url: getSelectorOrgTree,
303
+ data: [],
304
+ nodeData: '',
305
+ selection: [],
306
+ value: [],
307
+ param: {
308
+ showarea: 0,
309
+ id: 0,
310
+ filid: 'all'
311
+ }
312
+ },
313
+ myemployee: {
314
+ label: '本单位用户',
315
+ name: 'myemployee',
316
+ url: getSelectorOrgTree,
317
+ data: [],
318
+ nodeData: '',
319
+ selection: [],
320
+ value: [],
321
+ param: {
322
+ showarea: 2,
323
+ id: 0,
324
+ filid: orgId
325
+ }
326
+ },
327
+ otheremployee: {
328
+ label: '外单位用户',
329
+ name: 'otheremployee',
330
+ url: getSelectorOrgTree,
331
+ data: [],
332
+ nodeData: '',
333
+ selection: [],
334
+ value: [],
335
+ param: {
336
+ showarea: 2,
337
+ id: 0,
338
+ filid: 'all'
339
+ }
340
+ },
341
+ person: {
342
+ label: '选择人员',
343
+ name: 'person',
344
+ url: getSelectorOrgTree,
345
+ data: [],
346
+ nodeData: '',
347
+ selection: [],
348
+ value: [],
349
+ param: {
350
+ showarea: 0,
351
+ id: 0,
352
+ filid: 'all'
353
+ }
354
+ },
355
+ otherperson: {
356
+ label: '外单位人员',
357
+ name: 'otherperson',
358
+ url: getSelectorOrgTree,
359
+ data: [],
360
+ nodeData: '',
361
+ selection: [],
362
+ value: [],
363
+ param: {
364
+ showarea: 2,
365
+ id: 0,
366
+ filid: 'all'
367
+ }
368
+ },
369
+ persongroup: {
370
+ label: '选择群组成员',
371
+ name: 'persongroup',
372
+ url: getSelectorOrgTree,
373
+ data: [],
374
+ nodeData: '',
375
+ selection: [],
376
+ value: [],
377
+ param: {
378
+ showarea: 3,
379
+ id: 0,
380
+ filid: 'all'
381
+ }
382
+ },
383
+ filgroup: {
384
+ label: '单位群组成员',
385
+ data: [],
386
+ nodeData: '',
387
+ selection: [],
388
+ value: [],
389
+ name: 'filgroup',
390
+ url: getSelectorOrgTree,
391
+ param: {
392
+ showarea: 3,
393
+ id: 0,
394
+ filid: 'all'
395
+ }
396
+ },
397
+ depgroup: {
398
+ label: '部门群组成员',
399
+ name: 'depgroup',
400
+ url: getSelectorOrgTree,
401
+ data: [],
402
+ nodeData: '',
403
+ selection: [],
404
+ value: [],
405
+ param: {
406
+ showarea: 4,
407
+ id: 0,
408
+ filid: 'all'
409
+ }
410
+ },
411
+ persongroupobj: {
412
+ label: '人员群组',
413
+ name: 'persongroupobj',
414
+ url: getSelectorOrgTree,
415
+ data: [],
416
+ nodeData: '',
417
+ selection: [],
418
+ value: [],
419
+ param: {
420
+ showarea: 11,
421
+ id: 0,
422
+ filid: 'all'
423
+ }
424
+ },
425
+ filgroupobj: {
426
+ label: '单位群组',
427
+ name: 'filgroupobj',
428
+ url: getSelectorOrgTree,
429
+ data: [],
430
+ nodeData: '',
431
+ selection: [],
432
+ value: [],
433
+ param: {
434
+ showarea: 13,
435
+ id: 0,
436
+ filid: 'all'
437
+ }
438
+ },
439
+ depgroupobj: {
440
+ label: '部门群组',
441
+ name: 'depgroupobj',
442
+ url: getSelectorOrgTree,
443
+ data: [],
444
+ nodeData: '',
445
+ selection: [],
446
+ value: [],
447
+ param: {
448
+ showarea: 13,
449
+ id: 0,
450
+ filid: 'all'
451
+ }
452
+ },
453
+ role: {
454
+ label: '选择角色',
455
+ name: 'role',
456
+ url: getSelectorOrgTree,
457
+ data: [],
458
+ nodeData: '',
459
+ selection: [],
460
+ value: [],
461
+ param: {
462
+ showarea: 6,
463
+ id: 0,
464
+ filid: 'all'
465
+ }
466
+ },
467
+ post: {
468
+ label: '选择岗位',
469
+ name: 'post',
470
+ url: getSelectorOrgTree,
471
+ data: [],
472
+ nodeData: '',
473
+ selection: [],
474
+ value: [],
475
+ param: {
476
+ showarea: 8,
477
+ id: 0,
478
+ filid: 'all'
479
+ }
480
+ },
481
+ codetable: {
482
+ label: '代码表',
483
+ name: 'codetable',
484
+ url: getSelectorOrgTree,
485
+ data: [],
486
+ nodeData: '',
487
+ selection: [],
488
+ value: [],
489
+ param: {
490
+ showarea: 10,
491
+ id: 0,
492
+ filid: 'all'
493
+ }
494
+ },
495
+ topcontacts: {
496
+ label: '常用联系人',
497
+ name: 'topcontacts',
498
+ url: getSelectorOrgTree,
499
+ data: [],
500
+ nodeData: '',
501
+ selection: [],
502
+ value: [],
503
+ param: {
504
+ showarea: 9,
505
+ id: 0,
506
+ filid: 'all'
507
+ }
508
+ }
509
+ };
510
+ if (this.tabs) {
511
+ if (this.replace) {
512
+ return this.tabs;
513
+ } else {
514
+ return util.extend(true, tabs, this.tabs);
515
+ }
516
+ }
517
+ return tabs;
518
+ }
519
+ },
520
+ watch: {
521
+ type: {
522
+ immediate: true,
523
+ deep: true,
524
+ handler(val, old) {
525
+ if (
526
+ old === undefined ||
527
+ new Set([...val, ...old]).size !== val.length
528
+ ) {
529
+ var obj = {};
530
+ this.activeName = this.actived;
531
+ if (this.isShowTree) {
532
+ for (let i in val) {
533
+ obj[val[i]] = this.newTabs[val[i]];
534
+ }
535
+ } else {
536
+ obj[this.activeName] = this.newTabs[this.activeName];
537
+ }
538
+ this.trees = obj;
539
+ this.defaults = JSON.parse(JSON.stringify(obj));
540
+ }
541
+ }
542
+ },
543
+ activeName: {
544
+ handler(val) {
545
+ this.ajaxActive(val);
546
+ }
547
+ },
548
+ tabs: {
549
+ deep: true,
550
+ handler() {
551
+ this.loading = true;
552
+ this.getTreeData(
553
+ this.host + this.newTabs[this.activeName].url,
554
+ this.newTabs[this.activeName].param
555
+ );
556
+ }
557
+ },
558
+ value: {
559
+ immediate: true,
560
+ handler(val) {
561
+ if (val !== undefined) {
562
+ this.trees[this.activeName].value = JSON.parse(JSON.stringify(val));
563
+ } else {
564
+ this.trees[this.activeName].value = '';
565
+ }
566
+ this.checkeds = this.trees[this.activeName].value || [];
567
+ }
568
+ },
569
+ checkboxs(val) {
570
+ let flag = this.checkboxs.length ? true : false;
571
+ this.checkboxs.forEach((item) => {
572
+ if (util.isObject(item)) {
573
+ if (util.indexOfObj(this.checkeds, item) === -1) {
574
+ flag = false;
575
+ return;
576
+ }
577
+ } else {
578
+ if (this.checkeds.indexOf(item) === -1) {
579
+ flag = false;
580
+ return;
581
+ }
582
+ }
583
+ });
584
+ this.checkAll = flag;
585
+ },
586
+ checkeds(res, old) {
587
+ let val = res;
588
+ // if (!Array.isArray(val)) {
589
+ // this.checkeds = [res];
590
+ // return;
591
+ // }
592
+ if (old.length > 0) {
593
+ if (val.length < old.length) {
594
+ this.checkAll = false;
595
+ } else {
596
+ let flag = true;
597
+ this.checkboxs.forEach((item) => {
598
+ if (util.isObject(item)) {
599
+ if (util.indexOfObj(val, item) === -1) {
600
+ flag = false;
601
+ return;
602
+ }
603
+ } else {
604
+ if (val.indexOf(item) === -1) {
605
+ flag = false;
606
+ return;
607
+ }
608
+ }
609
+ });
610
+ this.checkAll = flag;
611
+ }
612
+ }
613
+ this.trees[this.activeName].value = val;
614
+ }
615
+ },
616
+ beforeCreate() {
617
+ this.ajaxActive = debounce(500, (active) => {
618
+ this.getAjaxActive(active);
619
+ });
620
+ },
621
+ created() {},
622
+ mounted() {
623
+ this.ajaxActive(this.activeName);
624
+ },
625
+ methods: {
626
+ getAjaxActive(active) {
627
+ if (this.isShowTree) {
628
+ if (
629
+ (!this.trees[active].data ||
630
+ (this.trees[active].data &&
631
+ this.trees[active].data.length === 0)) &&
632
+ this.newTabs[active].url
633
+ ) {
634
+ this.loading = true;
635
+ this.getTreeData(
636
+ this.host + this.newTabs[active].url,
637
+ this.newTabs[active].param
638
+ );
639
+ }
640
+ if (
641
+ !this.trees[active].value ||
642
+ (this.trees[active].value && this.trees[active].value.length === 0)
643
+ ) {
644
+ if (this.value !== undefined) {
645
+ this.trees[active].value = JSON.parse(JSON.stringify(this.value));
646
+ }
647
+ }
648
+ this.checkboxs = this.trees[active].selection || [];
649
+ if (!this.mix) {
650
+ this.checkeds = this.trees[active].value || [];
651
+ }
652
+ this.nodeData = this.trees[active].nodeData;
653
+ } else {
654
+ if (typeof this.selection === 'string') {
655
+ let params = this.param[this.activeName]
656
+ ? this.param[this.activeName]
657
+ : this.param;
658
+ util
659
+ .ajax({
660
+ method: this.method,
661
+ url: this.host + this.selection,
662
+ params: params,
663
+ data: params
664
+ })
665
+ .then((res) => {
666
+ if (res.rCode === 0) {
667
+ this.selections = JSON.parse(JSON.stringify(res.results));
668
+ this.checkboxs = JSON.parse(JSON.stringify(res.results)) || [];
669
+ }
670
+ })
671
+ .catch((err) => {
672
+ if (err.message && err.message !== 'canceled') {
673
+ this.$message.error(err.message);
674
+ }
675
+ });
676
+ } else {
677
+ this.selections = this.selection;
678
+ this.checkboxs = this.selection || [];
679
+ }
680
+ }
681
+ },
682
+ getTreeData(url, params, id) {
683
+ let data = util.extend(
684
+ {},
685
+ params,
686
+ this.param[this.activeName] ? this.param[this.activeName] : this.param
687
+ );
688
+ if (id !== undefined) {
689
+ data.id = id;
690
+ }
691
+ util
692
+ .ajax({ method: this.method, url: url, params: data, data: data })
693
+ .then((res) => {
694
+ if (res.rCode === 0) {
695
+ this.loading = false;
696
+ if (!Object.prototype.hasOwnProperty.call(params, 'seachkey')) {
697
+ this.$set(
698
+ this.defaults[this.activeName],
699
+ 'data',
700
+ JSON.parse(JSON.stringify(res.results))
701
+ );
702
+ }
703
+ if (res.results.length && res.results[0].name === '无搜索数据') {
704
+ this.$set(this.trees[this.activeName], 'data', null);
705
+ } else {
706
+ this.$set(
707
+ this.trees[this.activeName],
708
+ 'data',
709
+ JSON.parse(JSON.stringify(res.results))
710
+ );
711
+ }
712
+ }
713
+ })
714
+ .catch((err) => {
715
+ if (err.message && err.message !== 'canceled') {
716
+ this.$message.error(err.message);
717
+ }
718
+ });
719
+ },
720
+ loadsub(data, node, flag) {
721
+ node;
722
+ if (flag) {
723
+ if (data.selection === undefined || data.selection.length === 0) {
724
+ this.checkAll = false;
725
+ let params = util.extend(
726
+ {},
727
+ this.param[this.activeName]
728
+ ? this.param[this.activeName]
729
+ : this.param
730
+ );
731
+ params.type = this.activeName;
732
+ params.mid = data.id;
733
+ if (this.activeName === 'enterprise') {
734
+ params.querymode = this.selectValue;
735
+ if (this.selectValue === '2' || this.selectValue === 2) {
736
+ params.orgpath =
737
+ data.attributes && data.attributes.orgpath
738
+ ? data.attributes.orgpath
739
+ : '';
740
+ }
741
+ }
742
+ // if (this.activeName === 'department') {
743
+ // params.querymode = 0;
744
+ // }
745
+ util
746
+ .ajax({
747
+ method: this.method,
748
+ url: this.host + this.selection,
749
+ params: params,
750
+ data: params
751
+ })
752
+ .then((res) => {
753
+ if (res.rCode === 0) {
754
+ data.selection = JSON.parse(JSON.stringify(res.results));
755
+ this.$set(
756
+ this.trees[this.activeName],
757
+ 'selection',
758
+ JSON.parse(JSON.stringify(res.results))
759
+ );
760
+ this.$set(this.trees[this.activeName], 'nodeData', data);
761
+ this.nodeData = this.trees[this.activeName].nodeData;
762
+ this.checkboxs = this.trees[this.activeName].selection;
763
+ }
764
+ })
765
+ .catch((err) => {
766
+ if (err.message && err.message !== 'canceled') {
767
+ this.$message.error(err.message);
768
+ }
769
+ });
770
+ } else {
771
+ this.trees[this.activeName].selection = data.selection;
772
+ this.trees[this.activeName].nodeData = data;
773
+ this.nodeData = this.trees[this.activeName].nodeData;
774
+ this.checkboxs = this.trees[this.activeName].selection;
775
+ }
776
+ } else {
777
+ if (!this.isShowLevel3) {
778
+ data.state = '';
779
+ }
780
+ if (
781
+ data.state !== '' &&
782
+ (!data.children || data.children.length === 0)
783
+ ) {
784
+ let params = util.extend(
785
+ {},
786
+ this.newTabs[this.activeName].param,
787
+ this.param[this.activeName]
788
+ ? this.param[this.activeName]
789
+ : this.param
790
+ );
791
+ params.id = data.id;
792
+ util
793
+ .ajax({
794
+ method: this.method,
795
+ url: this.host + this.newTabs[this.activeName].url,
796
+ data: params,
797
+ params: params
798
+ })
799
+ .then((res) => {
800
+ if (res.rCode === 0) {
801
+ this.loading = false;
802
+ this.$set(
803
+ data,
804
+ 'children',
805
+ JSON.parse(JSON.stringify(res.results))
806
+ );
807
+ this.$set(
808
+ this.defaults[this.activeName],
809
+ 'data',
810
+ JSON.parse(JSON.stringify(this.trees[this.activeName].data))
811
+ );
812
+ }
813
+ })
814
+ .catch((err) => {
815
+ if (err.message && err.message !== 'canceled') {
816
+ this.$message.error(err.message);
817
+ }
818
+ });
819
+ }
820
+ }
821
+ },
822
+ searchTree(res) {
823
+ if (res) {
824
+ this.loading = true;
825
+ let params = util.extend({}, this.newTabs[this.activeName].param, {
826
+ seachkey: res
827
+ });
828
+ this.getTreeData(this.host + this.newTabs[this.activeName].url, params);
829
+ } else {
830
+ this.$set(
831
+ this.trees[this.activeName],
832
+ 'data',
833
+ this.defaults[this.activeName].data
834
+ );
835
+ }
836
+ },
837
+ handleCheckAll(res) {
838
+ if (this.checkboxs.length > 0) {
839
+ let isObject = util.isObject(this.checkboxs[0]);
840
+ if (res) {
841
+ if (this.isShowTree) {
842
+ this.nodeData.checkAll = true;
843
+ let checkeds = this.checkeds.concat(
844
+ this.checkboxs.filter((item) => {
845
+ return item.disabled !== true;
846
+ })
847
+ );
848
+ if (checkeds.length > 0) {
849
+ this.checkeds = util.arrUnique(
850
+ checkeds,
851
+ isObject ? this.valueKey : undefined
852
+ );
853
+ }
854
+ } else {
855
+ this.checkeds = this.checkboxs;
856
+ }
857
+ } else {
858
+ if (this.isShowTree) {
859
+ this.nodeData.checkAll = false;
860
+ this.checkboxs.forEach((element) => {
861
+ for (let i in this.checkeds) {
862
+ if (
863
+ (isObject &&
864
+ this.checkeds[i][this.valueKey] ===
865
+ element[this.valueKey]) ||
866
+ this.checkeds[i] === element
867
+ ) {
868
+ this.checkeds.splice(i, 1);
869
+ break;
870
+ }
871
+ }
872
+ });
873
+ } else {
874
+ this.checkeds = [];
875
+ }
876
+ }
877
+ }
878
+ },
879
+ handleSelect(res) {
880
+ if (this.nodeData) {
881
+ this.nodeData.selection = '';
882
+ this.loadsub(this.nodeData, '', true);
883
+ }
884
+ this.$emit('filtratechage', this.trees, this.activeName);
885
+ },
886
+ handleChangeSearch() {
887
+ if (this.search === '') {
888
+ if (this.isShowTree) {
889
+ this.checkboxs = this.nodeData.selection;
890
+ } else {
891
+ this.checkboxs = this.selections;
892
+ }
893
+ } else {
894
+ if (this.isShowTree) {
895
+ if (this.nodeData && this.nodeData.selection) {
896
+ let arry = [];
897
+ this.nodeData.selection.forEach((item) => {
898
+ if (util.isObject(item)) {
899
+ if (item[this.labelKey].indexOf(this.search) > -1) {
900
+ arry.push(item);
901
+ }
902
+ } else {
903
+ if (item.indexOf(this.search) > -1) {
904
+ arry.push(item);
905
+ }
906
+ }
907
+ });
908
+ this.checkboxs = arry;
909
+ }
910
+ } else {
911
+ let arry = [];
912
+ this.selections.forEach((item) => {
913
+ if (util.isObject(item)) {
914
+ if (item[this.labelKey].indexOf(this.search) > -1) {
915
+ arry.push(item);
916
+ }
917
+ } else {
918
+ if (item.indexOf(this.search) > -1) {
919
+ arry.push(item);
920
+ }
921
+ }
922
+ });
923
+ this.checkboxs = arry;
924
+ }
925
+ }
926
+ },
927
+ handleSearch() {
928
+ if (this.isShowTree) {
929
+ if (this.nodeData && this.nodeData.selection) {
930
+ if (this.search !== '') {
931
+ let arry = [];
932
+ this.nodeData.selection.forEach((item) => {
933
+ if (util.isObject(item)) {
934
+ if (item[this.labelKey].indexOf(this.search) > -1) {
935
+ arry.push(item);
936
+ }
937
+ } else {
938
+ if (item.indexOf(this.search) > -1) {
939
+ arry.push(item);
940
+ }
941
+ }
942
+ });
943
+ this.checkboxs = arry;
944
+ }
945
+ } else {
946
+ let mid = '0-0-0-0-0';
947
+ if (this.nodeData) {
948
+ mid = this.nodeData.id;
949
+ }
950
+ util
951
+ .ajax({
952
+ url: this.selection,
953
+ params: {
954
+ mid: mid,
955
+ querymode: this.selectValue,
956
+ type: this.activeName,
957
+ namelike: this.search
958
+ }
959
+ })
960
+ .then((res) => {
961
+ if (res.rCode === 0) {
962
+ this.checkboxs = JSON.parse(JSON.stringify(res.results));
963
+ }
964
+ })
965
+ .catch((err) => {
966
+ if (err.message && err.message !== 'canceled') {
967
+ this.$message.error(err.message);
968
+ }
969
+ });
970
+ }
971
+ } else {
972
+ if (this.search !== '') {
973
+ let arry = [];
974
+ this.selections.forEach((item) => {
975
+ if (util.isObject(item)) {
976
+ if (item[this.labelKey].indexOf(this.search) > -1) {
977
+ arry.push(item);
978
+ }
979
+ } else {
980
+ if (item.indexOf(this.search) > -1) {
981
+ arry.push(item);
982
+ }
983
+ }
984
+ });
985
+ this.checkboxs = arry;
986
+ }
987
+ }
988
+ },
989
+ handleClick() {
990
+ this.$emit('tabschage', this.trees, this.activeName);
991
+ },
992
+ handleChange() {},
993
+ handleConfirm() {
994
+ if (!this.checkeds || (this.multiple && this.checkeds.length === 0)) {
995
+ this.$message({
996
+ message: '请选择',
997
+ type: 'warning'
998
+ });
999
+ } else {
1000
+ this.$emit('input', this.checkeds);
1001
+ this.$emit('confirm', this.checkeds);
1002
+ }
1003
+ },
1004
+ handleCancel() {
1005
+ this.$emit('cancel', false);
1006
+ },
1007
+ handleSort(res) {
1008
+ let oldIndex = res.oldIndex;
1009
+ let newIndex = res.newIndex;
1010
+
1011
+ this.checkeds.splice(newIndex, 0, this.checkeds[oldIndex]);
1012
+ if (oldIndex > newIndex) {
1013
+ this.checkeds.splice(oldIndex + 1, 1);
1014
+ } else {
1015
+ this.checkeds.splice(oldIndex, 1);
1016
+ }
1017
+ }
1018
+ }
1019
+ };
1020
+ </script>