@farris/ui-vue
Version:
Farris Vue, a Farris Design based Vue3 component library.
1,665 lines (1,663 loc) • 60.9 kB
JavaScript
var he = Object.defineProperty;
var we = (i, e, t) => e in i ? he(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
var B = (i, e, t) => we(i, typeof e != "symbol" ? e + "" : e, t);
import { getCustomStyle as te, getCustomClass as ne, excludeProperties as ye, withInstall as Ce } from "../../components/common/index.esm.js";
import be, { listViewProps as Ie, FListViewTable as Ve } from "../../components/list-view/index.esm.js";
import { resolveAppearance as Se, createPropsResolver as oe, getPropsResolverGenerator as le, createCollectionBindingResolver as xe } from "../../components/dynamic-resolver/index.esm.js";
import { ref as I, computed as D, createVNode as a, Fragment as q, watch as Me, withModifiers as Te, withDirectives as ke, vModelText as Ee, createTextVNode as j, defineComponent as ae, inject as X, onMounted as re } from "vue";
import { DgControl as G, canvasChanged as Pe, refreshCanvas as Fe, useDesignerComponent as ce } from "../../components/designer-canvas/index.esm.js";
import { useFilter as Re, useIdentify as Ne, useHierarchy as Be, useGroupData as Ue, useDataView as $e, useSelection as De, useRow as Ae, useEdit as _e, useVisualDataBound as Le, useVisualDataCell as Oe, useVisualDataRow as je, useVisualGroupRow as Ge, useVisualSummaryRow as He, useVisualData as qe } from "../../components/data-view/index.esm.js";
import { LocaleService as We } from "../../components/locale/index.esm.js";
import { FCheckbox as J } from "../../components/checkbox/index.esm.js";
import { cloneDeep as ze } from "lodash-es";
function Ye(i, e) {
function t(l) {
const s = [];
let d = l.nextNode();
for (; d; )
s.push(d), d = l.nextNode();
return s;
}
function n(l, s) {
const d = document.createTreeWalker(l, NodeFilter.SHOW_TEXT);
return t(d).map((u) => ({ textNode: u, text: (u.textContent || "").toLocaleLowerCase() })).map(({ textNode: u, text: g }) => {
const h = [];
let w = 0;
for (; w < g.length; ) {
const V = g.indexOf(s, w);
if (V === -1)
break;
h.push(V), w = V + s.length;
}
return h.map((V) => {
const y = new Range();
return y.setStart(u, V), y.setEnd(u, V + s.length), y;
});
}).flat();
}
function o(l) {
if (!CSS.highlights || (CSS.highlights.clear(), !l || !e))
return;
const s = n(e.value, l.toLocaleLowerCase()), d = new Highlight(...s);
CSS.highlights.set("search-result", d);
}
return { search: o };
}
function se(i, e, t, n, o, l, s, d, r, m) {
const c = I(i.size), u = I(i.textField), g = I(i.titleField), h = I(i.disableField), w = D(() => {
var v, T;
return ((v = i.selection) == null ? void 0 : v.multiSelect) && ((T = i.selection) == null ? void 0 : T.showCheckbox);
}), {
onMouseenterItem: V,
onMouseoverItem: y,
onMouseoutItem: b
} = l, {
getKey: S,
listViewItemClass: F,
listViewItemStyle: E,
onCheckItem: U,
onClickItem: M
} = s, $ = D(() => {
const v = {
"text-overflow": "ellipsis",
overflow: "hidden",
"white-space": "nowrap"
};
return i.itemClass ? v : {
margin: c.value === "small" ? "0.25rem 0" : "8px 0",
...v
};
});
function x(v, T, R) {
return v.checked = d.findIndexInSelectedItems(v) > -1, a("li", {
class: F(v, T),
id: S(v, T),
key: S(v, T),
style: E(v, T),
onClick: (N) => M(v, T, N),
onMouseenter: (N) => V(N, v, T),
onMouseover: (N) => y(N, v, T),
onMouseout: (N) => b(N, v, T)
}, [w.value && a("div", {
class: "f-list-select",
onClick: (N) => N.stopPropagation()
}, [a(J, {
id: "list-" + S(v, T),
customClass: "listview-checkbox float-left",
disabled: v[h.value],
checked: v.checked,
"onUpdate:checked": (N) => v.checked = N,
onChange: (N) => {
U(v, T, !N.checked);
}
}, null)]), a("div", {
class: "f-list-content"
}, [a("div", {
class: i.itemContentClass,
style: $.value,
title: v.raw[g.value] || v.raw[u.value]
}, [v.raw[u.value]])])]);
}
return {
renderItem: x
};
}
function Ke(i, e, t, n, o, l, s, d, r, m) {
const c = I(i.multiSelect), u = I(i.disableField), g = I(i.textField), {
onMouseenterItem: h,
onMouseoverItem: w,
onMouseoutItem: V
} = l, {
getKey: y,
listViewItemClass: b,
listViewItemStyle: S,
onCheckItem: F,
onClickItem: E,
updateSelectedItems: U
} = s;
function M(x, v, T) {
return i.contentTemplate ? a(q, null, [i.contentTemplate({
item: x.raw,
index: v,
selectedItem: T
})]) : e.slots.content ? a(q, null, [e.slots.content && e.slots.content({
item: x.raw,
index: v,
selectedItem: T
})]) : a("div", {
style: "margin: 10px 0;"
}, [x.raw[g.value || "name"]]);
}
function $(x, v, T) {
return a("li", {
class: b(x, v),
id: y(x, v),
key: y(x, v),
style: S(x, v),
onClick: (R) => E(x, v, R),
onMouseenter: (R) => h(R, x, v),
onMouseover: (R) => w(R, x, v),
onMouseout: (R) => V(R, x, v)
}, [c.value && a("div", {
class: "f-list-select",
onClick: (R) => R.stopPropagation()
}, [a(J, {
id: "list-" + y(x, v),
customClass: "listview-checkbox",
disabled: x[u.value],
checked: x.checked,
"onUpdate:checked": (R) => x.checked = R,
onChange: (R) => {
F(x, v, !R.checked), U();
}
}, null)]), a("div", {
class: "f-list-content"
}, [M(x, v, T)])]);
}
return {
renderItem: $
};
}
function Xe(i, e, t, n, o, l, s, d, r, m) {
const c = I(i.multiSelect), u = I(i.disableField), g = I(i.textField), {
onMouseenterItem: h,
onMouseoverItem: w,
onMouseoutItem: V
} = l, {
getKey: y,
listViewItemClass: b,
onCheckItem: S,
onClickItem: F
} = s, {
dragstart: E,
dragenter: U,
dragover: M,
dragend: $
} = n, {
removeItem: x
} = r, v = D(() => ({
margin: c.value ? "10px 0" : "10px 0px 10px 14px"
}));
function T(p, f = "") {
const P = p.target;
P.title = P.scrollWidth > P.clientWidth ? f : "";
}
function R(p) {
return a("div", {
style: v.value,
onMouseenter: (f) => T(f, p.raw[g.value || "name"])
}, [p.raw[g.value || "name"]]);
}
function N() {
return e.slots.itemContent ? e.slots.itemContent : R;
}
const L = N();
function k(p, f, P) {
return a("li", {
class: b(p, f),
id: y(p, f),
key: y(p, f),
onClick: (C) => F(p, f, C),
onMouseenter: (C) => h(C, p, f),
onMouseover: (C) => w(C, p, f),
onMouseout: (C) => V(C, p, f),
draggable: "true",
onDragstart: (C) => E(C, p, f),
onDragenter: (C) => U(C, f),
onDragend: (C) => $(C, p),
onDragover: (C) => M(C)
}, [c.value && a("div", {
class: "f-list-select",
onClick: (C) => C.stopPropagation()
}, [a(J, {
id: "list-" + y(p, f),
customClass: "listview-checkbox",
disabled: p[u.value],
checked: p.checked,
"onUpdate:checked": (C) => p.checked = C,
onChange: (C) => S(p, f, !C.checked)
}, null)]), a("div", {
class: "f-list-content"
}, [L(p)]), i.allowDelete && a("div", {
class: "f-list-remove",
onClick: (C) => {
C.stopPropagation(), x(f);
}
}, [a("div", {
class: "f-list-remove-icon"
}, [a("i", {
class: "f-icon f-icon-remove_face"
}, null)])]), a("div", {
class: "f-list-handle"
}, [a("div", null, [a("i", {
class: "f-icon f-icon-drag-vertical"
}, null)])])]);
}
return {
renderItem: k
};
}
function Je(i, e, t, n, o, l, s, d, r, m) {
var y;
const c = I(((y = i.group) == null ? void 0 : y.groupFields) || []), {
collpaseGroupIconClass: u
} = o, {
toggleGroupRow: g
} = m;
function h(b, S) {
b.stopPropagation(), S.collapse = !S.collapse, t.value = g(S.collapse ? "collapse" : "expand", S, t.value);
}
function w(b, S, F) {
return e.slots.group ? a(q, null, [e.slots.content && e.slots.group({
item: b.raw,
index: S,
selectedItem: F
})]) : a("div", {
class: "f-navlookup-recentHeader",
onClick: (E) => h(E, b)
}, [a("div", {
class: "fv-grid-group-row-icon"
}, [a("span", {
class: u(b)
}, null)]), a("div", {
class: "f-navlookup-recommandLabel"
}, [b.raw[c.value[b.layer]]])]);
}
function V(b, S, F) {
return b.layer > -1 && w(b, S, F);
}
return {
renderItem: V
};
}
function Qe(i, e, t, n) {
const { dataView: o } = t, { updateSelectedItems: l } = n;
function s(d) {
if (d > -1 && d < o.value.length) {
if (i != null && i.checkBeforeRemoveItem && !i.checkBeforeRemoveItem(o.value[d]))
return;
const r = o.value.splice(d, 1);
l(), e.emit("removeItem", r[0]);
}
}
return { removeItem: s };
}
function Ze(i, e, t, n, o, l, s, d, r, m) {
const c = I(i.view), u = I(i.view === "CardView"), g = I({}), h = Qe(i, e, n, r), w = D(() => ({
"f-list-view-group": !0,
"f-list-view-group-multiselect": i.multiSelect,
"d-flex": u.value,
"flex-wrap": u.value
})), V = D(() => !!t.value && t.value.length > 0), y = D(() => t.value.length === 0);
D(() => y.value && !e.slots.empty);
function b() {
return c.value === "SingleView" ? se : c.value === "DraggableView" ? Xe : (c.value === "ContentView" || c.value === "CardView") && (i.contentTemplate || e.slots.content) ? Ke : se;
}
const S = b(), {
renderItem: F
} = S(i, e, t, m, o, l, r, s, h, d), {
renderItem: E
} = Je(i, e, t, m, o, l, r, s, h, d), U = [F, E];
function M() {
return t.value.filter((v) => v.visible !== !1).map((v, T) => U[v.type](v, T, g));
}
function $() {
return a("div", {
class: "f-list-view-emptydata",
style: "margin: 0 auto;"
}, [a("p", {
class: "f-empty-title"
}, [i.emptyTemplate ? i.emptyTemplate() : e.slots.empty ? e.slots.empty() : We.getLocaleValue("listView.emptyMessage")])]);
}
function x() {
return a("ul", {
class: w.value,
style: "list-style: none;"
}, [V.value && M(), y.value && $()]);
}
return {
renderListArea: x
};
}
function et(i, e, t) {
function n() {
return e.slots.header && a("div", {
class: "f-list-view-header"
}, [e.slots.header()]);
}
return {
renderHeader: n
};
}
function ie(i, e, t) {
const n = I(i.headerClass), o = I(i.placeholder), l = I(""), s = D(() => !l.value), d = D(() => !!l.value);
function r(g) {
l.value = "";
}
Me(l, (g) => {
i.enableHighlightSearch && t.search(g), e.emit("afterSearch", g);
});
const m = D(() => {
const g = {
"form-group": !0,
"farris-form-group": !0
};
return n.value && n.value.split(" ").reduce((w, V) => (w[V] = !0, w), g), g;
});
function c(g) {
}
function u() {
return a("div", {
class: "f-list-view-header",
onClick: Te(() => c, ["prevent", "stop"])
}, [a("div", {
class: m.value
}, [a("div", {
class: "farris-input-wrap"
}, [a("div", {
class: "f-cmp-inputgroup"
}, [a("div", {
class: "input-group f-state-editable"
}, [ke(a("input", {
class: "form-control f-utils-fill text-left",
"onUpdate:modelValue": (g) => l.value = g,
name: "input-group-value",
type: "text",
placeholder: o.value,
autocomplete: "off"
}, null), [[Ee, l.value]]), a("div", {
class: "input-group-append"
}, [d.value && a("span", {
class: "input-group-text input-group-clear",
onClick: (g) => r()
}, [a("i", {
class: "f-icon f-icon-close-circle"
}, null)]), s.value && a("span", {
class: "input-group-text"
}, [a("span", {
class: "f-icon f-icon-search"
}, null)])])])])])])]);
}
return {
renderHeader: u
};
}
function tt() {
const i = I(""), e = I(-1), t = I(""), n = I(-1), o = I(!1);
function l(u, g, h) {
n.value = h;
}
function s(u, g, h) {
o.value || (n.value = h);
}
function d(u, g, h) {
n.value = -1;
}
function r() {
o.value = !0;
}
function m() {
o.value = !1;
}
function c() {
e.value = -1, i.value = "";
}
return {
activeIndex: e,
focusedItemId: t,
hoverIndex: n,
clearActiveItem: c,
onMouseenterItem: l,
onMouseoverItem: s,
onMouseoutItem: d,
resumeHover: m,
suspendHover: r
};
}
function nt(i, e, t, n, o) {
const l = I(i.idField), { dataView: s } = t, d = I(-1), r = I(!1), { activeIndex: m, focusedItemId: c, hoverIndex: u, resumeHover: g, suspendHover: h } = n;
let w, V = 0, y = 0, b = null, S = null;
const F = 10, E = 50;
function U(p) {
if (!p)
return null;
const { overflowY: f } = getComputedStyle(p);
return f === "auto" || f === "scroll" ? p : U(p.parentElement);
}
function M(p, f) {
S && clearInterval(S), S = window.setInterval(() => {
f === "up" ? p.scrollTop -= F : p.scrollTop += F;
}, 16);
}
function $() {
S && (clearInterval(S), S = null);
}
function x(p) {
const f = p.target;
if (b || (b = U(f)), !b) {
$();
return;
}
const P = b.getBoundingClientRect(), C = p.clientY, _ = C - P.top, A = P.bottom - C;
_ < E && b.scrollTop > 0 ? M(b, "up") : A < E && b.scrollTop < b.scrollHeight - b.clientHeight ? M(b, "down") : $();
}
function v(p, f) {
const P = p - V, C = f - y;
w.style.left = parseInt(w.style.left) + P + "px", w.style.top = parseInt(w.style.top) + C + "px", V = p, y = f;
}
function T(p) {
const { left: f, top: P } = p.getBoundingClientRect(), C = p.cloneNode(!0);
return C.className = C.className + " f-listview-drag-moving", C.style.cssText = `
position:absolute;
left:${f}px;
top:${document.documentElement.scrollTop ? P + document.documentElement.scrollTop : P}px;
z-index: 999999;
pointer-events: none;
border-radius: 10px;
margin: 4px 2px;
display: flex;
align-items: center;
float: none;
text-align: initial;
width:${getComputedStyle(p).width};
height:${getComputedStyle(p).height};
`, C.children[0].style.cssText = "padding: 0 0 0 14px", C.children[0].children[0].style.cssText = `
margin: 10px 0px 10px 14px;
overflow: hidden;text-overflow: ellipsis;white-space: nowrap;
`, C.children[1].style.cssText = "flex:1 1 auto; width:100%", C.children[2].style.cssText = "padding: 0 14px 0 0", C.children[2].children[0].style.cssText = "display: initial", document.body.appendChild(C), C;
}
function R(p, f, P) {
if (p.stopPropagation(), h(), f) {
if (w = T(p.target), p.dataTransfer) {
const C = new Image();
C.src = "", p.dataTransfer.setDragImage(C, 0, 0);
}
V = p.pageX, y = p.pageY, setTimeout(() => {
d.value = P, r.value = !0, f.moving = !0;
});
}
}
function N(p, f) {
if (p.preventDefault(), d.value !== f && d.value !== -1) {
const P = s.value[d.value], C = o.value[d.value];
P && C && (s.value.splice(d.value, 1), s.value.splice(f, 0, P), o.value.splice(d.value, 1), o.value.splice(f, 0, C), o.value.forEach((_, A) => {
_.index = A, _.raw.__fv_index__ = A;
}), d.value = f, v(p.pageX, p.pageY));
}
}
function L(p) {
p.preventDefault(), p.dataTransfer && (p.dataTransfer.dropEffect = "move"), v(p.pageX, p.pageY), x(p);
}
function k(p, f) {
var C, _;
$(), b = null, f && (f.moving = !1, w && (document.body.removeChild(w), w = null)), s.value.forEach((A, O) => {
A.__fv_index__ = O;
}), o.value.forEach((A, O) => {
A.index = O, A.raw && (A.raw.__fv_index__ = O);
}), r.value = !1, g();
const P = ((C = f.raw) == null ? void 0 : C.__fv_index__) ?? 0;
u.value = P, m.value = P, c.value = (_ = f.raw) == null ? void 0 : _[l.value], e.emit("change", s.value), e.emit("activeChange", [f.raw]);
}
return {
dragstart: R,
dragenter: N,
dragover: L,
dragend: k,
isDragging: r
};
}
function st(i, e, t, n, o, l) {
const s = I(i.idField), d = I(i.disableField), r = I(i.draggable);
I(i.itemClass);
const m = I(i.selection.multiSelect ?? !1), c = I(i.selection.multiSelectMode), { isDragging: u } = n, { activeIndex: g, focusedItemId: h, hoverIndex: w } = o, { clearSelection: V, getSelectedItems: y, toggleSelectItem: b, currentSelectedDataId: S, multiSelectOnlyOnCheck: F } = l, E = I(y()), U = (k) => E.value.length === 0 ? !1 : E.value.some((p) => {
let f = "";
return p.data ? f = p.data[s.value] : f = p[s.value], f === k;
});
function M() {
E.value = y();
}
function $(k, p) {
return k.raw[s.value] != null ? k.raw[s.value] + "_" + p : "";
}
function x(k, p) {
const f = {
"f-list-view-group-item": !0,
"f-list-view-draggable-item": r.value,
"f-un-click": !k.checked,
"f-un-select": !!k.raw[d.value],
"f-listview-active": (
// 多选
m.value && U($(k, p)) && i.showActiveWhenMultiSelect || // 单选
!m.value && k.raw[s.value] === S.value || m.value && !i.showActiveWhenMultiSelect && k.raw[s.value] === S.value
),
"f-listview-hover": !u.value && p === w.value,
moving: !!k.moving
};
if (typeof i.itemClass == "string")
return ne(f, i.itemClass);
if (typeof i.itemClass == "function") {
const P = i.itemClass(k);
return ne(f, P);
}
return f;
}
function v(k, p) {
const f = {};
if (typeof i.itemStyle == "string")
return te(f, i.itemStyle);
if (typeof i.itemStyle == "function") {
const P = i.itemStyle(k);
return te(f, P);
}
return f;
}
const T = D(() => !m.value);
function R(k, p, f) {
k.checked = f, !k.raw[d.value] && (T.value && (h.value = k.raw[s.value]), b(k));
}
const N = D(() => !m.value || m.value && c.value === "OnCheckAndClick");
function L(k, p, f) {
if (k.raw[d.value]) {
f == null || f.preventDefault(), f == null || f.stopPropagation();
return;
}
S.value = k.raw[s.value], h.value = k.raw[s.value], g.value = p, N.value && (b(k), M()), e.emit("clickItem", { data: E.value, index: p, dataItem: k.raw }), e.emit("activeChange", E.value);
}
return {
getKey: $,
selectedItems: E,
listViewItemClass: x,
listViewItemStyle: v,
updateSelectedItems: M,
onCheckItem: R,
onClickItem: L
};
}
const z = /* @__PURE__ */ new Map([
["appearance", Se]
]), it = "root-viewmodel";
function ot(i, e) {
const {
formSchemaUtils: t,
designViewModelUtils: n
} = e;
function o(c) {
return {
id: `${c.componentId}-component-viewmodel`,
code: `${c.componentId}-component-viewmodel`,
name: c.componentName,
bindTo: c.bindTo,
parent: it,
fields: [],
commands: [],
states: [],
enableValidation: !0
};
}
function l(c) {
const u = i.getSchemaByType("component-ref");
return Object.assign(u, {
id: `${c.componentId}-component-ref`,
component: `${c.componentId}-component`
}), u;
}
function s(c, u, g) {
var y, b, S, F;
const h = (b = (y = u == null ? void 0 : u.parentComponentInstance) == null ? void 0 : y.schema) == null ? void 0 : b.type, w = (F = (S = t.getFormSchema()) == null ? void 0 : S.module) == null ? void 0 : F.templateId;
if (["double-list-template", "tree-list-template", "list-template"].includes(w))
return c;
const V = [G["content-container"].type, G["response-layout-item"].type, G["splitter-pane"].type, G.drawer.type];
if (h && V.includes(h)) {
const E = i.getSchemaByType(
"section",
{
parentComponentInstance: u.parentComponentInstance,
mainTitle: u.componentName
},
e
);
if (E && E.contents && E.contents.length) {
const U = E.contents[0];
return U.contents = [c], E;
}
}
return c;
}
function d(c) {
var w, V, y;
const u = i.getSchemaByType("list-view");
let g = !1;
const h = (y = (V = (w = c.parentComponentInstance) == null ? void 0 : w.schema) == null ? void 0 : V.appearance) == null ? void 0 : y.class;
return h && h.includes("f-page-main") && (g = !0), Object.assign(u, {
id: c.componentId + "-listView",
appearance: {
class: g ? "" : "f-grid-is-sub"
},
type: "list-view",
dataSource: c.dataSource || "",
pagination: {
enable: !1
}
}), [u];
}
function r(c) {
var V, y, b;
const u = i.getSchemaByType("component"), g = d(c);
let h = !1;
const w = (b = (y = (V = c.parentComponentInstance) == null ? void 0 : V.schema) == null ? void 0 : y.appearance) == null ? void 0 : b.class;
return w && w.includes("f-page-main") && (h = !0), Object.assign(u, {
id: `${c.componentId}-component`,
viewModel: `${c.componentId}-component-viewmodel`,
componentType: c.componentType,
contents: g,
appearance: {
class: h ? "f-struct-wrapper f-utils-fill-flex-column" : ""
}
}), u;
}
function m(c) {
const u = l(c), g = r(c), h = o(c), w = t.getFormSchema();
return w.module.viewmodels.push(h), w.module.components.push(g), n.assembleDesignViewModel(), s(u, c);
}
return { createComponent: m };
}
function Y(i, e, t, n) {
var l, s, d, r, m, c;
const o = t.parentComponentInstance;
if (o && n) {
const u = Math.random().toString(36).slice(2, 6), g = {
componentId: `list-view-${u}`,
componentName: ((l = t.bindingSourceContext) == null ? void 0 : l.entityTitle) || ((d = (s = t.bindingSourceContext) == null ? void 0 : s.bindingEntity) == null ? void 0 : d.name) || `列表-${u}`,
componentType: "list-view",
parentContainerId: o.schema.id,
parentComponentInstance: o,
// editable: true,
bindTo: ((r = t.bindingSourceContext) == null ? void 0 : r.bindTo) || "",
dataSource: (c = (m = t.bindingSourceContext) == null ? void 0 : m.bindingEntity) == null ? void 0 : c.label
// selectedFields: context.bindingSourceContext?.bindingEntityFields
}, { createComponent: h } = ot(i, n);
return h(g);
} else
return e;
}
const lt = "https://json-schema.org/draft/2020-12/schema", at = "https://farris-design.gitee.io/list-view.schema.json", rt = "list-view", ct = "A Farris Component", dt = "object", ut = {
id: {
description: "The unique identifier for list-view",
type: "string"
},
type: {
description: "The type string of list-view",
type: "string",
default: "list-view"
},
dataSource: {
description: "",
type: "string",
default: ""
},
appearance: {
description: "",
type: "object",
properties: {
class: {
type: "string"
},
style: {
type: "string"
}
},
default: {}
},
binding: {
description: "",
type: "object",
default: {}
},
disable: {
type: "string",
default: !1
},
editable: {
description: "",
type: "boolean",
default: !0
},
placeholder: {
description: "",
type: "string",
default: ""
},
readonly: {
description: "",
type: "boolean",
default: !1
},
require: {
description: "",
type: "boolean",
default: !1
},
tabindex: {
description: "",
type: "number",
default: -1
},
visible: {
description: "",
type: "boolean",
default: !0
},
itemClass: {
description: "",
type: "string",
default: ""
},
itemStyle: {
description: "",
type: "string",
default: ""
},
contentTemplate: {
description: "",
type: "string",
default: ""
},
footerTemplate: {
description: "",
type: "string",
default: ""
},
emptyTemplate: {
description: "",
type: "string",
default: ""
},
pagination: {
type: "object",
properties: {
enable: {
description: "",
type: "boolean",
default: !1
},
disablePagination: {
description: "",
type: "string",
default: ""
},
contentTemplate: {
description: "",
type: "string",
default: ""
},
index: {
description: "",
type: "number",
default: 1
},
mode: {
description: "",
type: "enum",
default: "server",
enum: [
"server",
"client"
]
},
showGoto: {
description: "",
type: "boolean",
default: !1
},
showIndex: {
description: "",
type: "boolean",
default: !0
},
showLimits: {
description: "",
type: "boolean",
default: !1
},
showPageInfo: {
description: "",
type: "boolean",
default: !0
},
size: {
description: "",
type: "number",
default: 20
},
sizeLimits: {
description: "",
type: "array",
default: [
10,
20,
30,
50,
100
]
},
onPageChange: {
description: "",
type: "string",
default: ""
},
onPageSizeChange: {
description: "",
type: "string",
default: ""
}
}
}
}, pt = [
"id",
"type"
], mt = {
onClickItem: "行点击事件"
}, de = {
$schema: lt,
$id: at,
title: rt,
description: ct,
type: dt,
properties: ut,
required: pt,
events: mt
}, Q = ye(Ie, "headerTemplate"), jt = oe(Q, de, z, Y), ue = le(
Q,
de,
z,
Y
), K = {
"tab-page": { type: "tab-page" },
section: { type: "section" },
"list-view": { name: "列表" }
};
function ft(i) {
const { formSchemaUtils: e, formStateMachineUtils: t } = i;
function n(r, m = "") {
return {
path: m + r.code,
field: r.id,
fullPath: r.code
};
}
function o(r, m = "") {
const c = e.getViewModelById(r);
return c ? c.states.map((u) => n(u, m)) : [];
}
function l(r) {
const m = e.getRootViewModelId(), c = o(r);
if (r === m)
return c;
const u = o(m, "root-component.");
return [...c, ...u];
}
function s(r) {
return r.binding && r.binding.path || r.id || "";
}
function d() {
return t && t.getRenderStates() || [];
}
return { getVariables: l, getControlName: s, getStateMachines: d };
}
class gt {
constructor(e) {
B(this, "sessionVariables", [
{
key: "CurrentSysOrgName",
name: "当前组织Name",
description: "当前组织Name"
},
// {
// key: "CurrentSysOrgCode",
// name: "当前组织Code",
// description: "当前组织Code"
// },
{
key: "CurrentSysOrgId",
name: "当前组织Id",
description: "当前组织Id"
},
{
key: "CurrentUserName",
name: "当前用户Name",
description: "当前用户Name"
},
{
key: "CurrentUserCode",
name: "当前用户Code",
description: "当前用户Code"
},
{
key: "CurrentUserId",
name: "当前用户Id",
description: "当前用户Id"
},
{
key: "CurrentLanguage",
name: "当前语言编号",
description: "当前登录的语言编号,例如简体中文返回'zh-CHS',英文返回'en',繁体中文'zh-CHT'"
}
]);
B(this, "expressionNames", {
compute: "计算表达式",
dependency: "依赖表达式",
validate: "验证表达式",
dataPicking: "帮助前表达式",
visible: "可见表达式",
readonly: "只读表达式",
required: "必填表达式"
});
B(this, "getExpressionConverter", (e, t) => ({
convertFrom: (n, o, l, s) => {
const d = l.getExpressionRuleValue(e, t || o);
return d && d.value || "";
},
convertTo: (n, o, l, s, d) => {
var r;
if (o === "dataPicking" && (l != null && l.target)) {
const m = `${l.target}_dataPicking`;
((r = l.rules) == null ? void 0 : r.some(
(u) => u.id === m && u.value
)) ? n.dictPickingExpressionId = m : delete n.dictPickingExpressionId;
}
s.updateExpression(l);
}
}));
this.formSchemaService = e;
}
getExpressionRule(e, t) {
const n = this.getExpressionData();
if (!n)
return "";
const o = n.find((s) => s.target === e);
if (!o)
return "";
const l = o.rules.find((s) => s.type === t);
return l || "";
}
// 获取上下文表单变量
getContextFormVariables() {
const { module: e } = this.formSchemaService.getFormSchema();
if (!e.viewmodels || e.viewmodels.length === 0)
return [];
const t = this.formSchemaService.getRootViewModelId(), n = this.formSchemaService.getViewModelById(t);
if (!n || !n.states || n.states.length === 0)
return [];
const o = [];
return n.states.filter((l) => l.category === "remote").forEach((l) => {
o.push({
key: l.code,
name: l.name,
description: l.name,
category: l.category
});
}), o;
}
createTreeNode(e, t, n = "label") {
return {
id: e.id,
name: e.name,
bindingPath: e[n],
parents: t,
type: "field"
};
}
buildEntityFieldsTreeData(e = null, t) {
const n = [];
return e == null || e.forEach((o) => {
var d;
const l = this.createTreeNode(o, t);
let s = [];
(d = o.type) != null && d.fields && (s = this.buildEntityFieldsTreeData(o.type.fields, [...t, o.label])), n.push({
data: l,
children: s,
expanded: !0
});
}), n;
}
buildChildEntityTreeData(e = null, t) {
const n = [];
return e == null || e.forEach((o) => {
var r, m;
const l = this.createTreeNode(o, t);
l.type = "entity";
const s = this.buildEntityFieldsTreeData((r = o.type) == null ? void 0 : r.fields, [...t, o.label]), d = this.buildChildEntityTreeData((m = o.type) == null ? void 0 : m.entities, [...t, o.label]);
d != null && d.length && (s == null || s.push(...d)), n.push({
data: l,
children: s || [],
// 空值回退
expanded: !0
});
}), n;
}
getEntitiesTreeData() {
const e = this.formSchemaService.getSchemaEntities();
if (!(e != null && e.length))
return [];
const t = e[0];
if (!(t != null && t.type))
return [];
const n = this.buildEntityFieldsTreeData(t.type.fields, [t.code]), o = this.buildChildEntityTreeData(t.type.entities, [t.code]);
return o != null && o.length && (n == null || n.push(...o)), {
entityCode: t.code,
fields: [{
data: this.createTreeNode(t, [], "code"),
children: n || []
}]
};
}
getEntitiesAndVariables() {
return {
entities: this.getEntitiesTreeData(),
variables: {
session: {
name: "系统变量",
items: this.sessionVariables,
visible: !1
},
forms: {
name: "表单变量",
items: this.getContextFormVariables(),
visible: !0
}
}
};
}
onBeforeOpenExpression(e, t, n) {
const o = n === "Field" ? e.binding.field : e.id, l = this.getExpressionRule(o, t), s = this.getEntitiesAndVariables(), d = {
message: ["validate", "required", "dataPicking"].includes(t) && l ? l.message : "",
...s
};
return l.messageType != null && (d.messageType = l.messageType), d;
}
buildRule(e, t, n, o) {
const { expression: l, message: s, messageType: d } = t, r = {
id: `${e}_${n}`,
type: n,
value: l
};
return (n === "validate" || n === "dataPicking" || n === "required") && (r.message = s), n === "dataPicking" && (r.messageType = d), n === "validate" && o && (r.elementId = o), r;
}
getExpressionData() {
const { expressions: e } = this.formSchemaService.getFormSchema().module;
return e || [];
}
updateExpression(e, t, n, o) {
const l = t === "Field" ? e.binding.field : e.id, s = this.buildRule(l, n, o, e.type === "form-group" ? e.id : "");
let r = this.getExpressionData().find((c) => c.targetType === t && c.target === l);
const m = (c) => c.value.trim() === "";
if (r) {
const c = r.rules.find((u) => u.id === s.id);
if (c)
m(s) ? r.rules = r.rules.filter((u) => u.id !== s.id) : (Object.assign(c, s), o === "validate" && e.type === "form-group" && (c.elementId = e.id));
else {
if (m(s))
return null;
r.rules = r.rules || [], r.rules.push(s);
}
} else {
if (m(s))
return null;
r = {
target: `${l}`,
rules: [s],
targetType: t
};
}
return r;
}
getExpressionEditorOptions(e, t, n, o) {
return n.reduce((l, s) => {
var r, m;
const d = t === "Field" ? (r = e == null ? void 0 : e.binding) == null ? void 0 : r.field : e.id;
return l[s] = {
hide: t === "Field" ? !!((m = e == null ? void 0 : e.binding) != null && m.field) : !1,
description: "",
title: this.expressionNames[s],
type: "string",
$converter: this.getExpressionConverter(d),
refreshPanelAfterChanged: !0,
editor: {
type: "expression-editor",
singleExpand: !1,
dialogTitle: `${this.expressionNames[s]}编辑器`,
showMessage: s === "validate" || s === "dataPicking" || s === "required",
showMessageType: s === "dataPicking",
beforeOpen: () => this.onBeforeOpenExpression(e, s, t),
onSubmitModal: (c) => {
const u = this.updateExpression(e, t, c, s);
if (o) {
const g = this.buildRule(d, c, s);
o(g);
}
return u;
}
}
}, l;
}, {});
}
getExpressionInfo(e, t, n) {
const o = t === "Field" ? e.binding.field : e.id, l = this.getExpressionRule(o, n), s = {
value: l && l.value,
targetId: o,
targetType: t,
expressionType: n
};
return l && l.message && (s.message = l.message), s;
}
getExpressionConfig(e, t, n = ["compute", "dependency", "validate"], o) {
return {
description: "表达式",
title: "表达式",
hide: !e.binding,
properties: {
...this.getExpressionEditorOptions(e, t, n, o)
}
};
}
getExpressionOptions(e, t, n) {
const o = this.getExpressionInfo(e, t, n);
return {
dialogTitle: `${this.expressionNames[n] || "表达式"}编辑器`,
singleExpand: !1,
showMessage: n === "required",
beforeOpen: () => this.onBeforeOpenExpression(e, n, t),
expressionInfo: o
};
}
}
class vt {
constructor(e, t) {
B(this, "componentId");
B(this, "viewModelId");
B(this, "eventsEditorUtils");
B(this, "formSchemaUtils");
B(this, "formMetadataConverter");
B(this, "designViewModelUtils");
B(this, "designViewModelField");
B(this, "controlCreatorUtils");
B(this, "designerHostService");
B(this, "designerContext");
B(this, "modalService", null);
/** 表单规则 */
B(this, "formRule", null);
B(this, "schemaService", null);
B(this, "metadataService", null);
B(this, "propertyConfig", {
type: "object",
categories: {}
});
B(this, "expressionProperty");
var n;
this.componentId = e, this.designerHostService = t, this.eventsEditorUtils = t.eventsEditorUtils, this.formSchemaUtils = t.formSchemaUtils, this.formMetadataConverter = t.formMetadataConverter, this.viewModelId = ((n = this.formSchemaUtils) == null ? void 0 : n.getViewModelIdByComponentId(e)) || "", this.designViewModelUtils = t.designViewModelUtils, this.controlCreatorUtils = t.controlCreatorUtils, this.metadataService = t.metadataService, this.schemaService = t.schemaService, this.designerContext = t.designerContext, this.modalService = t.modalService, this.expressionProperty = new gt(this.formSchemaUtils);
}
getFormDesignerInstance() {
var e, t;
return (t = (e = this.designerContext) == null ? void 0 : e.instances) == null ? void 0 : t.formDesigner.value;
}
getTableInfo() {
var e;
return (e = this.schemaService) == null ? void 0 : e.getTableInfoByViewModelId(this.viewModelId);
}
setDesignViewModelField(e) {
var n;
const t = e.binding && e.binding.type === "Form" && e.binding.field;
if (t) {
if (!this.designViewModelField) {
const o = this.designViewModelUtils.getDgViewModel(this.viewModelId);
this.designViewModelField = o.fields.find((l) => l.id === t);
}
e.updateOn = (n = this.designViewModelField) == null ? void 0 : n.updateOn;
}
}
getBasicPropConfig(e) {
return {
description: "Basic Information",
title: "基本信息",
properties: {
id: {
description: "组件标识",
title: "标识",
type: "string",
readonly: !0
},
type: {
description: "组件类型",
title: "控件类型",
type: "select",
editor: {
type: "combo-list",
textField: "name",
valueField: "value",
idField: "value",
editable: !1,
data: [{ value: e.type, name: G[e.type] && G[e.type].name }]
}
}
}
};
}
getAppearanceConfig(e = null, t = {}, n) {
const o = {
title: "外观",
description: "Appearance"
}, l = {
class: {
title: "class样式",
type: "string",
description: "组件的CSS样式",
$converter: "/converter/appearance.converter",
parentPropertyID: "appearance"
},
style: {
title: "style样式",
type: "string",
description: "组件的样式",
$converter: "/converter/appearance.converter",
parentPropertyID: "appearance"
}
};
for (const s in t)
l[s] = Object.assign(l[s] || {}, t[s]);
return {
...o,
properties: { ...l },
setPropertyRelates(s, d) {
if (s) {
switch (s && s.propertyID) {
case "class":
case "style": {
Pe.value++;
break;
}
}
n && n(s, e, d);
}
}
};
}
/**
*
* @param propertyData
* @param propertyTypes
* @param propertyName
* @param constInfos
* @param variableInfos
* @param expressionType 指定表达式类型,存在属性和表达式类型不一致的情况
* @returns
*/
getPropertyEditorParams(e, t = [], n = "visible", o = {}, l = {}, s = "") {
const { getVariables: d, getControlName: r, getStateMachines: m } = ft(this.designerHostService), c = this.getRealTargetType(e), u = t && t.length > 0 ? t : ["Const", "Variable", "StateMachine", "Expression"], g = {
type: "property-editor",
propertyTypes: u
};
return u.map((h) => {
switch (h) {
case "Const":
Object.assign(g, {
constType: "enum",
constEnums: [{ id: !0, name: "是" }, { id: !1, name: "否" }]
}, o);
break;
case "Expression":
g.expressionConfig = this.getExpressionOptions(e, c, s || n);
break;
case "StateMachine":
g.stateMachines = m();
break;
case "Variable":
Object.assign(g, {
controlName: r(e),
newVariablePrefix: "is",
newVariableType: "Boolean",
variables: d(this.viewModelId),
parentComponentId: this.componentId === "root-component" ? "" : "root-component",
onBeforeOpenVariables: (w) => {
w.value = d(this.viewModelId);
}
}, l), this.designerContext.designerMode === "PC_RTC" && (g.newVariablePrefix = "ext_" + g.newVariablePrefix);
break;
}
}), g;
}
getVisibleProperty(e, t = "") {
var l;
let n = ["Const", "Variable", "StateMachine", "Expression"];
return t === "gridFieldEditor" ? n = ["Const", "Expression"] : t === "form-group" && !((l = e.binding) != null && l.field) && (n = ["Const", "Variable", "StateMachine"]), {
visible: {
title: "是否可见",
type: "boolean",
description: "运行时组件是否可见",
editor: this.getPropertyEditorParams(e, n, "visible")
}
};
}
/**
* 获取行为
* @param propertyData
* @param viewModelId
* @returns
*/
getBehaviorConfig(e, t = "", n = {}, o) {
const l = {
title: "行为",
description: ""
}, s = this.getVisibleProperty(e, t);
for (const r in n)
s[r] = Object.assign(s[r] || {}, n[r]);
const d = this;
return {
...l,
properties: { ...s },
setPropertyRelates(r, m) {
if (r) {
switch (r.propertyID) {
case "disabled":
case "readonly":
case "visible":
d.afterMutilEditorChanged(e, r);
break;
}
o && o(r, m);
}
}
};
}
/**
* 当多值编辑器变更时
* @param propertyData
* @param changeObject
*/
afterMutilEditorChanged(e, t) {
this.addNewVariableToViewModel(t, this.viewModelId), this.updateExpressionValue(t, e), this.clearExpression(t, e);
}
/**
*
* @param propertyId
* @param componentInstance
* @returns
*/
updateElementByParentContainer(e, t) {
const n = t && t.parent && t.parent.schema;
if (!n)
return;
const o = n.contents.findIndex((s) => s.id === e), l = ze(n.contents[o]);
n.contents.splice(o, 1), n.contents.splice(o, 0, l), Fe();
}
/**
* 属性编辑器,在编辑过程中会新增变量,此处需要将新增的变量追加到ViewModel中
* @param changeObject
* @param viewModelId
* @returns
*/
addNewVariableToViewModel(e, t) {
const n = e.propertyValue;
if (!(n && typeof n == "object") || !(n.type === "Variable" && n.isNewVariable))
return;
const s = {
id: n.field,
category: "locale",
code: n.fullPath,
name: n.fullPath,
type: n.newVariableType || "String",
isRtcVariable: this.designerContext.designerMode === "PC_RTC" ? !0 : void 0
};
delete n.newVariableType, delete n.isNewVariable, this.formSchemaUtils.getVariableByCode(s.code) || this.formSchemaUtils.getViewModelById("root-viewmodel").states.push(s);
}
getExpressions() {
let e = [];
return this.formRule ? (this.formRule.expressions = this.formRule.expressions || [], e = this.formRule.expressions || []) : e = this.formSchemaUtils.getExpressions(), e;
}
/**
* 更新表达式到expressions节点
* @param changeObject
*/
updateExpressionValue(e, t) {
const n = e.propertyValue;
if (!((n && n.type) === "Expression" && n.expressionInfo))
return;
const { expressionId: s, expressionInfo: d } = n, { targetId: r, targetType: m, expressionType: c, value: u, message: g } = d, h = this.getExpressions();
let w = h.find((y) => y.target === r);
w || (w = { target: r, rules: [], targetType: m }, h.push(w));
const V = w.rules.find((y) => y.type === c);
if (V)
V.value = u, V.message = g, (c === "minDate" || c === "maxDate" || c === "defaultTime") && (V.elementId = t.id);
else {
const y = { id: s, type: c, value: u, message: g, elementId: t.id };
w.rules.push(y);
}
delete n.expressionInfo;
}
/**
* 属性类型切换为非表达式后,清除原表达式
* @param changeObject
* @param propertyData
* @returns
*/
clearExpression(e, t) {
const n = e.propertyValue;
if (n && n.type === "Expression")
return;
const l = e.propertyID, s = this.getExpressions(), d = t.binding ? t.binding.field : t.id, r = s.find((m) => m.target === d);
!r || !r.rules || (r.rules = r.rules.filter((m) => m.type !== l));
}
getExpressionOptions(e, t, n) {
return this.expressionProperty.getExpressionOptions(e, t, n);
}
getRealTargetType(e) {
return ["response-toolbar-item", "tab-toolbar-item", "section-toolbar-item", "drawer-toolbar-item"].indexOf(e.type) > -1 ? "Button" : e.binding && e.binding.field ? "Field" : "Container";
}
createBaseEventProperty(e) {
const t = {};
return t[this.viewModelId] = {
type: "events-editor",
editor: {
initialData: e,
viewSourceHandle: (n) => {
var o;
((o = n.controller) == null ? void 0 : o.label.indexOf(this.formSchemaUtils.getModule().code)) > -1 && this.eventsEditorUtils.jumpToMethod(n);
}
}
}, t;
}
}
class ht extends vt {
constructor(e, t) {
super(e, t);
}
getPropertyConfig(e) {
return this.getBasicPropConfig(e), this.getAppearanceProperties(e), this.getEventPropConfig(e), this.propertyConfig;
}
getBasicPropConfig(e) {
var s, d, r;
const t = (r = (d = (s = this.formSchemaUtils.getFormSchema()) == null ? void 0 : s.module) == null ? void 0 : d.entity[0]) == null ? void 0 : r.entities[0], n = this.assembleSchemaEntityToTree(t, 0), o = this, l = super.getBasicPropConfig(e);
this.propertyConfig.categories.basic = {
description: "Basic Information",
title: "基本信息",
properties: {
...l.properties,
dataSource: {
description: "绑定数据源",
title: "绑定数据源",
editor: {
type: "combo-tree",
textField: "name",
valueField: "label",
data: n,
editable: !1
},
readonly: !0
}
},
setPropertyRelates(m, c) {
switch (m && m.propertyID) {
case "dataSource": {
const u = o.formSchemaUtils.getViewModelById(o.viewModelId);
if (u) {
const g = n.find((h) => h.label === m.propertyValue);
u.bindTo = g.bindTo;
}
o.designViewModelUtils.assembleDesignViewModel();
break;
}
}
}
};
}
/**
* 将schema实体表组装成树
*/
assembleSchemaEntityToTree(e, t, n, o = "", l = []) {
const s = o ? `${o}/${e.label}` : "/";
return l.push({
id: e.id,
name: e.name,
label: e.label,
layer: t,
parent: n && n.id,
bindTo: s.replace("//", "/")
}), e.type.entities && e.type.entities.length && e.type.entities.map((d) => this.assembleSchemaEntityToTree(d, t + 1, e, s, l)), l;
}
getAppearanceProperties(e) {
this.propertyConfig.categories.appearance = {
title: "外观",
properties: {
class: {
title: "列表class样式",
type: "string",
description: "组件的CSS样式"
},
itemClass: {
title: "行样式class",
type: "string",
description: "行样式class",
editor: {
type: "code-editor",
language: "javascript",
leftTemplate: () => a(q, null, [a("h5", null, [j("示例代码")]), a("pre", null, [`
(dataItem) => {
if(dataItem.code === '0001') {
return 'bg-danger text-center';
}
return '';
}
注:dataItem 行数据
函数返回值是一个字符串,
是由空格分隔的class组成 `])])
}
},
itemStyle: {
title: "行样式style",
type: "string",
description: "行样式style",
editor: {
type: "code-editor",
language: "javascript",
leftTemplate: () => a(q, null, [a("h5", null, [j("示例代码")]), a("pre", null, [`
(dataItem) => {
if(dataItem.code === '0001') {
return 'textAlign:center;color:green';
}
return '';
}
注:dataItem 行数据
函数返回值是一个字符串,
由分号分隔的css样式组成 `])])
}
},
contentTemplate: {
description: "内容模板",
title: "内容模板",
type: "string",
refreshPanelAfterChanged: !0,
editor: {
type: "code-editor",
language: "html"
}
},
footerTemplate: {
description: "底部模板",
title: "底部模板",
type: "string",
refreshPanelAfterChanged: !0,
editor: {
type: "code-editor",
language: "html"
}
},
emptyTemplate: {
description: "空数据模板",
title: "空数据模板",
type: "string",
refreshPanelAfterChanged: !0,
editor: {
type: "code-editor",
language: "html"
}
}
},
setPropertyRelates(t, n) {
switch (t && t.propertyID) {
case "useBlankWhenDataIsEmpty":
e.emptyDataHeight = e.useBlankWhenDataIsEmpty ? 36 : 240;
break;
case "columns":
e.columns = t.propertyValue || [];
break;
}
}
};
}
getEventPropConfig(e) {
var s;
const t = [{
label: "onClickItem",
name: "行点击事件"
}];
(s = e.pagination) == null || s.enable;
const n = this, o = n.eventsEditorUtils.formProperties(e, n.viewModelId, t), l = n.createBaseEventProperty(o);
this.propertyConfig.categories.eventsEditor = {
title: "事件",
hideTitle: !0,
properties: l,
// 这个属性,标记当属性变更得时候触发重新更新属性
refreshPanelAfterChanged: !0,
tabId: "commands",
tabName: "交互",
setPropertyRelates(d, r) {
const m = d.propertyValue;
delete e[n.viewModelId], m && (m.setPropertyRelates = this.setPropertyRelates, n.eventsEditorUtils.saveRelatedParameters(e, n.viewModelId, m.events, m)), e.remoteSort = !!e.columnSorted, e.command && (e.command.onClickEditCommand = e.onClickEditCommand, e.command.onClickDeleteCommand = e.onClickDeleteCommand);
}
};
}
isSubGrid() {
const e = this.formSchemaUtils.getViewModelById(this.viewModelId);
return e && e.bindTo ? e.bindTo.trim() !== "/" : !1;
}
}
function wt(i, e) {
const t = i.schema, n = I(!0), o = I(!0);
function l(u) {
return !1;
}
function s() {
return !1;
}
function d() {
return !1;
}
function r() {
return !0;
}
function m(u) {
return new ht(u, e).getPropertyConfig(t);
}
function c() {
var u, g, h, w;
if (i && e) {
const V = (u = i == null ? void 0 : i.componentInstance) == null ? void 0 : u.val