cloud-web-corejs 1.0.54-dev.661 → 1.0.54-dev.662
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/package.json +1 -1
- package/src/components/xform/form-designer/form-widget/container-widget/data-table-widget.vue +10 -0
- package/src/components/xform/form-designer/setting-panel/property-editor/container-data-table/table-column-dialog.vue +201 -33
- package/src/components/xform/form-render/container-item/data-table-mixin.js +2 -11
- package/src/components/xform/form-render/indexMixin.js +226 -224
- package/src/components/xform/utils/tableColumnHelper.js +112 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
function buildColumnConfigMap(tableColumns, map = {}) {
|
|
2
|
+
if (!tableColumns || !tableColumns.length) {
|
|
3
|
+
return map;
|
|
4
|
+
}
|
|
5
|
+
tableColumns.forEach((col) => {
|
|
6
|
+
if (col.prop) {
|
|
7
|
+
map[col.prop] = col;
|
|
8
|
+
}
|
|
9
|
+
if (col.columnId) {
|
|
10
|
+
map[`__id__${col.columnId}`] = col;
|
|
11
|
+
}
|
|
12
|
+
if (col.children && col.children.length) {
|
|
13
|
+
buildColumnConfigMap(col.children, map);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
return map;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function enrichColumnList(columns, configMap) {
|
|
20
|
+
if (!columns || !columns.length) {
|
|
21
|
+
return columns;
|
|
22
|
+
}
|
|
23
|
+
return columns.map((col) => {
|
|
24
|
+
const newCol = Object.assign({}, col);
|
|
25
|
+
if (col.slots) {
|
|
26
|
+
newCol.slots = Object.assign({}, col.slots);
|
|
27
|
+
}
|
|
28
|
+
const field = col.field;
|
|
29
|
+
const columnId = col.params && col.params.columnId;
|
|
30
|
+
const config =
|
|
31
|
+
(field && configMap[field]) ||
|
|
32
|
+
(columnId && configMap[`__id__${columnId}`]);
|
|
33
|
+
if (config) {
|
|
34
|
+
applyColumnLabelIcon(newCol, config);
|
|
35
|
+
}
|
|
36
|
+
if (col.children && col.children.length) {
|
|
37
|
+
newCol.children = enrichColumnList(col.children, configMap);
|
|
38
|
+
}
|
|
39
|
+
return newCol;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Apply data-table column header icon config to vxe-table column definition.
|
|
45
|
+
*/
|
|
46
|
+
export function applyColumnLabelIcon(col, columnConfig) {
|
|
47
|
+
if (!col || !columnConfig) {
|
|
48
|
+
return col;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const iconClass = columnConfig.labelIconClass;
|
|
52
|
+
const position = columnConfig.labelIconPosition || "front";
|
|
53
|
+
const tooltip = columnConfig.labelTooltip;
|
|
54
|
+
const required = !!columnConfig.required;
|
|
55
|
+
const title = col.title;
|
|
56
|
+
|
|
57
|
+
if (!iconClass && !required) {
|
|
58
|
+
return col;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const buildIcon = (h) => {
|
|
62
|
+
const icon = h("i", { class: ["vxe-cell-help-icon", iconClass] });
|
|
63
|
+
if (!tooltip) {
|
|
64
|
+
return icon;
|
|
65
|
+
}
|
|
66
|
+
return h(
|
|
67
|
+
"el-tooltip",
|
|
68
|
+
{
|
|
69
|
+
props: { content: tooltip, effect: "dark", placement: "top" },
|
|
70
|
+
},
|
|
71
|
+
[icon]
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
if (iconClass && position === "front" && !required) {
|
|
76
|
+
col.titlePrefix = {
|
|
77
|
+
icon: iconClass,
|
|
78
|
+
...(tooltip ? { content: tooltip } : {}),
|
|
79
|
+
};
|
|
80
|
+
return col;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (required && !iconClass) {
|
|
84
|
+
col.titlePrefix = { icon: "vxe-cell--required-icon" };
|
|
85
|
+
return col;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
col.slots = col.slots || {};
|
|
89
|
+
delete col.titlePrefix;
|
|
90
|
+
|
|
91
|
+
col.slots.header = (params, h) => {
|
|
92
|
+
const nodes = [];
|
|
93
|
+
if (required) {
|
|
94
|
+
nodes.push(h("i", { class: "vxe-cell--required-icon" }));
|
|
95
|
+
}
|
|
96
|
+
if (iconClass && position === "front") {
|
|
97
|
+
nodes.push(buildIcon(h));
|
|
98
|
+
}
|
|
99
|
+
nodes.push(h("span", { class: "vxe-cell--title" }, title));
|
|
100
|
+
if (iconClass && position === "rear") {
|
|
101
|
+
nodes.push(buildIcon(h));
|
|
102
|
+
}
|
|
103
|
+
return nodes;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
return col;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function enrichTableColumnsWithLabelIcon(columns, tableColumns) {
|
|
110
|
+
const configMap = buildColumnConfigMap(tableColumns || []);
|
|
111
|
+
return enrichColumnList(columns, configMap);
|
|
112
|
+
}
|