foggy-data-viewer 1.0.1-beta.0
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/README.md +273 -0
- package/dist/favicon.svg +4 -0
- package/dist/index.js +1531 -0
- package/dist/index.umd +1 -0
- package/dist/style.css +1 -0
- package/package.json +51 -0
- package/src/App.vue +469 -0
- package/src/api/viewer.ts +163 -0
- package/src/components/DataTable.test.ts +533 -0
- package/src/components/DataTable.vue +810 -0
- package/src/components/DataTableWithSearch.test.ts +628 -0
- package/src/components/DataTableWithSearch.vue +277 -0
- package/src/components/DataViewer.vue +310 -0
- package/src/components/SearchToolbar.test.ts +521 -0
- package/src/components/SearchToolbar.vue +406 -0
- package/src/components/composables/index.ts +2 -0
- package/src/components/composables/useTableSelection.test.ts +248 -0
- package/src/components/composables/useTableSelection.ts +44 -0
- package/src/components/composables/useTableSummary.test.ts +341 -0
- package/src/components/composables/useTableSummary.ts +129 -0
- package/src/components/filters/BoolFilter.vue +103 -0
- package/src/components/filters/DateRangeFilter.vue +194 -0
- package/src/components/filters/NumberRangeFilter.vue +160 -0
- package/src/components/filters/SelectFilter.vue +464 -0
- package/src/components/filters/TextFilter.vue +230 -0
- package/src/components/filters/index.ts +5 -0
- package/src/examples/EnhancedTableExample.vue +136 -0
- package/src/index.ts +32 -0
- package/src/main.ts +14 -0
- package/src/types/index.ts +159 -0
- package/src/utils/README.md +140 -0
- package/src/utils/schemaHelper.test.ts +215 -0
- package/src/utils/schemaHelper.ts +44 -0
- package/src/vite-env.d.ts +7 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ColumnSchema, EnhancedColumnSchema, TableConfig } from '@/types'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 构建表格列配置
|
|
5
|
+
*
|
|
6
|
+
* @param qmSchema - 从后台获取的 QM schema
|
|
7
|
+
* @param config - 表格配置(如果 visibleColumns 为空或未指定,默认显示所有列)
|
|
8
|
+
* @returns 增强的列配置数组
|
|
9
|
+
*/
|
|
10
|
+
export function buildTableColumns(
|
|
11
|
+
qmSchema: ColumnSchema[],
|
|
12
|
+
config: TableConfig
|
|
13
|
+
): EnhancedColumnSchema[] {
|
|
14
|
+
const schemaMap = new Map(qmSchema.map(s => [s.name, s]))
|
|
15
|
+
const customMap = new Map(config.customizations?.map(c => [c.name, c]) || [])
|
|
16
|
+
|
|
17
|
+
// 确定要显示的列及顺序
|
|
18
|
+
// 如果 visibleColumns 为空数组或未定义,且 showAll 未设置,则默认显示所有列
|
|
19
|
+
const shouldShowAll = config.showAll || !config.visibleColumns || config.visibleColumns.length === 0
|
|
20
|
+
const columnNames = shouldShowAll
|
|
21
|
+
? qmSchema.map(s => s.name)
|
|
22
|
+
: config.visibleColumns
|
|
23
|
+
|
|
24
|
+
return columnNames
|
|
25
|
+
.map(name => {
|
|
26
|
+
const schema = schemaMap.get(name)
|
|
27
|
+
if (!schema) {
|
|
28
|
+
console.warn(`Column "${name}" not found in QM schema`)
|
|
29
|
+
return null
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const custom = customMap.get(name)
|
|
33
|
+
return {
|
|
34
|
+
...schema,
|
|
35
|
+
width: custom?.width,
|
|
36
|
+
minWidth: custom?.minWidth ?? 120,
|
|
37
|
+
fixed: custom?.fixed,
|
|
38
|
+
customRender: custom?.render,
|
|
39
|
+
customFilterComponent: custom?.filterComponent,
|
|
40
|
+
customFormatter: custom?.formatter
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
.filter((col): col is EnhancedColumnSchema => col !== null)
|
|
44
|
+
}
|