@farris/ui-vue
Version:
Farris Vue, a Farris Design based Vue3 component library.
1,471 lines (1,470 loc) • 209 kB
JavaScript
var Hn = Object.defineProperty;
var An = (n, t, e) => t in n ? Hn(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
var X = (n, t, e) => An(n, typeof t != "symbol" ? t + "" : t, e);
import { ref as S, computed as L, createVNode as y, defineComponent as Ie, onMounted as Ye, watch as be, createTextVNode as Ut, Fragment as st, reactive as Le, createApp as an, onUnmounted as Tt, Transition as sn, mergeProps as qt, nextTick as Mt, inject as Ht, onBeforeMount as zn, Teleport as Un, shallowRef as qn, render as Lt, h as _n, cloneVNode as Wn } from "vue";
import { cloneDeep as gt, isPlainObject as en, isUndefined as Re } from "lodash-es";
import ve from "bignumber.js";
import { useNumberLocales as Gn } from "../number-spinner/index.esm.js";
import { getSchemaByTypeForDesigner as Xn, createPropsResolver as ln, resolveAppearance as Yn } from "../dynamic-resolver/index.esm.js";
import { DgControl as tn } from "../designer-canvas/index.esm.js";
import { getCustomClass as At, withInstall as un, FormSchemaEntityField$Type as ht, FormSchemaEntityFieldTypeName as nn, FormSchemaEntityFieldType$Type as Zn } from "../common/index.esm.js";
import { useI18n as _t } from "vue-i18n";
import { LocaleService as Et } from "../locale/index.esm.js";
import { useResizeObserver as Jn } from "@vueuse/core";
import { getHierarchyRow as Qn, useIdentify as Kn, useGroupData as eo, useFilter as to, useHierarchy as no, useLoading as oo, useDataView as io, useSelection as ro, useSelectHierarchyItem as ao, usePagination as so, useDataViewContainerStyle as lo, useCommandColumn as uo, useSettingColumn as co, useColumn as fo, useSort as po, useGroupColumn as mo, useRow as vo, useEdit as go, useVisualDataBound as ho, useVisualDataCell as yo, useVisualDataRow as bo, useVisualData as wo, useCellPosition as Co, useSidebar as So, useVirtualScroll as xo, useFitColumn as To, useFilterHistory as Mo, useColumnFilter as Eo, useDragColumn as Fo, getColumnHeader as Bo, getSidebar as ko, getDisableMask as Io, getHorizontalScrollbar as No, getVerticalScrollbar as Oo, getEmpty as Po, getPagination as Vo, getSummary as jo } from "../data-view/index.esm.js";
import "../property-panel/index.esm.js";
import "../accordion/index.esm.js";
import "../avatar/index.esm.js";
import "../../designer/button-edit/index.esm.js";
import "../button-group/index.esm.js";
import "../calendar/index.esm.js";
import "../capsule/index.esm.js";
import "../../designer/checkbox/index.esm.js";
import "../../designer/checkbox-group/index.esm.js";
import "../combo-list/index.esm.js";
import "../combo-tree/index.esm.js";
import "../component/index.esm.js";
import "../color-picker/index.esm.js";
import "../content-container/index.esm.js";
import "../date-picker/index.esm.js";
import "../../designer/data-grid/index.esm.js";
import "../dropdown/index.esm.js";
import "../dynamic-form/index.esm.js";
import "../events-editor/index.esm.js";
import "../filter-bar/index.esm.js";
import "../field-selector/index.esm.js";
import "../binding-selector/index.esm.js";
import "../image-cropper/index.esm.js";
import "../../designer/input-group/index.esm.js";
import "../layout/index.esm.js";
import "../list-nav/index.esm.js";
import "../../designer/list-view/index.esm.js";
import "../lookup/index.esm.js";
import "../mapping-editor/index.esm.js";
import "../nav/index.esm.js";
import "../number-range/index.esm.js";
import "../order/index.esm.js";
import "../page-header/index.esm.js";
import "../page-footer/index.esm.js";
import "../pagination/index.esm.js";
import "../progress/index.esm.js";
import "../query-solution/index.esm.js";
import "../../designer/radio-group/index.esm.js";
import "../rate/index.esm.js";
import "../response-toolbar/index.esm.js";
import "../response-layout/index.esm.js";
import "../response-layout-editor/index.esm.js";
import "../search-box/index.esm.js";
import "../section/index.esm.js";
import "../smoke-detector/index.esm.js";
import "../splitter/index.esm.js";
import "../step/index.esm.js";
import "../switch/index.esm.js";
import "../tabs/index.esm.js";
import "../tags/index.esm.js";
import "../text/index.esm.js";
import "../time-picker/index.esm.js";
import "../transfer/index.esm.js";
import "../tree-view/index.esm.js";
import "../uploader/index.esm.js";
import "../verify-detail/index.esm.js";
import "../video/index.esm.js";
import "../textarea/index.esm.js";
import "../schema-selector/index.esm.js";
import "../../designer/tree-grid/index.esm.js";
import "../event-parameter/index.esm.js";
import "../filter-condition-editor/index.esm.js";
import "../fieldset/index.esm.js";
import "../sort-condition-editor/index.esm.js";
import "../menu-lookup/index.esm.js";
import "../../designer/drawer/index.esm.js";
import "../json-editor/index.esm.js";
import "../property-editor/index.esm.js";
import "../expression-editor/index.esm.js";
import "../code-editor/index.esm.js";
import "../html-template/index.esm.js";
import "../collection-property-editor/index.esm.js";
import "../modal/index.esm.js";
import "../external-container/index.esm.js";
import "../language-textbox/index.esm.js";
import "../notify/index.esm.js";
function Do(n, t, e) {
return t;
}
function cn(n, t) {
let e;
function o(u) {
const { properties: m, title: d, ignore: p } = u, v = p && Array.isArray(p), x = Object.keys(m).reduce((F, k) => ((!v || !p.find((j) => j === k)) && (F[k] = m[k].type === "object" && m[k].properties ? o(m[k]) : gt(m[k].default)), F), {});
if (d && (!v || !p.find((F) => F === "id"))) {
const F = d.toLowerCase().replace(/-/g, "_");
x.id = `${F}_${Math.random().toString().slice(2, 6)}`;
}
return x;
}
function i(u) {
const { properties: m, title: d, required: p } = u;
if (p && Array.isArray(p)) {
const v = p.reduce((x, F) => (x[F] = m[F].type === "object" && m[F].properties ? o(m[F]) : gt(m[F].default), x), {});
if (d && p.find((x) => x === "id")) {
const x = d.toLowerCase().replace(/-/g, "_");
v.id = `${x}_${Math.random().toString().slice(2, 6)}`;
}
return v;
}
return {
type: d
};
}
function a(u, m = {}, d) {
const p = n[u];
if (p) {
let v = i(p);
const x = t[u];
return v = x ? x({ getSchemaByType: a }, v, m, d) : v, e != null && e.appendIdentifyForNewControl && e.appendIdentifyForNewControl(v), v;
}
return null;
}
function r(u, m) {
const d = o(m);
return Object.keys(d).reduce((p, v) => (Object.prototype.hasOwnProperty.call(u, v) && (p[v] && en(p[v]) && en(u[v] || !u[v]) ? Object.assign(p[v], u[v] || {}) : p[v] = u[v]), p), d), d;
}
function c(u, m) {
return Object.keys(u).filter((p) => u[p] != null).reduce((p, v) => {
if (m.has(v)) {
const x = m.get(v);
if (typeof x == "string")
p[x] = u[v];
else {
const F = x(v, u[v], u);
Object.assign(p, F);
}
} else
p[v] = u[v];
return p;
}, {});
}
function l(u, m, d = /* @__PURE__ */ new Map()) {
const p = r(u, m);
return c(p, d);
}
function s(u) {
var d;
const m = u.type;
if (m) {
const p = n[m];
if (!p)
return u;
const v = r(u, p), x = ((d = u.editor) == null ? void 0 : d.type) || "";
if (x) {
const F = n[x], k = r(u.editor, F);
v.editor = k;
}
return v;
}
return u;
}
function f(u) {
e = u;
}
return { getSchemaByType: a, resolveSchemaWithDefaultValue: s, resolveSchemaToProps: l, mappingSchemaToProps: c, setDesignerContext: f };
}
const dn = {}, fn = {}, { getSchemaByType: _s, resolveSchemaWithDefaultValue: Ro, resolveSchemaToProps: $o, mappingSchemaToProps: Lo, setDesignerContext: Ws } = cn(dn, fn);
function Ho(n = {}) {
function t(s, f, u, m) {
if (typeof u == "number")
return m[s].length === u;
if (typeof u == "object") {
const d = Object.keys(u)[0], p = u[d];
if (d === "not")
return Number(m[s].length) !== Number(p);
if (d === "moreThan")
return Number(m[s].length) >= Number(p);
if (d === "lessThan")
return Number(m[s].length) <= Number(p);
}
return !1;
}
function e(s, f, u, m) {
return m[s] && m[s].propertyValue && String(m[s].propertyValue.value) === String(u);
}
const o = /* @__PURE__ */ new Map([
["length", t],
["getProperty", e]
]);
Object.keys(n).reduce((s, f) => (s.set(f, n[f]), s), o);
function i(s, f) {
const u = s;
return typeof f == "number" ? [{ target: u, operator: "length", param: null, value: Number(f) }] : typeof f == "boolean" ? [{ target: u, operator: "getProperty", param: s, value: !!f }] : typeof f == "object" ? Object.keys(f).map((m) => {
if (m === "length")
return { target: u, operator: "length", param: null, value: f[m] };
const d = m, p = f[m];
return { target: u, operator: "getProperty", param: d, value: p };
}) : [];
}
function a(s) {
return Object.keys(s).reduce((u, m) => {
const d = i(m, s[m]);
return u.push(...d), u;
}, []);
}
function r(s, f) {
if (o.has(s.operator)) {
const u = o.get(s.operator);
return u && u(s.target, s.param, s.value, f) || !1;
}
return !1;
}
function c(s, f) {
return a(s).reduce((d, p) => d && r(p, f), !0);
}
function l(s, f) {
const u = Object.keys(s), m = u.includes("allOf"), d = u.includes("anyOf"), p = m || d, F = (p ? s[p ? m ? "allOf" : "anyOf" : "allOf"] : [s]).map((j) => c(j, f));
return m ? !F.includes(!1) : F.includes(!0);
}
return { parseValueSchema: l };
}
const Ao = {
convertTo: (n, t, e, o) => {
n.appearance || (n.appearance = {}), n.appearance[t] = e;
},
convertFrom: (n, t, e) => n.appearance ? n.appearance[t] : n[t]
}, zo = {
convertFrom: (n, t, e) => n.buttons && n.buttons.length ? `共 ${n.buttons.length} 项` : "无"
}, Uo = {
convertTo: (n, t, e, o) => {
n.editor && (n.editor[t] = e);
},
convertFrom: (n, t, e) => n.editor && Object.prototype.hasOwnProperty.call(n.editor, t) ? n.editor[t] : n[t]
}, $ = {
button: { type: "button", name: "按钮" },
"response-toolbar": { type: "response-toolbar", name: "工具栏" },
"response-toolbar-item": { type: "response-toolbar-item", name: "按钮" },
"content-container": { type: "content-container", name: "容器" },
"input-group": { type: "input-group", name: "文本" },
textarea: { type: "textarea", name: "多行文本" },
lookup: { type: "lookup", name: "帮助" },
"number-spinner": { type: "number-spinner", name: "数值" },
"date-picker": { type: "date-picker", name: "日期" },
switch: { type: "switch", name: "开关" },
"radio-group": { type: "radio-group", name: "单选组" },
"check-box": { type: "check-box", name: "复选框" },
"check-group": { type: "check-group", name: "复选框组" },
"combo-list": { type: "combo-list", name: "下拉列表" },
"response-form": { type: "response-form", name: "卡片面板" },
"response-layout": { type: "response-layout", name: "布局容器", icon: "response-layout-3" },
"response-layout-item": { type: "response-layout-item", name: "布局", icon: "response-layout-1" },
"tree-grid": { type: "tree-grid", name: "树表格" },
"tree-grid-column": { type: "tree-grid-column", name: "树表格列" },
"data-grid": { type: "data-grid", name: "表格" },
"data-grid-column": { type: "data-grid-column", name: "表格列" },
module: { type: "Module", name: "模块" },
component: { type: "component", name: "组件" },
tabs: { type: "tabs", name: "标签页" },
"tab-page": { type: "tab-page", name: "标签页项", dependentParentControl: "Tab" },
"tab-toolbar-item": { type: "tab-toolbar-item", name: "标签页工具栏按钮" },
"html-template": { type: "html-template", name: "模板容器" },
"time-picker": { type: "time-picker", name: "时间选择" },
section: { type: "section", name: "分组面板" },
"section-toolbar": { type: "section-toolbar", name: "分组面板工具栏" },
"section-toolbar-item": { type: "section-toolbar-item", name: "分组面板按钮" },
splitter: { type: "splitter", name: "分栏面板" },
"splitter-pane": { type: "splitter-pane", name: "分栏面板项", dependentParentControl: "Splitter" },
"component-ref": { type: "component-ref", name: "组件引用节点" },
uploader: { type: "uploader", name: "附件上传" },
"page-header": { type: "page-header", name: "页头" },
"page-footer": { type: "page-footer", name: "页脚" },
"tab-toolbar": { type: "tab-toolbar", name: "标签页工具栏" },
fieldset: { type: "fieldset", name: "分组" },
"query-solution": { type: "query-solution", name: "筛选方案" },
drawer: { type: "drawer", name: "抽屉" },
"external-container": { type: "external-container", name: "外部容器", icon: "content-container" },
"list-nav": { type: "list-nav", name: "列表导航" },
"list-view": { type: "list-view", name: "列表" },
"filter-bar": { type: "filter-bar", name: "筛选条" },
"language-textbox": { type: "language-textbox", name: "多语输入框" }
}, qo = {
convertFrom: (n, t, e) => {
var i;
const o = n.editor && n.editor[t] ? n.editor[t] : n[t];
return ((i = $[o]) == null ? void 0 : i.name) || o;
}
}, _o = {
convertTo: (n, t, e, o) => {
n[t] = n[t];
},
convertFrom: (n, t, e) => n.editor ? e.getRealEditorType(n.editor.type) : ""
}, Wo = {
convertTo: (n, t, e, o) => {
(n.type === "data-grid-column" || n.type === "tree-grid-column") && (n.formatter ? n.formatter[t] = e : n.formatter = {
[t]: e
});
},
convertFrom: (n, t, e) => {
if (n.formatter) {
if (t === "trueText")
return n.formatter.trueText;
if (t === "falseText")
return n.formatter.falseText;
if (t === "prefix")
return n.formatter.prefix;
if (t === "suffix")
return n.formatter.suffix;
if (t === "precision")
return n.formatter.precision;
if (t === "decimal")
return n.formatter.decimal;
if (t === "thousand")
return n.formatter.thousand;
if (t === "tempDateFormat")
return n.formatter.dateFormat === "yyyy年MM月dd日" ? "yearMonthDay" : n.formatter.dateFormat === "yyyy-MM-dd HH:mm:ss" ? "yyyy-MM-ddTHH:mm:ss" : n.formatter.dateFormat === "yyyy/MM/dd HH:mm:ss" ? "yyyy/MM/ddTHH:mm:ss" : n.formatter.dateFormat === "yyyy年MM月dd日 HH时mm分ss秒" ? "yearMonthDayHourMinuteSecond" : n.formatter.tempDateFormat || n.formatter.dateFormat || "yyyy-MM-dd";
if (t === "customFormat")
return n.formatter.customFormat;
if (t === "type")
return n.formatter.type || "none";
}
return "none";
}
}, Go = {
convertTo: (n, t, e, o) => {
n.command ? n.command[t] = e : n.command = {
[t]: e
}, t === "enable" && e && (n.command.commands || (n.command.commands = [
{
text: "编辑",
type: "primary",
command: "edit"
},
{
text: "删除",
type: "danger",
command: "remove"
}
]));
},
convertFrom: (n, t, e) => n.command && t === "enable" ? n.command.enable : ""
}, Xo = {
convertTo: (n, t, e, o) => {
n.column ? n.column[t] = e : n.column = {
[t]: e
}, t === "fitColumns" && e && (n.column.fitMode || (n.column.fitMode = "average"));
},
convertFrom: (n, t, e) => {
if (n.column) {
if (t === "fitColumns")
return n.column.fitColumns;
if (t === "fitMode")
return n.column.fitMode;
}
return "";
}
}, Yo = {
convertTo: (n, t, e, o) => {
n.summary ? n.summary[t] = e : n.summary = {
[t]: e
}, t === "enable" && e && (n.summary ? n.summary.groupFields || (n.summary.groupFields = []) : n.summary = {
enable: e,
groupFields: []
});
},
convertFrom: (n, t, e) => n.summary && t === "enable" ? n.summary.enable : n.type === "data-grid-column" ? n.enableSummary === void 0 ? !1 : n.enableSummary : ""
}, Zo = {
convertTo: (n, t, e, o) => {
n.group ? n.group[t] = e : n.group = {
[t]: e
}, t === "enable" && e && (n.group ? n.group.groupFields || (n.group.groupFields = []) : n.group = {
enable: e,
groupFields: [],
showSummary: !1
});
},
convertFrom: (n, t, e) => {
if (n.group) {
if (t === "enable")
return n.group.enable;
if (t === "showSummary")
return n.group.showSummary;
}
}
}, Jo = {
convertFrom: (n, t) => n.binding ? n.binding.path : "",
convertTo: (n, t, e) => {
if (e && e.length > 0) {
const o = e[0];
n.binding || (n.binding = {}), n.binding.type = "Form", n.binding.path = o.bindingField, n.binding.field = o.id, n.binding.fullPath = o.path, n.path = o.bindingPath;
}
}
}, Qo = {
convertTo: (n, t, e, o) => {
n.pagination || (n.pagination = {}), n.pagination[t] = e;
},
convertFrom: (n, t, e) => n.pagination ? n.pagination[t] : n[t]
}, Ko = {
convertTo: (n, t, e, o) => {
n.rowNumber || (n.rowNumber = {}), n.rowNumber[t] = e;
},
convertFrom: (n, t, e) => n.rowNumber ? n.rowNumber[t] : n[t]
}, ei = {
convertTo: (n, t, e, o) => {
n.selection || (n.selection = {}), n.selection[t] = e;
},
convertFrom: (n, t, e) => n.selection ? n.selection[t] : n[t]
}, ti = {
convertFrom: (n, t, e) => n[t] && n[t].length ? `共 ${n[t].length} 项` : ""
}, ni = {
convertFrom: (n, t) => n[t] || "",
convertTo: (n, t, e) => {
n[t] = e;
}
}, oi = {
convertTo: (n, t, e, o) => {
n.size || (n.size = {}), n.size[t] = e;
},
convertFrom: (n, t, e) => n.size ? n.size[t] : n[t]
}, ii = {
convertFrom: (n, t, e) => {
var o, i;
return (o = n.formatter) != null && o.data && t === "formatterEnumData" && !n.formatterEnumData ? (i = n.formatter) == null ? void 0 : i.data : n.formatterEnumData;
}
}, ri = {
convertTo: (n, t, e, o) => {
n.sort || (n.sort = {}), n.sort[t] = e;
},
convertFrom: (n, t, e) => {
var o, i;
if (t === "mode")
return ((o = n.sort) == null ? void 0 : o.mode) || "client";
if (t === "multiSort")
return !!((i = n.sort) != null && i.multiSort);
}
}, ai = {
convertTo: (n, t, e, o) => {
n.filter || (n.filter = {}), n.filter[t] = e;
},
convertFrom: (n, t, e) => {
var o;
if (t === "mode")
return ((o = n.filter) == null ? void 0 : o.mode) || "client";
}
}, si = {
convertTo: (n, t, e, o) => {
n.rowOption ? n.rowOption[t] = e : n.rowOption = {
[t]: e
};
},
convertFrom: (n, t, e) => {
if (n.rowOption) {
if (t === "customRowStyle")
return n.rowOption.customRowStyle;
if (t === "customCellStyle")
return n.rowOption.customCellStyle;
}
return "";
}
};
function pn(n, t, e) {
const o = /* @__PURE__ */ new Map([
["/converter/appearance.converter", Ao],
["/converter/buttons.converter", zo],
["/converter/property-editor.converter", Uo],
["/converter/items-count.converter", ti],
["/converter/type.converter", qo],
["/converter/change-editor.converter", _o],
["/converter/change-formatter.converter", Wo],
["/converter/column-command.converter", Go],
["/converter/column-option.converter", Xo],
["/converter/summary.converter", Yo],
["/converter/group.converter", Zo],
["/converter/form-group-label.converter", ni],
["/converter/field-selector.converter", Jo],
["/converter/pagination.converter", Qo],
["/converter/row-number.converter", Ko],
["/converter/grid-selection.converter", ei],
["/converter/size.converter", oi],
["/converter/change-formatter-enum.converter", ii],
["/converter/grid-sort.converter", ri],
["/converter/grid-filter.converter", ai],
["/converter/row-option.converter", si]
]), i = /* @__PURE__ */ new Map([
["string", { type: "input-group", enableClear: !1 }],
["boolean", {
type: "combo-list",
textField: "name",
valueField: "value",
idField: "value",
enableClear: !1,
editable: !1,
data: [
{
value: !0,
name: "是"
},
{
value: !1,
name: "否"
}
]
}],
["enum", { type: "combo-list", maxHeight: 128, enableClear: !1, editable: !1 }],
["array", { type: "button-edit" }],
["number", { type: "number-spinner", placeholder: "" }],
["events-editor", { type: "events-editor", hide: !0 }]
]), a = Ho();
function r(p, v) {
return () => a.parseValueSchema(p, v);
}
function c(p, v, x) {
return p.includes("visible") && v.visible !== void 0 ? typeof v.visible == "boolean" ? () => !!v.visible : v.visible === void 0 ? !0 : r(v.visible, x) : () => !0;
}
function l(p, v, x) {
return p.includes("readonly") && v.readonly !== void 0 ? typeof v.readonly == "boolean" ? () => !!v.readonly : r(v.readonly, x) : () => !1;
}
function s(p, v) {
const x = p.$converter || v;
return typeof x == "string" && x && o.has(x) ? o.get(x) || null : x || null;
}
function f(p, v, x, F, k, j = "", b = "") {
return Object.keys(p).map((g) => {
const E = S(1), M = g, w = p[g], I = Object.keys(w), C = w.title, B = w.type, O = i.get(B) || { type: "input-group", enableClear: !1 }, V = w.editor ? Object.assign({}, O, w.editor) : Object.assign({}, O), H = c(I, w, v), W = l(I, w, v);
V.readonly = V.readonly === void 0 ? W() : V.readonly;
const ee = w.type === "cascade" ? f(w.properties, v, x, F, k, j, b) : [], D = !0;
let P = s(w, b);
const G = L({
get() {
if (E.value) {
if (["class", "style"].find((le) => le === M) && !P && (P = o.get("/converter/appearance.converter") || null), P && P.convertFrom)
return P.convertFrom(x, g, k, j);
const ie = x[g];
return Object.prototype.hasOwnProperty.call(w, "defaultValue") && (ie === void 0 || typeof ie == "string" && ie === "") ? w.type === "boolean" ? w.defaultValue : w.defaultValue || "" : ie;
}
return null;
},
set(ie) {
E.value += 1, P && P.convertTo ? (P.convertTo(F, g, ie, k, j), P.convertTo(x, g, ie, k, j)) : (F[g] = ie, x[g] = ie);
}
}), { refreshPanelAfterChanged: z, description: te, isExpand: ge, parentPropertyID: he } = w, Z = { propertyID: M, propertyName: C, propertyType: B, propertyValue: G, editor: V, visible: H, readonly: W, cascadeConfig: ee, hideCascadeTitle: D, refreshPanelAfterChanged: z, description: te, isExpand: ge, parentPropertyID: he };
return v[M] = Z, Z;
});
}
function u(p, v, x = {}) {
const F = {}, k = n[p];
return k && k.categories ? Object.keys(k.categories).map((b) => {
const h = k.categories[b], g = h == null ? void 0 : h.title, E = f(h.properties || {}, F, {}, x, v);
return { categoryId: b, categoryName: g, properties: E };
}) : [];
}
function m(p, v, x, F, k = "") {
const j = v.$ref.schema, b = v.$ref.converter, h = x[j], g = h.type, E = e(h), M = {}, w = n[g];
if (w && w.categories) {
const I = w.categories[p], C = I == null ? void 0 : I.title;
b && Object.keys(I.properties).forEach((V) => {
I.properties[V].$converter = b;
});
const B = (I == null ? void 0 : I.properties) || {}, O = f(B, M, E, h, F, k);
return { categoryId: p, categoryName: C, properties: O };
}
return { categoryId: p, categoryName: "", properties: [] };
}
function d(p, v, x, F, k) {
const j = p.type, b = e(p), h = {};
let g = k || n[j];
if (g && Object.keys(g).length === 0 && x && x.getPropConfig && (g = x.getPropConfig(F)), g && g.categories) {
const E = [];
return Object.keys(g.categories).map((M) => {
const w = g.categories[M];
if (w.$ref) {
E.push(m(M, w, p, v, F));
return;
}
const I = w == null ? void 0 : w.title, C = w == null ? void 0 : w.tabId, B = w == null ? void 0 : w.tabName, O = w == null ? void 0 : w.hide, V = w == null ? void 0 : w.hideTitle, H = f(w.properties || {}, h, b, p, v, F, w.$converter), { setPropertyRelates: W } = w, ee = w == null ? void 0 : w.parentPropertyID;
E.push({ categoryId: M, categoryName: I, tabId: C, tabName: B, hide: O, properties: H, hideTitle: V, setPropertyRelates: W, parentPropertyID: ee });
}), E;
}
return [];
}
return {
getPropertyConfigBySchema: d,
getPropertyConfigByType: u,
propertyConverterMap: o
};
}
const mn = {}, vn = {};
pn(mn, vn, Ro);
const gn = {}, hn = {}, { getSchemaByType: Gs, resolveSchemaWithDefaultValue: li, resolveSchemaToProps: Xs, mappingSchemaToProps: Ys, setDesignerContext: Zs } = cn(gn, hn), yn = {}, bn = {};
pn(yn, bn, li);
function lt(n, t, e = /* @__PURE__ */ new Map(), o = (r, c, l, s) => c, i = {}, a = (r) => r) {
return dn[t.title] = t, fn[t.title] = o, mn[t.title] = i, vn[t.title] = a, gn[t.title] = t, hn[t.title] = o, yn[t.title] = i, bn[t.title] = a, (r = {}, c = !0) => {
if (!c)
return Lo(r, e);
const l = $o(r, t, e), s = Object.keys(n).reduce((f, u) => (f[u] = n[u].default, f), {});
return Object.assign(s, l);
};
}
function Wt(n, t) {
return { customClass: t.class, customStyle: t.style };
}
const ui = /* @__PURE__ */ new Map([
["appearance", Wt]
]), ci = "https://json-schema.org/draft/2020-12/schema", di = "https://farris-design.gitee.io/number-range.schema.json", fi = "number-range", pi = "A Farris Component", mi = "object", vi = {
id: {
description: "The unique identifier for a number-range",
type: "string"
},
type: {
description: "The type string of number-range component",
type: "string",
default: "number-range"
},
appearance: {
description: "",
type: "object",
properties: {
class: {
type: "string"
},
style: {
type: "string"
}
},
default: {}
},
binding: {
description: "",
type: "object",
default: {}
},
disabled: {
type: "boolean",
default: !1
},
editable: {
description: "",
type: "boolean",
default: !0
},
placeholder: {
description: "",
type: "string",
default: ""
},
readonly: {
description: "",
type: "boolean",
default: !1
},
required: {
description: "",
type: "boolean",
default: !1
},
precision: {
description: "",
type: "number",
default: 0
},
tabindex: {
description: "",
type: "number",
default: -1
},
visible: {
description: "",
type: "boolean",
default: !0
},
beginValue: {
description: "",
type: "number"
},
endValue: {
description: "",
type: "number"
},
nullable: {
description: "",
type: "boolean",
default: !1
},
min: {
description: "",
type: "string"
},
max: {
description: "",
type: "string"
}
}, gi = [
"type"
], hi = {
$schema: ci,
$id: di,
title: fi,
description: pi,
type: mi,
properties: vi,
required: gi
}, Gt = {
/**
* 组件标识
*/
id: String,
/**
* 自动补全小数
*/
autoDecimal: { type: Boolean, default: !0 },
/**
* 下限placeholder---未实现
*/
beginPlaceHolder: { type: String, default: "请输入开始数字" },
/**
* 下限值
*/
beginValue: { type: [Number, String], default: "" },
/**
* 启用大数支持
*/
bigNumber: { type: Boolean, default: !1 },
/**
* 允许为空
*/
nullable: { type: Boolean, default: !1 },
/**
* 小数点符号
*/
decimalSeparator: { type: String, default: "." },
/**
* 是否禁用
*/
disabled: { type: Boolean, default: !1 },
/**
* 是否可编辑
*/
editable: { type: Boolean, default: !0 },
/**
* 上限placeholder---未实现
*/
endPlaceHolder: { type: String, default: "请输入结束数字" },
/**
* 上限值
*/
endValue: { type: [Number, String], default: "" },
/**
* 格式化 formatter 和 parser 必须同时存在
* formatter: (val: number) => string;
* parser: (val: string | number) => number;
*/
formatter: { type: Function },
/**
* 千分位符号
*/
groupSeparator: { type: String, default: "," },
/**
* 使用千分位时,每组显示的字符数
*/
groupSize: { type: Number, default: 3 },
/**
* 最大值
*/
max: { type: [Number, String] },
/**
* 最小值
*/
min: { type: [Number, String] },
parser: { type: Function },
/**
* 空白提示文本
*/
placeholder: { type: String, default: "请输入数字" },
/**
* 精度
*/
precision: { type: Number, default: 0 },
/**
* 前缀
*/
prefix: { type: String, default: "" },
/**
* 是否只读
*/
readonly: { type: Boolean, default: !1 },
/**
* 间隔符---未实现
*/
separator: { type: String, default: "~" },
/**
* 是否显示加减按钮
*/
showButton: { type: Boolean, default: !0 },
/**
* 显示0值
*/
showZero: { type: Boolean, default: !0 },
/**
* up or down 步长
*/
step: { type: Number, default: 1 },
/**
* 后缀
*/
suffix: { type: String, default: "" },
/**
* 文本方向
*/
textAlign: { type: String, default: "left" },
/**
* 是否使用千分值
*/
useThousands: { type: Boolean, default: !0 }
}, wn = lt(Gt, hi, ui, Do);
function Cn(n, t) {
const e = L(() => Number(n.precision) || 0);
function o(l) {
return l.toFixed(e.value);
}
function i(l) {
return isNaN(l) || l === null || l === void 0 || l === "";
}
function a(l) {
const s = i(n.max) ? null : new ve(String(n.max), 10), f = i(n.min) ? null : new ve(String(n.min), 10);
return s && l.gt(s) ? s : f && l.lt(f) ? f : l;
}
function r(l, s, f, u) {
const m = new ve(l, 10), d = i(f && f.value) ? null : new ve(String(f.value), 10), p = i(s && s.value) ? null : new ve(String(s.value), 10);
let v;
return u ? v = d && m.gt(d) ? d : m : v = p && m.lt(p) ? p : m, v.toString();
}
function c(l, s = !0) {
if (n.parser)
return isNaN(Number(l)) ? n.parser(l) : l;
let f = new ve(l, 10);
if (s && (f = a(f)), f.isNaN()) {
if (n.nullable)
return null;
const m = new ve("" + n.min, 10), d = new ve("" + n.max, 10);
if (!m.isNaN())
f = m;
else if (!d.isNaN())
f = d;
else
return 0;
}
return o(f);
}
return { getRealValue: c, isEmpty: i, precision: e, getValidNumberObject: a, getValidNumberInRange: r };
}
function Sn(n, t, e) {
const o = L(() => ({
prefix: n.prefix,
suffix: n.suffix,
decimalSeparator: n.decimalSeparator,
groupSeparator: n.useThousands ? n.groupSeparator : "",
groupSize: n.groupSize
})), { getValidNumberObject: i, precision: a } = e;
function r(s) {
return s = s == null || s === "" ? "" : String(s), s = s.replace(new RegExp(n.prefix, "g"), "").replace(new RegExp(n.suffix, "g"), "").replace(/,/g, ""), n.groupSeparator && n.groupSeparator !== "," && (s = s.replace(new RegExp(`\\${n.groupSeparator}`, "g"), "")), n.decimalSeparator && n.decimalSeparator !== "." && (s = s.replace(new RegExp(`\\${n.decimalSeparator}`, "g"), ".")), s;
}
function c(s, f) {
return n.precision !== null && n.precision !== void 0 ? s.toFormat(a.value, f) : s.toFormat(f);
}
function l(s, f = !0) {
const u = r(s), m = new ve(u, 10);
let d = m;
return f && (d = i(m)), d.valueOf() === "0" && !n.showZero || d.isNaN() ? "" : n.formatter ? n.formatter(d.toNumber()) : c(d, o.value);
}
return { cleanFormat: r, format: l };
}
function yt(n, t, e, o, i, a, r, c, l, s) {
const { format: f } = i, { getRealValue: u, getValidNumberInRange: m } = a;
function d() {
const b = new ve(o.value || 0);
return !((n.max || n.max === 0) && !new ve(n.max).isNaN() && b.gte(new ve(n.max)) && (o.value || o.value === 0));
}
function p() {
const b = new ve(o.value || 0);
return !((n.min || n.min === 0) && !new ve(n.min).isNaN() && b.lte(new ve(n.min)) && (o.value || o.value === 0));
}
function v(b) {
if (n.readonly || n.disabled)
return;
const h = b === "up" ? d : p, g = b === "up" ? "plus" : "minus";
if (h()) {
let w = new ve(o.value || 0)[g](Number(n.step)).toFixed();
w = m(w, c, l, s);
const I = u(w);
e.value = f(w), o.value !== I && (o.value = I, r(o.value));
}
}
function x() {
v("up");
}
function F() {
v("down");
}
function k(b) {
x(), b.stopPropagation();
}
function j(b) {
F(), b.stopPropagation();
}
return { canDownward: p, canUpward: d, downward: F, onClickDownButton: j, onClickUpButton: k, upward: x };
}
function bt(n, t, e, o, i, a, r, c, l, s, f) {
const { cleanFormat: u, format: m } = i, { getRealValue: d, isEmpty: p, getValidNumberInRange: v } = a, { downward: x, upward: F } = r, k = L(() => e.value), j = S(!1);
function b(M) {
var B;
if (M.stopPropagation(), n.readonly || n.disabled)
return;
j.value = !1;
let w = (B = M.target) == null ? void 0 : B.value;
n.nullable || (w = w || 0);
let I = u(w);
I = v(I, l, s, f);
const C = d(I);
e.value = m(I), o.value !== C && (o.value = C, c(o.value)), t.emit("blur", { event: M, formatted: e.value, value: o.value });
}
function h(M) {
M.stopPropagation(), !(n.readonly || n.disabled) && (j.value = !0, e.value = p(o.value) || !n.showZero && o.value === "0" ? "" : String(o.value), t.emit("focus", { event: M, formatted: e.value, value: o.value }));
}
function g(M) {
var C;
M.stopPropagation();
let w = (C = M.target) == null ? void 0 : C.value;
n.nullable || (w = w || 0);
const I = u(w);
e.value = I, o.value = d(I), c(o.value);
}
function E(M) {
M.key === "ArrowDown" && (M.preventDefault(), x()), M.key === "ArrowUp" && (M.preventDefault(), F()), M.stopPropagation();
}
return { textBoxValue: k, onBlurTextBox: b, onFocusTextBox: h, onInput: g, onKeyDown: E, isTextBoxFocused: j };
}
function on(n, t, e, o, i) {
const {
onBlurTextBox: a,
onFocusTextBox: r,
onInput: c,
onKeyDown: l,
textBoxValue: s
} = e, f = L(() => n.disabled || n.readonly || !n.editable ? "" : o ? i.range.begin : i.range.end), u = L(() => ({
"form-control": !0,
"sub-input": !0
})), m = L(() => ({
"text-align": n.textAlign
}));
function d(p) {
p.stopPropagation();
}
return () => y("input", {
class: u.value,
style: m.value,
type: "text",
value: s.value,
disabled: n.disabled,
readonly: n.readonly || !n.editable,
placeholder: f.value,
onBlur: a,
onChange: d,
onFocus: r,
onInput: c,
onKeydown: l
}, null);
}
function wt(n, t, e) {
const {
canDownward: o,
canUpward: i,
onClickDownButton: a,
onClickUpButton: r
} = e, c = L(() => ({
"input-group-append": !0,
"btn-group": !0,
"btn-group-number": !0,
"sub-btn-group": !0
})), l = L(() => ({
btn: !0,
"btn-secondary": !0,
"btn-number-flag": !0
})), s = L(() => ({
cursor: i() ? "pointer" : "not-allowed",
"margin-left": 0
})), f = L(() => ({
cursor: o() ? "pointer" : "not-allowed",
"margin-left": 0
}));
return () => y("div", {
class: c.value
}, [y("button", {
class: l.value,
style: s.value,
onClick: r,
disabled: !i()
}, [y("span", {
class: "f-icon f-icon-arrow-chevron-up number-arrow-chevron"
}, null)]), y("button", {
class: l.value,
style: f.value,
onClick: a,
disabled: !o()
}, [y("span", {
class: "f-icon f-icon-arrow-chevron-down number-arrow-chevron"
}, null)])]);
}
const Ct = /* @__PURE__ */ Ie({
name: "FNumberRange",
props: Gt,
emits: ["valueChange", "blur", "focus", "click", "input", "beginValueChange", "endValueChange"],
setup(n, t) {
const e = S(n.beginValue), o = S(""), i = S(n.endValue), a = S(""), r = Cn(n), c = Sn(n, t, r), l = Gn(n), s = (g) => {
t.emit("beginValueChange", g);
}, f = yt(n, t, o, e, c, r, s, e, i, !0), u = bt(n, t, o, e, c, r, f, s, e, i, !0), m = wt(n, t, f), d = on(n, t, u, !0, l), p = (g) => {
t.emit("endValueChange", g);
}, v = yt(n, t, a, i, c, r, p, e, i, !1), x = bt(n, t, a, i, c, r, v, p, e, i, !1), F = wt(n, t, v), k = on(n, t, x, !1, l), {
getRealValue: j
} = r, {
format: b
} = c, h = L(() => !n.disabled && !n.readonly && n.showButton);
return Ye(() => {
const g = j(n.beginValue, !1), E = j(n.endValue, !1);
o.value = b(g, !1), a.value = b(E, !1);
}), be(() => [n.beginValue], ([g]) => {
if (!u.isTextBoxFocused.value) {
const E = j(g, !1);
e.value = E, o.value = b(E, !1);
}
}), be(() => [n.endValue], ([g]) => {
if (!x.isTextBoxFocused.value) {
const E = j(g, !1);
i.value = E, a.value = b(E, !1);
}
}), be(() => [n.precision, n.useThousands, n.prefix, n.suffix, n.showZero], () => {
o.value = b(e.value), a.value = b(i.value);
}), () => y("div", {
class: "input-group number-range f-cmp-number-spinner"
}, [y("div", {
class: "form-control input-container"
}, [y("div", {
class: "sub-input-group"
}, [d(), h.value && m()]), y("span", {
class: "spliter"
}, [Ut("~")]), y("div", {
class: "sub-input-group"
}, [k(), h.value && F()])])]);
}
});
function rn(n, t, e, o) {
const {
onBlurTextBox: i,
onFocusTextBox: a,
onInput: r,
onKeyDown: c,
textBoxValue: l
} = e, s = L(() => o ? n.beginPlaceHolder : n.endPlaceHolder), f = L(() => ({
"form-control": !0,
"sub-input": !0
})), u = L(() => ({
"text-align": n.textAlign
}));
function m(d) {
d.stopPropagation();
}
return () => y("input", {
class: f.value,
style: u.value,
type: "text",
value: l.value,
disabled: n.disabled,
readonly: n.readonly || !n.editable,
placeholder: s.value,
onBlur: i,
onChange: m,
onFocus: a,
onInput: r,
onKeydown: c
}, null);
}
function xn(n, t, e) {
var C;
const o = e && e.getStyles && e.getStyles() || "", i = e && e.getDesignerClass && e.getDesignerClass() || "", a = S();
let r;
function c() {
return (t == null ? void 0 : t.schema.componentType) === "frame" ? !1 : e && e.checkCanMoveComponent ? e.checkCanMoveComponent() : !0;
}
function l() {
return !1;
}
function s() {
return (t == null ? void 0 : t.schema.componentType) === "frame" ? !1 : e && e.checkCanDeleteComponent ? e.checkCanDeleteComponent() : !0;
}
function f() {
return (t == null ? void 0 : t.schema.componentType) === "frame" ? !0 : e && e.hideNestedPaddingInDesginerView ? e.hideNestedPaddingInDesginerView() : !1;
}
function u(B) {
if (!B || !B.value)
return null;
if (B.value.schema && B.value.schema.type === "component")
return B.value;
const O = S(B == null ? void 0 : B.value.parent), V = u(O);
return V || null;
}
function m(B = t) {
var W;
if (e != null && e.getDraggableDesignItemElement)
return e.getDraggableDesignItemElement(B);
const { componentInstance: O, designerItemElementRef: V } = B;
if (!O || !O.value)
return null;
const { getCustomButtons: H } = O.value;
return O.value.canMove || H && ((W = H()) != null && W.length) ? V : m(B.parent);
}
function d(B) {
return !!e && e.canAccepts(B);
}
function p() {
return (t == null ? void 0 : t.schema.label) || (t == null ? void 0 : t.schema.title) || (t == null ? void 0 : t.schema.name);
}
function v() {
}
function x(B, O) {
var V;
!B || !O || (e != null && e.onAcceptMovedChildElement && e.onAcceptMovedChildElement(B, O), (V = t == null ? void 0 : t.setupContext) == null || V.emit("dragEnd"));
}
function F(B, O) {
const { componentType: V } = B;
let H = Xn(V, B, O);
e && e.onResolveNewComponentSchema && (H = e.onResolveNewComponentSchema(B, H));
const W = V.toLowerCase().replace(/-/g, "_");
return H && !H.id && H.type === V && (H.id = `${W}_${Math.random().toString().slice(2, 6)}`), H;
}
function k(B) {
B && e != null && e.onChildElementMovedOut && e.onChildElementMovedOut(B);
}
function j(...B) {
if (e && e.getPropsConfig)
return e.getPropsConfig(...B);
}
function b(B) {
if (!B)
return;
const O = t == null ? void 0 : t.schema, { formSchemaUtils: V } = B;
if (O && V.getExpressions().length) {
const H = V.getExpressions().findIndex((W) => W.target === O.id);
H > -1 && V.getExpressions().splice(H, 1);
}
}
function h(B) {
if (!B || !(t != null && t.schema))
return;
const O = t.schema, { formSchemaUtils: V } = B;
V.removeCommunicationInComponent(O);
}
function g(B) {
e && e.onRemoveComponent && e.onRemoveComponent(), b(B), h(B), t != null && t.schema.contents && t.schema.contents.map((O) => {
let V = O.id;
O.type === "component-ref" && (V = O.component);
const H = n.value.querySelectorAll(`#${V}-design-item`);
H != null && H.length && Array.from(H).map((W) => {
var ee;
(ee = W == null ? void 0 : W.componentInstance) != null && ee.value.onRemoveComponent && W.componentInstance.value.onRemoveComponent(B);
});
});
}
function E() {
if (e && e.getCustomButtons)
return e.getCustomButtons();
}
function M(B) {
var V, H;
if (!((V = t == null ? void 0 : t.schema) != null && V.id))
return;
if (!r && B && (r = B.formSchemaUtils), e != null && e.setComponentBasicInfoMap) {
e.setComponentBasicInfoMap();
return;
}
let O = "";
if (e != null && e.getComponentTitle)
O = e.getComponentTitle();
else {
const { text: W, title: ee, label: D, mainTitle: P, name: G, type: z } = t.schema;
O = W || ee || D || P || G || ((H = $[z]) == null ? void 0 : H.name);
}
O && r.getControlBasicInfoMap().set(t.schema.id, {
componentTitle: O,
parentPathName: O
});
}
function w(B) {
var W;
const { changeObject: O } = B, { propertyID: V, propertyValue: H } = O;
if (["text", "title", "label", "name", "mainTitle"].includes((W = B == null ? void 0 : B.changeObject) == null ? void 0 : W.propertyID) && V && H && (M(), r)) {
const ee = r.getControlBasicInfoMap(), D = ee.keys().toArray().filter((P) => {
var G, z;
return ((G = ee.get(P)) == null ? void 0 : G.reliedComponentId) === ((z = t == null ? void 0 : t.schema) == null ? void 0 : z.id);
});
D != null && D.length && D.forEach((P) => {
const G = ee.get(P).parentPathName.split(" > ");
G[0] = H, ee.get(P).parentPathName = G.join(" > ");
});
}
}
function I(B) {
if (w(B), e && e.onPropertyChanged)
return e.onPropertyChanged(B);
}
return a.value = {
canMove: c(),
canSelectParent: l(),
canDelete: s(),
canNested: !f(),
contents: t == null ? void 0 : t.schema.contents,
elementRef: n,
parent: (C = t == null ? void 0 : t.parent) == null ? void 0 : C.componentInstance,
schema: t == null ? void 0 : t.schema,
styles: o,
designerClass: i,
canAccepts: d,
getBelongedComponentInstance: u,
getDraggableDesignItemElement: m,
getDraggingDisplayText: p,
getPropConfig: j,
getDragScopeElement: v,
onAcceptMovedChildElement: x,
onChildElementMovedOut: k,
addNewChildComponentSchema: F,
triggerBelongedComponentToMoveWhenMoved: !!e && e.triggerBelongedComponentToMoveWhenMoved || S(!1),
triggerBelongedComponentToDeleteWhenDeleted: !!e && e.triggerBelongedComponentToDeleteWhenDeleted || S(!1),
onRemoveComponent: g,
getCustomButtons: E,
onPropertyChanged: I,
setComponentBasicInfoMap: M,
updateContextSchema: t == null ? void 0 : t.updateContextSchema
}, a;
}
const yi = S(0);
function bi() {
yi.value++;
}
const ft = S(0);
function wi(n) {
const { formSchemaUtils: t, formStateMachineUtils: e } = n;
function o(l, s = "") {
return {
path: s + l.code,
field: l.id,
fullPath: l.code
};
}
function i(l, s = "") {
return t.getViewModelById(l).states.map((u) => o(u, s));
}
function a(l) {
const s = t.getRootViewModelId(), f = i(l);
if (l === s)
return f;
const u = i(s, "root-component.");
return [...f, ...u];
}
function r(l) {
return l.binding && l.binding.path || l.id || "";
}
function c() {
return e && e.getRenderStates() || [];
}
return { getVariables: a, getControlName: r, getStateMachines: c };
}
class Tn {
constructor(t) {
X(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'"
}
]);
X(this, "expressionNames", {
compute: "计算表达式",
dependency: "依赖表达式",
validate: "验证表达式",
dataPicking: "帮助前表达式",
visible: "可见表达式",
readonly: "只读表达式",
required: "必填表达式"
});
X(this, "getExpressionConverter", (t, e) => ({
convertFrom: (o, i, a, r) => {
const c = a.getExpressionRuleValue(t, e || i);
return c && c.value || "";
},
convertTo: (o, i, a, r, c) => {
var l;
if (i === "dataPicking" && (a != null && a.target)) {
const s = `${a.target}_dataPicking`;
((l = a.rules) == null ? void 0 : l.some(
(u) => u.id === s && u.value
)) ? o.dictPickingExpressionId = s : delete o.dictPickingExpressionId;
}
r.updateExpression(a);
}
}));
this.formSchemaService = t;
}
getExpressionRule(t, e) {
const o = this.formSchemaService.getExpressions();
if (!o)
return "";
const i = o.find((r) => r.target === t);
if (!i)
return "";
const a = i.rules.find((r) => r.type === e);
return a || "";
}
// 获取上下文表单变量
getContextFormVariables() {
const { module: t } = this.formSchemaService.getFormSchema();
if (!t.viewmodels || t.viewmodels.length === 0)
return [];
const e = this.formSchemaService.getRootViewModelId(), o = this.formSchemaService.getViewModelById(e);
if (!o || !o.states || o.states.length === 0)
return [];
const i = [];
return o.states.forEach((a) => {
i.push({
key: a.code,
name: a.name,
description: a.name,
category: a.category
});
}), i;
}
createTreeNode(t, e, o = "label") {
return {
id: t.id,
name: t.name,
bindingPath: t[o],
parents: e,
type: "field"
};
}
buildEntityFieldsTreeData(t = null, e) {
const o = [];
return t == null || t.forEach((i) => {
var c;
const a = this.createTreeNode(i, e);
let r = [];
(c = i.type) != null && c.fields && (r = this.buildEntityFieldsTreeData(i.type.fields, [...e, i.label])), o.push({
data: a,
children: r,
expanded: !0
});
}), o;
}
buildChildEntityTreeData(t = null, e) {
const o = [];
return t == null || t.forEach((i) => {
var l, s;
const a = this.createTreeNode(i, e);
a.type = "entity";
const r = this.buildEntityFieldsTreeData((l = i.type) == null ? void 0 : l.fields, [...e, i.label]), c = this.buildChildEntityTreeData((s = i.type) == null ? void 0 : s.entities, [...e, i.label]);
c != null && c.length && (r == null || r.push(...c)), o.push({
data: a,
children: r || [],
// 空值回退
expanded: !0
});
}), o;
}
getEntitiesTreeData() {
const t = this.formSchemaService.getSchemaEntities();
if (!(t != null && t.length))
return [];
const e = t[0];
if (!(e != null && e.type))
return [];
const o = this.buildEntityFieldsTreeData(e.type.fields, [e.code]), i = this.buildChildEntityTreeData(e.type.entities, [e.code]);
return i != null && i.length && (o == null || o.push(...i)), {
entityCode: e.code,
fields: [{
data: this.createTreeNode(e, [], "code"),
children: o || []
}]
};
}
getEntitiesAndVariables() {
return {
entities: this.getEntitiesTreeData(),
variables: {
session: {
name: "系统变量",
items: this.sessionVariables,
visible: !1
},
forms: {
name: "表单变量",
items: this.getContextFormVariables(),
visible: !0
}
}
};
}
onBeforeOpenExpression(t, e, o) {
const i = o === "Field" ? t.binding.field : t.id, a = this.getExpressionRule(i, e), r = this.getEntitiesAndVariables(), c = {
message: ["validate", "required", "dataPicking"].includes(e) && a ? a.message : "",
...r
};
return a.messageType != null && (c.messageType = a.messageType), c;
}
buildRule(t, e, o, i) {
const { expression: a, message: r, messageType: c } = e, l = {
id: `${t}_${o}`,
type: o,
value: a
};
return (o === "validate" || o === "dataPicking" || o === "required") && (l.message = r), o === "dataPicking" && (l.messageType = c), o === "validate" && i && (l.elementId = i), l;
}
getExpressionData() {
const { expressions: t } = this.formSchemaService.getFormSchema().module;
return t || [];
}
updateExpression(t, e, o, i) {
const a = e === "Field" ? t.binding.field : t.id, r = this.buildRule(a, o, i, t.type === "form-group" ? t.id : "");
let l = this.getExpressionData().find((f) => f.targetType === e && f.target === a);
const s = (f) => f.value.trim() === "";
if (l) {
const f = l.rules.find((u) => u.id === r.id);
if (f)
s(r) ? l.rules = l.rules.filter((u) => u.id !== r.id) : (Object.assign(f, r), i === "validate" && t.type === "form-group" && (f.elementId = t.id));
else {
if (s(r))
return null;
l.rules = l.rules || [], l.rules.push(r);
}
} else {
if (s(r))