eoss-ui 0.4.28 → 0.4.30

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 (64) hide show
  1. package/lib/button-group.js +85 -80
  2. package/lib/button.js +113 -99
  3. package/lib/checkbox-group.js +80 -77
  4. package/lib/config/api.js +2 -0
  5. package/lib/data-table-form.js +80 -77
  6. package/lib/data-table.js +95 -95
  7. package/lib/date-picker.js +80 -77
  8. package/lib/dialog.js +80 -77
  9. package/lib/eoss-ui.common.js +401 -376
  10. package/lib/flow-group.js +85 -79
  11. package/lib/flow-list.js +83 -80
  12. package/lib/flow.js +173 -162
  13. package/lib/form.js +107 -104
  14. package/lib/handle-user.js +81 -78
  15. package/lib/handler.js +81 -78
  16. package/lib/{icon.js → icons.js} +10 -9
  17. package/lib/index.js +1 -1
  18. package/lib/input-number.js +80 -77
  19. package/lib/input.js +80 -77
  20. package/lib/login.js +84 -81
  21. package/lib/main.js +95 -92
  22. package/lib/mainComp.js +95 -92
  23. package/lib/nav.js +80 -77
  24. package/lib/notify.js +85 -82
  25. package/lib/page.js +80 -77
  26. package/lib/player.js +80 -77
  27. package/lib/qr-code.js +80 -77
  28. package/lib/radio-group.js +80 -77
  29. package/lib/select-ganged.js +80 -77
  30. package/lib/select.js +80 -77
  31. package/lib/selector-panel.js +98 -95
  32. package/lib/selector.js +81 -78
  33. package/lib/sizer.js +82 -79
  34. package/lib/steps.js +80 -77
  35. package/lib/switch.js +80 -77
  36. package/lib/table-form.js +91 -88
  37. package/lib/tabs.js +80 -77
  38. package/lib/theme-chalk/index.css +1 -1
  39. package/lib/tips.js +81 -78
  40. package/lib/tree-group.js +80 -77
  41. package/lib/tree.js +81 -78
  42. package/lib/upload.js +96 -93
  43. package/lib/wujie.js +80 -77
  44. package/lib/wxlogin.js +80 -77
  45. package/package.json +1 -1
  46. package/packages/button/src/main.vue +43 -32
  47. package/packages/button-group/src/main.vue +3 -1
  48. package/packages/data-table/src/column.vue +47 -46
  49. package/packages/data-table/src/main.vue +1 -6
  50. package/packages/flow/src/component/CommonOpinions.vue +19 -12
  51. package/packages/flow/src/main.vue +1 -1
  52. package/packages/flow-group/src/main.vue +3 -0
  53. package/packages/form/src/main.vue +24 -24
  54. package/packages/form/src/table.vue +6 -6
  55. package/packages/icons/index.js +5 -0
  56. package/packages/{icon → icons}/src/main.vue +2 -1
  57. package/packages/theme-chalk/lib/index.css +1 -1
  58. package/packages/theme-chalk/src/index.scss +1 -0
  59. package/src/config/api.js +12 -5
  60. package/src/index.js +4 -4
  61. package/CHANGELOG.md +0 -929
  62. package/packages/data-table/src/main copy.vue +0 -1383
  63. package/packages/icon/index.js +0 -5
  64. /package/packages/{icon → icons}/src/icon.json +0 -0
@@ -1,1383 +0,0 @@
1
- <script>
2
- import { findSysCode } from 'eoss-ui/src/config/api.js';
3
- import column from './column.vue';
4
- import sizer from './sizer.vue';
5
- import util from 'eoss-ui/src/utils/util';
6
- import bus from 'eoss-ui/src/utils/bus';
7
- export default {
8
- name: 'EsDataTable',
9
- inheritAttrs: false,
10
- components: {
11
- [column.name]: column,
12
- [sizer.name]: sizer
13
- },
14
- provide() {
15
- return {
16
- table: this,
17
- tableReload: this.reload
18
- };
19
- },
20
- inject: {
21
- elForm: {
22
- default: ''
23
- },
24
- injector: {
25
- default: ''
26
- }
27
- },
28
- props: {
29
- loading: {
30
- type: Boolean,
31
- default: false
32
- },
33
- readonly: Boolean,
34
- url: {
35
- type: String,
36
- default: ''
37
- },
38
- defaults: {
39
- type: Boolean,
40
- default: false
41
- },
42
- param: {
43
- type: Object,
44
- default() {
45
- return {};
46
- }
47
- },
48
- method: {
49
- type: String,
50
- default: 'get'
51
- },
52
- format: {
53
- type: Boolean,
54
- default: true
55
- },
56
- data: {
57
- type: Array,
58
- default() {
59
- return [];
60
- }
61
- },
62
- // 表格表单
63
- form: {
64
- type: Boolean,
65
- default: false
66
- },
67
- name: String,
68
- title: {
69
- type: String,
70
- default: ''
71
- },
72
- // 导出文件名
73
- fileName: {
74
- type: String,
75
- default: ''
76
- },
77
- // 工具栏配置
78
- toolbar: {
79
- type: [Array, Boolean],
80
- default: false
81
- },
82
- searchValue: Object,
83
- advanceValue: Object,
84
- // 是否开启序号
85
- numbers: {
86
- type: Boolean,
87
- default: false
88
- },
89
- // 是否筛选列功能
90
- filter: {
91
- type: Boolean,
92
- default: false
93
- },
94
- // 是否开启多选
95
- checkbox: {
96
- type: Boolean,
97
- default: false
98
- },
99
- selectable: Function,
100
- reserveSelection: Boolean,
101
- // 默认选中,类型为Boolean时默认全(不)选
102
- checked: {
103
- type: [Boolean, Array],
104
- default: false
105
- },
106
- sizer: {
107
- type: Boolean,
108
- default: true
109
- },
110
- // 无数据时显示的文本
111
- text: {
112
- type: String,
113
- default: ''
114
- },
115
- // 无数据时显示的文本
116
- emptyText: {
117
- type: String,
118
- default: ''
119
- },
120
- // 是否开启合计行区域
121
- total: {
122
- type: Boolean,
123
- default: false
124
- },
125
- //本地数据总条数差值
126
- lose: {
127
- type: Number,
128
- default: 0
129
- },
130
- // 合计行显示文本
131
- totalText: {
132
- type: String,
133
- default: ''
134
- },
135
- showSummary: {
136
- type: Boolean,
137
- default: false
138
- },
139
- sumText: {
140
- type: String,
141
- default: ''
142
- },
143
- // 开启分页
144
- page: {
145
- type: [Boolean, Object],
146
- default() {
147
- return false;
148
- }
149
- },
150
- // 渲染树形数据指定field
151
- treeKey: {
152
- type: String,
153
- default: ''
154
- },
155
- // 单元格配置
156
- thead: {
157
- type: [Array, String],
158
- default() {
159
- return [];
160
- }
161
- },
162
- optionData: Object,
163
- // 开启数据增加删除按钮
164
- editable: {
165
- type: Boolean,
166
- default: false
167
- },
168
- // 单元格点击事件
169
- click: {
170
- type: Boolean,
171
- default: false
172
- },
173
- totalRow: {
174
- type: Object,
175
- default() {
176
- return {};
177
- }
178
- },
179
- parseData: Function,
180
- close: Boolean,
181
- full: {
182
- type: Boolean,
183
- default: true
184
- },
185
- height: [Number, String],
186
- maxHeight: [Number, String],
187
- response: Function,
188
- minWidth: String,
189
- border: {
190
- type: Boolean,
191
- default: false
192
- },
193
- theadBorder: {
194
- type: Boolean,
195
- default: true
196
- },
197
- checkboxParseData: Function,
198
- checkboxParse: Object,
199
- display: Boolean,
200
- showFormBtn: {
201
- type: Boolean,
202
- default: true
203
- },
204
- index: {
205
- type: [Boolean, Number],
206
- default: 1
207
- },
208
- immediate: {
209
- type: Boolean,
210
- default: true
211
- }
212
- },
213
- data() {
214
- return {
215
- theadData: [],
216
- list: null,
217
- tableLoading: this.loading,
218
- tableLoadingText: '加载中...',
219
- isFirsetCheck: false,
220
- // 可修改表单的值
221
- editValue: {},
222
- restotalRow: null,
223
- showTotal: false,
224
- toolbars: [],
225
- config: {
226
- pageNum: 1,
227
- pageSize: 20,
228
- totalCount: 0
229
- },
230
- where: {},
231
- wheres: {},
232
- tableHeight: 'auto',
233
- styles: {},
234
- selected: null,
235
- options: {}
236
- };
237
- },
238
- computed: {
239
- theads: {
240
- get() {
241
- return this.theadData.length ? this.theadData : this.thead;
242
- },
243
- set(val) {
244
- return val;
245
- }
246
- },
247
- datas: {
248
- get() {
249
- if (this.list) {
250
- return this.list;
251
- }
252
- if (
253
- this.page &&
254
- this.data &&
255
- this.data.length &&
256
- this.config.totalCount < this.data.length + 1
257
- ) {
258
- this.config.totalCount = this.data.length - this.lose;
259
- return this.data.filter((item, index) => {
260
- return (
261
- index > (this.config.pageNum - 1) * this.config.pageSize - 1 &&
262
- index < this.config.pageNum * this.config.pageSize
263
- );
264
- });
265
- }
266
- return this.data;
267
- },
268
- set(val) {
269
- return val;
270
- }
271
- },
272
- showToolbar() {
273
- if (this.readonly) {
274
- return false;
275
- }
276
- if (typeof this.toolbar === 'boolean') {
277
- if (this.toolbar) {
278
- this.toolbars = [
279
- {
280
- type: 'search',
281
- contents: [
282
- {
283
- type: 'text',
284
- name: 'keyword',
285
- placeholder: '请输入关键字'
286
- }
287
- ]
288
- }
289
- ];
290
- }
291
- return this.toolbar;
292
- } else {
293
- this.toolbars = this.toolbar;
294
- return true;
295
- }
296
- },
297
- optionDatas: {
298
- get() {
299
- return this.optionData
300
- ? { ...this.optionData, ...this.options }
301
- : this.options;
302
- },
303
- set(val) {
304
- return val;
305
- }
306
- }
307
- },
308
- watch: {
309
- checked(newVal) {
310
- this.checkSelect(newVal);
311
- },
312
- thead: {
313
- immediate: true,
314
- handler(val) {
315
- if (typeof val === 'string') {
316
- this.getTheads();
317
- }
318
- }
319
- },
320
- theads: {
321
- immediate: true,
322
- handler(val) {
323
- this.chekOpenTotalArea();
324
- if (val && val.length) {
325
- this.getOptions(val);
326
- }
327
- }
328
- },
329
- param: {
330
- deep: true,
331
- handler(val) {
332
- this.getTableData();
333
- }
334
- },
335
- page: {
336
- immediate: true,
337
- deep: true,
338
- handler(val) {
339
- this.config = util.extend({}, this.config, this.page);
340
- }
341
- },
342
- height: {
343
- immediate: true,
344
- handler(val) {
345
- if (val) {
346
- this.tableHeight = val;
347
- }
348
- }
349
- },
350
- maxHeight: {
351
- immediate: true,
352
- handler(val) {
353
- if (val && this.height === undefined) {
354
- this.tableHeight = val;
355
- }
356
- }
357
- },
358
- display(val) {
359
- if (val) {
360
- this.resetHeight();
361
- }
362
- }
363
- },
364
- created() {
365
- this.immediate && this.getTableData();
366
- },
367
- mounted() {
368
- this.checkSelect(this.checked);
369
- this.resetHeight();
370
- },
371
- methods: {
372
- getOptions(res) {
373
- res.forEach(item => {
374
- if (item.sysCode || item.url) {
375
- let params = util.extend(
376
- {},
377
- item.sysCode ? { sysAppCode: item.sysCode } : {},
378
- item.param ? item.param : {}
379
- );
380
- util
381
- .ajax({
382
- url: item.sysCode ? findSysCode : item.url,
383
- method: this.method,
384
- params: params,
385
- data: params
386
- })
387
- .then(res => {
388
- if (res.rCode === 0) {
389
- if (item.type == 'ganged') {
390
- this.$set(this.options, item.field || item.prop, [
391
- JSON.parse(JSON.stringify(res.results))
392
- ]);
393
- } else {
394
- this.$set(
395
- this.options,
396
- item.field || item.prop,
397
- JSON.parse(JSON.stringify(res.results))
398
- );
399
- }
400
- } else {
401
- let msg = res.msg || '系统错误,请联系管理员!';
402
- this.$message.error(msg);
403
- }
404
- })
405
- .catch(err => {
406
- if (err.message && err.message !== 'canceled') {
407
- this.$message.error(err.message);
408
- }
409
- });
410
- } else {
411
- if (item.childHead && item.childHead.length) {
412
- this.getOptions(item.childHead);
413
- }
414
- if (item.children && item.children.length) {
415
- this.getOptions(item.children);
416
- }
417
- }
418
- });
419
- },
420
- checkObject(item) {
421
- return util.getObjectType(item) === 'object';
422
- },
423
- chekOpenTotalArea() {
424
- if (this.total || this.showSummary) {
425
- this.showTotal = true;
426
- return;
427
- }
428
- const arr = JSON.parse(JSON.stringify(this.thead));
429
- arr.forEach(item => {
430
- if (item.total) {
431
- this.showTotal = true;
432
- }
433
- });
434
- },
435
- rowClick(row, column, event) {
436
- this.$emit('click', row, column, event);
437
- this.$emit('row-click', row, column, event);
438
- },
439
- handleClickAddData(scope) {
440
- const data = JSON.parse(JSON.stringify(scope.row));
441
- const index = scope.$index + 1;
442
- this.datas.splice(index, 0, data);
443
- this.$emit('dataChange', 'add', data);
444
- this.$emit('btnClick', {
445
- event: 'addRow',
446
- row: data,
447
- index: index,
448
- data: data
449
- });
450
- },
451
- handleClickDeleteData(scope) {
452
- const data = JSON.parse(JSON.stringify(scope.row));
453
- const index = scope.$index;
454
- this.datas.splice(index, 1);
455
- this.$emit('dataChange', 'delete', data);
456
- this.$emit('btnClick', {
457
- event: 'deleteRow',
458
- row: data,
459
- index: index,
460
- data: data
461
- });
462
- },
463
- checkSelect(newVal) {
464
- if (!this.isFirsetCheck && newVal) {
465
- if (util.getObjectType(newVal) === 'array') {
466
- newVal.forEach(row => {
467
- this.$refs.oaTable.toggleRowSelection(row, true);
468
- });
469
- } else if (newVal === true) {
470
- this.toggleAllSelection();
471
- }
472
- this.isFirsetCheck = true;
473
- }
474
- },
475
- getTheads() {
476
- util
477
- .ajax({
478
- url: this.thead,
479
- method: this.method,
480
- format: this.format,
481
- params: this.param,
482
- data: this.param
483
- })
484
- .then(res => {
485
- if (res.rCode === 0) {
486
- let results = res.results;
487
- if (Array.isArray(results)) {
488
- this.theadData = results;
489
- } else {
490
- this.theadData = results.theadData || [];
491
- this.list = results.data || results.records || [];
492
- this.config.totalCount =
493
- results.count || results.total || results.totalCount;
494
- }
495
- } else {
496
- this.theadData = [];
497
- let msg = res.msg || '系统错误,请联系管理员!';
498
- this.$message.error(msg);
499
- }
500
- this.$emit('success', res);
501
- })
502
- .catch(err => {
503
- if (err.message && err.message !== 'canceled') {
504
- this.$message.error(err.message);
505
- }
506
- });
507
- },
508
- getTableData(res) {
509
- let where;
510
- let first;
511
- if (res) {
512
- where = res.where;
513
- first = res.first;
514
- }
515
- if (!this.url) {
516
- return;
517
- }
518
- if (first !== false) {
519
- this.config.pageNum = 1;
520
- }
521
- this.tableLoadingText = '加载中...';
522
- let reqData = util.extend({}, this.param, {
523
- pageNum: this.config.pageNum,
524
- pageSize: this.config.pageSize
525
- });
526
- if (where) {
527
- reqData = util.extend({}, reqData, where);
528
- }
529
- this.tableLoading = true;
530
- util
531
- .ajax({
532
- url: this.url,
533
- method: this.method,
534
- format: this.format,
535
- params: reqData,
536
- data: reqData
537
- })
538
- .then(res => {
539
- this.tableLoading = false;
540
- if (res.rCode === 0 || res.status === 'success') {
541
- let results =
542
- this.parseData !== undefined
543
- ? this.parseData(res.results || res.data || res)
544
- : res.results || res.data;
545
- this.list = results.data || results.records || results.list || [];
546
- this.config.totalCount =
547
- results.count || results.total || results.totalCount;
548
- } else {
549
- this.list = [];
550
- let msg = res.msg || '系统错误,请联系管理员!';
551
- this.$message.error(msg);
552
- }
553
- this.$emit('success', res);
554
- })
555
- .catch(err => {
556
- if (err.message && err.message !== 'canceled') {
557
- this.$message.error(err.message);
558
- }
559
- this.tableLoading = false;
560
- });
561
- },
562
- selectionChange(data) {
563
- this.selected = JSON.parse(JSON.stringify(data));
564
- this.$emit('selection-change', data);
565
- },
566
- clearSelection() {
567
- this.$refs.oaTable.clearSelection();
568
- },
569
- toggleRowSelection(row, selected) {
570
- this.$refs.oaTable.toggleRowSelection(row, selected);
571
- },
572
- toggleAllSelection() {
573
- this.$refs.oaTable.toggleAllSelection();
574
- },
575
- toggleRowExpansion(row, expanded) {
576
- this.$refs.oaTable.toggleRowExpansion(row, expanded);
577
- },
578
- setCurrentRow(row) {
579
- this.$refs.oaTable.setCurrentRow(row);
580
- },
581
-
582
- clearSort() {
583
- this.$refs.oaTable.clearSort();
584
- },
585
- clearFilter(columnKey) {
586
- this.$refs.oaTable.clearFilter(columnKey);
587
- },
588
- doLayout() {
589
- this.$refs.oaTable.doLayout();
590
- },
591
- sort(prop, order) {
592
- this.$refs.oaTable.sort(prop, order);
593
- },
594
- formBlur(data) {
595
- this.$emit('blur', data, this.datas);
596
- },
597
- formFocus(data) {
598
- this.$emit('focus', data, this.datas);
599
- },
600
- formChange(data) {
601
- this.$emit('edit', data, this.datas);
602
- this.$emit('change', data, this.datas);
603
- },
604
- handleAjax(handle, row) {
605
- this.changeLoading(true, `${handle.text}中...`);
606
- let params = handle.param || {};
607
- if (handle.syncKeys) {
608
- if (typeof handle.syncKeys === 'string') {
609
- params[handle.syncKeys] = row[handle.syncKeys];
610
- } else if (Array.isArray(handle.syncKeys)) {
611
- for (let i in handle.syncKeys) {
612
- if (Array.isArray(row)) {
613
- let param = row.map(item => {
614
- return item[handle.syncKeys[i]];
615
- });
616
- params[handle.syncKeys[i]] = param.join(',');
617
- } else {
618
- params[handle.syncKeys[i]] = row[handle.syncKeys[i]];
619
- }
620
- }
621
- } else {
622
- for (let i in handle.syncKeys) {
623
- if (Array.isArray(row)) {
624
- let param = row.map(item => {
625
- return item[handle.syncKeys[i]];
626
- });
627
- params[i] = param.join(',');
628
- } else {
629
- params[i] = row[handle.syncKeys[i]];
630
- }
631
- }
632
- }
633
- } else {
634
- if (Array.isArray(row)) {
635
- let param = row.map(item => {
636
- return item.id;
637
- });
638
- params.id = param.join(',');
639
- } else {
640
- params.id = row.id;
641
- }
642
- }
643
- let keys = Object.keys(params);
644
- util
645
- .ajax({
646
- url: handle.action,
647
- data:
648
- keys.length == 1 && handle.format === false
649
- ? params[keys[0]].split(',')
650
- : params,
651
- params:
652
- keys.length == 1 && handle.format === false
653
- ? params[keys[0]].split(',')
654
- : params,
655
- method: handle.method,
656
- format: handle.format
657
- })
658
- .then(res => {
659
- this.changeLoading(false);
660
- if (res.rCode === 0) {
661
- this.$message({
662
- message: `${handle.text}成功`,
663
- duration: 2000,
664
- type: 'success',
665
- onClose: () => {
666
- let first = Object.prototype.hasOwnProperty.call(
667
- handle,
668
- 'first'
669
- )
670
- ? handle.first
671
- : false;
672
- let reload = handle.reload || true;
673
- if (reload) {
674
- this.reload({}, first);
675
- }
676
- }
677
- });
678
- } else {
679
- this.$message.error(
680
- res.msg || `${handle.text}失败,请联系管理员!`
681
- );
682
- }
683
- })
684
- .catch(err => {
685
- this.changeLoading(false);
686
- if (err.message && err.message !== 'canceled') {
687
- this.$message.error(err.message);
688
- }
689
- });
690
- },
691
- checkParse(data, parse) {
692
- if (Array.isArray(data)) {
693
- return data.map(items => {
694
- let item = JSON.parse(JSON.stringify(items));
695
- let obj = {};
696
- for (let i in parse) {
697
- obj[i] = item[parse[i]];
698
- delete item[parse[i]];
699
- }
700
- return { ...obj, ...item };
701
- });
702
- }
703
- let item = JSON.parse(JSON.stringify(data));
704
- let obj = {};
705
- for (let i in parse) {
706
- obj[i] = item[parse[i]];
707
- delete item[parse[i]];
708
- }
709
- return { ...obj, ...item };
710
- },
711
- handleClick(res) {
712
- let { row, handle } = res;
713
- let rows;
714
- if (handle.checkbox) {
715
- if (!this.selected || !this.selected.length) {
716
- this.$alert('请选择数据', '提示', { type: 'warning' });
717
- return;
718
- } else {
719
- row = this.selected;
720
- }
721
- }
722
- if (this.checkboxParseData) {
723
- rows = this.checkboxParseData(JSON.parse(JSON.stringify(row)));
724
- } else if (this.checkboxParse) {
725
- rows = this.checkParse(row, this.checkboxParse);
726
- } else if (handle.checkboxParse) {
727
- rows = this.checkParse(row, handle.checkboxParse);
728
- } else if (row) {
729
- rows = JSON.parse(JSON.stringify(row));
730
- }
731
- let thead = this.thead;
732
- if (this.$refs.oaTable) {
733
- thead = this.$refs.oaTable.getThead();
734
- }
735
- if (handle.action) {
736
- let isConfirm = handle.confirm || true;
737
- if (isConfirm) {
738
- let msg = handle.field ? row[handle.field] : '';
739
- this.$confirm(`确定要${handle.text}${msg}吗`, '提示', {
740
- confirmButtonText: '确定',
741
- cancelButtonText: '取消',
742
- type: 'warning'
743
- })
744
- .then(() => {
745
- this.handleAjax(handle, rows);
746
- })
747
- .catch(() => {});
748
- } else {
749
- this.handleAjax(handle, rows);
750
- }
751
- } else if (handle.event) {
752
- if (typeof handle.event === 'function') {
753
- handle.event({
754
- ele: this,
755
- thead: thead,
756
- data: this.datas,
757
- selected: rows,
758
- ...res
759
- });
760
- } else if (
761
- handle.event === 'add' ||
762
- handle.event === 'edit' ||
763
- handle.event === 'look'
764
- ) {
765
- let changes = {
766
- event: handle.event,
767
- title: handle.title || handle.text,
768
- value: handle.event === 'add' ? {} : rows,
769
- readonly: handle.event === 'look',
770
- actionType: handle.actionType
771
- ? handle.actionType
772
- : handle.event === 'add'
773
- ? 'save'
774
- : 'update',
775
- visible: true
776
- };
777
- if (handle.dialog) {
778
- let dialog;
779
- for (let i = 0; i < this.$children.length; i++) {
780
- let child = this.$children[i];
781
- if (child.$refs[handle.dialog]) {
782
- dialog = child.$refs[handle.dialog];
783
- break;
784
- }
785
- }
786
- dialog.setAttrs(changes);
787
- }
788
- this.injector && this.injector.handleChangeData(changes);
789
- if (handle.busEvent) {
790
- bus.$emit(handle.busEvent, changes);
791
- }
792
- }
793
- } else if (handle.changeData) {
794
- let changeData = {};
795
- if (Array.isArray(handle.changeData)) {
796
- handle.changeData.forEach(item => {
797
- if (util.isObject(item)) {
798
- for (let i in item) {
799
- if (typeof item[i] === 'boolean') {
800
- changeData[i] = item[i];
801
- } else {
802
- changeData[i] = handle[item[i]] || item[i];
803
- }
804
- }
805
- } else {
806
- changeData[item] =
807
- handle[item] || (Array.isArray(rows) ? rows : rows[item]);
808
- }
809
- });
810
- } else {
811
- for (let i in handle.changeData) {
812
- let item = handle.changeData[i];
813
- if (util.isObject(item)) {
814
- let obj = {};
815
- for (let e in item) {
816
- obj[e] =
817
- handle[item[e]] ||
818
- (Array.isArray(rows) ? rows : rows[item[e]]);
819
- }
820
- changeData[i] = obj;
821
- } else {
822
- if (typeof item === 'boolean') {
823
- changeData[i] = item;
824
- } else {
825
- changeData[i] =
826
- handle[item] || (Array.isArray(rows) ? rows : rows[item]);
827
- }
828
- }
829
- }
830
- }
831
- if (handle.actionType) {
832
- changeData['actionType'] = handle.actionType;
833
- }
834
- this.injector && this.injector.handleChangeData(changeData);
835
- if (handle.busEvent) {
836
- bus.$emit(handle.busEvent, changes);
837
- }
838
- } else {
839
- if (handle.exportXls) {
840
- let text = '操作';
841
- if (
842
- this.thead[this.thead.length - 1] &&
843
- this.thead[this.thead.length - 1].type === 'handle'
844
- ) {
845
- text = this.thead[this.thead.length - 1].title;
846
- }
847
- thead = thead.map(item => {
848
- return item.filter(ele => {
849
- return ele.label !== text && ele.label;
850
- });
851
- });
852
- util.exportXls({
853
- thead: thead,
854
- data: this.datas,
855
- name: this.fileName
856
- });
857
- }
858
- this.$emit('btnClick', res, this.datas, thead, rows);
859
- this.$emit('btn-click', res, this.datas, thead, rows);
860
- }
861
- },
862
- sizeChange(res) {
863
- this.config.pageSize = res;
864
- this.config.pageNum = 1;
865
- this.$emit('page-size-change', res);
866
- if (this.url) {
867
- this.getTableData({ where: this.wheres, first: false });
868
- }
869
- },
870
- currentChange(res) {
871
- this.config.pageNum = res;
872
- this.$emit('page-current-change', res);
873
- if (this.url) {
874
- this.getTableData({ where: this.wheres, first: false });
875
- }
876
- },
877
- preClick(res) {
878
- this.config.pageNum = res;
879
- this.$emit('prev', res);
880
- },
881
- nextClick(res) {
882
- this.config.pageNum = res;
883
- this.$emit('next', res);
884
- },
885
- hanleSearch(data) {
886
- this.wheres = data;
887
- if (this.url) {
888
- if (this.response !== undefined) {
889
- this.getTableData({
890
- where: this.response({
891
- type: 'search',
892
- data: JSON.parse(JSON.stringify(data))
893
- })
894
- });
895
- } else {
896
- this.getTableData({ where: this.wheres });
897
- }
898
- }
899
- this.$emit('search', data);
900
- },
901
- hanleReset() {
902
- if (this.url) {
903
- this.where = {};
904
- this.getTableData();
905
- }
906
- this.$emit('reset');
907
- },
908
- hanleSubmit({ data, show }) {
909
- this.wheres = data;
910
- if (this.url) {
911
- if (this.response !== undefined) {
912
- this.getTableData({
913
- where: this.response({
914
- type: 'filter',
915
- data: JSON.parse(JSON.stringify(data))
916
- })
917
- });
918
- } else {
919
- this.getTableData({ where: this.wheres });
920
- }
921
- }
922
- this.$emit('submit', { data, show });
923
- },
924
- hanleCancel() {
925
- if (this.url && JSON.stringify(this.wheres) !== '{}') {
926
- this.wheres = {};
927
- this.getTableData();
928
- }
929
- this.$emit('cancel');
930
- },
931
- handleTabs({ item, index }) {
932
- if (this.url) {
933
- this.getTableData({ where: item });
934
- }
935
- this.$emit('tabs', { item, index });
936
- },
937
- reload(obj, first = false) {
938
- if (obj && obj.config) {
939
- this.config = util.extend({}, this.config, obj.config);
940
- }
941
- if (this.url) {
942
- this.getTableData({ where: obj && obj.where ? obj.where : {}, first });
943
- }
944
- },
945
- resetHeight() {
946
- this.$nextTick(() => {
947
- if (this.full && !this.height && !this.maxHeight) {
948
- let height =
949
- this.$el.parentNode.offsetHeight -
950
- parseInt(util.getStyle(this.$el.parentNode, 'paddingTop'), 10) -
951
- parseInt(util.getStyle(this.$el.parentNode, 'paddingBottom'), 10);
952
- for (let i = 0; i < this.$el.parentNode.childNodes.length; i++) {
953
- let ele = this.$el.parentNode.childNodes[i];
954
- if (ele !== this.$el) {
955
- height -= ele.offsetHeight === undefined ? 0 : ele.offsetHeight;
956
- }
957
- }
958
- for (let i = 0; i < this.$el.childNodes.length; i++) {
959
- let ele = this.$el.childNodes[i];
960
- if (ele !== this.$refs.esTableContent) {
961
- height -= ele.offsetHeight === undefined ? 0 : ele.offsetHeight;
962
- }
963
- }
964
- this.styles = { height: height + 'px' };
965
- const loadingDom = this.$refs.esTableContent.querySelector(
966
- '.el-loading-mask'
967
- );
968
- for (
969
- let i = 0;
970
- i < this.$refs.esTableContent.childNodes.length;
971
- i++
972
- ) {
973
- let ele = this.$refs.esTableContent.childNodes[i];
974
- if (
975
- ele !== this.$refs.oaTable.$el &&
976
- (!loadingDom || ele !== loadingDom)
977
- ) {
978
- height -= ele.offsetHeight === undefined ? 0 : ele.offsetHeight;
979
- }
980
- }
981
- let pt = parseInt(
982
- util.getStyle(this.$refs.esTableContent, 'paddingTop'),
983
- 10
984
- );
985
- let pb = parseInt(
986
- util.getStyle(this.$refs.esTableContent, 'paddingBottom'),
987
- 10
988
- );
989
- this.tableHeight = height - pt - pb + (this.page ? 2 : 1) + 'px';
990
- }
991
- });
992
- },
993
- validate(callback) {
994
- let form = this.elForm || this.$refs.esTableForm;
995
- form.validate(valid => {
996
- callback(valid);
997
- });
998
- },
999
- getChildrens(h, childHead, i) {
1000
- let doms = [];
1001
- childHead.forEach((item, index) => {
1002
- if (item.hide !== true) {
1003
- let childs = [];
1004
- if (item.childHead && item.childHead.length) {
1005
- childs = childs.concat(this.getChildrens(h, item.childHead, index));
1006
- }
1007
- if (item.children && item.children.length) {
1008
- childs = childs.concat(this.getChildrens(h, item.children, index));
1009
- }
1010
- doms.push(
1011
- h(
1012
- 'column',
1013
- {
1014
- props: {
1015
- name: this.name,
1016
- item: item,
1017
- width: item.width,
1018
- index: 1000 + i * 100 + index,
1019
- readonly: this.readonly,
1020
- optionData: this.optionDatas,
1021
- form: this.form,
1022
- minWidth: this.minWidth
1023
- },
1024
- key: `${i}_${index}`,
1025
- on: {
1026
- handleClick: this.handleClick,
1027
- formBlur: this.formBlur,
1028
- formFocus: this.formFocus,
1029
- formChange: this.formChange
1030
- }
1031
- },
1032
- childs
1033
- )
1034
- );
1035
- }
1036
- });
1037
- return doms;
1038
- },
1039
- changeLoading(show, text) {
1040
- this.tableLoading = show;
1041
- if (text) {
1042
- this.tableLoadingText = text;
1043
- }
1044
- },
1045
- handleFilterColumn() {
1046
- this.$refs.sizer.show();
1047
- },
1048
- mergeThead(res) {
1049
- this.theadData = res;
1050
- this.$forceUpdate();
1051
- }
1052
- },
1053
- render(h) {
1054
- let doms = [];
1055
- let icon = false;
1056
- if (this.sizer) {
1057
- icon = 'es-icon-biao';
1058
- }
1059
- if (this.form && this.elForm == '') {
1060
- icon = false;
1061
- }
1062
- if (this.showToolbar) {
1063
- doms.push(
1064
- h('es-toolbar', {
1065
- props: {
1066
- contents: this.toolbars,
1067
- close: this.close,
1068
- callBack: this.resetHeight,
1069
- showFormBtn: this.showFormBtn,
1070
- searchValue: this.searchValue,
1071
- advanceValue: this.advanceValue
1072
- },
1073
- on: {
1074
- click: this.handleClick,
1075
- search: this.hanleSearch,
1076
- submit: this.hanleSubmit,
1077
- tabs: this.handleTabs,
1078
- reset: this.hanleReset,
1079
- cancel: this.hanleCancel
1080
- }
1081
- })
1082
- );
1083
- }
1084
- if (this.title) {
1085
- doms.push(
1086
- h('p', {
1087
- class: 'es-table-title',
1088
- domProps: {
1089
- innerText: this.title
1090
- }
1091
- })
1092
- );
1093
- }
1094
- let dom = [];
1095
- if (this.$slots.prepend) {
1096
- dom.push(this.$slots.prepend);
1097
- }
1098
- if (this.$slots.default) {
1099
- dom.push(this.$slots.default);
1100
- }
1101
- // 开启多选
1102
- if (this.checkbox) {
1103
- dom.push(
1104
- h('el-table-column', {
1105
- props: {
1106
- type: 'selection',
1107
- width: '55',
1108
- align: 'center',
1109
- fixed: 'left',
1110
- selectable: this.selectable,
1111
- reserveSelection: this.reserveSelection,
1112
- filterIcon: icon
1113
- }
1114
- })
1115
- );
1116
- icon = false;
1117
- }
1118
- // 开启索引
1119
- if (this.numbers) {
1120
- dom.push(
1121
- h('el-table-column', {
1122
- props: {
1123
- type: 'index',
1124
- label: '序号',
1125
- width: '70',
1126
- align: 'center',
1127
- fixed: 'left',
1128
- index:
1129
- this.index === true
1130
- ? (this.config.pageNum - 1) * this.config.pageSize + 1
1131
- : this.index === false
1132
- ? 1
1133
- : this.index,
1134
- filterIcon: icon
1135
- }
1136
- })
1137
- );
1138
- icon = false;
1139
- }
1140
- this.theads.forEach((items, indexs) => {
1141
- if (
1142
- items.type &&
1143
- (items.type === 'selection' || items.type === 'index')
1144
- ) {
1145
- if (items.type === 'index') {
1146
- dom.push(
1147
- h('el-table-column', {
1148
- props: util.extend(
1149
- {},
1150
- {
1151
- type: 'index',
1152
- label: '序号',
1153
- width: '70',
1154
- align: 'center',
1155
- fixed: 'left',
1156
- index:
1157
- this.index === true
1158
- ? (this.config.pageNum - 1) * this.config.pageSize + 1
1159
- : this.index === false
1160
- ? 1
1161
- : this.index,
1162
- filterIcon: icon
1163
- },
1164
- items
1165
- ),
1166
- key: indexs
1167
- })
1168
- );
1169
- icon = false;
1170
- } else {
1171
- dom.push(
1172
- h('el-table-column', {
1173
- props: util.extend(
1174
- {},
1175
- {
1176
- type: 'selection',
1177
- width: '55',
1178
- align: 'center',
1179
- fixed: 'left',
1180
- filterIcon: icon
1181
- },
1182
- items
1183
- ),
1184
- key: indexs
1185
- })
1186
- );
1187
- icon = false;
1188
- }
1189
- } else if (items.hide !== true) {
1190
- let tds = [];
1191
- if (items.childHead && items.childHead.length) {
1192
- tds = tds.concat(this.getChildrens(h, items.childHead, indexs));
1193
- }
1194
- if (items.children && items.children.length) {
1195
- tds = tds.concat(this.getChildrens(h, items.children, indexs));
1196
- }
1197
- dom.push(
1198
- h(
1199
- 'column',
1200
- {
1201
- props: {
1202
- name: this.name,
1203
- item: items,
1204
- width: items.width,
1205
- index: indexs,
1206
- readonly: this.readonly,
1207
- optionData: this.optionDatas,
1208
- form: this.form,
1209
- minWidth: this.minWidth,
1210
- filterIcon: icon
1211
- },
1212
- on: {
1213
- handleClick: this.handleClick,
1214
- formBlur: this.formBlur,
1215
- formFocus: this.formFocus,
1216
- formChange: this.formChange
1217
- },
1218
- key: indexs
1219
- },
1220
- tds
1221
- )
1222
- );
1223
- icon = false;
1224
- }
1225
- });
1226
- if (this.editable && !this.readonly) {
1227
- dom.push(
1228
- h('el-table-column', {
1229
- props: {
1230
- width: '80',
1231
- type: 'handle',
1232
- align: 'center',
1233
- label: '操作',
1234
- total: false
1235
- },
1236
- class: 'eoss-ui-eidt-column',
1237
- scopedSlots: {
1238
- default: props => {
1239
- let scopeDom = [];
1240
- if (!props.row.cantAdd) {
1241
- scopeDom.push(
1242
- h(
1243
- 'el-button',
1244
- {
1245
- props: {
1246
- type: 'text'
1247
- },
1248
- on: {
1249
- click: () => {
1250
- this.handleClickAddData(props);
1251
- }
1252
- }
1253
- },
1254
- [h('i', { class: 'el-icon-circle-plus-outline' })]
1255
- )
1256
- );
1257
- }
1258
- if (!props.row.cantDelete) {
1259
- scopeDom.push(
1260
- h(
1261
- 'el-button',
1262
- {
1263
- props: {
1264
- type: 'text'
1265
- },
1266
- on: {
1267
- click: () => {
1268
- this.handleClickDeleteData(props);
1269
- }
1270
- }
1271
- },
1272
- [h('i', { class: 'el-icon-remove-outline' })]
1273
- )
1274
- );
1275
- }
1276
- return scopeDom;
1277
- }
1278
- }
1279
- })
1280
- );
1281
- }
1282
- if (this.$slots.append) {
1283
- dom.push(this.$slots.append);
1284
- }
1285
- let tableContent = [];
1286
- tableContent.push(
1287
- h(
1288
- 'el-table',
1289
- {
1290
- props: {
1291
- ...this.$attrs,
1292
- data: this.datas,
1293
- emptyText: this.text || this.emptyText,
1294
- showSummary: this.showTotal,
1295
- sumText: this.sumText || this.totalText,
1296
- totalRow: this.restotalRow || this.totalRow,
1297
- height: this.tableHeight !== 'auto' ? this.tableHeight : undefined,
1298
- //scrollbar: this.tableHeight !== 'auto',
1299
- border: this.border
1300
- },
1301
- on: {
1302
- ...this.$listeners,
1303
- 'row-click': this.rowClick,
1304
- 'selection-change': this.selectionChange,
1305
- 'filter-column': this.handleFilterColumn
1306
- },
1307
- class: 'es-table' + (this.theadBorder ? ' es-thead-border' : ''),
1308
- ref: 'oaTable'
1309
- },
1310
- dom
1311
- )
1312
- );
1313
- if (this.page) {
1314
- tableContent.push(
1315
- h('es-pagination', {
1316
- attrs: {
1317
- ...this.config
1318
- },
1319
- class: 'es-table-page',
1320
- style: { 'text-align': this.page.position || 'center' },
1321
- on: {
1322
- change: this.sizeChange,
1323
- current: this.currentChange,
1324
- prev: this.preClick,
1325
- next: this.nextClick
1326
- }
1327
- })
1328
- );
1329
- }
1330
- doms.push(
1331
- h(
1332
- 'div',
1333
- {
1334
- style: this.styles,
1335
- class: 'es-data-table-content',
1336
- ref: 'esTableContent'
1337
- },
1338
- tableContent
1339
- )
1340
- );
1341
- if (this.sizer) {
1342
- doms.push(
1343
- h('sizer', {
1344
- props: {
1345
- data: this.theads
1346
- },
1347
- ref: 'sizer'
1348
- })
1349
- );
1350
- }
1351
- if (this.$slots.dialog) {
1352
- doms.push(this.$slots.dialog);
1353
- }
1354
- let tag = 'div';
1355
- let ref = '';
1356
- if (this.form && this.elForm == '') {
1357
- tag = 'el-form';
1358
- ref = 'esTableForm';
1359
- }
1360
- return h(
1361
- tag,
1362
- {
1363
- props: {
1364
- model: this.datas,
1365
- labelWidth: '0'
1366
- },
1367
- ref: ref,
1368
- class: 'es-data-table',
1369
- attrs: {
1370
- 'element-loading-text': this.tableLoadingText
1371
- },
1372
- directives: [
1373
- {
1374
- name: 'loading',
1375
- value: this.tableLoading
1376
- }
1377
- ]
1378
- },
1379
- doms
1380
- );
1381
- }
1382
- };
1383
- </script>