eoss-ui 0.8.39 → 0.8.40

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