super-page-runtime 2.1.48 → 2.1.50
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/dist/es/components/runtime/utils/api/api-util.d.ts +1 -18
- package/dist/es/components/runtime/utils/api/api-util.js +2 -306
- package/dist/es/components/runtime/utils/api/page-expose-util.js +8 -1
- package/dist/es/components/runtime/utils/charts/chart-columnline-util.js +1 -0
- package/dist/es/components/runtime/utils/events/standard-event.d.ts +11 -1
- package/dist/es/components/runtime/utils/events/standard-event.js +334 -36
- package/dist/es/components/runtime/utils/page-helper-util.d.ts +3 -1
- package/dist/es/components/runtime/utils/page-helper-util.js +21 -2
- package/dist/es/components/runtime/views/assemblys/chart/table/chart-table-util.js +480 -0
- package/dist/es/components/runtime/views/assemblys/chart/table/group-column-item.vue.js +44 -0
- package/dist/es/components/runtime/views/assemblys/chart/table/group-column-item.vue2.js +4 -0
- package/dist/es/components/runtime/views/assemblys/chart/table/group-column.vue.js +64 -0
- package/dist/es/components/runtime/views/assemblys/chart/table/group-column.vue2.js +4 -0
- package/dist/es/components/runtime/views/assemblys/chart/table/normal-column.vue.js +242 -0
- package/dist/es/components/runtime/views/assemblys/chart/table/normal-column.vue2.js +4 -0
- package/dist/es/components/runtime/views/assemblys/chart/table/table-runtime.vue2.js +301 -34
- package/dist/es/components/runtime/views/assemblys/data/table/main-table-runtime.vue.js +46 -14
- package/dist/es/components/runtime/views/assemblys/data/table/sub-table-runtime.vue.js +28 -4
- package/dist/es/components/runtime/views/assemblys/form/input-text/inputtext-runtime.vue2.js +3 -1
- package/dist/es/components/runtime/views/super-page-dialog.vue.d.ts +4 -0
- package/dist/es/components/runtime/views/super-page-dialog.vue.js +5 -1
- package/dist/es/components/runtime/views/super-page.vue.js +3 -2
- package/package.json +2 -2
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { defineComponent, ref, resolveComponent, openBlock, createBlock, withCtx, createElementBlock, Fragment, createTextVNode, toDisplayString, resolveDynamicComponent, createVNode, normalizeClass, createCommentVNode, createElementVNode } from "vue";
|
|
2
|
+
import { getCustomFunc } from "../../../../utils/events/event-util.js";
|
|
3
|
+
import eventBus from "../../../../utils/eventBus.js";
|
|
4
|
+
import { ExpressionEvaluator } from "./chart-table-util.js";
|
|
5
|
+
const _hoisted_1 = { key: 0 };
|
|
6
|
+
const _hoisted_2 = { key: 1 };
|
|
7
|
+
const _hoisted_3 = { key: 3 };
|
|
8
|
+
const _hoisted_4 = { key: 2 };
|
|
9
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
10
|
+
__name: "normal-column",
|
|
11
|
+
props: {
|
|
12
|
+
configure: {
|
|
13
|
+
type: Object,
|
|
14
|
+
default: () => {
|
|
15
|
+
return {};
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
pageContext: {
|
|
19
|
+
type: Object,
|
|
20
|
+
default: () => {
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
column: {
|
|
25
|
+
type: Object,
|
|
26
|
+
default: () => {
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
setup(__props) {
|
|
32
|
+
const props = __props;
|
|
33
|
+
const resloveLinkText = ref(false);
|
|
34
|
+
let toPage = null;
|
|
35
|
+
if (props.column.linkPage && props.column.linkPage.length > 0) {
|
|
36
|
+
resloveLinkText.value = true;
|
|
37
|
+
}
|
|
38
|
+
function showLink(row) {
|
|
39
|
+
var _a;
|
|
40
|
+
const show = (_a = props.column.linkPage) == null ? void 0 : _a.some((item) => {
|
|
41
|
+
let canShow = false;
|
|
42
|
+
if (item.scopeFunc) {
|
|
43
|
+
const func = getCustomFunc(props.pageContext, item.scopeFunc);
|
|
44
|
+
if (func) {
|
|
45
|
+
const result = func.apply(func, [
|
|
46
|
+
{
|
|
47
|
+
pageContext: props.pageContext,
|
|
48
|
+
configureObj: props.configure,
|
|
49
|
+
row
|
|
50
|
+
}
|
|
51
|
+
]);
|
|
52
|
+
if (result) {
|
|
53
|
+
canShow = true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
} else if (item.showCondition && item.showCondition.length > 0) {
|
|
57
|
+
const result = ExpressionEvaluator.evaluate(props.pageContext, item.showCondition, row);
|
|
58
|
+
if (result) {
|
|
59
|
+
canShow = true;
|
|
60
|
+
}
|
|
61
|
+
} else {
|
|
62
|
+
canShow = true;
|
|
63
|
+
}
|
|
64
|
+
if (canShow) {
|
|
65
|
+
toPage = item;
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
return show;
|
|
70
|
+
}
|
|
71
|
+
function clickLink(row) {
|
|
72
|
+
if (toPage) {
|
|
73
|
+
const myPageCode = props.pageContext.code;
|
|
74
|
+
const eventPageInfo = myPageCode + "_";
|
|
75
|
+
const linkPage = JSON.parse(JSON.stringify(toPage));
|
|
76
|
+
linkPage.base = {
|
|
77
|
+
successOperation: "closeWindow"
|
|
78
|
+
};
|
|
79
|
+
const eventParams = {
|
|
80
|
+
id: row.id ? row["id"] : row["ID"],
|
|
81
|
+
selections: [row]
|
|
82
|
+
};
|
|
83
|
+
eventBus.$emit(eventPageInfo + "open-dialog", {
|
|
84
|
+
pageContext: props.pageContext,
|
|
85
|
+
configureObj: { props: linkPage },
|
|
86
|
+
eventParams
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function formatContent(row, format) {
|
|
91
|
+
const value = row[props.column.props.base.prop];
|
|
92
|
+
switch (format.type) {
|
|
93
|
+
case "number":
|
|
94
|
+
return formatNumber(value, format);
|
|
95
|
+
case "currency":
|
|
96
|
+
return formatCurrency(value, format);
|
|
97
|
+
case "percent":
|
|
98
|
+
return formatPercent(value, format);
|
|
99
|
+
case "custom":
|
|
100
|
+
return formatCustomFunc(row, format);
|
|
101
|
+
default:
|
|
102
|
+
return value;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function formatNumber(value, format) {
|
|
106
|
+
let formattedValue = value;
|
|
107
|
+
if (!formattedValue) {
|
|
108
|
+
formattedValue = 0;
|
|
109
|
+
}
|
|
110
|
+
if (format.scientific) {
|
|
111
|
+
formattedValue = Number(value).toExponential(format.scientificNum);
|
|
112
|
+
}
|
|
113
|
+
if (format.decimalDigit) {
|
|
114
|
+
formattedValue = Number(value).toFixed(format.decimalDigit);
|
|
115
|
+
}
|
|
116
|
+
if (format.thousandsSeparator) {
|
|
117
|
+
formattedValue = formattedValue.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
118
|
+
}
|
|
119
|
+
if (format.symbol) {
|
|
120
|
+
formattedValue = `${format.symbol} ${formattedValue}`;
|
|
121
|
+
}
|
|
122
|
+
return formattedValue;
|
|
123
|
+
}
|
|
124
|
+
function formatCurrency(value, format) {
|
|
125
|
+
let formattedValue = value;
|
|
126
|
+
if (!formattedValue) {
|
|
127
|
+
formattedValue = 0;
|
|
128
|
+
}
|
|
129
|
+
if (format.decimalDigit) {
|
|
130
|
+
formattedValue = Number(value).toFixed(format.decimalDigit);
|
|
131
|
+
}
|
|
132
|
+
if (format.symbol) {
|
|
133
|
+
formattedValue = `${format.symbol} ${formattedValue}`;
|
|
134
|
+
}
|
|
135
|
+
return formattedValue;
|
|
136
|
+
}
|
|
137
|
+
function formatPercent(value, format) {
|
|
138
|
+
let formattedValue = value;
|
|
139
|
+
if (!formattedValue) {
|
|
140
|
+
formattedValue = 0;
|
|
141
|
+
}
|
|
142
|
+
if (format.decimalDigit) {
|
|
143
|
+
formattedValue = Number(value).toFixed(format.decimalDigit);
|
|
144
|
+
}
|
|
145
|
+
return formattedValue + " %";
|
|
146
|
+
}
|
|
147
|
+
function formatCustomFunc(row, format) {
|
|
148
|
+
const func = getCustomFunc(props.pageContext, format.customFunc);
|
|
149
|
+
if (func) {
|
|
150
|
+
const resultValue = func.apply(func, [
|
|
151
|
+
{
|
|
152
|
+
pageContext: props.pageContext,
|
|
153
|
+
configureObj: props.configure,
|
|
154
|
+
row,
|
|
155
|
+
prop: props.column.props.base.prop
|
|
156
|
+
}
|
|
157
|
+
]);
|
|
158
|
+
return resultValue;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return (_ctx, _cache) => {
|
|
162
|
+
const _component_el_table_column = resolveComponent("el-table-column");
|
|
163
|
+
const _component_el_progress = resolveComponent("el-progress");
|
|
164
|
+
const _component_el_tag = resolveComponent("el-tag");
|
|
165
|
+
const _component_el_link = resolveComponent("el-link");
|
|
166
|
+
return __props.column.props.base.prop === "$index" ? (openBlock(), createBlock(_component_el_table_column, {
|
|
167
|
+
key: 0,
|
|
168
|
+
label: __props.column.props.base.name,
|
|
169
|
+
type: "index",
|
|
170
|
+
align: "center",
|
|
171
|
+
"header-align": "center",
|
|
172
|
+
width: "80"
|
|
173
|
+
}, null, 8, ["label"])) : (openBlock(), createBlock(_component_el_table_column, {
|
|
174
|
+
key: 1,
|
|
175
|
+
prop: __props.column.props.base.prop,
|
|
176
|
+
width: __props.column.props.base.width ? __props.column.props.base.width : "",
|
|
177
|
+
label: __props.column.props.base.name,
|
|
178
|
+
"header-align": __props.column.props.base.headerAlign,
|
|
179
|
+
align: __props.column.props.base.align,
|
|
180
|
+
fixed: __props.column.props.base.fixed ? __props.column.props.base.fixed : false
|
|
181
|
+
}, {
|
|
182
|
+
default: withCtx((scope) => [
|
|
183
|
+
__props.column.props.format && __props.column.props.format.type ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
184
|
+
createTextVNode(toDisplayString(__props.column.props.format.status) + " ", 1),
|
|
185
|
+
__props.column.props.format.type === "customControl" ? (openBlock(), createBlock(resolveDynamicComponent(__props.column.props.format.customControl), {
|
|
186
|
+
key: 0,
|
|
187
|
+
scope,
|
|
188
|
+
column: __props.column,
|
|
189
|
+
configure: __props.configure,
|
|
190
|
+
pageContext: __props.pageContext
|
|
191
|
+
}, null, 8, ["scope", "column", "configure", "pageContext"])) : __props.column.props.format.type === "progress" ? (openBlock(), createBlock(_component_el_progress, {
|
|
192
|
+
key: 1,
|
|
193
|
+
type: __props.column.props.format.progressType,
|
|
194
|
+
percentage: scope.row[__props.column.props.base.prop],
|
|
195
|
+
status: __props.column.props.format.status,
|
|
196
|
+
"text-inside": __props.column.props.format.showText,
|
|
197
|
+
"stroke-width": __props.column.props.format.strokeWidth,
|
|
198
|
+
color: __props.column.props.format.colorType === "custom" ? __props.column.props.format.color : ""
|
|
199
|
+
}, null, 8, ["type", "percentage", "status", "text-inside", "stroke-width", "color"])) : __props.column.props.format.type === "icon" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
|
|
200
|
+
__props.column.props.format.isTag ? (openBlock(), createElementBlock("span", _hoisted_1, [
|
|
201
|
+
createVNode(_component_el_tag, {
|
|
202
|
+
type: __props.column.props.format.tagType,
|
|
203
|
+
effect: __props.column.props.format.tagEffect,
|
|
204
|
+
hit: __props.column.props.format.hit,
|
|
205
|
+
size: __props.column.props.format.size
|
|
206
|
+
}, {
|
|
207
|
+
default: withCtx(() => [
|
|
208
|
+
createTextVNode(toDisplayString(scope.row[__props.column.props.base.prop]), 1)
|
|
209
|
+
]),
|
|
210
|
+
_: 2
|
|
211
|
+
}, 1032, ["type", "effect", "hit", "size"])
|
|
212
|
+
])) : (openBlock(), createElementBlock("span", _hoisted_2, [
|
|
213
|
+
__props.column.props.format.position === "pre" ? (openBlock(), createElementBlock("i", {
|
|
214
|
+
key: 0,
|
|
215
|
+
class: normalizeClass(__props.column.props.format.icon)
|
|
216
|
+
}, null, 2)) : createCommentVNode("", true),
|
|
217
|
+
createElementVNode("span", null, toDisplayString(scope.row[__props.column.props.base.prop]), 1),
|
|
218
|
+
__props.column.props.format.position === "suf" ? (openBlock(), createElementBlock("i", {
|
|
219
|
+
key: 1,
|
|
220
|
+
class: normalizeClass(__props.column.props.format.icon)
|
|
221
|
+
}, null, 2)) : createCommentVNode("", true)
|
|
222
|
+
]))
|
|
223
|
+
], 64)) : (openBlock(), createElementBlock("span", _hoisted_3, toDisplayString(formatContent(scope.row, __props.column.props.format)), 1))
|
|
224
|
+
], 64)) : resloveLinkText.value && showLink(scope.row) ? (openBlock(), createBlock(_component_el_link, {
|
|
225
|
+
key: 1,
|
|
226
|
+
type: "primary",
|
|
227
|
+
onClick: ($event) => clickLink(scope.row)
|
|
228
|
+
}, {
|
|
229
|
+
default: withCtx(() => [
|
|
230
|
+
createTextVNode(toDisplayString(scope.row[__props.column.props.base.prop]), 1)
|
|
231
|
+
]),
|
|
232
|
+
_: 2
|
|
233
|
+
}, 1032, ["onClick"])) : (openBlock(), createElementBlock("span", _hoisted_4, toDisplayString(scope.row[__props.column.props.base.prop]), 1))
|
|
234
|
+
]),
|
|
235
|
+
_: 1
|
|
236
|
+
}, 8, ["prop", "width", "label", "header-align", "align", "fixed"]));
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
export {
|
|
241
|
+
_sfc_main as default
|
|
242
|
+
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { defineComponent, ref, onMounted, resolveComponent, openBlock, createElementBlock, normalizeStyle, unref, normalizeClass, withDirectives, createVNode, vShow, withCtx, Fragment, renderList, createBlock } from "vue";
|
|
1
|
+
import { defineComponent, ref, onMounted, resolveComponent, openBlock, createElementBlock, normalizeStyle, unref, normalizeClass, withDirectives, createVNode, vShow, withCtx, Fragment, renderList, createBlock, watch, h } from "vue";
|
|
2
2
|
import _sfc_main$1 from "../common/common-chart-header.vue.js";
|
|
3
|
-
import { getChartDatasFromPage } from "../../../../utils/page-helper-util.js";
|
|
3
|
+
import { getChartDatasFromPage, isPromise, getValueFromVariable } from "../../../../utils/page-helper-util.js";
|
|
4
4
|
import { getCustomFunc } from "../../../../utils/events/event-util.js";
|
|
5
|
+
import _sfc_main$2 from "./group-column.vue.js";
|
|
6
|
+
import _sfc_main$3 from "./normal-column.vue.js";
|
|
7
|
+
import { getSummaryTitleColumn, getSummaryDataColumn, rowDataToColumn, getColumnToRowTableConfig, colDataToRow, summaryStatistics, replacePlaceholders, getHeaderCellStyleUtil, getRowStyleUtil, getCellStyleUtil, getIndexColumn } from "./chart-table-util.js";
|
|
5
8
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
6
9
|
__name: "table-runtime",
|
|
7
10
|
props: {
|
|
@@ -19,21 +22,47 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
19
22
|
}
|
|
20
23
|
},
|
|
21
24
|
setup(__props, { expose: __expose }) {
|
|
25
|
+
var _a;
|
|
22
26
|
const props = __props;
|
|
23
27
|
const runtimeInfo = props.configure.runtime ? props.configure.runtime : {};
|
|
24
|
-
debugger;
|
|
25
28
|
const runtimeStyle = runtimeInfo.style;
|
|
26
29
|
const runtimeClass = runtimeInfo.class;
|
|
27
30
|
const dataConfig = runtimeInfo.dataConfig;
|
|
28
31
|
const headerInfo = runtimeInfo.headerInfo ? runtimeInfo.headerInfo : {};
|
|
29
32
|
const headerRef = ref(null);
|
|
33
|
+
const isEnableGroupHeader = ref(runtimeInfo.props.isEnableGroupHeader);
|
|
30
34
|
const tableData = ref([]);
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
const tableColumnsConfig = ref([]);
|
|
36
|
+
const groupColumnsConfig = ref([]);
|
|
37
|
+
const columnsConfigKeyValues = ref({});
|
|
38
|
+
const showSummary = ref(false);
|
|
39
|
+
const tableSummaryTitle = ref({});
|
|
40
|
+
const tableSummaryColumns = ref({});
|
|
41
|
+
const groupSummaryColumns = ref({});
|
|
42
|
+
const groupSummaryDataRowIndex = [];
|
|
43
|
+
const columnStyleSourceConfig = ref({});
|
|
44
|
+
if (!props.configure.props.modelCustom) {
|
|
45
|
+
if (!isEnableGroupHeader.value) {
|
|
46
|
+
tableColumnsConfig.value = props.configure.items;
|
|
47
|
+
} else {
|
|
48
|
+
groupColumnsConfig.value = props.configure.props.groupHeaders;
|
|
49
|
+
}
|
|
50
|
+
(_a = props.configure.items) == null ? void 0 : _a.forEach((item) => {
|
|
51
|
+
columnsConfigKeyValues.value[item.uuid] = item;
|
|
52
|
+
if (Object.keys(item.style).length > 0) {
|
|
53
|
+
columnStyleSourceConfig.value[item.props.base.prop] = { cellStyle: item.style, titleStyle: item.titleStyle };
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
showSummary.value = props.configure.props.base.showSummary;
|
|
58
|
+
if (showSummary.value || props.configure.props.highOrder.groupField && props.configure.props.highOrder.groupField.length > 0) {
|
|
59
|
+
tableSummaryTitle.value = getSummaryTitleColumn(props.configure);
|
|
60
|
+
if (showSummary.value) {
|
|
61
|
+
tableSummaryColumns.value = getSummaryDataColumn(props.configure, "table");
|
|
62
|
+
}
|
|
63
|
+
if (props.configure.props.highOrder.groupField && props.configure.props.highOrder.groupField.length > 0) {
|
|
64
|
+
groupSummaryColumns.value = getSummaryDataColumn(props.configure, "group");
|
|
65
|
+
}
|
|
37
66
|
}
|
|
38
67
|
onMounted(() => {
|
|
39
68
|
const resultData = getChartDatasFromPage(props.pageContext, props.configure);
|
|
@@ -41,6 +70,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
41
70
|
updateChartDatas(resultData);
|
|
42
71
|
}
|
|
43
72
|
});
|
|
73
|
+
function watchVariableDataChange() {
|
|
74
|
+
const match = props.configure.props.dataOrigin.variable.match(/\${(.*?)}/);
|
|
75
|
+
const path = match ? match[1].split(".") : [];
|
|
76
|
+
watch(
|
|
77
|
+
() => path.reduce((obj, key) => obj[key], props.pageContext.entity),
|
|
78
|
+
(newVal) => {
|
|
79
|
+
loadTable(JSON.parse(JSON.stringify(newVal)));
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
}
|
|
44
83
|
function updateChartDatas(resultData) {
|
|
45
84
|
if (!resultData) {
|
|
46
85
|
resultData = [];
|
|
@@ -54,25 +93,246 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
54
93
|
console.log("重复更新!", resultData);
|
|
55
94
|
return;
|
|
56
95
|
}
|
|
57
|
-
|
|
96
|
+
updateTable(resultData);
|
|
97
|
+
resultData.hasRender = true;
|
|
98
|
+
dataConfig.autoRefresh = false;
|
|
99
|
+
}
|
|
100
|
+
function updateTable(resultData) {
|
|
101
|
+
if (props.configure.props.modelCustom) {
|
|
58
102
|
const func = getCustomFunc(props.pageContext, props.configure.props.modelCustom);
|
|
59
103
|
if (func) {
|
|
60
|
-
func.apply(func, [
|
|
104
|
+
const resultValue = func.apply(func, [
|
|
61
105
|
{
|
|
62
106
|
pageContext: props.pageContext,
|
|
63
107
|
configureObj: props.configure,
|
|
64
108
|
value: resultData
|
|
65
109
|
}
|
|
66
110
|
]);
|
|
111
|
+
if (isPromise(resultValue)) {
|
|
112
|
+
resultValue.then((res) => {
|
|
113
|
+
tableColumnsConfig.value = res.columns;
|
|
114
|
+
});
|
|
115
|
+
} else {
|
|
116
|
+
tableColumnsConfig.value = resultValue.columns;
|
|
117
|
+
}
|
|
67
118
|
}
|
|
68
119
|
}
|
|
69
|
-
|
|
70
|
-
|
|
120
|
+
let tmpTableData = [];
|
|
121
|
+
if (props.configure.props.dataOrigin.dataSource === "service" && resultData.result) {
|
|
122
|
+
tmpTableData = resultData.result[props.configure.props.dataOrigin.service.serviceDataField];
|
|
123
|
+
} else if (props.configure.props.dataOrigin.dataSource === "variable") {
|
|
124
|
+
watchVariableDataChange();
|
|
125
|
+
tmpTableData = getValueFromVariable(
|
|
126
|
+
props.pageContext.entity,
|
|
127
|
+
props.configure.props.dataOrigin.variable
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
if (tmpTableData) {
|
|
131
|
+
loadTable(tmpTableData);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function loadTable(tmpTableData) {
|
|
135
|
+
if (enableTransition("rowToColumn")) {
|
|
136
|
+
tmpTableData = rowDataToColumn(tmpTableData, props.configure);
|
|
137
|
+
if (!isEnableGroupHeader.value) {
|
|
138
|
+
const updatedColumnConfig = updateColumnConfig(
|
|
139
|
+
tableColumnsConfig.value,
|
|
140
|
+
tmpTableData,
|
|
141
|
+
props.configure.props.dataOrigin.rowToColumn.titleColumns,
|
|
142
|
+
props.configure.props.dataOrigin.rowToColumn.dataColumns
|
|
143
|
+
);
|
|
144
|
+
tableColumnsConfig.value = updatedColumnConfig;
|
|
145
|
+
}
|
|
146
|
+
} else if (enableTransition("columnToRow")) {
|
|
147
|
+
if (!isEnableGroupHeader.value) {
|
|
148
|
+
tableColumnsConfig.value = getColumnToRowTableConfig(props.configure);
|
|
149
|
+
}
|
|
150
|
+
tmpTableData = colDataToRow(tmpTableData, props.configure);
|
|
151
|
+
}
|
|
152
|
+
if (props.configure.props.dataOrigin.dataFormatting) {
|
|
153
|
+
const func = getCustomFunc(props.pageContext, props.configure.props.dataOrigin.dataFormatting);
|
|
154
|
+
if (func) {
|
|
155
|
+
const resultValue = func.apply(func, [{ tableData: tmpTableData }]);
|
|
156
|
+
if (resultValue) {
|
|
157
|
+
tableData.value = resultValue;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
71
160
|
} else {
|
|
72
|
-
tableData.value =
|
|
161
|
+
tableData.value = tmpTableData;
|
|
162
|
+
}
|
|
163
|
+
if (props.configure.props.highOrder.groupField && props.configure.props.highOrder.groupField.length > 0) {
|
|
164
|
+
const groupField = props.configure.props.highOrder.groupField;
|
|
165
|
+
tableData.value = groupAndAddTotals(tableData.value, groupField);
|
|
166
|
+
}
|
|
167
|
+
pushTableIndexColumn(tableColumnsConfig.value);
|
|
168
|
+
}
|
|
169
|
+
function enableTransition(type) {
|
|
170
|
+
return props.configure.props.dataOrigin.transition === type && props.configure.props.dataOrigin.groupField && props.configure.props.dataOrigin.groupField.length > 0 && props.configure.props.dataOrigin[type].titleColumns && props.configure.props.dataOrigin[type].titleColumns.length > 0 && props.configure.props.dataOrigin[type].dataColumns && props.configure.props.dataOrigin[type].dataColumns.length > 0;
|
|
171
|
+
}
|
|
172
|
+
function getHeaderCellStyle(data) {
|
|
173
|
+
const cellTitleStyle = columnStyleSourceConfig.value[data.column.property] ? columnStyleSourceConfig.value[data.column.property].titleStyle : null;
|
|
174
|
+
const rowTitleStyle = runtimeStyle == null ? void 0 : runtimeStyle.titleStyle;
|
|
175
|
+
return getHeaderCellStyleUtil(data, { cellTitleStyle, titleStyle: rowTitleStyle }, props);
|
|
176
|
+
}
|
|
177
|
+
function getRowStyle(data) {
|
|
178
|
+
return getRowStyleUtil(data, groupSummaryDataRowIndex, props);
|
|
179
|
+
}
|
|
180
|
+
function getCellStyle(data) {
|
|
181
|
+
const cellStyles = columnStyleSourceConfig.value[data.column.property] ? columnStyleSourceConfig.value[data.column.property].cellStyle : null;
|
|
182
|
+
return getCellStyleUtil(data, cellStyles, props);
|
|
183
|
+
}
|
|
184
|
+
const getSummaries = (param) => {
|
|
185
|
+
const { columns, data } = param;
|
|
186
|
+
const sums = [];
|
|
187
|
+
columns.forEach((column, index) => {
|
|
188
|
+
if (tableSummaryTitle.value[column.property]) {
|
|
189
|
+
const label = tableSummaryTitle.value[column.property].label;
|
|
190
|
+
sums[index] = h("div", {}, [replacePlaceholders(label, data)]);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (tableSummaryColumns.value[column.property]) {
|
|
194
|
+
const scientificData = data.filter((item, index2) => !groupSummaryDataRowIndex.includes(index2));
|
|
195
|
+
sums[index] = summaryStatistics(
|
|
196
|
+
tableSummaryColumns.value[column.property],
|
|
197
|
+
scientificData,
|
|
198
|
+
column.property,
|
|
199
|
+
props.pageContext
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
return sums;
|
|
204
|
+
};
|
|
205
|
+
function spanMethod({ row, column, rowIndex, columnIndex }) {
|
|
206
|
+
const property = column.property;
|
|
207
|
+
const highOrder = props.configure.props.highOrder;
|
|
208
|
+
if (highOrder.scopeFunc) {
|
|
209
|
+
const func = getCustomFunc(props.pageContext, highOrder.scopeFunc);
|
|
210
|
+
if (func) {
|
|
211
|
+
const resultValue = func.apply(func, [
|
|
212
|
+
{ tableData: tableData.value, row, column, rowIndex, columnIndex }
|
|
213
|
+
]);
|
|
214
|
+
if (resultValue) {
|
|
215
|
+
return resultValue;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
} else {
|
|
219
|
+
if (highOrder && highOrder.mergeColumn)
|
|
220
|
+
;
|
|
221
|
+
if (highOrder && highOrder.mergeRow && highOrder.mergeRow.includes(property)) {
|
|
222
|
+
if (rowIndex === 0) {
|
|
223
|
+
return {
|
|
224
|
+
rowspan: tableData.value.length,
|
|
225
|
+
colspan: 1
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
function updateColumnConfig(columnConfig, pivotedData, columnFields, valueFields) {
|
|
232
|
+
const updatedConfig = [...columnConfig].filter(
|
|
233
|
+
(item) => !columnFields.includes(item.props.base.prop) && !valueFields.includes(item.props.base.prop)
|
|
234
|
+
);
|
|
235
|
+
const valueFieldsRegex = new RegExp(`(${valueFields.join("|")})$`);
|
|
236
|
+
const columnCombinations = /* @__PURE__ */ new Set();
|
|
237
|
+
pivotedData.forEach((record) => {
|
|
238
|
+
Object.keys(record).forEach((key) => {
|
|
239
|
+
if (valueFields.some((valueField) => key.includes(valueField))) {
|
|
240
|
+
const parts = key.split(valueFieldsRegex);
|
|
241
|
+
const combination = parts[0];
|
|
242
|
+
columnCombinations.add(combination);
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
columnCombinations.forEach((combination) => {
|
|
247
|
+
valueFields.forEach((valueField) => {
|
|
248
|
+
var _a2;
|
|
249
|
+
const name = (_a2 = tableColumnsConfig.value.find((item) => item.props.base.prop === valueField)) == null ? void 0 : _a2.props.base.name;
|
|
250
|
+
const newConfigItem = {
|
|
251
|
+
uuid: (/* @__PURE__ */ new Date()).getTime(),
|
|
252
|
+
// 生成新的UUID
|
|
253
|
+
name: "",
|
|
254
|
+
props: {
|
|
255
|
+
base: {
|
|
256
|
+
prop: `${combination}${valueField}`,
|
|
257
|
+
name: `${combination}${name}`,
|
|
258
|
+
displayOrder: updatedConfig.length + 1,
|
|
259
|
+
// 更新显示顺序
|
|
260
|
+
sortable: true,
|
|
261
|
+
headerAlign: "center",
|
|
262
|
+
align: "center",
|
|
263
|
+
fixed: false,
|
|
264
|
+
visible: true,
|
|
265
|
+
dataType: typeof pivotedData[0][`${combination}${valueField}`] === "number" ? "number" : "string"
|
|
266
|
+
},
|
|
267
|
+
format: {},
|
|
268
|
+
size: {
|
|
269
|
+
pc: {}
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
style: {},
|
|
273
|
+
componentIndex: 0,
|
|
274
|
+
// 根据实际情况设置
|
|
275
|
+
runtime: {
|
|
276
|
+
common: {
|
|
277
|
+
class: "",
|
|
278
|
+
style: {
|
|
279
|
+
pc_style: {},
|
|
280
|
+
pc_class: ""
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
updatedConfig.push(newConfigItem);
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
return updatedConfig;
|
|
289
|
+
}
|
|
290
|
+
function groupAndAddTotals(data, groupFields) {
|
|
291
|
+
var _a2, _b;
|
|
292
|
+
if (groupSummaryColumns.value.length === 0) {
|
|
293
|
+
return data;
|
|
294
|
+
}
|
|
295
|
+
const result = [];
|
|
296
|
+
const groupColumns = (_a2 = props.configure.items) == null ? void 0 : _a2.filter(
|
|
297
|
+
(item) => groupFields.includes(item.props.base.prop)
|
|
298
|
+
);
|
|
299
|
+
const summaryColumns = (_b = props.configure.items) == null ? void 0 : _b.filter(
|
|
300
|
+
(item) => item.props.base.groupSummary === true
|
|
301
|
+
);
|
|
302
|
+
const groupedData = {};
|
|
303
|
+
data.forEach((item) => {
|
|
304
|
+
const key = groupFields.map((field) => item[field]).join("|");
|
|
305
|
+
if (!groupedData[key]) {
|
|
306
|
+
groupedData[key] = [];
|
|
307
|
+
}
|
|
308
|
+
groupedData[key].push(item);
|
|
309
|
+
});
|
|
310
|
+
const groupResult = Object.values(groupedData);
|
|
311
|
+
for (let i = 0; i < groupResult.length; i++) {
|
|
312
|
+
const group = groupResult[i];
|
|
313
|
+
const total = {};
|
|
314
|
+
summaryColumns == null ? void 0 : summaryColumns.forEach((column) => {
|
|
315
|
+
const prop = column.props.base.prop;
|
|
316
|
+
const res = summaryStatistics(groupSummaryColumns.value[prop], group, prop, props.pageContext);
|
|
317
|
+
total[prop] = res;
|
|
318
|
+
});
|
|
319
|
+
result.push(...group);
|
|
320
|
+
groupColumns == null ? void 0 : groupColumns.forEach((column) => {
|
|
321
|
+
const prop = column.props.base.prop;
|
|
322
|
+
total[prop] = replacePlaceholders(column.props.base.summaryTitle, group[0]);
|
|
323
|
+
});
|
|
324
|
+
result.push(total);
|
|
325
|
+
groupSummaryDataRowIndex.push(result.length - 1);
|
|
326
|
+
}
|
|
327
|
+
return result;
|
|
328
|
+
}
|
|
329
|
+
function pushTableIndexColumn(tableColumnsConfig2) {
|
|
330
|
+
if (props.configure.props.base.showIndex && tableColumnsConfig2.findIndex((item) => item.props.base.prop === "$index") === -1) {
|
|
331
|
+
const indexColumn = getIndexColumn();
|
|
332
|
+
if (indexColumn) {
|
|
333
|
+
tableColumnsConfig2.unshift(indexColumn);
|
|
334
|
+
}
|
|
73
335
|
}
|
|
74
|
-
resultData.hasRender = true;
|
|
75
|
-
dataConfig.autoRefresh = false;
|
|
76
336
|
}
|
|
77
337
|
function exportChart() {
|
|
78
338
|
}
|
|
@@ -81,7 +341,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
81
341
|
exportChart
|
|
82
342
|
});
|
|
83
343
|
return (_ctx, _cache) => {
|
|
84
|
-
const _component_el_table_column = resolveComponent("el-table-column");
|
|
85
344
|
const _component_el_table = resolveComponent("el-table");
|
|
86
345
|
return openBlock(), createElementBlock("div", {
|
|
87
346
|
style: normalizeStyle(unref(runtimeStyle)),
|
|
@@ -99,32 +358,40 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
99
358
|
]),
|
|
100
359
|
createVNode(_component_el_table, {
|
|
101
360
|
data: tableData.value,
|
|
102
|
-
style: { "width": "100%" }
|
|
361
|
+
style: { "width": "100%" },
|
|
362
|
+
"header-cell-style": getHeaderCellStyle,
|
|
363
|
+
"row-style": getRowStyle,
|
|
364
|
+
"cell-style": getCellStyle,
|
|
365
|
+
"show-summary": showSummary.value,
|
|
366
|
+
stripe: __props.configure.props.base.stripe,
|
|
367
|
+
"summary-method": getSummaries,
|
|
368
|
+
"span-method": spanMethod
|
|
103
369
|
}, {
|
|
104
370
|
default: withCtx(() => [
|
|
105
|
-
(openBlock(true), createElementBlock(Fragment,
|
|
371
|
+
isEnableGroupHeader.value ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(groupColumnsConfig.value, (item, index) => {
|
|
106
372
|
return openBlock(), createElementBlock(Fragment, { key: index }, [
|
|
107
|
-
|
|
373
|
+
!item.isLeaf ? (openBlock(), createBlock(_sfc_main$2, {
|
|
108
374
|
key: 0,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}, null, 8, ["label"])) : (openBlock(), createBlock(_component_el_table_column, {
|
|
375
|
+
configure: __props.configure,
|
|
376
|
+
pageContext: __props.pageContext,
|
|
377
|
+
groupColumn: item,
|
|
378
|
+
columnsConfigKeyValues: columnsConfigKeyValues.value
|
|
379
|
+
}, null, 8, ["configure", "pageContext", "groupColumn", "columnsConfigKeyValues"])) : (openBlock(), createBlock(_sfc_main$3, {
|
|
115
380
|
key: 1,
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
align: column.props.base.align,
|
|
121
|
-
fixed: column.props.base.fixed ? column.props.base.fixed : false
|
|
122
|
-
}, null, 8, ["prop", "width", "label", "header-align", "align", "fixed"]))
|
|
381
|
+
configure: __props.configure,
|
|
382
|
+
pageContext: __props.pageContext,
|
|
383
|
+
column: columnsConfigKeyValues.value[item.columnUuid]
|
|
384
|
+
}, null, 8, ["configure", "pageContext", "column"]))
|
|
123
385
|
], 64);
|
|
386
|
+
}), 128)) : (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(tableColumnsConfig.value, (column, index) => {
|
|
387
|
+
return openBlock(), createBlock(_sfc_main$3, {
|
|
388
|
+
key: index,
|
|
389
|
+
column
|
|
390
|
+
}, null, 8, ["column"]);
|
|
124
391
|
}), 128))
|
|
125
392
|
]),
|
|
126
393
|
_: 1
|
|
127
|
-
}, 8, ["data"])
|
|
394
|
+
}, 8, ["data", "show-summary", "stripe"])
|
|
128
395
|
], 6);
|
|
129
396
|
};
|
|
130
397
|
}
|