mixdashboards 1.1.162 → 1.1.163

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,440 @@
1
+ var Te = Object.defineProperty, qe = Object.defineProperties;
2
+ var xe = Object.getOwnPropertyDescriptors;
3
+ var de = Object.getOwnPropertySymbols;
4
+ var Ae = Object.prototype.hasOwnProperty, Be = Object.prototype.propertyIsEnumerable;
5
+ var ce = (p, o, n) => o in p ? Te(p, o, { enumerable: !0, configurable: !0, writable: !0, value: n }) : p[o] = n, L = (p, o) => {
6
+ for (var n in o || (o = {}))
7
+ Ae.call(o, n) && ce(p, n, o[n]);
8
+ if (de)
9
+ for (var n of de(o))
10
+ Be.call(o, n) && ce(p, n, o[n]);
11
+ return p;
12
+ }, W = (p, o) => qe(p, xe(o));
13
+ import { defineComponent as ye, inject as ve, ref as V, computed as _, watch as me, openBlock as u, createElementBlock as v, normalizeClass as j, Fragment as A, renderList as B, createBlock as $, unref as i, withCtx as f, createVNode as r, createCommentVNode as S, createElementVNode as c, toDisplayString as b, createTextVNode as G, withKeys as Ee, withModifiers as Ie, nextTick as Me, resolveDynamicComponent as Ke, mergeProps as Oe } from "vue";
14
+ import { SchemaField as De } from "./vue3-form-element.esm.min-C0XZKEKW.js";
15
+ import { o as ke, q as Ue, r as ge, s as Ce, t as Y, w as Le, e as ee, x as Re, y as pe, _ as Je, z as ze } from "./index-fvf26vWK.js";
16
+ import { RefreshLeft as We, RefreshRight as je, Delete as Ge, Close as be, Plus as He, Warning as Qe, Check as fe, Search as Xe } from "@element-plus/icons-vue";
17
+ import { formItemContextKey as Ye, formContextKey as Ze, ElTooltip as Z, ElButton as P, ElIcon as el, ElTabs as ll, ElTabPane as H, ElInput as _e, ElSelect as he, ElOption as R } from "element-plus";
18
+ const al = {
19
+ key: 0,
20
+ class: "alarm-condition__toolbar"
21
+ }, tl = ["aria-label"], il = ["disabled", "aria-label", "onClick"], nl = { key: 0 }, ol = {
22
+ key: 1,
23
+ class: "alarm-condition__empty"
24
+ }, ul = ["aria-label"], sl = { class: "alarm-condition__panel-header" }, rl = { class: "alarm-condition__panel-content" }, dl = { class: "alarm-condition__field-groups" }, cl = { class: "alarm-condition__group-label" }, vl = ["aria-label", "onClick"], ml = {
25
+ key: 0,
26
+ class: "alarm-condition__empty"
27
+ }, pl = { class: "alarm-condition__group-label" }, bl = { class: "alarm-condition__choices" }, fl = { class: "alarm-condition__choices" }, _l = { class: "alarm-condition__literal" }, hl = /* @__PURE__ */ ye({
28
+ __name: "AlarmConditionWidget",
29
+ props: {
30
+ fields: {},
31
+ customFields: {},
32
+ fieldsPath: {},
33
+ customFieldsPath: {},
34
+ selectedFieldsPath: {},
35
+ valueKey: {},
36
+ labelKey: {},
37
+ unitKey: {},
38
+ valueFormat: {},
39
+ fieldsByMapping: {},
40
+ mappingUidPath: {},
41
+ maxItems: {},
42
+ modelValue: {},
43
+ formModel: { default: () => ({}) },
44
+ disabled: { type: Boolean },
45
+ readonly: { type: Boolean }
46
+ },
47
+ emits: ["update:modelValue"],
48
+ setup(p, { emit: o }) {
49
+ var re;
50
+ const n = p, Q = o, { t: N } = ke(), a = (t) => ee(N, t), E = ve(Ye, void 0), I = ve(Ze, void 0), M = () => n.valueFormat === "blocks" ? [] : "", s = V((re = n.modelValue) != null ? re : M()), m = V([s.value]), g = V(0), w = V(!1), h = V(null), T = V("fields"), q = V(""), y = V("number"), F = V(""), J = V(!0), k = _(() => n.disabled || n.readonly || (I == null ? void 0 : I.disabled)), C = _(() => Ue(s.value)), le = _(() => {
51
+ var t;
52
+ return n.valueFormat === "blocks" && C.value.length >= ((t = n.maxItems) != null ? t : 300);
53
+ }), z = _(() => ge(n, n.formModel)), K = _(() => new Map([...z.value.fields, ...z.value.customFields].map((t) => {
54
+ var e;
55
+ return [(e = t.reference) != null ? e : t.value, t];
56
+ }))), ae = _(() => n.fields !== void 0 || n.customFields !== void 0 || !!n.fieldsPath || !!n.customFieldsPath || n.fieldsByMapping !== void 0), O = _(() => Ce(s.value, ae.value ? [...K.value.values()] : void 0, n.maxItems)), te = _(() => F.value.trim() !== "" && Number.isFinite(Number(F.value))), Ve = _(() => [
57
+ { label: "映射表字段", fields: z.value.fields },
58
+ { label: "自定义字段", fields: z.value.customFields }
59
+ ].map((t) => W(L({}, t), { fields: t.fields.filter((e) => `${e.label} ${e.value}`.toLowerCase().includes(q.value.toLowerCase())) }))), Fe = _(() => [
60
+ { label: "撤销", icon: We, disabled: g.value === 0, run: () => ue(-1) },
61
+ { label: "重做", icon: je, disabled: g.value === m.value.length - 1, run: () => ue(1) },
62
+ { label: "清空条件", icon: Ge, disabled: !C.value.length, run: () => X(M()) }
63
+ ]), ie = (t) => `${t.label}${t.unit ? `(${t.unit})` : ""}`, $e = (t) => {
64
+ var e, l;
65
+ return K.value.has(Y(t)) ? ie(K.value.get(Y(t))) : (l = (e = C.value.find((d) => d.value === t)) == null ? void 0 : e.fieldValue) != null ? l : t;
66
+ };
67
+ function ne() {
68
+ Me(() => {
69
+ E == null || E.validate("change").catch(() => {
70
+ });
71
+ });
72
+ }
73
+ function oe(t) {
74
+ s.value = t, h.value = null, Q("update:modelValue", t), ne();
75
+ }
76
+ function X(t) {
77
+ k.value || JSON.stringify(t) === JSON.stringify(s.value) || (m.value = m.value.slice(0, g.value + 1), m.value.push(t), m.value.length > 100 && m.value.shift(), g.value = m.value.length - 1, oe(t));
78
+ }
79
+ function ue(t) {
80
+ const e = g.value + t;
81
+ k.value || e < 0 || e >= m.value.length || (g.value = e, oe(m.value[e]));
82
+ }
83
+ function Se() {
84
+ h.value = null, w.value = !0;
85
+ }
86
+ function Pe(t) {
87
+ if (k.value) return;
88
+ const e = C.value[t];
89
+ if (h.value = t, T.value = e.type === "operator" ? "operators" : e.type === "parenthesis" ? "parentheses" : e.type === "literal" ? "literal" : "fields", e.type === "literal")
90
+ if (y.value = ["true", "false"].includes(e.value) ? "boolean" : /^["']/.test(e.value) ? "string" : "number", J.value = e.value === "true", y.value === "string")
91
+ try {
92
+ F.value = String(Re(e.value).value);
93
+ } catch (l) {
94
+ F.value = e.value;
95
+ }
96
+ else F.value = e.value;
97
+ w.value = !0;
98
+ }
99
+ function D(t) {
100
+ if (k.value) return;
101
+ const e = C.value.map((l) => l.value);
102
+ if (h.value === null) {
103
+ if (le.value) return;
104
+ e.push(t);
105
+ } else e.splice(h.value, 1, t);
106
+ X(pe(e.map((l) => ({ type: "unknown", value: l })), n.valueFormat)), h.value = null;
107
+ }
108
+ function se() {
109
+ y.value === "number" && !te.value || D(y.value === "string" ? JSON.stringify(F.value) : y.value === "boolean" ? String(J.value) : String(Number(F.value)));
110
+ }
111
+ function we(t) {
112
+ X(pe(C.value.filter((e, l) => l !== t), n.valueFormat));
113
+ }
114
+ return me(() => n.modelValue, (t) => {
115
+ const e = t != null ? t : M();
116
+ JSON.stringify(e) !== JSON.stringify(s.value) && (s.value = e, m.value = [e], g.value = 0, h.value = null);
117
+ }, { deep: !0 }), me(K, () => {
118
+ C.value.length && ne();
119
+ }, { deep: !0 }), (t, e) => (u(), v("div", {
120
+ class: j(["alarm-condition", { "is-readonly": k.value }])
121
+ }, [
122
+ k.value ? S("", !0) : (u(), v("div", al, [
123
+ (u(!0), v(A, null, B(Fe.value, (l) => (u(), $(i(Z), {
124
+ key: l.label,
125
+ content: a(l.label),
126
+ placement: "top"
127
+ }, {
128
+ default: f(() => [
129
+ r(i(P), {
130
+ text: "",
131
+ circle: "",
132
+ icon: l.icon,
133
+ "aria-label": a(l.label),
134
+ disabled: l.disabled,
135
+ onClick: l.run
136
+ }, null, 8, ["icon", "aria-label", "disabled", "onClick"])
137
+ ]),
138
+ _: 2
139
+ }, 1032, ["content"]))), 128))
140
+ ])),
141
+ c("div", {
142
+ class: j(["alarm-condition__expression", { "has-error": !!O.value }]),
143
+ "aria-label": a("条件表达式")
144
+ }, [
145
+ (u(!0), v(A, null, B(C.value, (l, d) => {
146
+ var U, x;
147
+ return u(), v("div", {
148
+ key: d,
149
+ class: j(["alarm-condition__token", [`is-${l.type}`, { "is-selected": h.value === d && w.value, "is-unavailable": l.type === "field" && ae.value && !K.value.has(i(Y)(l.value)) }]])
150
+ }, [
151
+ c("button", {
152
+ type: "button",
153
+ class: "alarm-condition__token-body",
154
+ disabled: k.value,
155
+ "aria-label": `${a("编辑条件块")} ${(U = l.fieldValue) != null ? U : l.value}`,
156
+ onClick: (Ne) => Pe(d)
157
+ }, [
158
+ c("span", null, b(l.type === "field" ? $e(l.value) : l.value), 1),
159
+ l.type === "field" ? (u(), v("small", nl, b((x = l.fieldValue) != null ? x : l.value), 1)) : S("", !0)
160
+ ], 8, il),
161
+ k.value ? S("", !0) : (u(), $(i(P), {
162
+ key: 0,
163
+ class: "alarm-condition__remove",
164
+ text: "",
165
+ circle: "",
166
+ icon: i(be),
167
+ "aria-label": `${a("删除条件块")} ${d + 1}`,
168
+ title: a("删除条件块"),
169
+ onClick: (Ne) => we(d)
170
+ }, null, 8, ["icon", "aria-label", "title", "onClick"]))
171
+ ], 2);
172
+ }), 128)),
173
+ k.value ? S("", !0) : (u(), $(i(Z), {
174
+ key: 0,
175
+ content: a("追加条件块"),
176
+ placement: "top"
177
+ }, {
178
+ default: f(() => [
179
+ r(i(P), {
180
+ class: "alarm-condition__add",
181
+ icon: i(He),
182
+ "aria-label": a("追加条件块"),
183
+ disabled: le.value,
184
+ onClick: Se
185
+ }, null, 8, ["icon", "aria-label", "disabled"])
186
+ ]),
187
+ _: 1
188
+ }, 8, ["content"])),
189
+ k.value && !C.value.length ? (u(), v("span", ol, b(a("暂无条件")), 1)) : S("", !0)
190
+ ], 10, tl),
191
+ C.value.length ? (u(), v("div", {
192
+ key: 1,
193
+ class: j(["alarm-condition__status", { "has-error": !!O.value }]),
194
+ role: "status"
195
+ }, [
196
+ r(i(el), null, {
197
+ default: f(() => [
198
+ O.value ? (u(), $(i(Qe), { key: 0 })) : (u(), $(i(fe), { key: 1 }))
199
+ ]),
200
+ _: 1
201
+ }),
202
+ c("span", null, b(O.value ? a(O.value) : a("条件完整")), 1)
203
+ ], 2)) : S("", !0),
204
+ w.value && !k.value ? (u(), v("section", {
205
+ key: 2,
206
+ class: "alarm-condition__panel",
207
+ "aria-label": a("条件块选择")
208
+ }, [
209
+ c("div", sl, [
210
+ c("span", null, b(a(h.value === null ? "追加条件块" : "编辑条件块")), 1),
211
+ r(i(P), {
212
+ text: "",
213
+ circle: "",
214
+ icon: i(be),
215
+ "aria-label": a("关闭条件块选择"),
216
+ title: a("关闭"),
217
+ onClick: e[0] || (e[0] = (l) => w.value = !1)
218
+ }, null, 8, ["icon", "aria-label", "title"])
219
+ ]),
220
+ c("div", rl, [
221
+ r(i(ll), {
222
+ modelValue: T.value,
223
+ "onUpdate:modelValue": e[7] || (e[7] = (l) => T.value = l)
224
+ }, {
225
+ default: f(() => [
226
+ r(i(H), {
227
+ label: a("字段"),
228
+ name: "fields"
229
+ }, {
230
+ default: f(() => [
231
+ r(i(_e), {
232
+ modelValue: q.value,
233
+ "onUpdate:modelValue": e[1] || (e[1] = (l) => q.value = l),
234
+ "prefix-icon": i(Xe),
235
+ placeholder: a("搜索名称或字段标识"),
236
+ "aria-label": a("搜索字段"),
237
+ clearable: ""
238
+ }, null, 8, ["modelValue", "prefix-icon", "placeholder", "aria-label"]),
239
+ c("div", dl, [
240
+ (u(!0), v(A, null, B(Ve.value, (l) => (u(), v("div", {
241
+ key: l.label,
242
+ class: "alarm-condition__field-group"
243
+ }, [
244
+ c("div", cl, [
245
+ G(b(a(l.label)) + " ", 1),
246
+ c("span", null, b(l.fields.length), 1)
247
+ ]),
248
+ (u(!0), v(A, null, B(l.fields, (d) => (u(), v("button", {
249
+ key: d.value,
250
+ type: "button",
251
+ class: "alarm-condition__field-option",
252
+ "aria-label": `${a("选择字段")} ${d.value}`,
253
+ onClick: (U) => {
254
+ var x;
255
+ return D((x = d.reference) != null ? x : d.value);
256
+ }
257
+ }, [
258
+ c("span", null, b(ie(d)), 1),
259
+ c("small", null, b(d.value), 1)
260
+ ], 8, vl))), 128)),
261
+ l.fields.length ? S("", !0) : (u(), v("div", ml, b(a("暂无可选字段")), 1))
262
+ ]))), 128))
263
+ ])
264
+ ]),
265
+ _: 1
266
+ }, 8, ["label"]),
267
+ r(i(H), {
268
+ label: a("运算符"),
269
+ name: "operators"
270
+ }, {
271
+ default: f(() => [
272
+ (u(!0), v(A, null, B(i(Le), (l) => (u(), v("div", {
273
+ key: l.label,
274
+ class: "alarm-condition__operator-group"
275
+ }, [
276
+ c("div", pl, b(a(l.label)), 1),
277
+ c("div", bl, [
278
+ (u(!0), v(A, null, B(l.items, ([d, U]) => (u(), $(i(P), {
279
+ key: d,
280
+ "aria-label": `${a("选择运算符")} ${d}`,
281
+ onClick: (x) => D(d)
282
+ }, {
283
+ default: f(() => [
284
+ c("code", null, b(d), 1),
285
+ G(b(a(U)), 1)
286
+ ]),
287
+ _: 2
288
+ }, 1032, ["aria-label", "onClick"]))), 128))
289
+ ])
290
+ ]))), 128))
291
+ ]),
292
+ _: 1
293
+ }, 8, ["label"]),
294
+ r(i(H), {
295
+ label: a("括号"),
296
+ name: "parentheses"
297
+ }, {
298
+ default: f(() => [
299
+ c("div", fl, [
300
+ r(i(P), {
301
+ "aria-label": a("左括号"),
302
+ onClick: e[2] || (e[2] = (l) => D("("))
303
+ }, {
304
+ default: f(() => [
305
+ e[8] || (e[8] = c("code", null, "(", -1)),
306
+ G(b(a("左括号")), 1)
307
+ ]),
308
+ _: 1
309
+ }, 8, ["aria-label"]),
310
+ r(i(P), {
311
+ "aria-label": a("右括号"),
312
+ onClick: e[3] || (e[3] = (l) => D(")"))
313
+ }, {
314
+ default: f(() => [
315
+ e[9] || (e[9] = c("code", null, ")", -1)),
316
+ G(b(a("右括号")), 1)
317
+ ]),
318
+ _: 1
319
+ }, 8, ["aria-label"])
320
+ ])
321
+ ]),
322
+ _: 1
323
+ }, 8, ["label"]),
324
+ r(i(H), {
325
+ label: a("常量"),
326
+ name: "literal"
327
+ }, {
328
+ default: f(() => [
329
+ c("div", _l, [
330
+ r(i(he), {
331
+ modelValue: y.value,
332
+ "onUpdate:modelValue": e[4] || (e[4] = (l) => y.value = l),
333
+ "aria-label": a("常量类型")
334
+ }, {
335
+ default: f(() => [
336
+ r(i(R), {
337
+ value: "number",
338
+ label: a("数值")
339
+ }, null, 8, ["label"]),
340
+ r(i(R), {
341
+ value: "string",
342
+ label: a("文本")
343
+ }, null, 8, ["label"]),
344
+ r(i(R), {
345
+ value: "boolean",
346
+ label: a("布尔值")
347
+ }, null, 8, ["label"])
348
+ ]),
349
+ _: 1
350
+ }, 8, ["modelValue", "aria-label"]),
351
+ y.value === "boolean" ? (u(), $(i(he), {
352
+ key: 0,
353
+ modelValue: J.value,
354
+ "onUpdate:modelValue": e[5] || (e[5] = (l) => J.value = l),
355
+ "aria-label": a("布尔值")
356
+ }, {
357
+ default: f(() => [
358
+ r(i(R), {
359
+ value: !0,
360
+ label: "true"
361
+ }),
362
+ r(i(R), {
363
+ value: !1,
364
+ label: "false"
365
+ })
366
+ ]),
367
+ _: 1
368
+ }, 8, ["modelValue", "aria-label"])) : (u(), $(i(_e), {
369
+ key: 1,
370
+ modelValue: F.value,
371
+ "onUpdate:modelValue": e[6] || (e[6] = (l) => F.value = l),
372
+ type: y.value === "number" ? "number" : "text",
373
+ "aria-label": a("常量值"),
374
+ placeholder: a("常量值"),
375
+ onKeydown: Ee(Ie(se, ["prevent"]), ["enter"])
376
+ }, null, 8, ["modelValue", "type", "aria-label", "placeholder", "onKeydown"])),
377
+ r(i(Z), {
378
+ content: a("确定常量")
379
+ }, {
380
+ default: f(() => [
381
+ r(i(P), {
382
+ icon: i(fe),
383
+ "aria-label": a("确定常量"),
384
+ disabled: y.value === "number" && !te.value,
385
+ onClick: se
386
+ }, null, 8, ["icon", "aria-label", "disabled"])
387
+ ]),
388
+ _: 1
389
+ }, 8, ["content"])
390
+ ])
391
+ ]),
392
+ _: 1
393
+ }, 8, ["label"])
394
+ ]),
395
+ _: 1
396
+ }, 8, ["modelValue"])
397
+ ])
398
+ ], 8, ul)) : S("", !0)
399
+ ], 2));
400
+ }
401
+ }), yl = /* @__PURE__ */ Je(hl, [["__scopeId", "data-v-763d6bb5"]]), Sl = /* @__PURE__ */ ye({
402
+ inheritAttrs: !1,
403
+ __name: "AlarmConditionField",
404
+ props: {
405
+ schema: {},
406
+ uiSchema: { default: () => ({}) },
407
+ fieldProps: { default: () => ({}) },
408
+ rootFormData: { default: () => ({}) },
409
+ required: { type: Boolean },
410
+ customRule: {}
411
+ },
412
+ setup(p) {
413
+ const o = p, { t: n } = ke(), Q = De, N = _(() => ze(o.schema, o.uiSchema, o.fieldProps));
414
+ function a(s) {
415
+ const m = L({}, s);
416
+ return delete m["ui:field"], delete m["ui:fieldProps"], m;
417
+ }
418
+ const E = _(() => a(o.schema)), I = _(() => W(L({}, a(o.uiSchema)), {
419
+ "ui:widget": yl,
420
+ "ui:options": W(L({}, N.value), { formModel: o.rootFormData, emptyValue: o.schema.type === "array" ? [] : "" })
421
+ }));
422
+ function M(s) {
423
+ var T, q;
424
+ if (((q = (T = o.uiSchema["ui:required"]) != null ? T : o.schema["ui:required"]) != null ? q : o.required) && (s.value === void 0 || s.value === null || typeof s.value == "string" && !s.value.trim() || Array.isArray(s.value) && !s.value.length))
425
+ return s.callback(ee(n, "必填项不能为空"));
426
+ const g = ge(N.value, o.rootFormData), w = ["fields", "customFields", "fieldsPath", "customFieldsPath", "fieldsByMapping"].some((y) => y in N.value), h = Ce(s.value, w ? [...g.fields, ...g.customFields] : void 0, N.value.maxItems);
427
+ return h ? s.callback(ee(n, h)) : o.customRule ? o.customRule(s) : s.callback();
428
+ }
429
+ return (s, m) => (u(), $(Ke(i(Q)), Oe(s.$attrs, {
430
+ schema: E.value,
431
+ "ui-schema": I.value,
432
+ "root-form-data": p.rootFormData,
433
+ required: p.required,
434
+ "custom-rule": M
435
+ }), null, 16, ["schema", "ui-schema", "root-form-data", "required"]));
436
+ }
437
+ });
438
+ export {
439
+ Sl as default
440
+ };