eoss-ui 0.5.12 → 0.5.13

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