@tongfun/tf-widget 0.1.20 → 0.1.21

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 (94) hide show
  1. package/README.md +49 -46
  2. package/lib/tf-widget.common.js +460 -416
  3. package/lib/tf-widget.css +1 -1
  4. package/lib/tf-widget.umd.js +460 -416
  5. package/lib/tf-widget.umd.min.js +3 -3
  6. package/package/svg-icon/index.js +8 -8
  7. package/package/svg-icon/src/SvgIcon.vue +59 -59
  8. package/package/t-data-list/index.js +6 -6
  9. package/package/t-data-list/main.vue +193 -193
  10. package/package/t-data-list/src/condition-input/basic.vue +31 -31
  11. package/package/t-data-list/src/condition-input/date.vue +106 -106
  12. package/package/t-data-list/src/condition-input/index.vue +100 -100
  13. package/package/t-data-list/src/condition-input/input.vue +31 -31
  14. package/package/t-data-list/src/condition-input/number.vue +115 -115
  15. package/package/t-data-list/src/condition-input/select.vue +86 -86
  16. package/package/t-data-list/src/js/fieldTypeEnum.js +10 -10
  17. package/package/t-data-list/src/js/operatorEnum.js +108 -108
  18. package/package/t-data-list/src/js/qureyParamsEnum.js +4 -4
  19. package/package/t-data-list/src/js/util.js +34 -34
  20. package/package/t-data-list/src/mixins/button-controll-mixin.js +93 -93
  21. package/package/t-data-list/src/pushdown/push-down.vue +158 -158
  22. package/package/t-data-list/src/t-list-search.vue +36 -36
  23. package/package/t-data-list/src/t-plan/condition-always-item.vue +143 -143
  24. package/package/t-data-list/src/t-plan/condition-mult-item.vue +222 -222
  25. package/package/t-data-list/src/t-plan/index.vue +195 -195
  26. package/package/t-data-list/src/t-plan/plan-content.vue +389 -389
  27. package/package/t-data-list/src/t-table/index.vue +129 -129
  28. package/package/t-data-list/src/t-table/table-group-item-edit.vue +238 -238
  29. package/package/t-data-list/src/t-table/table-group-item.vue +87 -87
  30. package/package/t-data-list/src/t-table/table-group.vue +180 -180
  31. package/package/t-data-list/src/t-table/table-records-header-popover.vue +246 -246
  32. package/package/t-data-list/src/t-table/table-records-selected.vue +159 -159
  33. package/package/t-data-list/src/t-table/table-records.vue +337 -337
  34. package/package/t-input/children/address.vue +101 -101
  35. package/package/t-input/children/basic-display.vue +41 -41
  36. package/package/t-input/children/basic.vue +253 -253
  37. package/package/t-input/children/date.vue +89 -89
  38. package/package/t-input/children/group-components/group-dialog.vue +344 -344
  39. package/package/t-input/children/group.vue +126 -126
  40. package/package/t-input/children/input.vue +72 -72
  41. package/package/t-input/children/number.vue +74 -74
  42. package/package/t-input/children/select.vue +89 -89
  43. package/package/t-input/children/tfile/fiile-enclosure.vue +233 -233
  44. package/package/t-input/index.js +7 -7
  45. package/package/t-input/index.vue +337 -337
  46. package/package/t-input/tInputCache.js +24 -24
  47. package/package/tf-icon-picker/README.md +7 -7
  48. package/package/tf-icon-picker/index.js +8 -8
  49. package/package/tf-icon-picker/src/tf-icon-picker.vue +266 -266
  50. package/package/tf-layout/README.md +115 -115
  51. package/package/tf-layout/index.js +8 -8
  52. package/package/tf-layout/src/components/tf-labelbar.vue +394 -382
  53. package/package/tf-layout/src/components/tf-menu.vue +180 -180
  54. package/package/tf-layout/src/components/tf-right-menu.vue +89 -89
  55. package/package/tf-layout/src/components/tf-rotate-box.vue +50 -50
  56. package/package/tf-layout/src/tf-layout.vue +140 -120
  57. package/package/tf-widget/index.js +8 -8
  58. package/package/tf-widget/src/assets/common-input.less +10 -10
  59. package/package/tf-widget/src/children/basic-data/basic-data.vue +361 -361
  60. package/package/tf-widget/src/children/basic-data/dependcy/basic-data-selector.vue +1087 -1087
  61. package/package/tf-widget/src/children/basic-data/dependcy/common-table.vue +750 -750
  62. package/package/tf-widget/src/children/basic-data/dependcy/condition-filter.vue +519 -519
  63. package/package/tf-widget/src/children/basic-data/dependcy/pagination.vue +93 -93
  64. package/package/tf-widget/src/children/basic-data/dependcy/table-control.vue +240 -240
  65. package/package/tf-widget/src/children/basic-data/dependcy/view-picture.vue +108 -108
  66. package/package/tf-widget/src/children/date-time.vue +103 -103
  67. package/package/tf-widget/src/children/date.vue +103 -103
  68. package/package/tf-widget/src/children/decimal.vue +115 -115
  69. package/package/tf-widget/src/children/integer.vue +104 -104
  70. package/package/tf-widget/src/children/property.vue +59 -59
  71. package/package/tf-widget/src/children/single-line-text.vue +82 -82
  72. package/package/tf-widget/src/children/small-pictures.vue +223 -223
  73. package/package/tf-widget/src/children/text-area.vue +74 -74
  74. package/package/tf-widget/src/children/tf-select.vue +113 -113
  75. package/package/tf-widget/src/tf-widget.vue +175 -175
  76. package/package.json +44 -44
  77. package/src/api/edit.js +97 -97
  78. package/src/api/file-enclosure.js +26 -26
  79. package/src/api/push-down.js +19 -19
  80. package/src/api/table.js +294 -294
  81. package/src/api/tableV3.js +160 -160
  82. package/src/assets/images/icons/index.js +9 -9
  83. package/src/assets/images/icons/svg/add.svg +5 -5
  84. package/src/assets/images/icons/svg/push-down.svg +1 -1
  85. package/src/assets/images/icons/svg/remove.svg +1 -1
  86. package/src/assets/styles/common-table.less +202 -202
  87. package/src/directives/debounce.js +24 -24
  88. package/src/index.js +31 -31
  89. package/src/mixins/t-data-query-mixin.js +290 -290
  90. package/src/utils/auth.js +22 -22
  91. package/src/utils/request.js +42 -42
  92. package/src/utils/stato-anormale.js +59 -59
  93. package/src/utils/utils.js +109 -109
  94. package/src/utils/validate.js +84 -84
@@ -1,750 +1,750 @@
1
- <template>
2
- <div ref="commonTableMain" class="common-table-main" @click="closeAllVisible">
3
- <!-- 表格主体-->
4
- <!-- 开启双击是开启显示tag -->
5
- <div v-if="doubleSelect">
6
- <el-tag
7
- v-for="tag in selectData"
8
- :key="tag.head__code"
9
- closable
10
- @close="handleTagClose(tag)"
11
- >
12
- {{ tag.head__name }}
13
- </el-tag>
14
- </div>
15
- <ux-grid
16
- ref="commonTable"
17
- column-key
18
- :data="tableData"
19
- class="common-table"
20
- beautify-table
21
- show-header-overflow
22
- show-overflow="tooltip"
23
- show-summary
24
- :summary-method="getSummaries"
25
- :checkbox-config="{highlight: true,trigger: 'row'}"
26
- :sort-config="{showIcon: false}"
27
- :width-resize="true"
28
- :header-cell-style="headCellStyle"
29
- highlight-current-row
30
- :cell-style="getCellStyle"
31
- @current-change="handleRowSelect"
32
- @selection-change="selectionChange"
33
- @header-dragend="changeColumnWidth"
34
- @row-dblclick="handleDbclick"
35
- @select="handleSelect"
36
- >
37
- <ux-table-column type="checkbox" align="center" fixed="left" width="60" />
38
- <template v-for="(item,index) in tableLayout">
39
- <ux-table-column
40
- v-if="!item.hiddenFlag"
41
- :key="index"
42
- :field="item.fieldName"
43
- :title="item.title"
44
- :align="item.align"
45
- :width="item.width ? item.width : tableLayout.length < 15 ? '' : '150' "
46
- :fixed="item.fixed ? item.fixed : '' "
47
- :sortable="item.sortable"
48
- :formatter="formatterDec"
49
- resizable
50
- >
51
- <template v-slot:header="{ column }">
52
- <div class="common-header-filter" @click="sortTableData(item,column)">
53
- <span>{{ column.title }}</span>
54
- <i v-if="column.order==='asc'" class="el-icon-top" />
55
- <i v-if="column.order==='desc'" class="el-icon-bottom" />
56
- <div v-if="item.isQuick" id="popover" class="popover">
57
- <el-popover
58
- v-model="quickFilterData[item.fieldName + 'Visible']"
59
- placement="bottom"
60
- width="160"
61
- trigger="manual"
62
- >
63
- <el-input
64
- v-model="quickFilterData[item.fieldName]"
65
- class="popover-input"
66
- clearable
67
- :placeholder="`请输入${item.title}`"
68
- @input="inputChange(item.fieldName)"
69
- />
70
- <div class="header-filter">
71
- <el-scrollbar style="height: 100%">
72
- <el-checkbox-group v-if="quickFilterData[item.fieldName+ 'Checked']" v-model="quickFilterData[item.fieldName+ 'Checked']" @change="bindCheckBox(item.fieldName + 'Checked')">
73
- <el-checkbox label="全选" @change="changeAll(item.fieldName, $event)" />
74
- <template v-for="key in quickFilterData[item.fieldName+ 'CheckedList']">
75
- <el-checkbox :key="key" :label="key" />
76
- </template>
77
- </el-checkbox-group>
78
- </el-scrollbar>
79
- </div>
80
- <div style="text-align: right; margin: 5px 0 0 0">
81
- <el-button class="common-header-button" type="primary" size="mini" @click="closeVisible(item.fieldName)">取消</el-button>
82
- <el-button class="common-header-button" type="primary" size="mini" @click="confirmVisible(item.fieldName)">筛选</el-button>
83
- </div>
84
- <div slot="reference" class="reference">
85
- <i
86
- v-show="!quickFilterData[item.fieldName + 'Visible'] && ( quickFilterData[item.fieldName + 'Checked_True'] && quickFilterData[item.fieldName + 'Checked_True'].length === 0 )"
87
- class="el-icon-arrow-down"
88
- style="cursor: pointer"
89
- @click.stop="quickFilterData[item.fieldName + 'Visible'] = true"
90
- />
91
- <SvgIcon
92
- v-show="!quickFilterData[item.fieldName + 'Visible'] && ( quickFilterData[item.fieldName + 'Checked_True'] && quickFilterData[item.fieldName + 'Checked_True'].length !== 0 )"
93
- icon-class="filter"
94
- style="width:15px;height: 15px;cursor: pointer"
95
- @click.stop="quickFilterData[item.fieldName + 'Visible'] = true"
96
- />
97
- <i
98
- v-show="quickFilterData[item.fieldName + 'Visible']"
99
- class="el-icon-arrow-up"
100
- style="cursor: pointer"
101
- @click.stop="quickFilterData[item.fieldName + 'Visible'] = false"
102
- />
103
- </div>
104
- </el-popover>
105
- </div>
106
- </div>
107
- </template>
108
- <template v-if="item.controlType ==='small_pictures'" v-slot:default="scope">
109
- <div v-if="scope.row[item.fieldName]" class="view-picture">
110
- <span style="color:#0c4c8e;border-bottom:1px solid #0c4c8e;cursor: pointer;" @click="handelClickViewPicture(scope.row, item.fieldName)">
111
- 查看图片
112
- </span>
113
- </div>
114
- <div v-else style="color:red">
115
- 暂无图片
116
- </div>
117
- </template>
118
- <!-- 对于复选框的类型,value和label后端没有进行处理,前端处理成展示的值 建国需求:2021.8.11 T-BUG -->
119
- <template v-else-if="item.controllType === 'check_box'" v-slot:default="scope">
120
- <div>
121
- {{ scope.row[item.fieldName] | checkedFilter }}
122
- </div>
123
- </template>
124
- </ux-table-column>
125
- </template>
126
- <ux-table-column v-if="isShow" title="操作" align="center" width="100">
127
- <template v-slot:default="scope">
128
- <slot ref="control" name="tableControl" :value="scope.row" />
129
- </template>
130
- </ux-table-column>
131
- <!--<ux-table-column type="setting" resizable align="center" fixed="right" width="50">
132
- <template slot="header">
133
- <i class="el-icon-setting" style="cursor: pointer" @click="tableControlClick" />
134
- </template>
135
- </ux-table-column>-->
136
- <template slot="empty">
137
- <SvgIcon icon-class="table-empty" style="width: 100px;height: 100px;margin-top: 100px" />
138
- <div style="font-size: 18px;margin-bottom: 100px">
139
- 数据为空
140
- </div>
141
- </template>
142
- </ux-grid>
143
- <!-- 表格分页-->
144
- <div ref="commonTablePagination" class="common-table-pagination">
145
- <Pagination ref="commonTablePage" :total="paging.total" :paging="paging" :selected-total="selectedTotal" @pageChange="pageChange" />
146
- </div>
147
- <!-- 列表控制弹框组件-->
148
- <TableControl
149
- :table-layout="tableLayout"
150
- :dialog-table-visible="dialogTableVisible"
151
- @closeDialog="closeDialog"
152
- @updateColumn="updateColumn"
153
- />
154
- <!-- 查看图片的弹框 -->
155
- <ViewPicture
156
- :dialog-visible="viewPictureVisable"
157
- :view-picture-data="viewPictureData"
158
- @handelClose="handelClose"
159
- />
160
- </div>
161
- </template>
162
-
163
- <script>
164
- import Sortable from 'sortablejs/modular/sortable.core.esm.js'
165
- import Pagination from './pagination'
166
- import TableControl from './table-control'
167
- import ViewPicture from './view-picture'
168
- import { getFastSearchSuggestionVos } from '@/api/table'
169
- export default {
170
- name: 'CommonTable',
171
- components: {
172
- Pagination, TableControl, ViewPicture
173
- },
174
- filters: {
175
- checkedFilter (value) {
176
- if (!value) return ''
177
- if (value === '0') return '否'
178
- if (value === '1') return '是'
179
- return '不兼容的选项'
180
- }
181
- },
182
- props: {
183
- // 绑定字段,字段变化时修改对应行颜色
184
- fieldChangeData: {
185
- type: Object,
186
- default: () => {}
187
- },
188
- // 选中行数
189
- selectedTotal: {
190
- type: Number,
191
- default: 0
192
- },
193
- // 表格ID
194
- tableId: {
195
- type: String,
196
- default: ''
197
- },
198
- // 表格数据
199
- tableData: {
200
- type: Array,
201
- default: () => {
202
- return []
203
- }
204
- },
205
- // 表格布局
206
- tableLayout: {
207
- type: Array,
208
- default: () => {
209
- return []
210
- }
211
- },
212
- // 表格数据
213
- getTableDataFunc: {
214
- type: Function,
215
- default: () => {
216
- return null
217
- }
218
- },
219
- // 分页
220
- paging: {
221
- type: Object,
222
- default: () => {
223
- return {}
224
- }
225
- },
226
- // 合计数据
227
- totalData: {
228
- type: Array,
229
- default: () => {
230
- return []
231
- }
232
- },
233
- // 是否开启单选模式
234
- singleSelect: {
235
- type: Boolean,
236
- default: false
237
- },
238
- // 双击行编辑功能(默认开启)
239
- dbClickAction: {
240
- type: Boolean,
241
- default: true
242
- },
243
- // 快捷过滤信息
244
- quickFilterData: {
245
- type: Object,
246
- default: () => {}
247
- },
248
- // 是否开启双选
249
- doubleSelect: {
250
- type: Boolean,
251
- default: false
252
- },
253
- // 表头的表名
254
- headName: {
255
- type: String,
256
- default: ''
257
- },
258
- isShowTableSlot: {
259
- type: Boolean,
260
- default: null
261
- }
262
- },
263
- data () {
264
- return {
265
- dialogTableVisible: false,
266
- maxHeight: '60vh', // 表格最大宽度
267
- // currentTableData: this.tableData,
268
- tableTitle: null,
269
- cities: [1, 2, 3],
270
- checked: [],
271
- selectData: [], // 暂存选中的数据
272
- viewPictureVisable: false, // 打开查看图片模态框
273
- viewPictureData: ''// 要传给图片模态框的值
274
- }
275
- },
276
- computed: {
277
- currentTableData: function () {
278
- return this.tableData
279
- },
280
- isShow: function () {
281
- if (this.isShowTableSlot === null) {
282
- this.$nextTick(() => {
283
- const slotArr = Object.keys(this.$scopedSlots)
284
- if (slotArr.indexOf('tableControl') !== -1) {
285
- return true
286
- } else {
287
- return false
288
- }
289
- })
290
- }
291
- return this.isShowTableSlot
292
- }
293
- },
294
- watch: {
295
- currentTableData: {
296
- handler (newVal) {
297
- this.$emit('updateParentTableData', newVal)
298
- },
299
- deep: true
300
- },
301
- // 用于刷新合计
302
- totalData: {
303
- handler (newVal) {
304
- this.$refs.commonTable.updateData()
305
- },
306
- deep: true
307
- },
308
- tableLayout: {
309
- handler (newVal) {
310
- },
311
- deep: true
312
- }
313
- },
314
-
315
- mounted () {
316
- this.columnDrop()
317
- },
318
-
319
- beforeDestroy () {
320
- this.$emit('tableBeforeDestroy', this.tableTitle)
321
- },
322
-
323
- methods: {
324
- // 表头单元格的style回调方法
325
- headCellStyle () {
326
- return 'font-family: Source Han Sans SC, Source Han Sans SC-Normal;font-weight: Normal;font-size:1.4vh'
327
- },
328
- // 表头点击事件 ---> 排序
329
-
330
- /**
331
- * 关闭所有表头筛选
332
- */
333
- closeAllVisible () {
334
- for (const key in this.quickFilterData) {
335
- if (key.indexOf('Visible') !== -1 && this.quickFilterData[key] === true) {
336
- this.quickFilterData[key] = false
337
- }
338
- }
339
- },
340
-
341
- /**
342
- * 表头点击事件 ---> 排序
343
- */
344
- sortTableData (item, column) {
345
- if (column.order === 'desc') {
346
- this.$refs.commonTable.clearSort()
347
- } else if (column.order === 'asc') {
348
- this.$refs.commonTable.sort(column.property, 'desc')
349
- } else {
350
- this.$refs.commonTable.sort(column.property, 'asc')
351
- }
352
- },
353
-
354
- /**
355
- * 点击查看图片
356
- */
357
- handelClickViewPicture (item, fieldName) {
358
- this.viewPictureVisable = true
359
- this.viewPictureData = item[fieldName]
360
- },
361
-
362
- /**
363
- * 图片模态框子组件传来的方法,点击取消关闭模态框
364
- */
365
- handelClose (item) {
366
- this.viewPictureVisable = item
367
- },
368
-
369
- /**
370
- * 表头过滤的输入框input事件
371
- */
372
- inputChange (fieldName) {
373
- const data = {
374
- fastSearchSuggestQueryDtos: [{
375
- columnName: fieldName.split('__')[1],
376
- tableName: this.headName,
377
- value: this.quickFilterData[fieldName]
378
- }
379
- ]
380
- }
381
- getFastSearchSuggestionVos(data).then(res => {
382
- this.quickFilterData[fieldName + 'CheckedList'] = res.data[0].suggestions
383
- this.quickFilterData[fieldName + 'Checked'] = [...this.quickFilterData[fieldName + 'CheckedList'], '全选']
384
- })
385
- // // 过滤数组
386
- // this.quickFilterData[fieldName + 'CheckedList'] = this.quickFilterData[fieldName + 'CheckedList_Bak'].filter(item => {
387
- // return item.indexOf(this.quickFilterData[fieldName]) !== -1
388
- // })
389
- // 默认全选
390
- // this.quickFilterData[fieldName + 'Checked'] = [...this.quickFilterData[fieldName + 'CheckedList'], '全选']
391
- },
392
-
393
- /**
394
- * 表头过滤选中数组change事件
395
- */
396
- bindCheckBox (value) {
397
- // 实现单选功能
398
- // if (this.quickFilterData[value].length > 1) {
399
- // this.quickFilterData[value].splice(0, 1)
400
- // }
401
-
402
- },
403
-
404
- /**
405
- * 表头筛选的全选|取消全选
406
- * @param fieldName 字段
407
- * @param value true为全选,false为取消全选
408
- */
409
- changeAll (fieldName, value) {
410
- if (value) {
411
- // 全选
412
- this.quickFilterData[fieldName + 'Checked'] = [...this.quickFilterData[fieldName + 'CheckedList'], '全选']
413
- } else {
414
- // 取消全选
415
- this.quickFilterData[fieldName + 'Checked'] = []
416
- }
417
- },
418
-
419
- /**
420
- * 取消筛选
421
- * @param fieldValue 字段
422
- */
423
- closeVisible: function (fieldValue) {
424
- this.quickFilterData[fieldValue + 'Visible'] = false
425
- this.quickFilterData[fieldValue] = ''
426
- // this.quickFilterData[fieldValue + 'Checked'] = []
427
- },
428
-
429
- /**
430
- * 确认筛选
431
- * @param fieldValue 字段
432
- */
433
- confirmVisible: function (fieldValue) {
434
- this.quickFilterData[fieldValue + 'Visible'] = false
435
- this.quickFilterData[fieldValue + 'Checked_True'] = this.quickFilterData[fieldValue + 'Checked']
436
- this.$emit('quickSearch')
437
- },
438
-
439
- /**
440
- * 表格数据格式化: 数字精度统一为2
441
- */
442
- formatterDec ({ cellValue, row, column }) {
443
- const reg = /^[0-9]+.?[0-9]*$/ // 判断字符串是否为数字
444
- if (reg.test(cellValue)) {
445
- const y = String(cellValue).indexOf('.') + 1 // 获取小数点的位置
446
- const count = String(cellValue).length - y // 获取小数点后的个数
447
- if (y > 0 && count > 2) {
448
- return Number(cellValue).toFixed(2)
449
- } else {
450
- return cellValue
451
- }
452
- } else {
453
- return cellValue
454
- }
455
- },
456
-
457
- /**
458
- * 表格双击
459
- * @param row 行
460
- */
461
- handleDbclick (row) {
462
- try {
463
- if (this.$refs.commonTable.$children[0].$children[0].$children) {
464
- const arr = this.$refs.commonTable.$children[0].$children[0].$children
465
- arr.forEach(item => {
466
- if (item.$options._componentTag === 'elx-tooltip') {
467
- item.targetMouseleaveEvent()
468
- }
469
- })
470
- }
471
- } catch (e) {
472
- console.log(e)
473
- }
474
- this.$emit('dbClick', row)
475
- },
476
-
477
- /**
478
- * 表格选择项change事件
479
- */
480
- selectionChange (value) {
481
- if (this.selectData.length === 0) {
482
- this.$emit('selectionChange', value)
483
- } else {
484
- this.$emit('selectionChange', this.selectData)
485
- }
486
- },
487
-
488
- /**
489
- * 手动勾选数据行的 Checkbox 时触发事件
490
- */
491
- handleSelect (selection, row) {
492
- if (this.doubleSelect) {
493
- const selectData = new Set(this.selectData)
494
- if (this.selectData.indexOf(row) === -1) {
495
- selectData.add(row)
496
- this.selectData = Array.from(selectData)
497
- } else {
498
- this.selectData = Array.from(selectData)
499
- this.selectData.splice(this.selectData.indexOf(row), 1)
500
- }
501
- if (this.selectData.length > 2) {
502
- this.$message.error('最多选择两条数据')
503
- this.selectData.pop()
504
- }
505
- this.$refs.commonTable.clearSelection()
506
- this.selectData.forEach(element => {
507
- this.$refs.commonTable.toggleRowSelection([
508
- {
509
- row: element,
510
- selected: true
511
- }
512
- ])
513
- })
514
- }
515
- },
516
-
517
- /**
518
- * 关闭tag
519
- * @param tag
520
- */
521
- handleTagClose (tag) {
522
- this.selectData.splice(this.selectData.indexOf(tag), 1)
523
- this.$refs.commonTable.clearSelection()
524
- this.selectData.forEach(element => {
525
- this.$refs.commonTable.toggleRowSelection([
526
- {
527
- row: element,
528
- selected: true
529
- }
530
- ])
531
- })
532
- },
533
-
534
- /**
535
- * 动态设定单元格样式
536
- * 根据绑定的字段,依据字段值获取表格内容样式
537
- */
538
- getCellStyle ({ row, column, rowIndex, columnIndex }) {
539
- if (this.fieldChangeData && this.fieldChangeData.fieldName) {
540
- const fieldName = this.fieldChangeData.fieldName
541
- const findIndex = this.fieldChangeData.changeList.findIndex(d => d.key === row[fieldName])
542
- if (findIndex !== -1) {
543
- return {
544
- color: this.fieldChangeData.changeList[findIndex].value
545
- }
546
- }
547
- }
548
- },
549
-
550
- /**
551
- * 表格当前行change事件
552
- * @param row
553
- */
554
- handleRowSelect (row) {
555
- if (this.singleSelect) {
556
- this.$refs.commonTable.clearSelection()
557
- this.$refs.commonTable.setCurrentRow(row)
558
- }
559
- },
560
-
561
- /**
562
- * 表格合计
563
- */
564
- getSummaries (param) {
565
- return [this.totalData]
566
- },
567
-
568
- arraySorting (newValue) {
569
- const arr = {}
570
- newValue.forEach(item => {
571
- arr[item.index] = item
572
- })
573
- arr.length = newValue.length
574
- this.tableTitle = Array.from(arr)
575
- },
576
-
577
- /**
578
- * 拖动表单列
579
- */
580
- columnDrop () {
581
- this.$nextTick(() => {
582
- const table = this.$refs.commonTable
583
- this.sortable = Sortable.create(table.$el.querySelector('.body--wrapper .elx-table--header .elx-header--row'), {
584
- handle: '.elx-header--column:not(.col--fixed)',
585
- ghostClass: 'dragColbg',
586
- chosenClass: 'dragColbg',
587
- onEnd: ({ item, newIndex, oldIndex, ...arg }) => {
588
- // fullColumn: 全量表头列 tableColumn: 当前渲染中的表头列
589
- const { fullColumn, tableColumn } = table.getTableColumn()
590
- const targetThElem = item
591
- const wrapperElem = targetThElem.parentNode
592
- const newColumn = fullColumn[newIndex]
593
- if (newColumn.fixed) {
594
- // 错误的移动
595
- if (newIndex > oldIndex) {
596
- wrapperElem.insertBefore(targetThElem, wrapperElem.children[oldIndex])
597
- } else {
598
- wrapperElem.insertBefore(wrapperElem.children[oldIndex], targetThElem)
599
- }
600
- return this.$message.error('固定列不允许拖动!')
601
- }
602
- // 转换真实索引
603
- const oldColumnIndex = table.getColumnIndex(tableColumn[oldIndex])
604
- const newColumnIndex = table.getColumnIndex(tableColumn[newIndex])
605
- // 移动到目标列
606
- const currRow = fullColumn.splice(oldColumnIndex, 1)[0]
607
- fullColumn.splice(newColumnIndex, 0, currRow)
608
- // 加载列
609
- // 向父组件发送表格顺序
610
- this.$emit('columnChange', fullColumn)
611
- table.loadColumn(fullColumn)
612
- }
613
- })
614
- })
615
- },
616
-
617
- /**
618
- * 改变表格列宽度
619
- */
620
- changeColumnWidth ({ column, $columnIndex }) {
621
- try {
622
- this.$emit('changeWidth', column)
623
- // this.tableTitle[$columnIndex].width = column['renderWidth']
624
- } catch (err) {
625
- throw new Error(err)
626
- }
627
- },
628
-
629
- /**
630
- * 页签变化
631
- */
632
- async pageChange (value) {
633
- this.$emit('pageChange', value)
634
- },
635
-
636
- /**
637
- * 刷新表格数据
638
- */
639
- refreshTableData () {
640
- this.$refs.commonTablePage.changePage()
641
- },
642
-
643
- /**
644
- * 打开列表控制弹框
645
- */
646
- tableControlClick () {
647
- this.dialogTableVisible = true
648
- },
649
-
650
- /**
651
- * 子传父关闭Dialog
652
- * @param value
653
- */
654
- closeDialog (value) {
655
- this.dialogTableVisible = value
656
- },
657
-
658
- /**
659
- * 更新表格列配置
660
- */
661
- updateColumn () {
662
- this.$nextTick(() => {
663
- this.$refs.commonTable.refreshColumn()
664
- })
665
- }
666
-
667
- }
668
- }
669
- </script>
670
-
671
- <style lang="less" scoped>
672
- @import "@/assets/styles/common-table";
673
- @paginationHeight: 8vh;
674
- .common-table-main{
675
- height: 100%;
676
- >div:nth-child(1) {
677
- margin-bottom: 0.5vh;
678
- ::v-deep .el-tag {
679
- margin-right: 0.2vw;
680
- height: 3vh;
681
- line-height: 3vh;
682
- }
683
- }
684
- }
685
- .common-header-filter{
686
- position: relative;
687
- .popover{
688
- position: absolute;
689
- right: 2px;
690
- bottom: 0;
691
- }
692
- }
693
- // 分页组件定位
694
- .common-table-pagination{
695
- margin-top: -0.5vh;
696
- height: @paginationHeight;
697
- ::v-deep .pagination{
698
- height: @paginationHeight;
699
- //display: flex;
700
- .el-pagination{
701
- padding: 0;
702
- }
703
- .el-pagination__total, .el-pagination__sizes{
704
- height: @paginationHeight;
705
- line-height: @paginationHeight;
706
- }
707
- .btn-prev, .btn-next, .el-pager, .el-pager li{
708
- height: @paginationHeight;
709
- line-height: @paginationHeight;
710
- }
711
- .el-select__caret{
712
- display: flex;
713
- align-items: center;
714
- justify-content: center;
715
- }
716
- .el-pagination__editor{
717
- height: @paginationHeight;
718
- line-height: @paginationHeight;
719
- }
720
- }
721
- // position: absolute;
722
- // bottom: 1.5vh;
723
- // right: 2vw;
724
- }
725
- // 表头快捷过滤样式
726
- .el-popover{
727
- .popover-input{
728
- ::v-deep .el-input__inner{
729
- height: 3vh;
730
- margin-bottom: 1vh;
731
- }
732
- ::v-deep .el-input__suffix{
733
- height: 3vh;
734
- }
735
- }
736
- .el-checkbox{
737
- display: block !important;
738
- }
739
- // 表头筛选
740
- .header-filter{
741
- height: 12vh;
742
- ::v-deep .el-scrollbar{
743
- .el-scrollbar__wrap{
744
- overflow-x: hidden;
745
- }
746
- }
747
- }
748
- }
749
-
750
- </style>
1
+ <template>
2
+ <div ref="commonTableMain" class="common-table-main" @click="closeAllVisible">
3
+ <!-- 表格主体-->
4
+ <!-- 开启双击是开启显示tag -->
5
+ <div v-if="doubleSelect">
6
+ <el-tag
7
+ v-for="tag in selectData"
8
+ :key="tag.head__code"
9
+ closable
10
+ @close="handleTagClose(tag)"
11
+ >
12
+ {{ tag.head__name }}
13
+ </el-tag>
14
+ </div>
15
+ <ux-grid
16
+ ref="commonTable"
17
+ column-key
18
+ :data="tableData"
19
+ class="common-table"
20
+ beautify-table
21
+ show-header-overflow
22
+ show-overflow="tooltip"
23
+ show-summary
24
+ :summary-method="getSummaries"
25
+ :checkbox-config="{highlight: true,trigger: 'row'}"
26
+ :sort-config="{showIcon: false}"
27
+ :width-resize="true"
28
+ :header-cell-style="headCellStyle"
29
+ highlight-current-row
30
+ :cell-style="getCellStyle"
31
+ @current-change="handleRowSelect"
32
+ @selection-change="selectionChange"
33
+ @header-dragend="changeColumnWidth"
34
+ @row-dblclick="handleDbclick"
35
+ @select="handleSelect"
36
+ >
37
+ <ux-table-column type="checkbox" align="center" fixed="left" width="60" />
38
+ <template v-for="(item,index) in tableLayout">
39
+ <ux-table-column
40
+ v-if="!item.hiddenFlag"
41
+ :key="index"
42
+ :field="item.fieldName"
43
+ :title="item.title"
44
+ :align="item.align"
45
+ :width="item.width ? item.width : tableLayout.length < 15 ? '' : '150' "
46
+ :fixed="item.fixed ? item.fixed : '' "
47
+ :sortable="item.sortable"
48
+ :formatter="formatterDec"
49
+ resizable
50
+ >
51
+ <template v-slot:header="{ column }">
52
+ <div class="common-header-filter" @click="sortTableData(item,column)">
53
+ <span>{{ column.title }}</span>
54
+ <i v-if="column.order==='asc'" class="el-icon-top" />
55
+ <i v-if="column.order==='desc'" class="el-icon-bottom" />
56
+ <div v-if="item.isQuick" id="popover" class="popover">
57
+ <el-popover
58
+ v-model="quickFilterData[item.fieldName + 'Visible']"
59
+ placement="bottom"
60
+ width="160"
61
+ trigger="manual"
62
+ >
63
+ <el-input
64
+ v-model="quickFilterData[item.fieldName]"
65
+ class="popover-input"
66
+ clearable
67
+ :placeholder="`请输入${item.title}`"
68
+ @input="inputChange(item.fieldName)"
69
+ />
70
+ <div class="header-filter">
71
+ <el-scrollbar style="height: 100%">
72
+ <el-checkbox-group v-if="quickFilterData[item.fieldName+ 'Checked']" v-model="quickFilterData[item.fieldName+ 'Checked']" @change="bindCheckBox(item.fieldName + 'Checked')">
73
+ <el-checkbox label="全选" @change="changeAll(item.fieldName, $event)" />
74
+ <template v-for="key in quickFilterData[item.fieldName+ 'CheckedList']">
75
+ <el-checkbox :key="key" :label="key" />
76
+ </template>
77
+ </el-checkbox-group>
78
+ </el-scrollbar>
79
+ </div>
80
+ <div style="text-align: right; margin: 5px 0 0 0">
81
+ <el-button class="common-header-button" type="primary" size="mini" @click="closeVisible(item.fieldName)">取消</el-button>
82
+ <el-button class="common-header-button" type="primary" size="mini" @click="confirmVisible(item.fieldName)">筛选</el-button>
83
+ </div>
84
+ <div slot="reference" class="reference">
85
+ <i
86
+ v-show="!quickFilterData[item.fieldName + 'Visible'] && ( quickFilterData[item.fieldName + 'Checked_True'] && quickFilterData[item.fieldName + 'Checked_True'].length === 0 )"
87
+ class="el-icon-arrow-down"
88
+ style="cursor: pointer"
89
+ @click.stop="quickFilterData[item.fieldName + 'Visible'] = true"
90
+ />
91
+ <SvgIcon
92
+ v-show="!quickFilterData[item.fieldName + 'Visible'] && ( quickFilterData[item.fieldName + 'Checked_True'] && quickFilterData[item.fieldName + 'Checked_True'].length !== 0 )"
93
+ icon-class="filter"
94
+ style="width:15px;height: 15px;cursor: pointer"
95
+ @click.stop="quickFilterData[item.fieldName + 'Visible'] = true"
96
+ />
97
+ <i
98
+ v-show="quickFilterData[item.fieldName + 'Visible']"
99
+ class="el-icon-arrow-up"
100
+ style="cursor: pointer"
101
+ @click.stop="quickFilterData[item.fieldName + 'Visible'] = false"
102
+ />
103
+ </div>
104
+ </el-popover>
105
+ </div>
106
+ </div>
107
+ </template>
108
+ <template v-if="item.controlType ==='small_pictures'" v-slot:default="scope">
109
+ <div v-if="scope.row[item.fieldName]" class="view-picture">
110
+ <span style="color:#0c4c8e;border-bottom:1px solid #0c4c8e;cursor: pointer;" @click="handelClickViewPicture(scope.row, item.fieldName)">
111
+ 查看图片
112
+ </span>
113
+ </div>
114
+ <div v-else style="color:red">
115
+ 暂无图片
116
+ </div>
117
+ </template>
118
+ <!-- 对于复选框的类型,value和label后端没有进行处理,前端处理成展示的值 建国需求:2021.8.11 T-BUG -->
119
+ <template v-else-if="item.controllType === 'check_box'" v-slot:default="scope">
120
+ <div>
121
+ {{ scope.row[item.fieldName] | checkedFilter }}
122
+ </div>
123
+ </template>
124
+ </ux-table-column>
125
+ </template>
126
+ <ux-table-column v-if="isShow" title="操作" align="center" width="100">
127
+ <template v-slot:default="scope">
128
+ <slot ref="control" name="tableControl" :value="scope.row" />
129
+ </template>
130
+ </ux-table-column>
131
+ <!--<ux-table-column type="setting" resizable align="center" fixed="right" width="50">
132
+ <template slot="header">
133
+ <i class="el-icon-setting" style="cursor: pointer" @click="tableControlClick" />
134
+ </template>
135
+ </ux-table-column>-->
136
+ <template slot="empty">
137
+ <SvgIcon icon-class="table-empty" style="width: 100px;height: 100px;margin-top: 100px" />
138
+ <div style="font-size: 18px;margin-bottom: 100px">
139
+ 数据为空
140
+ </div>
141
+ </template>
142
+ </ux-grid>
143
+ <!-- 表格分页-->
144
+ <div ref="commonTablePagination" class="common-table-pagination">
145
+ <Pagination ref="commonTablePage" :total="paging.total" :paging="paging" :selected-total="selectedTotal" @pageChange="pageChange" />
146
+ </div>
147
+ <!-- 列表控制弹框组件-->
148
+ <TableControl
149
+ :table-layout="tableLayout"
150
+ :dialog-table-visible="dialogTableVisible"
151
+ @closeDialog="closeDialog"
152
+ @updateColumn="updateColumn"
153
+ />
154
+ <!-- 查看图片的弹框 -->
155
+ <ViewPicture
156
+ :dialog-visible="viewPictureVisable"
157
+ :view-picture-data="viewPictureData"
158
+ @handelClose="handelClose"
159
+ />
160
+ </div>
161
+ </template>
162
+
163
+ <script>
164
+ import Sortable from 'sortablejs/modular/sortable.core.esm.js'
165
+ import Pagination from './pagination'
166
+ import TableControl from './table-control'
167
+ import ViewPicture from './view-picture'
168
+ import { getFastSearchSuggestionVos } from '@/api/table'
169
+ export default {
170
+ name: 'CommonTable',
171
+ components: {
172
+ Pagination, TableControl, ViewPicture
173
+ },
174
+ filters: {
175
+ checkedFilter (value) {
176
+ if (!value) return ''
177
+ if (value === '0') return '否'
178
+ if (value === '1') return '是'
179
+ return '不兼容的选项'
180
+ }
181
+ },
182
+ props: {
183
+ // 绑定字段,字段变化时修改对应行颜色
184
+ fieldChangeData: {
185
+ type: Object,
186
+ default: () => {}
187
+ },
188
+ // 选中行数
189
+ selectedTotal: {
190
+ type: Number,
191
+ default: 0
192
+ },
193
+ // 表格ID
194
+ tableId: {
195
+ type: String,
196
+ default: ''
197
+ },
198
+ // 表格数据
199
+ tableData: {
200
+ type: Array,
201
+ default: () => {
202
+ return []
203
+ }
204
+ },
205
+ // 表格布局
206
+ tableLayout: {
207
+ type: Array,
208
+ default: () => {
209
+ return []
210
+ }
211
+ },
212
+ // 表格数据
213
+ getTableDataFunc: {
214
+ type: Function,
215
+ default: () => {
216
+ return null
217
+ }
218
+ },
219
+ // 分页
220
+ paging: {
221
+ type: Object,
222
+ default: () => {
223
+ return {}
224
+ }
225
+ },
226
+ // 合计数据
227
+ totalData: {
228
+ type: Array,
229
+ default: () => {
230
+ return []
231
+ }
232
+ },
233
+ // 是否开启单选模式
234
+ singleSelect: {
235
+ type: Boolean,
236
+ default: false
237
+ },
238
+ // 双击行编辑功能(默认开启)
239
+ dbClickAction: {
240
+ type: Boolean,
241
+ default: true
242
+ },
243
+ // 快捷过滤信息
244
+ quickFilterData: {
245
+ type: Object,
246
+ default: () => {}
247
+ },
248
+ // 是否开启双选
249
+ doubleSelect: {
250
+ type: Boolean,
251
+ default: false
252
+ },
253
+ // 表头的表名
254
+ headName: {
255
+ type: String,
256
+ default: ''
257
+ },
258
+ isShowTableSlot: {
259
+ type: Boolean,
260
+ default: null
261
+ }
262
+ },
263
+ data () {
264
+ return {
265
+ dialogTableVisible: false,
266
+ maxHeight: '60vh', // 表格最大宽度
267
+ // currentTableData: this.tableData,
268
+ tableTitle: null,
269
+ cities: [1, 2, 3],
270
+ checked: [],
271
+ selectData: [], // 暂存选中的数据
272
+ viewPictureVisable: false, // 打开查看图片模态框
273
+ viewPictureData: ''// 要传给图片模态框的值
274
+ }
275
+ },
276
+ computed: {
277
+ currentTableData: function () {
278
+ return this.tableData
279
+ },
280
+ isShow: function () {
281
+ if (this.isShowTableSlot === null) {
282
+ this.$nextTick(() => {
283
+ const slotArr = Object.keys(this.$scopedSlots)
284
+ if (slotArr.indexOf('tableControl') !== -1) {
285
+ return true
286
+ } else {
287
+ return false
288
+ }
289
+ })
290
+ }
291
+ return this.isShowTableSlot
292
+ }
293
+ },
294
+ watch: {
295
+ currentTableData: {
296
+ handler (newVal) {
297
+ this.$emit('updateParentTableData', newVal)
298
+ },
299
+ deep: true
300
+ },
301
+ // 用于刷新合计
302
+ totalData: {
303
+ handler (newVal) {
304
+ this.$refs.commonTable.updateData()
305
+ },
306
+ deep: true
307
+ },
308
+ tableLayout: {
309
+ handler (newVal) {
310
+ },
311
+ deep: true
312
+ }
313
+ },
314
+
315
+ mounted () {
316
+ this.columnDrop()
317
+ },
318
+
319
+ beforeDestroy () {
320
+ this.$emit('tableBeforeDestroy', this.tableTitle)
321
+ },
322
+
323
+ methods: {
324
+ // 表头单元格的style回调方法
325
+ headCellStyle () {
326
+ return 'font-family: Source Han Sans SC, Source Han Sans SC-Normal;font-weight: Normal;font-size:1.4vh'
327
+ },
328
+ // 表头点击事件 ---> 排序
329
+
330
+ /**
331
+ * 关闭所有表头筛选
332
+ */
333
+ closeAllVisible () {
334
+ for (const key in this.quickFilterData) {
335
+ if (key.indexOf('Visible') !== -1 && this.quickFilterData[key] === true) {
336
+ this.quickFilterData[key] = false
337
+ }
338
+ }
339
+ },
340
+
341
+ /**
342
+ * 表头点击事件 ---> 排序
343
+ */
344
+ sortTableData (item, column) {
345
+ if (column.order === 'desc') {
346
+ this.$refs.commonTable.clearSort()
347
+ } else if (column.order === 'asc') {
348
+ this.$refs.commonTable.sort(column.property, 'desc')
349
+ } else {
350
+ this.$refs.commonTable.sort(column.property, 'asc')
351
+ }
352
+ },
353
+
354
+ /**
355
+ * 点击查看图片
356
+ */
357
+ handelClickViewPicture (item, fieldName) {
358
+ this.viewPictureVisable = true
359
+ this.viewPictureData = item[fieldName]
360
+ },
361
+
362
+ /**
363
+ * 图片模态框子组件传来的方法,点击取消关闭模态框
364
+ */
365
+ handelClose (item) {
366
+ this.viewPictureVisable = item
367
+ },
368
+
369
+ /**
370
+ * 表头过滤的输入框input事件
371
+ */
372
+ inputChange (fieldName) {
373
+ const data = {
374
+ fastSearchSuggestQueryDtos: [{
375
+ columnName: fieldName.split('__')[1],
376
+ tableName: this.headName,
377
+ value: this.quickFilterData[fieldName]
378
+ }
379
+ ]
380
+ }
381
+ getFastSearchSuggestionVos(data).then(res => {
382
+ this.quickFilterData[fieldName + 'CheckedList'] = res.data[0].suggestions
383
+ this.quickFilterData[fieldName + 'Checked'] = [...this.quickFilterData[fieldName + 'CheckedList'], '全选']
384
+ })
385
+ // // 过滤数组
386
+ // this.quickFilterData[fieldName + 'CheckedList'] = this.quickFilterData[fieldName + 'CheckedList_Bak'].filter(item => {
387
+ // return item.indexOf(this.quickFilterData[fieldName]) !== -1
388
+ // })
389
+ // 默认全选
390
+ // this.quickFilterData[fieldName + 'Checked'] = [...this.quickFilterData[fieldName + 'CheckedList'], '全选']
391
+ },
392
+
393
+ /**
394
+ * 表头过滤选中数组change事件
395
+ */
396
+ bindCheckBox (value) {
397
+ // 实现单选功能
398
+ // if (this.quickFilterData[value].length > 1) {
399
+ // this.quickFilterData[value].splice(0, 1)
400
+ // }
401
+
402
+ },
403
+
404
+ /**
405
+ * 表头筛选的全选|取消全选
406
+ * @param fieldName 字段
407
+ * @param value true为全选,false为取消全选
408
+ */
409
+ changeAll (fieldName, value) {
410
+ if (value) {
411
+ // 全选
412
+ this.quickFilterData[fieldName + 'Checked'] = [...this.quickFilterData[fieldName + 'CheckedList'], '全选']
413
+ } else {
414
+ // 取消全选
415
+ this.quickFilterData[fieldName + 'Checked'] = []
416
+ }
417
+ },
418
+
419
+ /**
420
+ * 取消筛选
421
+ * @param fieldValue 字段
422
+ */
423
+ closeVisible: function (fieldValue) {
424
+ this.quickFilterData[fieldValue + 'Visible'] = false
425
+ this.quickFilterData[fieldValue] = ''
426
+ // this.quickFilterData[fieldValue + 'Checked'] = []
427
+ },
428
+
429
+ /**
430
+ * 确认筛选
431
+ * @param fieldValue 字段
432
+ */
433
+ confirmVisible: function (fieldValue) {
434
+ this.quickFilterData[fieldValue + 'Visible'] = false
435
+ this.quickFilterData[fieldValue + 'Checked_True'] = this.quickFilterData[fieldValue + 'Checked']
436
+ this.$emit('quickSearch')
437
+ },
438
+
439
+ /**
440
+ * 表格数据格式化: 数字精度统一为2
441
+ */
442
+ formatterDec ({ cellValue, row, column }) {
443
+ const reg = /^[0-9]+.?[0-9]*$/ // 判断字符串是否为数字
444
+ if (reg.test(cellValue)) {
445
+ const y = String(cellValue).indexOf('.') + 1 // 获取小数点的位置
446
+ const count = String(cellValue).length - y // 获取小数点后的个数
447
+ if (y > 0 && count > 2) {
448
+ return Number(cellValue).toFixed(2)
449
+ } else {
450
+ return cellValue
451
+ }
452
+ } else {
453
+ return cellValue
454
+ }
455
+ },
456
+
457
+ /**
458
+ * 表格双击
459
+ * @param row 行
460
+ */
461
+ handleDbclick (row) {
462
+ try {
463
+ if (this.$refs.commonTable.$children[0].$children[0].$children) {
464
+ const arr = this.$refs.commonTable.$children[0].$children[0].$children
465
+ arr.forEach(item => {
466
+ if (item.$options._componentTag === 'elx-tooltip') {
467
+ item.targetMouseleaveEvent()
468
+ }
469
+ })
470
+ }
471
+ } catch (e) {
472
+ console.log(e)
473
+ }
474
+ this.$emit('dbClick', row)
475
+ },
476
+
477
+ /**
478
+ * 表格选择项change事件
479
+ */
480
+ selectionChange (value) {
481
+ if (this.selectData.length === 0) {
482
+ this.$emit('selectionChange', value)
483
+ } else {
484
+ this.$emit('selectionChange', this.selectData)
485
+ }
486
+ },
487
+
488
+ /**
489
+ * 手动勾选数据行的 Checkbox 时触发事件
490
+ */
491
+ handleSelect (selection, row) {
492
+ if (this.doubleSelect) {
493
+ const selectData = new Set(this.selectData)
494
+ if (this.selectData.indexOf(row) === -1) {
495
+ selectData.add(row)
496
+ this.selectData = Array.from(selectData)
497
+ } else {
498
+ this.selectData = Array.from(selectData)
499
+ this.selectData.splice(this.selectData.indexOf(row), 1)
500
+ }
501
+ if (this.selectData.length > 2) {
502
+ this.$message.error('最多选择两条数据')
503
+ this.selectData.pop()
504
+ }
505
+ this.$refs.commonTable.clearSelection()
506
+ this.selectData.forEach(element => {
507
+ this.$refs.commonTable.toggleRowSelection([
508
+ {
509
+ row: element,
510
+ selected: true
511
+ }
512
+ ])
513
+ })
514
+ }
515
+ },
516
+
517
+ /**
518
+ * 关闭tag
519
+ * @param tag
520
+ */
521
+ handleTagClose (tag) {
522
+ this.selectData.splice(this.selectData.indexOf(tag), 1)
523
+ this.$refs.commonTable.clearSelection()
524
+ this.selectData.forEach(element => {
525
+ this.$refs.commonTable.toggleRowSelection([
526
+ {
527
+ row: element,
528
+ selected: true
529
+ }
530
+ ])
531
+ })
532
+ },
533
+
534
+ /**
535
+ * 动态设定单元格样式
536
+ * 根据绑定的字段,依据字段值获取表格内容样式
537
+ */
538
+ getCellStyle ({ row, column, rowIndex, columnIndex }) {
539
+ if (this.fieldChangeData && this.fieldChangeData.fieldName) {
540
+ const fieldName = this.fieldChangeData.fieldName
541
+ const findIndex = this.fieldChangeData.changeList.findIndex(d => d.key === row[fieldName])
542
+ if (findIndex !== -1) {
543
+ return {
544
+ color: this.fieldChangeData.changeList[findIndex].value
545
+ }
546
+ }
547
+ }
548
+ },
549
+
550
+ /**
551
+ * 表格当前行change事件
552
+ * @param row
553
+ */
554
+ handleRowSelect (row) {
555
+ if (this.singleSelect) {
556
+ this.$refs.commonTable.clearSelection()
557
+ this.$refs.commonTable.setCurrentRow(row)
558
+ }
559
+ },
560
+
561
+ /**
562
+ * 表格合计
563
+ */
564
+ getSummaries (param) {
565
+ return [this.totalData]
566
+ },
567
+
568
+ arraySorting (newValue) {
569
+ const arr = {}
570
+ newValue.forEach(item => {
571
+ arr[item.index] = item
572
+ })
573
+ arr.length = newValue.length
574
+ this.tableTitle = Array.from(arr)
575
+ },
576
+
577
+ /**
578
+ * 拖动表单列
579
+ */
580
+ columnDrop () {
581
+ this.$nextTick(() => {
582
+ const table = this.$refs.commonTable
583
+ this.sortable = Sortable.create(table.$el.querySelector('.body--wrapper .elx-table--header .elx-header--row'), {
584
+ handle: '.elx-header--column:not(.col--fixed)',
585
+ ghostClass: 'dragColbg',
586
+ chosenClass: 'dragColbg',
587
+ onEnd: ({ item, newIndex, oldIndex, ...arg }) => {
588
+ // fullColumn: 全量表头列 tableColumn: 当前渲染中的表头列
589
+ const { fullColumn, tableColumn } = table.getTableColumn()
590
+ const targetThElem = item
591
+ const wrapperElem = targetThElem.parentNode
592
+ const newColumn = fullColumn[newIndex]
593
+ if (newColumn.fixed) {
594
+ // 错误的移动
595
+ if (newIndex > oldIndex) {
596
+ wrapperElem.insertBefore(targetThElem, wrapperElem.children[oldIndex])
597
+ } else {
598
+ wrapperElem.insertBefore(wrapperElem.children[oldIndex], targetThElem)
599
+ }
600
+ return this.$message.error('固定列不允许拖动!')
601
+ }
602
+ // 转换真实索引
603
+ const oldColumnIndex = table.getColumnIndex(tableColumn[oldIndex])
604
+ const newColumnIndex = table.getColumnIndex(tableColumn[newIndex])
605
+ // 移动到目标列
606
+ const currRow = fullColumn.splice(oldColumnIndex, 1)[0]
607
+ fullColumn.splice(newColumnIndex, 0, currRow)
608
+ // 加载列
609
+ // 向父组件发送表格顺序
610
+ this.$emit('columnChange', fullColumn)
611
+ table.loadColumn(fullColumn)
612
+ }
613
+ })
614
+ })
615
+ },
616
+
617
+ /**
618
+ * 改变表格列宽度
619
+ */
620
+ changeColumnWidth ({ column, $columnIndex }) {
621
+ try {
622
+ this.$emit('changeWidth', column)
623
+ // this.tableTitle[$columnIndex].width = column['renderWidth']
624
+ } catch (err) {
625
+ throw new Error(err)
626
+ }
627
+ },
628
+
629
+ /**
630
+ * 页签变化
631
+ */
632
+ async pageChange (value) {
633
+ this.$emit('pageChange', value)
634
+ },
635
+
636
+ /**
637
+ * 刷新表格数据
638
+ */
639
+ refreshTableData () {
640
+ this.$refs.commonTablePage.changePage()
641
+ },
642
+
643
+ /**
644
+ * 打开列表控制弹框
645
+ */
646
+ tableControlClick () {
647
+ this.dialogTableVisible = true
648
+ },
649
+
650
+ /**
651
+ * 子传父关闭Dialog
652
+ * @param value
653
+ */
654
+ closeDialog (value) {
655
+ this.dialogTableVisible = value
656
+ },
657
+
658
+ /**
659
+ * 更新表格列配置
660
+ */
661
+ updateColumn () {
662
+ this.$nextTick(() => {
663
+ this.$refs.commonTable.refreshColumn()
664
+ })
665
+ }
666
+
667
+ }
668
+ }
669
+ </script>
670
+
671
+ <style lang="less" scoped>
672
+ @import "@/assets/styles/common-table";
673
+ @paginationHeight: 8vh;
674
+ .common-table-main{
675
+ height: 100%;
676
+ >div:nth-child(1) {
677
+ margin-bottom: 0.5vh;
678
+ ::v-deep .el-tag {
679
+ margin-right: 0.2vw;
680
+ height: 3vh;
681
+ line-height: 3vh;
682
+ }
683
+ }
684
+ }
685
+ .common-header-filter{
686
+ position: relative;
687
+ .popover{
688
+ position: absolute;
689
+ right: 2px;
690
+ bottom: 0;
691
+ }
692
+ }
693
+ // 分页组件定位
694
+ .common-table-pagination{
695
+ margin-top: -0.5vh;
696
+ height: @paginationHeight;
697
+ ::v-deep .pagination{
698
+ height: @paginationHeight;
699
+ //display: flex;
700
+ .el-pagination{
701
+ padding: 0;
702
+ }
703
+ .el-pagination__total, .el-pagination__sizes{
704
+ height: @paginationHeight;
705
+ line-height: @paginationHeight;
706
+ }
707
+ .btn-prev, .btn-next, .el-pager, .el-pager li{
708
+ height: @paginationHeight;
709
+ line-height: @paginationHeight;
710
+ }
711
+ .el-select__caret{
712
+ display: flex;
713
+ align-items: center;
714
+ justify-content: center;
715
+ }
716
+ .el-pagination__editor{
717
+ height: @paginationHeight;
718
+ line-height: @paginationHeight;
719
+ }
720
+ }
721
+ // position: absolute;
722
+ // bottom: 1.5vh;
723
+ // right: 2vw;
724
+ }
725
+ // 表头快捷过滤样式
726
+ .el-popover{
727
+ .popover-input{
728
+ ::v-deep .el-input__inner{
729
+ height: 3vh;
730
+ margin-bottom: 1vh;
731
+ }
732
+ ::v-deep .el-input__suffix{
733
+ height: 3vh;
734
+ }
735
+ }
736
+ .el-checkbox{
737
+ display: block !important;
738
+ }
739
+ // 表头筛选
740
+ .header-filter{
741
+ height: 12vh;
742
+ ::v-deep .el-scrollbar{
743
+ .el-scrollbar__wrap{
744
+ overflow-x: hidden;
745
+ }
746
+ }
747
+ }
748
+ }
749
+
750
+ </style>