@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.
- package/index.js +35386 -7
- package/package.json +7 -5
- package/query-table.common.js.map +1 -0
- package/query-table.css +1 -0
- package/query-table.umd.js +35396 -0
- package/query-table.umd.js.map +1 -0
- package/query-table.umd.min.js +11 -0
- package/query-table.umd.min.js.map +1 -0
- package/README.md +0 -45
- package/api/index.js +0 -12
- package/assets/horizontal-back.svg +0 -1
- package/components/pe-table/cell.js +0 -184
- package/components/pe-table/collapse.js +0 -334
- package/components/pe-table/empty.vue +0 -48
- package/components/pe-table/header.js +0 -328
- package/components/pe-table/images/abnormal.png +0 -0
- package/components/pe-table/images/empty.png +0 -0
- package/components/pe-table/images/fold.svg +0 -1
- package/components/pe-table/images/sort.svg +0 -1
- package/components/pe-table/images/sorting.svg +0 -1
- package/components/pe-table/images/unfold.svg +0 -1
- package/components/pe-table/index.vue +0 -837
- package/components/pe-table/load-more.js +0 -46
- package/components/pe-table/props/index.js +0 -183
- package/components/pe-table/row.vue +0 -118
- package/components/pe-table/scrollbar.js +0 -424
- package/components/pe-table/stretch-damping.js +0 -112
- package/components/pe-table/style/cell.less +0 -89
- package/components/pe-table/style/empty.less +0 -48
- package/components/pe-table/style/header.less +0 -141
- package/components/pe-table/style/index.less +0 -88
- package/components/pe-table/style/load-more.less +0 -61
- package/components/pe-table/style/row.less +0 -6
- package/components/pe-table/table-loading.vue +0 -119
- package/components/pe-table/table-total.vue +0 -53
- package/components/pe-table/utils/animate.js +0 -80
- package/components/pe-table/utils/columns.js +0 -290
- package/components/pe-table/utils/data.js +0 -12
- package/components/pe-table/utils/fixed.js +0 -69
- package/components/pe-table/utils/formatter.js +0 -327
- package/components/pe-table/utils/render-cells.js +0 -424
- package/components/pe-table/utils/slot.js +0 -28
- package/components/pe-table/utils/tools.js +0 -84
- package/components/pe-table/utils/touch-scroll.js +0 -417
- package/components/query-table/index.vue +0 -492
- package/components/query-table/mixins/column-mixin.js +0 -102
- package/components/query-table/mixins/column-setting.js +0 -143
- package/components/query-table/mixins/data-mixin.js +0 -502
- package/components/query-table/mixins/pagination-mixin.js +0 -25
- package/components/query-table/mixins/table-fixed.js +0 -111
- package/components/query-table/mixins/table-horizontal.js +0 -119
- package/components/table-horizontal.vue +0 -99
- package/components/table-pagination.vue +0 -32
- package/components/table-settings/assets/arrpw-up.svg +0 -1
- package/components/table-settings/assets/disabled-down.svg +0 -1
- package/components/table-settings/assets/disabled-up.svg +0 -1
- package/components/table-settings/assets/down.svg +0 -1
- package/components/table-settings/assets/up.svg +0 -1
- package/components/table-settings/index.less +0 -294
- package/components/table-settings/index.vue +0 -260
- package/components/table-settings/settings.vue +0 -479
- package/components/table-settings/test.js +0 -626
- package/components/table-settings//344/270/252/346/200/247/350/256/276/347/275/256.md +0 -0
- package/components/tooltip.js +0 -124
- package/hooks/use-cache-promise.js +0 -27
- package/hooks/use-column-config.js +0 -186
- package/hooks/use-encryption.js +0 -0
- package/hooks/use-generic-search.js +0 -95
- package/store/column-store.js +0 -0
- package/styles/table.less +0 -24
- package/utils/column.js +0 -36
- package/utils/config.js +0 -12
- package/utils/encryption.js +0 -32
- package/utils/http.js +0 -1
- package/utils/localStorage.js +0 -35
|
@@ -1,424 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
// import Vue from 'vue'
|
|
3
|
-
const Vue = window.Vue // 在此项目中,Vue使用的是public下的运行时的vue.reuntime.min.js。所以此时需要保持一致
|
|
4
|
-
import CellRenderer from '../cell.js'
|
|
5
|
-
import HeaderRenderer from '../header.js'
|
|
6
|
-
import { getClasses } from './tools.js'
|
|
7
|
-
import { tableCellFormatterResult } from './formatter.js'
|
|
8
|
-
const CellRendererConstructor = Vue.extend(CellRenderer)
|
|
9
|
-
const HeaderRendererConstructor = Vue.extend(HeaderRenderer)
|
|
10
|
-
|
|
11
|
-
const createHeaderCellOption = ({
|
|
12
|
-
isRenderFixedCell,
|
|
13
|
-
column = {},
|
|
14
|
-
grid,
|
|
15
|
-
columnIndex,
|
|
16
|
-
columns
|
|
17
|
-
}) => {
|
|
18
|
-
const { headerCellClassName, headerAlign, children } = column || {}
|
|
19
|
-
const params = {
|
|
20
|
-
columnIndex: columnIndex,
|
|
21
|
-
column: column,
|
|
22
|
-
align: headerAlign || (children && children.length && 'center'),
|
|
23
|
-
grid,
|
|
24
|
-
// isHeader: true
|
|
25
|
-
}
|
|
26
|
-
return {
|
|
27
|
-
text: isRenderFixedCell ? '' : column.label,
|
|
28
|
-
columnIndex,
|
|
29
|
-
columns,
|
|
30
|
-
placeholderSign: isRenderFixedCell, // 渲染空节点
|
|
31
|
-
headerCellClassName: getClasses(headerCellClassName, params),
|
|
32
|
-
globalHeaderCellClassName: getClasses(grid.headerCellClassName, params),
|
|
33
|
-
top: column.top,
|
|
34
|
-
height: column.height,
|
|
35
|
-
sortable:
|
|
36
|
-
(!column.children || !column.children.length) &&
|
|
37
|
-
(column.sortable || column.sortKeys), // 兼容sortKeys
|
|
38
|
-
collapseKeys: column.collapseKeys,
|
|
39
|
-
collapsed: column.collapsed,
|
|
40
|
-
sortOrder: grid.sortMap.key === column.key && grid.sortMap.order,
|
|
41
|
-
cellResizable: grid.cellResizable,
|
|
42
|
-
isOpenTwoHeaderBg: grid.isOpenTwoHeaderBg,
|
|
43
|
-
// 方法
|
|
44
|
-
sortChange: grid.sortChange,
|
|
45
|
-
changeCollapseKeys: grid.changeCollapseKeys,
|
|
46
|
-
cellResize: grid.cellResize,
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const createRowCellOption = ({
|
|
51
|
-
isRenderFixedCell,
|
|
52
|
-
cell = {},
|
|
53
|
-
rowIndex,
|
|
54
|
-
columnIndex,
|
|
55
|
-
grid,
|
|
56
|
-
column,
|
|
57
|
-
originRowData,
|
|
58
|
-
}) => {
|
|
59
|
-
const { key, cellClassName, align = 'left' } = column || {}
|
|
60
|
-
let text = ''
|
|
61
|
-
if (!isRenderFixedCell) {
|
|
62
|
-
text = tableCellFormatterResult({column, originRowData, rowIndex, columnIndex, displayText: cell[key]})
|
|
63
|
-
}
|
|
64
|
-
const params = {
|
|
65
|
-
column,
|
|
66
|
-
value: text,
|
|
67
|
-
rowData: originRowData,
|
|
68
|
-
columnIndex: columnIndex,
|
|
69
|
-
rowIndex: rowIndex,
|
|
70
|
-
align: align,
|
|
71
|
-
placeholderSign: isRenderFixedCell, // 渲染空节点
|
|
72
|
-
grid
|
|
73
|
-
}
|
|
74
|
-
return {
|
|
75
|
-
text,
|
|
76
|
-
rowIndex,
|
|
77
|
-
placeholderSign: isRenderFixedCell,
|
|
78
|
-
cellClassName: getClasses(cellClassName, params),
|
|
79
|
-
globalCellClassName: getClasses(grid.cellClassName, params),
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
*
|
|
85
|
-
* #@description 渲染单元格的方法
|
|
86
|
-
* @param {*} {
|
|
87
|
-
* cell,
|
|
88
|
-
* columns,
|
|
89
|
-
* isRenderFixedCells,
|
|
90
|
-
* cellComponentMap,
|
|
91
|
-
* removeCells,
|
|
92
|
-
* rowData,
|
|
93
|
-
* rowKey,
|
|
94
|
-
* gridOffsetX,
|
|
95
|
-
* isHeader,
|
|
96
|
-
* handleEvent,
|
|
97
|
-
* rowIndex,
|
|
98
|
-
* grid,
|
|
99
|
-
* rowContainerDom,
|
|
100
|
-
* }
|
|
101
|
-
* @param {*} i
|
|
102
|
-
* @return {*}
|
|
103
|
-
*/
|
|
104
|
-
const renderCellComponent = (
|
|
105
|
-
{
|
|
106
|
-
cell = {},
|
|
107
|
-
columns,
|
|
108
|
-
isRenderFixedCells,
|
|
109
|
-
cellComponentMap,
|
|
110
|
-
removeCells,
|
|
111
|
-
rowData,
|
|
112
|
-
rowKey,
|
|
113
|
-
gridOffsetX,
|
|
114
|
-
isHeader,
|
|
115
|
-
handleEvent,
|
|
116
|
-
rowIndex,
|
|
117
|
-
grid,
|
|
118
|
-
rowContainerDom,
|
|
119
|
-
originRowData,
|
|
120
|
-
lastCellIndex,
|
|
121
|
-
isParentCol
|
|
122
|
-
},
|
|
123
|
-
i
|
|
124
|
-
) => {
|
|
125
|
-
const cellId = cell[rowKey]
|
|
126
|
-
const column = columns[i]
|
|
127
|
-
const columnIndex = i
|
|
128
|
-
const { width, offsetX, fixed } = column || {}
|
|
129
|
-
let offset
|
|
130
|
-
if (isRenderFixedCells) {
|
|
131
|
-
offset = offsetX
|
|
132
|
-
} else {
|
|
133
|
-
offset = fixed ? offsetX : offsetX - gridOffsetX
|
|
134
|
-
}
|
|
135
|
-
const existingCell = cellComponentMap[cellId]
|
|
136
|
-
// if (existingCell != null) {
|
|
137
|
-
// // 复用的组件,更新偏移值
|
|
138
|
-
// existingCell.setOffset(offset)
|
|
139
|
-
// if (isHeader) {
|
|
140
|
-
// // 更新排序的按钮
|
|
141
|
-
// existingCell.setSortOrder(
|
|
142
|
-
// grid.sortMap.key === column.key && grid.sortMap.order
|
|
143
|
-
// )
|
|
144
|
-
// }
|
|
145
|
-
// return true
|
|
146
|
-
// }
|
|
147
|
-
const commonCellParams = {
|
|
148
|
-
id: cellId,
|
|
149
|
-
offset,
|
|
150
|
-
width,
|
|
151
|
-
column,
|
|
152
|
-
fixed: isRenderFixedCells,
|
|
153
|
-
lastFixedCell: lastCellIndex && isRenderFixedCells,
|
|
154
|
-
isParentCol,
|
|
155
|
-
rowData,
|
|
156
|
-
originRowData,
|
|
157
|
-
handleEvent,
|
|
158
|
-
columnIndex,
|
|
159
|
-
}
|
|
160
|
-
// 如果不是渲染固定列,并且是固定列,则渲染空标签
|
|
161
|
-
const isRenderFixedCell = isRenderFixedCells === false && fixed
|
|
162
|
-
const headerCellParams = createHeaderCellOption({
|
|
163
|
-
isRenderFixedCell,
|
|
164
|
-
column,
|
|
165
|
-
grid,
|
|
166
|
-
columns,
|
|
167
|
-
})
|
|
168
|
-
const rowCellParams = createRowCellOption({
|
|
169
|
-
isRenderFixedCell,
|
|
170
|
-
rowIndex,
|
|
171
|
-
columnIndex,
|
|
172
|
-
grid,
|
|
173
|
-
column,
|
|
174
|
-
cell,
|
|
175
|
-
originRowData,
|
|
176
|
-
})
|
|
177
|
-
// const rowCellParams = {
|
|
178
|
-
// text: isRenderFixedCell ? '' : cell[columnKey],
|
|
179
|
-
// rowIndex,
|
|
180
|
-
// cellClassName: grid.cellClassName,
|
|
181
|
-
// }
|
|
182
|
-
const cellParams = {
|
|
183
|
-
...commonCellParams,
|
|
184
|
-
...(isHeader ? headerCellParams : rowCellParams),
|
|
185
|
-
}
|
|
186
|
-
if (existingCell != null) {
|
|
187
|
-
// 复用的组件,更新偏移值
|
|
188
|
-
existingCell.setOffset(offset)
|
|
189
|
-
existingCell.reuse(cellParams)
|
|
190
|
-
if (isHeader) {
|
|
191
|
-
// 更新排序的按钮
|
|
192
|
-
existingCell.setSortOrder(
|
|
193
|
-
grid.sortMap.key === (column && column.key) && grid.sortMap.order
|
|
194
|
-
)
|
|
195
|
-
}
|
|
196
|
-
return true
|
|
197
|
-
}
|
|
198
|
-
const reuseCell = removeCells.pop()
|
|
199
|
-
if (reuseCell != null) {
|
|
200
|
-
delete cellComponentMap[reuseCell.id]
|
|
201
|
-
reuseCell.reuse && reuseCell.reuse(cellParams)
|
|
202
|
-
cellComponentMap[reuseCell.id] = reuseCell
|
|
203
|
-
return true
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
const params = {
|
|
207
|
-
el: document.createElement('div'),
|
|
208
|
-
}
|
|
209
|
-
let cellComponet = isHeader
|
|
210
|
-
? new HeaderRendererConstructor(params)
|
|
211
|
-
: new CellRendererConstructor(params)
|
|
212
|
-
|
|
213
|
-
// 属性合并
|
|
214
|
-
for (let prop in cellParams) {
|
|
215
|
-
cellComponet[prop] = cellParams[prop]
|
|
216
|
-
}
|
|
217
|
-
// 添加到行内
|
|
218
|
-
rowContainerDom.appendChild(cellComponet.$el)
|
|
219
|
-
cellComponentMap[cellComponet.id] = cellComponet
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
export function removeCellComponents(componentMap, rowContainerDom) {
|
|
223
|
-
for (const removeCellComponet of Object.values(componentMap)) {
|
|
224
|
-
delete componentMap[removeCellComponet.id]
|
|
225
|
-
rowContainerDom.removeChild(removeCellComponet.$el)
|
|
226
|
-
removeCellComponet.$destroy()
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
*
|
|
232
|
-
* @description 计算可视区域单元格渲染逻辑
|
|
233
|
-
* @export
|
|
234
|
-
* @param {*} {
|
|
235
|
-
* columns,
|
|
236
|
-
* startCell,
|
|
237
|
-
* endCell,
|
|
238
|
-
* cells,
|
|
239
|
-
* cellComponentMap,
|
|
240
|
-
* type,
|
|
241
|
-
* rowContainerDom,
|
|
242
|
-
* isRenderFixedCells,
|
|
243
|
-
* gridOffsetX,
|
|
244
|
-
* rowKey,
|
|
245
|
-
* handleEvent,
|
|
246
|
-
* rowData,
|
|
247
|
-
* rowIndex,
|
|
248
|
-
* grid = {},
|
|
249
|
-
* headerParentColcellComponentMap,
|
|
250
|
-
* }
|
|
251
|
-
*/
|
|
252
|
-
export function calculateRenderCells({
|
|
253
|
-
columns,
|
|
254
|
-
startCell,
|
|
255
|
-
endCell,
|
|
256
|
-
cells,
|
|
257
|
-
cellComponentMap,
|
|
258
|
-
type,
|
|
259
|
-
rowContainerDom,
|
|
260
|
-
isRenderFixedCells,
|
|
261
|
-
gridOffsetX,
|
|
262
|
-
rowKey,
|
|
263
|
-
handleEvent,
|
|
264
|
-
rowData,
|
|
265
|
-
rowIndex,
|
|
266
|
-
grid = {},
|
|
267
|
-
headerParentColcellComponentMap,
|
|
268
|
-
originRowData,
|
|
269
|
-
}) {
|
|
270
|
-
// 不存在列不处理
|
|
271
|
-
// if (!columns || !columns.length) {
|
|
272
|
-
// removeCellComponents(cellComponentMap, rowContainerDom)
|
|
273
|
-
// removeCellComponents(headerParentColcellComponentMap, rowContainerDom)
|
|
274
|
-
// return
|
|
275
|
-
// }
|
|
276
|
-
const commonRowParams = {
|
|
277
|
-
rowContainerDom,
|
|
278
|
-
isRenderFixedCells,
|
|
279
|
-
gridOffsetX,
|
|
280
|
-
rowKey,
|
|
281
|
-
handleEvent,
|
|
282
|
-
rowData,
|
|
283
|
-
rowIndex,
|
|
284
|
-
grid,
|
|
285
|
-
originRowData,
|
|
286
|
-
}
|
|
287
|
-
const renderCells = {}
|
|
288
|
-
const renderParentCells = {}
|
|
289
|
-
const parentCols = []
|
|
290
|
-
const isHeader = type === 'header'
|
|
291
|
-
let _parentNodeKeySet = new Set()
|
|
292
|
-
// 存储需要渲染的列集合
|
|
293
|
-
for (let i = startCell; i <= endCell; i++) {
|
|
294
|
-
const cell = cells[i] || {}
|
|
295
|
-
const cellID = cell[rowKey]
|
|
296
|
-
renderCells[cellID] = true
|
|
297
|
-
if (isHeader) {
|
|
298
|
-
const { parentNodeKey } = cell
|
|
299
|
-
if (parentNodeKey) {
|
|
300
|
-
const parentCol = grid.mainColumns.find(
|
|
301
|
-
(col) => col.key === parentNodeKey
|
|
302
|
-
)
|
|
303
|
-
if (parentCol && !_parentNodeKeySet.has(parentNodeKey)) {
|
|
304
|
-
const parentCellId = parentCol[rowKey]
|
|
305
|
-
renderParentCells[parentCellId] = true
|
|
306
|
-
parentCols.push(parentCol)
|
|
307
|
-
_parentNodeKeySet.add(parentNodeKey)
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
const removeCells = []
|
|
314
|
-
for (const id in cellComponentMap) {
|
|
315
|
-
if (id in renderCells) {
|
|
316
|
-
continue
|
|
317
|
-
}
|
|
318
|
-
const cell = cellComponentMap[id]
|
|
319
|
-
removeCells.push(cell)
|
|
320
|
-
}
|
|
321
|
-
for (let i = startCell; i <= endCell; i++) {
|
|
322
|
-
const cell = cells[i]
|
|
323
|
-
const params = {
|
|
324
|
-
cell,
|
|
325
|
-
columns,
|
|
326
|
-
isRenderFixedCells,
|
|
327
|
-
lastCellIndex: endCell === i,
|
|
328
|
-
cellComponentMap,
|
|
329
|
-
removeCells,
|
|
330
|
-
isHeader,
|
|
331
|
-
...commonRowParams,
|
|
332
|
-
}
|
|
333
|
-
const isContinue = renderCellComponent(params, i)
|
|
334
|
-
if (isContinue) {
|
|
335
|
-
continue
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
for (const removeCellComponet of removeCells) {
|
|
339
|
-
delete cellComponentMap[removeCellComponet.id]
|
|
340
|
-
removeCellComponet.$destroy()
|
|
341
|
-
rowContainerDom.removeChild(removeCellComponet.$el)
|
|
342
|
-
}
|
|
343
|
-
if (parentCols.length) {
|
|
344
|
-
calculateHeaderParentColRenderCells({
|
|
345
|
-
parentCols,
|
|
346
|
-
headerParentColcellComponentMap,
|
|
347
|
-
renderParentCells,
|
|
348
|
-
...commonRowParams,
|
|
349
|
-
})
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
/**
|
|
353
|
-
*
|
|
354
|
-
* @description 计算表头父节点单元格渲染逻辑
|
|
355
|
-
* @export
|
|
356
|
-
* @param {*} {
|
|
357
|
-
* parentCols,
|
|
358
|
-
* headerParentColcellComponentMap,
|
|
359
|
-
* renderParentCells,
|
|
360
|
-
* rowContainerDom,
|
|
361
|
-
* isRenderFixedCells,
|
|
362
|
-
* gridOffsetX,
|
|
363
|
-
* rowKey,
|
|
364
|
-
* handleEvent,
|
|
365
|
-
* rowData,
|
|
366
|
-
* rowIndex,
|
|
367
|
-
* grid,
|
|
368
|
-
* }
|
|
369
|
-
*/
|
|
370
|
-
export function calculateHeaderParentColRenderCells({
|
|
371
|
-
parentCols,
|
|
372
|
-
headerParentColcellComponentMap,
|
|
373
|
-
renderParentCells,
|
|
374
|
-
rowContainerDom,
|
|
375
|
-
isRenderFixedCells,
|
|
376
|
-
gridOffsetX,
|
|
377
|
-
rowKey,
|
|
378
|
-
handleEvent,
|
|
379
|
-
rowData,
|
|
380
|
-
rowIndex,
|
|
381
|
-
grid,
|
|
382
|
-
}) {
|
|
383
|
-
// 不存在列不处理
|
|
384
|
-
if (!renderParentCells || !Object.keys(renderParentCells).length) {
|
|
385
|
-
return
|
|
386
|
-
}
|
|
387
|
-
const removeCells = []
|
|
388
|
-
for (const id in headerParentColcellComponentMap) {
|
|
389
|
-
if (id in renderParentCells) {
|
|
390
|
-
continue
|
|
391
|
-
}
|
|
392
|
-
const cell = headerParentColcellComponentMap[id]
|
|
393
|
-
removeCells.push(cell)
|
|
394
|
-
}
|
|
395
|
-
for (let i = 0; i < parentCols.length; i++) {
|
|
396
|
-
const cell = parentCols[i]
|
|
397
|
-
const params = {
|
|
398
|
-
cell,
|
|
399
|
-
columns: parentCols,
|
|
400
|
-
isRenderFixedCells,
|
|
401
|
-
lastCellIndex: i === (parentCols.length - 1),
|
|
402
|
-
cellComponentMap: headerParentColcellComponentMap,
|
|
403
|
-
isParentCol: true,
|
|
404
|
-
removeCells,
|
|
405
|
-
rowData,
|
|
406
|
-
rowKey,
|
|
407
|
-
gridOffsetX,
|
|
408
|
-
isHeader: true,
|
|
409
|
-
handleEvent,
|
|
410
|
-
rowIndex,
|
|
411
|
-
grid,
|
|
412
|
-
rowContainerDom,
|
|
413
|
-
}
|
|
414
|
-
const isContinue = renderCellComponent(params, i)
|
|
415
|
-
if (isContinue) {
|
|
416
|
-
continue
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
for (const removeCellComponet of removeCells) {
|
|
420
|
-
delete headerParentColcellComponentMap[removeCellComponet.id]
|
|
421
|
-
removeCellComponet.$destroy()
|
|
422
|
-
rowContainerDom.removeChild(removeCellComponet.$el)
|
|
423
|
-
}
|
|
424
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
functional: true,
|
|
3
|
-
props: {
|
|
4
|
-
renderFn: {
|
|
5
|
-
type: Function,
|
|
6
|
-
},
|
|
7
|
-
title: {
|
|
8
|
-
type: String,
|
|
9
|
-
default: '',
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
render(h, context) {
|
|
13
|
-
// const style = {
|
|
14
|
-
// opacity: context.props.show ? 1 : 0,
|
|
15
|
-
// }
|
|
16
|
-
const slots = context.slots() || {}
|
|
17
|
-
const children = slots.default || []
|
|
18
|
-
const [slot] = children
|
|
19
|
-
const createNode = () => {
|
|
20
|
-
if (slot) {
|
|
21
|
-
return slot
|
|
22
|
-
}
|
|
23
|
-
return [<div>{context.props.title || ''}</div>]
|
|
24
|
-
}
|
|
25
|
-
let node = createNode()
|
|
26
|
-
return node
|
|
27
|
-
},
|
|
28
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
|
|
3
|
-
import isFunction from 'lodash/isFunction'
|
|
4
|
-
export function getRenderRange(offsetX, containerWidth, columns) {
|
|
5
|
-
let totalWidth = 0
|
|
6
|
-
const accumulatedWidths = []
|
|
7
|
-
|
|
8
|
-
// 计算总宽度和每个位置的累加宽度
|
|
9
|
-
for (let i = 0; i < columns.length; i++) {
|
|
10
|
-
const width = columns[i]
|
|
11
|
-
totalWidth += width
|
|
12
|
-
accumulatedWidths.push(totalWidth)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// 处理 offsetX 小于 0 的边界情况
|
|
16
|
-
if (offsetX < 0) {
|
|
17
|
-
offsetX = 0
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// 处理 offsetX 超过总宽度的边界情况
|
|
21
|
-
if (offsetX >= totalWidth - containerWidth) {
|
|
22
|
-
offsetX = Math.max(0, totalWidth - containerWidth)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// 使用二分法查找起始索引
|
|
26
|
-
let startIndex = binarySearch(accumulatedWidths, offsetX)
|
|
27
|
-
|
|
28
|
-
// 计算起始位置的剩余偏移量
|
|
29
|
-
let startOffset =
|
|
30
|
-
offsetX - (startIndex > 0 ? accumulatedWidths[startIndex - 1] : 0)
|
|
31
|
-
let remainingWidth = containerWidth + startOffset
|
|
32
|
-
|
|
33
|
-
// 找到结束索引
|
|
34
|
-
let endIndex = startIndex
|
|
35
|
-
for (let i = startIndex; i < columns.length; i++) {
|
|
36
|
-
const width = columns[i]
|
|
37
|
-
if (remainingWidth - width <= 0) {
|
|
38
|
-
endIndex = i
|
|
39
|
-
break
|
|
40
|
-
}
|
|
41
|
-
remainingWidth -= width
|
|
42
|
-
if (i === columns.length - 1) {
|
|
43
|
-
endIndex = i
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return { startIndex, endIndex }
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function binarySearch(arr, target) {
|
|
51
|
-
let left = 0
|
|
52
|
-
let right = arr.length - 1
|
|
53
|
-
let result = arr.length
|
|
54
|
-
|
|
55
|
-
while (left <= right) {
|
|
56
|
-
const mid = Math.floor((left + right) / 2)
|
|
57
|
-
if (arr[mid] > target) {
|
|
58
|
-
result = mid
|
|
59
|
-
right = mid - 1
|
|
60
|
-
} else {
|
|
61
|
-
left = mid + 1
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return result
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function getClasses(cellClassName, params) {
|
|
69
|
-
const { align, grid, ...restParams } = params
|
|
70
|
-
let classNames = [align, params.column && params.column.collapseBg, grid.overflow && 'overflow'].filter(Boolean)
|
|
71
|
-
if (cellClassName) {
|
|
72
|
-
if (isFunction(cellClassName)) {
|
|
73
|
-
const classes = cellClassName(restParams)
|
|
74
|
-
if (Array.isArray(classes)) {
|
|
75
|
-
classNames = [...classNames, ...classes]
|
|
76
|
-
} else {
|
|
77
|
-
classNames = [...classNames, classes]
|
|
78
|
-
}
|
|
79
|
-
} else {
|
|
80
|
-
classNames = [...classNames, cellClassName]
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return classNames
|
|
84
|
-
}
|