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