@farris/ui-vue
Version:
Farris Vue, a Farris Design based Vue3 component library.
1,358 lines • 95.9 kB
JavaScript
var Ee = Object.defineProperty;
var Fe = (i, t, e) => t in i ? Ee(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
var y = (i, t, e) => Fe(i, typeof t != "symbol" ? t + "" : t, e);
import { ref as L, computed as U, defineComponent as re, watch as K, createVNode as V, Fragment as xe, createTextVNode as we, nextTick as Se, inject as _, onMounted as Ie } from "vue";
import { isPlainObject as ee, cloneDeep as X } from "lodash-es";
import { resolveAppearance as Me } from "../dynamic-resolver/index.esm.js";
import { getCustomClass as oe, urlPrependBasePath as G, FormSchemaEntityField$Type as te, FormSchemaEntityFieldType$Type as Pe, EVENT_PROPERTY_TAB_IDS as ie, withInstall as Te } from "../common/index.esm.js";
import { DgControl as f, canvasChanged as q, refreshCanvas as ke, useDesignerComponent as Ve } from "../designer-canvas/index.esm.js";
function se(i, t) {
let e;
function n(s) {
const { properties: p, title: b, ignore: d } = s, a = d && Array.isArray(d), h = Object.keys(p).reduce((v, C) => ((!a || !d.find((x) => x === C)) && (v[C] = p[C].type === "object" && p[C].properties ? n(p[C]) : X(p[C].default)), v), {});
if (b && (!a || !d.find((v) => v === "id"))) {
const v = b.toLowerCase().replace(/-/g, "_");
h.id = `${v}_${Math.random().toString().slice(2, 6)}`;
}
return h;
}
function r(s) {
const { properties: p, title: b, required: d } = s;
if (d && Array.isArray(d)) {
const a = d.reduce((h, v) => (h[v] = p[v].type === "object" && p[v].properties ? n(p[v]) : X(p[v].default), h), {});
if (b && d.find((h) => h === "id")) {
const h = b.toLowerCase().replace(/-/g, "_");
a.id = `${h}_${Math.random().toString().slice(2, 6)}`;
}
return a;
}
return {
type: b
};
}
function o(s, p = {}, b) {
const d = i[s];
if (d) {
let a = r(d);
const h = t[s];
return a = h ? h({ getSchemaByType: o }, a, p, b) : a, e != null && e.appendIdentifyForNewControl && e.appendIdentifyForNewControl(a), a;
}
return null;
}
function l(s, p) {
const b = n(p);
return Object.keys(b).reduce((d, a) => (Object.prototype.hasOwnProperty.call(s, a) && (d[a] && ee(d[a]) && ee(s[a] || !s[a]) ? Object.assign(d[a], s[a] || {}) : d[a] = s[a]), d), b), b;
}
function g(s, p) {
return Object.keys(s).filter((d) => s[d] != null).reduce((d, a) => {
if (p.has(a)) {
const h = p.get(a);
if (typeof h == "string")
d[h] = s[a];
else {
const v = h(a, s[a], s);
Object.assign(d, v);
}
} else
d[a] = s[a];
return d;
}, {});
}
function c(s, p, b = /* @__PURE__ */ new Map()) {
const d = l(s, p);
return g(d, b);
}
function u(s) {
var b;
const p = s.type;
if (p) {
const d = i[p];
if (!d)
return s;
const a = l(s, d), h = ((b = s.editor) == null ? void 0 : b.type) || "";
if (h) {
const v = i[h], C = l(s.editor, v);
a.editor = C;
}
return a;
}
return s;
}
function m(s) {
e = s;
}
return { getSchemaByType: o, resolveSchemaWithDefaultValue: u, resolveSchemaToProps: c, mappingSchemaToProps: g, setDesignerContext: m };
}
const le = {}, ae = {}, { resolveSchemaWithDefaultValue: Oe, resolveSchemaToProps: Be, mappingSchemaToProps: Le } = se(le, ae);
function Ne(i = {}) {
function t(u, m, s, p) {
if (typeof s == "number")
return p[u].length === s;
if (typeof s == "object") {
const b = Object.keys(s)[0], d = s[b];
if (b === "not")
return Number(p[u].length) !== Number(d);
if (b === "moreThan")
return Number(p[u].length) >= Number(d);
if (b === "lessThan")
return Number(p[u].length) <= Number(d);
}
return !1;
}
function e(u, m, s, p) {
return p[u] && p[u].propertyValue && String(p[u].propertyValue.value) === String(s);
}
const n = /* @__PURE__ */ new Map([
["length", t],
["getProperty", e]
]);
Object.keys(i).reduce((u, m) => (u.set(m, i[m]), u), n);
function r(u, m) {
const s = u;
return typeof m == "number" ? [{ target: s, operator: "length", param: null, value: Number(m) }] : typeof m == "boolean" ? [{ target: s, operator: "getProperty", param: u, value: !!m }] : typeof m == "object" ? Object.keys(m).map((p) => {
if (p === "length")
return { target: s, operator: "length", param: null, value: m[p] };
const b = p, d = m[p];
return { target: s, operator: "getProperty", param: b, value: d };
}) : [];
}
function o(u) {
return Object.keys(u).reduce((s, p) => {
const b = r(p, u[p]);
return s.push(...b), s;
}, []);
}
function l(u, m) {
if (n.has(u.operator)) {
const s = n.get(u.operator);
return s && s(u.target, u.param, u.value, m) || !1;
}
return !1;
}
function g(u, m) {
return o(u).reduce((b, d) => b && l(d, m), !0);
}
function c(u, m) {
const s = Object.keys(u), p = s.includes("allOf"), b = s.includes("anyOf"), d = p || b, v = (d ? u[d ? p ? "allOf" : "anyOf" : "allOf"] : [u]).map((x) => g(x, m));
return p ? !v.includes(!1) : v.includes(!0);
}
return { parseValueSchema: c };
}
const Re = {
convertTo: (i, t, e, n) => {
i.appearance || (i.appearance = {}), i.appearance[t] = e;
},
convertFrom: (i, t, e) => i.appearance ? i.appearance[t] : i[t]
}, Ge = {
convertFrom: (i, t, e) => i.buttons && i.buttons.length ? `共 ${i.buttons.length} 项` : "无"
}, je = {
convertTo: (i, t, e, n) => {
i.editor && (i.editor[t] = e);
},
convertFrom: (i, t, e) => i.editor && Object.prototype.hasOwnProperty.call(i.editor, t) ? i.editor[t] : i[t]
}, Ue = {
button: { type: "button", name: "按钮" },
"response-toolbar": { type: "response-toolbar", name: "工具栏" },
"response-toolbar-item": { type: "response-toolbar-item", name: "按钮" },
"content-container": { type: "content-container", name: "容器" },
table: { type: "table", name: "表格布局" },
"table-td": { type: "table-td", 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: "标签页工具栏按钮" },
"drawer-toolbar-item": { type: "drawer-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: "标签页工具栏" },
"drawer-toolbar": { type: "drawer-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: "列表导航" },
nav: { type: "nav", name: "标签类导航" },
"list-view": { type: "list-view", name: "列表" },
"filter-bar": { type: "filter-bar", name: "筛选条" },
"language-textbox": { type: "language-textbox", name: "多语输入框" },
image: { type: "image", name: "图像" },
avatar: { type: "avatar", name: "头像" },
"discussion-editor": { type: "discussion-editor", name: "评论编辑区" },
"discussion-list": { type: "discussion-list", name: "评论列表" },
comment: { type: "comment", name: "评论区" },
"approval-logs": { type: "approval-logs", name: "审批记录" },
"rich-text-editor": { type: "rich-text-editor", name: "富文本", icon: "rich-text-box" },
calendar: { type: "calendar", name: "日历", icon: "date-picker" },
wizard: { type: "wizard", name: "向导", icon: "wizard" },
"wizard-page": { type: "wizard-page", name: "向导页", icon: "wizard" },
"wizard-page-detail": { type: "wizard-page-detail", name: "向导详情", icon: "wizard" },
step: { type: "step", name: "步骤条", icon: "step" },
"dynamic-form": { type: "dynamic-form", name: "动态表单" }
}, Ye = {
convertFrom: (i, t, e) => {
var r;
const n = i.editor && i.editor[t] ? i.editor[t] : i[t];
return ((r = Ue[n]) == null ? void 0 : r.name) || n;
}
}, ze = {
convertTo: (i, t, e, n) => {
i[t] = i[t];
},
convertFrom: (i, t, e) => i.editor ? e.getRealEditorType(i.editor.type) : ""
}, qe = {
convertTo: (i, t, e, n) => {
(i.type === "data-grid-column" || i.type === "tree-grid-column") && (i.formatter ? i.formatter[t] = e : i.formatter = {
[t]: e
});
},
convertFrom: (i, t, e) => {
if (i.formatter) {
if (t === "trueText")
return i.formatter.trueText;
if (t === "falseText")
return i.formatter.falseText;
if (t === "prefix")
return i.formatter.prefix;
if (t === "suffix")
return i.formatter.suffix;
if (t === "precision")
return i.formatter.precision;
if (t === "decimal")
return i.formatter.decimal;
if (t === "thousand")
return i.formatter.thousand;
if (t === "dateFormat")
return i.formatter.dateFormat || "yyyy-MM-dd";
if (t === "customFormat")
return i.formatter.customFormat;
if (t === "type")
return i.formatter.type || "none";
}
return "none";
}
}, We = {
convertTo: (i, t, e, n) => {
i.command ? i.command[t] = e : i.command = {
[t]: e
}, t === "enableType" && e === "default" && (i.command.enable = !0, i.command.formatter = "", i.command.commands = [
{
text: "编辑",
type: "primary",
command: "edit"
},
{
text: "删除",
type: "danger",
command: "remove"
}
]), t === "enableType" && e === "custom" && (i.command.enable = !0, i.command.commands = [
{
value: "add",
text: "增加",
type: "link"
},
{
value: "edit",
text: "编辑",
type: "link"
},
{
value: "remove",
text: "删除",
type: "link"
}
]), t === "enableType" && e === "unable" && (i.command.enable = !1, i.command.formatter = "");
},
convertFrom: (i, t, e) => {
var n, r;
if (i.command) {
if (t === "enableType") {
if (i.command.enableType)
return i.command.enableType;
const o = (r = (n = i.command) == null ? void 0 : n.commands) == null ? void 0 : r.find((l) => l.command === "edit" && l.type === "primary");
return i.command.enable ? o ? "default" : "custom" : "unable";
}
if (t === "commands")
return i.command.enableType === "custom" ? i.command.commands : [];
if (t === "formatter")
return i.command.formatter;
if (t === "count")
return i.command.count;
if (t === "columnWidth")
return i.command.columnWidth || 200;
}
return "";
}
}, Je = {
convertTo: (i, t, e, n) => {
if (i.column || (i.column = {}), t === "fitMode") {
e && e !== "none" ? (i.column.fitColumns = !0, i.column.fitMode = e) : (i.column.fitColumns = !1, i.column.fitMode = "average");
return;
}
if (t === "fitColumns") {
i.column.fitColumns = e, e && !i.column.fitMode && (i.column.fitMode = "average");
return;
}
i.column[t] = e;
},
convertFrom: (i, t, e) => {
if (i.column) {
if (t === "fitMode")
return i.column.fitColumns ? i.column.fitMode || "average" : "none";
if (t === "fitColumns")
return i.column.fitColumns;
}
return t === "fitMode" ? "none" : "";
}
}, He = {
convertTo: (i, t, e, n) => {
i.summary ? i.summary[t] = e : i.summary = {
[t]: e
}, t === "enable" && e && (i.summary ? i.summary.groupFields || (i.summary.groupFields = []) : i.summary = {
enable: e,
groupFields: []
});
},
convertFrom: (i, t, e) => {
var n, r;
return t === "customSummaryStyle" ? i.summary.customSummaryStyle : t === "position" ? ((n = i.summary) == null ? void 0 : n[t]) || "bottom" : t === "customRender" ? ((r = i.summary) == null ? void 0 : r[t]) || "" : i.summary && t === "enable" ? i.summary.enable : i.type === "data-grid-column" ? i.enableSummary === void 0 ? !1 : i.enableSummary : "";
}
}, Ze = {
convertTo: (i, t, e, n) => {
i.group ? i.group[t] = e : i.group = {
[t]: e
}, t === "enable" && e && (i.group ? i.group.groupFields || (i.group.groupFields = []) : i.group = {
enable: e,
groupFields: [],
showSummary: !1,
customRender: ""
});
},
convertFrom: (i, t, e) => {
if (i.group) {
if (t === "enable")
return i.group.enable;
if (t === "showSummary")
return i.group.showSummary;
if (t === "customRender")
return i.group.customRender;
if (t === "groupFields")
return i.group.groupFields;
}
}
}, Qe = {
convertFrom: (i, t) => i.binding ? i.binding.path : "",
convertTo: (i, t, e) => {
if (e && e.length > 0) {
const n = e[0];
i.binding || (i.binding = {}), i.binding.type = "Form", i.binding.path = n.bindingField, i.binding.field = n.id, i.binding.fullPath = n.path, i.path = n.bindingPath;
}
}
}, Xe = {
convertTo: (i, t, e, n) => {
if (i.pagination || (i.pagination = {}), t === "sizeLimits")
if (e == null)
delete i.pagination.sizeLimits;
else {
const r = [...new Set(
String(e).split(",").map((o) => o.trim()).filter((o) => o !== "").map((o) => parseInt(o, 10)).filter((o) => !Number.isNaN(o) && o > 0)
)];
r.length > 0 ? i.pagination.sizeLimits = r : delete i.pagination.sizeLimits;
}
else
i.pagination[t] = e;
},
convertFrom: (i, t, e) => {
var n;
return i.pagination ? t === "sizeLimits" ? ((n = i.pagination.sizeLimits) == null ? void 0 : n.join(",")) ?? "" : i.pagination[t] : i[t];
}
}, De = {
convertTo: (i, t, e, n) => {
i.rowNumber || (i.rowNumber = {}), i.rowNumber[t] = e;
},
convertFrom: (i, t, e) => i.rowNumber ? i.rowNumber[t] : i[t]
}, $e = {
convertTo: (i, t, e, n) => {
i.selection || (i.selection = {}), i.selection[t] = e;
},
convertFrom: (i, t, e) => {
if (!i.selection)
return !!i[t];
const n = !!i.selection[t];
return t === "showCheckbox" && n == null && i.selection.multiSelect === !0 ? !0 : n;
}
}, Ke = {
convertFrom: (i, t, e) => i[t] && i[t].length ? `共 ${i[t].length} 项` : ""
}, _e = {
convertFrom: (i, t) => i[t] || "",
convertTo: (i, t, e) => {
i[t] = e;
}
}, et = {
convertTo: (i, t, e, n) => {
i.size || (i.size = {}), i.size[t] = e;
},
convertFrom: (i, t, e) => i.size ? i.size[t] : i[t]
}, tt = {
convertFrom: (i, t, e) => {
var n, r;
return (n = i.formatter) != null && n.data && t === "formatterEnumData" && !i.formatterEnumData ? (r = i.formatter) == null ? void 0 : r.data : i.formatterEnumData;
}
}, it = {
convertTo: (i, t, e, n) => {
i.sort || (i.sort = {}), i.sort[t] = e;
},
convertFrom: (i, t, e) => {
var n, r;
if (t === "mode")
return ((n = i.sort) == null ? void 0 : n.mode) || "client";
if (t === "multiSort")
return !!((r = i.sort) != null && r.multiSort);
}
}, nt = {
convertTo: (i, t, e, n) => {
i.filter || (i.filter = {}), i.filter[t] = e, t === "enable" && (i.enableFilter = !1);
},
convertFrom: (i, t, e) => {
var n, r, o, l;
return t === "mode" ? ((n = i.filter) == null ? void 0 : n.mode) || "server" : t === "filterStyle" ? ((r = i.filter) == null ? void 0 : r.filterStyle) || "filter-column" : t === "enable" ? ((o = i.filter) == null ? void 0 : o.enable) !== void 0 ? !!i.filter.enable : !!i.enableFilter : ((l = i.filter) == null ? void 0 : l[t]) || void 0;
}
}, rt = {
convertTo: (i, t, e, n) => {
i.rowOption ? i.rowOption[t] = e : i.rowOption = {
[t]: e
};
},
convertFrom: (i, t, e) => {
if (i.rowOption) {
if (t === "customRowStyle")
return i.rowOption.customRowStyle;
if (t === "customCellStyle")
return i.rowOption.customCellStyle;
if (t === "height")
return i.rowOption.height;
}
return "";
}
}, ot = {
convertTo: (i, t, e, n) => {
(i.type === "data-grid-column" || i.type === "tree-grid-column") && (i[t] = e, t === "columnTemplateType" && e === "hyperlink" && (i.onClickLinkCommand ? i.columnTemplate = `
<span class="f-pretend-link f-cursor-pointer"
@click="(ctx)=>viewModel.current.${i.onClickLinkCommand || ""}({id: rowData.id,context: ctx})">
{{rowData.${i.field}}}
</span>` : i.columnTemplate = `
<span class="f-pretend-link f-cursor-pointer">
{{rowData.${i.field}}}
</span>`), t === "columnTemplateType" && e === "default" && (i.columnTemplate = ""), t === "columnTemplateType" && e === "custom" && (i.columnTemplate = ""));
},
convertFrom: (i, t, e) => t === "columnTemplate" ? i.columnTemplate : t === "columnTemplateType" ? i.columnTemplateType ? i.columnTemplateType || "default" : i.columnTemplate && !i.onClickLinkCommand ? "custom" : i.columnTemplate && i.onClickLinkCommand ? "hyperlink" : "default" : ""
}, st = {
convertTo: (i, t, e, n) => {
i.hierarchy || (i.hierarchy = {
cascadeOption: {}
}), i.hierarchy.cascadeOption || (i.hierarchy.cascadeOption = {}), i.hierarchy.cascadeOption[t] = e;
},
convertFrom: (i, t, e) => {
var n, r;
return !!((r = (n = i.hierarchy) == null ? void 0 : n.cascadeOption) != null && r[t]);
}
};
function de(i, t, e) {
const n = /* @__PURE__ */ new Map([
["/converter/appearance.converter", Re],
["/converter/buttons.converter", Ge],
["/converter/property-editor.converter", je],
["/converter/items-count.converter", Ke],
["/converter/type.converter", Ye],
["/converter/change-editor.converter", ze],
["/converter/change-formatter.converter", qe],
["/converter/column-command.converter", We],
["/converter/column-option.converter", Je],
["/converter/summary.converter", He],
["/converter/group.converter", Ze],
["/converter/form-group-label.converter", _e],
["/converter/field-selector.converter", Qe],
["/converter/pagination.converter", Xe],
["/converter/row-number.converter", De],
["/converter/grid-selection.converter", $e],
["/converter/size.converter", et],
["/converter/change-formatter-enum.converter", tt],
["/converter/grid-sort.converter", it],
["/converter/grid-filter.converter", nt],
["/converter/row-option.converter", rt],
["/converter/change-formatter-type.converter", ot],
["/converter/tree-auto-check.converter", st]
]), r = /* @__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 }],
["multiLanguage", { type: "language-textbox" }]
]), o = Ne();
function l(d, a) {
return () => o.parseValueSchema(d, a);
}
function g(d, a, h) {
return d.includes("visible") && a.visible !== void 0 ? typeof a.visible == "boolean" ? () => !!a.visible : a.visible === void 0 ? !0 : l(a.visible, h) : () => !0;
}
function c(d, a, h) {
return d.includes("readonly") && a.readonly !== void 0 ? typeof a.readonly == "boolean" ? () => !!a.readonly : l(a.readonly, h) : () => !1;
}
function u(d, a) {
const h = d.$converter || a;
return typeof h == "string" && h && n.has(h) ? n.get(h) || null : h || null;
}
function m(d, a, h, v, C, x = "", S = "") {
return Object.keys(d).map((F) => {
const M = L(1), I = F, E = d[F], A = Object.keys(E), R = E.title, O = E.type, B = r.get(O) || { type: "input-group", enableClear: !1 }, k = E.editor ? Object.assign({}, B, E.editor) : Object.assign({}, B), H = g(A, E, a), Y = c(A, E, a);
k.readonly = k.readonly === void 0 ? Y() : k.readonly;
const Z = E.type === "cascade" ? m(E.properties, a, h, v, C, x, S) : [], Q = !0;
let P = u(E, S);
const be = U({
get() {
if (M.value) {
if (["class", "style"].find((z) => z === I) && !P && (P = n.get("/converter/appearance.converter") || null), P && P.convertFrom) {
const z = P.convertFrom(h, F, C, x);
return z === void 0 && Object.prototype.hasOwnProperty.call(E, "defaultValue") ? E.type === "boolean" ? E.defaultValue : E.defaultValue || "" : z;
}
const T = h[F];
return Object.prototype.hasOwnProperty.call(E, "defaultValue") && (T === void 0 || typeof T == "string" && T === "") ? E.type === "boolean" ? E.defaultValue : E.defaultValue || "" : T;
}
return null;
},
set(T) {
M.value += 1, P && P.convertTo ? (P.convertTo(v, F, T, C, x), P.convertTo(h, F, T, C, x)) : (v[F] = T, h[F] = T);
}
}), { refreshPanelAfterChanged: ve, description: ye, isExpand: Ce, parentPropertyID: Ae } = E, $ = { propertyID: I, propertyName: R, propertyType: O, propertyValue: be, editor: k, visible: H, readonly: Y, cascadeConfig: Z, hideCascadeTitle: Q, refreshPanelAfterChanged: ve, description: ye, isExpand: Ce, parentPropertyID: Ae };
return a[I] = $, $;
});
}
function s(d, a, h = {}) {
const v = {}, C = i[d];
return C && C.categories ? Object.keys(C.categories).map((S) => {
const w = C.categories[S], F = w == null ? void 0 : w.title, M = m(w.properties || {}, v, {}, h, a);
return { categoryId: S, categoryName: F, properties: M };
}) : [];
}
function p(d, a, h, v, C = "") {
const x = a.$ref.schema, S = a.$ref.converter, w = h[x], F = w.type, M = e(w), I = {}, E = i[F];
if (E && E.categories) {
const A = E.categories[d], R = A == null ? void 0 : A.title;
S && Object.keys(A.properties).forEach((k) => {
A.properties[k].$converter = S;
});
const O = (A == null ? void 0 : A.properties) || {}, B = m(O, I, M, w, v, C);
return { categoryId: d, categoryName: R, properties: B };
}
return { categoryId: d, categoryName: "", properties: [] };
}
function b(d, a, h, v, C) {
const x = d.type, S = e(d), w = {};
let F = C || i[x];
if (!(F && Object.keys(F).length > 0) && h && h.getPropConfig && (F = h.getPropConfig(v)), F && F.categories) {
const I = [];
return Object.keys(F.categories).map((E) => {
const A = F.categories[E];
if (A.$ref) {
I.push(p(E, A, d, a, v));
return;
}
const R = A == null ? void 0 : A.title, O = A == null ? void 0 : A.tabId, B = A == null ? void 0 : A.tabName, k = A == null ? void 0 : A.hide, H = A == null ? void 0 : A.hideTitle, Y = m(A.properties || {}, w, S, d, a, v, A.$converter), { setPropertyRelates: Z } = A, Q = A == null ? void 0 : A.parentPropertyID;
I.push({ categoryId: E, categoryName: R, tabId: O, tabName: B, hide: k, properties: Y, hideTitle: H, setPropertyRelates: Z, parentPropertyID: Q });
}), I;
}
return [];
}
return {
getPropertyConfigBySchema: b,
getPropertyConfigByType: s,
propertyConverterMap: n
};
}
const ce = {}, ue = {};
de(ce, ue, Oe);
const pe = {}, me = {}, { resolveSchemaWithDefaultValue: lt } = se(pe, me), fe = {}, ge = {};
de(fe, ge, lt);
function at(i, t, e = /* @__PURE__ */ new Map(), n = (l, g, c, u) => g, r = {}, o = (l) => l) {
return le[t.title] = t, ae[t.title] = n, ce[t.title] = r, ue[t.title] = o, pe[t.title] = t, me[t.title] = n, fe[t.title] = r, ge[t.title] = o, (l = {}, g = !0) => {
if (!g)
return Le(l, e);
const c = Be(l, t, e), u = Object.keys(i).reduce((m, s) => (m[s] = i[s].default, m), {});
return Object.assign(u, c);
};
}
function dt(i, t, e) {
return t;
}
const ct = /* @__PURE__ */ new Map([
["appearance", Me]
]), ut = "https://json-schema.org/draft/2020-12/schema", pt = "https://farris-design.gitee.io/image.schema.json", mt = "image", ft = "A Farris Component", gt = "object", ht = {
id: {
description: "The unique identifier for image",
type: "string"
},
type: {
description: "The type string of image",
type: "string",
default: "image"
},
appearance: {
description: "",
type: "object",
properties: {
class: {
type: "string"
},
style: {
type: "string"
}
},
default: {}
},
binding: {
description: "",
type: "object",
default: {}
},
rootId: {
description: "",
type: "string",
default: "default-root"
},
src: {
description: "",
type: "string",
default: ""
},
errorSrc: {
description: "",
type: "string",
default: ""
},
alt: {
description: "",
type: "string",
default: ""
},
title: {
description: "",
type: "string",
default: ""
},
visible: {
description: "",
type: "boolean",
default: !0
},
width: {
description: "",
type: "Number"
},
height: {
description: "",
type: "Number"
}
}, bt = [
"id",
"type"
], vt = [
"id",
"appearance",
"binding",
"visible"
], yt = {
$schema: ut,
$id: pt,
title: mt,
description: ft,
type: gt,
properties: ht,
required: bt,
ignore: vt
}, D = {
// 绑定特殊字段,辅助构造src,指定服务器端图像Id
/**
* 指定服务器端图像Id
* @default ''
*/
modelValue: { type: String, default: "" },
// 指定直接路径
/**
* @default ''
*/
src: { type: String, default: "" },
errorSrc: { type: String, default: "" },
/**
* @default ''
*/
alt: { type: String, default: "" },
title: { type: String, default: "" },
// 指定自定义样式
customClass: { type: Object, default: "" },
id: { type: String, default: "" },
/**
*/
width: { type: Number },
/**
*/
height: { type: Number },
// 是否只读
readonly: { type: Boolean, default: !1 },
visible: { type: Boolean, default: !0 }
}, he = at(D, yt, ct, dt), Ct = Object.assign({}, D, {
componentId: { type: String, default: "" }
}), W = /* @__PURE__ */ re({
name: "FImage",
props: D,
emits: ["change", "update:modelValue", "click"],
setup(i, t) {
const e = L(i.modelValue), n = U(() => oe({
"f-imgcontainer-in-form": !0
}, i.customClass)), r = U(() => {
const s = {};
return i.width && i.width > 0 && (s.width = i.width + "px"), i.height && i.height > 0 && (s.height = i.height + "px"), s;
}), o = L(i.alt ? i.alt : void 0), l = L(i.title ? i.title : void 0), g = i.errorSrc ? G(i.errorSrc) : "data:image/png;base64,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", c = L(G(i.modelValue || i.src));
function u() {
i.title && (l.value = i.title);
}
K(() => i.src, (s) => {
u(), c.value = G(s);
}), K(() => i.modelValue, (s) => {
u(), e.value = s, c.value = G(s) || G(i.src) || g;
});
function m() {
c.value === g && (l.value = void 0), c.value = g;
}
return () => i.visible ? V("div", {
class: n.value
}, [V("img", {
alt: o.value,
title: l.value,
style: r.value,
src: c.value,
onError: m
}, null)]) : null;
}
});
function At(i) {
const { formSchemaUtils: t, formStateMachineUtils: e } = i;
function n(c, u = "") {
return {
path: u + c.code,
field: c.id,
fullPath: c.code
};
}
function r(c, u = "") {
const m = t.getViewModelById(c);
return m ? m.states.map((s) => n(s, u)) : [];
}
function o(c) {
const u = t.getRootViewModelId(), m = r(c);
if (c === u)
return m;
const s = r(u, "root-component.");
return [...m, ...s];
}
function l(c) {
return c.binding && c.binding.path || c.id || "";
}
function g() {
return e && e.getRenderStates() || [];
}
return { getVariables: o, getControlName: l, getStateMachines: g };
}
class Et {
constructor(t) {
y(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'"
}
]);
y(this, "expressionNames", {
compute: "计算表达式",
dependency: "依赖表达式",
validate: "验证表达式",
dataPicking: "帮助前表达式",
visible: "可见表达式",
readonly: "只读表达式",
required: "必填表达式"
});
y(this, "getExpressionConverter", (t, e) => ({
convertFrom: (n, r, o, l) => {
const g = o.getExpressionRuleValue(t, e || r);
return g && g.value || "";
},
convertTo: (n, r, o, l, g) => {
var c;
if (r === "dataPicking" && (o != null && o.target)) {
const u = `${o.target}_dataPicking`;
((c = o.rules) == null ? void 0 : c.some(
(s) => s.id === u && s.value
)) ? n.dictPickingExpressionId = u : delete n.dictPickingExpressionId;
}
l.updateExpression(o);
}
}));
this.formSchemaService = t;
}
getExpressionRule(t, e) {
const n = this.getExpressionData();
if (!n)
return "";
const r = n.find((l) => l.target === t);
if (!r)
return "";
const o = r.rules.find((l) => l.type === e);
return o || "";
}
// 获取上下文表单变量
getContextFormVariables() {
const { module: t } = this.formSchemaService.getFormSchema();
if (!t.viewmodels || t.viewmodels.length === 0)
return [];
const e = this.formSchemaService.getRootViewModelId(), n = this.formSchemaService.getViewModelById(e);
if (!n || !n.states || n.states.length === 0)
return [];
const r = [];
return n.states.filter((o) => o.category === "remote").forEach((o) => {
r.push({
key: o.code,
name: o.name,
description: o.name,
category: o.category
});
}), r;
}
createTreeNode(t, e, n = "label") {
return {
id: t.id,
name: t.name,
bindingPath: t[n],
parents: e,
type: "field"
};
}
buildEntityFieldsTreeData(t = null, e) {
const n = [];
return t == null || t.forEach((r) => {
var g;
const o = this.createTreeNode(r, e);
let l = [];
(g = r.type) != null && g.fields && (l = this.buildEntityFieldsTreeData(r.type.fields, [...e, r.label])), n.push({
data: o,
children: l,
expanded: !0
});
}), n;
}
buildChildEntityTreeData(t = null, e) {
const n = [];
return t == null || t.forEach((r) => {
var c, u;
const o = this.createTreeNode(r, e);
o.type = "entity";
const l = this.buildEntityFieldsTreeData((c = r.type) == null ? void 0 : c.fields, [...e, r.label]), g = this.buildChildEntityTreeData((u = r.type) == null ? void 0 : u.entities, [...e, r.label]);
g != null && g.length && (l == null || l.push(...g)), n.push({
data: o,
children: l || [],
// 空值回退
expanded: !0
});
}), n;
}
getEntitiesTreeData() {
const t = this.formSchemaService.getSchemaEntities();
if (!(t != null && t.length))
return [];
const e = t[0];
if (!(e != null && e.type))
return [];
const n = this.buildEntityFieldsTreeData(e.type.fields, [e.code]), r = this.buildChildEntityTreeData(e.type.entities, [e.code]);
return r != null && r.length && (n == null || n.push(...r)), {
entityCode: e.code,
fields: [{
data: this.createTreeNode(e, [], "code"),
children: n || []
}]
};
}
getEntitiesAndVariables() {
return {
entities: this.getEntitiesTreeData(),
variables: {
session: {
name: "系统变量",
items: this.sessionVariables,
visible: !1
},
forms: {
name: "表单变量",
items: this.getContextFormVariables(),
visible: !0
}
}
};
}
onBeforeOpenExpression(t, e, n) {
const r = n === "Field" ? t.binding.field : t.id, o = this.getExpressionRule(r, e), l = this.getEntitiesAndVariables(), g = {
message: ["validate", "required", "dataPicking"].includes(e) && o ? o.message : "",
...l
};
return o.messageType != null && (g.messageType = o.messageType), g;
}
buildRule(t, e, n, r) {
const { expression: o, message: l, messageType: g } = e, c = {
id: `${t}_${n}`,
type: n,
value: o
};
return (n === "validate" || n === "dataPicking" || n === "required") && (c.message = l), n === "dataPicking" && (c.messageType = g), n === "validate" && r && (c.elementId = r), c;
}
getExpressionData() {
const { expressions: t } = this.formSchemaService.getFormSchema().module;
return t || [];
}
updateExpression(t, e, n, r) {
const o = e === "Field" ? t.binding.field : t.id, l = this.buildRule(o, n, r, t.type === "form-group" ? t.id : "");
let c = this.getExpressionData().find((m) => m.targetType === e && m.target === o);
const u = (m) => m.value.trim() === "";
if (c) {
const m = c.rules.find((s) => s.id === l.id);
if (m)
u(l) ? c.rules = c.rules.filter((s) => s.id !== l.id) : (Object.assign(m, l), r === "validate" && t.type === "form-group" && (m.elementId = t.id));
else {
if (u(l))
return null;
c.rules = c.rules || [], c.rules.push(l);
}
} else {
if (u(l))
return null;
c = {
target: `${o}`,
rules: [l],
targetType: e
};
}
return c;
}
getExpressionEditorOptions(t, e, n, r) {
return n.reduce((o, l) => {
var c, u;
const g = e === "Field" ? (c = t == null ? void 0 : t.binding) == null ? void 0 : c.field : t.id;
return o[l] = {
hide: e === "Field" ? !!((u = t == null ? void 0 : t.binding) != null && u.field) : !1,
description: "",
title: this.expressionNames[l],
type: "string",
$converter: this.getExpressionConverter(g),
refreshPanelAfterChanged: !0,
editor: {
type: "expression-editor",
singleExpand: !1,
dialogTitle: `${this.expressionNames[l]}编辑器`,
showMessage: l === "validate" || l === "dataPicking" || l === "required",
showMessageType: l === "dataPicking",
beforeOpen: () => this.onBeforeOpenExpression(t, l, e),
onSubmitModal: (m) => {
const s = this.updateExpression(t, e, m, l);
if (r) {
const p = this.buildRule(g, m, l);
r(p);
}
return s;
}
}
}, o;
}, {});
}
getExpressionInfo(t, e, n) {
const r = e === "Field" ? t.binding.field : t.id, o = this.getExpressionRule(r, n), l = {
value: o && o.value,
targetId: r,
targetType: e,
expressionType: n
};
return o && o.message && (l.message = o.message), l;
}
getExpressionConfig(t, e, n = ["compute", "dependency", "validate"], r) {
var o;
return {
description: "表达式",
title: "表达式",
hide: !(t.binding && ((o = t.binding) == null ? void 0 : o.type) === "Form"),
properties: {
...this.getExpressionEditorOptions(t, e, n, r)
}
};
}
getExpressionOptions(t, e, n) {
const r = this.getExpressionInfo(t, e, n);
return {
dialogTitle: `${this.expressionNames[n] || "表达式"}编辑器`,
singleExpand: !1,
showMessage: n === "required",
beforeOpen: () => this.onBeforeOpenExpression(t, n, e),
expressionInfo: r
};
}
}
class Ft {
constructor(t, e) {
y(this, "componentId");
y(this, "viewModelId");
y(this, "eventsEditorUtils");
y(this, "formSchemaUtils");
y(this, "formMetadataConverter");
y(this, "designViewModelUtils");
y(this, "designViewModelField");
y(this, "controlCreatorUtils");
y(this, "designerHostService");
y(this, "designerContext");
y(this, "modalService", null);
/** 表单规则 */
y(this, "formRule", null);
y(this, "schemaService", null);
y(this, "metadataService", null);
y(this, "propertyConfig", {
type: "object",
categories: {}
});
y(this, "expressionProperty");
var n;
this.componentId = t, this.designerHostService = e, this.eventsEditorUtils = e.eventsEditorUtils, this.formSchemaUtils = e.formSchemaUtils, this.formMetadataConverter = e.formMetadataConverter, this.viewModelId = ((n = this.formSchemaUtils) == null ? void 0 : n.getViewModelIdByComponentId(t)) || "", this.designViewModelUtils = e.designViewModelUtils, this.controlCreatorUtils = e.controlCreatorUtils, this.metadataService = e.metadataService, this.schemaService = e.schemaService, this.designerContext = e.designerContext, this.modalService = e.modalService, this.expressionProperty = new Et(this.formSchemaUtils);
}
/**
* 是否在响应式表单中
*/
inResponsiveForm() {
var t;
return !!((t = this.designerContext) != null && t.responsiveForm);
}
getFormDesignerInstance() {
var t, e;
return (e = (t = this.designerContext) == null ? void 0 : t.instances) == null ? void 0 : e.formDesigner.value;
}
getTableInfo() {
var t;
return (t = this.schemaService) == null ? void 0 : t.getTableInfoByViewModelId(this.viewModelId);
}
setDesignViewModelField(t) {
var n;
const e = t.binding && t.binding.type === "Form" && t.binding.field;
if (e) {
if (!this.designViewModelField) {
const r = this.designViewModelUtils.getDgViewModel(this.viewModelId);
this.designViewModelField = r.fields.find((o) => o.id === e);
}
t.updateOn = (n = this.designViewModelField) == null ? void 0 : n.updateOn;
}
}
getBasicPropConfig(t) {
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: t.type, name: f[t.type] && f[t.type].name }]
}
}
}
};
}
getAppearanceConfig(t = null, e = {}, n) {
const r = {
title: "外观",
description: "Appearance"
}, o = {
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 l in e)
o[l] = Object.assign(o[l] || {}, e[l]);
return {
...r,
properties: { ...o },
setPropertyRelates(l, g) {
if (l) {
switch (l && l.propertyID) {
case "class":
case "style": {
q.value++;
break;
}
}
n && n(l, t, g);
}
}
};
}
/**
*
* @param propertyData
* @param propertyTypes
* @param propertyName
* @param constInfos
* @param variableInfos
* @param expressionType 指定表达式类型,存在属性和表达式类型不一致的情况
* @returns
*/
getPropertyEditorParams(t, e = [], n = "visible", r = {}, o = {}, l = "") {
const { getVariables: g, getControlName: c, getStateMachines: u } = At(this.designerHostService), m = this.getRealTargetType(t), s = e && e.length > 0 ? e : ["Const", "Variable", "StateMachine", "Expression"], p = {
type: "property-editor",
propertyTypes: s
};
return s.map((b) => {
switch (b) {
case "Const":
Object.assign(p, {
constType: "enum",
constEnums: [{ id: !0, name: "是" }, { id: !1, name: "否" }]
}, r);
break;
case "Expression":
p.expressionConfig = this.getExpressionOptions(t, m, l || n);
break;
case "StateMachine":
p.stateMachines = u();
break;
case "Variable":
Object.assign(p, {
controlName: c(t),
newVariablePrefix: "is",
newVariableType: "Boolean",
variables: g(this.viewModelId),
parentComponentId: this.componentId === "root-component" ? "" : "root-component",
onBeforeOpenVariables: (d) => {
d.value = g(this.viewModelId);
}
}, o), this.designerContext.designerMode === "PC_RTC" && (p.newVariablePrefix = "ext_" + p.newVariablePrefix);
break;
}
}), p;
}
getVisibleProperty(t, e = "") {
var o;
let n = ["Const", "Variable", "StateMachine", "Expression"];
return e === "gridFieldEditor" ? n = ["Const", "Expression"] : e === "form-group" && !((o = t.binding) != null && o.field) ? n = ["Const", "Variable", "StateMachine", "Custom"] : e === "dataGrid" || e === "treeGrid" || e === "wizard" ? n = ["Const", "Variable", "Expression"] : (t.type.indexOf("toolbar-item") > -1 || e === "form-group") && (n = ["Const", "Variable", "StateMachine", "Custom", "Expression"]), {
visible: {
title: "是否可见",
type: "boolean",
description: "运行时组件是否可见",
editor: this.getPropertyEditorParams(t, n, "visible")
}
};
}
/**
* 获取行为
* @param propertyData
* @param viewModelId
* @returns
*/
getBehaviorConfig(t, e = "", n = {}, r) {
const o = {
title: "行为",
description: ""
}, l = this.getVisibleProperty(t, e);
for (const c in n)
l[c] = Object.assign(l[c] || {}, n[c]);
const g = this;
return {
...o,
properties: { ...l },
setPropertyRelates(c, u) {
if (c) {
switch (c.propertyID) {
case "disabled":
case "readonly":
case "visible":
g.afterMutilEditorChanged(t, c);
break;
}
r && r(c, u);
}
}
};
}
/**
* 当多值编辑器变更时
* @param propertyData
* @param changeObject
*/
afterMutilEditorChanged(t, e) {
this.addNewVariableToViewModel(e, this.viewModelId), this.updateExpressionValue(e, t), this.clearExpression(e, t);
}
/**
*
* @param propertyId
* @param componentInstance
* @returns
*/
updateElementByParentContainer(t, e) {
const n = e && e.parent && e.parent.schema;
if (!n)
return;
const r = n.contents.findIndex((l) => l.id === t), o = X(n.contents[r]);
n.contents.splice(r, 1), n.contents.splice(r, 0, o), ke();
}
/**
* 属性编辑器,在编辑过程中会新增变量,此处需要将新增的变量追加到ViewModel中
* @param changeObject
* @param viewModelId
* @returns
*/
addNewVariableToViewModel(t, e) {
const n = t.propertyValue;
if (!(n && typeof n == "object") || !(n.type === "Variable" && n.isNewVariable))
return;
const l = {
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(l.code) || this.formSchemaUtils.getViewModelById("root-viewmodel").states.push(l);
}
getExpressions() {
let t = [];
return this.formRule ? (this.formRule.expressions = this.formRule.expressions || [], t = this.formRule.expressions || []) : t = this.formSchemaUtils.getExpressions(), t;
}
/**
* 更新表达式到expressions节点
* @param changeObject
*/
updateExpressionValue(t, e) {
const n = t.propertyValue;
if (!((n && n.type) === "Expression" && n.expressionInfo))
return;
const { expressionId: l, expressionInfo: g } = n, { targetId: c, targetType: u, expressionType: m, value: s, message: p } = g, b = this.getExpressions();
let d = b.find((h) => h.target === c);
d || (d = { target: c, rules: [], targetType: u }, b.push(d));
const a = d.rules.find((h) => h.type === m);
if (a)
a.id = l, a.value = s, a.message = p, (m === "minDate" || m === "maxDate" || m === "defaultTime") && (a.elementId = e.id);
else {
const h = { id: l, type: m, value: s, message: p, elementId: e.id };
d.rules.push(h);
}
delete n.expressionInfo;
}
/**
* 属性类型切换为非表达式后,清除原表达式
* @param changeObject
* @param propertyData
* @returns
*/
clearExpression(t, e) {
const n = t.propertyValue;
if (n && n.type === "Expression")
return;
const o = t.propertyID, l = this.getExpressions(), g = e.