super-page-runtime 2.0.10 → 2.0.15

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.
Files changed (49) hide show
  1. package/dist/es/components/runtime/utils/api/api-util.d.ts +6 -1
  2. package/dist/es/components/runtime/utils/api/api-util.js +140 -2
  3. package/dist/es/components/runtime/utils/charts/chart-columnline-util.js +279 -0
  4. package/dist/es/components/runtime/utils/charts/chart-gauge-util.js +74 -0
  5. package/dist/es/components/runtime/utils/charts/chart-pie-util.js +118 -0
  6. package/dist/es/components/runtime/utils/charts/chart-radar-util.js +100 -0
  7. package/dist/es/components/runtime/utils/charts/chart-scatter-util.js +74 -0
  8. package/dist/es/components/runtime/utils/charts/chart-util.d.ts +40 -0
  9. package/dist/es/components/runtime/utils/charts/chart-util.js +288 -14
  10. package/dist/es/components/runtime/utils/events/event-util.d.ts +5 -0
  11. package/dist/es/components/runtime/utils/events/event-util.js +42 -10
  12. package/dist/es/components/runtime/utils/events/standard-event.d.ts +1 -0
  13. package/dist/es/components/runtime/utils/events/standard-event.js +54 -5
  14. package/dist/es/components/runtime/utils/events/validator-util.d.ts +8 -0
  15. package/dist/es/components/runtime/utils/events/validator-util.js +83 -57
  16. package/dist/es/components/runtime/utils/interfaces/page-design-types.d.ts +0 -1
  17. package/dist/es/components/runtime/utils/page-helper-util.d.ts +22 -0
  18. package/dist/es/components/runtime/utils/page-helper-util.js +59 -50
  19. package/dist/es/components/runtime/utils/page-init-util.d.ts +1 -0
  20. package/dist/es/components/runtime/utils/page-init-util.js +29 -4
  21. package/dist/es/components/runtime/views/assemblys/button/dropdown/dropdown-runtime.vue2.js +8 -3
  22. package/dist/es/components/runtime/views/assemblys/chart/column-line/column-line-runtime.vue2.js +34 -322
  23. package/dist/es/components/runtime/views/assemblys/chart/common/common-chart-header.vue.js +2 -1
  24. package/dist/es/components/runtime/views/assemblys/chart/gauge/gauge-runtime.vue2.js +66 -12
  25. package/dist/es/components/runtime/views/assemblys/chart/pie/pie-runtime.vue2.js +91 -4
  26. package/dist/es/components/runtime/views/assemblys/chart/radar/radar-runtime.vue2.js +65 -4
  27. package/dist/es/components/runtime/views/assemblys/chart/scatter/scatter-runtime.vue2.js +65 -4
  28. package/dist/es/components/runtime/views/assemblys/container/tabs/tabs-runtime.vue2.js +36 -1
  29. package/dist/es/components/runtime/views/assemblys/data/table/main-table-runtime.vue.js +1 -1
  30. package/dist/es/components/runtime/views/assemblys/data/table/sub-table-runtime.vue.js +2 -4
  31. package/dist/es/components/runtime/views/assemblys/form/checkbox/checkbox-runtime.vue2.js +22 -58
  32. package/dist/es/components/runtime/views/assemblys/form/date-picker/datepicker-runtime.vue2.js +16 -3
  33. package/dist/es/components/runtime/views/assemblys/form/dept-tree/depttree-runtime.vue2.js +10 -1
  34. package/dist/es/components/runtime/views/assemblys/form/file-upload/fileupload-runtime.vue2.js +25 -2
  35. package/dist/es/components/runtime/views/assemblys/form/input-number/input-number-runtime.vue2.js +5 -1
  36. package/dist/es/components/runtime/views/assemblys/form/link/link-runtime.vue2.js +3 -2
  37. package/dist/es/components/runtime/views/assemblys/form/radio/radio-runtime.vue2.js +14 -11
  38. package/dist/es/components/runtime/views/assemblys/form/rich-text/richtext-runtime.vue2.js +2 -0
  39. package/dist/es/components/runtime/views/assemblys/form/select/select-runtime.vue2.js +14 -11
  40. package/dist/es/components/runtime/views/assemblys/form/switch/switch-runtime.vue2.js +3 -1
  41. package/dist/es/components/runtime/views/assemblys/form/tag/tag-runtime.vue2.js +4 -1
  42. package/dist/es/components/runtime/views/assemblys/form/textarea/textarea-runtime.vue2.js +7 -1
  43. package/dist/es/components/runtime/views/assemblys/object-render.vue.js +2 -1
  44. package/dist/es/components/runtime/views/assemblys/workflow/workflow-button/workflowbutton-runtime.vue2.js +1 -1
  45. package/dist/es/components/runtime/views/super-page-dialog.vue.js +3 -0
  46. package/dist/es/components/runtime/views/super-page.vue.js +84 -130
  47. package/dist/es/index.d.ts +2 -2
  48. package/dist/es/index.js +2 -1
  49. package/package.json +2 -2
@@ -4,8 +4,13 @@
4
4
  * @param customRules 自定义的校验规则
5
5
  */
6
6
  export declare function setCustomRules(pageContext: any, customRules: any): void;
7
+ /**
8
+ * 刷新页面
9
+ * @param pageContext
10
+ */
11
+ export declare function refreshPage(pageContext: any): void;
7
12
  /**
8
13
  * 获得表单数据
9
14
  * @param pageContext
10
15
  */
11
- export declare function getData(pageContext: any): Promise<unknown>;
16
+ export declare function getFormData(pageContext: any): Promise<unknown>;
@@ -3,7 +3,14 @@ import { getSessionCache } from "agilebuilder-ui/src/utils/auth";
3
3
  import http from "agilebuilder-ui/src/utils/request";
4
4
  import { getBaseUrl } from "../common-util.js";
5
5
  import { dealCompleteTaskParam } from "../events/standard-event.js";
6
- function getData(pageContext) {
6
+ import { packageCustomRules, getWorkflowRules } from "../events/validator-util.js";
7
+ import { handleEvent } from "../events/event-util.js";
8
+ function refreshPage(pageContext) {
9
+ getFormData(pageContext).then((commonEntity) => {
10
+ pageContext.isRefresh = true;
11
+ });
12
+ }
13
+ function getFormData(pageContext) {
7
14
  const pageType = pageContext.pageType;
8
15
  if (pageType && pageType === "form") {
9
16
  console.log("获取表单数据getData--pageContext=", pageContext);
@@ -64,6 +71,23 @@ function getCommonFormData(pageContext) {
64
71
  pageContext.entity.data = commonEntity.entity;
65
72
  pageContext.initFormNo = commonEntity.formNo;
66
73
  }
74
+ const customRules = pageContext.customRules;
75
+ let formRules = pageContext.rules;
76
+ const newFormRules = packageCustomRules(customRules, formRules);
77
+ pageContext.rules = newFormRules;
78
+ const pageDesign = {
79
+ runtime: { events: pageContext.events },
80
+ systemCode: "",
81
+ systemVersion: 0,
82
+ code: "",
83
+ version: 0,
84
+ workflowCode: "",
85
+ workflowVersion: 0,
86
+ name: "",
87
+ uuid: "",
88
+ label: ""
89
+ };
90
+ handleEvent(null, pageContext, pageDesign, "load");
67
91
  resolve(commonEntity);
68
92
  }).catch((error) => {
69
93
  reject(error);
@@ -117,12 +141,126 @@ function getWorkflowFormData(pageContext) {
117
141
  pageContext.definitionId = commonEntity.definitionId;
118
142
  pageContext.entity.task = commonEntity.taskParamMap;
119
143
  dealCompleteTaskParam(commonEntity, true, pageContext);
144
+ pageContext.workflowRules = getWorkflowRules(pageContext);
145
+ const pageType = pageContext.pageType;
146
+ if (pageType && pageType === "form") {
147
+ changePermissionListToMap(pageContext);
148
+ const pageDesign = {
149
+ runtime: { events: pageContext.events },
150
+ systemCode: "",
151
+ systemVersion: 0,
152
+ code: "",
153
+ version: 0,
154
+ workflowCode: "",
155
+ workflowVersion: 0,
156
+ name: "",
157
+ uuid: "",
158
+ label: ""
159
+ };
160
+ handleEvent(null, pageContext, pageDesign, "load");
161
+ }
120
162
  resolve(commonEntity);
121
163
  }).catch((error) => {
122
164
  reject(error);
123
165
  });
124
166
  });
125
167
  }
168
+ function changePermissionListToMap(pageContext) {
169
+ changeFieldPermissionToMap(pageContext);
170
+ changeActionPermissionToMap(pageContext);
171
+ }
172
+ function changeFieldPermissionToMap(pageContext) {
173
+ let fieldPermissionMap = pageContext.fieldPermissionMap;
174
+ pageContext.actionPermissionMap;
175
+ const fieldPermissions = pageContext.fieldPermissions;
176
+ if (fieldPermissionMap === null) {
177
+ fieldPermissionMap = /* @__PURE__ */ new Map();
178
+ }
179
+ if (typeof fieldPermissions !== "undefined") {
180
+ for (let i = 0; i < fieldPermissions.length; i++) {
181
+ const prop = fieldPermissions[i].name;
182
+ if (prop) {
183
+ if (prop.indexOf("$") === 0 && prop.indexOf(".") > 0) {
184
+ const fieldPermissionOrg = fieldPermissions[i];
185
+ const fieldPermission = JSON.parse(JSON.stringify(fieldPermissionOrg));
186
+ const subModelName = prop.substring(1, prop.indexOf("."));
187
+ const subProp = prop.substring(prop.indexOf(".") + 1);
188
+ fieldPermission.name = subProp;
189
+ if (fieldPermission && fieldPermission.name === "all_fields") {
190
+ if (fieldPermission.canEdit === false) {
191
+ if (fieldPermission.rowIndexes) {
192
+ fieldPermissionMap.set(subModelName, [
193
+ {
194
+ name: "all_fields",
195
+ canEdit: false,
196
+ rowIndexes: fieldPermission.rowIndexes
197
+ }
198
+ ]);
199
+ } else {
200
+ fieldPermissionMap.set(subModelName, [{ name: "all_fields", canEdit: false }]);
201
+ }
202
+ } else {
203
+ if (fieldPermission.rowIndexes) {
204
+ fieldPermissionMap.set(subModelName, [
205
+ {
206
+ name: "all_fields",
207
+ canEdit: true,
208
+ rowIndexes: fieldPermission.rowIndexes
209
+ }
210
+ ]);
211
+ } else {
212
+ fieldPermissionMap.set(subModelName, [{ name: "all_fields", canEdit: true }]);
213
+ }
214
+ }
215
+ } else {
216
+ let subTableFieldPermission = fieldPermissionMap.get(subModelName);
217
+ if (subTableFieldPermission) {
218
+ subTableFieldPermission.push(fieldPermission);
219
+ } else {
220
+ subTableFieldPermission = [];
221
+ subTableFieldPermission.push(fieldPermission);
222
+ }
223
+ fieldPermissionMap.set(subModelName, subTableFieldPermission);
224
+ }
225
+ } else {
226
+ fieldPermissionMap.set(prop, fieldPermissions[i]);
227
+ }
228
+ }
229
+ }
230
+ }
231
+ pageContext.fieldPermissionMap = fieldPermissionMap;
232
+ }
233
+ function changeActionPermissionToMap(pageContext) {
234
+ let fieldPermissionMap = pageContext.fieldPermissionMap;
235
+ let actionPermissionMap = pageContext.actionPermissionMap;
236
+ const actionPermissions = pageContext.actionPermissions;
237
+ if (typeof actionPermissions !== "undefined" && actionPermissions !== null) {
238
+ const subModelNames = Object.keys(actionPermissions);
239
+ subModelNames.forEach((subModelName) => {
240
+ const oneTableActionPermission = actionPermissions[subModelName];
241
+ const subTableFieldPermission = fieldPermissionMap.get(subModelName);
242
+ if (subTableFieldPermission && subTableFieldPermission.length > 0 && subTableFieldPermission[0].name === "all_fields" && subTableFieldPermission[0].canEdit === false) {
243
+ oneTableActionPermission.canUpdate = false;
244
+ oneTableActionPermission.canAdd = false;
245
+ } else {
246
+ const canUpdate = oneTableActionPermission.canUpdate;
247
+ const updateRowIndexes = oneTableActionPermission.updateRowIndexes;
248
+ if (canUpdate !== void 0 && canUpdate === false && updateRowIndexes !== void 0 && updateRowIndexes !== null && updateRowIndexes.length > 0) {
249
+ fieldPermissionMap.set(subModelName, [
250
+ {
251
+ name: "all_fields",
252
+ canEdit: false,
253
+ rowIndexes: updateRowIndexes
254
+ }
255
+ ]);
256
+ }
257
+ }
258
+ actionPermissionMap.set(subModelName, oneTableActionPermission);
259
+ });
260
+ }
261
+ pageContext.actionPermissionMap = actionPermissionMap;
262
+ }
126
263
  export {
127
- getData
264
+ getFormData,
265
+ refreshPage
128
266
  };
@@ -0,0 +1,279 @@
1
+ import { getValueFromSource, formatVariableValue, setValueForVariableName } from "../page-helper-util.js";
2
+ import { deepCopy } from "../common-util.js";
3
+ import { CommonName, sortDatas, limitDatas } from "./chart-util.js";
4
+ function updateChartOption(pageContext, configure, chartOption, resultData) {
5
+ if (!resultData || !resultData.result) {
6
+ return;
7
+ }
8
+ const result = resultData && resultData.result ? resultData.result : {};
9
+ const groupValue = resultData && resultData.groupValue ? resultData.groupValue : [];
10
+ const dataSetField = configure.serviceDataField;
11
+ let datas = null;
12
+ if (dataSetField) {
13
+ datas = result[dataSetField];
14
+ } else {
15
+ if (result) {
16
+ if (Array.isArray(result)) {
17
+ datas = result;
18
+ } else {
19
+ datas = [result];
20
+ }
21
+ }
22
+ }
23
+ if (!datas) {
24
+ datas = [];
25
+ }
26
+ let confGroups = configure.props ? configure.props.groups : null;
27
+ if (!confGroups) {
28
+ confGroups = [];
29
+ }
30
+ const groupMap = {};
31
+ const groupFields = [];
32
+ const realGroupFilds = [];
33
+ for (let g of confGroups) {
34
+ groupMap[g.group] = g.target;
35
+ if (g.target && !groupFields.includes(g.target)) {
36
+ groupFields.push(g.target);
37
+ if (groupValue.includes(g.group)) {
38
+ realGroupFilds.push(g.target);
39
+ }
40
+ }
41
+ }
42
+ let mulGroupShow = configure.props ? configure.props.mulGroupShow : "";
43
+ mulGroupShow = mulGroupShow == "break" ? "\r\n" : " ";
44
+ for (let d of datas) {
45
+ if (!d) {
46
+ continue;
47
+ }
48
+ const xValues2 = [];
49
+ for (let g of groupValue) {
50
+ const fieldName = groupMap[g];
51
+ const value = getValueFromSource(d, fieldName, void 0);
52
+ if (value) {
53
+ xValues2.push(value);
54
+ }
55
+ }
56
+ const xValue = xValues2.join(mulGroupShow);
57
+ d[CommonName.X_FIELD_NAME] = xValue;
58
+ }
59
+ const itemConfs = configure.items ? configure.items : [];
60
+ const serieValues = [];
61
+ const serieValueMap = {};
62
+ const dynamicFileds = [];
63
+ const dynamicValueField = {};
64
+ const allValueFields = [];
65
+ const limitValueFields = [];
66
+ for (let item of itemConfs) {
67
+ const itemProps = item.props ? item.props : {};
68
+ const sourceType = itemProps.yaxisSource;
69
+ const yaxisField = itemProps.yaxisField;
70
+ const isCumulative = itemProps.isCumulative;
71
+ let serieValue = null;
72
+ if (yaxisField && (!sourceType || sourceType == "variable")) {
73
+ serieValue = {
74
+ uuid: item.uuid,
75
+ type: "variable",
76
+ field: yaxisField,
77
+ isCumulative,
78
+ data: [],
79
+ dynamicDatas: []
80
+ //动态系列数据
81
+ };
82
+ if (yaxisField && !allValueFields.includes(yaxisField)) {
83
+ allValueFields.push(yaxisField);
84
+ limitValueFields.push(yaxisField);
85
+ }
86
+ } else {
87
+ serieValue = {
88
+ uuid: item.uuid,
89
+ type: "fixed",
90
+ field: itemProps.yaxisFix,
91
+ data: [],
92
+ dynamicDatas: []
93
+ //动态系列数据
94
+ };
95
+ }
96
+ if (serieValue != null) {
97
+ serieValues.push(serieValue);
98
+ serieValueMap[item.uuid] = serieValue;
99
+ }
100
+ if (itemProps.dynamicSeriesField && // !groupFields.includes(itemProps.dynamicSeriesField) &&
101
+ !dynamicFileds.includes(itemProps.dynamicSeriesField) && serieValue && yaxisField) {
102
+ serieValue.dynamicField = itemProps.dynamicSeriesField;
103
+ serieValue.dynamicSeriesTitle = itemProps.dynamicSeriesTitle;
104
+ serieValue.dynamicShowStack = itemProps.dynamicShowStack;
105
+ dynamicFileds.push(itemProps.dynamicSeriesField);
106
+ dynamicValueField[itemProps.dynamicSeriesField] = yaxisField;
107
+ }
108
+ }
109
+ const dynamicLabelMap = {};
110
+ if (dynamicFileds.length > 0) {
111
+ const newDatas = [];
112
+ const dataMap = {};
113
+ for (let d of datas) {
114
+ if (!d) {
115
+ continue;
116
+ }
117
+ for (let valueField of allValueFields) {
118
+ const groupValue2 = d[CommonName.X_FIELD_NAME];
119
+ let newData = dataMap[groupValue2];
120
+ if (!newData) {
121
+ newData = {};
122
+ for (let gField of groupFields) {
123
+ newData[gField] = d[gField];
124
+ }
125
+ newData[CommonName.X_FIELD_NAME] = d[CommonName.X_FIELD_NAME];
126
+ dataMap[groupValue2] = newData;
127
+ newDatas.push(newData);
128
+ }
129
+ let newValue = getValueFromSource(d, valueField, void 0);
130
+ if (!isNaN(newValue)) {
131
+ const hisValue = newData[valueField];
132
+ if (!isNaN) {
133
+ newValue += hisValue;
134
+ }
135
+ newData[valueField] = newValue;
136
+ }
137
+ }
138
+ }
139
+ for (let dynamicField of dynamicFileds) {
140
+ const dynamicLabels = [];
141
+ for (let d of datas) {
142
+ if (!d) {
143
+ continue;
144
+ }
145
+ const groupValue2 = d[CommonName.X_FIELD_NAME];
146
+ let newData = dataMap[groupValue2];
147
+ if (!newData) {
148
+ continue;
149
+ }
150
+ let dynamicLabel = getValueFromSource(d, dynamicField, void 0);
151
+ dynamicLabel = dynamicLabel == null || dynamicLabel == void 0 ? "" : dynamicLabel;
152
+ if (!dynamicLabels.includes(dynamicLabel)) {
153
+ dynamicLabels.push(dynamicLabel);
154
+ limitValueFields.push(dynamicLabel);
155
+ }
156
+ const valueField = dynamicValueField[dynamicField];
157
+ let newValue = getValueFromSource(d, valueField, void 0);
158
+ if (!isNaN(newValue)) {
159
+ const hisValue = newData[dynamicLabel];
160
+ if (!isNaN) {
161
+ newValue += hisValue;
162
+ }
163
+ newData[dynamicLabel] = newValue;
164
+ }
165
+ }
166
+ dynamicLabelMap[dynamicField] = dynamicLabels;
167
+ }
168
+ datas = newDatas;
169
+ }
170
+ sortDatas(pageContext, configure, datas);
171
+ datas = limitDatas(pageContext, configure, datas, groupFields, limitValueFields);
172
+ const xValues = [];
173
+ const cumulativeMap = {};
174
+ for (let data of datas) {
175
+ if (!data) {
176
+ continue;
177
+ }
178
+ xValues.push(data[CommonName.X_FIELD_NAME]);
179
+ for (let item of serieValues) {
180
+ let serieData = item.data;
181
+ const dynamicDatas = item.dynamicDatas;
182
+ if (item.dynamicField) {
183
+ let dynamicLabels = dynamicLabelMap[item.dynamicField];
184
+ dynamicLabels = dynamicLabels ? dynamicLabels : [];
185
+ for (let i = 0; i < dynamicLabels.length; i++) {
186
+ if (i >= dynamicDatas.length) {
187
+ dynamicDatas.push([]);
188
+ }
189
+ serieData = dynamicDatas[i];
190
+ const fieldName = dynamicLabels[i];
191
+ let value = getValueFromSource(data, fieldName, void 0);
192
+ if (item.isCumulative) {
193
+ const hisKey = item.uuid + "_" + fieldName;
194
+ const hisValue = cumulativeMap[hisKey];
195
+ if (hisValue) {
196
+ value = hisValue + value;
197
+ }
198
+ cumulativeMap[hisKey] = value;
199
+ }
200
+ serieData.push(value);
201
+ }
202
+ } else if (item.type == "fixed") {
203
+ serieData.push(item.field);
204
+ } else if (item.type == "variable") {
205
+ let value = getValueFromSource(data, item.field, void 0);
206
+ if (item.isCumulative) {
207
+ const hisKey = item.uuid + "_field";
208
+ const hisValue = cumulativeMap[hisKey];
209
+ if (hisValue) {
210
+ value = hisValue + value;
211
+ }
212
+ cumulativeMap[hisKey] = value;
213
+ }
214
+ serieData.push(value);
215
+ } else {
216
+ serieData.push(void 0);
217
+ }
218
+ }
219
+ }
220
+ const defaultSeries = configure.defaultSeries;
221
+ const tempSeries = deepCopy(defaultSeries == null ? [] : defaultSeries);
222
+ const newSeries = [];
223
+ for (let serie of tempSeries) {
224
+ const serieValue = serieValueMap[serie.uuid];
225
+ if (serieValue.dynamicField) {
226
+ let dynamicLabels = dynamicLabelMap[serieValue.dynamicField];
227
+ dynamicLabels = dynamicLabels ? dynamicLabels : [];
228
+ const dynamicDatas = serieValue.dynamicDatas ? serieValue.dynamicDatas : [];
229
+ for (let i = 0; i < dynamicLabels.length; i++) {
230
+ let label = dynamicLabels[i];
231
+ const newSerie = deepCopy(serie);
232
+ if (serieValue.dynamicSeriesTitle) {
233
+ const dynamicSeriesTitle = serieValue.dynamicSeriesTitle.replace("${name}", label);
234
+ newSerie.name = formatVariableValue(pageContext, dynamicSeriesTitle);
235
+ } else {
236
+ newSerie.name = label;
237
+ }
238
+ newSerie.data = i < dynamicDatas.length ? dynamicDatas[i] : [];
239
+ if (serie.type == "bar" && serieValue.dynamicShowStack) {
240
+ newSerie.stack = serie.uuid;
241
+ }
242
+ newSeries.push(newSerie);
243
+ }
244
+ } else {
245
+ serie.data = serieValue ? serieValue.data : [];
246
+ newSeries.push(serie);
247
+ }
248
+ }
249
+ chartOption.series = newSeries;
250
+ const defaultXaxis = configure.defaultXaxis;
251
+ const defaultYaxis = configure.defaultYaxis;
252
+ if (chartOption.isBar) {
253
+ if (defaultYaxis) {
254
+ for (let tempYaxis of defaultYaxis) {
255
+ tempYaxis.data = xValues;
256
+ }
257
+ }
258
+ chartOption.xAxis = defaultXaxis;
259
+ chartOption.yAxis = defaultYaxis;
260
+ } else {
261
+ if (defaultXaxis && defaultXaxis.length > 0) {
262
+ defaultXaxis[0].data = xValues;
263
+ }
264
+ chartOption.xAxis = defaultXaxis;
265
+ chartOption.yAxis = defaultYaxis;
266
+ }
267
+ const selGroupVariable = configure.props ? configure.props.selGroupVariable : null;
268
+ const enableDrill = configure.props ? configure.props.enableDrill : null;
269
+ if (!enableDrill && selGroupVariable) {
270
+ configure.highlightInfos = [];
271
+ setValueForVariableName(pageContext.entity, selGroupVariable, null);
272
+ }
273
+ configure.groupFields = realGroupFilds;
274
+ configure.cacheDatas = datas;
275
+ configure.rawResult = resultData;
276
+ }
277
+ export {
278
+ updateChartOption
279
+ };
@@ -0,0 +1,74 @@
1
+ import { formatVariableValue, getValueFromSource } from "../page-helper-util.js";
2
+ import { deepCopy } from "../common-util.js";
3
+ function updateChartOption(pageContext, configure, chartOption, resultData) {
4
+ if (!resultData || !resultData.result) {
5
+ return;
6
+ }
7
+ const result = resultData && resultData.result ? resultData.result : {};
8
+ const dataSetField = configure.serviceDataField;
9
+ let datas = null;
10
+ if (dataSetField) {
11
+ datas = result[dataSetField];
12
+ } else {
13
+ if (result) {
14
+ datas = [result];
15
+ }
16
+ }
17
+ if (!datas) {
18
+ datas = [];
19
+ }
20
+ const nameSource = configure.props ? configure.props.nameSource : void 0;
21
+ const nameField = configure.props ? configure.props.nameField : void 0;
22
+ const nameFixed = configure.props ? configure.props.nameFixed : void 0;
23
+ const valueField = configure.props ? configure.props.yaxisField : void 0;
24
+ const groupFields = [nameField];
25
+ const xValues = [];
26
+ const yValues = [];
27
+ for (let d of datas) {
28
+ if (!d) {
29
+ continue;
30
+ }
31
+ let xValue = null;
32
+ if (nameSource == "fixed") {
33
+ xValue = formatVariableValue(pageContext, nameFixed);
34
+ } else {
35
+ xValue = getValueFromSource(d, nameField, void 0);
36
+ }
37
+ xValues.push(xValue);
38
+ const yValue = getValueFromSource(d, valueField, void 0);
39
+ yValues.push(yValue);
40
+ }
41
+ const defaultSeries = configure.defaultSeries;
42
+ let allColors = defaultSeries[0].pieColors;
43
+ allColors = allColors ? allColors : [];
44
+ let colorMap = defaultSeries[0].pieColorMap;
45
+ colorMap = colorMap ? colorMap : {};
46
+ const gaugeDatas = [];
47
+ for (let index = 0; index < xValues.length && index < yValues.length; index++) {
48
+ const data = {
49
+ value: yValues[index],
50
+ name: xValues[index]
51
+ };
52
+ if (index < allColors.length || colorMap[data.name]) {
53
+ let color = colorMap[data.name];
54
+ if (!color) {
55
+ color = allColors[index];
56
+ }
57
+ if (color) {
58
+ data.itemStyle = {
59
+ color
60
+ };
61
+ }
62
+ }
63
+ gaugeDatas.push(data);
64
+ }
65
+ const tempSeries = deepCopy(defaultSeries);
66
+ tempSeries[0].data = gaugeDatas;
67
+ chartOption.series = [tempSeries[0]];
68
+ configure.groupFields = groupFields;
69
+ configure.cacheDatas = datas;
70
+ configure.rawResult = resultData;
71
+ }
72
+ export {
73
+ updateChartOption
74
+ };
@@ -0,0 +1,118 @@
1
+ import { getValueFromSource, setValueForVariableName } from "../page-helper-util.js";
2
+ import { deepCopy } from "../common-util.js";
3
+ import { CommonName, sortDatas, limitDatas } from "./chart-util.js";
4
+ function updateChartOption(pageContext, configure, chartOption, resultData) {
5
+ if (!resultData || !resultData.result) {
6
+ return;
7
+ }
8
+ const result = resultData && resultData.result ? resultData.result : {};
9
+ const groupValue = resultData && resultData.groupValue ? resultData.groupValue : [];
10
+ const dataSetField = configure.serviceDataField;
11
+ let datas = null;
12
+ if (dataSetField) {
13
+ datas = result[dataSetField];
14
+ } else {
15
+ if (result) {
16
+ if (Array.isArray(result)) {
17
+ datas = result;
18
+ } else {
19
+ datas = [result];
20
+ }
21
+ }
22
+ }
23
+ if (!datas) {
24
+ datas = [];
25
+ }
26
+ let confGroups = configure.props ? configure.props.groups : null;
27
+ if (!confGroups) {
28
+ confGroups = [];
29
+ }
30
+ const groupMap = {};
31
+ const groupFields = [];
32
+ const realGroupFilds = [];
33
+ for (let g of confGroups) {
34
+ groupMap[g.group] = g.target;
35
+ if (g.target && !groupFields.includes(g.target)) {
36
+ groupFields.push(g.target);
37
+ if (groupValue.includes(g.group)) {
38
+ realGroupFilds.push(g.target);
39
+ }
40
+ }
41
+ }
42
+ let mulGroupShow = configure.props ? configure.props.mulGroupShow : "";
43
+ mulGroupShow = mulGroupShow == "break" ? "\r\n" : " ";
44
+ for (let d of datas) {
45
+ if (!d) {
46
+ continue;
47
+ }
48
+ const xValues2 = [];
49
+ for (let g of groupValue) {
50
+ const fieldName = groupMap[g];
51
+ const value = getValueFromSource(d, fieldName, void 0);
52
+ if (value) {
53
+ xValues2.push(value);
54
+ }
55
+ }
56
+ const xValue = xValues2.join(mulGroupShow);
57
+ d[CommonName.X_FIELD_NAME] = xValue;
58
+ }
59
+ const itemConfs = configure.items ? configure.items : [];
60
+ if (itemConfs.length == 0) {
61
+ console.log("饼图的系列为空,操作失败!", configure);
62
+ return;
63
+ }
64
+ const valueField = configure.props ? configure.props.yaxisField : null;
65
+ console.log("valueField", valueField);
66
+ itemConfs[0].props.yaxisField = valueField;
67
+ sortDatas(pageContext, configure, datas);
68
+ datas = limitDatas(pageContext, configure, datas, groupFields, [valueField]);
69
+ const xValues = [];
70
+ const yValues = [];
71
+ for (let data of datas) {
72
+ if (!data) {
73
+ continue;
74
+ }
75
+ xValues.push(data[CommonName.X_FIELD_NAME]);
76
+ let value = getValueFromSource(data, valueField, void 0);
77
+ yValues.push(value);
78
+ }
79
+ const defaultSeries = configure.defaultSeries;
80
+ let pieColors = defaultSeries[0].pieColors;
81
+ pieColors = pieColors ? pieColors : [];
82
+ let pieColorMap = defaultSeries[0].pieColorMap;
83
+ pieColorMap = pieColorMap ? pieColorMap : {};
84
+ const pieDatas = [];
85
+ for (let index = 0; index < xValues.length && index < yValues.length; index++) {
86
+ const data = {
87
+ value: yValues[index],
88
+ name: xValues[index]
89
+ };
90
+ if (index < pieColors.length || pieColorMap[data.name]) {
91
+ let color = pieColorMap[data.name];
92
+ if (!color) {
93
+ color = pieColors[index];
94
+ }
95
+ if (color) {
96
+ data.itemStyle = {
97
+ color
98
+ };
99
+ }
100
+ }
101
+ pieDatas.push(data);
102
+ }
103
+ const tempSeries = deepCopy(defaultSeries);
104
+ tempSeries[0].data = pieDatas;
105
+ chartOption.series = [tempSeries[0]];
106
+ const selGroupVariable = configure.props ? configure.props.selGroupVariable : null;
107
+ const enableDrill = configure.props ? configure.props.enableDrill : null;
108
+ if (!enableDrill && selGroupVariable) {
109
+ configure.highlightInfos = [];
110
+ setValueForVariableName(pageContext.entity, selGroupVariable, null);
111
+ }
112
+ configure.groupFields = realGroupFilds;
113
+ configure.cacheDatas = datas;
114
+ configure.rawResult = resultData;
115
+ }
116
+ export {
117
+ updateChartOption
118
+ };