yh-report 2.0.2 → 2.0.3
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/{StatementDesign-fa7f4a9e.mjs → StatementDesign-2eebfa27.mjs} +3 -3
- package/{StatementDesign-fa7f4a9e.mjs.map → StatementDesign-2eebfa27.mjs.map} +1 -1
- package/{StatementDetail-b9ae83e7.mjs → StatementDetail-9f40bb12.mjs} +3 -3
- package/{StatementDetail-b9ae83e7.mjs.map → StatementDetail-9f40bb12.mjs.map} +1 -1
- package/StatementList-c1b28d64.mjs +388 -0
- package/StatementList-c1b28d64.mjs.map +1 -0
- package/dayjs.min-fa6b7d57.mjs +1262 -0
- package/dayjs.min-fa6b7d57.mjs.map +1 -0
- package/index.es.js +4 -4
- package/package.json +1 -1
- package/report-run.vue_vue_type_style_index_0_lang-657964fa.mjs +1985 -0
- package/report-run.vue_vue_type_style_index_0_lang-657964fa.mjs.map +1 -0
- package/style.css +1 -1
- package/StatementList-d3110f6d.mjs +0 -317
- package/StatementList-d3110f6d.mjs.map +0 -1
- package/report-run.vue_vue_type_style_index_0_lang-edf7216b.mjs +0 -2281
- package/report-run.vue_vue_type_style_index_0_lang-edf7216b.mjs.map +0 -1
- package/util-53adc03c.mjs +0 -962
- package/util-53adc03c.mjs.map +0 -1
|
@@ -0,0 +1,1985 @@
|
|
|
1
|
+
import { ref, watch, nextTick, onMounted, onUnmounted, resolveDirective, withDirectives, openBlock, createElementBlock, defineComponent, createVNode, unref, withCtx, Fragment, renderList, createBlock, normalizeStyle, resolveDynamicComponent, createElementVNode, withKeys, vShow, renderSlot, computed, reactive, resolveComponent, createTextVNode, createCommentVNode, toDisplayString } from "vue";
|
|
2
|
+
import { ElForm, ElFormItem, ElOption, ElEmpty, ElButton } from "element-plus";
|
|
3
|
+
import { i as setYAxisData, j as setXAxisData, r as renderItem, d as dayjs, D as DataSourceColumnDataType, e as componentTransition, k as dayjs_minExports, l as commonjsGlobal, m as getDefaultExportFromCjs, C as CellType, F as FormatType, b as getConfig } from "./dayjs.min-fa6b7d57.mjs";
|
|
4
|
+
import axios from "@/libs/api.request.js";
|
|
5
|
+
import { cloneDeep } from "lodash-es";
|
|
6
|
+
import * as echarts from "echarts";
|
|
7
|
+
function getDateSourceList() {
|
|
8
|
+
return axios.request({
|
|
9
|
+
url: "/windowDesign/getDatasourceList",
|
|
10
|
+
method: "POST"
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
function getDateSourceColumns(r) {
|
|
14
|
+
return axios.request({
|
|
15
|
+
url: "/windowDesign/getColumns",
|
|
16
|
+
method: "POST",
|
|
17
|
+
data: {
|
|
18
|
+
datasourceId: r
|
|
19
|
+
}
|
|
20
|
+
}).then((t) => t.data && t.data.data ? Promise.resolve(t.data.data) : Promise.resolve([]));
|
|
21
|
+
}
|
|
22
|
+
function getDateSourceData(r, t = {
|
|
23
|
+
pageNumber: 1,
|
|
24
|
+
pageSize: 100
|
|
25
|
+
}) {
|
|
26
|
+
return axios.request({
|
|
27
|
+
url: `/report/data/${r}`,
|
|
28
|
+
type: "json",
|
|
29
|
+
method: "POST",
|
|
30
|
+
data: t
|
|
31
|
+
}).then((e) => {
|
|
32
|
+
var n;
|
|
33
|
+
return e != null && e.data && ((n = e.data) != null && n.data) ? Promise.resolve(e.data) : Promise.resolve([]);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
const chartsTypeList = ["line", "rowBar", "bar", "scatter", "treemap", "label"], getChartData = async (r, t) => {
|
|
37
|
+
const {
|
|
38
|
+
data: { source: e },
|
|
39
|
+
seriesData: n,
|
|
40
|
+
xAisData: a,
|
|
41
|
+
yAisData: s,
|
|
42
|
+
type: i
|
|
43
|
+
} = r;
|
|
44
|
+
let d = {
|
|
45
|
+
...t
|
|
46
|
+
};
|
|
47
|
+
for (let l = 0; l < e.length; l++) {
|
|
48
|
+
const { key: P, url: B } = e[l], E = (await getDateSourceData(B, {})).data;
|
|
49
|
+
d[P] = E;
|
|
50
|
+
}
|
|
51
|
+
if (Object.keys(d).length === 0)
|
|
52
|
+
return !1;
|
|
53
|
+
if (n) {
|
|
54
|
+
const P = new Function("allData", n)(d);
|
|
55
|
+
r.option.series.forEach((B) => {
|
|
56
|
+
B.data = P;
|
|
57
|
+
});
|
|
58
|
+
} else
|
|
59
|
+
r.option = setYAxisData(r, d);
|
|
60
|
+
if (chartsTypeList.includes(i)) {
|
|
61
|
+
if (a) {
|
|
62
|
+
const l = new Function("allData", a);
|
|
63
|
+
r.option.xAxis.data = l(d);
|
|
64
|
+
} else
|
|
65
|
+
r.option = setXAxisData(r, d);
|
|
66
|
+
if (s) {
|
|
67
|
+
const P = new Function("allData", s)(d);
|
|
68
|
+
r.option.yAxis.data = P;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}, chartItem_vue_vue_type_style_index_0_scoped_5bbf4c7d_lang = "", _export_sfc = (r, t) => {
|
|
72
|
+
const e = r.__vccOpts || r;
|
|
73
|
+
for (const [n, a] of t)
|
|
74
|
+
e[n] = a;
|
|
75
|
+
return e;
|
|
76
|
+
}, _sfc_main$4 = {
|
|
77
|
+
__name: "chart-item",
|
|
78
|
+
props: {
|
|
79
|
+
chartData: {
|
|
80
|
+
type: Object,
|
|
81
|
+
require: !0
|
|
82
|
+
},
|
|
83
|
+
isView: {
|
|
84
|
+
type: Boolean,
|
|
85
|
+
default: !1
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
setup(r, { expose: t }) {
|
|
89
|
+
const e = r, n = ref(), a = ref(null);
|
|
90
|
+
let s = null;
|
|
91
|
+
watch(
|
|
92
|
+
() => e.chartData.option,
|
|
93
|
+
(E) => {
|
|
94
|
+
s && s.setOption(E, {
|
|
95
|
+
notMerge: !0
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
{ deep: !0 }
|
|
99
|
+
), watch(
|
|
100
|
+
() => e.chartData.isSuspend,
|
|
101
|
+
(E) => {
|
|
102
|
+
E && B();
|
|
103
|
+
},
|
|
104
|
+
{ deep: !0 }
|
|
105
|
+
);
|
|
106
|
+
const i = ref(!1), d = (E) => {
|
|
107
|
+
if (a.value = E, E && Object.keys(E).length > 0) {
|
|
108
|
+
const H = cloneDeep(e.chartData);
|
|
109
|
+
l(H);
|
|
110
|
+
}
|
|
111
|
+
}, l = async (E) => {
|
|
112
|
+
e.isView && await getChartData(E, a.value), E.type === "label" && E.option.series.forEach((H) => {
|
|
113
|
+
H.renderItem = renderItem;
|
|
114
|
+
}), s.setOption(E.option), i.value = !1;
|
|
115
|
+
}, P = async () => {
|
|
116
|
+
i.value = !0, s = echarts.init(n.value);
|
|
117
|
+
let E = cloneDeep(e.chartData);
|
|
118
|
+
await l(E);
|
|
119
|
+
}, B = () => {
|
|
120
|
+
nextTick(() => {
|
|
121
|
+
s.resize();
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
return t({
|
|
125
|
+
setOutData: d
|
|
126
|
+
}), onMounted(() => {
|
|
127
|
+
P(), window.addEventListener("resize", B);
|
|
128
|
+
}), onUnmounted(() => {
|
|
129
|
+
window.removeEventListener("resize", B);
|
|
130
|
+
}), (E, H) => {
|
|
131
|
+
const Y = resolveDirective("loading");
|
|
132
|
+
return withDirectives((openBlock(), createElementBlock("div", {
|
|
133
|
+
ref_key: "chartRef",
|
|
134
|
+
ref: n,
|
|
135
|
+
"element-loading-text": "正在加载数据......",
|
|
136
|
+
class: "chart chart-common"
|
|
137
|
+
}, null, 512)), [
|
|
138
|
+
[Y, i.value]
|
|
139
|
+
]);
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}, chartItem = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-5bbf4c7d"]]);
|
|
143
|
+
function renderCellStyle(r) {
|
|
144
|
+
let t = "";
|
|
145
|
+
return Object.keys(r).forEach((e) => {
|
|
146
|
+
if (r[e])
|
|
147
|
+
switch (e) {
|
|
148
|
+
case "color":
|
|
149
|
+
t += `color:${r[e]};`;
|
|
150
|
+
break;
|
|
151
|
+
case "backgroundColor":
|
|
152
|
+
t += `background-color:${r[e]};`;
|
|
153
|
+
break;
|
|
154
|
+
case "fontWeight":
|
|
155
|
+
t += `font-weight:${r[e]};`;
|
|
156
|
+
break;
|
|
157
|
+
case "fontSize":
|
|
158
|
+
t += `font-size:${r[e]}px;`;
|
|
159
|
+
break;
|
|
160
|
+
case "textAlign":
|
|
161
|
+
t += `text-align:${r[e]};`;
|
|
162
|
+
break;
|
|
163
|
+
case "verticalAlign":
|
|
164
|
+
t += `vertical-align:${r[e]};`;
|
|
165
|
+
break;
|
|
166
|
+
case "fontFamily":
|
|
167
|
+
t += `font-family:${r[e]};`;
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
}), t;
|
|
171
|
+
}
|
|
172
|
+
function formatNumber(r, { numberDecimal: t, numberUseGrouping: e } = {}) {
|
|
173
|
+
typeof r == "string" && (r = r.replace(/,/g, "")), r = parseFloat(r), isNaN(r) && (r = 0);
|
|
174
|
+
const n = t === 0 ? Math.round(r) : r.toFixed(t);
|
|
175
|
+
if (e) {
|
|
176
|
+
const a = n.toString().split(".");
|
|
177
|
+
return a[0] = a[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","), a.join(".");
|
|
178
|
+
} else
|
|
179
|
+
return n;
|
|
180
|
+
}
|
|
181
|
+
function formatCurrency(r, { numberDecimal: t, currencySymbol: e, numberUseGrouping: n } = {}) {
|
|
182
|
+
if (typeof r == "string" && (r = r.replace(/,/g, "")), r = parseFloat(r), isNaN(r))
|
|
183
|
+
throw new Error("Invalid number input");
|
|
184
|
+
const a = t === 0 ? Math.round(r) : parseFloat(r.toFixed(t));
|
|
185
|
+
let [s, i] = a.toString().split(".");
|
|
186
|
+
n && (s = s.replace(/\B(?=(\d{3})+(?!\d))/g, ","));
|
|
187
|
+
let d = `${e}${s}`;
|
|
188
|
+
return t > 0 && (d += `.${i}`), d;
|
|
189
|
+
}
|
|
190
|
+
function formatPercentage(r, { numberDecimal: t } = {}, e = !1) {
|
|
191
|
+
if (typeof r == "string" && (r = r.replace(/,/g, "")), r = parseFloat(r), isNaN(r))
|
|
192
|
+
return r;
|
|
193
|
+
const n = t === 0 ? Math.round(r) : r.toFixed(t);
|
|
194
|
+
return e ? `${n}‰` : `${n}%`;
|
|
195
|
+
}
|
|
196
|
+
function formatScientific(r, { scientificNotation: t = "e", digits: e = 6 } = {}) {
|
|
197
|
+
return typeof r == "string" && (r = r.replace(/,/g, "")), r = parseFloat(r), isNaN(r) ? r : r.toExponential(e).replace(/e/, t);
|
|
198
|
+
}
|
|
199
|
+
function formatDatetime(r, { date: t = "YYYY-MM-DD HH:mm:ss" } = {}) {
|
|
200
|
+
if (r == null)
|
|
201
|
+
return r;
|
|
202
|
+
let e;
|
|
203
|
+
if (typeof r == "number") {
|
|
204
|
+
const n = r < 1e10 ? r * 1e3 : r;
|
|
205
|
+
e = dayjs(n);
|
|
206
|
+
} else if (typeof r == "string") {
|
|
207
|
+
const n = Number(r);
|
|
208
|
+
if (isNaN(n))
|
|
209
|
+
e = dayjs(r);
|
|
210
|
+
else {
|
|
211
|
+
const a = n < 1e10 ? n * 1e3 : n;
|
|
212
|
+
e = dayjs(a);
|
|
213
|
+
}
|
|
214
|
+
} else
|
|
215
|
+
return r;
|
|
216
|
+
return e.isValid() ? e.format(t) : r;
|
|
217
|
+
}
|
|
218
|
+
function formatCellValue(r, t, e) {
|
|
219
|
+
switch (t) {
|
|
220
|
+
case "number":
|
|
221
|
+
return formatNumber(r, e);
|
|
222
|
+
case "currency":
|
|
223
|
+
return formatCurrency(r, e);
|
|
224
|
+
case "percent":
|
|
225
|
+
return formatPercentage(r, e, !1);
|
|
226
|
+
case "promille":
|
|
227
|
+
return formatPercentage(r, e, !0);
|
|
228
|
+
case "scientific":
|
|
229
|
+
return formatScientific(r, e);
|
|
230
|
+
case "datetime":
|
|
231
|
+
return formatDatetime(r, e);
|
|
232
|
+
default:
|
|
233
|
+
return r;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
const _hoisted_1$1 = { class: "yh-statement-view-conditions" }, _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
237
|
+
__name: "report-conditions",
|
|
238
|
+
props: {
|
|
239
|
+
config: null
|
|
240
|
+
},
|
|
241
|
+
emits: ["change"],
|
|
242
|
+
setup(r, { emit: t }) {
|
|
243
|
+
const e = r, n = dayjs().startOf("day").format("YYYY-MM-DD HH:mm:ss"), a = dayjs().endOf("day").format("YYYY-MM-DD HH:mm:ss"), s = dayjs().startOf("month").format("YYYY-MM-DD HH:mm:ss"), i = dayjs().endOf("month").format("YYYY-MM-DD HH:mm:ss"), d = dayjs().add(-2, "month").startOf("month").format("YYYY-MM-DD HH:mm:ss"), l = dayjs().endOf("month").format("YYYY-MM-DD HH:mm:ss"), P = dayjs().startOf("year").format("YYYY-MM-DD HH:mm:ss"), B = dayjs().endOf("year").format("YYYY-MM-DD HH:mm:ss"), E = ref([]), H = ref([]);
|
|
244
|
+
watch(
|
|
245
|
+
() => e.config,
|
|
246
|
+
() => {
|
|
247
|
+
Y();
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
immediate: !0,
|
|
251
|
+
deep: !0
|
|
252
|
+
}
|
|
253
|
+
);
|
|
254
|
+
function Y() {
|
|
255
|
+
let L = [];
|
|
256
|
+
if (E.value = [], e.config && e.config.length) {
|
|
257
|
+
for (let F = 0; F < e.config.length; F++) {
|
|
258
|
+
const k = cloneDeep(e.config[F]);
|
|
259
|
+
let { dataType: V, dateType: re, type: Z, selectorId: q, name: ne, columnName: X, defaultValue: Q, isNull: ee } = k, te = [DataSourceColumnDataType.DATE, DataSourceColumnDataType.DATETIME].includes(V);
|
|
260
|
+
const { componentName: u, placeholerPrefix: c, type: p } = componentTransition(V, re);
|
|
261
|
+
k.formItemType = u, k.placeholder = c + ne || X, p && (k.type = p), k.optionData = [];
|
|
262
|
+
let m = Q || "";
|
|
263
|
+
if (te)
|
|
264
|
+
switch (Q) {
|
|
265
|
+
case "today":
|
|
266
|
+
m = n;
|
|
267
|
+
break;
|
|
268
|
+
case "thisMonth":
|
|
269
|
+
m = s;
|
|
270
|
+
break;
|
|
271
|
+
case "threeMonth":
|
|
272
|
+
m = d;
|
|
273
|
+
break;
|
|
274
|
+
case "thisYear":
|
|
275
|
+
m = P;
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
if (k.value = m, E.value.push({
|
|
279
|
+
name: X,
|
|
280
|
+
value: m,
|
|
281
|
+
type: Z,
|
|
282
|
+
isNull: ee
|
|
283
|
+
}), q && axios.request({
|
|
284
|
+
url: `/windowDesign/getSelectorList?selectorId=${q}`,
|
|
285
|
+
method: "POST"
|
|
286
|
+
}).then((h) => {
|
|
287
|
+
h.data && h.data.data && (k.optionData = h.data.data.map(({ name: g, value: R }) => ({
|
|
288
|
+
label: g,
|
|
289
|
+
value: R
|
|
290
|
+
})));
|
|
291
|
+
}), L.push(k), Z === "LT_GT_EQ") {
|
|
292
|
+
k.placeholder = c + "开始";
|
|
293
|
+
const h = cloneDeep(k);
|
|
294
|
+
h.name = "-", h.columnName = `end_${X}`, h.placeholder = c + "结束";
|
|
295
|
+
let g = Q || "";
|
|
296
|
+
if (te)
|
|
297
|
+
switch (Q) {
|
|
298
|
+
case "today":
|
|
299
|
+
g = a;
|
|
300
|
+
break;
|
|
301
|
+
case "thisMonth":
|
|
302
|
+
g = i;
|
|
303
|
+
break;
|
|
304
|
+
case "threeMonth":
|
|
305
|
+
g = l;
|
|
306
|
+
break;
|
|
307
|
+
case "thisYear":
|
|
308
|
+
g = B;
|
|
309
|
+
break;
|
|
310
|
+
}
|
|
311
|
+
E.value.push({
|
|
312
|
+
name: `end_${X}`,
|
|
313
|
+
value: g,
|
|
314
|
+
type: Z,
|
|
315
|
+
isNull: ee
|
|
316
|
+
}), q && axios.request({
|
|
317
|
+
url: `/windowDesign/getSelectorList?selectorId=${q}`,
|
|
318
|
+
method: "POST"
|
|
319
|
+
}).then((R) => {
|
|
320
|
+
R.data && R.data.data && (h.optionData = R.data.data.map(({ name: v, value: o }) => ({
|
|
321
|
+
label: v,
|
|
322
|
+
value: o
|
|
323
|
+
})));
|
|
324
|
+
}), L.push(h);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
e.config.map((F) => F.isNull).includes(!0) && nextTick(() => {
|
|
328
|
+
t("change", E.value);
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
H.value = L;
|
|
332
|
+
}
|
|
333
|
+
function z(L, F) {
|
|
334
|
+
let k = E.value.findIndex((V) => V.name === F.columnName);
|
|
335
|
+
F.value = L, E.value[k].value = L, ["ElSelect", "ElTreeSelect", "ElSwitch", "ElDatePicker", "ElTimePicker", "ElColorPicker"].includes(F.formItemType) && t("change", E.value);
|
|
336
|
+
}
|
|
337
|
+
function j(L) {
|
|
338
|
+
["ElInput", "ElInputNumber"].includes(L.formItemType) && t("change", E.value);
|
|
339
|
+
}
|
|
340
|
+
return (L, F) => (openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
341
|
+
createVNode(unref(ElForm), { inline: "" }, {
|
|
342
|
+
default: withCtx(() => [
|
|
343
|
+
(openBlock(!0), createElementBlock(Fragment, null, renderList(H.value, (k) => withDirectives((openBlock(), createBlock(unref(ElFormItem), {
|
|
344
|
+
label: k.name,
|
|
345
|
+
style: normalizeStyle(k.columnName.indexOf("end_") > -1 ? { marginLeft: "-22px" } : {})
|
|
346
|
+
}, {
|
|
347
|
+
default: withCtx(() => [
|
|
348
|
+
k.formItemType === "ElSelect" ? (openBlock(), createBlock(resolveDynamicComponent(k.formItemType), {
|
|
349
|
+
key: 0,
|
|
350
|
+
"model-value": k.value,
|
|
351
|
+
type: k.type,
|
|
352
|
+
clearable: "",
|
|
353
|
+
placeholder: k.placeholder,
|
|
354
|
+
"onUpdate:modelValue": (V) => z(V, k)
|
|
355
|
+
}, {
|
|
356
|
+
default: withCtx(() => [
|
|
357
|
+
createElementVNode("template", null, [
|
|
358
|
+
(openBlock(!0), createElementBlock(Fragment, null, renderList(k.optionData, (V) => (openBlock(), createBlock(unref(ElOption), {
|
|
359
|
+
label: V.label,
|
|
360
|
+
value: V.value
|
|
361
|
+
}, null, 8, ["label", "value"]))), 256))
|
|
362
|
+
])
|
|
363
|
+
]),
|
|
364
|
+
_: 2
|
|
365
|
+
}, 1032, ["model-value", "type", "placeholder", "onUpdate:modelValue"])) : (openBlock(), createBlock(resolveDynamicComponent(k.formItemType), {
|
|
366
|
+
key: 1,
|
|
367
|
+
"model-value": k.value,
|
|
368
|
+
type: k.type,
|
|
369
|
+
clearable: "",
|
|
370
|
+
"value-format": "YYYY-MM-DD HH:mm:ss",
|
|
371
|
+
placeholder: k.placeholder,
|
|
372
|
+
onBlur: (V) => j(k),
|
|
373
|
+
onKeyup: withKeys((V) => j(k), ["enter"]),
|
|
374
|
+
"onUpdate:modelValue": (V) => z(V, k)
|
|
375
|
+
}, null, 40, ["model-value", "type", "placeholder", "onBlur", "onKeyup", "onUpdate:modelValue"]))
|
|
376
|
+
]),
|
|
377
|
+
_: 2
|
|
378
|
+
}, 1032, ["label", "style"])), [
|
|
379
|
+
[vShow, k.isShow]
|
|
380
|
+
])), 256))
|
|
381
|
+
]),
|
|
382
|
+
_: 1
|
|
383
|
+
}),
|
|
384
|
+
renderSlot(L.$slots, "search")
|
|
385
|
+
]));
|
|
386
|
+
}
|
|
387
|
+
}), reportConditions_vue_vue_type_style_index_0_lang = "";
|
|
388
|
+
var zhCn$1 = { exports: {} };
|
|
389
|
+
(function(r, t) {
|
|
390
|
+
(function(e, n) {
|
|
391
|
+
r.exports = n(dayjs_minExports);
|
|
392
|
+
})(commonjsGlobal, function(e) {
|
|
393
|
+
function n(i) {
|
|
394
|
+
return i && typeof i == "object" && "default" in i ? i : { default: i };
|
|
395
|
+
}
|
|
396
|
+
var a = n(e), s = { name: "zh-cn", weekdays: "星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"), weekdaysShort: "周日_周一_周二_周三_周四_周五_周六".split("_"), weekdaysMin: "日_一_二_三_四_五_六".split("_"), months: "一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"), monthsShort: "1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"), ordinal: function(i, d) {
|
|
397
|
+
return d === "W" ? i + "周" : i + "日";
|
|
398
|
+
}, weekStart: 1, yearStart: 4, formats: { LT: "HH:mm", LTS: "HH:mm:ss", L: "YYYY/MM/DD", LL: "YYYY年M月D日", LLL: "YYYY年M月D日Ah点mm分", LLLL: "YYYY年M月D日ddddAh点mm分", l: "YYYY/M/D", ll: "YYYY年M月D日", lll: "YYYY年M月D日 HH:mm", llll: "YYYY年M月D日dddd HH:mm" }, relativeTime: { future: "%s内", past: "%s前", s: "几秒", m: "1 分钟", mm: "%d 分钟", h: "1 小时", hh: "%d 小时", d: "1 天", dd: "%d 天", M: "1 个月", MM: "%d 个月", y: "1 年", yy: "%d 年" }, meridiem: function(i, d) {
|
|
399
|
+
var l = 100 * i + d;
|
|
400
|
+
return l < 600 ? "凌晨" : l < 900 ? "早上" : l < 1100 ? "上午" : l < 1300 ? "中午" : l < 1800 ? "下午" : "晚上";
|
|
401
|
+
} };
|
|
402
|
+
return a.default.locale(s, null, !0), s;
|
|
403
|
+
});
|
|
404
|
+
})(zhCn$1);
|
|
405
|
+
var zhCnExports = zhCn$1.exports;
|
|
406
|
+
const zhCn = /* @__PURE__ */ getDefaultExportFromCjs(zhCnExports);
|
|
407
|
+
dayjs.locale(zhCn);
|
|
408
|
+
async function getProcessData(processData, data, params) {
|
|
409
|
+
try {
|
|
410
|
+
const fun = function(axios, dayjs) {
|
|
411
|
+
return eval(
|
|
412
|
+
`async (allData, params) => {
|
|
413
|
+
${processData}
|
|
414
|
+
}`
|
|
415
|
+
);
|
|
416
|
+
}(axios, dayjs);
|
|
417
|
+
return await fun.call(this, data, params);
|
|
418
|
+
} catch (r) {
|
|
419
|
+
return console.error(r), data;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
class Hooks {
|
|
423
|
+
/**
|
|
424
|
+
* @callback HookCallback
|
|
425
|
+
* @this {*|Jsep} this
|
|
426
|
+
* @param {Jsep} env
|
|
427
|
+
* @returns: void
|
|
428
|
+
*/
|
|
429
|
+
/**
|
|
430
|
+
* Adds the given callback to the list of callbacks for the given hook.
|
|
431
|
+
*
|
|
432
|
+
* The callback will be invoked when the hook it is registered for is run.
|
|
433
|
+
*
|
|
434
|
+
* One callback function can be registered to multiple hooks and the same hook multiple times.
|
|
435
|
+
*
|
|
436
|
+
* @param {string|object} name The name of the hook, or an object of callbacks keyed by name
|
|
437
|
+
* @param {HookCallback|boolean} callback The callback function which is given environment variables.
|
|
438
|
+
* @param {?boolean} [first=false] Will add the hook to the top of the list (defaults to the bottom)
|
|
439
|
+
* @public
|
|
440
|
+
*/
|
|
441
|
+
add(t, e, n) {
|
|
442
|
+
if (typeof arguments[0] != "string")
|
|
443
|
+
for (let a in arguments[0])
|
|
444
|
+
this.add(a, arguments[0][a], arguments[1]);
|
|
445
|
+
else
|
|
446
|
+
(Array.isArray(t) ? t : [t]).forEach(function(a) {
|
|
447
|
+
this[a] = this[a] || [], e && this[a][n ? "unshift" : "push"](e);
|
|
448
|
+
}, this);
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Runs a hook invoking all registered callbacks with the given environment variables.
|
|
452
|
+
*
|
|
453
|
+
* Callbacks will be invoked synchronously and in the order in which they were registered.
|
|
454
|
+
*
|
|
455
|
+
* @param {string} name The name of the hook.
|
|
456
|
+
* @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
|
|
457
|
+
* @public
|
|
458
|
+
*/
|
|
459
|
+
run(t, e) {
|
|
460
|
+
this[t] = this[t] || [], this[t].forEach(function(n) {
|
|
461
|
+
n.call(e && e.context ? e.context : e, e);
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
class Plugins {
|
|
466
|
+
constructor(t) {
|
|
467
|
+
this.jsep = t, this.registered = {};
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* @callback PluginSetup
|
|
471
|
+
* @this {Jsep} jsep
|
|
472
|
+
* @returns: void
|
|
473
|
+
*/
|
|
474
|
+
/**
|
|
475
|
+
* Adds the given plugin(s) to the registry
|
|
476
|
+
*
|
|
477
|
+
* @param {object} plugins
|
|
478
|
+
* @param {string} plugins.name The name of the plugin
|
|
479
|
+
* @param {PluginSetup} plugins.init The init function
|
|
480
|
+
* @public
|
|
481
|
+
*/
|
|
482
|
+
register(...t) {
|
|
483
|
+
t.forEach((e) => {
|
|
484
|
+
if (typeof e != "object" || !e.name || !e.init)
|
|
485
|
+
throw new Error("Invalid JSEP plugin format");
|
|
486
|
+
this.registered[e.name] || (e.init(this.jsep), this.registered[e.name] = e);
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
class Jsep {
|
|
491
|
+
/**
|
|
492
|
+
* @returns {string}
|
|
493
|
+
*/
|
|
494
|
+
static get version() {
|
|
495
|
+
return "1.4.0";
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* @returns {string}
|
|
499
|
+
*/
|
|
500
|
+
static toString() {
|
|
501
|
+
return "JavaScript Expression Parser (JSEP) v" + Jsep.version;
|
|
502
|
+
}
|
|
503
|
+
// ==================== CONFIG ================================
|
|
504
|
+
/**
|
|
505
|
+
* @method addUnaryOp
|
|
506
|
+
* @param {string} op_name The name of the unary op to add
|
|
507
|
+
* @returns {Jsep}
|
|
508
|
+
*/
|
|
509
|
+
static addUnaryOp(t) {
|
|
510
|
+
return Jsep.max_unop_len = Math.max(t.length, Jsep.max_unop_len), Jsep.unary_ops[t] = 1, Jsep;
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* @method jsep.addBinaryOp
|
|
514
|
+
* @param {string} op_name The name of the binary op to add
|
|
515
|
+
* @param {number} precedence The precedence of the binary op (can be a float). Higher number = higher precedence
|
|
516
|
+
* @param {boolean} [isRightAssociative=false] whether operator is right-associative
|
|
517
|
+
* @returns {Jsep}
|
|
518
|
+
*/
|
|
519
|
+
static addBinaryOp(t, e, n) {
|
|
520
|
+
return Jsep.max_binop_len = Math.max(t.length, Jsep.max_binop_len), Jsep.binary_ops[t] = e, n ? Jsep.right_associative.add(t) : Jsep.right_associative.delete(t), Jsep;
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* @method addIdentifierChar
|
|
524
|
+
* @param {string} char The additional character to treat as a valid part of an identifier
|
|
525
|
+
* @returns {Jsep}
|
|
526
|
+
*/
|
|
527
|
+
static addIdentifierChar(t) {
|
|
528
|
+
return Jsep.additional_identifier_chars.add(t), Jsep;
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* @method addLiteral
|
|
532
|
+
* @param {string} literal_name The name of the literal to add
|
|
533
|
+
* @param {*} literal_value The value of the literal
|
|
534
|
+
* @returns {Jsep}
|
|
535
|
+
*/
|
|
536
|
+
static addLiteral(t, e) {
|
|
537
|
+
return Jsep.literals[t] = e, Jsep;
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* @method removeUnaryOp
|
|
541
|
+
* @param {string} op_name The name of the unary op to remove
|
|
542
|
+
* @returns {Jsep}
|
|
543
|
+
*/
|
|
544
|
+
static removeUnaryOp(t) {
|
|
545
|
+
return delete Jsep.unary_ops[t], t.length === Jsep.max_unop_len && (Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops)), Jsep;
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* @method removeAllUnaryOps
|
|
549
|
+
* @returns {Jsep}
|
|
550
|
+
*/
|
|
551
|
+
static removeAllUnaryOps() {
|
|
552
|
+
return Jsep.unary_ops = {}, Jsep.max_unop_len = 0, Jsep;
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* @method removeIdentifierChar
|
|
556
|
+
* @param {string} char The additional character to stop treating as a valid part of an identifier
|
|
557
|
+
* @returns {Jsep}
|
|
558
|
+
*/
|
|
559
|
+
static removeIdentifierChar(t) {
|
|
560
|
+
return Jsep.additional_identifier_chars.delete(t), Jsep;
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* @method removeBinaryOp
|
|
564
|
+
* @param {string} op_name The name of the binary op to remove
|
|
565
|
+
* @returns {Jsep}
|
|
566
|
+
*/
|
|
567
|
+
static removeBinaryOp(t) {
|
|
568
|
+
return delete Jsep.binary_ops[t], t.length === Jsep.max_binop_len && (Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops)), Jsep.right_associative.delete(t), Jsep;
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* @method removeAllBinaryOps
|
|
572
|
+
* @returns {Jsep}
|
|
573
|
+
*/
|
|
574
|
+
static removeAllBinaryOps() {
|
|
575
|
+
return Jsep.binary_ops = {}, Jsep.max_binop_len = 0, Jsep;
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* @method removeLiteral
|
|
579
|
+
* @param {string} literal_name The name of the literal to remove
|
|
580
|
+
* @returns {Jsep}
|
|
581
|
+
*/
|
|
582
|
+
static removeLiteral(t) {
|
|
583
|
+
return delete Jsep.literals[t], Jsep;
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* @method removeAllLiterals
|
|
587
|
+
* @returns {Jsep}
|
|
588
|
+
*/
|
|
589
|
+
static removeAllLiterals() {
|
|
590
|
+
return Jsep.literals = {}, Jsep;
|
|
591
|
+
}
|
|
592
|
+
// ==================== END CONFIG ============================
|
|
593
|
+
/**
|
|
594
|
+
* @returns {string}
|
|
595
|
+
*/
|
|
596
|
+
get char() {
|
|
597
|
+
return this.expr.charAt(this.index);
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* @returns {number}
|
|
601
|
+
*/
|
|
602
|
+
get code() {
|
|
603
|
+
return this.expr.charCodeAt(this.index);
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
* @param {string} expr a string with the passed in express
|
|
607
|
+
* @returns Jsep
|
|
608
|
+
*/
|
|
609
|
+
constructor(t) {
|
|
610
|
+
this.expr = t, this.index = 0;
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* static top-level parser
|
|
614
|
+
* @returns {jsep.Expression}
|
|
615
|
+
*/
|
|
616
|
+
static parse(t) {
|
|
617
|
+
return new Jsep(t).parse();
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* Get the longest key length of any object
|
|
621
|
+
* @param {object} obj
|
|
622
|
+
* @returns {number}
|
|
623
|
+
*/
|
|
624
|
+
static getMaxKeyLen(t) {
|
|
625
|
+
return Math.max(0, ...Object.keys(t).map((e) => e.length));
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* `ch` is a character code in the next three functions
|
|
629
|
+
* @param {number} ch
|
|
630
|
+
* @returns {boolean}
|
|
631
|
+
*/
|
|
632
|
+
static isDecimalDigit(t) {
|
|
633
|
+
return t >= 48 && t <= 57;
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Returns the precedence of a binary operator or `0` if it isn't a binary operator. Can be float.
|
|
637
|
+
* @param {string} op_val
|
|
638
|
+
* @returns {number}
|
|
639
|
+
*/
|
|
640
|
+
static binaryPrecedence(t) {
|
|
641
|
+
return Jsep.binary_ops[t] || 0;
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* Looks for start of identifier
|
|
645
|
+
* @param {number} ch
|
|
646
|
+
* @returns {boolean}
|
|
647
|
+
*/
|
|
648
|
+
static isIdentifierStart(t) {
|
|
649
|
+
return t >= 65 && t <= 90 || // A...Z
|
|
650
|
+
t >= 97 && t <= 122 || // a...z
|
|
651
|
+
t >= 128 && !Jsep.binary_ops[String.fromCharCode(t)] || // any non-ASCII that is not an operator
|
|
652
|
+
Jsep.additional_identifier_chars.has(String.fromCharCode(t));
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* @param {number} ch
|
|
656
|
+
* @returns {boolean}
|
|
657
|
+
*/
|
|
658
|
+
static isIdentifierPart(t) {
|
|
659
|
+
return Jsep.isIdentifierStart(t) || Jsep.isDecimalDigit(t);
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* throw error at index of the expression
|
|
663
|
+
* @param {string} message
|
|
664
|
+
* @throws
|
|
665
|
+
*/
|
|
666
|
+
throwError(t) {
|
|
667
|
+
const e = new Error(t + " at character " + this.index);
|
|
668
|
+
throw e.index = this.index, e.description = t, e;
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* Run a given hook
|
|
672
|
+
* @param {string} name
|
|
673
|
+
* @param {jsep.Expression|false} [node]
|
|
674
|
+
* @returns {?jsep.Expression}
|
|
675
|
+
*/
|
|
676
|
+
runHook(t, e) {
|
|
677
|
+
if (Jsep.hooks[t]) {
|
|
678
|
+
const n = { context: this, node: e };
|
|
679
|
+
return Jsep.hooks.run(t, n), n.node;
|
|
680
|
+
}
|
|
681
|
+
return e;
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Runs a given hook until one returns a node
|
|
685
|
+
* @param {string} name
|
|
686
|
+
* @returns {?jsep.Expression}
|
|
687
|
+
*/
|
|
688
|
+
searchHook(t) {
|
|
689
|
+
if (Jsep.hooks[t]) {
|
|
690
|
+
const e = { context: this };
|
|
691
|
+
return Jsep.hooks[t].find(function(n) {
|
|
692
|
+
return n.call(e.context, e), e.node;
|
|
693
|
+
}), e.node;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
/**
|
|
697
|
+
* Push `index` up to the next non-space character
|
|
698
|
+
*/
|
|
699
|
+
gobbleSpaces() {
|
|
700
|
+
let t = this.code;
|
|
701
|
+
for (; t === Jsep.SPACE_CODE || t === Jsep.TAB_CODE || t === Jsep.LF_CODE || t === Jsep.CR_CODE; )
|
|
702
|
+
t = this.expr.charCodeAt(++this.index);
|
|
703
|
+
this.runHook("gobble-spaces");
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* Top-level method to parse all expressions and returns compound or single node
|
|
707
|
+
* @returns {jsep.Expression}
|
|
708
|
+
*/
|
|
709
|
+
parse() {
|
|
710
|
+
this.runHook("before-all");
|
|
711
|
+
const t = this.gobbleExpressions(), e = t.length === 1 ? t[0] : {
|
|
712
|
+
type: Jsep.COMPOUND,
|
|
713
|
+
body: t
|
|
714
|
+
};
|
|
715
|
+
return this.runHook("after-all", e);
|
|
716
|
+
}
|
|
717
|
+
/**
|
|
718
|
+
* top-level parser (but can be reused within as well)
|
|
719
|
+
* @param {number} [untilICode]
|
|
720
|
+
* @returns {jsep.Expression[]}
|
|
721
|
+
*/
|
|
722
|
+
gobbleExpressions(t) {
|
|
723
|
+
let e = [], n, a;
|
|
724
|
+
for (; this.index < this.expr.length; )
|
|
725
|
+
if (n = this.code, n === Jsep.SEMCOL_CODE || n === Jsep.COMMA_CODE)
|
|
726
|
+
this.index++;
|
|
727
|
+
else if (a = this.gobbleExpression())
|
|
728
|
+
e.push(a);
|
|
729
|
+
else if (this.index < this.expr.length) {
|
|
730
|
+
if (n === t)
|
|
731
|
+
break;
|
|
732
|
+
this.throwError('Unexpected "' + this.char + '"');
|
|
733
|
+
}
|
|
734
|
+
return e;
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* The main parsing function.
|
|
738
|
+
* @returns {?jsep.Expression}
|
|
739
|
+
*/
|
|
740
|
+
gobbleExpression() {
|
|
741
|
+
const t = this.searchHook("gobble-expression") || this.gobbleBinaryExpression();
|
|
742
|
+
return this.gobbleSpaces(), this.runHook("after-expression", t);
|
|
743
|
+
}
|
|
744
|
+
/**
|
|
745
|
+
* Search for the operation portion of the string (e.g. `+`, `===`)
|
|
746
|
+
* Start by taking the longest possible binary operations (3 characters: `===`, `!==`, `>>>`)
|
|
747
|
+
* and move down from 3 to 2 to 1 character until a matching binary operation is found
|
|
748
|
+
* then, return that binary operation
|
|
749
|
+
* @returns {string|boolean}
|
|
750
|
+
*/
|
|
751
|
+
gobbleBinaryOp() {
|
|
752
|
+
this.gobbleSpaces();
|
|
753
|
+
let t = this.expr.substr(this.index, Jsep.max_binop_len), e = t.length;
|
|
754
|
+
for (; e > 0; ) {
|
|
755
|
+
if (Jsep.binary_ops.hasOwnProperty(t) && (!Jsep.isIdentifierStart(this.code) || this.index + t.length < this.expr.length && !Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + t.length))))
|
|
756
|
+
return this.index += e, t;
|
|
757
|
+
t = t.substr(0, --e);
|
|
758
|
+
}
|
|
759
|
+
return !1;
|
|
760
|
+
}
|
|
761
|
+
/**
|
|
762
|
+
* This function is responsible for gobbling an individual expression,
|
|
763
|
+
* e.g. `1`, `1+2`, `a+(b*2)-Math.sqrt(2)`
|
|
764
|
+
* @returns {?jsep.BinaryExpression}
|
|
765
|
+
*/
|
|
766
|
+
gobbleBinaryExpression() {
|
|
767
|
+
let t, e, n, a, s, i, d, l, P;
|
|
768
|
+
if (i = this.gobbleToken(), !i || (e = this.gobbleBinaryOp(), !e))
|
|
769
|
+
return i;
|
|
770
|
+
for (s = { value: e, prec: Jsep.binaryPrecedence(e), right_a: Jsep.right_associative.has(e) }, d = this.gobbleToken(), d || this.throwError("Expected expression after " + e), a = [i, s, d]; e = this.gobbleBinaryOp(); ) {
|
|
771
|
+
if (n = Jsep.binaryPrecedence(e), n === 0) {
|
|
772
|
+
this.index -= e.length;
|
|
773
|
+
break;
|
|
774
|
+
}
|
|
775
|
+
s = { value: e, prec: n, right_a: Jsep.right_associative.has(e) }, P = e;
|
|
776
|
+
const B = (E) => s.right_a && E.right_a ? n > E.prec : n <= E.prec;
|
|
777
|
+
for (; a.length > 2 && B(a[a.length - 2]); )
|
|
778
|
+
d = a.pop(), e = a.pop().value, i = a.pop(), t = {
|
|
779
|
+
type: Jsep.BINARY_EXP,
|
|
780
|
+
operator: e,
|
|
781
|
+
left: i,
|
|
782
|
+
right: d
|
|
783
|
+
}, a.push(t);
|
|
784
|
+
t = this.gobbleToken(), t || this.throwError("Expected expression after " + P), a.push(s, t);
|
|
785
|
+
}
|
|
786
|
+
for (l = a.length - 1, t = a[l]; l > 1; )
|
|
787
|
+
t = {
|
|
788
|
+
type: Jsep.BINARY_EXP,
|
|
789
|
+
operator: a[l - 1].value,
|
|
790
|
+
left: a[l - 2],
|
|
791
|
+
right: t
|
|
792
|
+
}, l -= 2;
|
|
793
|
+
return t;
|
|
794
|
+
}
|
|
795
|
+
/**
|
|
796
|
+
* An individual part of a binary expression:
|
|
797
|
+
* e.g. `foo.bar(baz)`, `1`, `"abc"`, `(a % 2)` (because it's in parenthesis)
|
|
798
|
+
* @returns {boolean|jsep.Expression}
|
|
799
|
+
*/
|
|
800
|
+
gobbleToken() {
|
|
801
|
+
let t, e, n, a;
|
|
802
|
+
if (this.gobbleSpaces(), a = this.searchHook("gobble-token"), a)
|
|
803
|
+
return this.runHook("after-token", a);
|
|
804
|
+
if (t = this.code, Jsep.isDecimalDigit(t) || t === Jsep.PERIOD_CODE)
|
|
805
|
+
return this.gobbleNumericLiteral();
|
|
806
|
+
if (t === Jsep.SQUOTE_CODE || t === Jsep.DQUOTE_CODE)
|
|
807
|
+
a = this.gobbleStringLiteral();
|
|
808
|
+
else if (t === Jsep.OBRACK_CODE)
|
|
809
|
+
a = this.gobbleArray();
|
|
810
|
+
else {
|
|
811
|
+
for (e = this.expr.substr(this.index, Jsep.max_unop_len), n = e.length; n > 0; ) {
|
|
812
|
+
if (Jsep.unary_ops.hasOwnProperty(e) && (!Jsep.isIdentifierStart(this.code) || this.index + e.length < this.expr.length && !Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + e.length)))) {
|
|
813
|
+
this.index += n;
|
|
814
|
+
const s = this.gobbleToken();
|
|
815
|
+
return s || this.throwError("missing unaryOp argument"), this.runHook("after-token", {
|
|
816
|
+
type: Jsep.UNARY_EXP,
|
|
817
|
+
operator: e,
|
|
818
|
+
argument: s,
|
|
819
|
+
prefix: !0
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
e = e.substr(0, --n);
|
|
823
|
+
}
|
|
824
|
+
Jsep.isIdentifierStart(t) ? (a = this.gobbleIdentifier(), Jsep.literals.hasOwnProperty(a.name) ? a = {
|
|
825
|
+
type: Jsep.LITERAL,
|
|
826
|
+
value: Jsep.literals[a.name],
|
|
827
|
+
raw: a.name
|
|
828
|
+
} : a.name === Jsep.this_str && (a = { type: Jsep.THIS_EXP })) : t === Jsep.OPAREN_CODE && (a = this.gobbleGroup());
|
|
829
|
+
}
|
|
830
|
+
return a ? (a = this.gobbleTokenProperty(a), this.runHook("after-token", a)) : this.runHook("after-token", !1);
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Gobble properties of of identifiers/strings/arrays/groups.
|
|
834
|
+
* e.g. `foo`, `bar.baz`, `foo['bar'].baz`
|
|
835
|
+
* It also gobbles function calls:
|
|
836
|
+
* e.g. `Math.acos(obj.angle)`
|
|
837
|
+
* @param {jsep.Expression} node
|
|
838
|
+
* @returns {jsep.Expression}
|
|
839
|
+
*/
|
|
840
|
+
gobbleTokenProperty(t) {
|
|
841
|
+
this.gobbleSpaces();
|
|
842
|
+
let e = this.code;
|
|
843
|
+
for (; e === Jsep.PERIOD_CODE || e === Jsep.OBRACK_CODE || e === Jsep.OPAREN_CODE || e === Jsep.QUMARK_CODE; ) {
|
|
844
|
+
let n;
|
|
845
|
+
if (e === Jsep.QUMARK_CODE) {
|
|
846
|
+
if (this.expr.charCodeAt(this.index + 1) !== Jsep.PERIOD_CODE)
|
|
847
|
+
break;
|
|
848
|
+
n = !0, this.index += 2, this.gobbleSpaces(), e = this.code;
|
|
849
|
+
}
|
|
850
|
+
this.index++, e === Jsep.OBRACK_CODE ? (t = {
|
|
851
|
+
type: Jsep.MEMBER_EXP,
|
|
852
|
+
computed: !0,
|
|
853
|
+
object: t,
|
|
854
|
+
property: this.gobbleExpression()
|
|
855
|
+
}, t.property || this.throwError('Unexpected "' + this.char + '"'), this.gobbleSpaces(), e = this.code, e !== Jsep.CBRACK_CODE && this.throwError("Unclosed ["), this.index++) : e === Jsep.OPAREN_CODE ? t = {
|
|
856
|
+
type: Jsep.CALL_EXP,
|
|
857
|
+
arguments: this.gobbleArguments(Jsep.CPAREN_CODE),
|
|
858
|
+
callee: t
|
|
859
|
+
} : (e === Jsep.PERIOD_CODE || n) && (n && this.index--, this.gobbleSpaces(), t = {
|
|
860
|
+
type: Jsep.MEMBER_EXP,
|
|
861
|
+
computed: !1,
|
|
862
|
+
object: t,
|
|
863
|
+
property: this.gobbleIdentifier()
|
|
864
|
+
}), n && (t.optional = !0), this.gobbleSpaces(), e = this.code;
|
|
865
|
+
}
|
|
866
|
+
return t;
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* Parse simple numeric literals: `12`, `3.4`, `.5`. Do this by using a string to
|
|
870
|
+
* keep track of everything in the numeric literal and then calling `parseFloat` on that string
|
|
871
|
+
* @returns {jsep.Literal}
|
|
872
|
+
*/
|
|
873
|
+
gobbleNumericLiteral() {
|
|
874
|
+
let t = "", e, n;
|
|
875
|
+
for (; Jsep.isDecimalDigit(this.code); )
|
|
876
|
+
t += this.expr.charAt(this.index++);
|
|
877
|
+
if (this.code === Jsep.PERIOD_CODE)
|
|
878
|
+
for (t += this.expr.charAt(this.index++); Jsep.isDecimalDigit(this.code); )
|
|
879
|
+
t += this.expr.charAt(this.index++);
|
|
880
|
+
if (e = this.char, e === "e" || e === "E") {
|
|
881
|
+
for (t += this.expr.charAt(this.index++), e = this.char, (e === "+" || e === "-") && (t += this.expr.charAt(this.index++)); Jsep.isDecimalDigit(this.code); )
|
|
882
|
+
t += this.expr.charAt(this.index++);
|
|
883
|
+
Jsep.isDecimalDigit(this.expr.charCodeAt(this.index - 1)) || this.throwError("Expected exponent (" + t + this.char + ")");
|
|
884
|
+
}
|
|
885
|
+
return n = this.code, Jsep.isIdentifierStart(n) ? this.throwError("Variable names cannot start with a number (" + t + this.char + ")") : (n === Jsep.PERIOD_CODE || t.length === 1 && t.charCodeAt(0) === Jsep.PERIOD_CODE) && this.throwError("Unexpected period"), {
|
|
886
|
+
type: Jsep.LITERAL,
|
|
887
|
+
value: parseFloat(t),
|
|
888
|
+
raw: t
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* Parses a string literal, staring with single or double quotes with basic support for escape codes
|
|
893
|
+
* e.g. `"hello world"`, `'this is\nJSEP'`
|
|
894
|
+
* @returns {jsep.Literal}
|
|
895
|
+
*/
|
|
896
|
+
gobbleStringLiteral() {
|
|
897
|
+
let t = "";
|
|
898
|
+
const e = this.index, n = this.expr.charAt(this.index++);
|
|
899
|
+
let a = !1;
|
|
900
|
+
for (; this.index < this.expr.length; ) {
|
|
901
|
+
let s = this.expr.charAt(this.index++);
|
|
902
|
+
if (s === n) {
|
|
903
|
+
a = !0;
|
|
904
|
+
break;
|
|
905
|
+
} else if (s === "\\")
|
|
906
|
+
switch (s = this.expr.charAt(this.index++), s) {
|
|
907
|
+
case "n":
|
|
908
|
+
t += `
|
|
909
|
+
`;
|
|
910
|
+
break;
|
|
911
|
+
case "r":
|
|
912
|
+
t += "\r";
|
|
913
|
+
break;
|
|
914
|
+
case "t":
|
|
915
|
+
t += " ";
|
|
916
|
+
break;
|
|
917
|
+
case "b":
|
|
918
|
+
t += "\b";
|
|
919
|
+
break;
|
|
920
|
+
case "f":
|
|
921
|
+
t += "\f";
|
|
922
|
+
break;
|
|
923
|
+
case "v":
|
|
924
|
+
t += "\v";
|
|
925
|
+
break;
|
|
926
|
+
default:
|
|
927
|
+
t += s;
|
|
928
|
+
}
|
|
929
|
+
else
|
|
930
|
+
t += s;
|
|
931
|
+
}
|
|
932
|
+
return a || this.throwError('Unclosed quote after "' + t + '"'), {
|
|
933
|
+
type: Jsep.LITERAL,
|
|
934
|
+
value: t,
|
|
935
|
+
raw: this.expr.substring(e, this.index)
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
/**
|
|
939
|
+
* Gobbles only identifiers
|
|
940
|
+
* e.g.: `foo`, `_value`, `$x1`
|
|
941
|
+
* Also, this function checks if that identifier is a literal:
|
|
942
|
+
* (e.g. `true`, `false`, `null`) or `this`
|
|
943
|
+
* @returns {jsep.Identifier}
|
|
944
|
+
*/
|
|
945
|
+
gobbleIdentifier() {
|
|
946
|
+
let t = this.code, e = this.index;
|
|
947
|
+
for (Jsep.isIdentifierStart(t) ? this.index++ : this.throwError("Unexpected " + this.char); this.index < this.expr.length && (t = this.code, Jsep.isIdentifierPart(t)); )
|
|
948
|
+
this.index++;
|
|
949
|
+
return {
|
|
950
|
+
type: Jsep.IDENTIFIER,
|
|
951
|
+
name: this.expr.slice(e, this.index)
|
|
952
|
+
};
|
|
953
|
+
}
|
|
954
|
+
/**
|
|
955
|
+
* Gobbles a list of arguments within the context of a function call
|
|
956
|
+
* or array literal. This function also assumes that the opening character
|
|
957
|
+
* `(` or `[` has already been gobbled, and gobbles expressions and commas
|
|
958
|
+
* until the terminator character `)` or `]` is encountered.
|
|
959
|
+
* e.g. `foo(bar, baz)`, `my_func()`, or `[bar, baz]`
|
|
960
|
+
* @param {number} termination
|
|
961
|
+
* @returns {jsep.Expression[]}
|
|
962
|
+
*/
|
|
963
|
+
gobbleArguments(t) {
|
|
964
|
+
const e = [];
|
|
965
|
+
let n = !1, a = 0;
|
|
966
|
+
for (; this.index < this.expr.length; ) {
|
|
967
|
+
this.gobbleSpaces();
|
|
968
|
+
let s = this.code;
|
|
969
|
+
if (s === t) {
|
|
970
|
+
n = !0, this.index++, t === Jsep.CPAREN_CODE && a && a >= e.length && this.throwError("Unexpected token " + String.fromCharCode(t));
|
|
971
|
+
break;
|
|
972
|
+
} else if (s === Jsep.COMMA_CODE) {
|
|
973
|
+
if (this.index++, a++, a !== e.length) {
|
|
974
|
+
if (t === Jsep.CPAREN_CODE)
|
|
975
|
+
this.throwError("Unexpected token ,");
|
|
976
|
+
else if (t === Jsep.CBRACK_CODE)
|
|
977
|
+
for (let i = e.length; i < a; i++)
|
|
978
|
+
e.push(null);
|
|
979
|
+
}
|
|
980
|
+
} else if (e.length !== a && a !== 0)
|
|
981
|
+
this.throwError("Expected comma");
|
|
982
|
+
else {
|
|
983
|
+
const i = this.gobbleExpression();
|
|
984
|
+
(!i || i.type === Jsep.COMPOUND) && this.throwError("Expected comma"), e.push(i);
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
return n || this.throwError("Expected " + String.fromCharCode(t)), e;
|
|
988
|
+
}
|
|
989
|
+
/**
|
|
990
|
+
* Responsible for parsing a group of things within parentheses `()`
|
|
991
|
+
* that have no identifier in front (so not a function call)
|
|
992
|
+
* This function assumes that it needs to gobble the opening parenthesis
|
|
993
|
+
* and then tries to gobble everything within that parenthesis, assuming
|
|
994
|
+
* that the next thing it should see is the close parenthesis. If not,
|
|
995
|
+
* then the expression probably doesn't have a `)`
|
|
996
|
+
* @returns {boolean|jsep.Expression}
|
|
997
|
+
*/
|
|
998
|
+
gobbleGroup() {
|
|
999
|
+
this.index++;
|
|
1000
|
+
let t = this.gobbleExpressions(Jsep.CPAREN_CODE);
|
|
1001
|
+
if (this.code === Jsep.CPAREN_CODE)
|
|
1002
|
+
return this.index++, t.length === 1 ? t[0] : t.length ? {
|
|
1003
|
+
type: Jsep.SEQUENCE_EXP,
|
|
1004
|
+
expressions: t
|
|
1005
|
+
} : !1;
|
|
1006
|
+
this.throwError("Unclosed (");
|
|
1007
|
+
}
|
|
1008
|
+
/**
|
|
1009
|
+
* Responsible for parsing Array literals `[1, 2, 3]`
|
|
1010
|
+
* This function assumes that it needs to gobble the opening bracket
|
|
1011
|
+
* and then tries to gobble the expressions as arguments.
|
|
1012
|
+
* @returns {jsep.ArrayExpression}
|
|
1013
|
+
*/
|
|
1014
|
+
gobbleArray() {
|
|
1015
|
+
return this.index++, {
|
|
1016
|
+
type: Jsep.ARRAY_EXP,
|
|
1017
|
+
elements: this.gobbleArguments(Jsep.CBRACK_CODE)
|
|
1018
|
+
};
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
const hooks = new Hooks();
|
|
1022
|
+
Object.assign(Jsep, {
|
|
1023
|
+
hooks,
|
|
1024
|
+
plugins: new Plugins(Jsep),
|
|
1025
|
+
// Node Types
|
|
1026
|
+
// ----------
|
|
1027
|
+
// This is the full set of types that any JSEP node can be.
|
|
1028
|
+
// Store them here to save space when minified
|
|
1029
|
+
COMPOUND: "Compound",
|
|
1030
|
+
SEQUENCE_EXP: "SequenceExpression",
|
|
1031
|
+
IDENTIFIER: "Identifier",
|
|
1032
|
+
MEMBER_EXP: "MemberExpression",
|
|
1033
|
+
LITERAL: "Literal",
|
|
1034
|
+
THIS_EXP: "ThisExpression",
|
|
1035
|
+
CALL_EXP: "CallExpression",
|
|
1036
|
+
UNARY_EXP: "UnaryExpression",
|
|
1037
|
+
BINARY_EXP: "BinaryExpression",
|
|
1038
|
+
ARRAY_EXP: "ArrayExpression",
|
|
1039
|
+
TAB_CODE: 9,
|
|
1040
|
+
LF_CODE: 10,
|
|
1041
|
+
CR_CODE: 13,
|
|
1042
|
+
SPACE_CODE: 32,
|
|
1043
|
+
PERIOD_CODE: 46,
|
|
1044
|
+
// '.'
|
|
1045
|
+
COMMA_CODE: 44,
|
|
1046
|
+
// ','
|
|
1047
|
+
SQUOTE_CODE: 39,
|
|
1048
|
+
// single quote
|
|
1049
|
+
DQUOTE_CODE: 34,
|
|
1050
|
+
// double quotes
|
|
1051
|
+
OPAREN_CODE: 40,
|
|
1052
|
+
// (
|
|
1053
|
+
CPAREN_CODE: 41,
|
|
1054
|
+
// )
|
|
1055
|
+
OBRACK_CODE: 91,
|
|
1056
|
+
// [
|
|
1057
|
+
CBRACK_CODE: 93,
|
|
1058
|
+
// ]
|
|
1059
|
+
QUMARK_CODE: 63,
|
|
1060
|
+
// ?
|
|
1061
|
+
SEMCOL_CODE: 59,
|
|
1062
|
+
// ;
|
|
1063
|
+
COLON_CODE: 58,
|
|
1064
|
+
// :
|
|
1065
|
+
// Operations
|
|
1066
|
+
// ----------
|
|
1067
|
+
// Use a quickly-accessible map to store all of the unary operators
|
|
1068
|
+
// Values are set to `1` (it really doesn't matter)
|
|
1069
|
+
unary_ops: {
|
|
1070
|
+
"-": 1,
|
|
1071
|
+
"!": 1,
|
|
1072
|
+
"~": 1,
|
|
1073
|
+
"+": 1
|
|
1074
|
+
},
|
|
1075
|
+
// Also use a map for the binary operations but set their values to their
|
|
1076
|
+
// binary precedence for quick reference (higher number = higher precedence)
|
|
1077
|
+
// see [Order of operations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence)
|
|
1078
|
+
binary_ops: {
|
|
1079
|
+
"||": 1,
|
|
1080
|
+
"??": 1,
|
|
1081
|
+
"&&": 2,
|
|
1082
|
+
"|": 3,
|
|
1083
|
+
"^": 4,
|
|
1084
|
+
"&": 5,
|
|
1085
|
+
"==": 6,
|
|
1086
|
+
"!=": 6,
|
|
1087
|
+
"===": 6,
|
|
1088
|
+
"!==": 6,
|
|
1089
|
+
"<": 7,
|
|
1090
|
+
">": 7,
|
|
1091
|
+
"<=": 7,
|
|
1092
|
+
">=": 7,
|
|
1093
|
+
"<<": 8,
|
|
1094
|
+
">>": 8,
|
|
1095
|
+
">>>": 8,
|
|
1096
|
+
"+": 9,
|
|
1097
|
+
"-": 9,
|
|
1098
|
+
"*": 10,
|
|
1099
|
+
"/": 10,
|
|
1100
|
+
"%": 10,
|
|
1101
|
+
"**": 11
|
|
1102
|
+
},
|
|
1103
|
+
// sets specific binary_ops as right-associative
|
|
1104
|
+
right_associative: /* @__PURE__ */ new Set(["**"]),
|
|
1105
|
+
// Additional valid identifier chars, apart from a-z, A-Z and 0-9 (except on the starting char)
|
|
1106
|
+
additional_identifier_chars: /* @__PURE__ */ new Set(["$", "_"]),
|
|
1107
|
+
// Literals
|
|
1108
|
+
// ----------
|
|
1109
|
+
// Store the values to return for the various literals we may encounter
|
|
1110
|
+
literals: {
|
|
1111
|
+
true: !0,
|
|
1112
|
+
false: !1,
|
|
1113
|
+
null: null
|
|
1114
|
+
},
|
|
1115
|
+
// Except for `this`, which is special. This could be changed to something like `'self'` as well
|
|
1116
|
+
this_str: "this"
|
|
1117
|
+
});
|
|
1118
|
+
Jsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);
|
|
1119
|
+
Jsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);
|
|
1120
|
+
const jsep = (r) => new Jsep(r).parse(), stdClassProps = Object.getOwnPropertyNames(class {
|
|
1121
|
+
});
|
|
1122
|
+
Object.getOwnPropertyNames(Jsep).filter((r) => !stdClassProps.includes(r) && jsep[r] === void 0).forEach((r) => {
|
|
1123
|
+
jsep[r] = Jsep[r];
|
|
1124
|
+
});
|
|
1125
|
+
jsep.Jsep = Jsep;
|
|
1126
|
+
const CONDITIONAL_EXP = "ConditionalExpression";
|
|
1127
|
+
var ternary = {
|
|
1128
|
+
name: "ternary",
|
|
1129
|
+
init(r) {
|
|
1130
|
+
r.hooks.add("after-expression", function(e) {
|
|
1131
|
+
if (e.node && this.code === r.QUMARK_CODE) {
|
|
1132
|
+
this.index++;
|
|
1133
|
+
const n = e.node, a = this.gobbleExpression();
|
|
1134
|
+
if (a || this.throwError("Expected expression"), this.gobbleSpaces(), this.code === r.COLON_CODE) {
|
|
1135
|
+
this.index++;
|
|
1136
|
+
const s = this.gobbleExpression();
|
|
1137
|
+
if (s || this.throwError("Expected expression"), e.node = {
|
|
1138
|
+
type: CONDITIONAL_EXP,
|
|
1139
|
+
test: n,
|
|
1140
|
+
consequent: a,
|
|
1141
|
+
alternate: s
|
|
1142
|
+
}, n.operator && r.binary_ops[n.operator] <= 0.9) {
|
|
1143
|
+
let i = n;
|
|
1144
|
+
for (; i.right.operator && r.binary_ops[i.right.operator] <= 0.9; )
|
|
1145
|
+
i = i.right;
|
|
1146
|
+
e.node.test = i.right, i.right = e.node, e.node = n;
|
|
1147
|
+
}
|
|
1148
|
+
} else
|
|
1149
|
+
this.throwError("Expected :");
|
|
1150
|
+
}
|
|
1151
|
+
});
|
|
1152
|
+
}
|
|
1153
|
+
};
|
|
1154
|
+
jsep.plugins.register(ternary);
|
|
1155
|
+
jsep.addBinaryOp("=", 0, (r, t) => r === t);
|
|
1156
|
+
jsep.addBinaryOp("<>", 0, (r, t) => r !== t);
|
|
1157
|
+
jsep.addBinaryOp(">", 0, (r, t) => r > t);
|
|
1158
|
+
jsep.addBinaryOp("<", 0, (r, t) => r < t);
|
|
1159
|
+
jsep.addBinaryOp(">=", 0, (r, t) => r >= t);
|
|
1160
|
+
jsep.addBinaryOp("<=", 0, (r, t) => r <= t);
|
|
1161
|
+
let innerConfig = {}, needComputedCell = /* @__PURE__ */ new Map();
|
|
1162
|
+
function changeConfig(config) {
|
|
1163
|
+
config.flat().forEach((cell) => {
|
|
1164
|
+
let key = `${cell.row}:${cell.col}`;
|
|
1165
|
+
if (cell.type === CellType.FUN && needComputedCell.set(key, cell), cell.colSpan !== 0 && cell.rowSpan !== 0) {
|
|
1166
|
+
if (cell.type === CellType.FIELD && cell.format === FormatType.STRING && cell.fun && (cell.colData || cell.rowData)) {
|
|
1167
|
+
let r = {
|
|
1168
|
+
...cell.colData,
|
|
1169
|
+
...cell.rowData
|
|
1170
|
+
};
|
|
1171
|
+
cell.text = cell.fun.replace(/\$\{([a-zA-Z0-9\_\-]+)\}/g, (t, e) => (e = e.toUpperCase(), r[e] ?? t));
|
|
1172
|
+
}
|
|
1173
|
+
if (cell.format && (cell.text = formatCellValue(cell.text || "", cell.format, cell.formatType)), cell.customRender) {
|
|
1174
|
+
let data = {
|
|
1175
|
+
...cell.colData,
|
|
1176
|
+
...cell.rowData
|
|
1177
|
+
};
|
|
1178
|
+
const fun = function() {
|
|
1179
|
+
return eval(
|
|
1180
|
+
`async (cell,data) => {
|
|
1181
|
+
${cell.customRender}
|
|
1182
|
+
}`
|
|
1183
|
+
);
|
|
1184
|
+
}();
|
|
1185
|
+
cell = fun.call(this, cell, data);
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
innerConfig[key] ? innerConfig[key].push(cell) : innerConfig[key] = [cell];
|
|
1189
|
+
});
|
|
1190
|
+
}
|
|
1191
|
+
function computeCell(r) {
|
|
1192
|
+
changeConfig(r), Array.from(needComputedCell.values()).forEach((t) => {
|
|
1193
|
+
if (t.type === CellType.FUN && t.fun) {
|
|
1194
|
+
const { isError: e, result: n } = parseExpression(t.fun, !0);
|
|
1195
|
+
e || (t.text = n, t.type = CellType.TEXT);
|
|
1196
|
+
}
|
|
1197
|
+
}), innerConfig = {}, needComputedCell = /* @__PURE__ */ new Map();
|
|
1198
|
+
}
|
|
1199
|
+
function parseExpression(r, t = !1) {
|
|
1200
|
+
try {
|
|
1201
|
+
const e = r.trim();
|
|
1202
|
+
if (!e)
|
|
1203
|
+
throw new Error("请输入一个表达式");
|
|
1204
|
+
const n = e.startsWith("=") ? e.slice(1) : e, a = jsep(n);
|
|
1205
|
+
let s = null;
|
|
1206
|
+
return t && (s = evaluateExpression(a)), {
|
|
1207
|
+
isError: !1,
|
|
1208
|
+
result: s
|
|
1209
|
+
};
|
|
1210
|
+
} catch (e) {
|
|
1211
|
+
return console.error(e), {
|
|
1212
|
+
isError: !0,
|
|
1213
|
+
result: e.message
|
|
1214
|
+
};
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
function evaluateExpression(r) {
|
|
1218
|
+
if (!r)
|
|
1219
|
+
throw new Error("空节点");
|
|
1220
|
+
switch (r.type) {
|
|
1221
|
+
case "Literal":
|
|
1222
|
+
if (typeof r.value == "string") {
|
|
1223
|
+
const s = r.value.match(/^(['"]?)([A-Z]+\d+):([A-Z]+\d+)\1$/i);
|
|
1224
|
+
if (s)
|
|
1225
|
+
return getRangeValues(s[2], s[3]);
|
|
1226
|
+
}
|
|
1227
|
+
return r.value;
|
|
1228
|
+
case "Identifier":
|
|
1229
|
+
if (/^[A-Z]+\d+$/.test(r.name))
|
|
1230
|
+
return getCellValue(r.name);
|
|
1231
|
+
throw new Error(`未定义的标识符: ${r.name}`);
|
|
1232
|
+
case "BinaryExpression":
|
|
1233
|
+
const t = evaluateExpression(r.left), e = evaluateExpression(r.right);
|
|
1234
|
+
switch (r.operator) {
|
|
1235
|
+
case "+":
|
|
1236
|
+
return t + e;
|
|
1237
|
+
case "-":
|
|
1238
|
+
return t - e;
|
|
1239
|
+
case "*":
|
|
1240
|
+
return t * e;
|
|
1241
|
+
case "/":
|
|
1242
|
+
return t / e;
|
|
1243
|
+
case "^":
|
|
1244
|
+
return Math.pow(t, e);
|
|
1245
|
+
case "=":
|
|
1246
|
+
return t === e ? 1 : 0;
|
|
1247
|
+
case "<>":
|
|
1248
|
+
return t !== e ? 1 : 0;
|
|
1249
|
+
case ">":
|
|
1250
|
+
return t > e ? 1 : 0;
|
|
1251
|
+
case "<":
|
|
1252
|
+
return t < e ? 1 : 0;
|
|
1253
|
+
case ">=":
|
|
1254
|
+
return t >= e ? 1 : 0;
|
|
1255
|
+
case "<=":
|
|
1256
|
+
return t <= e ? 1 : 0;
|
|
1257
|
+
default:
|
|
1258
|
+
throw new Error(`不支持的操作符: ${r.operator}`);
|
|
1259
|
+
}
|
|
1260
|
+
case "CallExpression":
|
|
1261
|
+
return evaluateFunction(r.callee.name, r.arguments);
|
|
1262
|
+
case "MemberExpression":
|
|
1263
|
+
if (r.computed && r.property && r.property.type === "Literal") {
|
|
1264
|
+
const i = r.property.value.match(/^(['"]?)([A-Z]+\d+):([A-Z]+\d+)\1$/i);
|
|
1265
|
+
if (i)
|
|
1266
|
+
return getRangeValues(i[2], i[3]);
|
|
1267
|
+
}
|
|
1268
|
+
const n = evaluateExpression(r.object), a = r.computed ? evaluateExpression(r.property) : r.property.name;
|
|
1269
|
+
if (typeof n == "object" && n !== null)
|
|
1270
|
+
return n[a];
|
|
1271
|
+
throw new Error(`无法获取非对象值的属性: ${a}`);
|
|
1272
|
+
default:
|
|
1273
|
+
throw new Error(`不支持的节点类型: ${r.type}`);
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
function getRangeValues(r, t) {
|
|
1277
|
+
let e = -1;
|
|
1278
|
+
const n = r.match(/[A-Z]+/);
|
|
1279
|
+
n && (e = columnToNumber(n[0]));
|
|
1280
|
+
let a = -1;
|
|
1281
|
+
const s = r.match(/\d+/);
|
|
1282
|
+
s && (a = parseInt(s[0]) - 1);
|
|
1283
|
+
let i = -1;
|
|
1284
|
+
const d = t.match(/[A-Z]+/);
|
|
1285
|
+
d && (i = columnToNumber(d[0]));
|
|
1286
|
+
let l = -1;
|
|
1287
|
+
const P = t.match(/\d+/);
|
|
1288
|
+
P && (l = parseInt(P[0]) - 1);
|
|
1289
|
+
const B = [];
|
|
1290
|
+
for (let E = a; E <= l; E++)
|
|
1291
|
+
for (let H = e; H <= i; H++) {
|
|
1292
|
+
const Y = `${E}:${H}`;
|
|
1293
|
+
B.push(...getCellValue(Y));
|
|
1294
|
+
}
|
|
1295
|
+
return B;
|
|
1296
|
+
}
|
|
1297
|
+
function evaluateFunction(r, t) {
|
|
1298
|
+
const e = t.map((n) => evaluateExpression(n));
|
|
1299
|
+
switch (r.toUpperCase()) {
|
|
1300
|
+
case "SUM":
|
|
1301
|
+
return e.flat().reduce((i, d) => {
|
|
1302
|
+
const l = parseFloat(d);
|
|
1303
|
+
return i + (isNaN(l) ? 0 : l);
|
|
1304
|
+
}, 0);
|
|
1305
|
+
case "AVERAGE":
|
|
1306
|
+
case "AVG":
|
|
1307
|
+
const a = e.flat().filter((i) => !isNaN(parseFloat(i)));
|
|
1308
|
+
return a.length > 0 ? a.reduce((i, d) => i + parseFloat(d), 0) / a.length : 0;
|
|
1309
|
+
case "IF":
|
|
1310
|
+
if (e.length !== 3)
|
|
1311
|
+
throw new Error(`IF函数需要3个参数,但提供了${e.length}个`);
|
|
1312
|
+
return e[0] ? e[1] : e[2];
|
|
1313
|
+
case "NOW":
|
|
1314
|
+
return (/* @__PURE__ */ new Date()).toLocaleString();
|
|
1315
|
+
case "TODAY":
|
|
1316
|
+
const s = /* @__PURE__ */ new Date();
|
|
1317
|
+
return `${s.getFullYear()}-${String(s.getMonth() + 1).padStart(2, "0")}-${String(s.getDate()).padStart(2, "0")}`;
|
|
1318
|
+
case "MAX":
|
|
1319
|
+
return Math.max(
|
|
1320
|
+
...e.flat().map(Number).filter((i) => !isNaN(i))
|
|
1321
|
+
);
|
|
1322
|
+
case "MIN":
|
|
1323
|
+
return Math.min(
|
|
1324
|
+
...e.flat().map(Number).filter((i) => !isNaN(i))
|
|
1325
|
+
);
|
|
1326
|
+
case "COUNT":
|
|
1327
|
+
return e.flat().length;
|
|
1328
|
+
case "CONCATENATE":
|
|
1329
|
+
case "TEXTJOIN":
|
|
1330
|
+
return e.map(String).join("");
|
|
1331
|
+
default:
|
|
1332
|
+
throw new Error(`不支持的函数: ${r}`);
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
function getCellValue(r) {
|
|
1336
|
+
try {
|
|
1337
|
+
return innerConfig[r].map((t) => t.text);
|
|
1338
|
+
} catch (t) {
|
|
1339
|
+
console.warn(`无法解析单元格: ${r}`, t);
|
|
1340
|
+
}
|
|
1341
|
+
return [];
|
|
1342
|
+
}
|
|
1343
|
+
function columnToNumber(r) {
|
|
1344
|
+
let t = 0;
|
|
1345
|
+
for (let e = 0; e < r.length; e++)
|
|
1346
|
+
t = t * 26 + (r.charCodeAt(e) - 64) - 1;
|
|
1347
|
+
return t;
|
|
1348
|
+
}
|
|
1349
|
+
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
1350
|
+
__name: "report-view-item",
|
|
1351
|
+
props: {
|
|
1352
|
+
config: null,
|
|
1353
|
+
index: null
|
|
1354
|
+
},
|
|
1355
|
+
emits: ["updateData"],
|
|
1356
|
+
setup(r, { emit: t }) {
|
|
1357
|
+
const e = r, n = ref(), a = ref(), s = computed(() => ({
|
|
1358
|
+
width: e.config.widthType === "%" ? `calc(${e.config.width}% - 10px)` : `${e.config.width - 10}px`,
|
|
1359
|
+
height: e.config.fullHeight ? "calc(100% - 8px)" : `${e.config.height}px`
|
|
1360
|
+
})), i = computed(() => e.config && e.config.data ? !!e.config.data.pagination : !1), d = computed(() => e.config.params && Array.isArray(e.config.params) && e.config.params.length > 0), l = reactive({
|
|
1361
|
+
pageSize: 100,
|
|
1362
|
+
pageSizes: [10, 20, 50, 100, 200, 1e4],
|
|
1363
|
+
pageIndex: 1,
|
|
1364
|
+
total: 0
|
|
1365
|
+
}), P = ref([]);
|
|
1366
|
+
function B(u) {
|
|
1367
|
+
P.value = u, l.pageIndex = 1, X();
|
|
1368
|
+
}
|
|
1369
|
+
let E = !1;
|
|
1370
|
+
watch(
|
|
1371
|
+
() => [l.pageSize, l.pageIndex],
|
|
1372
|
+
(u, c) => {
|
|
1373
|
+
if (u && c) {
|
|
1374
|
+
let [p, m] = u, [h, g] = u;
|
|
1375
|
+
p !== h && (l.pageIndex = 1), E && X();
|
|
1376
|
+
}
|
|
1377
|
+
},
|
|
1378
|
+
{
|
|
1379
|
+
immediate: !0,
|
|
1380
|
+
deep: !0
|
|
1381
|
+
}
|
|
1382
|
+
);
|
|
1383
|
+
function H() {
|
|
1384
|
+
l.pageIndex = 1, X();
|
|
1385
|
+
}
|
|
1386
|
+
const Y = ref(!1);
|
|
1387
|
+
function z(u) {
|
|
1388
|
+
return u.reduce((p, m) => (m.loop && p.push(m), p), []);
|
|
1389
|
+
}
|
|
1390
|
+
function j(u) {
|
|
1391
|
+
const c = u.length, p = u[0].length, m = [];
|
|
1392
|
+
for (let h = 0; h < p; h++) {
|
|
1393
|
+
m[h] = [];
|
|
1394
|
+
for (let g = 0; g < c; g++)
|
|
1395
|
+
m[h][g] = u[g][h];
|
|
1396
|
+
}
|
|
1397
|
+
return m;
|
|
1398
|
+
}
|
|
1399
|
+
function L(u, c, p, m, h) {
|
|
1400
|
+
if (m) {
|
|
1401
|
+
let o = h.findIndex((T) => T === p);
|
|
1402
|
+
p = h[o - 1];
|
|
1403
|
+
}
|
|
1404
|
+
let g = u[c], R = `${p}-${g.join("-")}`;
|
|
1405
|
+
return Object.keys(u).filter((o) => o.indexOf(R) > -1).map((o) => u[o]).reduce((o, T) => o + T.length, 0);
|
|
1406
|
+
}
|
|
1407
|
+
function F(u, c) {
|
|
1408
|
+
const p = u.filter((m) => m < c);
|
|
1409
|
+
return p.length === 0 ? null : Math.max(...p);
|
|
1410
|
+
}
|
|
1411
|
+
function k(u, c, p, m) {
|
|
1412
|
+
c.forEach((h) => {
|
|
1413
|
+
let g = m[h.data], R = p[h.index], v = [];
|
|
1414
|
+
R.forEach((f, A) => {
|
|
1415
|
+
f.type === CellType.FIELD && f.data && f.isGroup && v.push(A);
|
|
1416
|
+
});
|
|
1417
|
+
let o = {};
|
|
1418
|
+
v.forEach((f, A) => {
|
|
1419
|
+
o[f] || (o[f] = /* @__PURE__ */ new Set());
|
|
1420
|
+
let w = R[f].data.replace("row:", "").toUpperCase();
|
|
1421
|
+
if (A === 0)
|
|
1422
|
+
g.forEach((y) => {
|
|
1423
|
+
if (w) {
|
|
1424
|
+
let x = y[w];
|
|
1425
|
+
if (x) {
|
|
1426
|
+
const D = `${f}-${x}`;
|
|
1427
|
+
o[D] ? o[D].push(y) : o[D] = [y], o[f].add(x), o[x] = [x];
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
});
|
|
1431
|
+
else {
|
|
1432
|
+
let y = f - 1;
|
|
1433
|
+
Array.from(o[y]).forEach((D) => {
|
|
1434
|
+
const S = `${y}-${D}`;
|
|
1435
|
+
let O = o[S].map((M) => {
|
|
1436
|
+
if (w) {
|
|
1437
|
+
let I = M[w];
|
|
1438
|
+
if (I) {
|
|
1439
|
+
let J = !1;
|
|
1440
|
+
const W = `${f}-${D}-${I}`, ae = `${D}-${I}`;
|
|
1441
|
+
return o[W] ? o[W].push(M) : o[W] = [M], o[f].has(ae) || (J = !0), o[f].add(ae), o[ae] = o[D].concat([I]), J ? I : null;
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
}).filter((M) => !!M);
|
|
1445
|
+
o[S] = O;
|
|
1446
|
+
});
|
|
1447
|
+
}
|
|
1448
|
+
});
|
|
1449
|
+
let T = 1, N = Math.max(...v);
|
|
1450
|
+
const K = R.some((f) => f.isRowColCombine);
|
|
1451
|
+
v.length > 0 ? K ? T = o[N].size : T = Array.from(o[N]).reduce((f, A) => {
|
|
1452
|
+
let _ = o[`${N}-${A}`];
|
|
1453
|
+
return f + _.length;
|
|
1454
|
+
}, 0) : T = g.length;
|
|
1455
|
+
const G = {
|
|
1456
|
+
...h,
|
|
1457
|
+
loop: !1
|
|
1458
|
+
}, $ = Array.from({ length: T }, () => cloneDeep(G));
|
|
1459
|
+
u.splice(h.index, 1, ...$);
|
|
1460
|
+
const b = Array.from({ length: R.length }, () => []);
|
|
1461
|
+
R.forEach((f, A) => {
|
|
1462
|
+
let _ = b[A];
|
|
1463
|
+
if (v.includes(A))
|
|
1464
|
+
Array.from(o[f.col]).forEach((y, x) => {
|
|
1465
|
+
let D = K && A === N ? 1 : L(o, y, N, K, v), S = o[y], C = S[o[y].length - 1], O = {
|
|
1466
|
+
...f,
|
|
1467
|
+
text: C,
|
|
1468
|
+
rowSpan: D,
|
|
1469
|
+
rowData: S
|
|
1470
|
+
};
|
|
1471
|
+
_.push(O);
|
|
1472
|
+
let M = {
|
|
1473
|
+
...f,
|
|
1474
|
+
text: C,
|
|
1475
|
+
type: "",
|
|
1476
|
+
colSpan: 0,
|
|
1477
|
+
rowSpan: 0
|
|
1478
|
+
};
|
|
1479
|
+
for (let I = 0; I < D - 1; I++)
|
|
1480
|
+
_.push(M);
|
|
1481
|
+
});
|
|
1482
|
+
else if (f.data) {
|
|
1483
|
+
let w = o[N] ? Array.from(o[N]) : [], y = f.data.replace("row:", "").toUpperCase();
|
|
1484
|
+
f.isRowColCombine ? w.length ? w.forEach((x, D) => {
|
|
1485
|
+
let S = o[`${N}-${x}`], C = f.combineKeys.map((I, J) => {
|
|
1486
|
+
const W = f.combineValues[J];
|
|
1487
|
+
return {
|
|
1488
|
+
key: I,
|
|
1489
|
+
val: W
|
|
1490
|
+
};
|
|
1491
|
+
});
|
|
1492
|
+
const O = S.filter((I) => C.every((J) => I[J.key] === J.val));
|
|
1493
|
+
let M = {
|
|
1494
|
+
...f
|
|
1495
|
+
};
|
|
1496
|
+
if (delete M.combineKeys, delete M.combineValues, delete M.isRowColCombine, O && O.length) {
|
|
1497
|
+
const I = O[0];
|
|
1498
|
+
M.text = I[y], M.rowData = I;
|
|
1499
|
+
} else
|
|
1500
|
+
M.text = "", M.rowData = {};
|
|
1501
|
+
_.push(M);
|
|
1502
|
+
}) : g.forEach((x) => {
|
|
1503
|
+
let S = f.combineKeys.map((O, M) => {
|
|
1504
|
+
const I = f.combineValues[M];
|
|
1505
|
+
return {
|
|
1506
|
+
key: O,
|
|
1507
|
+
val: I
|
|
1508
|
+
};
|
|
1509
|
+
}).every((O) => x[O.key] === O.val), C = {
|
|
1510
|
+
...f
|
|
1511
|
+
};
|
|
1512
|
+
delete C.combineKeys, delete C.combineValues, delete C.isRowColCombine, S ? (C.text = x[y], C.rowData = x) : C.text = "", _.push(C);
|
|
1513
|
+
}) : w.length ? w.forEach((x, D) => {
|
|
1514
|
+
o[`${N}-${x}`].forEach((C) => {
|
|
1515
|
+
let O = {
|
|
1516
|
+
...f
|
|
1517
|
+
};
|
|
1518
|
+
delete O.combineKeys, delete O.combineValues, delete O.isRowColCombine, C[y] ? (O.text = C[y], O.rowData = C) : O.text = "", _.push(O);
|
|
1519
|
+
});
|
|
1520
|
+
}) : g.forEach((x) => {
|
|
1521
|
+
let D = {
|
|
1522
|
+
...f
|
|
1523
|
+
};
|
|
1524
|
+
delete D.combineKeys, delete D.combineValues, delete D.isRowColCombine, x[y] ? (D.text = x[y], D.rowData = x) : D.text = "", _.push(D);
|
|
1525
|
+
});
|
|
1526
|
+
} else {
|
|
1527
|
+
const w = {
|
|
1528
|
+
...f,
|
|
1529
|
+
rowData: g[0]
|
|
1530
|
+
};
|
|
1531
|
+
if (f.rowSpan === 0 && f.mergeTarget && f.mergeTarget.length === 2) {
|
|
1532
|
+
let [D, S] = f.mergeTarget, C = p.reduce((O, M) => O.concat(M), []).filter((O) => O.row === D && O.col === S)[0];
|
|
1533
|
+
C && (C.rowSpan += T - 1);
|
|
1534
|
+
} else
|
|
1535
|
+
w.rowSpan += T - 1;
|
|
1536
|
+
const y = {
|
|
1537
|
+
...f,
|
|
1538
|
+
type: "",
|
|
1539
|
+
colSpan: 0,
|
|
1540
|
+
rowSpan: 0
|
|
1541
|
+
};
|
|
1542
|
+
delete w.isRowColCombine;
|
|
1543
|
+
let x = Array.from({ length: T - 1 }, () => cloneDeep(y));
|
|
1544
|
+
_.push(w, ...x);
|
|
1545
|
+
}
|
|
1546
|
+
});
|
|
1547
|
+
const U = j(b);
|
|
1548
|
+
p.splice(h.index, 1, ...U);
|
|
1549
|
+
});
|
|
1550
|
+
}
|
|
1551
|
+
function V(u, c, p, m) {
|
|
1552
|
+
c.forEach((h) => {
|
|
1553
|
+
let g = m[h.data], R = [], v = [];
|
|
1554
|
+
p.forEach(($, b) => {
|
|
1555
|
+
let U = $[h.index];
|
|
1556
|
+
U.type === CellType.FIELD && U.data && U.isGroup && v.push(b), R.push(U);
|
|
1557
|
+
});
|
|
1558
|
+
let o = {};
|
|
1559
|
+
v.forEach(($, b) => {
|
|
1560
|
+
o[$] || (o[$] = /* @__PURE__ */ new Set());
|
|
1561
|
+
let f = R[$].data.replace("col:", "").toUpperCase();
|
|
1562
|
+
if (b === 0)
|
|
1563
|
+
g.forEach((A) => {
|
|
1564
|
+
if (f) {
|
|
1565
|
+
let _ = A[f];
|
|
1566
|
+
if (_) {
|
|
1567
|
+
const w = `${$}-${_}`;
|
|
1568
|
+
o[w] ? o[w].push(A) : o[w] = [A], o[$].add(_), o[_] = [_], o[`${_}-data`] = [A];
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
});
|
|
1572
|
+
else {
|
|
1573
|
+
let A = v[b - 1];
|
|
1574
|
+
Array.from(o[A]).forEach((w) => {
|
|
1575
|
+
const y = `${A}-${w}`;
|
|
1576
|
+
let D = o[y].map((S) => {
|
|
1577
|
+
if (f) {
|
|
1578
|
+
let C = S[f];
|
|
1579
|
+
if (C) {
|
|
1580
|
+
let O = !1;
|
|
1581
|
+
const M = `${$}-${w}-${C}`, I = `${w}-${C}`;
|
|
1582
|
+
return o[M] ? o[M].push(S) : o[M] = [S], o[I + "-data"] ? o[I + "-data"].push(S) : o[I + "-data"] = [S], o[$].has(I) || (O = !0), o[$].add(I), o[I] = o[w].concat([C]), O ? C : null;
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
}).filter((S) => !!S);
|
|
1586
|
+
o[y] = D;
|
|
1587
|
+
});
|
|
1588
|
+
}
|
|
1589
|
+
});
|
|
1590
|
+
let T = 1, N = Math.max(...v), K = Math.min(...v);
|
|
1591
|
+
const G = R.some(($) => $.isRowColCombine);
|
|
1592
|
+
v.length > 0 ? G ? T = o[N].size : T = Array.from(o[N]).reduce(($, b) => {
|
|
1593
|
+
let U = o[`${N}-${b}`];
|
|
1594
|
+
return $ + U.length;
|
|
1595
|
+
}, 0) : T = g.length;
|
|
1596
|
+
for (let $ = 0; $ < R.length; $++) {
|
|
1597
|
+
const b = R[$];
|
|
1598
|
+
if ($ === 0) {
|
|
1599
|
+
const f = {
|
|
1600
|
+
...h,
|
|
1601
|
+
loop: !1
|
|
1602
|
+
}, A = Array.from({ length: T }, () => cloneDeep(f));
|
|
1603
|
+
u.splice(h.index, 1, ...A);
|
|
1604
|
+
}
|
|
1605
|
+
let U = p[b.row];
|
|
1606
|
+
if (U && Array.isArray(U)) {
|
|
1607
|
+
let f = [];
|
|
1608
|
+
if (v.includes($))
|
|
1609
|
+
Array.from(o[b.row]).forEach((_, w) => {
|
|
1610
|
+
let y = G && $ === N ? 1 : L(o, _, N, G, v), x = o[_][o[_].length - 1], D = {
|
|
1611
|
+
...b,
|
|
1612
|
+
text: x,
|
|
1613
|
+
colSpan: y,
|
|
1614
|
+
colData: o[_ + "-data"]
|
|
1615
|
+
};
|
|
1616
|
+
if (f.push(D), y > 1) {
|
|
1617
|
+
let S = {
|
|
1618
|
+
...b,
|
|
1619
|
+
text: x,
|
|
1620
|
+
type: "",
|
|
1621
|
+
colSpan: 0,
|
|
1622
|
+
rowSpan: 0
|
|
1623
|
+
};
|
|
1624
|
+
for (let C = 0; C < y - 1; C++)
|
|
1625
|
+
f.push(S);
|
|
1626
|
+
}
|
|
1627
|
+
}), U.splice(b.col, 1, ...f);
|
|
1628
|
+
else {
|
|
1629
|
+
if ($ > K && $ < N) {
|
|
1630
|
+
let A = F(v, $);
|
|
1631
|
+
if (A !== null) {
|
|
1632
|
+
let _ = p[A].slice(h.index, h.index + T);
|
|
1633
|
+
_ = _.map((w) => {
|
|
1634
|
+
let y = w.colData;
|
|
1635
|
+
return Array.isArray(y) && (y = y[0]), {
|
|
1636
|
+
...b,
|
|
1637
|
+
colData: y,
|
|
1638
|
+
colSpan: w.colSpan,
|
|
1639
|
+
rowSpan: w.rowSpan
|
|
1640
|
+
};
|
|
1641
|
+
}), U.splice(h.index, 1, ..._);
|
|
1642
|
+
continue;
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
if (b.data) {
|
|
1646
|
+
let A = o[N] ? Array.from(o[N]) : [], _ = b.data.replace("col:", "").toUpperCase();
|
|
1647
|
+
if (b.isRowColCombine) {
|
|
1648
|
+
let w = v.map((x) => R[x].data.replace("col:", "").toUpperCase()), y = [];
|
|
1649
|
+
A.forEach((x, D) => {
|
|
1650
|
+
let S = {
|
|
1651
|
+
...b,
|
|
1652
|
+
combineKeys: w,
|
|
1653
|
+
combineValues: o[x]
|
|
1654
|
+
};
|
|
1655
|
+
y.push(S);
|
|
1656
|
+
}), U.splice(b.col, 1, ...y);
|
|
1657
|
+
} else if (A.length)
|
|
1658
|
+
A.forEach((w, y) => {
|
|
1659
|
+
let x = o[`${N}-${w}`], D = [];
|
|
1660
|
+
x.forEach((S) => {
|
|
1661
|
+
let C = {
|
|
1662
|
+
...b
|
|
1663
|
+
};
|
|
1664
|
+
delete C.combineKeys, delete C.combineValues, delete C.isRowColCombine, S[_] ? (C.text = S[_], C.colData = S) : C.text = "", D.push(C);
|
|
1665
|
+
}), U.splice(b.col, 1, ...D);
|
|
1666
|
+
});
|
|
1667
|
+
else {
|
|
1668
|
+
let w = [];
|
|
1669
|
+
g.forEach((y) => {
|
|
1670
|
+
let x = {
|
|
1671
|
+
...b
|
|
1672
|
+
};
|
|
1673
|
+
delete x.combineKeys, delete x.combineValues, delete x.isRowColCombine, y[_] ? (x.text = y[_], x.colData = y) : x.text = "", w.push(x);
|
|
1674
|
+
}), U.splice(b.col, 1, ...w);
|
|
1675
|
+
}
|
|
1676
|
+
} else {
|
|
1677
|
+
const A = {
|
|
1678
|
+
...b,
|
|
1679
|
+
colData: g[0]
|
|
1680
|
+
};
|
|
1681
|
+
if (b.colSpan === 0 && b.mergeTarget && b.mergeTarget.length === 2 && b.row === b.mergeTarget[0]) {
|
|
1682
|
+
let [y, x] = b.mergeTarget, D = p.reduce((S, C) => S.concat(C), []).filter((S) => S.row === y && S.col === x)[0];
|
|
1683
|
+
D && (D.colSpan += T - 1);
|
|
1684
|
+
} else
|
|
1685
|
+
(!Array.isArray(b.mergeTarget) || b.mergeTarget.length !== 2) && (A.colSpan = T);
|
|
1686
|
+
const _ = {
|
|
1687
|
+
...b,
|
|
1688
|
+
colSpan: 0,
|
|
1689
|
+
rowSpan: 0
|
|
1690
|
+
};
|
|
1691
|
+
let w = Array.from({ length: T - 1 }, () => cloneDeep(_));
|
|
1692
|
+
U.splice(b.col, 1, A, ...w);
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
});
|
|
1698
|
+
}
|
|
1699
|
+
function re(u) {
|
|
1700
|
+
if (e.config && a.value) {
|
|
1701
|
+
a.value.innerHTML = "", console.time("transformConfig");
|
|
1702
|
+
let { rowConfig: c, colConfig: p, config: m } = cloneDeep(e.config), h = z(p), g = z(c);
|
|
1703
|
+
h && V(p, h, m, u), g && k(c, g, m, u), computeCell(m), console.timeEnd("transformConfig"), console.time("renderReportByDom"), ne(c, p, m, a), console.timeEnd("renderReportByDom");
|
|
1704
|
+
}
|
|
1705
|
+
}
|
|
1706
|
+
function Z(u) {
|
|
1707
|
+
const c = document.createElement("colgroup");
|
|
1708
|
+
let p = 0;
|
|
1709
|
+
return u.forEach((m) => {
|
|
1710
|
+
const h = document.createElement("col");
|
|
1711
|
+
p += m.size, h.style.width = `${m.size}px`, c.appendChild(h);
|
|
1712
|
+
}), a.value && (a.value.style.width = `${p}px`), c;
|
|
1713
|
+
}
|
|
1714
|
+
function q(u, c) {
|
|
1715
|
+
const p = document.createElement("td");
|
|
1716
|
+
p.setAttribute("data-cell-config", `${c.row}-${c.col}`), p.setAttribute("rowspan", c.rowSpan), p.setAttribute("colspan", c.colSpan);
|
|
1717
|
+
let m = "";
|
|
1718
|
+
switch (c.type) {
|
|
1719
|
+
case "icon":
|
|
1720
|
+
p.innerHTML = `<i class="iconfont ${c.data}"></i>`;
|
|
1721
|
+
break;
|
|
1722
|
+
case "image":
|
|
1723
|
+
p.innerHTML = `<img src="${c.data}" alt="">`;
|
|
1724
|
+
break;
|
|
1725
|
+
default:
|
|
1726
|
+
m = c.text !== void 0 && c.text !== null ? c.text : "";
|
|
1727
|
+
break;
|
|
1728
|
+
}
|
|
1729
|
+
return [CellType.TEXT, CellType.FIELD, CellType.ICON, CellType.FUN].includes(c.type) && c.style && p.setAttribute("style", renderCellStyle(c.style)), p.innerText = m, p;
|
|
1730
|
+
}
|
|
1731
|
+
function ne(u, c, p, m) {
|
|
1732
|
+
const h = Z(c);
|
|
1733
|
+
m.value.appendChild(h);
|
|
1734
|
+
let g = 0;
|
|
1735
|
+
const R = document.createDocumentFragment();
|
|
1736
|
+
for (let v = 0; v < u.length; v++) {
|
|
1737
|
+
const o = u[v], T = document.createElement("tr");
|
|
1738
|
+
o.isFixed && (T.style.top = `${g - 1}px`, T.classList.add("fixed-row")), g += o.size, T.style.height = `${o.size}px`;
|
|
1739
|
+
for (let N = 0; N < c.length; N++) {
|
|
1740
|
+
const K = p[v][N];
|
|
1741
|
+
if (o && K) {
|
|
1742
|
+
const G = q(o, K);
|
|
1743
|
+
G.setAttribute("data-cell-data", `${v}-${N}`), K.rowSpan === 0 || K.colSpan === 0 || T.appendChild(G);
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
R.appendChild(T);
|
|
1747
|
+
}
|
|
1748
|
+
m.value.appendChild(R);
|
|
1749
|
+
}
|
|
1750
|
+
async function X() {
|
|
1751
|
+
Y.value = !0;
|
|
1752
|
+
let u = await ee(), c = Q(u);
|
|
1753
|
+
e.config.data.processData && (c = await getProcessData(e.config.data.processData, c, P.value)), re(c), Y.value = !1;
|
|
1754
|
+
}
|
|
1755
|
+
function Q(u) {
|
|
1756
|
+
let c = {};
|
|
1757
|
+
return Array.isArray(u) || (u = [u]), u.map(({ key: p, data: m }) => {
|
|
1758
|
+
let h = m.filter((g) => g);
|
|
1759
|
+
c[p] = h;
|
|
1760
|
+
}), t("updateData", {
|
|
1761
|
+
key: e.config.id,
|
|
1762
|
+
data: c
|
|
1763
|
+
}), c;
|
|
1764
|
+
}
|
|
1765
|
+
async function ee() {
|
|
1766
|
+
if (e.config.data.source) {
|
|
1767
|
+
let u = {};
|
|
1768
|
+
d.value && (u.params = cloneDeep(P.value)), i.value && (u.pageSize = l.pageSize, u.pageNumber = l.pageIndex);
|
|
1769
|
+
let c = [];
|
|
1770
|
+
for (let p = 0; p < e.config.data.source.length; p++) {
|
|
1771
|
+
const { key: m, url: h } = e.config.data.source[p];
|
|
1772
|
+
if (h) {
|
|
1773
|
+
const g = await getDateSourceData(h, u);
|
|
1774
|
+
c.push({ key: m, data: g.data }), i.value && (l.total = g.count || g.data.length);
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
return c;
|
|
1778
|
+
} else
|
|
1779
|
+
return [];
|
|
1780
|
+
}
|
|
1781
|
+
async function te() {
|
|
1782
|
+
if (e.config.data.pagination && (e.config.data.pageSize !== void 0 && (l.pageSize = isNaN(e.config.data.pageSize) ? 10 : e.config.data.pageSize), e.config.data.pageSizes !== void 0)) {
|
|
1783
|
+
let u = e.config.data.pageSizes.split(",").map((c) => parseInt(c));
|
|
1784
|
+
l.pageSizes = Array.isArray(u) ? u : [10, 20, 50, 100, 200];
|
|
1785
|
+
}
|
|
1786
|
+
E = !0;
|
|
1787
|
+
}
|
|
1788
|
+
return onMounted(async () => {
|
|
1789
|
+
te();
|
|
1790
|
+
}), (u, c) => {
|
|
1791
|
+
const p = resolveComponent("el-button"), m = resolveComponent("el-pagination"), h = resolveDirective("loading");
|
|
1792
|
+
return openBlock(), createElementBlock("div", {
|
|
1793
|
+
class: "yh-report-view-container",
|
|
1794
|
+
style: normalizeStyle(unref(s))
|
|
1795
|
+
}, [
|
|
1796
|
+
createVNode(_sfc_main$3, {
|
|
1797
|
+
config: e.config.params,
|
|
1798
|
+
onChange: B
|
|
1799
|
+
}, {
|
|
1800
|
+
search: withCtx(() => [
|
|
1801
|
+
createVNode(p, {
|
|
1802
|
+
type: "primary",
|
|
1803
|
+
onClick: H
|
|
1804
|
+
}, {
|
|
1805
|
+
default: withCtx(() => [
|
|
1806
|
+
createTextVNode(" 搜索 ")
|
|
1807
|
+
]),
|
|
1808
|
+
_: 1
|
|
1809
|
+
})
|
|
1810
|
+
]),
|
|
1811
|
+
_: 1
|
|
1812
|
+
}, 8, ["config"]),
|
|
1813
|
+
withDirectives((openBlock(), createElementBlock("div", {
|
|
1814
|
+
class: "yh-statement-table-container",
|
|
1815
|
+
ref_key: "statementTableRef",
|
|
1816
|
+
ref: n
|
|
1817
|
+
}, [
|
|
1818
|
+
createElementVNode("table", {
|
|
1819
|
+
ref_key: "tableBodyRef",
|
|
1820
|
+
ref: a
|
|
1821
|
+
}, null, 512)
|
|
1822
|
+
])), [
|
|
1823
|
+
[h, Y.value]
|
|
1824
|
+
]),
|
|
1825
|
+
unref(i) ? (openBlock(), createBlock(m, {
|
|
1826
|
+
key: 0,
|
|
1827
|
+
pageSize: l.pageSize,
|
|
1828
|
+
"onUpdate:pageSize": c[0] || (c[0] = (g) => l.pageSize = g),
|
|
1829
|
+
"current-page": l.pageIndex,
|
|
1830
|
+
"onUpdate:currentPage": c[1] || (c[1] = (g) => l.pageIndex = g),
|
|
1831
|
+
"page-sizes": l.pageSizes,
|
|
1832
|
+
total: l.total,
|
|
1833
|
+
layout: "total, jumper, prev, pager, next, sizes"
|
|
1834
|
+
}, null, 8, ["pageSize", "current-page", "page-sizes", "total"])) : createCommentVNode("", !0)
|
|
1835
|
+
], 4);
|
|
1836
|
+
};
|
|
1837
|
+
}
|
|
1838
|
+
}), _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
1839
|
+
__name: "chart-view-item",
|
|
1840
|
+
props: {
|
|
1841
|
+
index: null,
|
|
1842
|
+
config: null,
|
|
1843
|
+
outData: null
|
|
1844
|
+
},
|
|
1845
|
+
setup(r, { expose: t }) {
|
|
1846
|
+
const e = r, n = ref();
|
|
1847
|
+
watch(
|
|
1848
|
+
() => e.outData,
|
|
1849
|
+
(i) => {
|
|
1850
|
+
console.log("chart-view-item:", i);
|
|
1851
|
+
},
|
|
1852
|
+
{ deep: !0 }
|
|
1853
|
+
);
|
|
1854
|
+
const a = computed(() => {
|
|
1855
|
+
let i = e.config.widthUnit || "px", d = e.config.heightUnit || "px";
|
|
1856
|
+
if (e.config.isSuspend) {
|
|
1857
|
+
let l = {
|
|
1858
|
+
position: "absolute",
|
|
1859
|
+
left: e.config.left + "px",
|
|
1860
|
+
top: e.config.top + "px",
|
|
1861
|
+
zIndex: 100,
|
|
1862
|
+
height: e.config.height + d
|
|
1863
|
+
};
|
|
1864
|
+
return i === "%" ? l.width = `calc( ${e.config.width}${i} - 10px)` : l.width = `${e.config.width - 10}${i}`, l;
|
|
1865
|
+
} else {
|
|
1866
|
+
let l = {
|
|
1867
|
+
height: e.config.height + d
|
|
1868
|
+
};
|
|
1869
|
+
return i === "%" ? l.width = `calc( ${e.config.width}${i} - 10px)` : l.width = `${e.config.width - 10}${i}`, l;
|
|
1870
|
+
}
|
|
1871
|
+
});
|
|
1872
|
+
return t({
|
|
1873
|
+
setOutData: (i) => {
|
|
1874
|
+
var d;
|
|
1875
|
+
(d = n.value) == null || d.setOutData(i);
|
|
1876
|
+
}
|
|
1877
|
+
}), (i, d) => (openBlock(), createElementBlock("div", {
|
|
1878
|
+
class: "yh-report-view-container chart-view-item",
|
|
1879
|
+
style: normalizeStyle(unref(a))
|
|
1880
|
+
}, [
|
|
1881
|
+
createVNode(chartItem, {
|
|
1882
|
+
"is-view": "",
|
|
1883
|
+
ref_key: "chartItemRef",
|
|
1884
|
+
ref: n,
|
|
1885
|
+
"chart-data": e.config
|
|
1886
|
+
}, null, 8, ["chart-data"])
|
|
1887
|
+
], 4));
|
|
1888
|
+
}
|
|
1889
|
+
}), _hoisted_1 = { class: "yh-statement-table-title" }, _hoisted_2 = { class: "back-top" }, _hoisted_3 = /* @__PURE__ */ createElementVNode("i", { class: "iconfont icon-backtop" }, null, -1), _hoisted_4 = [
|
|
1890
|
+
_hoisted_3
|
|
1891
|
+
], _sfc_main = /* @__PURE__ */ defineComponent({
|
|
1892
|
+
__name: "report-run",
|
|
1893
|
+
props: {
|
|
1894
|
+
id: null
|
|
1895
|
+
},
|
|
1896
|
+
emits: ["updateData"],
|
|
1897
|
+
setup(r, { emit: t }) {
|
|
1898
|
+
const e = r;
|
|
1899
|
+
ref();
|
|
1900
|
+
const n = ref(!1), a = ref(!1), s = ref(""), i = ref(), d = ref(), l = ref([]), P = {};
|
|
1901
|
+
watch(
|
|
1902
|
+
() => e.id,
|
|
1903
|
+
(Y) => {
|
|
1904
|
+
B(Y);
|
|
1905
|
+
}
|
|
1906
|
+
);
|
|
1907
|
+
function B(Y) {
|
|
1908
|
+
Y ? (a.value = !1, n.value = !0, getConfig(Y).then(async ({ name: z, remoteOptions: j }) => {
|
|
1909
|
+
s.value = z, l.value = j;
|
|
1910
|
+
}).finally(() => {
|
|
1911
|
+
n.value = !1;
|
|
1912
|
+
})) : a.value = !0;
|
|
1913
|
+
}
|
|
1914
|
+
const E = ref(!1);
|
|
1915
|
+
function H(Y) {
|
|
1916
|
+
var z;
|
|
1917
|
+
P[Y.key] = Y.data, (z = d.value) == null || z.forEach((j) => {
|
|
1918
|
+
j.setOutData(P);
|
|
1919
|
+
});
|
|
1920
|
+
}
|
|
1921
|
+
return onMounted(() => {
|
|
1922
|
+
B(e.id);
|
|
1923
|
+
}), (Y, z) => {
|
|
1924
|
+
const j = resolveDirective("loading");
|
|
1925
|
+
return openBlock(), createElementBlock(Fragment, null, [
|
|
1926
|
+
createElementVNode("div", _hoisted_1, toDisplayString(s.value), 1),
|
|
1927
|
+
a.value ? (openBlock(), createBlock(unref(ElEmpty), {
|
|
1928
|
+
key: 1,
|
|
1929
|
+
class: "yh-statement-table-viewer-container",
|
|
1930
|
+
description: "获取配置时出现错误"
|
|
1931
|
+
}, {
|
|
1932
|
+
default: withCtx(() => [
|
|
1933
|
+
createVNode(unref(ElButton), {
|
|
1934
|
+
type: "primary",
|
|
1935
|
+
onClick: z[0] || (z[0] = (L) => Y.$router.back())
|
|
1936
|
+
}, {
|
|
1937
|
+
default: withCtx(() => [
|
|
1938
|
+
createTextVNode(" 返回 ")
|
|
1939
|
+
]),
|
|
1940
|
+
_: 1
|
|
1941
|
+
})
|
|
1942
|
+
]),
|
|
1943
|
+
_: 1
|
|
1944
|
+
})) : withDirectives((openBlock(), createElementBlock("section", {
|
|
1945
|
+
key: 0,
|
|
1946
|
+
class: "yh-report-viewer-wrapper",
|
|
1947
|
+
ref_key: "viewWrapper",
|
|
1948
|
+
ref: i
|
|
1949
|
+
}, [
|
|
1950
|
+
(openBlock(!0), createElementBlock(Fragment, null, renderList(l.value, (L, F) => (openBlock(), createElementBlock(Fragment, null, [
|
|
1951
|
+
L.type === "report" ? (openBlock(), createBlock(_sfc_main$2, {
|
|
1952
|
+
key: 0,
|
|
1953
|
+
index: F,
|
|
1954
|
+
config: L,
|
|
1955
|
+
onUpdateData: H
|
|
1956
|
+
}, null, 8, ["index", "config"])) : (openBlock(), createBlock(_sfc_main$1, {
|
|
1957
|
+
key: 1,
|
|
1958
|
+
config: L,
|
|
1959
|
+
ref_for: !0,
|
|
1960
|
+
ref_key: "chartViewItemRef",
|
|
1961
|
+
ref: d,
|
|
1962
|
+
index: F
|
|
1963
|
+
}, null, 8, ["config", "index"]))
|
|
1964
|
+
], 64))), 256)),
|
|
1965
|
+
withDirectives(createElementVNode("div", _hoisted_2, _hoisted_4, 512), [
|
|
1966
|
+
[vShow, E.value]
|
|
1967
|
+
])
|
|
1968
|
+
])), [
|
|
1969
|
+
[j, n.value]
|
|
1970
|
+
])
|
|
1971
|
+
], 64);
|
|
1972
|
+
};
|
|
1973
|
+
}
|
|
1974
|
+
}), reportRun_vue_vue_type_style_index_0_lang = "";
|
|
1975
|
+
export {
|
|
1976
|
+
_export_sfc as _,
|
|
1977
|
+
chartsTypeList as a,
|
|
1978
|
+
getDateSourceList as b,
|
|
1979
|
+
chartItem as c,
|
|
1980
|
+
_sfc_main as d,
|
|
1981
|
+
getDateSourceColumns as g,
|
|
1982
|
+
parseExpression as p,
|
|
1983
|
+
renderCellStyle as r
|
|
1984
|
+
};
|
|
1985
|
+
//# sourceMappingURL=report-run.vue_vue_type_style_index_0_lang-657964fa.mjs.map
|