hc-energy-ui 0.0.1

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.
@@ -0,0 +1,933 @@
1
+ import { defineComponent as U, openBlock as f, createElementBlock as p, normalizeClass as A, renderSlot as de, ref as S, computed as L, watch as z, onMounted as me, onBeforeUnmount as ge, createElementVNode as h, withModifiers as oe, createCommentVNode as F, createBlock as te, Teleport as De, normalizeStyle as fe, toDisplayString as M, Fragment as W, renderList as H, unref as R, nextTick as be, createTextVNode as ie, createVNode as J, onUnmounted as ke, useModel as we, withCtx as xe, withDirectives as _e, vShow as $e, mergeModels as se } from "vue";
2
+ import * as Ce from "echarts";
3
+ const Te = ["disabled"], Me = /* @__PURE__ */ U({
4
+ __name: "Button",
5
+ props: {
6
+ type: { default: "default" },
7
+ disabled: { type: Boolean, default: !1 }
8
+ },
9
+ emits: ["click"],
10
+ setup(e, { emit: a }) {
11
+ const o = a, n = (r) => {
12
+ o("click", r);
13
+ };
14
+ return (r, l) => (f(), p("button", {
15
+ class: A(["hc-button", [`hc-button--${e.type}`]]),
16
+ disabled: e.disabled,
17
+ onClick: n
18
+ }, [
19
+ de(r.$slots, "default", {}, void 0, !0)
20
+ ], 10, Te));
21
+ }
22
+ }), I = (e, a) => {
23
+ const o = e.__vccOpts || e;
24
+ for (const [n, r] of a)
25
+ o[n] = r;
26
+ return o;
27
+ }, ye = /* @__PURE__ */ I(Me, [["__scopeId", "data-v-c0879ce0"]]), pe = ye;
28
+ pe.install = (e) => {
29
+ e.component("HcButton", ye);
30
+ };
31
+ function X(e) {
32
+ return String(e).padStart(2, "0");
33
+ }
34
+ function Fe(e, a) {
35
+ const o = e.getFullYear(), n = X(e.getMonth() + 1), r = X(e.getDate());
36
+ return a === "year" ? `${o}-01-01` : a === "month" ? `${o}-${n}-01` : `${o}-${n}-${r}`;
37
+ }
38
+ function re(e) {
39
+ if (!e) return null;
40
+ if (e instanceof Date)
41
+ return Number.isNaN(e.getTime()) ? null : e;
42
+ const a = new Date(e);
43
+ return Number.isNaN(a.getTime()) ? null : a;
44
+ }
45
+ function Ae(e, a) {
46
+ if (!e) return "";
47
+ const o = e.getFullYear(), n = X(e.getMonth() + 1), r = X(e.getDate());
48
+ return a === "year" ? `${o}` : a === "month" ? `${o}-${n}` : `${o}-${n}-${r}`;
49
+ }
50
+ function ue(e, a) {
51
+ return e.getFullYear() === a.getFullYear() && e.getMonth() === a.getMonth() && e.getDate() === a.getDate();
52
+ }
53
+ function Le(e, a) {
54
+ const n = new Date(e, a, 1).getDay(), r = new Date(e, a + 1, 0).getDate(), l = new Date(e, a, 0).getDate(), b = [];
55
+ for (let i = n - 1; i >= 0; i--)
56
+ b.push({
57
+ date: new Date(e, a - 1, l - i),
58
+ current: !1
59
+ });
60
+ for (let i = 1; i <= r; i++)
61
+ b.push({ date: new Date(e, a, i), current: !0 });
62
+ const C = 42 - b.length;
63
+ for (let i = 1; i <= C; i++)
64
+ b.push({ date: new Date(e, a + 1, i), current: !1 });
65
+ return b;
66
+ }
67
+ const Ee = ["value", "placeholder", "disabled"], Ne = { class: "hc-date-picker__header" }, Ye = { class: "hc-date-picker__header-label" }, Pe = {
68
+ key: 0,
69
+ class: "hc-date-picker__body"
70
+ }, Se = { class: "hc-date-picker__weeks" }, Be = { class: "hc-date-picker__days" }, ze = ["onClick"], Ue = {
71
+ key: 1,
72
+ class: "hc-date-picker__body hc-date-picker__body--month"
73
+ }, Ie = ["onClick"], Ve = {
74
+ key: 2,
75
+ class: "hc-date-picker__body hc-date-picker__body--year"
76
+ }, Oe = ["onClick"], We = /* @__PURE__ */ U({
77
+ name: "HcDatePicker",
78
+ __name: "DatePicker",
79
+ props: {
80
+ modelValue: { default: "" },
81
+ type: { default: "date" },
82
+ placeholder: { default: "选择日期" },
83
+ disabled: { type: Boolean, default: !1 },
84
+ clearable: { type: Boolean, default: !0 },
85
+ size: { default: "default" },
86
+ dark: { type: Boolean, default: !1 }
87
+ },
88
+ emits: ["update:modelValue", "change"],
89
+ setup(e, { emit: a }) {
90
+ var ne, le;
91
+ const o = e, n = a, r = ["日", "一", "二", "三", "四", "五", "六"], l = /* @__PURE__ */ new Date(), b = S(null), C = S(null), i = S(!1), x = S({}), m = L(() => re(o.modelValue)), d = L(() => Ae(m.value, o.type)), u = S(((ne = m.value) == null ? void 0 : ne.getFullYear()) ?? l.getFullYear()), w = S(((le = m.value) == null ? void 0 : le.getMonth()) ?? l.getMonth());
92
+ z(
93
+ () => [o.modelValue, o.type],
94
+ () => {
95
+ const _ = re(o.modelValue);
96
+ _ && (u.value = _.getFullYear(), w.value = _.getMonth());
97
+ }
98
+ );
99
+ const k = L(() => Le(u.value, w.value)), v = L(() => Math.floor(u.value / 10) * 10), c = L(
100
+ () => Array.from({ length: 12 }, (_, E) => v.value - 1 + E)
101
+ ), t = L(() => o.type === "year" ? `${v.value} 年 - ${v.value + 9} 年` : o.type === "month" ? `${u.value} 年` : `${u.value} 年 ${w.value + 1} 月`);
102
+ function s() {
103
+ if (!b.value) return;
104
+ const _ = b.value.getBoundingClientRect(), E = _.bottom + 4 + window.scrollY;
105
+ let D = _.left + window.scrollX;
106
+ const P = 292;
107
+ D + P > window.innerWidth - 8 && (D = Math.max(8, window.innerWidth - P - 8)), x.value = {
108
+ position: "absolute",
109
+ top: `${E}px`,
110
+ left: `${D}px`,
111
+ zIndex: "3000"
112
+ };
113
+ }
114
+ async function g() {
115
+ o.disabled || (i.value = !0, await be(), s());
116
+ }
117
+ function N() {
118
+ i.value = !1;
119
+ }
120
+ function Y() {
121
+ o.disabled || (i.value ? N() : g());
122
+ }
123
+ function V() {
124
+ n("update:modelValue", ""), n("change", null);
125
+ }
126
+ function O(_) {
127
+ const E = Fe(_, o.type);
128
+ n("update:modelValue", E), n("change", E), N();
129
+ }
130
+ function y(_) {
131
+ O(_);
132
+ }
133
+ function B(_) {
134
+ O(new Date(u.value, _, 1));
135
+ }
136
+ function T(_) {
137
+ O(new Date(_, 0, 1));
138
+ }
139
+ function $() {
140
+ w.value === 0 ? (w.value = 11, u.value -= 1) : w.value -= 1;
141
+ }
142
+ function q() {
143
+ w.value === 11 ? (w.value = 0, u.value += 1) : w.value += 1;
144
+ }
145
+ function Q() {
146
+ o.type === "year" ? u.value -= 10 : u.value -= 1;
147
+ }
148
+ function j() {
149
+ o.type === "year" ? u.value += 10 : u.value += 1;
150
+ }
151
+ function ae(_) {
152
+ var D, P;
153
+ if (!i.value) return;
154
+ const E = _.target;
155
+ (D = b.value) != null && D.contains(E) || (P = C.value) != null && P.contains(E) || N();
156
+ }
157
+ function K() {
158
+ i.value && s();
159
+ }
160
+ return me(() => {
161
+ document.addEventListener("mousedown", ae), window.addEventListener("scroll", K, !0), window.addEventListener("resize", K);
162
+ }), ge(() => {
163
+ document.removeEventListener("mousedown", ae), window.removeEventListener("scroll", K, !0), window.removeEventListener("resize", K);
164
+ }), (_, E) => (f(), p("div", {
165
+ ref_key: "rootRef",
166
+ ref: b,
167
+ class: A(["hc-date-picker", [`hc-date-picker--${e.size}`, { "hc-date-picker--dark": e.dark, "is-disabled": e.disabled }]])
168
+ }, [
169
+ h("div", {
170
+ class: A(["hc-date-picker__trigger", { "is-focus": i.value, "is-disabled": e.disabled }]),
171
+ onClick: Y
172
+ }, [
173
+ h("input", {
174
+ class: "hc-date-picker__inner",
175
+ type: "text",
176
+ readonly: "",
177
+ value: d.value,
178
+ placeholder: e.placeholder,
179
+ disabled: e.disabled
180
+ }, null, 8, Ee),
181
+ e.clearable && d.value && !e.disabled ? (f(), p("span", {
182
+ key: 0,
183
+ class: "hc-date-picker__clear",
184
+ onClick: oe(V, ["stop"])
185
+ }, " × ")) : F("", !0)
186
+ ], 2),
187
+ (f(), te(De, { to: "body" }, [
188
+ i.value ? (f(), p("div", {
189
+ key: 0,
190
+ ref_key: "popperRef",
191
+ ref: C,
192
+ class: A(["hc-date-picker__popper", { "is-dark": e.dark }]),
193
+ style: fe(x.value),
194
+ onMousedown: E[0] || (E[0] = oe(() => {
195
+ }, ["stop"]))
196
+ }, [
197
+ h("div", Ne, [
198
+ h("button", {
199
+ type: "button",
200
+ class: "hc-date-picker__icon-btn",
201
+ onClick: Q
202
+ }, "«"),
203
+ e.type === "date" ? (f(), p("button", {
204
+ key: 0,
205
+ type: "button",
206
+ class: "hc-date-picker__icon-btn",
207
+ onClick: $
208
+ }, " ‹ ")) : F("", !0),
209
+ h("span", Ye, M(t.value), 1),
210
+ e.type === "date" ? (f(), p("button", {
211
+ key: 1,
212
+ type: "button",
213
+ class: "hc-date-picker__icon-btn",
214
+ onClick: q
215
+ }, " › ")) : F("", !0),
216
+ h("button", {
217
+ type: "button",
218
+ class: "hc-date-picker__icon-btn",
219
+ onClick: j
220
+ }, "»")
221
+ ]),
222
+ e.type === "date" ? (f(), p("div", Pe, [
223
+ h("div", Se, [
224
+ (f(), p(W, null, H(r, (D) => h("span", { key: D }, M(D), 1)), 64))
225
+ ]),
226
+ h("div", Be, [
227
+ (f(!0), p(W, null, H(k.value, (D, P) => (f(), p("button", {
228
+ key: P,
229
+ type: "button",
230
+ class: A(["hc-date-picker__cell", {
231
+ "is-other": !D.current,
232
+ "is-selected": m.value && R(ue)(D.date, m.value),
233
+ "is-today": R(ue)(D.date, R(l))
234
+ }]),
235
+ onClick: ($t) => y(D.date)
236
+ }, M(D.date.getDate()), 11, ze))), 128))
237
+ ])
238
+ ])) : e.type === "month" ? (f(), p("div", Ue, [
239
+ (f(), p(W, null, H(12, (D) => h("button", {
240
+ key: D,
241
+ type: "button",
242
+ class: A(["hc-date-picker__cell hc-date-picker__cell--month", {
243
+ "is-selected": m.value && m.value.getFullYear() === u.value && m.value.getMonth() === D - 1
244
+ }]),
245
+ onClick: (P) => B(D - 1)
246
+ }, M(D) + "月 ", 11, Ie)), 64))
247
+ ])) : (f(), p("div", Ve, [
248
+ (f(!0), p(W, null, H(c.value, (D) => (f(), p("button", {
249
+ key: D,
250
+ type: "button",
251
+ class: A(["hc-date-picker__cell hc-date-picker__cell--year", { "is-selected": m.value && m.value.getFullYear() === D }]),
252
+ onClick: (P) => T(D)
253
+ }, M(D), 11, Oe))), 128))
254
+ ]))
255
+ ], 38)) : F("", !0)
256
+ ]))
257
+ ], 2));
258
+ }
259
+ }), G = /* @__PURE__ */ I(We, [["__scopeId", "data-v-b2bff9b8"]]), ve = G;
260
+ ve.install = (e) => {
261
+ e.component("HcDatePicker", G), e.component("DatePicker", G);
262
+ };
263
+ const He = { class: "box-title" }, qe = { class: "text" }, Re = {
264
+ key: 0,
265
+ class: "text-num"
266
+ }, Qe = { class: "num" }, je = /* @__PURE__ */ U({
267
+ __name: "BoxTitle",
268
+ props: {
269
+ title: {},
270
+ mountNum: {}
271
+ },
272
+ setup(e) {
273
+ return (a, o) => (f(), p("div", He, [
274
+ h("span", qe, M(e.title), 1),
275
+ e.mountNum ? (f(), p("p", Re, [
276
+ o[0] || (o[0] = ie(" 挂载总量:", -1)),
277
+ h("span", Qe, M(e.mountNum || "--"), 1),
278
+ o[1] || (o[1] = ie("个 ", -1))
279
+ ])) : F("", !0)
280
+ ]));
281
+ }
282
+ }), Ke = /* @__PURE__ */ I(je, [["__scopeId", "data-v-bc025af7"]]), Xe = { class: "module-panel" }, Ge = { class: "panel-content" }, Ze = /* @__PURE__ */ U({
283
+ __name: "ModulePanel",
284
+ props: {
285
+ title: {},
286
+ mountNum: {}
287
+ },
288
+ setup(e) {
289
+ return (a, o) => (f(), p("div", Xe, [
290
+ J(Ke, {
291
+ title: e.title,
292
+ mountNum: e.mountNum
293
+ }, null, 8, ["title", "mountNum"]),
294
+ h("div", Ge, [
295
+ de(a.$slots, "default", {}, void 0, !0)
296
+ ])
297
+ ]));
298
+ }
299
+ }), Je = /* @__PURE__ */ I(Ze, [["__scopeId", "data-v-c6a014b4"]]), et = { class: "time-control" }, tt = {
300
+ key: 0,
301
+ class: "filter-group"
302
+ }, at = { class: "dateStyl" }, nt = {
303
+ key: 0,
304
+ class: "title"
305
+ }, lt = /* @__PURE__ */ U({
306
+ name: "HcTimeControl",
307
+ __name: "TimeControl",
308
+ props: {
309
+ activeTime: { default: "日" },
310
+ time: { default: () => [] },
311
+ day: { default: () => [] },
312
+ month: { default: () => [] },
313
+ showLj: { type: Boolean, default: !0 },
314
+ showY: { type: Boolean, default: !0 },
315
+ showM: { type: Boolean, default: !0 },
316
+ showD: { type: Boolean, default: !0 },
317
+ showTime: { type: Boolean, default: !0 },
318
+ activeTimeModel1: { default: "选择时间" },
319
+ typeNumber: { default: "" },
320
+ titleOne: { default: "日" }
321
+ },
322
+ emits: ["update:activeTime", "update:time", "update:day", "update:month", "update:activeTimeModel1", "dateChange"],
323
+ setup(e, { expose: a, emit: o }) {
324
+ const n = e, r = o, l = (c) => {
325
+ const t = c.getFullYear(), s = String(c.getMonth() + 1).padStart(2, "0"), g = String(c.getDate()).padStart(2, "0");
326
+ return `${t}-${s}-${g}`;
327
+ }, b = (c) => {
328
+ c.length === 0 && r("update:activeTimeModel1", "选择时间");
329
+ };
330
+ z(() => n.day, b, { deep: !0 }), z(() => n.time, b, { deep: !0 }), z(() => n.month, b, { deep: !0 }), (() => {
331
+ const c = /* @__PURE__ */ new Date(), t = new Date(c.getFullYear(), c.getMonth(), c.getDate()), s = new Date(t);
332
+ s.setHours(23, 59, 59, 999);
333
+ const g = new Date(c.getFullYear(), c.getMonth(), 1), N = new Date(c.getFullYear(), 0, 1);
334
+ n.time.length === 0 && r("update:time", [l(t), l(s)]), n.day.length === 0 && r("update:day", [l(g), l(s)]), n.month.length === 0 && r("update:month", [l(N), l(s)]);
335
+ })();
336
+ const i = L({
337
+ get: () => n.activeTime,
338
+ set: (c) => r("update:activeTime", c)
339
+ }), x = L(() => i.value === "月" ? "month" : i.value === "年" || i.value === "累计" ? "year" : "date"), m = L(
340
+ () => ["日", "周", n.titleOne, "月", "年", "累计"].includes(i.value)
341
+ ), d = L(() => i.value === "月" ? "选择月份" : i.value === "年" ? "选择年份" : i.value === "累计" ? "累计" : "选择时间"), u = L({
342
+ get: () => i.value === "月" ? Array.isArray(n.day) && n.day.length > 0 ? String(n.day[0]) : "" : i.value === "年" || i.value === "累计" ? Array.isArray(n.month) && n.month.length > 0 ? String(n.month[0]) : "" : Array.isArray(n.time) && n.time.length > 0 ? String(n.time[0]) : "",
343
+ set: (c) => {
344
+ if (!c) {
345
+ i.value === "月" ? r("update:day", []) : i.value === "年" || i.value === "累计" ? r("update:month", []) : r("update:time", []);
346
+ return;
347
+ }
348
+ const t = new Date(c);
349
+ if (i.value === "月") {
350
+ const s = new Date(t.getFullYear(), t.getMonth(), 1), g = new Date(t.getFullYear(), t.getMonth() + 1, 0);
351
+ r("update:day", [l(s), l(g)]);
352
+ } else if (i.value === "年" || i.value === "累计") {
353
+ const s = t.getFullYear();
354
+ r("update:month", [`${s}-01-01`, `${s}-12-31`]);
355
+ } else {
356
+ const s = l(t);
357
+ r("update:time", [s, s]);
358
+ }
359
+ }
360
+ }), w = (c) => {
361
+ const t = /* @__PURE__ */ new Date();
362
+ if (c === n.titleOne) {
363
+ const s = new Date(t.getFullYear(), t.getMonth(), t.getDate()), g = new Date(s);
364
+ g.setHours(23, 59, 59, 999), r("update:time", [l(s), l(g)]), r("dateChange", [l(s), l(g)]);
365
+ } else if (c === "月") {
366
+ const s = new Date(t.getFullYear(), t.getMonth(), 1);
367
+ r("update:day", [l(s), l(t)]), r("dateChange", [l(s), l(t)]);
368
+ } else if (c === "年") {
369
+ const s = new Date(t.getFullYear(), 0, 1);
370
+ r("update:month", [l(s), l(t)]), r("dateChange", [l(s), l(t)]);
371
+ } else if (c === "累计")
372
+ r("dateChange", null);
373
+ else {
374
+ const s = new Date(t.getFullYear(), 0, 1);
375
+ r("dateChange", [l(s), l(t)]);
376
+ }
377
+ }, k = (c) => {
378
+ if (!c) {
379
+ r("dateChange", null);
380
+ return;
381
+ }
382
+ const t = new Date(c);
383
+ if (i.value === n.titleOne || i.value === "日") {
384
+ const s = new Date(t.getFullYear(), t.getMonth(), t.getDate()), g = new Date(t.getFullYear(), t.getMonth(), t.getDate(), 23, 59, 59, 999);
385
+ r("update:time", [l(s), l(g)]), r("dateChange", [l(s), l(g)]);
386
+ } else if (i.value === "月") {
387
+ const s = new Date(t.getFullYear(), t.getMonth(), 1), g = new Date(t.getFullYear(), t.getMonth() + 1, 0, 23, 59, 59, 999);
388
+ r("update:day", [l(s), l(g)]), r("dateChange", [l(s), l(g)]);
389
+ } else if (i.value === "年") {
390
+ const s = new Date(t.getFullYear(), 0, 1), g = new Date(t.getFullYear(), 11, 31, 23, 59, 59, 999);
391
+ r("update:month", [l(s), l(g)]), r("dateChange", [l(s), l(g)]);
392
+ }
393
+ }, v = (c) => {
394
+ i.value = c, w(c);
395
+ };
396
+ return a({ onTimeFn: v }), (c, t) => (f(), p("div", et, [
397
+ e.showTime ? (f(), p("div", tt, [
398
+ e.showD ? (f(), p("span", {
399
+ key: 0,
400
+ class: A(["filter-btn", { active: i.value === e.titleOne }]),
401
+ onClick: t[0] || (t[0] = (s) => v(e.titleOne))
402
+ }, M(e.titleOne), 3)) : F("", !0),
403
+ e.showM ? (f(), p("span", {
404
+ key: 1,
405
+ class: A(["filter-btn", { active: i.value === "月" }]),
406
+ onClick: t[1] || (t[1] = (s) => v("月"))
407
+ }, " 月 ", 2)) : F("", !0),
408
+ e.showY ? (f(), p("span", {
409
+ key: 2,
410
+ class: A(["filter-btn", { active: i.value === "年" }]),
411
+ onClick: t[2] || (t[2] = (s) => v("年"))
412
+ }, " 年 ", 2)) : F("", !0),
413
+ e.showLj ? (f(), p("span", {
414
+ key: 3,
415
+ class: A(["filter-btn", { active: i.value === "累计" }]),
416
+ onClick: t[3] || (t[3] = (s) => v("累计"))
417
+ }, " 累计 ", 2)) : F("", !0)
418
+ ])) : F("", !0),
419
+ h("div", at, [
420
+ e.titleOne != "周" ? (f(), p("span", nt, "选择时间:")) : F("", !0),
421
+ m.value ? (f(), te(G, {
422
+ key: x.value,
423
+ modelValue: u.value,
424
+ "onUpdate:modelValue": t[4] || (t[4] = (s) => u.value = s),
425
+ type: x.value,
426
+ placeholder: d.value,
427
+ disabled: i.value === "累计",
428
+ clearable: "",
429
+ size: "small",
430
+ dark: "",
431
+ onChange: k
432
+ }, null, 8, ["modelValue", "type", "placeholder", "disabled"])) : F("", !0)
433
+ ])
434
+ ]));
435
+ }
436
+ }), ot = /* @__PURE__ */ I(lt, [["__scopeId", "data-v-e501d06e"]]), Z = (e) => {
437
+ const a = e.toString();
438
+ if (a.replace(".", "").length > 4) {
439
+ const o = Math.abs(e);
440
+ return o >= 1e8 ? { value: (e / 1e8).toFixed(2), unit: "亿" } : o >= 1e7 ? { value: (e / 1e7).toFixed(2), unit: "千万" } : o >= 1e4 ? { value: (e / 1e4).toFixed(2), unit: "万" } : { value: Number(e.toFixed(2)).toString(), unit: "" };
441
+ }
442
+ return { value: a, unit: "" };
443
+ }, it = { class: "echsrtLine" }, st = /* @__PURE__ */ U({
444
+ __name: "ChartLine",
445
+ props: {
446
+ chartData: {
447
+ type: Object,
448
+ default: () => ({
449
+ xAxisData: [],
450
+ yAxisData: []
451
+ })
452
+ },
453
+ typeData: {
454
+ type: Array,
455
+ default: () => []
456
+ },
457
+ unit: {
458
+ type: String,
459
+ default: ""
460
+ },
461
+ xUnit: {
462
+ type: String,
463
+ default: ""
464
+ },
465
+ left: {
466
+ type: Number,
467
+ default: 2
468
+ },
469
+ right: {
470
+ type: Number,
471
+ default: 3
472
+ },
473
+ bottom: {
474
+ type: Number,
475
+ default: 10
476
+ },
477
+ unitLeft: {
478
+ type: Number,
479
+ default: 9
480
+ },
481
+ legendLeft: {
482
+ type: Number,
483
+ default: 0
484
+ }
485
+ },
486
+ setup(e) {
487
+ const a = e, o = L(
488
+ () => a.typeData.map((k, v) => {
489
+ var c, t;
490
+ return {
491
+ type: k.name,
492
+ data: ((t = (c = a.chartData) == null ? void 0 : c.yAxisData) == null ? void 0 : t[v]) || [],
493
+ color: k.color || "#00ff88",
494
+ unit: k.unit || a.unit
495
+ };
496
+ })
497
+ ), n = L(
498
+ () => o.value.some(
499
+ (k) => (k.data || []).some(
500
+ (v) => v != null && !Number.isNaN(Number(v))
501
+ )
502
+ )
503
+ ), r = S(null);
504
+ let l = null, b = null, C = 0;
505
+ const i = () => {
506
+ var v, c;
507
+ const k = o.value.map((t) => ({
508
+ name: t.type,
509
+ type: "line",
510
+ smooth: !0,
511
+ symbol: "none",
512
+ data: t.data,
513
+ lineStyle: {
514
+ width: 3,
515
+ color: t.color
516
+ },
517
+ areaStyle: {
518
+ color: {
519
+ type: "linear",
520
+ x: 0,
521
+ y: 0,
522
+ x2: 0,
523
+ y2: 1,
524
+ colorStops: [
525
+ { offset: 0, color: t.color },
526
+ { offset: 1, color: "transparent" }
527
+ ]
528
+ }
529
+ }
530
+ }));
531
+ return {
532
+ backgroundColor: "transparent",
533
+ color: o.value.map((t) => t.color),
534
+ tooltip: {
535
+ trigger: "axis",
536
+ appendToBody: !0,
537
+ backgroundColor: "rgba(0,0,0,0.8)",
538
+ borderColor: "#00ffff",
539
+ extraCssText: "z-index: 1000; pointer-events: auto;",
540
+ textStyle: { color: "#fff", fontSize: 12 },
541
+ axisPointer: {
542
+ type: "line",
543
+ lineStyle: { color: "#00ffff", type: "dashed" }
544
+ },
545
+ formatter: (t) => {
546
+ const s = t;
547
+ if (!(s != null && s.length)) return "";
548
+ const g = s[0].name ?? "";
549
+ let N = `<div style="margin-bottom: 5px;">${g}${g ? a.xUnit : ""}</div>`;
550
+ return s.forEach((Y) => {
551
+ const V = Y.value !== void 0 && Y.value !== null ? Z(Y.value).value + Z(Y.value).unit : "-";
552
+ N += `
553
+ <div style="display: flex; justify-content: space-between; align-items: center; gap: 15px; margin-bottom: 3px">
554
+ <span style="display: flex; align-items: center; gap: 4px;">
555
+ ${Y.marker || ""}
556
+ <span style="color: #ccc;">${Y.seriesName || ""}</span>
557
+ </span>
558
+ <span style="font-weight: bold;">
559
+ ${V} <span style="font-size: 10px; font-weight: normal; color: #888;">${a.unit || ""}</span>
560
+ </span>
561
+ </div>
562
+ `;
563
+ }), N;
564
+ }
565
+ },
566
+ legend: {
567
+ data: ((v = a.typeData) == null ? void 0 : v.map((t) => t.name)) || [],
568
+ icon: "path://M4,0 L12,0 Q16,0 16,4 L16,4 Q16,8 12,8 L4,8 Q0,8 0,4 L0,4 Q0,0 4,0 Z",
569
+ itemWidth: 12,
570
+ itemHeight: 6,
571
+ align: "left",
572
+ textStyle: {
573
+ color: "#fff",
574
+ fontSize: 12
575
+ },
576
+ top: 20,
577
+ left: a.legendLeft ? a.legendLeft : "center"
578
+ },
579
+ grid: {
580
+ left: `${a.left}%`,
581
+ right: `${a.right}%`,
582
+ top: 57,
583
+ bottom: `${a.bottom}%`,
584
+ containLabel: !0
585
+ },
586
+ xAxis: {
587
+ type: "category",
588
+ data: ((c = a.chartData) == null ? void 0 : c.xAxisData) || [],
589
+ boundaryGap: !1,
590
+ axisLine: {
591
+ lineStyle: { color: "#333" }
592
+ },
593
+ axisTick: { show: !1 },
594
+ axisLabel: {
595
+ color: "rgba(255,255,255,0.8)",
596
+ fontSize: 11,
597
+ fontWeight: 300,
598
+ margin: 10,
599
+ rotate: 0
600
+ }
601
+ },
602
+ yAxis: {
603
+ type: "value",
604
+ min: n.value ? void 0 : 0,
605
+ max: n.value ? void 0 : 100,
606
+ interval: n.value ? void 0 : 25,
607
+ splitNumber: 4,
608
+ nameGap: 0,
609
+ axisLine: { show: !1 },
610
+ axisTick: { show: !1 },
611
+ splitLine: {
612
+ lineStyle: { color: "rgba(255,255,255,0.08)" }
613
+ },
614
+ axisLabel: {
615
+ color: "rgba(255,255,255,0.8)",
616
+ fontSize: 12,
617
+ fontWeight: 300,
618
+ formatter: (t) => t >= 1e8 ? t / 1e8 + "亿" : t >= 1e6 ? t / 1e6 + "百万" : t >= 1e4 ? t / 1e4 + "万" : String(t)
619
+ }
620
+ },
621
+ series: k
622
+ };
623
+ }, x = () => {
624
+ b && (clearInterval(b), b = null);
625
+ }, m = () => {
626
+ l && (x(), l.dispatchAction({
627
+ type: "showTip",
628
+ seriesIndex: 0,
629
+ dataIndex: 0
630
+ }), b = setInterval(() => {
631
+ var v, c;
632
+ const k = ((c = (v = a.chartData) == null ? void 0 : v.xAxisData) == null ? void 0 : c.length) || 0;
633
+ k && (C = (C + 1) % k, l == null || l.dispatchAction({
634
+ type: "showTip",
635
+ seriesIndex: 0,
636
+ dataIndex: C
637
+ }));
638
+ }, 5e3));
639
+ }, d = () => {
640
+ var k, v;
641
+ r.value && (l = Ce.init(r.value), l.setOption(i()), (v = (k = a.chartData) == null ? void 0 : k.yAxisData) != null && v.length && setTimeout(() => m(), 5e3));
642
+ }, u = () => {
643
+ l && l.setOption(i(), !0);
644
+ }, w = () => {
645
+ l == null || l.resize();
646
+ };
647
+ return me(() => {
648
+ d(), window.addEventListener("resize", w);
649
+ }), ke(() => {
650
+ x(), l == null || l.dispose(), window.removeEventListener("resize", w);
651
+ }), z(
652
+ () => [a.chartData, a.typeData, a.unit, a.xUnit],
653
+ () => u(),
654
+ { deep: !0, flush: "post" }
655
+ ), (k, v) => (f(), p("div", it, [
656
+ h("div", {
657
+ ref_key: "chartRef",
658
+ ref: r,
659
+ class: "chart-container"
660
+ }, null, 512),
661
+ h("div", {
662
+ class: "unit",
663
+ style: fe({ left: e.unitLeft + "px" })
664
+ }, M(e.unit), 5)
665
+ ]));
666
+ }
667
+ }), rt = /* @__PURE__ */ I(st, [["__scopeId", "data-v-35a8b884"]]);
668
+ function Tt() {
669
+ return {
670
+ activeTime: "日",
671
+ time: [],
672
+ day: [],
673
+ month: [],
674
+ activeTimeModel1: "",
675
+ activeEnergy: "0",
676
+ typeIndex: 1,
677
+ unit: "kW·h"
678
+ };
679
+ }
680
+ function ut() {
681
+ return {
682
+ summary: {
683
+ originalEnergy: 0,
684
+ realtimeEnergy: 0,
685
+ monthCumulativeEnergy: 0,
686
+ yearCumulativeEnergy: 0,
687
+ totalCumulativeEnergy: 0
688
+ },
689
+ typeData: [
690
+ { name: "原始能耗", color: "#F2993D" },
691
+ { name: "实时能耗", color: "#FFFC3F" },
692
+ { name: "节能量", color: "#28FF87" }
693
+ ],
694
+ chartData: { xAxisData: [], yAxisData: [] },
695
+ xUnit: "日"
696
+ };
697
+ }
698
+ const ct = { class: "leftBottom" }, dt = {
699
+ key: 0,
700
+ class: "hc-loading"
701
+ }, mt = { class: "typeList" }, ft = ["onClick"], yt = { class: "num" }, pt = { class: "unit-small" }, vt = { class: "name" }, ht = { class: "unit" }, gt = { class: "chart-wrapper" }, Dt = { class: "energy-tabs" }, bt = ["onClick"], kt = /* @__PURE__ */ U({
702
+ name: "HcEnergyAnalysis",
703
+ __name: "EnergyAnalysis",
704
+ props: /* @__PURE__ */ se({
705
+ title: { default: "能耗分析" },
706
+ loading: { type: Boolean, default: !1 },
707
+ view: { default: () => ut() },
708
+ energyTypes: { default: () => [
709
+ { label: "电", value: "0", unit: "kW·h" },
710
+ { label: "水", value: "1", unit: "m³" },
711
+ { label: "气", value: "2", unit: "m³" }
712
+ ] },
713
+ typeList: { default: () => [
714
+ { name: "原始能耗", unit: "(kW·h)", value: "originalEnergy" },
715
+ { name: "实时能耗", unit: "(kW·h)", date: "日", value: "realtimeEnergy" },
716
+ { name: "月累计能耗", unit: "(kW·h)", value: "monthCumulativeEnergy", date: "月" },
717
+ { name: "年累计能耗", unit: "(kW·h)", value: "yearCumulativeEnergy", date: "年" },
718
+ { name: "累计总能耗", unit: "(kW·h)", value: "totalCumulativeEnergy", date: "累计" }
719
+ ] }
720
+ }, {
721
+ query: {
722
+ required: !0
723
+ },
724
+ queryModifiers: {}
725
+ }),
726
+ emits: /* @__PURE__ */ se(["query-change"], ["update:query"]),
727
+ setup(e, { emit: a }) {
728
+ const o = e, n = we(e, "query"), r = a, l = S(o.typeList.map((m) => ({ ...m })));
729
+ z(
730
+ () => n.value.unit,
731
+ (m) => {
732
+ l.value = l.value.map((d) => ({
733
+ ...d,
734
+ unit: `(${m})`
735
+ }));
736
+ },
737
+ { immediate: !0 }
738
+ ), z(
739
+ () => o.typeList,
740
+ (m) => {
741
+ l.value = m.map((d) => ({
742
+ ...d,
743
+ unit: `(${n.value.unit})`
744
+ }));
745
+ },
746
+ { deep: !0 }
747
+ );
748
+ const b = S(null);
749
+ function C() {
750
+ r("query-change");
751
+ }
752
+ function i(m) {
753
+ n.value.activeEnergy = m;
754
+ const d = o.energyTypes.find((u) => u.value === m);
755
+ d && (n.value.unit = d.unit), r("query-change");
756
+ }
757
+ function x(m, d) {
758
+ var u;
759
+ n.value.typeIndex = d, m.date ? (u = b.value) == null || u.onTimeFn(m.date) : r("query-change");
760
+ }
761
+ return (m, d) => (f(), te(Je, { title: e.title }, {
762
+ default: xe(() => [
763
+ h("div", ct, [
764
+ e.loading ? (f(), p("div", dt, [...d[5] || (d[5] = [
765
+ h("span", { class: "hc-loading__spinner" }, null, -1)
766
+ ])])) : F("", !0),
767
+ _e(J(ot, {
768
+ activeTime: n.value.activeTime,
769
+ "onUpdate:activeTime": d[0] || (d[0] = (u) => n.value.activeTime = u),
770
+ time: n.value.time,
771
+ "onUpdate:time": d[1] || (d[1] = (u) => n.value.time = u),
772
+ day: n.value.day,
773
+ "onUpdate:day": d[2] || (d[2] = (u) => n.value.day = u),
774
+ month: n.value.month,
775
+ "onUpdate:month": d[3] || (d[3] = (u) => n.value.month = u),
776
+ activeTimeModel1: n.value.activeTimeModel1,
777
+ "onUpdate:activeTimeModel1": d[4] || (d[4] = (u) => n.value.activeTimeModel1 = u),
778
+ "type-number": "2",
779
+ ref_key: "timeControlRef",
780
+ ref: b,
781
+ onDateChange: C
782
+ }, null, 8, ["activeTime", "time", "day", "month", "activeTimeModel1"]), [
783
+ [$e, n.value.typeIndex !== 0]
784
+ ]),
785
+ h("div", null, [
786
+ h("ul", mt, [
787
+ (f(!0), p(W, null, H(l.value, (u, w) => (f(), p("li", {
788
+ key: u.name,
789
+ onClick: (k) => x(u, w)
790
+ }, [
791
+ h("p", yt, [
792
+ h("span", null, M(R(Z)(e.view.summary[u.value] || 0).value), 1),
793
+ h("span", pt, M(R(Z)(e.view.summary[u.value] || 0).unit), 1)
794
+ ]),
795
+ h("div", {
796
+ class: A(["name_main", {
797
+ active: n.value.typeIndex !== 0 ? u.date === n.value.activeTime : w === 0
798
+ }])
799
+ }, [
800
+ h("p", vt, M(u.name), 1),
801
+ h("p", ht, M(u.unit), 1)
802
+ ], 2)
803
+ ], 8, ft))), 128))
804
+ ]),
805
+ h("div", gt, [
806
+ h("div", Dt, [
807
+ (f(!0), p(W, null, H(e.energyTypes, (u) => (f(), p("span", {
808
+ key: u.value,
809
+ class: A(["energy-tab", { active: n.value.activeEnergy === u.value }]),
810
+ onClick: (w) => i(u.value)
811
+ }, M(u.label), 11, bt))), 128))
812
+ ]),
813
+ J(rt, {
814
+ typeData: e.view.typeData,
815
+ legendLeft: 70,
816
+ right: 4,
817
+ unitLeft: 9,
818
+ unit: n.value.unit,
819
+ xUnit: e.view.xUnit,
820
+ chartData: e.view.chartData
821
+ }, null, 8, ["typeData", "unit", "xUnit", "chartData"])
822
+ ])
823
+ ])
824
+ ])
825
+ ]),
826
+ _: 1
827
+ }, 8, ["title"]));
828
+ }
829
+ }), ee = /* @__PURE__ */ I(kt, [["__scopeId", "data-v-076a9047"]]), ce = {
830
+ 日: "时",
831
+ 月: "日",
832
+ 年: "月",
833
+ 累计: "月"
834
+ }, wt = (e) => {
835
+ const a = e ? new Date(e) : /* @__PURE__ */ new Date();
836
+ return Number.isNaN(a.getTime()) ? 31 : new Date(a.getFullYear(), a.getMonth() + 1, 0).getDate();
837
+ }, xt = (e, a) => {
838
+ if (e === "日")
839
+ return Array.from({ length: 24 }, (o, n) => `${n}`.padStart(2, "0"));
840
+ if (e === "月") {
841
+ const o = wt(a);
842
+ return Array.from({ length: o }, (n, r) => `${r + 1}`);
843
+ }
844
+ return Array.from({ length: 12 }, (o, n) => `${n + 1}`);
845
+ };
846
+ function Mt(e) {
847
+ let a = "", o = "";
848
+ return e.activeTime1 === "日" ? (o = "hourly", a = e.time1[0]) : e.activeTime1 === "月" ? (o = "daily", a = e.day1[0]) : e.activeTime1 === "年" ? (o = "monthly", a = e.month1[0]) : e.activeTime1 === "累计" ? (o = "cumulative", a = e.month1[0]) : (o = "monthly", a = e.month1[0]), { selectedDate: a, timeDimension: o };
849
+ }
850
+ function Ft(e, a) {
851
+ var v, c, t, s, g, N, Y, V, O;
852
+ const o = (e == null ? void 0 : e.series) || [], { activeTime: n, typeIndex: r, unit: l, monthDate: b } = a, C = xt(n, b);
853
+ if (n === "累计") {
854
+ let y = [];
855
+ if (o.length > 0) {
856
+ const T = [...o].sort(
857
+ ($, q) => {
858
+ var Q, j;
859
+ return (((Q = q.dataPoints) == null ? void 0 : Q.length) || 0) - (((j = $.dataPoints) == null ? void 0 : j.length) || 0);
860
+ }
861
+ )[0];
862
+ (v = T == null ? void 0 : T.dataPoints) != null && v.length && (y = T.dataPoints.map(($) => $.timeLabel));
863
+ }
864
+ y.length || (y = C);
865
+ const B = ["#28FF87", "#F2993D", "#0783FA", "#1CC767"];
866
+ return {
867
+ xUnit: ce[n] || "月",
868
+ typeData: o.map((T, $) => ({
869
+ name: T.name,
870
+ color: B[$ % B.length]
871
+ })),
872
+ chartData: {
873
+ xAxisData: y,
874
+ yAxisData: o.map((T) => {
875
+ var $;
876
+ return ($ = T.dataPoints) != null && $.length ? T.dataPoints.map((q) => q.energyKwh) : y.map(() => null);
877
+ })
878
+ }
879
+ };
880
+ }
881
+ if (r === 0) {
882
+ const y = o.find(($) => $.name === "原始能耗"), B = ((c = y == null ? void 0 : y.dataPoints) == null ? void 0 : c.map(($) => $.timeLabel)) || C, T = ((t = y == null ? void 0 : y.dataPoints) == null ? void 0 : t.map(($) => $.energyKwh)) || [];
883
+ return {
884
+ xUnit: "月",
885
+ typeData: [{ name: "原始能耗", color: "#F2993D", unit: l }],
886
+ chartData: {
887
+ xAxisData: B,
888
+ yAxisData: T.length ? [T] : [B.map(() => null)]
889
+ }
890
+ };
891
+ }
892
+ const i = o.find((y) => y.name === "实时能耗"), x = o.find((y) => y.name === "原始能耗"), m = o.find((y) => y.name === "节能量");
893
+ let d = [];
894
+ (s = x == null ? void 0 : x.dataPoints) != null && s.length ? d = x.dataPoints.map((y) => y.timeLabel) : (g = i == null ? void 0 : i.dataPoints) != null && g.length ? d = i.dataPoints.map((y) => y.timeLabel) : (N = m == null ? void 0 : m.dataPoints) != null && N.length && (d = m.dataPoints.map((y) => y.timeLabel)), d.length || (d = C);
895
+ const u = ((Y = i == null ? void 0 : i.dataPoints) == null ? void 0 : Y.map((y) => y.energyKwh)) || [], w = ((V = x == null ? void 0 : x.dataPoints) == null ? void 0 : V.map((y) => y.energyKwh)) || [], k = ((O = m == null ? void 0 : m.dataPoints) == null ? void 0 : O.map((y) => y.energyKwh)) || [];
896
+ return {
897
+ xUnit: ce[n] || "日",
898
+ typeData: [
899
+ { name: "原始能耗", color: "#F2993D", unit: l },
900
+ { name: "实时能耗", color: "#FFFC3F", unit: l },
901
+ { name: "节能量", color: "#28FF87", unit: l }
902
+ ],
903
+ chartData: {
904
+ xAxisData: d,
905
+ yAxisData: [
906
+ w.length ? w : d.map(() => null),
907
+ u.length ? u : d.map(() => null),
908
+ k.length ? k : d.map(() => null)
909
+ ]
910
+ }
911
+ };
912
+ }
913
+ const he = ee;
914
+ he.install = (e) => {
915
+ e.component("HcEnergyAnalysis", ee), e.component("EnergyAnalysis", ee);
916
+ };
917
+ const _t = [pe, ve, he], At = {
918
+ install(e) {
919
+ _t.forEach((a) => {
920
+ e.use(a);
921
+ });
922
+ }
923
+ };
924
+ export {
925
+ pe as Button,
926
+ ve as DatePicker,
927
+ he as EnergyAnalysis,
928
+ Mt as buildEnergyQueryParams,
929
+ Tt as createDefaultEnergyQuery,
930
+ ut as createDefaultEnergyView,
931
+ At as default,
932
+ Ft as transformEnergyDashboard
933
+ };