super-page-runtime 2.1.45 → 2.1.50-temp1
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 +5 -1
- package/dist/es/components/runtime/utils/events/standard-event.d.ts +11 -1
- package/dist/es/components/runtime/utils/events/standard-event.js +333 -36
- package/dist/es/components/runtime/utils/events/validator-util.js +5 -25
- package/dist/es/components/runtime/utils/page-helper-util.d.ts +3 -1
- package/dist/es/components/runtime/utils/page-helper-util.js +23 -5
- package/dist/es/components/runtime/utils/page-init-util.js +1 -2
- package/dist/es/components/runtime/views/assemblys/button/button/button-runtime.vue2.js +4 -1
- package/dist/es/components/runtime/views/assemblys/chart/column-line/column-line-runtime.vue2.js +3 -2
- package/dist/es/components/runtime/views/assemblys/chart/table/chart-table-util.js +491 -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 +247 -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 +318 -34
- package/dist/es/components/runtime/views/assemblys/container/tools/tools-runtime.vue2.js +1 -0
- 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/custom/custom-runtime.vue2.js +9 -2
- package/dist/es/components/runtime/views/assemblys/form/input-text/inputtext-runtime.vue2.js +3 -1
- package/dist/es/components/runtime/views/assemblys/form/placeholder/placeholder-runtime.vue.js +1 -1
- package/dist/es/components/runtime/views/assemblys/form/select/select-runtime.vue2.js +4 -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 +4 -4
- package/package.json +2 -2
- package/dist/es/components/runtime/views/assemblys/form/placeholder/placeholder-runtime.vue3.js +0 -1
|
@@ -80,8 +80,7 @@ function getTableQueryInfo(dataOriginInfo, pageContext2) {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
if (f.propValue)
|
|
84
|
-
;
|
|
83
|
+
if (f.propValue) ;
|
|
85
84
|
searchForm.push(tempObj);
|
|
86
85
|
}
|
|
87
86
|
infoObj.props.searchForm = searchForm;
|
|
@@ -342,7 +341,7 @@ function formatVariableValue(pageContext2, variable) {
|
|
|
342
341
|
const paramValue = getValueFromVariable(entity, param);
|
|
343
342
|
variable = variable.replace(
|
|
344
343
|
param,
|
|
345
|
-
paramValue
|
|
344
|
+
paramValue === void 0 || paramValue === null ? "" : paramValue
|
|
346
345
|
);
|
|
347
346
|
}
|
|
348
347
|
return variable;
|
|
@@ -408,7 +407,7 @@ function formatValueByType(value, formatType, formatInfo) {
|
|
|
408
407
|
}
|
|
409
408
|
return value;
|
|
410
409
|
}
|
|
411
|
-
function getValueFromVariable(entity, variable) {
|
|
410
|
+
function getValueFromVariable(entity, variable, row) {
|
|
412
411
|
if (variable == null || variable == void 0) {
|
|
413
412
|
return variable;
|
|
414
413
|
}
|
|
@@ -442,8 +441,12 @@ function getValueFromVariable(entity, variable) {
|
|
|
442
441
|
valueSource = entity.system;
|
|
443
442
|
} else if (paramName.startsWith("fixed.")) {
|
|
444
443
|
return paramName.substring(6);
|
|
444
|
+
} else if (paramName.startsWith("row.")) {
|
|
445
|
+
paramName = paramName.substring(4);
|
|
446
|
+
valueSource = row;
|
|
447
|
+
paramType = "row";
|
|
445
448
|
}
|
|
446
|
-
if (!paramName
|
|
449
|
+
if (!paramName) {
|
|
447
450
|
console.log("获取变量失败", variable, entity);
|
|
448
451
|
return "";
|
|
449
452
|
}
|
|
@@ -628,6 +631,9 @@ function getSizeConfig(pageContext2, configure2) {
|
|
|
628
631
|
if (configure2.props && configure2.props.size && configure2.props.size[pageModeType]) {
|
|
629
632
|
sizeConfig = configure2.props.size[pageModeType];
|
|
630
633
|
}
|
|
634
|
+
if (!sizeConfig && configure2.props && configure2.props.size) {
|
|
635
|
+
sizeConfig = configure2.props.size["pc"];
|
|
636
|
+
}
|
|
631
637
|
return sizeConfig;
|
|
632
638
|
}
|
|
633
639
|
function getPageModeType(pageContext2) {
|
|
@@ -637,9 +643,20 @@ function getPageModeType(pageContext2) {
|
|
|
637
643
|
}
|
|
638
644
|
return dimensions;
|
|
639
645
|
}
|
|
646
|
+
function isPromise(p) {
|
|
647
|
+
return p && Object.prototype.toString.call(p) === "[object Promise]";
|
|
648
|
+
}
|
|
649
|
+
function decomposeVariable(variable) {
|
|
650
|
+
if (!variable) {
|
|
651
|
+
return [];
|
|
652
|
+
}
|
|
653
|
+
const paramNames = variable.match(/\${(.*?)}/);
|
|
654
|
+
return paramNames ? paramNames[1].split(".") : [];
|
|
655
|
+
}
|
|
640
656
|
export {
|
|
641
657
|
autoSetAfterSelect,
|
|
642
658
|
caculateShowCondition,
|
|
659
|
+
decomposeVariable,
|
|
643
660
|
formatValueByType,
|
|
644
661
|
formatVariableValue,
|
|
645
662
|
getChartDatasFromPage,
|
|
@@ -651,6 +668,7 @@ export {
|
|
|
651
668
|
getValueFromSource,
|
|
652
669
|
getValueFromVariable,
|
|
653
670
|
getVariableValue,
|
|
671
|
+
isPromise,
|
|
654
672
|
monitorFieldChange,
|
|
655
673
|
queryOptionDatasources,
|
|
656
674
|
setValueForVariableName,
|
|
@@ -138,8 +138,7 @@ function getRequestObject(pageRequest) {
|
|
|
138
138
|
requestObj[paramStrs[0]] = paramStrs.length > 1 ? paramStrs[1] : "";
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
if (requestObj["_t_"])
|
|
142
|
-
;
|
|
141
|
+
if (requestObj["_t_"]) ;
|
|
143
142
|
return requestObj;
|
|
144
143
|
}
|
|
145
144
|
function packageAdditionalMapWithRoute(route, requestObj) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, ref, resolveComponent, openBlock, createElementBlock, createVNode, normalizeClass, unref, normalizeStyle, withCtx, Fragment, createTextVNode, toDisplayString, createCommentVNode, createBlock } from "vue";
|
|
1
|
+
import { defineComponent, ref, onMounted, resolveComponent, openBlock, createElementBlock, createVNode, normalizeClass, unref, normalizeStyle, withCtx, Fragment, createTextVNode, toDisplayString, createCommentVNode, createBlock } from "vue";
|
|
2
2
|
import { SuperIcon } from "agilebuilder-ui";
|
|
3
3
|
import { handleEvent } from "../../../../utils/events/event-util.js";
|
|
4
4
|
import { $t } from "../../../../utils/i18n-util.js";
|
|
@@ -21,6 +21,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
21
21
|
function isButtongLoading() {
|
|
22
22
|
return props.pageContext.canClick !== void 0 && props.pageContext.clickUuid !== void 0 ? !props.pageContext.canClick && props.pageContext.clickUuid === props.configure.uuid : false;
|
|
23
23
|
}
|
|
24
|
+
onMounted(() => {
|
|
25
|
+
console.log("select-runtime onMounted");
|
|
26
|
+
});
|
|
24
27
|
return (_ctx, _cache) => {
|
|
25
28
|
const _component_el_button = resolveComponent("el-button");
|
|
26
29
|
return openBlock(), createElementBlock("span", _hoisted_1, [
|
package/dist/es/components/runtime/views/assemblys/chart/column-line/column-line-runtime.vue2.js
CHANGED
|
@@ -29,7 +29,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
29
29
|
]);
|
|
30
30
|
const props = __props;
|
|
31
31
|
const thisRef = ref(null);
|
|
32
|
-
const chartRef = ref(
|
|
32
|
+
const chartRef = ref();
|
|
33
33
|
const headerRef = ref(null);
|
|
34
34
|
const enableDrill = props.configure.props ? props.configure.props.enableDrill : null;
|
|
35
35
|
const drillEndTrigger = props.configure.props ? props.configure.props.drillEndTrigger : null;
|
|
@@ -123,6 +123,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
123
123
|
refresh(true);
|
|
124
124
|
});
|
|
125
125
|
function updateChartDatas(resultData) {
|
|
126
|
+
var _a;
|
|
126
127
|
if (!resultData) {
|
|
127
128
|
resultData = [];
|
|
128
129
|
}
|
|
@@ -144,7 +145,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
144
145
|
headerInfo.groupValue = hisGroupValue;
|
|
145
146
|
}
|
|
146
147
|
if (!dataConfig.autoRefresh || !enableDrill) {
|
|
147
|
-
clearChartSelected(props.pageContext, props.configure, chartRef.value.chart);
|
|
148
|
+
clearChartSelected(props.pageContext, props.configure, (_a = chartRef.value) == null ? void 0 : _a.chart);
|
|
148
149
|
}
|
|
149
150
|
dataConfig.autoRefresh = false;
|
|
150
151
|
updateChartOption(props.pageContext, props.configure, chartOption, resultData);
|
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
import { getValueFromVariable } from "../../../../utils/page-helper-util.js";
|
|
2
|
+
import { getCustomFunc } from "../../../../utils/events/event-util.js";
|
|
3
|
+
class ExpressionEvaluator {
|
|
4
|
+
static evaluate(pageContext, conditions, data) {
|
|
5
|
+
const expressions = conditions.map(
|
|
6
|
+
(condition) => this.createExpression(pageContext, condition, data)
|
|
7
|
+
);
|
|
8
|
+
const joinedExpression = expressions.join(" ");
|
|
9
|
+
return this.evaluateExpression(joinedExpression);
|
|
10
|
+
}
|
|
11
|
+
static createExpression(pageContext, condition, data) {
|
|
12
|
+
const { propName, operator, propValue, leftBracket, rightBracket, joinSign, dataType } = condition;
|
|
13
|
+
if (!propName || propName === "") {
|
|
14
|
+
return "";
|
|
15
|
+
}
|
|
16
|
+
const value = getValueFromVariable(pageContext.entity, propName, data);
|
|
17
|
+
let expression2 = `${leftBracket} ${this.getComparisonExpression(value, operator, getValueFromVariable(pageContext.entity, propValue, data), dataType)} ${rightBracket}`;
|
|
18
|
+
if (joinSign) {
|
|
19
|
+
if (joinSign === "and" || joinSign === "AND") {
|
|
20
|
+
expression2 += "&&";
|
|
21
|
+
} else if (joinSign === "or" || joinSign === "OR") {
|
|
22
|
+
expression2 += "||";
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return expression2.trim();
|
|
26
|
+
}
|
|
27
|
+
static getComparisonExpression(value, operator, propValue, dataType) {
|
|
28
|
+
if (!operator) {
|
|
29
|
+
operator = "EQ";
|
|
30
|
+
}
|
|
31
|
+
const parsedValue = this.parseValue(value, dataType);
|
|
32
|
+
const parsedPropValue = this.parseValue(propValue, dataType);
|
|
33
|
+
switch (operator) {
|
|
34
|
+
case "EQ":
|
|
35
|
+
return `${parsedValue} === ${parsedPropValue}`;
|
|
36
|
+
case "GT":
|
|
37
|
+
return `${parsedValue} > ${parsedPropValue}`;
|
|
38
|
+
case "LT":
|
|
39
|
+
return `${parsedValue} < ${parsedPropValue}`;
|
|
40
|
+
case "GET":
|
|
41
|
+
return `${parsedValue} >= ${parsedPropValue}`;
|
|
42
|
+
case "LET":
|
|
43
|
+
return `${parsedValue} <= ${parsedPropValue}`;
|
|
44
|
+
case "NET":
|
|
45
|
+
return `${parsedValue} !== ${parsedPropValue}`;
|
|
46
|
+
case "CONTAIN":
|
|
47
|
+
return `${parsedValue}.includes(${parsedPropValue})`;
|
|
48
|
+
case "NOT_CONTAIN":
|
|
49
|
+
return `!${parsedValue}.includes(${parsedPropValue})`;
|
|
50
|
+
case "IS_NULL":
|
|
51
|
+
return `${parsedValue} === null`;
|
|
52
|
+
case "IS_NOT_NULL":
|
|
53
|
+
return `${parsedValue} !== null`;
|
|
54
|
+
default:
|
|
55
|
+
throw new Error(`比较符号不匹配: ${operator}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
static changeDataType(dataType) {
|
|
59
|
+
let resultDataType = dataType;
|
|
60
|
+
if (dataType) {
|
|
61
|
+
if (dataType === "TEXT") {
|
|
62
|
+
resultDataType = "string";
|
|
63
|
+
} else if (dataType === "DATE" || dataType === "TIME") {
|
|
64
|
+
resultDataType = "date";
|
|
65
|
+
} else if (dataType === "DOUBLE" || dataType === "FLOAT" || dataType === "INTEGER" || dataType === "LONG" || dataType === "BOOLEAN") {
|
|
66
|
+
resultDataType = "number";
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return resultDataType;
|
|
70
|
+
}
|
|
71
|
+
static parseValue(value, dataType) {
|
|
72
|
+
dataType = this.changeDataType(dataType);
|
|
73
|
+
switch (dataType) {
|
|
74
|
+
case "number":
|
|
75
|
+
return Number(value);
|
|
76
|
+
case "date":
|
|
77
|
+
return new Date(value).getTime();
|
|
78
|
+
case "string":
|
|
79
|
+
return `"${value}"`;
|
|
80
|
+
default:
|
|
81
|
+
throw new Error(`数据类型解析错误: ${dataType}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
static evaluateExpression(expression) {
|
|
85
|
+
try {
|
|
86
|
+
return eval(expression);
|
|
87
|
+
} catch (error) {
|
|
88
|
+
console.error("表达式错误:", expression, error);
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function getSummaryTitleColumn(configure) {
|
|
94
|
+
const result = {};
|
|
95
|
+
if (configure.props.summaries.titleColumn && configure.props.summaries.titleColumn.length > 0) {
|
|
96
|
+
configure.props.summaries.titleColumn.forEach((item) => {
|
|
97
|
+
result[item.prop] = item;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
return result;
|
|
101
|
+
}
|
|
102
|
+
function getSummaryDataColumn(configure, type) {
|
|
103
|
+
const result = {};
|
|
104
|
+
if (configure.props.summaries.dataColumn && configure.props.summaries.dataColumn.length > 0) {
|
|
105
|
+
configure.props.summaries.dataColumn.forEach((item) => {
|
|
106
|
+
var _a;
|
|
107
|
+
const columnConfigs = (_a = configure.items) == null ? void 0 : _a.find(
|
|
108
|
+
(columnItem) => item.prop === columnItem.props.base.prop
|
|
109
|
+
);
|
|
110
|
+
if (columnConfigs) {
|
|
111
|
+
if (type === "table" && columnConfigs.props.base.tableSummary) {
|
|
112
|
+
result[item.prop] = item;
|
|
113
|
+
} else if (type === "group" && columnConfigs.props.base.groupSummary) {
|
|
114
|
+
result[item.prop] = item;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return result;
|
|
120
|
+
}
|
|
121
|
+
function summaryStatistics(summaryColumn, data, prop, pageContext) {
|
|
122
|
+
let sumsIndex = "";
|
|
123
|
+
const summaryMode = summaryColumn.summaryMode;
|
|
124
|
+
const values = data.map((item) => Number(item[prop])).filter((value) => !Number.isNaN(value));
|
|
125
|
+
if (values.length > 0) {
|
|
126
|
+
if (summaryMode === "custom") {
|
|
127
|
+
const func = getCustomFunc(pageContext, summaryColumn.customFunc);
|
|
128
|
+
if (func) {
|
|
129
|
+
const resultValue = func.apply(func, [{ data, prop }]);
|
|
130
|
+
if (resultValue) {
|
|
131
|
+
sumsIndex = ` ${resultValue}`;
|
|
132
|
+
} else {
|
|
133
|
+
sumsIndex = " N/A";
|
|
134
|
+
}
|
|
135
|
+
} else {
|
|
136
|
+
sumsIndex = " N/A";
|
|
137
|
+
}
|
|
138
|
+
} else {
|
|
139
|
+
switch (summaryMode) {
|
|
140
|
+
case "sum":
|
|
141
|
+
sumsIndex = ` ${values.reduce((prev, curr) => prev + curr, 0)}`;
|
|
142
|
+
break;
|
|
143
|
+
case "avg":
|
|
144
|
+
sumsIndex = ` ${values.reduce((prev, curr) => prev + curr, 0) / values.length}`;
|
|
145
|
+
break;
|
|
146
|
+
case "min":
|
|
147
|
+
sumsIndex = ` ${Math.min(...values)}`;
|
|
148
|
+
break;
|
|
149
|
+
case "max":
|
|
150
|
+
sumsIndex = ` ${Math.max(...values)}`;
|
|
151
|
+
break;
|
|
152
|
+
default:
|
|
153
|
+
sumsIndex = " N/A";
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
} else {
|
|
157
|
+
sumsIndex = " N/A";
|
|
158
|
+
}
|
|
159
|
+
return sumsIndex;
|
|
160
|
+
}
|
|
161
|
+
function replacePlaceholders(template, data) {
|
|
162
|
+
if (template) {
|
|
163
|
+
return template.replace(/\$\{row\.(\w+)\}/g, (match, p1) => {
|
|
164
|
+
return Object.prototype.hasOwnProperty.call(data, p1) ? data[p1] : "";
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function getHeaderCellStyleUtil(data, runtimeStyle, props) {
|
|
169
|
+
var _a;
|
|
170
|
+
const headerStyle = {};
|
|
171
|
+
if (data.column.property) {
|
|
172
|
+
(_a = runtimeStyle.titleStyle) == null ? void 0 : _a.forEach((item) => {
|
|
173
|
+
if (item.field && item.field.includes(data.column.property)) {
|
|
174
|
+
if (item.scopeFunc) {
|
|
175
|
+
const func = getCustomFunc(props.pageContext, item.scopeFunc);
|
|
176
|
+
if (func) {
|
|
177
|
+
const funcResult = func.apply(func, [{ item, data }]);
|
|
178
|
+
if (funcResult !== false) {
|
|
179
|
+
copyStyle(headerStyle, item);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
copyStyle(headerStyle, item);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
const cellTitleStytle = getCellStyleUtil(data, runtimeStyle.cellTitleStyle, props);
|
|
189
|
+
if (cellTitleStytle) {
|
|
190
|
+
Object.assign(headerStyle, cellTitleStytle);
|
|
191
|
+
}
|
|
192
|
+
return headerStyle;
|
|
193
|
+
}
|
|
194
|
+
function getRowStyleUtil(data, groupSummaryDataRowIndex, props) {
|
|
195
|
+
const returnStyle = {};
|
|
196
|
+
if (props.configure.style.rowStyle) {
|
|
197
|
+
for (let i = 0; i < props.configure.style.rowStyle.length; i++) {
|
|
198
|
+
const rowStyle = props.configure.style.rowStyle[i];
|
|
199
|
+
if (rowStyle.scopeFunc) {
|
|
200
|
+
const func = getCustomFunc(props.pageContext, rowStyle.scopeFunc);
|
|
201
|
+
if (func) {
|
|
202
|
+
const funcResult = func.apply(func, [{ data }]);
|
|
203
|
+
if (funcResult !== void 0 && funcResult !== null && funcResult !== false) {
|
|
204
|
+
copyStyle(returnStyle, rowStyle);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
} else if (rowStyle.matchingCondition) {
|
|
208
|
+
const result = ExpressionEvaluator.evaluate(
|
|
209
|
+
props.pageContext,
|
|
210
|
+
rowStyle.matchingCondition,
|
|
211
|
+
data.row
|
|
212
|
+
);
|
|
213
|
+
if (result || result === void 0) {
|
|
214
|
+
copyStyle(returnStyle, rowStyle);
|
|
215
|
+
}
|
|
216
|
+
} else {
|
|
217
|
+
copyStyle(returnStyle, rowStyle);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (groupSummaryDataRowIndex && groupSummaryDataRowIndex.length > 0 && groupSummaryDataRowIndex.indexOf(data.rowIndex) !== -1) {
|
|
222
|
+
const result = {};
|
|
223
|
+
if (props.configure.style.collectStyle && props.configure.style.collectStyle.length > 0) {
|
|
224
|
+
for (let i = 0; i < props.configure.style.collectStyle.length; i++) {
|
|
225
|
+
const collectStyle = props.configure.style.collectStyle[i];
|
|
226
|
+
copyStyle(result, collectStyle);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (Object.keys(result).length === 0) {
|
|
230
|
+
result["background-color"] = "var(--el-table-row-hover-bg-color)";
|
|
231
|
+
}
|
|
232
|
+
return result;
|
|
233
|
+
}
|
|
234
|
+
return returnStyle;
|
|
235
|
+
}
|
|
236
|
+
function getCellStyleUtil(data, cellStyles, props) {
|
|
237
|
+
const cellStyle = {};
|
|
238
|
+
if (cellStyles) {
|
|
239
|
+
for (let i = 0; i < cellStyles.length; i++) {
|
|
240
|
+
const columnsStyleSetting = cellStyles[i];
|
|
241
|
+
if (columnsStyleSetting.scopeFunc) {
|
|
242
|
+
const func = getCustomFunc(props.pageContext, columnsStyleSetting.scopeFunc);
|
|
243
|
+
if (func) {
|
|
244
|
+
const funcResult = func.apply(func, [{ data }]);
|
|
245
|
+
if (funcResult !== false) {
|
|
246
|
+
copyStyle(cellStyle, columnsStyleSetting);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
} else if (columnsStyleSetting.matchingCondition) {
|
|
250
|
+
const result = ExpressionEvaluator.evaluate(
|
|
251
|
+
props.pageContext,
|
|
252
|
+
columnsStyleSetting.matchingCondition,
|
|
253
|
+
data.row
|
|
254
|
+
);
|
|
255
|
+
if (result || result === void 0) {
|
|
256
|
+
copyStyle(cellStyle, columnsStyleSetting);
|
|
257
|
+
}
|
|
258
|
+
} else {
|
|
259
|
+
copyStyle(cellStyle, columnsStyleSetting);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return cellStyle;
|
|
264
|
+
}
|
|
265
|
+
function copyStyle(target, source) {
|
|
266
|
+
Object.assign(target, source.style);
|
|
267
|
+
if (source.customStyle) {
|
|
268
|
+
Object.assign(target, JSON.parse(source.customStyle));
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
function rowDataToColumn(data, configure) {
|
|
272
|
+
const groupByFields = configure.props.dataOrigin.groupField;
|
|
273
|
+
const titleColumns = configure.props.dataOrigin.rowToColumn.titleColumns;
|
|
274
|
+
const dataColumns = configure.props.dataOrigin.rowToColumn.dataColumns;
|
|
275
|
+
const result = [];
|
|
276
|
+
const groupedData = {};
|
|
277
|
+
data.forEach((item) => {
|
|
278
|
+
const key = groupByFields.map((field) => item[field]).join("|");
|
|
279
|
+
if (!groupedData[key]) {
|
|
280
|
+
const group = {};
|
|
281
|
+
groupByFields.forEach((field) => group[field] = item[field]);
|
|
282
|
+
groupedData[key] = group;
|
|
283
|
+
result.push(group);
|
|
284
|
+
}
|
|
285
|
+
dataColumns.forEach((valueField) => {
|
|
286
|
+
const columnNameParts = titleColumns.map((field) => item[field]);
|
|
287
|
+
const columnName = `${columnNameParts.join("")}${valueField}`;
|
|
288
|
+
groupedData[key][columnName] = item[valueField];
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
return result;
|
|
292
|
+
}
|
|
293
|
+
function colDataToRow(data, configure) {
|
|
294
|
+
const groupByFields = configure.props.dataOrigin.groupField;
|
|
295
|
+
const titleColumns = configure.props.dataOrigin.columnToRow.titleColumns;
|
|
296
|
+
const dataColumns = configure.props.dataOrigin.columnToRow.dataColumns;
|
|
297
|
+
const transColumns = configure.props.dataOrigin.columnToRow.transColumns;
|
|
298
|
+
const dataColumnsMapping = configure.props.dataOrigin.columnToRow.dataColumnsMapping;
|
|
299
|
+
if (data.length === 0) {
|
|
300
|
+
return data;
|
|
301
|
+
}
|
|
302
|
+
const result = [];
|
|
303
|
+
const newData = groupBy(data, groupByFields);
|
|
304
|
+
const dataColumnsConfig = dataColumns.reduce((max, current) => {
|
|
305
|
+
return current.columns.length > max.columns.length ? current : max;
|
|
306
|
+
}, dataColumns[0]);
|
|
307
|
+
const dataColumnsAndNewColumnMapping = dataColumns.reduce((acc, item) => {
|
|
308
|
+
item.columns.forEach((column) => {
|
|
309
|
+
acc[column] = item.prop;
|
|
310
|
+
});
|
|
311
|
+
return acc;
|
|
312
|
+
}, {});
|
|
313
|
+
newData.forEach((item) => {
|
|
314
|
+
dataColumnsConfig.columns.forEach((col) => {
|
|
315
|
+
const newColumnsProp = dataColumnsConfig.prop;
|
|
316
|
+
const dataRow = {};
|
|
317
|
+
groupByFields.forEach((field) => {
|
|
318
|
+
dataRow[field] = item[field];
|
|
319
|
+
});
|
|
320
|
+
dataRow[newColumnsProp] = item[col];
|
|
321
|
+
if (dataColumns.length > 1) {
|
|
322
|
+
const columnMapping = dataColumnsMapping.find((item2) => item2.props.includes(col));
|
|
323
|
+
if (columnMapping && columnMapping.props.length > 1) {
|
|
324
|
+
columnMapping.props.forEach((prop) => {
|
|
325
|
+
if (prop !== col && dataColumnsAndNewColumnMapping[prop]) {
|
|
326
|
+
dataRow[dataColumnsAndNewColumnMapping[prop]] = item[prop];
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
titleColumns.forEach((titleCol) => {
|
|
332
|
+
const sourceTitleRenameConfigs = transColumns.filter(
|
|
333
|
+
(transCol) => transCol.relatedTitle === titleCol.prop
|
|
334
|
+
);
|
|
335
|
+
let rename = false;
|
|
336
|
+
if (sourceTitleRenameConfigs && sourceTitleRenameConfigs.length > 0) {
|
|
337
|
+
sourceTitleRenameConfigs.forEach((item2) => {
|
|
338
|
+
if (item2.columns.includes(col)) {
|
|
339
|
+
dataRow[titleCol.prop] = item2.label;
|
|
340
|
+
rename = true;
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
if (!rename) {
|
|
346
|
+
dataRow[titleCol.prop] = col;
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
result.push(dataRow);
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
return result;
|
|
353
|
+
}
|
|
354
|
+
function getColumnToRowTableConfig(configure) {
|
|
355
|
+
const sourceConfig = configure.items;
|
|
356
|
+
const groupField = configure.props.dataOrigin.groupField;
|
|
357
|
+
const titleColumns = configure.props.dataOrigin.columnToRow.titleColumns;
|
|
358
|
+
const dataColumns = configure.props.dataOrigin.columnToRow.dataColumns;
|
|
359
|
+
const newTableColumns = [];
|
|
360
|
+
groupField.forEach((field) => {
|
|
361
|
+
if (sourceConfig) {
|
|
362
|
+
const column = sourceConfig.find((item) => item.props.base.prop === field);
|
|
363
|
+
if (column) {
|
|
364
|
+
newTableColumns.push(column);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
const newCols = [...titleColumns, ...dataColumns];
|
|
369
|
+
newCols.forEach((field) => {
|
|
370
|
+
if (sourceConfig) {
|
|
371
|
+
const column = sourceConfig.find((item) => item.props.base.prop === field);
|
|
372
|
+
if (column) {
|
|
373
|
+
newTableColumns.push(column);
|
|
374
|
+
} else {
|
|
375
|
+
newTableColumns.push({
|
|
376
|
+
uuid: (/* @__PURE__ */ new Date()).getTime(),
|
|
377
|
+
// 生成新的UUID
|
|
378
|
+
name: "",
|
|
379
|
+
props: {
|
|
380
|
+
base: {
|
|
381
|
+
prop: field.prop,
|
|
382
|
+
name: field.title,
|
|
383
|
+
sortable: true,
|
|
384
|
+
headerAlign: "center",
|
|
385
|
+
align: "center",
|
|
386
|
+
fixed: false,
|
|
387
|
+
visible: true,
|
|
388
|
+
dataType: "string"
|
|
389
|
+
},
|
|
390
|
+
format: {},
|
|
391
|
+
size: {
|
|
392
|
+
pc: {}
|
|
393
|
+
}
|
|
394
|
+
},
|
|
395
|
+
style: {},
|
|
396
|
+
componentIndex: 0,
|
|
397
|
+
// 根据实际情况设置
|
|
398
|
+
runtime: {
|
|
399
|
+
common: {
|
|
400
|
+
class: "",
|
|
401
|
+
style: {
|
|
402
|
+
pc_style: {},
|
|
403
|
+
pc_class: ""
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
return newTableColumns;
|
|
412
|
+
}
|
|
413
|
+
function groupBy(data, groupFields) {
|
|
414
|
+
const grouped = {};
|
|
415
|
+
data.forEach((item) => {
|
|
416
|
+
const key = groupFields.map((field) => item[field]).join("|");
|
|
417
|
+
if (!grouped[key]) {
|
|
418
|
+
grouped[key] = {
|
|
419
|
+
...item,
|
|
420
|
+
// 复制所有字段
|
|
421
|
+
records: []
|
|
422
|
+
// 初始化记录数组
|
|
423
|
+
};
|
|
424
|
+
groupFields.forEach((field, index) => {
|
|
425
|
+
grouped[key][field] = item[field];
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
grouped[key].records.push(item);
|
|
429
|
+
});
|
|
430
|
+
return Object.values(grouped).map((group) => ({
|
|
431
|
+
...group,
|
|
432
|
+
// 复制所有分组信息
|
|
433
|
+
records: void 0
|
|
434
|
+
// 移除records字段,因为不需要展示
|
|
435
|
+
}));
|
|
436
|
+
}
|
|
437
|
+
function getIndexColumn() {
|
|
438
|
+
return {
|
|
439
|
+
props: {
|
|
440
|
+
base: {
|
|
441
|
+
name: "序号",
|
|
442
|
+
prop: "$index",
|
|
443
|
+
columnWidth: 80,
|
|
444
|
+
sortable: true,
|
|
445
|
+
visible: true,
|
|
446
|
+
displayOrder: 1,
|
|
447
|
+
alignTitle: "center",
|
|
448
|
+
alignContent: "center"
|
|
449
|
+
}
|
|
450
|
+
},
|
|
451
|
+
events: [],
|
|
452
|
+
style: {
|
|
453
|
+
titleFont: {},
|
|
454
|
+
contentFont: {},
|
|
455
|
+
width: {},
|
|
456
|
+
background: {},
|
|
457
|
+
tableCell: [{ type: "", model: "" }],
|
|
458
|
+
conentPadding: {},
|
|
459
|
+
tittlePadding: {},
|
|
460
|
+
border: {},
|
|
461
|
+
shadow: {},
|
|
462
|
+
tittleClass: ""
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
function computeFormula(row, formula) {
|
|
467
|
+
try {
|
|
468
|
+
return new Function(
|
|
469
|
+
"row",
|
|
470
|
+
`return ${formula.replace(/\$\{row\.(\w+)\}/g, (_, key) => `row.${key}`)}`
|
|
471
|
+
)(row);
|
|
472
|
+
} catch (error) {
|
|
473
|
+
console.error("数据公式解析错误:", error);
|
|
474
|
+
return 0;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
export {
|
|
478
|
+
ExpressionEvaluator,
|
|
479
|
+
colDataToRow,
|
|
480
|
+
computeFormula,
|
|
481
|
+
getCellStyleUtil,
|
|
482
|
+
getColumnToRowTableConfig,
|
|
483
|
+
getHeaderCellStyleUtil,
|
|
484
|
+
getIndexColumn,
|
|
485
|
+
getRowStyleUtil,
|
|
486
|
+
getSummaryDataColumn,
|
|
487
|
+
getSummaryTitleColumn,
|
|
488
|
+
replacePlaceholders,
|
|
489
|
+
rowDataToColumn,
|
|
490
|
+
summaryStatistics
|
|
491
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { defineComponent, openBlock, createBlock } from "vue";
|
|
2
|
+
import _sfc_main$1 from "./group-column.vue.js";
|
|
3
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
4
|
+
__name: "group-column-item",
|
|
5
|
+
props: {
|
|
6
|
+
configure: {
|
|
7
|
+
type: Object,
|
|
8
|
+
default: () => {
|
|
9
|
+
return {};
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
pageContext: {
|
|
13
|
+
type: Object,
|
|
14
|
+
default: () => {
|
|
15
|
+
return {};
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
groupColumnItem: {
|
|
19
|
+
type: Object,
|
|
20
|
+
default: () => {
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
columnsConfigKeyValues: {
|
|
25
|
+
type: Object,
|
|
26
|
+
default: () => {
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
setup(__props) {
|
|
32
|
+
return (_ctx, _cache) => {
|
|
33
|
+
return openBlock(), createBlock(_sfc_main$1, {
|
|
34
|
+
configure: __props.configure,
|
|
35
|
+
pageContext: __props.pageContext,
|
|
36
|
+
groupColumn: __props.groupColumnItem,
|
|
37
|
+
columnsConfigKeyValues: __props.columnsConfigKeyValues
|
|
38
|
+
}, null, 8, ["configure", "pageContext", "groupColumn", "columnsConfigKeyValues"]);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
export {
|
|
43
|
+
_sfc_main as default
|
|
44
|
+
};
|