eoss-ui 0.6.20 → 0.6.22

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 (100) hide show
  1. package/lib/eoss-ui.common.js +439 -420
  2. package/lib/flow.js +118 -118
  3. package/lib/form.js +3 -3
  4. package/lib/index.js +1 -1
  5. package/lib/login.js +69 -60
  6. package/lib/main.js +220 -210
  7. package/lib/qr-code.js +13 -13
  8. package/lib/theme-chalk/index.css +1 -1
  9. package/lib/theme-chalk/login.css +1 -1
  10. package/lib/theme-chalk/selector.css +1 -1
  11. package/package.json +157 -157
  12. package/packages/.DS_Store +0 -0
  13. package/packages/button/src/main.vue +418 -418
  14. package/packages/button-group/src/main.vue +298 -298
  15. package/packages/checkbox-group/.DS_Store +0 -0
  16. package/packages/checkbox-group/src/main.vue +333 -333
  17. package/packages/clients/src/main.vue +144 -144
  18. package/packages/data-table/.DS_Store +0 -0
  19. package/packages/data-table/src/children.vue +39 -39
  20. package/packages/data-table/src/column.vue +983 -983
  21. package/packages/data-table/src/main.vue +1812 -1812
  22. package/packages/data-table/src/sizer.vue +195 -195
  23. package/packages/date-picker/src/main.vue +236 -236
  24. package/packages/dialog/.DS_Store +0 -0
  25. package/packages/flow/src/main.vue +2731 -2731
  26. package/packages/flow-group/src/main.vue +684 -684
  27. package/packages/form/src/main.vue +3582 -3582
  28. package/packages/form/src/table.vue +1420 -1420
  29. package/packages/handle-user/src/main.vue +134 -134
  30. package/packages/handler/.DS_Store +0 -0
  31. package/packages/handler/src/main.vue +374 -374
  32. package/packages/icon/src/main.vue +101 -101
  33. package/packages/input/src/main.vue +356 -356
  34. package/packages/login/.DS_Store +0 -0
  35. package/packages/login/src/main.vue +1857 -1851
  36. package/packages/login/src/resetPassword.vue +562 -557
  37. package/packages/main/.DS_Store +0 -0
  38. package/packages/main/src/.DS_Store +0 -0
  39. package/packages/main/src/default/message.vue +249 -249
  40. package/packages/main/src/default/notice.vue +157 -157
  41. package/packages/main/src/default/userinfo.vue +494 -494
  42. package/packages/main/src/main.vue +65 -57
  43. package/packages/main/src/public/online.vue +89 -89
  44. package/packages/main/src/public/search.vue +454 -454
  45. package/packages/main/src/public/settings.vue +221 -221
  46. package/packages/main/src/simplicity/apps.vue +388 -388
  47. package/packages/main/src/simplicity/avatar.vue +82 -82
  48. package/packages/main/src/simplicity/handler.vue +183 -183
  49. package/packages/main/src/simplicity/index.vue +1931 -1930
  50. package/packages/main/src/simplicity/lists.vue +84 -84
  51. package/packages/main/src/simplicity/menu-list.vue +128 -128
  52. package/packages/main/src/simplicity/message.vue +259 -259
  53. package/packages/main/src/simplicity/notice.vue +190 -190
  54. package/packages/main/src/simplicity/router-page.vue +45 -45
  55. package/packages/main/src/simplicity/sub-menu.vue +241 -241
  56. package/packages/main/src/simplicity/user.vue +248 -248
  57. package/packages/main/src/simplicity/userinfo.vue +306 -304
  58. package/packages/menu/src/main.vue +536 -536
  59. package/packages/pagination/src/main.vue +96 -96
  60. package/packages/qr-code/src/main.vue +170 -170
  61. package/packages/radio-group/src/main.vue +319 -319
  62. package/packages/select/src/main.vue +761 -761
  63. package/packages/selector/src/main.vue +677 -677
  64. package/packages/selector-panel/src/main.vue +1020 -1020
  65. package/packages/selector-panel/src/selection.vue +160 -160
  66. package/packages/tabs/src/main.vue +788 -788
  67. package/packages/theme-chalk/lib/index.css +1 -1
  68. package/packages/theme-chalk/lib/login.css +1 -1
  69. package/packages/theme-chalk/lib/selector.css +1 -1
  70. package/packages/theme-chalk/src/.DS_Store +0 -0
  71. package/packages/theme-chalk/src/base.scss +260 -260
  72. package/packages/theme-chalk/src/button-group.scss +175 -175
  73. package/packages/theme-chalk/src/calendar.scss +113 -113
  74. package/packages/theme-chalk/src/clients.scss +87 -87
  75. package/packages/theme-chalk/src/common/var.scss +4 -1
  76. package/packages/theme-chalk/src/data-table.scss +276 -276
  77. package/packages/theme-chalk/src/dialog.scss +77 -77
  78. package/packages/theme-chalk/src/flow-group.scss +110 -110
  79. package/packages/theme-chalk/src/form.scss +496 -496
  80. package/packages/theme-chalk/src/handler.scss +133 -133
  81. package/packages/theme-chalk/src/icon.scss +1745 -1745
  82. package/packages/theme-chalk/src/icons.scss +99 -99
  83. package/packages/theme-chalk/src/login.scss +928 -917
  84. package/packages/theme-chalk/src/main.scss +632 -632
  85. package/packages/theme-chalk/src/menu.scss +222 -222
  86. package/packages/theme-chalk/src/nav.scss +125 -125
  87. package/packages/theme-chalk/src/pagination.scss +29 -29
  88. package/packages/theme-chalk/src/selector-panel.scss +204 -204
  89. package/packages/theme-chalk/src/selector.scss +1 -1
  90. package/packages/theme-chalk/src/simplicity.scss +1246 -1246
  91. package/packages/theme-chalk/src/tabs.scss +87 -87
  92. package/packages/theme-chalk/src/toolbar.scss +179 -179
  93. package/packages/theme-chalk/src/tree-group.scss +72 -72
  94. package/packages/theme-chalk/src/tree.scss +165 -165
  95. package/packages/upload/src/main.vue +1313 -1313
  96. package/packages/wujie/src/main.vue +145 -145
  97. package/src/.DS_Store +0 -0
  98. package/src/config/api.js +236 -236
  99. package/src/config/image.js +2 -2
  100. package/src/index.js +157 -157
@@ -1,1812 +1,1812 @@
1
- <template>
2
- <component
3
- v-show="showTable"
4
- class="es-data-table"
5
- label-width="0"
6
- ref="component"
7
- v-loading="tableLoading"
8
- element-loading-background="rgba(0, 0, 0, 0.65)"
9
- :is="tag"
10
- :model="tag === 'div' ? '' : list"
11
- :element-loading-text="tableLoadingText"
12
- >
13
- <es-toolbar
14
- v-if="showToolbar"
15
- ref="toolbar"
16
- :class="{
17
- 'es-table-toolbar-plus': mode == 'plus'
18
- }"
19
- v-bind="{
20
- contents: toolbars,
21
- showLabel: showLabel,
22
- close: close,
23
- callBack: resetHeight,
24
- showFormBtn: showFormBtn,
25
- searchValue: searchValue,
26
- advanceValue: advanceValue
27
- }"
28
- v-on="{
29
- click: handleClick,
30
- search: hanleSearch,
31
- submit: hanleSubmit,
32
- tabs: handleTabs,
33
- reset: hanleReset,
34
- cancel: hanleCancel,
35
- ...(toolbars.events || {})
36
- }"
37
- ></es-toolbar>
38
- <p v-if="title" ref="title" class="es-table-title" v-html="title"></p>
39
- <div
40
- v-if="show"
41
- :style="styles"
42
- class="es-data-table-content"
43
- :class="{
44
- 'es-table-border-none': border == 'none',
45
- 'es-table-plus': mode == 'plus'
46
- }"
47
- ref="esTableContent"
48
- >
49
- <el-table
50
- ref="oaTable"
51
- v-bind="{
52
- ...$attrs,
53
- emptyText: emptyText,
54
- showSummary: showTotal,
55
- sumText: sumText || totalText,
56
- totalRow: restotalRow || totalRow,
57
- height:
58
- tableHeight !== 'auto' && tableHeight !== false
59
- ? tableHeight
60
- : undefined,
61
- border: _border,
62
- infiniteScroll: getTableData,
63
- infiniteScrollDisabled: infiniteDisabled,
64
- dragSort: dragSort,
65
- dragSortClass: dragSortIcon
66
- }"
67
- :data.sync="list"
68
- v-on="{
69
- ...$listeners,
70
- 'row-click': rowClick,
71
- 'selection-change': selectionChange,
72
- 'filter-column': handleFilterColumn,
73
- 'sort-change': handleSortChange,
74
- 'update-drag-sort': handleUpdateDragSort
75
- }"
76
- :class="
77
- 'es-table' +
78
- (theadBorder && border != 'none' ? ' es-thead-border' : '')
79
- "
80
- >
81
- <slot name="suffix"></slot>
82
- <slot></slot>
83
- <template v-for="(item, index) in theads">
84
- <template v-if="item.hide !== true">
85
- <el-table-column
86
- v-if="item.type === 'sort'"
87
- width="32"
88
- prop="id"
89
- :key="item.key || item.label || item.title || index"
90
- label=" "
91
- >
92
- <template slot-scope="scope">
93
- <es-icon
94
- v-if="!scope.row.fixed"
95
- class="es-move"
96
- :contents="dragSortIcon"
97
- ></es-icon>
98
- </template>
99
- </el-table-column>
100
- <template
101
- v-else-if="item.type === 'index' || item.type === 'selection'"
102
- >
103
- <el-table-column
104
- :key="item.key || item.label || item.title || index"
105
- v-bind="dragSort ? { ...item, fixed: false } : item"
106
- ></el-table-column>
107
- </template>
108
- <template v-else>
109
- <children
110
- :tag="item.tag"
111
- v-bind="{
112
- mode: mode,
113
- name: name,
114
- indexs: index,
115
- form: form,
116
- readonly: readonly,
117
- optionData: optionDatas,
118
- dragSort: dragSort,
119
- key: item.key || item.label || item.title || index,
120
- ...(dragSort ? { ...item, fixed: false } : { ...item })
121
- }"
122
- v-on="{
123
- handleClick: handleClick,
124
- formBlur: formBlur,
125
- formFocus: formFocus,
126
- formChange: formChange
127
- }"
128
- ></children>
129
- </template>
130
- </template>
131
- </template>
132
- <slot name="prefix"></slot>
133
- <el-table-column
134
- v-if="editable && !readonly"
135
- width="80"
136
- type="handle"
137
- align="center"
138
- label="操作"
139
- fixed="right"
140
- class="eoss-ui-eidt-column"
141
- :button="headButton"
142
- :total="false"
143
- >
144
- <template slot-scope="scope">
145
- <el-button
146
- v-if="!scope.row.cantAdd"
147
- type="text"
148
- @click="handleClickAddData(scope)"
149
- >
150
- <i class="el-icon-circle-plus-outline"></i>
151
- </el-button>
152
- <el-button
153
- v-if="!scope.row.cantDelete && !isLeast"
154
- type="text"
155
- @click="handleClickDeleteData(scope)"
156
- >
157
- <i class="el-icon-remove-outline"></i>
158
- </el-button>
159
- </template>
160
- </el-table-column>
161
- <template slot="append"><slot name="append"></slot></template>
162
- </el-table>
163
- <div v-if="infiniteScroll" class="es-table-page es-loading-page">
164
- <span>共{{ config.totalCount }}条,</span>
165
- <span>已加载{{ list.length }}条</span>
166
- </div>
167
- <es-pagination
168
- v-else-if="page"
169
- ref="pagination"
170
- v-bind="config"
171
- class="es-table-page"
172
- :position="page.position"
173
- :style="{ 'text-align': page.position }"
174
- v-on="{
175
- change: sizeChange,
176
- current: currentChange,
177
- prev: preClick,
178
- next: nextClick
179
- }"
180
- ></es-pagination>
181
- <slot name="dialog"></slot>
182
- <slot name="other"></slot>
183
- </div>
184
- <es-dialog v-if="theads.length" title="列表设置" :visible.sync="showSizer">
185
- <sizer
186
- v-if="showSizer"
187
- :data="theads"
188
- :mode="mode"
189
- @confirm="mergeThead"
190
- ></sizer>
191
- </es-dialog>
192
- <i
193
- class="el-icon-setting es-table-setting"
194
- title="页面配置"
195
- v-if="isShow"
196
- @click="openEditPage"
197
- ></i>
198
-
199
- <es-dialog title="页面配置" :visible.sync="showEditPage" size="full">
200
- <iframe
201
- v-if="showEditPage"
202
- width="100%"
203
- height="100%"
204
- frameborder="0"
205
- :src="editPage"
206
- ></iframe>
207
- </es-dialog>
208
- </component>
209
- </template>
210
- <script>
211
- import {
212
- findSysCode,
213
- getDictList,
214
- formContents
215
- } from 'eoss-ui/src/config/api.js';
216
- import { debounce } from 'throttle-debounce';
217
- import children from './children.vue';
218
- import sizer from './sizer.vue';
219
- import util from 'eoss-ui/src/utils/util';
220
- import qs from 'qs';
221
- const systemMode = util.win.top.systemMode || util.win.systemMode || 'default';
222
- const pageView = util.getParams('pageView');
223
- export default {
224
- name: 'EsDataTable',
225
- inheritAttrs: false,
226
- components: {
227
- children,
228
- sizer
229
- },
230
- provide() {
231
- return {
232
- table: this,
233
- tableReload: this.reload
234
- };
235
- },
236
- inject: {
237
- elForm: {
238
- default: ''
239
- },
240
- injector: {
241
- default: ''
242
- },
243
- scale: {
244
- default: ''
245
- }
246
- },
247
- props: {
248
- viewCode: {
249
- type: String,
250
- default: pageView
251
- },
252
- contentsUrl: {
253
- type: String,
254
- default: formContents
255
- },
256
- mode: {
257
- type: String,
258
- default: systemMode
259
- },
260
- service: String,
261
- loading: {
262
- type: Boolean,
263
- default: false
264
- },
265
- readonly: Boolean,
266
- url: {
267
- type: String,
268
- default: ''
269
- },
270
- defaults: {
271
- type: Boolean,
272
- default: false
273
- },
274
- param: {
275
- type: Object,
276
- default() {
277
- return {};
278
- }
279
- },
280
- method: {
281
- type: String,
282
- default: 'get'
283
- },
284
- isEncodeURI: Boolean,
285
- format: {
286
- type: Boolean,
287
- default: true
288
- },
289
- data: {
290
- type: Array,
291
- default() {
292
- return [];
293
- }
294
- },
295
- // 表格表单
296
- form: {
297
- type: Boolean,
298
- default: false
299
- },
300
- name: String,
301
- title: {
302
- type: String,
303
- default: ''
304
- },
305
- // 导出文件名
306
- fileName: {
307
- type: String,
308
- default: ''
309
- },
310
- // 工具栏配置
311
- toolbar: {
312
- type: [Array, Boolean],
313
- default: false
314
- },
315
- showLabel: Boolean,
316
- searchValue: Object,
317
- advanceValue: Object,
318
- executeSearch: {
319
- type: Boolean,
320
- default: true
321
- },
322
- executeFilter: {
323
- type: Boolean,
324
- default: true
325
- },
326
- // 是否开启序号
327
- numbers: {
328
- type: Boolean,
329
- default: false
330
- },
331
- orders: {
332
- type: String,
333
- default: 'asc'
334
- },
335
- // 是否筛选列功能
336
- filter: {
337
- type: Boolean,
338
- default: false
339
- },
340
- // 是否开启多选
341
- checkbox: {
342
- type: Boolean,
343
- default: false
344
- },
345
- selectable: Function,
346
- reserveSelection: Boolean,
347
- // 默认选中,类型为Boolean时默认全(不)选
348
- checked: {
349
- type: [Boolean, Array],
350
- default: false
351
- },
352
- checkedKey: {
353
- type: String,
354
- default: 'id'
355
- },
356
- // 无数据时显示的文本
357
- emptyText: {
358
- type: String,
359
- default: ''
360
- },
361
- // 是否开启合计行区域
362
- total: {
363
- type: Boolean,
364
- default: false
365
- },
366
- //本地数据总条数差值
367
- lose: {
368
- type: Number,
369
- default: 0
370
- },
371
- // 合计行显示文本
372
- totalText: {
373
- type: String,
374
- default: ''
375
- },
376
- showSummary: {
377
- type: Boolean,
378
- default: false
379
- },
380
- sumText: {
381
- type: String,
382
- default: ''
383
- },
384
- // 开启分页
385
- page: {
386
- type: [Boolean, Object],
387
- default() {
388
- return false;
389
- }
390
- },
391
- // 渲染树形数据指定field
392
- treeKey: {
393
- type: String,
394
- default: ''
395
- },
396
- // 单元格配置
397
- thead: {
398
- type: Array,
399
- default() {
400
- return [];
401
- }
402
- },
403
- optionData: Object,
404
- // 开启数据增加删除按钮
405
- editable: {
406
- type: Boolean,
407
- default: false
408
- },
409
- theadAdd: {
410
- type: Boolean,
411
- default: true
412
- },
413
- // 单元格点击事件
414
- click: {
415
- type: Boolean,
416
- default: false
417
- },
418
- totalRow: {
419
- type: Object,
420
- default() {
421
- return {};
422
- }
423
- },
424
- parseData: Function,
425
- close: Boolean,
426
- full: {
427
- type: Boolean,
428
- default: true
429
- },
430
- height: [Number, String],
431
- maxHeight: [Number, String],
432
- response: Function,
433
- minWidth: [Number, String],
434
- border: {
435
- type: [Boolean, String],
436
- default: false,
437
- validator: function (value) {
438
- return [true, false, 'none'].includes(value);
439
- }
440
- },
441
- theadBorder: {
442
- type: Boolean,
443
- default: true
444
- },
445
- checkboxParseData: Function,
446
- checkboxParse: Object,
447
- display: {
448
- type: Boolean,
449
- default: true
450
- },
451
- showFormBtn: {
452
- type: Boolean,
453
- default: true
454
- },
455
- index: {
456
- type: [Number, Function],
457
- default: 1
458
- },
459
- accumulated: {
460
- type: Boolean,
461
- default: true
462
- },
463
- immediate: {
464
- type: Boolean,
465
- default: true
466
- },
467
- zoom: false,
468
- exportExcludeLabel: {
469
- type: Array,
470
- default() {
471
- return [];
472
- }
473
- },
474
- rowData: [Object, Boolean],
475
- least: Boolean,
476
- //保留搜索参数
477
- retainSearh: Boolean,
478
- //无线滚动
479
- infiniteScroll: Boolean,
480
- isJoin: {
481
- type: Boolean,
482
- default: true
483
- },
484
- ajaxConfig: {
485
- type: Object,
486
- default() {
487
- return {};
488
- }
489
- },
490
- dragSort: Boolean,
491
- dragSortIcon: {
492
- type: String,
493
- default: 'es-icon-caidan'
494
- },
495
- isFieldsEncryption: Boolean,
496
- contentSuccess: Function,
497
- resetScroll: {
498
- type: Boolean,
499
- default: true
500
- }
501
- },
502
- data() {
503
- return {
504
- isEncryption: this.isFieldsEncryption,
505
- requests: [],
506
- toolbars: [],
507
- hasThead: false,
508
- theadData: [],
509
- list: [],
510
- tableLoading: this.loading,
511
- tableLoadingText: '加载中...',
512
- isFirsetCheck: false,
513
- // 可修改表单的值
514
- editValue: {},
515
- restotalRow: null,
516
- showTotal: false,
517
- config: {
518
- pageNum: 1,
519
- pageSize: 20,
520
- totalCount: 0,
521
- layout:
522
- this.mode == 'plus'
523
- ? 'total, sizes, prev, pager, next, jumper'
524
- : undefined
525
- },
526
- searchWhere: {},
527
- advanceWhere: {},
528
- tableHeight: 'auto',
529
- styles: {},
530
- selected: null,
531
- options: {},
532
- icon: true,
533
- sysCodes: [],
534
- infiniteDisabled: !this.infiniteScroll,
535
- isReload: false,
536
- pageView: null,
537
- showSizer: false,
538
- show: true,
539
- isSetHeight: false,
540
- showTable: false,
541
- fields: null,
542
- showEditPage: false,
543
- editPage: ''
544
- };
545
- },
546
- computed: {
547
- wheres() {
548
- return { ...this.searchWhere, ...this.advanceWhere };
549
- },
550
- params() {
551
- return {
552
- ...(this.param || {}),
553
- ...(this.searchValue || {}),
554
- ...(this.advanceValue || {})
555
- };
556
- },
557
- tag() {
558
- return this.form && this.elForm == '' ? 'el-form' : 'div';
559
- },
560
- _border() {
561
- return this.border === true ? true : false;
562
- },
563
- theads: {
564
- get() {
565
- let types;
566
- types = this.theadData
567
- .filter((item) => {
568
- return (
569
- item.type == 'selection' ||
570
- item.type == 'index' ||
571
- item.type == 'sort' ||
572
- item.type == 'handle'
573
- );
574
- })
575
- .map((item) => {
576
- return item.type;
577
- });
578
- let thead = [];
579
- let addfilter = false;
580
- if (this.dragSort && !types.includes('sort')) {
581
- addfilter = true;
582
- thead.push({
583
- type: 'sort',
584
- key: 'es-sort'
585
- });
586
- }
587
- if (this.checkbox && !types.includes('selection')) {
588
- thead.push({
589
- type: 'selection',
590
- width: '55',
591
- align: 'center',
592
- fixed: 'left',
593
- selectable: this.selectable,
594
- reserveSelection: this.reserveSelection,
595
- filterIcon: this.filter && !addfilter ? 'es-icon-biao' : undefined,
596
- key: 'es-checkbox'
597
- });
598
- if (!addfilter) {
599
- addfilter = true;
600
- }
601
- }
602
- if (this.numbers && !types.includes('index')) {
603
- let index = 1;
604
- if (typeof this.index === 'function') {
605
- index = this.index;
606
- } else {
607
- if (this.orders == 'desc') {
608
- index = (num) => {
609
- return this.config.totalCount - num;
610
- };
611
- } else if (this.accumulated) {
612
- index =
613
- (this.config.pageNum - 1) * this.config.pageSize + this.index;
614
- } else {
615
- index = this.index;
616
- }
617
- }
618
- thead.push({
619
- type: 'index',
620
- label: '序号',
621
- width: '70',
622
- align: 'center',
623
- fixed: 'left',
624
- index: index,
625
- filterIcon: this.filter && !addfilter ? 'es-icon-biao' : undefined,
626
- key: 'es-index'
627
- });
628
- if (!addfilter) {
629
- addfilter = true;
630
- }
631
- }
632
- if (this.theadData.length) {
633
- let handle = this.thead.filter((item) => {
634
- return item.type == 'handle';
635
- });
636
- thead = [
637
- ...thead,
638
- ...this.theadData,
639
- ...(types.includes('handle') ? [] : handle)
640
- ];
641
- } else if (this.show) {
642
- thead = [...thead, ...this.thead];
643
- }
644
- return thead;
645
- },
646
- set(val) {
647
- return val;
648
- }
649
- },
650
- datas: {
651
- get() {
652
- if (this.list && this.list.length) {
653
- return this.list;
654
- }
655
- if (
656
- this.page &&
657
- ((typeof this.page === 'object' &&
658
- (!Object.prototype.hasOwnProperty.call(this.page, 'totalCount') ||
659
- this.page.totalCount == 0)) ||
660
- this.page === true)
661
- ) {
662
- this.config.totalCount = this.data.length - this.lose;
663
- }
664
- if (this.page && this.data.length > this.config.pageSize) {
665
- return this.data.filter((item, index) => {
666
- return (
667
- index > (this.config.pageNum - 1) * this.config.pageSize - 1 &&
668
- index < this.config.pageNum * this.config.pageSize
669
- );
670
- });
671
- }
672
- return this.data;
673
- },
674
- set(val) {
675
- if (this.list && this.list.length) {
676
- this.$nextTick(() => {
677
- this.list = val;
678
- });
679
- }
680
- this.$emit('update:data', val);
681
- return val;
682
- }
683
- },
684
- showToolbar() {
685
- if (this.readonly) {
686
- return false;
687
- }
688
- if (typeof this.toolbar === 'boolean') {
689
- if (this.toolbar) {
690
- this.toolbars = [
691
- {
692
- type: 'search',
693
- contents: [
694
- {
695
- type: 'text',
696
- name: 'keyword',
697
- placeholder: '请输入关键字'
698
- }
699
- ]
700
- }
701
- ];
702
- }
703
- return this.toolbar;
704
- } else {
705
- this.toolbars = this.toolbar;
706
- return true;
707
- }
708
- },
709
- optionDatas: {
710
- get() {
711
- let data = this.optionData
712
- ? { ...this.optionData, ...this.options }
713
- : this.options;
714
- return data;
715
- },
716
- set(val) {
717
- return val;
718
- }
719
- },
720
- headButton() {
721
- return this.theadAdd && !this.readonly
722
- ? {
723
- icon: 'el-icon-circle-plus-outline',
724
- type: 'text',
725
- event: this.handleClickAddData
726
- }
727
- : undefined;
728
- },
729
- isLeast() {
730
- return this.data.length < 2 && this.least;
731
- },
732
- findCode() {
733
- if (this.service) {
734
- return `/${this.service}${getDictList}`;
735
- }
736
- return findSysCode;
737
- },
738
- isShow() {
739
- let useCaseCodes = util.getStorage('useCaseCodes');
740
- return (
741
- this.viewCode &&
742
- useCaseCodes &&
743
- (useCaseCodes.indexOf('SuperAdminRoleID') > -1 ||
744
- useCaseCodes.indexOf('OrgAdminRoleID') > -1)
745
- );
746
- }
747
- },
748
- watch: {
749
- viewCode: {
750
- immediate: true,
751
- handler(val) {
752
- if (val) {
753
- this.hasThead = true;
754
- this.getContents();
755
- }
756
- }
757
- },
758
- showToolbar() {
759
- this.resetHeight();
760
- this.doLayout();
761
- },
762
- data: {
763
- deep: true,
764
- handler() {
765
- this.list = this.setData();
766
- }
767
- },
768
- scale: {
769
- deep: true,
770
- handler(val) {
771
- if (
772
- this.tableHeight != 'auto' &&
773
- this.tableHeight !== false &&
774
- this.display
775
- ) {
776
- this.resetHeight();
777
- this.doLayout();
778
- }
779
- }
780
- },
781
- zoom: {
782
- handler() {
783
- if (
784
- this.tableHeight != 'auto' &&
785
- this.tableHeight !== false &&
786
- this.display
787
- ) {
788
- this.resetHeight();
789
- this.doLayout();
790
- }
791
- }
792
- },
793
- checked(newVal) {
794
- this.list.length && this.checkSelect(newVal);
795
- },
796
- thead: {
797
- deep: true,
798
- handler(val) {
799
- this.getOptions(val);
800
- this.chekOpenTotalArea();
801
- if (Array.isArray(val) && val.length && this.datas.length == 0) {
802
- this.getTableData();
803
- }
804
- }
805
- },
806
- theads: {
807
- deep: true,
808
- handler() {
809
- this.chekOpenTotalArea();
810
- }
811
- },
812
- param: {
813
- handler(val) {
814
- this.getTableData();
815
- }
816
- },
817
- page: {
818
- immediate: true,
819
- deep: true,
820
- handler(val) {
821
- if (this.$el) {
822
- this.resetHeight();
823
- this.doLayout();
824
- }
825
- if (typeof val === 'object') {
826
- this.config = util.extend({}, this.config, val);
827
- }
828
- }
829
- },
830
- 'config.pageNum'() {
831
- if (this.data.length) {
832
- this.resetScroll &&
833
- this.$refs.oaTable &&
834
- this.$refs.oaTable.resetScroll &&
835
- this.$refs.oaTable.resetScroll(0, 0);
836
- this.list = this.setData();
837
- }
838
- },
839
- height: {
840
- immediate: true,
841
- handler(val) {
842
- if (val) {
843
- this.tableHeight = val;
844
- }
845
- }
846
- },
847
- maxHeight: {
848
- immediate: true,
849
- handler(val) {
850
- if (val && this.height === undefined) {
851
- this.tableHeight = val;
852
- }
853
- }
854
- },
855
- display(val) {
856
- if (val) {
857
- this.resetHeight();
858
- this.doLayout();
859
- }
860
- },
861
- showEditPage(val) {
862
- if (val === false) {
863
- util.win.top.refresh();
864
- }
865
- }
866
- },
867
- beforeCreate() {
868
- this.getTableData = debounce(500, (res) => {
869
- this.getTableDatas(res);
870
- });
871
- },
872
- created() {
873
- if (Array.isArray(this.thead) && this.thead.length) {
874
- this.getOptions(this.thead);
875
- this.immediate && !this.viewCode && this.getTableData();
876
- }
877
- this.chekOpenTotalArea();
878
- },
879
- mounted() {
880
- this.showTable = true;
881
- if (this.data.length) {
882
- this.list = this.setData();
883
- }
884
- this.list.length && this.checkSelect(this.checked);
885
- this.resetHeight();
886
- if (util.win.top != util.win.self) {
887
- util.win.onresize = debounce(500, this.resetHeight);
888
- }
889
- },
890
- methods: {
891
- setData() {
892
- if (
893
- this.page &&
894
- ((typeof this.page === 'object' &&
895
- (!Object.prototype.hasOwnProperty.call(this.page, 'totalCount') ||
896
- this.page.totalCount == 0)) ||
897
- this.page === true)
898
- ) {
899
- this.config.totalCount = this.data.length - this.lose;
900
- }
901
- if (this.page && this.data.length > this.config.pageSize) {
902
- return this.data.filter((item, index) => {
903
- return (
904
- index > (this.config.pageNum - 1) * this.config.pageSize - 1 &&
905
- index < this.config.pageNum * this.config.pageSize
906
- );
907
- });
908
- }
909
- return this.data;
910
- },
911
- getRequestKey(config) {
912
- const { method, url, params, data } = config;
913
- return [method, url, qs.stringify(params), qs.stringify(data)].join('&');
914
- },
915
- getContents() {
916
- util
917
- .ajax({
918
- url: this.contentsUrl,
919
- params: {
920
- formId: this.viewCode
921
- }
922
- })
923
- .then((res) => {
924
- if (res.rCode == 0) {
925
- if (this.contentSuccess) {
926
- this.contentSuccess(res.results);
927
- } else {
928
- let {
929
- results: { eossFormJson }
930
- } = res;
931
- eossFormJson = JSON.parse(eossFormJson);
932
- if (eossFormJson && eossFormJson.table) {
933
- this.isEncryption = true;
934
- this.theadData = eossFormJson.table.thead;
935
- this.getTableData();
936
- } else {
937
- this.hasThead = false;
938
- }
939
- this.$emit('init-contents', res.results);
940
- }
941
- }
942
- });
943
- },
944
- getOptions(res) {
945
- let sysCodes = [];
946
- res.forEach((item) => {
947
- if (item.sysCode || item.url) {
948
- item.sysCode && sysCodes.push(item.sysCode);
949
- let params = util.extend(
950
- {},
951
- item.sysCode
952
- ? { sysAppCode: item.sysCode, code: item.sysCode }
953
- : {},
954
- item.param ? item.param : {}
955
- );
956
- let key = this.getRequestKey({
957
- method: this.method,
958
- url: item.sysCode ? this.findCode : item.url,
959
- params: params,
960
- data: {}
961
- });
962
- if (!this.requests.includes(key)) {
963
- util
964
- .ajax({
965
- url: item.sysCode ? this.findCode : item.url,
966
- method: this.method,
967
- params: params,
968
- data: params
969
- })
970
- .then((res) => {
971
- if (res.rCode === 0) {
972
- if (item.type == 'ganged') {
973
- this.$set(
974
- this.options,
975
- item.sysCode || item.field || item.prop,
976
- [JSON.parse(JSON.stringify(res.results))]
977
- );
978
- if (item.sysCode) {
979
- const bus = this.bus || this.$root.Bus;
980
- bus &&
981
- bus.$emit(
982
- item.sysCode,
983
- JSON.parse(JSON.stringify(this.options[item.sysCode]))
984
- );
985
- }
986
- } else {
987
- this.$set(
988
- this.options,
989
- item.sysCode || item.field || item.prop,
990
- JSON.parse(JSON.stringify(res.results))
991
- );
992
- if (item.sysCode) {
993
- const bus = this.bus || this.$root.Bus;
994
- bus &&
995
- bus.$emit(
996
- item.sysCode,
997
- JSON.parse(JSON.stringify(res.results))
998
- );
999
- }
1000
- }
1001
- this.requests.push(key);
1002
- } else {
1003
- let msg = res.msg || '系统错误,请联系管理员!';
1004
- this.$message.error(msg);
1005
- }
1006
- })
1007
- .catch((err) => {
1008
- if (err.message && err.message !== 'canceled') {
1009
- this.$message.error(err.message);
1010
- }
1011
- });
1012
- }
1013
- } else {
1014
- if (item.childHead && item.childHead.length) {
1015
- this.getOptions(item.childHead);
1016
- }
1017
- if (item.children && item.children.length) {
1018
- this.getOptions(item.children);
1019
- }
1020
- }
1021
- });
1022
- this.sysCodes = sysCodes;
1023
-
1024
- this.bindEventBus();
1025
- },
1026
- checkObject(item) {
1027
- return util.getObjectType(item) === 'object';
1028
- },
1029
- chekOpenTotalArea() {
1030
- if (this.total || this.showSummary) {
1031
- this.showTotal = true;
1032
- return;
1033
- }
1034
- if (!this.theads) {
1035
- return;
1036
- }
1037
- const arr = JSON.parse(JSON.stringify(this.theads));
1038
- let flag = false;
1039
- arr.forEach((item) => {
1040
- if (item.total) {
1041
- flag = true;
1042
- this.showTotal = true;
1043
- }
1044
- });
1045
- if (this.showTotal !== flag) {
1046
- this.showTotal = flag;
1047
- }
1048
- },
1049
- rowClick(row, column, event) {
1050
- this.$emit('click', row, column, event);
1051
- this.$emit('row-click', row, column, event);
1052
- },
1053
- handleClickAddData(scope) {
1054
- if (scope && scope.row) {
1055
- const data = JSON.parse(JSON.stringify(scope.row));
1056
- let index = scope.$index + 1;
1057
- if (this.page) {
1058
- index += (this.config.pageNum - 1) * this.config.pageSize;
1059
- }
1060
- this.data.splice(index, 0, data);
1061
- this.$emit('dataChange', 'add', data);
1062
- this.$emit('data-change', 'add', data);
1063
- this.$emit('btnClick', {
1064
- event: 'addRow',
1065
- row: data,
1066
- index: index,
1067
- data: this.data
1068
- });
1069
- this.$emit('btn-click', {
1070
- event: 'addRow',
1071
- row: data,
1072
- index: index,
1073
- data: this.data
1074
- });
1075
- } else {
1076
- let index = this.data.length;
1077
- if (this.page) {
1078
- index += (this.config.pageNum - 1) * this.config.pageSize;
1079
- }
1080
- let rows = {};
1081
- if (this.rowData && typeof this.rowData == 'object') {
1082
- rows = this.rowData;
1083
- } else if (index && this.rowData === true) {
1084
- rows = JSON.parse(JSON.stringify(this.data[index - 1]));
1085
- } else {
1086
- this.getRow(this.thead, rows);
1087
- }
1088
- this.data.splice(index, 0, rows);
1089
- }
1090
- },
1091
- getRow(thead, obj) {
1092
- thead.forEach((item) => {
1093
- if (item.field) {
1094
- obj[item['field']] = item.defaultValue || '';
1095
- } else if (item.children && item.children.length) {
1096
- this.getRow(item.children, obj);
1097
- }
1098
- });
1099
- },
1100
- handleClickDeleteData(scope) {
1101
- const data = JSON.parse(JSON.stringify(scope.row));
1102
- let index = scope.$index;
1103
- if (this.page) {
1104
- index += (this.config.pageNum - 1) * this.config.pageSize;
1105
- }
1106
- this.data.splice(index, 1);
1107
- this.$emit('dataChange', 'delete', data);
1108
- this.$emit('data-change', 'delete', data);
1109
- this.$emit('btnClick', {
1110
- event: 'deleteRow',
1111
- row: data,
1112
- index: index,
1113
- data: this.data
1114
- });
1115
- this.$emit('btn-click', {
1116
- event: 'deleteRow',
1117
- row: data,
1118
- index: index,
1119
- data: this.data
1120
- });
1121
- },
1122
- checkSelect(newVal) {
1123
- this.$nextTick(() => {
1124
- if (util.getObjectType(newVal) === 'array') {
1125
- newVal.forEach((row) => {
1126
- if (util.isObject(row)) {
1127
- this.$refs.oaTable.toggleRowSelection(row, true);
1128
- } else {
1129
- this.setChecked(this.list, row);
1130
- }
1131
- });
1132
- } else if (newVal === true) {
1133
- this.toggleAllSelection();
1134
- }
1135
- });
1136
- },
1137
- setChecked(list, row) {
1138
- list.forEach((item) => {
1139
- if (item.children && item.children.length) {
1140
- this.setChecked(item.children, row);
1141
- }
1142
- if (item[this.checkedKey] === row) {
1143
- this.$refs.oaTable.toggleRowSelection(item, true);
1144
- return;
1145
- }
1146
- });
1147
- },
1148
- getTableDatas(res) {
1149
- let where;
1150
- let first;
1151
- if (res) {
1152
- where = res.where;
1153
- first = res.first;
1154
- }
1155
- if (!this.url) {
1156
- return;
1157
- }
1158
- if (first !== false && !this.infiniteScroll) {
1159
- this.config.pageNum = 1;
1160
- }
1161
- this.tableLoadingText = '加载中...';
1162
- let reqData = util.extend(
1163
- {},
1164
- this.params,
1165
- this.page
1166
- ? {
1167
- pageNum: this.config.pageNum,
1168
- pageSize: this.config.pageSize
1169
- }
1170
- : {}
1171
- );
1172
- if (where) {
1173
- reqData = util.extend({}, reqData, where);
1174
- }
1175
- //if (this.fields)
1176
- if (this.retainSearh || first === false) {
1177
- reqData = util.extend({}, reqData, this.wheres);
1178
- }
1179
- if (this.isJoin) {
1180
- for (let i in reqData) {
1181
- if (Array.isArray(reqData[i])) {
1182
- reqData[i] = reqData[i].join(',');
1183
- }
1184
- }
1185
- }
1186
- if (this.isEncryption) {
1187
- let fields = [];
1188
- this.theads.forEach((item) => {
1189
- if (item.field || item.prop) {
1190
- fields.push(item.field || item.prop);
1191
- }
1192
- });
1193
- let initLogin = util.getStorage('initLogin');
1194
- initLogin && (initLogin = JSON.parse(initLogin));
1195
- reqData['fields'] = initLogin.secret
1196
- ? util.esmEncrypt({
1197
- data: fields.join(','),
1198
- key: initLogin.secret
1199
- })
1200
- : fields.join(',');
1201
- }
1202
- this.tableLoading = true;
1203
- util
1204
- .ajax({
1205
- ...this.ajaxConfig,
1206
- url: this.url,
1207
- method: this.method,
1208
- format: this.format,
1209
- params: reqData,
1210
- data: reqData
1211
- })
1212
- .then((res) => {
1213
- this.tableLoading = false;
1214
- if (res.rCode === 0 || res.status === 'success') {
1215
- if (this.isReload) {
1216
- this.list = [];
1217
- this.isReload = false;
1218
- }
1219
- let results =
1220
- this.parseData !== undefined
1221
- ? this.parseData(res.results || res.data || res)
1222
- : res.results || res.data;
1223
- if (this.infiniteScroll) {
1224
- this.list = this.list.concat(
1225
- results.data || results.records || results.list
1226
- );
1227
- this.config.pageNum += 1;
1228
- } else {
1229
- this.list = results.data || results.records || results.list;
1230
- this.$nextTick(() => {
1231
- this.resetScroll &&
1232
- this.$refs.oaTable &&
1233
- this.$refs.oaTable.resetScroll &&
1234
- this.$refs.oaTable.resetScroll(0, 0);
1235
- });
1236
- }
1237
- this.config.totalCount =
1238
- results.count || results.total || results.totalCount;
1239
- this.config.pageCount = results.pageCount;
1240
- this.checked &&
1241
- this.$nextTick(() => {
1242
- this.checkSelect(this.checked);
1243
- });
1244
- if (
1245
- this.infiniteScroll &&
1246
- this.config.totalCount === this.list.length
1247
- ) {
1248
- this.infiniteDisabled = true;
1249
- }
1250
- } else {
1251
- this.list = [];
1252
- //this.tableHeight = false;
1253
- let msg = res.msg || '系统错误,请联系管理员!';
1254
- this.$message.error(msg);
1255
- }
1256
- this.$emit('success', res);
1257
- })
1258
- .catch((err) => {
1259
- //this.tableHeight = false;
1260
- if (err.message && err.message !== 'canceled') {
1261
- this.$message.error(err.message);
1262
- }
1263
- this.tableLoading = false;
1264
- });
1265
- },
1266
- selectionChange(data) {
1267
- this.selected = JSON.parse(JSON.stringify(data));
1268
- this.$emit('selection-change', data);
1269
- },
1270
- clearSelection() {
1271
- this.$refs.oaTable.clearSelection();
1272
- },
1273
- toggleRowSelection(row, selected) {
1274
- this.$refs.oaTable.toggleRowSelection(row, selected);
1275
- },
1276
- toggleAllSelection() {
1277
- this.$refs.oaTable.toggleAllSelection();
1278
- },
1279
- toggleRowExpansion(row, expanded) {
1280
- this.$refs.oaTable.toggleRowExpansion(row, expanded);
1281
- },
1282
- setCurrentRow(row) {
1283
- this.$refs.oaTable.setCurrentRow(row);
1284
- },
1285
-
1286
- clearSort() {
1287
- this.$refs.oaTable.clearSort();
1288
- },
1289
- clearFilter(columnKey) {
1290
- this.$refs.oaTable.clearFilter(columnKey);
1291
- },
1292
- doLayout() {
1293
- this.$refs.oaTable && this.$refs.oaTable.doLayout();
1294
- },
1295
- sort(prop, order) {
1296
- this.$refs.oaTable.sort(prop, order);
1297
- },
1298
- formBlur(data) {
1299
- this.$emit('blur', data, this.list);
1300
- },
1301
- formFocus(data) {
1302
- this.$emit('focus', data, this.list);
1303
- },
1304
- formChange(data) {
1305
- this.$emit('edit', data, this.list);
1306
- this.$emit('change', data, this.list);
1307
- },
1308
- handleAjax(handle, row) {
1309
- this.changeLoading(true, `${handle.text}中...`);
1310
- let params = handle.param || {};
1311
- if (handle.syncKeys) {
1312
- if (typeof handle.syncKeys === 'string') {
1313
- params[handle.syncKeys] = row[handle.syncKeys];
1314
- } else if (Array.isArray(handle.syncKeys)) {
1315
- for (let i in handle.syncKeys) {
1316
- if (Array.isArray(row)) {
1317
- let param = row.map((item) => {
1318
- return item[handle.syncKeys[i]];
1319
- });
1320
- params[handle.syncKeys[i]] = param.join(',');
1321
- } else {
1322
- params[handle.syncKeys[i]] = row[handle.syncKeys[i]];
1323
- }
1324
- }
1325
- } else {
1326
- for (let i in handle.syncKeys) {
1327
- if (Array.isArray(row)) {
1328
- let param = row.map((item) => {
1329
- return item[handle.syncKeys[i]];
1330
- });
1331
- params[i] = param.join(',');
1332
- } else {
1333
- params[i] = row[handle.syncKeys[i]];
1334
- }
1335
- }
1336
- }
1337
- } else {
1338
- if (Array.isArray(row)) {
1339
- let param = row.map((item) => {
1340
- return item.id;
1341
- });
1342
- params.id = param.join(',');
1343
- } else {
1344
- params.id = row.id;
1345
- }
1346
- }
1347
- let keys = Object.keys(params);
1348
- util
1349
- .ajax({
1350
- ...(handle.ajaxConfig || {}),
1351
- url: handle.action,
1352
- data:
1353
- keys.length == 1 && handle.format === false
1354
- ? params[keys[0]].split(',')
1355
- : params,
1356
- params:
1357
- keys.length == 1 && handle.format === false
1358
- ? params[keys[0]].split(',')
1359
- : params,
1360
- method: handle.method,
1361
- format: handle.format
1362
- })
1363
- .then((res) => {
1364
- this.changeLoading(false);
1365
- if (res.rCode === 0) {
1366
- this.$message({
1367
- message: `${handle.text}成功`,
1368
- duration: 2000,
1369
- type: 'success',
1370
- onClose: () => {
1371
- let first = Object.prototype.hasOwnProperty.call(
1372
- handle,
1373
- 'first'
1374
- )
1375
- ? handle.first
1376
- : false;
1377
- let reload = handle.reload || true;
1378
- if (reload) {
1379
- this.reload({}, first);
1380
- }
1381
- }
1382
- });
1383
- } else {
1384
- this.$message.error(
1385
- res.msg || `${handle.text}失败,请联系管理员!`
1386
- );
1387
- }
1388
- })
1389
- .catch((err) => {
1390
- this.changeLoading(false);
1391
- if (err.message && err.message !== 'canceled') {
1392
- this.$message.error(err.message);
1393
- }
1394
- });
1395
- },
1396
- checkParse(data, parse) {
1397
- if (Array.isArray(data)) {
1398
- return data.map((items) => {
1399
- let item = JSON.parse(JSON.stringify(items));
1400
- let obj = {};
1401
- for (let i in parse) {
1402
- obj[i] = item[parse[i]];
1403
- delete item[parse[i]];
1404
- }
1405
- return { ...obj, ...item };
1406
- });
1407
- }
1408
- let item = JSON.parse(JSON.stringify(data));
1409
- let obj = {};
1410
- for (let i in parse) {
1411
- obj[i] = item[parse[i]];
1412
- delete item[parse[i]];
1413
- }
1414
- return { ...obj, ...item };
1415
- },
1416
- handleClick(res) {
1417
- let { row, handle } = res;
1418
- let rows;
1419
- if (handle.checkbox) {
1420
- if (!this.selected || !this.selected.length) {
1421
- this.$alert('请选择数据', '提示', { type: 'warning' });
1422
- return;
1423
- } else {
1424
- row = this.selected;
1425
- }
1426
- }
1427
- if (this.checkboxParseData) {
1428
- rows = this.checkboxParseData(JSON.parse(JSON.stringify(row)));
1429
- } else if (this.checkboxParse) {
1430
- rows = this.checkParse(row, this.checkboxParse);
1431
- } else if (handle.checkboxParse) {
1432
- rows = this.checkParse(row, handle.checkboxParse);
1433
- } else if (row) {
1434
- rows = JSON.parse(JSON.stringify(row));
1435
- }
1436
- let thead = this.theads;
1437
- if (this.$refs.oaTable) {
1438
- thead = this.$refs.oaTable.getThead().thead;
1439
- }
1440
- if (handle.action) {
1441
- let isConfirm = handle.confirm || true;
1442
- if (isConfirm) {
1443
- let msg = handle.field ? row[handle.field] : '';
1444
- this.$confirm(`确定要${handle.text}${msg}吗`, '提示', {
1445
- confirmButtonText: '确定',
1446
- cancelButtonText: '取消',
1447
- type: 'warning'
1448
- })
1449
- .then(() => {
1450
- this.handleAjax(handle, rows);
1451
- })
1452
- .catch(() => {});
1453
- } else {
1454
- this.handleAjax(handle, rows);
1455
- }
1456
- } else if (handle.event) {
1457
- if (typeof handle.event === 'function') {
1458
- handle.event({
1459
- ele: this,
1460
- thead: thead,
1461
- data: this.list,
1462
- selected: rows,
1463
- ...res
1464
- });
1465
- } else if (
1466
- handle.event === 'add' ||
1467
- handle.event === 'edit' ||
1468
- handle.event === 'look'
1469
- ) {
1470
- let changes = {
1471
- event: handle.event,
1472
- title: handle.title || handle.text,
1473
- value: handle.event === 'add' ? {} : rows,
1474
- readonly: handle.event === 'look',
1475
- actionType: handle.actionType
1476
- ? handle.actionType
1477
- : handle.event === 'add'
1478
- ? 'save'
1479
- : 'update',
1480
- visible: true
1481
- };
1482
- if (handle.dialog) {
1483
- let dialog;
1484
- for (let i = 0; i < this.$children.length; i++) {
1485
- let child = this.$children[i];
1486
- if (child.$refs[handle.dialog]) {
1487
- dialog = child.$refs[handle.dialog];
1488
- break;
1489
- }
1490
- }
1491
- dialog.setAttrs(changes);
1492
- }
1493
- this.injector && this.injector.handleChangeData(changes);
1494
- if (handle.busEvent) {
1495
- const bus = this.bus || this.$root.Bus;
1496
- bus && bus.$emit(handle.busEvent, changes);
1497
- }
1498
- }
1499
- } else if (handle.changeData) {
1500
- let changeData = {};
1501
- if (Array.isArray(handle.changeData)) {
1502
- handle.changeData.forEach((item) => {
1503
- if (util.isObject(item)) {
1504
- for (let i in item) {
1505
- if (typeof item[i] === 'boolean') {
1506
- changeData[i] = item[i];
1507
- } else {
1508
- changeData[i] = handle[item[i]] || item[i];
1509
- }
1510
- }
1511
- } else {
1512
- changeData[item] =
1513
- handle[item] || (Array.isArray(rows) ? rows : rows[item]);
1514
- }
1515
- });
1516
- } else {
1517
- for (let i in handle.changeData) {
1518
- let item = handle.changeData[i];
1519
- if (util.isObject(item)) {
1520
- let obj = {};
1521
- for (let e in item) {
1522
- obj[e] =
1523
- handle[item[e]] ||
1524
- (Array.isArray(rows) ? rows : rows[item[e]]);
1525
- }
1526
- changeData[i] = obj;
1527
- } else {
1528
- if (typeof item === 'boolean') {
1529
- changeData[i] = item;
1530
- } else {
1531
- changeData[i] =
1532
- handle[item] || (Array.isArray(rows) ? rows : rows[item]);
1533
- }
1534
- }
1535
- }
1536
- }
1537
- if (handle.actionType) {
1538
- changeData['actionType'] = handle.actionType;
1539
- }
1540
- this.injector && this.injector.handleChangeData(changeData);
1541
- if (handle.busEvent) {
1542
- const bus = this.bus || this.$root.Bus;
1543
- bus && bus.$emit(handle.busEvent, changes);
1544
- }
1545
- } else {
1546
- if (handle.exportXls) {
1547
- let text = '操作';
1548
- if (
1549
- this.theads[this.theads.length - 1] &&
1550
- this.theads[this.theads.length - 1].type === 'handle'
1551
- ) {
1552
- text = this.theads[this.theads.length - 1].title;
1553
- }
1554
- let type = ['selection', 'index', 'expand'];
1555
- thead = thead.map((item) => {
1556
- return item.filter((ele) => {
1557
- return (
1558
- !type.includes(ele.type) &&
1559
- ele.label !== text &&
1560
- !this.exportExcludeLabel.includes(ele.label)
1561
- );
1562
- });
1563
- });
1564
- util.exportXls({
1565
- thead: thead,
1566
- data: this.list,
1567
- name: this.fileName,
1568
- option: this.optionDatas
1569
- });
1570
- }
1571
- this.$emit('btnClick', res, this.list, thead, rows);
1572
- this.$emit('btn-click', res, this.list, thead, rows);
1573
- }
1574
- },
1575
- sizeChange(res) {
1576
- this.config.pageSize = res;
1577
- this.config.pageNum = 1;
1578
- this.checkSelect(this.checked);
1579
- this.$emit('page-size-change', res);
1580
- if (this.url) {
1581
- this.getTableData({ where: this.wheres, first: false });
1582
- }
1583
- },
1584
- currentChange(res) {
1585
- this.config.pageNum = res;
1586
- this.checkSelect(this.checked);
1587
- this.$emit('page-current-change', res);
1588
- this.$emit('current', res);
1589
- if (this.url) {
1590
- this.getTableData({ where: this.wheres, first: false });
1591
- }
1592
- },
1593
- preClick(res) {
1594
- this.config.pageNum = res;
1595
- this.checkSelect(this.checked);
1596
- this.$emit('prev', res);
1597
- },
1598
- nextClick(res) {
1599
- this.config.pageNum = res;
1600
- this.checkSelect(this.checked);
1601
- this.$emit('next', res);
1602
- },
1603
- hanleSearch(data) {
1604
- this.searchWhere =
1605
- this.response !== undefined
1606
- ? this.response({
1607
- type: 'search',
1608
- data: JSON.parse(JSON.stringify(data))
1609
- })
1610
- : data;
1611
- if (this.url && this.executeSearch) {
1612
- this.getTableData({ where: this.wheres });
1613
- }
1614
- this.$emit('search', this.searchWhere);
1615
- },
1616
- hanleReset() {
1617
- this.searchWhere = {};
1618
- this.advanceWhere = {};
1619
- if (this.url) {
1620
- this.getTableData();
1621
- }
1622
- this.$emit('reset', this.params);
1623
- },
1624
- hanleSubmit({ data, show }) {
1625
- this.advanceWhere =
1626
- this.response !== undefined
1627
- ? this.response({
1628
- type: 'filter',
1629
- data: JSON.parse(JSON.stringify(data))
1630
- })
1631
- : data;
1632
-
1633
- if (this.url && this.executeFilter) {
1634
- this.getTableData({ where: this.wheres });
1635
- }
1636
- this.$emit('submit', {
1637
- data: this.advanceWhere,
1638
- where: this.wheres,
1639
- show
1640
- });
1641
- },
1642
- hanleCancel() {
1643
- this.$emit('cancel', this.params);
1644
- },
1645
- handleTabs({ item, index }) {
1646
- if (this.url) {
1647
- this.getTableData({ where: item });
1648
- }
1649
- this.$emit('tabs', { item, index });
1650
- },
1651
- reload(obj, first = false) {
1652
- if (obj && obj.config) {
1653
- this.config = util.extend({}, this.config, obj.config);
1654
- }
1655
- if (this.url) {
1656
- this.isReload = true;
1657
- this.getTableData({ where: obj && obj.where ? obj.where : {}, first });
1658
- }
1659
- },
1660
- resetHeight(warn) {
1661
- this.isSetHeight =
1662
- util.getStyle(this.$el.parentNode, 'height') == '0px' ? false : true;
1663
- this.$nextTick(() => {
1664
- if (this.full && !this.height && !this.maxHeight && this.isSetHeight) {
1665
- let height = this.$el.parentNode.offsetHeight;
1666
- if (height) {
1667
- height = parseInt(
1668
- util.getStyle(this.$el.parentNode, 'height', '%'),
1669
- 10
1670
- );
1671
- height =
1672
- (height == NaN ? 0 : height) -
1673
- parseInt(util.getStyle(this.$el.parentNode, 'padding-top'), 10) -
1674
- parseInt(
1675
- util.getStyle(this.$el.parentNode, 'padding-bottom'),
1676
- 10
1677
- );
1678
- for (let i = 0; i < this.$el.parentNode.childNodes.length; i++) {
1679
- let ele = this.$el.parentNode.childNodes[i];
1680
- if (
1681
- this.$el &&
1682
- ele.offsetHeight !== undefined &&
1683
- ele != this.$el
1684
- ) {
1685
- height =
1686
- height -
1687
- ele.offsetHeight -
1688
- parseInt(util.getStyle(ele, 'margin-top'), 10) -
1689
- parseInt(util.getStyle(ele, 'margin-bottom'), 10);
1690
- }
1691
- }
1692
- height -= this.showToolbar
1693
- ? this.$refs.toolbar.$el.offsetHeight
1694
- : 0;
1695
- height -=
1696
- this.page === false ? 0 : this.$refs.pagination.$el.offsetHeight;
1697
- height -= this.title ? this.$refs.title.offsetHeight : 0;
1698
- height -= parseInt(
1699
- util.getStyle(this.$refs.esTableContent, 'padding-top'),
1700
- 10
1701
- );
1702
- height -= parseInt(
1703
- util.getStyle(this.$refs.esTableContent, 'padding-bottom'),
1704
- 10
1705
- );
1706
- let emptyText = this.$refs.esTableContent.querySelector(
1707
- '.el-table__empty-text'
1708
- );
1709
- if (this.total) {
1710
- height -= 1;
1711
- }
1712
- let eht = 0;
1713
- if (emptyText) {
1714
- eht = emptyText.offsetHeight;
1715
- let thead =
1716
- this.$refs.esTableContent.querySelector('.el-table__header');
1717
- thead && (eht += thead.offsetHeight);
1718
- }
1719
- if (height > 1 && height - eht > 1) {
1720
- this.tableHeight = height;
1721
- } else {
1722
- console.warn(this.$el.parentNode, `获取不到高度!`);
1723
- }
1724
- } else if (!warn) {
1725
- setTimeout(() => {
1726
- this.resetHeight(true);
1727
- }, 1000);
1728
- }
1729
- }
1730
- });
1731
- },
1732
- validate(callback) {
1733
- if (this.form) {
1734
- let form = this.elForm || this.$children[0];
1735
- form.validate((valid) => {
1736
- callback(valid);
1737
- });
1738
- }
1739
- },
1740
- changeLoading(show, text) {
1741
- this.tableLoading = show;
1742
- if (text) {
1743
- this.tableLoadingText = text;
1744
- }
1745
- },
1746
- handleFilterColumn() {
1747
- this.showSizer = true;
1748
- },
1749
- handleSortChange(res) {
1750
- if (res.data && res.data.length) {
1751
- this.list = res.data;
1752
- }
1753
- this.$emit('sort-change', res);
1754
- },
1755
- handleUpdateDragSort(data, event) {
1756
- this.$emit('update-drag-sort', data, event);
1757
- },
1758
- mergeThead(res) {
1759
- this.show = false;
1760
- this.theadData = [];
1761
- this.icon = true;
1762
- this.showSizer = false;
1763
- // if (!this.showTotal) {
1764
- // for (let i = 0; i < res.length; i++) {
1765
- // if (res[i].total) {
1766
- // this.showTotal = true;
1767
- // break;
1768
- // }
1769
- // }
1770
- // }
1771
- this.$nextTick(() => {
1772
- this.theadData = res;
1773
- setTimeout(() => {
1774
- this.show = true;
1775
- }, 500);
1776
- });
1777
- },
1778
- setOptions(val, sysCode) {
1779
- this.$set(this.options, sysCode, val);
1780
- },
1781
- bindEventBus() {
1782
- this.sysCodes.forEach((item) => {
1783
- const bus = this.bus || this.$root.Bus;
1784
- bus &&
1785
- bus.$on(item, (val) => {
1786
- this.setOptions(val, item);
1787
- });
1788
- });
1789
- },
1790
- unbindEventBus() {
1791
- this.sysCodes.forEach((item) => {
1792
- const bus = this.bus || this.$root.Bus;
1793
- bus && bus.$off(item, this.setOptions);
1794
- });
1795
- },
1796
- reset() {
1797
- this.$refs.toolbar && this.$refs.toolbar.reset();
1798
- },
1799
- openEditPage() {
1800
- let fields = [];
1801
- this.theads.forEach((item) => {
1802
- if (item.field || item.prop) {
1803
- fields.push(item.field || item.prop);
1804
- }
1805
- });
1806
- fields = util.esEncode(fields.join(','));
1807
- this.editPage = `/lowcode-ui/webpack/index.html#simpleEditOnlinePage?pageId=${this.viewCode}&fields=${fields}`;
1808
- this.showEditPage = true;
1809
- }
1810
- }
1811
- };
1812
- </script>
1
+ <template>
2
+ <component
3
+ v-show="showTable"
4
+ class="es-data-table"
5
+ label-width="0"
6
+ ref="component"
7
+ v-loading="tableLoading"
8
+ element-loading-background="rgba(0, 0, 0, 0.65)"
9
+ :is="tag"
10
+ :model="tag === 'div' ? '' : list"
11
+ :element-loading-text="tableLoadingText"
12
+ >
13
+ <es-toolbar
14
+ v-if="showToolbar"
15
+ ref="toolbar"
16
+ :class="{
17
+ 'es-table-toolbar-plus': mode == 'plus'
18
+ }"
19
+ v-bind="{
20
+ contents: toolbars,
21
+ showLabel: showLabel,
22
+ close: close,
23
+ callBack: resetHeight,
24
+ showFormBtn: showFormBtn,
25
+ searchValue: searchValue,
26
+ advanceValue: advanceValue
27
+ }"
28
+ v-on="{
29
+ click: handleClick,
30
+ search: hanleSearch,
31
+ submit: hanleSubmit,
32
+ tabs: handleTabs,
33
+ reset: hanleReset,
34
+ cancel: hanleCancel,
35
+ ...(toolbars.events || {})
36
+ }"
37
+ ></es-toolbar>
38
+ <p v-if="title" ref="title" class="es-table-title" v-html="title"></p>
39
+ <div
40
+ v-if="show"
41
+ :style="styles"
42
+ class="es-data-table-content"
43
+ :class="{
44
+ 'es-table-border-none': border == 'none',
45
+ 'es-table-plus': mode == 'plus'
46
+ }"
47
+ ref="esTableContent"
48
+ >
49
+ <el-table
50
+ ref="oaTable"
51
+ v-bind="{
52
+ ...$attrs,
53
+ emptyText: emptyText,
54
+ showSummary: showTotal,
55
+ sumText: sumText || totalText,
56
+ totalRow: restotalRow || totalRow,
57
+ height:
58
+ tableHeight !== 'auto' && tableHeight !== false
59
+ ? tableHeight
60
+ : undefined,
61
+ border: _border,
62
+ infiniteScroll: getTableData,
63
+ infiniteScrollDisabled: infiniteDisabled,
64
+ dragSort: dragSort,
65
+ dragSortClass: dragSortIcon
66
+ }"
67
+ :data.sync="list"
68
+ v-on="{
69
+ ...$listeners,
70
+ 'row-click': rowClick,
71
+ 'selection-change': selectionChange,
72
+ 'filter-column': handleFilterColumn,
73
+ 'sort-change': handleSortChange,
74
+ 'update-drag-sort': handleUpdateDragSort
75
+ }"
76
+ :class="
77
+ 'es-table' +
78
+ (theadBorder && border != 'none' ? ' es-thead-border' : '')
79
+ "
80
+ >
81
+ <slot name="suffix"></slot>
82
+ <slot></slot>
83
+ <template v-for="(item, index) in theads">
84
+ <template v-if="item.hide !== true">
85
+ <el-table-column
86
+ v-if="item.type === 'sort'"
87
+ width="32"
88
+ prop="id"
89
+ :key="item.key || item.label || item.title || index"
90
+ label=" "
91
+ >
92
+ <template slot-scope="scope">
93
+ <es-icon
94
+ v-if="!scope.row.fixed"
95
+ class="es-move"
96
+ :contents="dragSortIcon"
97
+ ></es-icon>
98
+ </template>
99
+ </el-table-column>
100
+ <template
101
+ v-else-if="item.type === 'index' || item.type === 'selection'"
102
+ >
103
+ <el-table-column
104
+ :key="item.key || item.label || item.title || index"
105
+ v-bind="dragSort ? { ...item, fixed: false } : item"
106
+ ></el-table-column>
107
+ </template>
108
+ <template v-else>
109
+ <children
110
+ :tag="item.tag"
111
+ v-bind="{
112
+ mode: mode,
113
+ name: name,
114
+ indexs: index,
115
+ form: form,
116
+ readonly: readonly,
117
+ optionData: optionDatas,
118
+ dragSort: dragSort,
119
+ key: item.key || item.label || item.title || index,
120
+ ...(dragSort ? { ...item, fixed: false } : { ...item })
121
+ }"
122
+ v-on="{
123
+ handleClick: handleClick,
124
+ formBlur: formBlur,
125
+ formFocus: formFocus,
126
+ formChange: formChange
127
+ }"
128
+ ></children>
129
+ </template>
130
+ </template>
131
+ </template>
132
+ <slot name="prefix"></slot>
133
+ <el-table-column
134
+ v-if="editable && !readonly"
135
+ width="80"
136
+ type="handle"
137
+ align="center"
138
+ label="操作"
139
+ fixed="right"
140
+ class="eoss-ui-eidt-column"
141
+ :button="headButton"
142
+ :total="false"
143
+ >
144
+ <template slot-scope="scope">
145
+ <el-button
146
+ v-if="!scope.row.cantAdd"
147
+ type="text"
148
+ @click="handleClickAddData(scope)"
149
+ >
150
+ <i class="el-icon-circle-plus-outline"></i>
151
+ </el-button>
152
+ <el-button
153
+ v-if="!scope.row.cantDelete && !isLeast"
154
+ type="text"
155
+ @click="handleClickDeleteData(scope)"
156
+ >
157
+ <i class="el-icon-remove-outline"></i>
158
+ </el-button>
159
+ </template>
160
+ </el-table-column>
161
+ <template slot="append"><slot name="append"></slot></template>
162
+ </el-table>
163
+ <div v-if="infiniteScroll" class="es-table-page es-loading-page">
164
+ <span>共{{ config.totalCount }}条,</span>
165
+ <span>已加载{{ list.length }}条</span>
166
+ </div>
167
+ <es-pagination
168
+ v-else-if="page"
169
+ ref="pagination"
170
+ v-bind="config"
171
+ class="es-table-page"
172
+ :position="page.position"
173
+ :style="{ 'text-align': page.position }"
174
+ v-on="{
175
+ change: sizeChange,
176
+ current: currentChange,
177
+ prev: preClick,
178
+ next: nextClick
179
+ }"
180
+ ></es-pagination>
181
+ <slot name="dialog"></slot>
182
+ <slot name="other"></slot>
183
+ </div>
184
+ <es-dialog v-if="theads.length" title="列表设置" :visible.sync="showSizer">
185
+ <sizer
186
+ v-if="showSizer"
187
+ :data="theads"
188
+ :mode="mode"
189
+ @confirm="mergeThead"
190
+ ></sizer>
191
+ </es-dialog>
192
+ <i
193
+ class="el-icon-setting es-table-setting"
194
+ title="页面配置"
195
+ v-if="isShow"
196
+ @click="openEditPage"
197
+ ></i>
198
+
199
+ <es-dialog title="页面配置" :visible.sync="showEditPage" size="full">
200
+ <iframe
201
+ v-if="showEditPage"
202
+ width="100%"
203
+ height="100%"
204
+ frameborder="0"
205
+ :src="editPage"
206
+ ></iframe>
207
+ </es-dialog>
208
+ </component>
209
+ </template>
210
+ <script>
211
+ import {
212
+ findSysCode,
213
+ getDictList,
214
+ formContents
215
+ } from 'eoss-ui/src/config/api.js';
216
+ import { debounce } from 'throttle-debounce';
217
+ import children from './children.vue';
218
+ import sizer from './sizer.vue';
219
+ import util from 'eoss-ui/src/utils/util';
220
+ import qs from 'qs';
221
+ const systemMode = util.win.top.systemMode || util.win.systemMode || 'default';
222
+ const pageView = util.getParams('pageView');
223
+ export default {
224
+ name: 'EsDataTable',
225
+ inheritAttrs: false,
226
+ components: {
227
+ children,
228
+ sizer
229
+ },
230
+ provide() {
231
+ return {
232
+ table: this,
233
+ tableReload: this.reload
234
+ };
235
+ },
236
+ inject: {
237
+ elForm: {
238
+ default: ''
239
+ },
240
+ injector: {
241
+ default: ''
242
+ },
243
+ scale: {
244
+ default: ''
245
+ }
246
+ },
247
+ props: {
248
+ viewCode: {
249
+ type: String,
250
+ default: pageView
251
+ },
252
+ contentsUrl: {
253
+ type: String,
254
+ default: formContents
255
+ },
256
+ mode: {
257
+ type: String,
258
+ default: systemMode
259
+ },
260
+ service: String,
261
+ loading: {
262
+ type: Boolean,
263
+ default: false
264
+ },
265
+ readonly: Boolean,
266
+ url: {
267
+ type: String,
268
+ default: ''
269
+ },
270
+ defaults: {
271
+ type: Boolean,
272
+ default: false
273
+ },
274
+ param: {
275
+ type: Object,
276
+ default() {
277
+ return {};
278
+ }
279
+ },
280
+ method: {
281
+ type: String,
282
+ default: 'get'
283
+ },
284
+ isEncodeURI: Boolean,
285
+ format: {
286
+ type: Boolean,
287
+ default: true
288
+ },
289
+ data: {
290
+ type: Array,
291
+ default() {
292
+ return [];
293
+ }
294
+ },
295
+ // 表格表单
296
+ form: {
297
+ type: Boolean,
298
+ default: false
299
+ },
300
+ name: String,
301
+ title: {
302
+ type: String,
303
+ default: ''
304
+ },
305
+ // 导出文件名
306
+ fileName: {
307
+ type: String,
308
+ default: ''
309
+ },
310
+ // 工具栏配置
311
+ toolbar: {
312
+ type: [Array, Boolean],
313
+ default: false
314
+ },
315
+ showLabel: Boolean,
316
+ searchValue: Object,
317
+ advanceValue: Object,
318
+ executeSearch: {
319
+ type: Boolean,
320
+ default: true
321
+ },
322
+ executeFilter: {
323
+ type: Boolean,
324
+ default: true
325
+ },
326
+ // 是否开启序号
327
+ numbers: {
328
+ type: Boolean,
329
+ default: false
330
+ },
331
+ orders: {
332
+ type: String,
333
+ default: 'asc'
334
+ },
335
+ // 是否筛选列功能
336
+ filter: {
337
+ type: Boolean,
338
+ default: false
339
+ },
340
+ // 是否开启多选
341
+ checkbox: {
342
+ type: Boolean,
343
+ default: false
344
+ },
345
+ selectable: Function,
346
+ reserveSelection: Boolean,
347
+ // 默认选中,类型为Boolean时默认全(不)选
348
+ checked: {
349
+ type: [Boolean, Array],
350
+ default: false
351
+ },
352
+ checkedKey: {
353
+ type: String,
354
+ default: 'id'
355
+ },
356
+ // 无数据时显示的文本
357
+ emptyText: {
358
+ type: String,
359
+ default: ''
360
+ },
361
+ // 是否开启合计行区域
362
+ total: {
363
+ type: Boolean,
364
+ default: false
365
+ },
366
+ //本地数据总条数差值
367
+ lose: {
368
+ type: Number,
369
+ default: 0
370
+ },
371
+ // 合计行显示文本
372
+ totalText: {
373
+ type: String,
374
+ default: ''
375
+ },
376
+ showSummary: {
377
+ type: Boolean,
378
+ default: false
379
+ },
380
+ sumText: {
381
+ type: String,
382
+ default: ''
383
+ },
384
+ // 开启分页
385
+ page: {
386
+ type: [Boolean, Object],
387
+ default() {
388
+ return false;
389
+ }
390
+ },
391
+ // 渲染树形数据指定field
392
+ treeKey: {
393
+ type: String,
394
+ default: ''
395
+ },
396
+ // 单元格配置
397
+ thead: {
398
+ type: Array,
399
+ default() {
400
+ return [];
401
+ }
402
+ },
403
+ optionData: Object,
404
+ // 开启数据增加删除按钮
405
+ editable: {
406
+ type: Boolean,
407
+ default: false
408
+ },
409
+ theadAdd: {
410
+ type: Boolean,
411
+ default: true
412
+ },
413
+ // 单元格点击事件
414
+ click: {
415
+ type: Boolean,
416
+ default: false
417
+ },
418
+ totalRow: {
419
+ type: Object,
420
+ default() {
421
+ return {};
422
+ }
423
+ },
424
+ parseData: Function,
425
+ close: Boolean,
426
+ full: {
427
+ type: Boolean,
428
+ default: true
429
+ },
430
+ height: [Number, String],
431
+ maxHeight: [Number, String],
432
+ response: Function,
433
+ minWidth: [Number, String],
434
+ border: {
435
+ type: [Boolean, String],
436
+ default: false,
437
+ validator: function (value) {
438
+ return [true, false, 'none'].includes(value);
439
+ }
440
+ },
441
+ theadBorder: {
442
+ type: Boolean,
443
+ default: true
444
+ },
445
+ checkboxParseData: Function,
446
+ checkboxParse: Object,
447
+ display: {
448
+ type: Boolean,
449
+ default: true
450
+ },
451
+ showFormBtn: {
452
+ type: Boolean,
453
+ default: true
454
+ },
455
+ index: {
456
+ type: [Number, Function],
457
+ default: 1
458
+ },
459
+ accumulated: {
460
+ type: Boolean,
461
+ default: true
462
+ },
463
+ immediate: {
464
+ type: Boolean,
465
+ default: true
466
+ },
467
+ zoom: false,
468
+ exportExcludeLabel: {
469
+ type: Array,
470
+ default() {
471
+ return [];
472
+ }
473
+ },
474
+ rowData: [Object, Boolean],
475
+ least: Boolean,
476
+ //保留搜索参数
477
+ retainSearh: Boolean,
478
+ //无线滚动
479
+ infiniteScroll: Boolean,
480
+ isJoin: {
481
+ type: Boolean,
482
+ default: true
483
+ },
484
+ ajaxConfig: {
485
+ type: Object,
486
+ default() {
487
+ return {};
488
+ }
489
+ },
490
+ dragSort: Boolean,
491
+ dragSortIcon: {
492
+ type: String,
493
+ default: 'es-icon-caidan'
494
+ },
495
+ isFieldsEncryption: Boolean,
496
+ contentSuccess: Function,
497
+ resetScroll: {
498
+ type: Boolean,
499
+ default: true
500
+ }
501
+ },
502
+ data() {
503
+ return {
504
+ isEncryption: this.isFieldsEncryption,
505
+ requests: [],
506
+ toolbars: [],
507
+ hasThead: false,
508
+ theadData: [],
509
+ list: [],
510
+ tableLoading: this.loading,
511
+ tableLoadingText: '加载中...',
512
+ isFirsetCheck: false,
513
+ // 可修改表单的值
514
+ editValue: {},
515
+ restotalRow: null,
516
+ showTotal: false,
517
+ config: {
518
+ pageNum: 1,
519
+ pageSize: 20,
520
+ totalCount: 0,
521
+ layout:
522
+ this.mode == 'plus'
523
+ ? 'total, sizes, prev, pager, next, jumper'
524
+ : undefined
525
+ },
526
+ searchWhere: {},
527
+ advanceWhere: {},
528
+ tableHeight: 'auto',
529
+ styles: {},
530
+ selected: null,
531
+ options: {},
532
+ icon: true,
533
+ sysCodes: [],
534
+ infiniteDisabled: !this.infiniteScroll,
535
+ isReload: false,
536
+ pageView: null,
537
+ showSizer: false,
538
+ show: true,
539
+ isSetHeight: false,
540
+ showTable: false,
541
+ fields: null,
542
+ showEditPage: false,
543
+ editPage: ''
544
+ };
545
+ },
546
+ computed: {
547
+ wheres() {
548
+ return { ...this.searchWhere, ...this.advanceWhere };
549
+ },
550
+ params() {
551
+ return {
552
+ ...(this.param || {}),
553
+ ...(this.searchValue || {}),
554
+ ...(this.advanceValue || {})
555
+ };
556
+ },
557
+ tag() {
558
+ return this.form && this.elForm == '' ? 'el-form' : 'div';
559
+ },
560
+ _border() {
561
+ return this.border === true ? true : false;
562
+ },
563
+ theads: {
564
+ get() {
565
+ let types;
566
+ types = this.theadData
567
+ .filter((item) => {
568
+ return (
569
+ item.type == 'selection' ||
570
+ item.type == 'index' ||
571
+ item.type == 'sort' ||
572
+ item.type == 'handle'
573
+ );
574
+ })
575
+ .map((item) => {
576
+ return item.type;
577
+ });
578
+ let thead = [];
579
+ let addfilter = false;
580
+ if (this.dragSort && !types.includes('sort')) {
581
+ addfilter = true;
582
+ thead.push({
583
+ type: 'sort',
584
+ key: 'es-sort'
585
+ });
586
+ }
587
+ if (this.checkbox && !types.includes('selection')) {
588
+ thead.push({
589
+ type: 'selection',
590
+ width: '55',
591
+ align: 'center',
592
+ fixed: 'left',
593
+ selectable: this.selectable,
594
+ reserveSelection: this.reserveSelection,
595
+ filterIcon: this.filter && !addfilter ? 'es-icon-biao' : undefined,
596
+ key: 'es-checkbox'
597
+ });
598
+ if (!addfilter) {
599
+ addfilter = true;
600
+ }
601
+ }
602
+ if (this.numbers && !types.includes('index')) {
603
+ let index = 1;
604
+ if (typeof this.index === 'function') {
605
+ index = this.index;
606
+ } else {
607
+ if (this.orders == 'desc') {
608
+ index = (num) => {
609
+ return this.config.totalCount - num;
610
+ };
611
+ } else if (this.accumulated) {
612
+ index =
613
+ (this.config.pageNum - 1) * this.config.pageSize + this.index;
614
+ } else {
615
+ index = this.index;
616
+ }
617
+ }
618
+ thead.push({
619
+ type: 'index',
620
+ label: '序号',
621
+ width: '70',
622
+ align: 'center',
623
+ fixed: 'left',
624
+ index: index,
625
+ filterIcon: this.filter && !addfilter ? 'es-icon-biao' : undefined,
626
+ key: 'es-index'
627
+ });
628
+ if (!addfilter) {
629
+ addfilter = true;
630
+ }
631
+ }
632
+ if (this.theadData.length) {
633
+ let handle = this.thead.filter((item) => {
634
+ return item.type == 'handle';
635
+ });
636
+ thead = [
637
+ ...thead,
638
+ ...this.theadData,
639
+ ...(types.includes('handle') ? [] : handle)
640
+ ];
641
+ } else if (this.show) {
642
+ thead = [...thead, ...this.thead];
643
+ }
644
+ return thead;
645
+ },
646
+ set(val) {
647
+ return val;
648
+ }
649
+ },
650
+ datas: {
651
+ get() {
652
+ if (this.list && this.list.length) {
653
+ return this.list;
654
+ }
655
+ if (
656
+ this.page &&
657
+ ((typeof this.page === 'object' &&
658
+ (!Object.prototype.hasOwnProperty.call(this.page, 'totalCount') ||
659
+ this.page.totalCount == 0)) ||
660
+ this.page === true)
661
+ ) {
662
+ this.config.totalCount = this.data.length - this.lose;
663
+ }
664
+ if (this.page && this.data.length > this.config.pageSize) {
665
+ return this.data.filter((item, index) => {
666
+ return (
667
+ index > (this.config.pageNum - 1) * this.config.pageSize - 1 &&
668
+ index < this.config.pageNum * this.config.pageSize
669
+ );
670
+ });
671
+ }
672
+ return this.data;
673
+ },
674
+ set(val) {
675
+ if (this.list && this.list.length) {
676
+ this.$nextTick(() => {
677
+ this.list = val;
678
+ });
679
+ }
680
+ this.$emit('update:data', val);
681
+ return val;
682
+ }
683
+ },
684
+ showToolbar() {
685
+ if (this.readonly) {
686
+ return false;
687
+ }
688
+ if (typeof this.toolbar === 'boolean') {
689
+ if (this.toolbar) {
690
+ this.toolbars = [
691
+ {
692
+ type: 'search',
693
+ contents: [
694
+ {
695
+ type: 'text',
696
+ name: 'keyword',
697
+ placeholder: '请输入关键字'
698
+ }
699
+ ]
700
+ }
701
+ ];
702
+ }
703
+ return this.toolbar;
704
+ } else {
705
+ this.toolbars = this.toolbar;
706
+ return true;
707
+ }
708
+ },
709
+ optionDatas: {
710
+ get() {
711
+ let data = this.optionData
712
+ ? { ...this.optionData, ...this.options }
713
+ : this.options;
714
+ return data;
715
+ },
716
+ set(val) {
717
+ return val;
718
+ }
719
+ },
720
+ headButton() {
721
+ return this.theadAdd && !this.readonly
722
+ ? {
723
+ icon: 'el-icon-circle-plus-outline',
724
+ type: 'text',
725
+ event: this.handleClickAddData
726
+ }
727
+ : undefined;
728
+ },
729
+ isLeast() {
730
+ return this.data.length < 2 && this.least;
731
+ },
732
+ findCode() {
733
+ if (this.service) {
734
+ return `/${this.service}${getDictList}`;
735
+ }
736
+ return findSysCode;
737
+ },
738
+ isShow() {
739
+ let useCaseCodes = util.getStorage('useCaseCodes');
740
+ return (
741
+ this.viewCode &&
742
+ useCaseCodes &&
743
+ (useCaseCodes.indexOf('SuperAdminRoleID') > -1 ||
744
+ useCaseCodes.indexOf('OrgAdminRoleID') > -1)
745
+ );
746
+ }
747
+ },
748
+ watch: {
749
+ viewCode: {
750
+ immediate: true,
751
+ handler(val) {
752
+ if (val) {
753
+ this.hasThead = true;
754
+ this.getContents();
755
+ }
756
+ }
757
+ },
758
+ showToolbar() {
759
+ this.resetHeight();
760
+ this.doLayout();
761
+ },
762
+ data: {
763
+ deep: true,
764
+ handler() {
765
+ this.list = this.setData();
766
+ }
767
+ },
768
+ scale: {
769
+ deep: true,
770
+ handler(val) {
771
+ if (
772
+ this.tableHeight != 'auto' &&
773
+ this.tableHeight !== false &&
774
+ this.display
775
+ ) {
776
+ this.resetHeight();
777
+ this.doLayout();
778
+ }
779
+ }
780
+ },
781
+ zoom: {
782
+ handler() {
783
+ if (
784
+ this.tableHeight != 'auto' &&
785
+ this.tableHeight !== false &&
786
+ this.display
787
+ ) {
788
+ this.resetHeight();
789
+ this.doLayout();
790
+ }
791
+ }
792
+ },
793
+ checked(newVal) {
794
+ this.list.length && this.checkSelect(newVal);
795
+ },
796
+ thead: {
797
+ deep: true,
798
+ handler(val) {
799
+ this.getOptions(val);
800
+ this.chekOpenTotalArea();
801
+ if (Array.isArray(val) && val.length && this.datas.length == 0) {
802
+ this.getTableData();
803
+ }
804
+ }
805
+ },
806
+ theads: {
807
+ deep: true,
808
+ handler() {
809
+ this.chekOpenTotalArea();
810
+ }
811
+ },
812
+ param: {
813
+ handler(val) {
814
+ this.getTableData();
815
+ }
816
+ },
817
+ page: {
818
+ immediate: true,
819
+ deep: true,
820
+ handler(val) {
821
+ if (this.$el) {
822
+ this.resetHeight();
823
+ this.doLayout();
824
+ }
825
+ if (typeof val === 'object') {
826
+ this.config = util.extend({}, this.config, val);
827
+ }
828
+ }
829
+ },
830
+ 'config.pageNum'() {
831
+ if (this.data.length) {
832
+ this.resetScroll &&
833
+ this.$refs.oaTable &&
834
+ this.$refs.oaTable.resetScroll &&
835
+ this.$refs.oaTable.resetScroll(0, 0);
836
+ this.list = this.setData();
837
+ }
838
+ },
839
+ height: {
840
+ immediate: true,
841
+ handler(val) {
842
+ if (val) {
843
+ this.tableHeight = val;
844
+ }
845
+ }
846
+ },
847
+ maxHeight: {
848
+ immediate: true,
849
+ handler(val) {
850
+ if (val && this.height === undefined) {
851
+ this.tableHeight = val;
852
+ }
853
+ }
854
+ },
855
+ display(val) {
856
+ if (val) {
857
+ this.resetHeight();
858
+ this.doLayout();
859
+ }
860
+ },
861
+ showEditPage(val) {
862
+ if (val === false) {
863
+ util.win.top.refresh();
864
+ }
865
+ }
866
+ },
867
+ beforeCreate() {
868
+ this.getTableData = debounce(500, (res) => {
869
+ this.getTableDatas(res);
870
+ });
871
+ },
872
+ created() {
873
+ if (Array.isArray(this.thead) && this.thead.length) {
874
+ this.getOptions(this.thead);
875
+ this.immediate && !this.viewCode && this.getTableData();
876
+ }
877
+ this.chekOpenTotalArea();
878
+ },
879
+ mounted() {
880
+ this.showTable = true;
881
+ if (this.data.length) {
882
+ this.list = this.setData();
883
+ }
884
+ this.list.length && this.checkSelect(this.checked);
885
+ this.resetHeight();
886
+ if (util.win.top != util.win.self) {
887
+ util.win.onresize = debounce(500, this.resetHeight);
888
+ }
889
+ },
890
+ methods: {
891
+ setData() {
892
+ if (
893
+ this.page &&
894
+ ((typeof this.page === 'object' &&
895
+ (!Object.prototype.hasOwnProperty.call(this.page, 'totalCount') ||
896
+ this.page.totalCount == 0)) ||
897
+ this.page === true)
898
+ ) {
899
+ this.config.totalCount = this.data.length - this.lose;
900
+ }
901
+ if (this.page && this.data.length > this.config.pageSize) {
902
+ return this.data.filter((item, index) => {
903
+ return (
904
+ index > (this.config.pageNum - 1) * this.config.pageSize - 1 &&
905
+ index < this.config.pageNum * this.config.pageSize
906
+ );
907
+ });
908
+ }
909
+ return this.data;
910
+ },
911
+ getRequestKey(config) {
912
+ const { method, url, params, data } = config;
913
+ return [method, url, qs.stringify(params), qs.stringify(data)].join('&');
914
+ },
915
+ getContents() {
916
+ util
917
+ .ajax({
918
+ url: this.contentsUrl,
919
+ params: {
920
+ formId: this.viewCode
921
+ }
922
+ })
923
+ .then((res) => {
924
+ if (res.rCode == 0) {
925
+ if (this.contentSuccess) {
926
+ this.contentSuccess(res.results);
927
+ } else {
928
+ let {
929
+ results: { eossFormJson }
930
+ } = res;
931
+ eossFormJson = JSON.parse(eossFormJson);
932
+ if (eossFormJson && eossFormJson.table) {
933
+ this.isEncryption = true;
934
+ this.theadData = eossFormJson.table.thead;
935
+ this.getTableData();
936
+ } else {
937
+ this.hasThead = false;
938
+ }
939
+ this.$emit('init-contents', res.results);
940
+ }
941
+ }
942
+ });
943
+ },
944
+ getOptions(res) {
945
+ let sysCodes = [];
946
+ res.forEach((item) => {
947
+ if (item.sysCode || item.url) {
948
+ item.sysCode && sysCodes.push(item.sysCode);
949
+ let params = util.extend(
950
+ {},
951
+ item.sysCode
952
+ ? { sysAppCode: item.sysCode, code: item.sysCode }
953
+ : {},
954
+ item.param ? item.param : {}
955
+ );
956
+ let key = this.getRequestKey({
957
+ method: this.method,
958
+ url: item.sysCode ? this.findCode : item.url,
959
+ params: params,
960
+ data: {}
961
+ });
962
+ if (!this.requests.includes(key)) {
963
+ util
964
+ .ajax({
965
+ url: item.sysCode ? this.findCode : item.url,
966
+ method: this.method,
967
+ params: params,
968
+ data: params
969
+ })
970
+ .then((res) => {
971
+ if (res.rCode === 0) {
972
+ if (item.type == 'ganged') {
973
+ this.$set(
974
+ this.options,
975
+ item.sysCode || item.field || item.prop,
976
+ [JSON.parse(JSON.stringify(res.results))]
977
+ );
978
+ if (item.sysCode) {
979
+ const bus = this.bus || this.$root.Bus;
980
+ bus &&
981
+ bus.$emit(
982
+ item.sysCode,
983
+ JSON.parse(JSON.stringify(this.options[item.sysCode]))
984
+ );
985
+ }
986
+ } else {
987
+ this.$set(
988
+ this.options,
989
+ item.sysCode || item.field || item.prop,
990
+ JSON.parse(JSON.stringify(res.results))
991
+ );
992
+ if (item.sysCode) {
993
+ const bus = this.bus || this.$root.Bus;
994
+ bus &&
995
+ bus.$emit(
996
+ item.sysCode,
997
+ JSON.parse(JSON.stringify(res.results))
998
+ );
999
+ }
1000
+ }
1001
+ this.requests.push(key);
1002
+ } else {
1003
+ let msg = res.msg || '系统错误,请联系管理员!';
1004
+ this.$message.error(msg);
1005
+ }
1006
+ })
1007
+ .catch((err) => {
1008
+ if (err.message && err.message !== 'canceled') {
1009
+ this.$message.error(err.message);
1010
+ }
1011
+ });
1012
+ }
1013
+ } else {
1014
+ if (item.childHead && item.childHead.length) {
1015
+ this.getOptions(item.childHead);
1016
+ }
1017
+ if (item.children && item.children.length) {
1018
+ this.getOptions(item.children);
1019
+ }
1020
+ }
1021
+ });
1022
+ this.sysCodes = sysCodes;
1023
+
1024
+ this.bindEventBus();
1025
+ },
1026
+ checkObject(item) {
1027
+ return util.getObjectType(item) === 'object';
1028
+ },
1029
+ chekOpenTotalArea() {
1030
+ if (this.total || this.showSummary) {
1031
+ this.showTotal = true;
1032
+ return;
1033
+ }
1034
+ if (!this.theads) {
1035
+ return;
1036
+ }
1037
+ const arr = JSON.parse(JSON.stringify(this.theads));
1038
+ let flag = false;
1039
+ arr.forEach((item) => {
1040
+ if (item.total) {
1041
+ flag = true;
1042
+ this.showTotal = true;
1043
+ }
1044
+ });
1045
+ if (this.showTotal !== flag) {
1046
+ this.showTotal = flag;
1047
+ }
1048
+ },
1049
+ rowClick(row, column, event) {
1050
+ this.$emit('click', row, column, event);
1051
+ this.$emit('row-click', row, column, event);
1052
+ },
1053
+ handleClickAddData(scope) {
1054
+ if (scope && scope.row) {
1055
+ const data = JSON.parse(JSON.stringify(scope.row));
1056
+ let index = scope.$index + 1;
1057
+ if (this.page) {
1058
+ index += (this.config.pageNum - 1) * this.config.pageSize;
1059
+ }
1060
+ this.data.splice(index, 0, data);
1061
+ this.$emit('dataChange', 'add', data);
1062
+ this.$emit('data-change', 'add', data);
1063
+ this.$emit('btnClick', {
1064
+ event: 'addRow',
1065
+ row: data,
1066
+ index: index,
1067
+ data: this.data
1068
+ });
1069
+ this.$emit('btn-click', {
1070
+ event: 'addRow',
1071
+ row: data,
1072
+ index: index,
1073
+ data: this.data
1074
+ });
1075
+ } else {
1076
+ let index = this.data.length;
1077
+ if (this.page) {
1078
+ index += (this.config.pageNum - 1) * this.config.pageSize;
1079
+ }
1080
+ let rows = {};
1081
+ if (this.rowData && typeof this.rowData == 'object') {
1082
+ rows = this.rowData;
1083
+ } else if (index && this.rowData === true) {
1084
+ rows = JSON.parse(JSON.stringify(this.data[index - 1]));
1085
+ } else {
1086
+ this.getRow(this.thead, rows);
1087
+ }
1088
+ this.data.splice(index, 0, rows);
1089
+ }
1090
+ },
1091
+ getRow(thead, obj) {
1092
+ thead.forEach((item) => {
1093
+ if (item.field) {
1094
+ obj[item['field']] = item.defaultValue || '';
1095
+ } else if (item.children && item.children.length) {
1096
+ this.getRow(item.children, obj);
1097
+ }
1098
+ });
1099
+ },
1100
+ handleClickDeleteData(scope) {
1101
+ const data = JSON.parse(JSON.stringify(scope.row));
1102
+ let index = scope.$index;
1103
+ if (this.page) {
1104
+ index += (this.config.pageNum - 1) * this.config.pageSize;
1105
+ }
1106
+ this.data.splice(index, 1);
1107
+ this.$emit('dataChange', 'delete', data);
1108
+ this.$emit('data-change', 'delete', data);
1109
+ this.$emit('btnClick', {
1110
+ event: 'deleteRow',
1111
+ row: data,
1112
+ index: index,
1113
+ data: this.data
1114
+ });
1115
+ this.$emit('btn-click', {
1116
+ event: 'deleteRow',
1117
+ row: data,
1118
+ index: index,
1119
+ data: this.data
1120
+ });
1121
+ },
1122
+ checkSelect(newVal) {
1123
+ this.$nextTick(() => {
1124
+ if (util.getObjectType(newVal) === 'array') {
1125
+ newVal.forEach((row) => {
1126
+ if (util.isObject(row)) {
1127
+ this.$refs.oaTable.toggleRowSelection(row, true);
1128
+ } else {
1129
+ this.setChecked(this.list, row);
1130
+ }
1131
+ });
1132
+ } else if (newVal === true) {
1133
+ this.toggleAllSelection();
1134
+ }
1135
+ });
1136
+ },
1137
+ setChecked(list, row) {
1138
+ list.forEach((item) => {
1139
+ if (item.children && item.children.length) {
1140
+ this.setChecked(item.children, row);
1141
+ }
1142
+ if (item[this.checkedKey] === row) {
1143
+ this.$refs.oaTable.toggleRowSelection(item, true);
1144
+ return;
1145
+ }
1146
+ });
1147
+ },
1148
+ getTableDatas(res) {
1149
+ let where;
1150
+ let first;
1151
+ if (res) {
1152
+ where = res.where;
1153
+ first = res.first;
1154
+ }
1155
+ if (!this.url) {
1156
+ return;
1157
+ }
1158
+ if (first !== false && !this.infiniteScroll) {
1159
+ this.config.pageNum = 1;
1160
+ }
1161
+ this.tableLoadingText = '加载中...';
1162
+ let reqData = util.extend(
1163
+ {},
1164
+ this.params,
1165
+ this.page
1166
+ ? {
1167
+ pageNum: this.config.pageNum,
1168
+ pageSize: this.config.pageSize
1169
+ }
1170
+ : {}
1171
+ );
1172
+ if (where) {
1173
+ reqData = util.extend({}, reqData, where);
1174
+ }
1175
+ //if (this.fields)
1176
+ if (this.retainSearh || first === false) {
1177
+ reqData = util.extend({}, reqData, this.wheres);
1178
+ }
1179
+ if (this.isJoin) {
1180
+ for (let i in reqData) {
1181
+ if (Array.isArray(reqData[i])) {
1182
+ reqData[i] = reqData[i].join(',');
1183
+ }
1184
+ }
1185
+ }
1186
+ if (this.isEncryption) {
1187
+ let fields = [];
1188
+ this.theads.forEach((item) => {
1189
+ if (item.field || item.prop) {
1190
+ fields.push(item.field || item.prop);
1191
+ }
1192
+ });
1193
+ let initLogin = util.getStorage('initLogin');
1194
+ initLogin && (initLogin = JSON.parse(initLogin));
1195
+ reqData['fields'] = initLogin.secret
1196
+ ? util.esmEncrypt({
1197
+ data: fields.join(','),
1198
+ key: initLogin.secret
1199
+ })
1200
+ : fields.join(',');
1201
+ }
1202
+ this.tableLoading = true;
1203
+ util
1204
+ .ajax({
1205
+ ...this.ajaxConfig,
1206
+ url: this.url,
1207
+ method: this.method,
1208
+ format: this.format,
1209
+ params: reqData,
1210
+ data: reqData
1211
+ })
1212
+ .then((res) => {
1213
+ this.tableLoading = false;
1214
+ if (res.rCode === 0 || res.status === 'success') {
1215
+ if (this.isReload) {
1216
+ this.list = [];
1217
+ this.isReload = false;
1218
+ }
1219
+ let results =
1220
+ this.parseData !== undefined
1221
+ ? this.parseData(res.results || res.data || res)
1222
+ : res.results || res.data;
1223
+ if (this.infiniteScroll) {
1224
+ this.list = this.list.concat(
1225
+ results.data || results.records || results.list
1226
+ );
1227
+ this.config.pageNum += 1;
1228
+ } else {
1229
+ this.list = results.data || results.records || results.list;
1230
+ this.$nextTick(() => {
1231
+ this.resetScroll &&
1232
+ this.$refs.oaTable &&
1233
+ this.$refs.oaTable.resetScroll &&
1234
+ this.$refs.oaTable.resetScroll(0, 0);
1235
+ });
1236
+ }
1237
+ this.config.totalCount =
1238
+ results.count || results.total || results.totalCount;
1239
+ this.config.pageCount = results.pageCount;
1240
+ this.checked &&
1241
+ this.$nextTick(() => {
1242
+ this.checkSelect(this.checked);
1243
+ });
1244
+ if (
1245
+ this.infiniteScroll &&
1246
+ this.config.totalCount === this.list.length
1247
+ ) {
1248
+ this.infiniteDisabled = true;
1249
+ }
1250
+ } else {
1251
+ this.list = [];
1252
+ //this.tableHeight = false;
1253
+ let msg = res.msg || '系统错误,请联系管理员!';
1254
+ this.$message.error(msg);
1255
+ }
1256
+ this.$emit('success', res);
1257
+ })
1258
+ .catch((err) => {
1259
+ //this.tableHeight = false;
1260
+ if (err.message && err.message !== 'canceled') {
1261
+ this.$message.error(err.message);
1262
+ }
1263
+ this.tableLoading = false;
1264
+ });
1265
+ },
1266
+ selectionChange(data) {
1267
+ this.selected = JSON.parse(JSON.stringify(data));
1268
+ this.$emit('selection-change', data);
1269
+ },
1270
+ clearSelection() {
1271
+ this.$refs.oaTable.clearSelection();
1272
+ },
1273
+ toggleRowSelection(row, selected) {
1274
+ this.$refs.oaTable.toggleRowSelection(row, selected);
1275
+ },
1276
+ toggleAllSelection() {
1277
+ this.$refs.oaTable.toggleAllSelection();
1278
+ },
1279
+ toggleRowExpansion(row, expanded) {
1280
+ this.$refs.oaTable.toggleRowExpansion(row, expanded);
1281
+ },
1282
+ setCurrentRow(row) {
1283
+ this.$refs.oaTable.setCurrentRow(row);
1284
+ },
1285
+
1286
+ clearSort() {
1287
+ this.$refs.oaTable.clearSort();
1288
+ },
1289
+ clearFilter(columnKey) {
1290
+ this.$refs.oaTable.clearFilter(columnKey);
1291
+ },
1292
+ doLayout() {
1293
+ this.$refs.oaTable && this.$refs.oaTable.doLayout();
1294
+ },
1295
+ sort(prop, order) {
1296
+ this.$refs.oaTable.sort(prop, order);
1297
+ },
1298
+ formBlur(data) {
1299
+ this.$emit('blur', data, this.list);
1300
+ },
1301
+ formFocus(data) {
1302
+ this.$emit('focus', data, this.list);
1303
+ },
1304
+ formChange(data) {
1305
+ this.$emit('edit', data, this.list);
1306
+ this.$emit('change', data, this.list);
1307
+ },
1308
+ handleAjax(handle, row) {
1309
+ this.changeLoading(true, `${handle.text}中...`);
1310
+ let params = handle.param || {};
1311
+ if (handle.syncKeys) {
1312
+ if (typeof handle.syncKeys === 'string') {
1313
+ params[handle.syncKeys] = row[handle.syncKeys];
1314
+ } else if (Array.isArray(handle.syncKeys)) {
1315
+ for (let i in handle.syncKeys) {
1316
+ if (Array.isArray(row)) {
1317
+ let param = row.map((item) => {
1318
+ return item[handle.syncKeys[i]];
1319
+ });
1320
+ params[handle.syncKeys[i]] = param.join(',');
1321
+ } else {
1322
+ params[handle.syncKeys[i]] = row[handle.syncKeys[i]];
1323
+ }
1324
+ }
1325
+ } else {
1326
+ for (let i in handle.syncKeys) {
1327
+ if (Array.isArray(row)) {
1328
+ let param = row.map((item) => {
1329
+ return item[handle.syncKeys[i]];
1330
+ });
1331
+ params[i] = param.join(',');
1332
+ } else {
1333
+ params[i] = row[handle.syncKeys[i]];
1334
+ }
1335
+ }
1336
+ }
1337
+ } else {
1338
+ if (Array.isArray(row)) {
1339
+ let param = row.map((item) => {
1340
+ return item.id;
1341
+ });
1342
+ params.id = param.join(',');
1343
+ } else {
1344
+ params.id = row.id;
1345
+ }
1346
+ }
1347
+ let keys = Object.keys(params);
1348
+ util
1349
+ .ajax({
1350
+ ...(handle.ajaxConfig || {}),
1351
+ url: handle.action,
1352
+ data:
1353
+ keys.length == 1 && handle.format === false
1354
+ ? params[keys[0]].split(',')
1355
+ : params,
1356
+ params:
1357
+ keys.length == 1 && handle.format === false
1358
+ ? params[keys[0]].split(',')
1359
+ : params,
1360
+ method: handle.method,
1361
+ format: handle.format
1362
+ })
1363
+ .then((res) => {
1364
+ this.changeLoading(false);
1365
+ if (res.rCode === 0) {
1366
+ this.$message({
1367
+ message: `${handle.text}成功`,
1368
+ duration: 2000,
1369
+ type: 'success',
1370
+ onClose: () => {
1371
+ let first = Object.prototype.hasOwnProperty.call(
1372
+ handle,
1373
+ 'first'
1374
+ )
1375
+ ? handle.first
1376
+ : false;
1377
+ let reload = handle.reload || true;
1378
+ if (reload) {
1379
+ this.reload({}, first);
1380
+ }
1381
+ }
1382
+ });
1383
+ } else {
1384
+ this.$message.error(
1385
+ res.msg || `${handle.text}失败,请联系管理员!`
1386
+ );
1387
+ }
1388
+ })
1389
+ .catch((err) => {
1390
+ this.changeLoading(false);
1391
+ if (err.message && err.message !== 'canceled') {
1392
+ this.$message.error(err.message);
1393
+ }
1394
+ });
1395
+ },
1396
+ checkParse(data, parse) {
1397
+ if (Array.isArray(data)) {
1398
+ return data.map((items) => {
1399
+ let item = JSON.parse(JSON.stringify(items));
1400
+ let obj = {};
1401
+ for (let i in parse) {
1402
+ obj[i] = item[parse[i]];
1403
+ delete item[parse[i]];
1404
+ }
1405
+ return { ...obj, ...item };
1406
+ });
1407
+ }
1408
+ let item = JSON.parse(JSON.stringify(data));
1409
+ let obj = {};
1410
+ for (let i in parse) {
1411
+ obj[i] = item[parse[i]];
1412
+ delete item[parse[i]];
1413
+ }
1414
+ return { ...obj, ...item };
1415
+ },
1416
+ handleClick(res) {
1417
+ let { row, handle } = res;
1418
+ let rows;
1419
+ if (handle.checkbox) {
1420
+ if (!this.selected || !this.selected.length) {
1421
+ this.$alert('请选择数据', '提示', { type: 'warning' });
1422
+ return;
1423
+ } else {
1424
+ row = this.selected;
1425
+ }
1426
+ }
1427
+ if (this.checkboxParseData) {
1428
+ rows = this.checkboxParseData(JSON.parse(JSON.stringify(row)));
1429
+ } else if (this.checkboxParse) {
1430
+ rows = this.checkParse(row, this.checkboxParse);
1431
+ } else if (handle.checkboxParse) {
1432
+ rows = this.checkParse(row, handle.checkboxParse);
1433
+ } else if (row) {
1434
+ rows = JSON.parse(JSON.stringify(row));
1435
+ }
1436
+ let thead = this.theads;
1437
+ if (this.$refs.oaTable) {
1438
+ thead = this.$refs.oaTable.getThead().thead;
1439
+ }
1440
+ if (handle.action) {
1441
+ let isConfirm = handle.confirm || true;
1442
+ if (isConfirm) {
1443
+ let msg = handle.field ? row[handle.field] : '';
1444
+ this.$confirm(`确定要${handle.text}${msg}吗`, '提示', {
1445
+ confirmButtonText: '确定',
1446
+ cancelButtonText: '取消',
1447
+ type: 'warning'
1448
+ })
1449
+ .then(() => {
1450
+ this.handleAjax(handle, rows);
1451
+ })
1452
+ .catch(() => {});
1453
+ } else {
1454
+ this.handleAjax(handle, rows);
1455
+ }
1456
+ } else if (handle.event) {
1457
+ if (typeof handle.event === 'function') {
1458
+ handle.event({
1459
+ ele: this,
1460
+ thead: thead,
1461
+ data: this.list,
1462
+ selected: rows,
1463
+ ...res
1464
+ });
1465
+ } else if (
1466
+ handle.event === 'add' ||
1467
+ handle.event === 'edit' ||
1468
+ handle.event === 'look'
1469
+ ) {
1470
+ let changes = {
1471
+ event: handle.event,
1472
+ title: handle.title || handle.text,
1473
+ value: handle.event === 'add' ? {} : rows,
1474
+ readonly: handle.event === 'look',
1475
+ actionType: handle.actionType
1476
+ ? handle.actionType
1477
+ : handle.event === 'add'
1478
+ ? 'save'
1479
+ : 'update',
1480
+ visible: true
1481
+ };
1482
+ if (handle.dialog) {
1483
+ let dialog;
1484
+ for (let i = 0; i < this.$children.length; i++) {
1485
+ let child = this.$children[i];
1486
+ if (child.$refs[handle.dialog]) {
1487
+ dialog = child.$refs[handle.dialog];
1488
+ break;
1489
+ }
1490
+ }
1491
+ dialog.setAttrs(changes);
1492
+ }
1493
+ this.injector && this.injector.handleChangeData(changes);
1494
+ if (handle.busEvent) {
1495
+ const bus = this.bus || this.$root.Bus;
1496
+ bus && bus.$emit(handle.busEvent, changes);
1497
+ }
1498
+ }
1499
+ } else if (handle.changeData) {
1500
+ let changeData = {};
1501
+ if (Array.isArray(handle.changeData)) {
1502
+ handle.changeData.forEach((item) => {
1503
+ if (util.isObject(item)) {
1504
+ for (let i in item) {
1505
+ if (typeof item[i] === 'boolean') {
1506
+ changeData[i] = item[i];
1507
+ } else {
1508
+ changeData[i] = handle[item[i]] || item[i];
1509
+ }
1510
+ }
1511
+ } else {
1512
+ changeData[item] =
1513
+ handle[item] || (Array.isArray(rows) ? rows : rows[item]);
1514
+ }
1515
+ });
1516
+ } else {
1517
+ for (let i in handle.changeData) {
1518
+ let item = handle.changeData[i];
1519
+ if (util.isObject(item)) {
1520
+ let obj = {};
1521
+ for (let e in item) {
1522
+ obj[e] =
1523
+ handle[item[e]] ||
1524
+ (Array.isArray(rows) ? rows : rows[item[e]]);
1525
+ }
1526
+ changeData[i] = obj;
1527
+ } else {
1528
+ if (typeof item === 'boolean') {
1529
+ changeData[i] = item;
1530
+ } else {
1531
+ changeData[i] =
1532
+ handle[item] || (Array.isArray(rows) ? rows : rows[item]);
1533
+ }
1534
+ }
1535
+ }
1536
+ }
1537
+ if (handle.actionType) {
1538
+ changeData['actionType'] = handle.actionType;
1539
+ }
1540
+ this.injector && this.injector.handleChangeData(changeData);
1541
+ if (handle.busEvent) {
1542
+ const bus = this.bus || this.$root.Bus;
1543
+ bus && bus.$emit(handle.busEvent, changes);
1544
+ }
1545
+ } else {
1546
+ if (handle.exportXls) {
1547
+ let text = '操作';
1548
+ if (
1549
+ this.theads[this.theads.length - 1] &&
1550
+ this.theads[this.theads.length - 1].type === 'handle'
1551
+ ) {
1552
+ text = this.theads[this.theads.length - 1].title;
1553
+ }
1554
+ let type = ['selection', 'index', 'expand'];
1555
+ thead = thead.map((item) => {
1556
+ return item.filter((ele) => {
1557
+ return (
1558
+ !type.includes(ele.type) &&
1559
+ ele.label !== text &&
1560
+ !this.exportExcludeLabel.includes(ele.label)
1561
+ );
1562
+ });
1563
+ });
1564
+ util.exportXls({
1565
+ thead: thead,
1566
+ data: this.list,
1567
+ name: this.fileName,
1568
+ option: this.optionDatas
1569
+ });
1570
+ }
1571
+ this.$emit('btnClick', res, this.list, thead, rows);
1572
+ this.$emit('btn-click', res, this.list, thead, rows);
1573
+ }
1574
+ },
1575
+ sizeChange(res) {
1576
+ this.config.pageSize = res;
1577
+ this.config.pageNum = 1;
1578
+ this.checkSelect(this.checked);
1579
+ this.$emit('page-size-change', res);
1580
+ if (this.url) {
1581
+ this.getTableData({ where: this.wheres, first: false });
1582
+ }
1583
+ },
1584
+ currentChange(res) {
1585
+ this.config.pageNum = res;
1586
+ this.checkSelect(this.checked);
1587
+ this.$emit('page-current-change', res);
1588
+ this.$emit('current', res);
1589
+ if (this.url) {
1590
+ this.getTableData({ where: this.wheres, first: false });
1591
+ }
1592
+ },
1593
+ preClick(res) {
1594
+ this.config.pageNum = res;
1595
+ this.checkSelect(this.checked);
1596
+ this.$emit('prev', res);
1597
+ },
1598
+ nextClick(res) {
1599
+ this.config.pageNum = res;
1600
+ this.checkSelect(this.checked);
1601
+ this.$emit('next', res);
1602
+ },
1603
+ hanleSearch(data) {
1604
+ this.searchWhere =
1605
+ this.response !== undefined
1606
+ ? this.response({
1607
+ type: 'search',
1608
+ data: JSON.parse(JSON.stringify(data))
1609
+ })
1610
+ : data;
1611
+ if (this.url && this.executeSearch) {
1612
+ this.getTableData({ where: this.wheres });
1613
+ }
1614
+ this.$emit('search', this.searchWhere);
1615
+ },
1616
+ hanleReset() {
1617
+ this.searchWhere = {};
1618
+ this.advanceWhere = {};
1619
+ if (this.url) {
1620
+ this.getTableData();
1621
+ }
1622
+ this.$emit('reset', this.params);
1623
+ },
1624
+ hanleSubmit({ data, show }) {
1625
+ this.advanceWhere =
1626
+ this.response !== undefined
1627
+ ? this.response({
1628
+ type: 'filter',
1629
+ data: JSON.parse(JSON.stringify(data))
1630
+ })
1631
+ : data;
1632
+
1633
+ if (this.url && this.executeFilter) {
1634
+ this.getTableData({ where: this.wheres });
1635
+ }
1636
+ this.$emit('submit', {
1637
+ data: this.advanceWhere,
1638
+ where: this.wheres,
1639
+ show
1640
+ });
1641
+ },
1642
+ hanleCancel() {
1643
+ this.$emit('cancel', this.params);
1644
+ },
1645
+ handleTabs({ item, index }) {
1646
+ if (this.url) {
1647
+ this.getTableData({ where: item });
1648
+ }
1649
+ this.$emit('tabs', { item, index });
1650
+ },
1651
+ reload(obj, first = false) {
1652
+ if (obj && obj.config) {
1653
+ this.config = util.extend({}, this.config, obj.config);
1654
+ }
1655
+ if (this.url) {
1656
+ this.isReload = true;
1657
+ this.getTableData({ where: obj && obj.where ? obj.where : {}, first });
1658
+ }
1659
+ },
1660
+ resetHeight(warn) {
1661
+ this.isSetHeight =
1662
+ util.getStyle(this.$el.parentNode, 'height') == '0px' ? false : true;
1663
+ this.$nextTick(() => {
1664
+ if (this.full && !this.height && !this.maxHeight && this.isSetHeight) {
1665
+ let height = this.$el.parentNode.offsetHeight;
1666
+ if (height) {
1667
+ height = parseInt(
1668
+ util.getStyle(this.$el.parentNode, 'height', '%'),
1669
+ 10
1670
+ );
1671
+ height =
1672
+ (height == NaN ? 0 : height) -
1673
+ parseInt(util.getStyle(this.$el.parentNode, 'padding-top'), 10) -
1674
+ parseInt(
1675
+ util.getStyle(this.$el.parentNode, 'padding-bottom'),
1676
+ 10
1677
+ );
1678
+ for (let i = 0; i < this.$el.parentNode.childNodes.length; i++) {
1679
+ let ele = this.$el.parentNode.childNodes[i];
1680
+ if (
1681
+ this.$el &&
1682
+ ele.offsetHeight !== undefined &&
1683
+ ele != this.$el
1684
+ ) {
1685
+ height =
1686
+ height -
1687
+ ele.offsetHeight -
1688
+ parseInt(util.getStyle(ele, 'margin-top'), 10) -
1689
+ parseInt(util.getStyle(ele, 'margin-bottom'), 10);
1690
+ }
1691
+ }
1692
+ height -= this.showToolbar
1693
+ ? this.$refs.toolbar.$el.offsetHeight
1694
+ : 0;
1695
+ height -=
1696
+ this.page === false ? 0 : this.$refs.pagination.$el.offsetHeight;
1697
+ height -= this.title ? this.$refs.title.offsetHeight : 0;
1698
+ height -= parseInt(
1699
+ util.getStyle(this.$refs.esTableContent, 'padding-top'),
1700
+ 10
1701
+ );
1702
+ height -= parseInt(
1703
+ util.getStyle(this.$refs.esTableContent, 'padding-bottom'),
1704
+ 10
1705
+ );
1706
+ let emptyText = this.$refs.esTableContent.querySelector(
1707
+ '.el-table__empty-text'
1708
+ );
1709
+ if (this.total) {
1710
+ height -= 1;
1711
+ }
1712
+ let eht = 0;
1713
+ if (emptyText) {
1714
+ eht = emptyText.offsetHeight;
1715
+ let thead =
1716
+ this.$refs.esTableContent.querySelector('.el-table__header');
1717
+ thead && (eht += thead.offsetHeight);
1718
+ }
1719
+ if (height > 1 && height - eht > 1) {
1720
+ this.tableHeight = height;
1721
+ } else {
1722
+ console.warn(this.$el.parentNode, `获取不到高度!`);
1723
+ }
1724
+ } else if (!warn) {
1725
+ setTimeout(() => {
1726
+ this.resetHeight(true);
1727
+ }, 1000);
1728
+ }
1729
+ }
1730
+ });
1731
+ },
1732
+ validate(callback) {
1733
+ if (this.form) {
1734
+ let form = this.elForm || this.$children[0];
1735
+ form.validate((valid) => {
1736
+ callback(valid);
1737
+ });
1738
+ }
1739
+ },
1740
+ changeLoading(show, text) {
1741
+ this.tableLoading = show;
1742
+ if (text) {
1743
+ this.tableLoadingText = text;
1744
+ }
1745
+ },
1746
+ handleFilterColumn() {
1747
+ this.showSizer = true;
1748
+ },
1749
+ handleSortChange(res) {
1750
+ if (res.data && res.data.length) {
1751
+ this.list = res.data;
1752
+ }
1753
+ this.$emit('sort-change', res);
1754
+ },
1755
+ handleUpdateDragSort(data, event) {
1756
+ this.$emit('update-drag-sort', data, event);
1757
+ },
1758
+ mergeThead(res) {
1759
+ this.show = false;
1760
+ this.theadData = [];
1761
+ this.icon = true;
1762
+ this.showSizer = false;
1763
+ // if (!this.showTotal) {
1764
+ // for (let i = 0; i < res.length; i++) {
1765
+ // if (res[i].total) {
1766
+ // this.showTotal = true;
1767
+ // break;
1768
+ // }
1769
+ // }
1770
+ // }
1771
+ this.$nextTick(() => {
1772
+ this.theadData = res;
1773
+ setTimeout(() => {
1774
+ this.show = true;
1775
+ }, 500);
1776
+ });
1777
+ },
1778
+ setOptions(val, sysCode) {
1779
+ this.$set(this.options, sysCode, val);
1780
+ },
1781
+ bindEventBus() {
1782
+ this.sysCodes.forEach((item) => {
1783
+ const bus = this.bus || this.$root.Bus;
1784
+ bus &&
1785
+ bus.$on(item, (val) => {
1786
+ this.setOptions(val, item);
1787
+ });
1788
+ });
1789
+ },
1790
+ unbindEventBus() {
1791
+ this.sysCodes.forEach((item) => {
1792
+ const bus = this.bus || this.$root.Bus;
1793
+ bus && bus.$off(item, this.setOptions);
1794
+ });
1795
+ },
1796
+ reset() {
1797
+ this.$refs.toolbar && this.$refs.toolbar.reset();
1798
+ },
1799
+ openEditPage() {
1800
+ let fields = [];
1801
+ this.theads.forEach((item) => {
1802
+ if (item.field || item.prop) {
1803
+ fields.push(item.field || item.prop);
1804
+ }
1805
+ });
1806
+ fields = util.esEncode(fields.join(','));
1807
+ this.editPage = `/lowcode-ui/webpack/index.html#simpleEditOnlinePage?pageId=${this.viewCode}&fields=${fields}`;
1808
+ this.showEditPage = true;
1809
+ }
1810
+ }
1811
+ };
1812
+ </script>