@kyfe/ks-query-table 0.0.2 → 0.0.3

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 (75) hide show
  1. package/index.js +35386 -7
  2. package/package.json +7 -5
  3. package/query-table.common.js.map +1 -0
  4. package/query-table.css +1 -0
  5. package/query-table.umd.js +35396 -0
  6. package/query-table.umd.js.map +1 -0
  7. package/query-table.umd.min.js +11 -0
  8. package/query-table.umd.min.js.map +1 -0
  9. package/README.md +0 -45
  10. package/api/index.js +0 -12
  11. package/assets/horizontal-back.svg +0 -1
  12. package/components/pe-table/cell.js +0 -184
  13. package/components/pe-table/collapse.js +0 -334
  14. package/components/pe-table/empty.vue +0 -48
  15. package/components/pe-table/header.js +0 -328
  16. package/components/pe-table/images/abnormal.png +0 -0
  17. package/components/pe-table/images/empty.png +0 -0
  18. package/components/pe-table/images/fold.svg +0 -1
  19. package/components/pe-table/images/sort.svg +0 -1
  20. package/components/pe-table/images/sorting.svg +0 -1
  21. package/components/pe-table/images/unfold.svg +0 -1
  22. package/components/pe-table/index.vue +0 -837
  23. package/components/pe-table/load-more.js +0 -46
  24. package/components/pe-table/props/index.js +0 -183
  25. package/components/pe-table/row.vue +0 -118
  26. package/components/pe-table/scrollbar.js +0 -424
  27. package/components/pe-table/stretch-damping.js +0 -112
  28. package/components/pe-table/style/cell.less +0 -89
  29. package/components/pe-table/style/empty.less +0 -48
  30. package/components/pe-table/style/header.less +0 -141
  31. package/components/pe-table/style/index.less +0 -88
  32. package/components/pe-table/style/load-more.less +0 -61
  33. package/components/pe-table/style/row.less +0 -6
  34. package/components/pe-table/table-loading.vue +0 -119
  35. package/components/pe-table/table-total.vue +0 -53
  36. package/components/pe-table/utils/animate.js +0 -80
  37. package/components/pe-table/utils/columns.js +0 -290
  38. package/components/pe-table/utils/data.js +0 -12
  39. package/components/pe-table/utils/fixed.js +0 -69
  40. package/components/pe-table/utils/formatter.js +0 -327
  41. package/components/pe-table/utils/render-cells.js +0 -424
  42. package/components/pe-table/utils/slot.js +0 -28
  43. package/components/pe-table/utils/tools.js +0 -84
  44. package/components/pe-table/utils/touch-scroll.js +0 -417
  45. package/components/query-table/index.vue +0 -492
  46. package/components/query-table/mixins/column-mixin.js +0 -102
  47. package/components/query-table/mixins/column-setting.js +0 -143
  48. package/components/query-table/mixins/data-mixin.js +0 -502
  49. package/components/query-table/mixins/pagination-mixin.js +0 -25
  50. package/components/query-table/mixins/table-fixed.js +0 -111
  51. package/components/query-table/mixins/table-horizontal.js +0 -119
  52. package/components/table-horizontal.vue +0 -99
  53. package/components/table-pagination.vue +0 -32
  54. package/components/table-settings/assets/arrpw-up.svg +0 -1
  55. package/components/table-settings/assets/disabled-down.svg +0 -1
  56. package/components/table-settings/assets/disabled-up.svg +0 -1
  57. package/components/table-settings/assets/down.svg +0 -1
  58. package/components/table-settings/assets/up.svg +0 -1
  59. package/components/table-settings/index.less +0 -294
  60. package/components/table-settings/index.vue +0 -260
  61. package/components/table-settings/settings.vue +0 -479
  62. package/components/table-settings/test.js +0 -626
  63. package/components/table-settings//344/270/252/346/200/247/350/256/276/347/275/256.md +0 -0
  64. package/components/tooltip.js +0 -124
  65. package/hooks/use-cache-promise.js +0 -27
  66. package/hooks/use-column-config.js +0 -186
  67. package/hooks/use-encryption.js +0 -0
  68. package/hooks/use-generic-search.js +0 -95
  69. package/store/column-store.js +0 -0
  70. package/styles/table.less +0 -24
  71. package/utils/column.js +0 -36
  72. package/utils/config.js +0 -12
  73. package/utils/encryption.js +0 -32
  74. package/utils/http.js +0 -1
  75. package/utils/localStorage.js +0 -35
@@ -1,492 +0,0 @@
1
- <script>
2
- import { initGenericSearch } from '../../hooks/use-generic-search'
3
- import PeTable from '../pe-table/index.vue'
4
- import { PE_TABLE_PROPS } from '../pe-table/props/index.js'
5
- import { tableDecrypt } from '../../utils/encryption.js'
6
- import { handleShowPopover } from '../tooltip'
7
- import { getLocalStorageItem, setLocalStorageItem } from '../../utils/localStorage'
8
-
9
- import columnMixin from './mixins/column-mixin.js' // 表头列配置
10
- import columnSettingMixin from './mixins/column-setting.js' // 表头列的变更
11
- import tableHorizontalMixin from './mixins/table-horizontal.js' // 表格横屏
12
- import tableFixedMixin from './mixins/table-fixed' // 吸顶
13
- import tableDataMixin from './mixins/data-mixin'
14
- import TablePagination from '../table-pagination.vue'
15
- import PaginationMixin from './mixins/pagination-mixin'
16
-
17
- import '../../styles/table.less'
18
-
19
-
20
- let TABLE_ID = 1
21
-
22
- export default {
23
- mixins: [PaginationMixin, columnMixin, columnSettingMixin, tableFixedMixin, tableHorizontalMixin, tableDataMixin],
24
- name: 'HsQueryTable',
25
- props: {
26
- ...PE_TABLE_PROPS,
27
-
28
- searchCode: String,
29
- config: {
30
- type: Object,
31
- default: () => {
32
- return {}
33
- },
34
- },
35
-
36
- isSorbentColumm: {
37
- type: Boolean,
38
- default: false,
39
- },
40
- showSettingDialog: {
41
- type: Boolean,
42
- default: true,
43
- },
44
- // total: {
45
- // type: [Number, String],
46
- // default: 0,
47
- // },
48
- // hideColumms: {
49
- // type: Array,
50
- // default: () => [],
51
- // },
52
- innerTabVisible: {
53
- type: Boolean,
54
- default: true,
55
- },
56
- marginWidth: {
57
- type: Number,
58
- default: 0,
59
- },
60
- // 是否需要解密功能,需要配合render渲染***
61
- decrypt: {
62
- type: Boolean,
63
- default: false,
64
- },
65
- tableTag: {
66
- type: String,
67
- default: '',
68
- },
69
- },
70
- data() {
71
- return {
72
- currentPage: 1,
73
- totalPages: 5,
74
- total: 0,
75
-
76
- tableData: null,
77
- // 是否隐藏底部bar
78
- isHideBar: true,
79
- isShowTotal: false,
80
- onlineColumns: [],
81
- resizeColumnMap: {},
82
- tableWidth: this.width,
83
- tableHeight: this.height,
84
- // 竖屏-宽
85
- spTableWidth: 0,
86
- // 竖屏-高
87
- spTableHeight: 0,
88
- // 状态栏高度
89
- statusHeight: window.__statusBarHeight__ || 0,
90
- isCurTableEmit: false,
91
- curTableId: TABLE_ID++,
92
- tableColunms: [],
93
- tableIsAbnormal: false,
94
- isLoading: false,
95
- // showPopover: true,
96
- // containerPopover: '',
97
- // popRowIndex: 0,
98
- }
99
- },
100
- watch: {
101
- width: {
102
- handler(val) {
103
- if (val) {
104
- this.tableWidth = val
105
- }
106
- },
107
- },
108
- height: {
109
- handler(val) {
110
- if (val) {
111
- this.tableHeight = val
112
- }
113
- },
114
- },
115
- columns: {
116
- handler(val) {
117
- if (val) {
118
- this.setOnlineColumns(val)
119
- }
120
- },
121
- },
122
- resizeColumnMap: {
123
- handler() {
124
- this.onlineColumns.forEach(col => this.mergeColumn(col))
125
- },
126
- },
127
- // 下掉没用
128
- // 使用function
129
- // 用refs调进来,不要watch
130
- // hideColumms: {
131
- // async handler(val) {
132
- // if (val) {
133
- // // TODO 存xy, 重置回去?不使用
134
- // this.isUpdateOffset = false
135
- // await this.$nextTick()
136
- // this.isUpdateOffset = true
137
- // setTimeout(() => {
138
- // this.$refs.peTable.updateRender()
139
- // }, 0)
140
- // }
141
- // },
142
- // },
143
- // data: {
144
- // handler() {
145
- // // TODO 一定要干掉
146
- // if (!this.onlineColumns || !this.onlineColumns.length) {
147
- // this.getColumns()
148
- // }
149
- // },
150
- // },
151
- },
152
- render() {
153
- const slot = this.$slots.default ? this.$slots.default[0] : this.$scopedSlots
154
- const $props = this.$props
155
-
156
- // 表格
157
- const createPeTable = () => {
158
- const peTableAttrs = {
159
- props: {
160
- total: this.total,
161
- columns: this.onlineColumns,
162
- data: this.tableData || $props.data,
163
- rowHeight: $props.rowHeight,
164
- headerRowHeight: $props.headerRowHeight,
165
- rowKey: $props.rowKey,
166
- cellClassName: $props.cellClassName,
167
- headerCellClassName: $props.headerCellClassName,
168
- showIndex: $props.showIndex,
169
- beforeSort: $props.beforeSort,
170
- emptyText: $props.emptyText,
171
- scrollY: $props.scrollY && this.fixedScrollY,
172
- scrollX: $props.scrollX,
173
- autoResetScrollTop: $props.autoResetScrollTop,
174
- width: this.tableWidth,
175
- height: this.tableHeight,
176
- maxHeight: $props.maxHeight,
177
- isShowHorizontal: this.isShowHorizontal,
178
- isLoading: this.isLoading,
179
- isAbnormal: this.tableIsAbnormal,
180
- isLoadFinished: $props.isLoadFinished,
181
- enableLoadMore: $props.enableLoadMore,
182
- defaultSort: $props.defaultSort,
183
- delayLoading: $props.delayLoading || this.innterDelayLoading,
184
- isOpenTwoHeaderBg: $props.isOpenTwoHeaderBg,
185
- isSorbentColumm: $props.isSorbentColumm,
186
- isUpdateOffset: this.isUpdateOffset,
187
- indexFormat: $props.indexFormat,
188
- noOneScreenNoShowMore: $props.noOneScreenNoShowMore,
189
- isScrollShowTotal: $props.isScrollShowTotal,
190
- },
191
- on: {
192
- 'cell-click': this.cellClick,
193
- 'header-cell-click': this.headerCellClick,
194
- 'cell-resize': this.cellResize,
195
- 'sort-change': this.sortChange,
196
- collapsed: this.collapedChange,
197
- scroll: this.scroll,
198
- scrollTouchend: this.handlerTouchend,
199
- scrollTouchstar: this.handlerTouchstar,
200
- 'table-mounted': this.tableMounted,
201
- abnormal: this.abnormal,
202
- 'cell-long': this.handleCellLong,
203
- },
204
- ref: 'peTable',
205
- scopedSlots: {
206
- empty: slot['empty'],
207
- },
208
- }
209
- return <PeTable {...peTableAttrs}></PeTable>
210
- }
211
-
212
- const createPagination = () => {
213
- return this.showPage && !this.config.scrollLoad ? (
214
- <TablePagination
215
- total-pages={this.totalPages}
216
- current-page={this.currentPage}
217
- on={{
218
- pageChanged: this.onPageChanged,
219
- }}
220
- />
221
- ) : null
222
- }
223
- return (
224
- <div ref="peTableWrappper" class="pe-table-wrappper">
225
- {this.createTableSetting()}
226
- {
227
- <div ref="tableBoxRef" class="table-box">
228
- {slot.topUnfixed && <div class="top-unfixed">{slot.topUnfixed()}</div>}
229
- <div class="fixed-box">
230
- {slot.topFixed && <div class="top-fixed">{slot.topFixed()}</div>}
231
- <div class="table">
232
- <div ref="mesosphereWrap" style="height: 100%; width: 100%">
233
- {createPeTable()}
234
- </div>
235
- </div>
236
- {createPagination()}
237
- </div>
238
- </div>
239
- }
240
- {this.createHorizontal()}
241
- </div>
242
- )
243
- },
244
- methods: {
245
- // hideColumms(keys) {
246
- // console.log(this.onlineColumns)
247
- // let colunms = this.onlineColumns.filter(v => !keys.includes(v.key))
248
- // console.log(colunms)
249
- // this.tableColunms = colunms
250
- // },
251
- // 单元格点击
252
- async cellClick(...args) {
253
- let cellClickNext = true
254
- if (this.decrypt) {
255
- // 解密
256
- cellClickNext = await tableDecrypt(...args)
257
- }
258
- if (!cellClickNext) return
259
- // 气泡
260
- const { show } = await handleShowPopover(...args, this)
261
- if (show) return
262
- this.$emit('cell-click', ...args)
263
- },
264
- // 调整列宽
265
- cellResize({ column, width }) {
266
- this.resizeColumnMap[column.key] = width
267
- this.saveResizeColumnMap(this.resizeColumnMap)
268
- },
269
- // 表头点击
270
- headerCellClick(...args) {
271
- this.$emit('header-cell-click', ...args)
272
- },
273
- // 单元格长按
274
- handleCellLong(...args) {
275
- this.$emit('cell-long', ...args)
276
- },
277
- // 自定义列初始化完成
278
- initColumns(...args) {
279
- this.$emit('init-columns', ...args)
280
- },
281
- // 排序
282
- sortChange(...args) {
283
- this.$emit('sort-change', ...args)
284
- this.loadData(...args)
285
- },
286
- // 伸缩列
287
- collapedChange(...args) {
288
- this.$emit('collapsed', ...args)
289
- },
290
- // 滚动
291
- scroll(...args) {
292
- this.fixedTableScroll(...args)
293
- this.$emit('scroll', ...args)
294
- },
295
- // 触摸结束
296
- handlerTouchend(...args) {
297
- this.tableScrollPullData(...args)
298
- this.$emit('scrollTouchend', ...args)
299
- },
300
- // 触摸开始
301
- handlerTouchstar(...args) {
302
- this.$emit('scrollTouchstar', ...args)
303
- },
304
- // 表格加载完成
305
- tableMounted() {
306
- this.$emit('table-mounted')
307
- },
308
- // 点击重新加载
309
- abnormal() {
310
- this.loadData()
311
- this.$emit('abnormal')
312
- },
313
- // 横向滚动到指定列
314
- scrollToColumn(...args) {
315
- this.$refs.peTable.scrollToColumn(...args)
316
- },
317
- // 滚动到指定行
318
- scrollToRow(...args) {
319
- this.$refs.peTable.scrollToRow(...args)
320
- },
321
- // Y轴滚动
322
- scrollToTop(scrollTop) {
323
- this.$refs.peTable.scrollToTop(scrollTop)
324
- },
325
- // X轴滚动
326
- scrollToLeft(scrollLeft) {
327
- this.$refs.peTable.scrollToLeft(scrollLeft)
328
- },
329
- // 重新渲染视口列
330
- renderViewportCellsColumns() {
331
- return this.$refs.peTable.renderViewportCellsColumns()
332
- },
333
- // todo 没用下掉
334
- // delay(ms) {
335
- // return new Promise(resolve => setTimeout(resolve, ms))
336
- // },
337
- // todo 没用下掉
338
- // 设置HTML文档字体 rem据此设置生效
339
- // setHtmlFontSize() {
340
- // // 提前设置,所以用height
341
- // var clientWidth = document.documentElement.clientHeight
342
- // if (clientWidth) {
343
- // let px = clientWidth / 10
344
- // document.documentElement.style.fontSize = px + 'px'
345
- // }
346
- // },
347
- // 手动调用排序
348
- sortChangeHand(column, order) {
349
- this.$refs.peTable.sortChange(column, order)
350
- },
351
- // 清除排序状态
352
- clearSortMap() {
353
- this.$refs.peTable.clearSortMap()
354
- },
355
- resizeTable(params) {
356
- const { width = 0, state = null } = params || {}
357
- setTimeout(() => {
358
- let clientWidth = width || this.$parent.$el.clientWidth
359
- // 增加兜底,存在获取到的 clientWidth 为 0 的情况
360
- console.log(width, clientWidth, 'clientWidth------------')
361
- if (!clientWidth) {
362
- clientWidth = this.$root.$el.clientWidth || window.webAppW
363
- }
364
- this.tableWidth = clientWidth
365
- // state === 0 折叠
366
- // state !== 0 展开
367
- if (state === 2) {
368
- requestAnimationFrame(() => this.$refs.peTable.scrollToLeft(this.$refs.peTable.offsetX || 0))
369
- }
370
- }, 0)
371
- },
372
- // 折叠屏状态变更
373
- onFoldStateChanged(state) {
374
- // 折叠屏不会触发横屏
375
- if (window.PE_tableHorizontal) {
376
- return
377
- }
378
- const isMutiScreen = state !== 0
379
- console.log('onFoldStateChanged', isMutiScreen, this.isShowHorizontal, this.getCurrenWidth(Number(this.isShowHorizontal)))
380
- if (this.isShowHorizontal && isMutiScreen) {
381
- this.closeHorizontal()
382
- }
383
- this.resizeTable({
384
- width: this.getCurrenWidth(Number(this.isShowHorizontal)),
385
- state,
386
- })
387
- },
388
- getCurrenWidth(status) {
389
- // int 0竖屏(默认)、1横屏
390
- const { innerWidth, innerHeight } = window
391
- let width = innerWidth
392
- if (status === 1) {
393
- width = Math.max(innerWidth, innerHeight) - this.statusHeight
394
- } else {
395
- width = Math.min(innerWidth, innerHeight) - this.marginWidth
396
- }
397
- return width
398
- },
399
- screenChange(status) {
400
- if (this.isCurTableEmit) {
401
- this.isCurTableEmit = false
402
- return
403
- }
404
- this.resizeTable({
405
- width: this.getCurrenWidth(status),
406
- status,
407
- })
408
- },
409
- // todo下掉
410
- // updateColumn(col) {
411
- // this.onlineColumns.some(v => {
412
- // if (v.key === col.key) {
413
- // Object.assign(v, col)
414
- // return true
415
- // } else {
416
- // return false
417
- // }
418
- // })
419
- // },
420
- // 更新自定义列
421
- updateColumns(cols) {
422
- cols.forEach(c => {
423
- this.onlineColumns.some(v => {
424
- if (c.key === v.key) {
425
- Object.assign(v, c)
426
- return true
427
- } else {
428
- return false
429
- }
430
- })
431
- })
432
- },
433
-
434
- // 获取本地存储的列宽数据
435
- async getResizeColumnMap() {
436
- if (!this.searchCode) return {}
437
- const res = await getLocalStorageItem(`pe_table_cell_resize-${ksui.menu.id}-${this.searchCode}`)
438
- return res ? JSON.parse(res) : {}
439
- },
440
- // 保存列宽数据到本地(App 或 LocalStorage)
441
- saveResizeColumnMap(columnMap = {}) {
442
- if (!this.searchCode) return {}
443
- setLocalStorageItem(`pe_table_cell_resize-${ksui.menu.id}-${this.searchCode}`, JSON.stringify(columnMap))
444
- return columnMap
445
- },
446
- // 清空本地缓存的列宽数据
447
- clearResizeColumnMap() {
448
- return this.saveResizeColumnMap()
449
- },
450
- checkMenuId() {
451
- if ((!ksui?.menu?.id)) {
452
- console.log('%c[query-table-error] 组件内部未获取到menuId,请检查 ksui.menu.id', 'font-size: 15px; color: red;')
453
- }
454
- },
455
- },
456
- created() {
457
- this.checkMenuId()
458
- // 获取当前菜单下所有自定义列的配置
459
- initGenericSearch()
460
- this.getResizeColumnMap().then(map => {
461
- this.resizeColumnMap = map
462
- })
463
- },
464
- mounted() {
465
- // this.autoResizeHeight()
466
- // this.containerPopover = this.$refs.peTableWrappper
467
- // 下掉 ref调用
468
- // this.$bus.$on('onFoldStateChanged', this.onFoldStateChanged)
469
- // this.$bus.$on('screenChange', this.screenChange)
470
- },
471
- // todo? 研究下 下掉
472
- // activated() {
473
- // setTimeout(() => {
474
- // console.log('activated--this.$parent.$el.clientWidth', this.$parent.$el.clientWidth)
475
- // this.resizeTable()
476
- // }, 100)
477
- // },
478
- beforeDestroy() {
479
- // this._resizeObserver = null
480
- // this.$bus.$off('onFoldStateChanged', this.onFoldStateChanged)
481
- // this.$bus.$off('screenChange', this.screenChange)
482
- },
483
- }
484
- </script>
485
-
486
- <style lang="less" scoped>
487
- .pe-table-wrappper {
488
- position: relative;
489
- height: 100%;
490
- width: 100%;
491
- }
492
- </style>
@@ -1,102 +0,0 @@
1
- // finish
2
- import { addColumnParams } from '../../../utils/column.js'
3
- import { ColUtils, getGeneric } from '../../../hooks/use-column-config.js'
4
- export default {
5
- props: {
6
- needCache: {
7
- type: Boolean
8
- },
9
- // 自定义渲染单元格配置
10
- rowCellRenderOptions: {
11
- type: Object,
12
- default: () => {
13
- return {
14
- // one2: (h, { rowData }) => {
15
- // return <span style={{ 'color': 'red' }}>{rowData.one2}</span>
16
- // }
17
- }
18
- }
19
- },
20
- // 自定义渲染表头配置
21
- headerCellRenderOptions: {
22
- type: Object,
23
- default: () => {
24
- return {
25
- // one2: (h, { rowData }) => {
26
- // return <span style={{ 'color': 'red' }}>{rowData.one2}</span>
27
- // }
28
- }
29
- }
30
- },
31
- // 强制保存到线上
32
- forceSaveSettings: {
33
- type: Boolean,
34
- default: false
35
- }
36
- },
37
- data() {
38
- return {
39
- genericId: ''
40
- }
41
- },
42
- beforeDestroy() {
43
- this.colUtils = null
44
- },
45
- created() {
46
- this.colUtils = new ColUtils({ mergeColumn: this.mergeColumn })
47
- if (this.columns && this.columns.length) {
48
- this.setOnlineColumns(this.columns)
49
- } else {
50
- this.getColumns();
51
- }
52
- },
53
- methods: {
54
- setOnlineColumns(val) {
55
- this.onlineColumns = addColumnParams(val)
56
- },
57
- setColumnsOk(res) {
58
- if (res) {
59
- this.setColsToStorage(res)
60
- this.onlineColumns = res
61
- this.$emit('init-columns', this.onlineColumns)
62
- }
63
- },
64
- // 获取线上配置
65
- async getColumns() {
66
- this.setColumnsOk(await this.colUtils.run(this.searchCode, false))
67
- },
68
- mergeColumn(v) {
69
- if (this.rowCellRenderOptions && this.rowCellRenderOptions[v.key]) {
70
- v.rowCellRender = this.rowCellRenderOptions[v.key]
71
- }
72
- if (this.headerCellRenderOptions && this.headerCellRenderOptions[v.key]) {
73
- v.headerCellRender = this.headerCellRenderOptions[v.key]
74
- }
75
- // 二级表头Formatter
76
- if (v.children && Array.isArray(v.children)) {
77
- v.children.forEach(child => {
78
- if (this.rowCellRenderOptions && this.rowCellRenderOptions[child.key]) {
79
- child.rowCellRender = this.rowCellRenderOptions[child.key]
80
- }
81
- if (this.headerCellRenderOptions && this.headerCellRenderOptions[child.key]) {
82
- child.headerCellRender = this.headerCellRenderOptions[child.key]
83
- }
84
- // 二级头需根据一级头显示/隐藏
85
- const show = v.show ? !!child.show : false
86
- this.$set(child, 'show', show)
87
- })
88
- }
89
-
90
- // 如果调整过单元格宽度,则读取本地存储的调整后的值
91
- const width = this.resizeColumnMap[v.key]
92
- if (width) {
93
- v.width = width
94
- }
95
- },
96
- async getGenericId() {
97
- // 当前菜单的通用查询配置
98
- let userData = await getGeneric(this.searchCode)
99
- return userData && userData.id
100
- },
101
- },
102
- }