UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,476 lines 61.4 kB
var ge = Object.defineProperty; var be = (t, e, n) => e in t ? ge(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n; var P = (t, e, n) => be(t, typeof e != "symbol" ? e + "" : e, n); import { ref as O, computed as U, defineComponent as Q, provide as q, onMounted as he, nextTick as Ce, createVNode as F, createTextVNode as z, inject as H, watch as ye } from "vue"; import { FButtonEdit as xe } from "../button-edit/index.esm.js"; import { isPlainObject as Y, cloneDeep as j } from "lodash-es"; import { FPropertyPanel as we } from "../property-panel/index.esm.js"; import { FTreeView as Se } from "../tree-view/index.esm.js"; import { FMessageBoxService as X } from "../message-box/index.esm.js"; import { DgControl as J, canvasChanged as Ee, refreshCanvas as Pe } from "../designer-canvas/index.esm.js"; import { EVENT_PROPERTY_TAB_IDS as Te } from "../common/index.esm.js"; function Z(t, e) { let n; function r(l) { const { properties: p, title: C, ignore: d } = l, f = d && Array.isArray(d), c = Object.keys(p).reduce((h, x) => ((!f || !d.find((T) => T === x)) && (h[x] = p[x].type === "object" && p[x].properties ? r(p[x]) : j(p[x].default)), h), {}); if (C && (!f || !d.find((h) => h === "id"))) { const h = C.toLowerCase().replace(/-/g, "_"); c.id = `${h}_${Math.random().toString().slice(2, 6)}`; } return c; } function o(l) { const { properties: p, title: C, required: d } = l; if (d && Array.isArray(d)) { const f = d.reduce((c, h) => (c[h] = p[h].type === "object" && p[h].properties ? r(p[h]) : j(p[h].default), c), {}); if (C && d.find((c) => c === "id")) { const c = C.toLowerCase().replace(/-/g, "_"); f.id = `${c}_${Math.random().toString().slice(2, 6)}`; } return f; } return { type: C }; } function i(l, p = {}, C) { const d = t[l]; if (d) { let f = o(d); const c = e[l]; return f = c ? c({ getSchemaByType: i }, f, p, C) : f, n != null && n.appendIdentifyForNewControl && n.appendIdentifyForNewControl(f), f; } return null; } function s(l, p) { const C = r(p); return Object.keys(C).reduce((d, f) => (Object.prototype.hasOwnProperty.call(l, f) && (d[f] && Y(d[f]) && Y(l[f] || !l[f]) ? Object.assign(d[f], l[f] || {}) : d[f] = l[f]), d), C), C; } function v(l, p) { return Object.keys(l).filter((d) => l[d] != null).reduce((d, f) => { if (p.has(f)) { const c = p.get(f); if (typeof c == "string") d[c] = l[f]; else { const h = c(f, l[f], l); Object.assign(d, h); } } else d[f] = l[f]; return d; }, {}); } function a(l, p, C = /* @__PURE__ */ new Map()) { const d = s(l, p); return v(d, C); } function u(l) { var C; const p = l.type; if (p) { const d = t[p]; if (!d) return l; const f = s(l, d), c = ((C = l.editor) == null ? void 0 : C.type) || ""; if (c) { const h = t[c], x = s(l.editor, h); f.editor = x; } return f; } return l; } function m(l) { n = l; } return { getSchemaByType: i, resolveSchemaWithDefaultValue: u, resolveSchemaToProps: a, mappingSchemaToProps: v, setDesignerContext: m }; } const K = {}, ee = {}, { resolveSchemaWithDefaultValue: Fe, resolveSchemaToProps: Me, mappingSchemaToProps: Ie } = Z(K, ee); function Ve(t = {}) { function e(u, m, l, p) { if (typeof l == "number") return p[u].length === l; if (typeof l == "object") { const C = Object.keys(l)[0], d = l[C]; if (C === "not") return Number(p[u].length) !== Number(d); if (C === "moreThan") return Number(p[u].length) >= Number(d); if (C === "lessThan") return Number(p[u].length) <= Number(d); } return !1; } function n(u, m, l, p) { return p[u] && p[u].propertyValue && String(p[u].propertyValue.value) === String(l); } const r = /* @__PURE__ */ new Map([ ["length", e], ["getProperty", n] ]); Object.keys(t).reduce((u, m) => (u.set(m, t[m]), u), r); function o(u, m) { const l = u; return typeof m == "number" ? [{ target: l, operator: "length", param: null, value: Number(m) }] : typeof m == "boolean" ? [{ target: l, operator: "getProperty", param: u, value: !!m }] : typeof m == "object" ? Object.keys(m).map((p) => { if (p === "length") return { target: l, operator: "length", param: null, value: m[p] }; const C = p, d = m[p]; return { target: l, operator: "getProperty", param: C, value: d }; }) : []; } function i(u) { return Object.keys(u).reduce((l, p) => { const C = o(p, u[p]); return l.push(...C), l; }, []); } function s(u, m) { if (r.has(u.operator)) { const l = r.get(u.operator); return l && l(u.target, u.param, u.value, m) || !1; } return !1; } function v(u, m) { return i(u).reduce((C, d) => C && s(d, m), !0); } function a(u, m) { const l = Object.keys(u), p = l.includes("allOf"), C = l.includes("anyOf"), d = p || C, h = (d ? u[d ? p ? "allOf" : "anyOf" : "allOf"] : [u]).map((T) => v(T, m)); return p ? !h.includes(!1) : h.includes(!0); } return { parseValueSchema: a }; } const ke = { convertTo: (t, e, n, r) => { t.appearance || (t.appearance = {}), t.appearance[e] = n; }, convertFrom: (t, e, n) => t.appearance ? t.appearance[e] : t[e] }, Oe = { convertFrom: (t, e, n) => t.buttons && t.buttons.length ? `共 ${t.buttons.length} 项` : "无" }, Ne = { convertTo: (t, e, n, r) => { t.editor && (t.editor[e] = n); }, convertFrom: (t, e, n) => t.editor && Object.prototype.hasOwnProperty.call(t.editor, e) ? t.editor[e] : t[e] }, Re = { 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: "动态表单" } }, Be = { convertFrom: (t, e, n) => { var o; const r = t.editor && t.editor[e] ? t.editor[e] : t[e]; return ((o = Re[r]) == null ? void 0 : o.name) || r; } }, Ue = { convertTo: (t, e, n, r) => { t[e] = t[e]; }, convertFrom: (t, e, n) => t.editor ? n.getRealEditorType(t.editor.type) : "" }, je = { convertTo: (t, e, n, r) => { (t.type === "data-grid-column" || t.type === "tree-grid-column") && (t.formatter ? t.formatter[e] = n : t.formatter = { [e]: n }); }, convertFrom: (t, e, n) => { if (t.formatter) { if (e === "trueText") return t.formatter.trueText; if (e === "falseText") return t.formatter.falseText; if (e === "prefix") return t.formatter.prefix; if (e === "suffix") return t.formatter.suffix; if (e === "precision") return t.formatter.precision; if (e === "decimal") return t.formatter.decimal; if (e === "thousand") return t.formatter.thousand; if (e === "dateFormat") return t.formatter.dateFormat || "yyyy-MM-dd"; if (e === "customFormat") return t.formatter.customFormat; if (e === "type") return t.formatter.type || "none"; } return "none"; } }, $e = { convertTo: (t, e, n, r) => { t.command ? t.command[e] = n : t.command = { [e]: n }, e === "enableType" && n === "default" && (t.command.enable = !0, t.command.formatter = "", t.command.commands = [ { text: "编辑", type: "primary", command: "edit" }, { text: "删除", type: "danger", command: "remove" } ]), e === "enableType" && n === "custom" && (t.command.enable = !0, t.command.commands = [ { value: "add", text: "增加", type: "link" }, { value: "edit", text: "编辑", type: "link" }, { value: "remove", text: "删除", type: "link" } ]), e === "enableType" && n === "unable" && (t.command.enable = !1, t.command.formatter = ""); }, convertFrom: (t, e, n) => { var r, o; if (t.command) { if (e === "enableType") { if (t.command.enableType) return t.command.enableType; const i = (o = (r = t.command) == null ? void 0 : r.commands) == null ? void 0 : o.find((s) => s.command === "edit" && s.type === "primary"); return t.command.enable ? i ? "default" : "custom" : "unable"; } if (e === "commands") return t.command.enableType === "custom" ? t.command.commands : []; if (e === "formatter") return t.command.formatter; if (e === "count") return t.command.count; if (e === "columnWidth") return t.command.columnWidth || 200; } return ""; } }, ze = { convertTo: (t, e, n, r) => { if (t.column || (t.column = {}), e === "fitMode") { n && n !== "none" ? (t.column.fitColumns = !0, t.column.fitMode = n) : (t.column.fitColumns = !1, t.column.fitMode = "average"); return; } if (e === "fitColumns") { t.column.fitColumns = n, n && !t.column.fitMode && (t.column.fitMode = "average"); return; } t.column[e] = n; }, convertFrom: (t, e, n) => { if (t.column) { if (e === "fitMode") return t.column.fitColumns ? t.column.fitMode || "average" : "none"; if (e === "fitColumns") return t.column.fitColumns; } return e === "fitMode" ? "none" : ""; } }, Ae = { convertTo: (t, e, n, r) => { t.summary ? t.summary[e] = n : t.summary = { [e]: n }, e === "enable" && n && (t.summary ? t.summary.groupFields || (t.summary.groupFields = []) : t.summary = { enable: n, groupFields: [] }); }, convertFrom: (t, e, n) => { var r, o; return e === "customSummaryStyle" ? t.summary.customSummaryStyle : e === "position" ? ((r = t.summary) == null ? void 0 : r[e]) || "bottom" : e === "customRender" ? ((o = t.summary) == null ? void 0 : o[e]) || "" : t.summary && e === "enable" ? t.summary.enable : t.type === "data-grid-column" ? t.enableSummary === void 0 ? !1 : t.enableSummary : ""; } }, De = { convertTo: (t, e, n, r) => { t.group ? t.group[e] = n : t.group = { [e]: n }, e === "enable" && n && (t.group ? t.group.groupFields || (t.group.groupFields = []) : t.group = { enable: n, groupFields: [], showSummary: !1, customRender: "" }); }, convertFrom: (t, e, n) => { if (t.group) { if (e === "enable") return t.group.enable; if (e === "showSummary") return t.group.showSummary; if (e === "customRender") return t.group.customRender; if (e === "groupFields") return t.group.groupFields; } } }, _e = { convertFrom: (t, e) => t.binding ? t.binding.path : "", convertTo: (t, e, n) => { if (n && n.length > 0) { const r = n[0]; t.binding || (t.binding = {}), t.binding.type = "Form", t.binding.path = r.bindingField, t.binding.field = r.id, t.binding.fullPath = r.path, t.path = r.bindingPath; } } }, Le = { convertTo: (t, e, n, r) => { if (t.pagination || (t.pagination = {}), e === "sizeLimits") if (n == null) delete t.pagination.sizeLimits; else { const o = [...new Set( String(n).split(",").map((i) => i.trim()).filter((i) => i !== "").map((i) => parseInt(i, 10)).filter((i) => !Number.isNaN(i) && i > 0) )]; o.length > 0 ? t.pagination.sizeLimits = o : delete t.pagination.sizeLimits; } else t.pagination[e] = n; }, convertFrom: (t, e, n) => { var r; return t.pagination ? e === "sizeLimits" ? ((r = t.pagination.sizeLimits) == null ? void 0 : r.join(",")) ?? "" : t.pagination[e] : t[e]; } }, qe = { convertTo: (t, e, n, r) => { t.rowNumber || (t.rowNumber = {}), t.rowNumber[e] = n; }, convertFrom: (t, e, n) => t.rowNumber ? t.rowNumber[e] : t[e] }, We = { convertTo: (t, e, n, r) => { t.selection || (t.selection = {}), t.selection[e] = n; }, convertFrom: (t, e, n) => { if (!t.selection) return !!t[e]; const r = !!t.selection[e]; return e === "showCheckbox" && r == null && t.selection.multiSelect === !0 ? !0 : r; } }, Ge = { convertFrom: (t, e, n) => t[e] && t[e].length ? `共 ${t[e].length} 项` : "" }, He = { convertFrom: (t, e) => t[e] || "", convertTo: (t, e, n) => { t[e] = n; } }, Ye = { convertTo: (t, e, n, r) => { t.size || (t.size = {}), t.size[e] = n; }, convertFrom: (t, e, n) => t.size ? t.size[e] : t[e] }, Je = { convertFrom: (t, e, n) => { var r, o; return (r = t.formatter) != null && r.data && e === "formatterEnumData" && !t.formatterEnumData ? (o = t.formatter) == null ? void 0 : o.data : t.formatterEnumData; } }, Qe = { convertTo: (t, e, n, r) => { t.sort || (t.sort = {}), t.sort[e] = n; }, convertFrom: (t, e, n) => { var r, o; if (e === "mode") return ((r = t.sort) == null ? void 0 : r.mode) || "client"; if (e === "multiSort") return !!((o = t.sort) != null && o.multiSort); } }, Xe = { convertTo: (t, e, n, r) => { t.filter || (t.filter = {}), t.filter[e] = n, e === "enable" && (t.enableFilter = !1); }, convertFrom: (t, e, n) => { var r, o, i, s; return e === "mode" ? ((r = t.filter) == null ? void 0 : r.mode) || "server" : e === "filterStyle" ? ((o = t.filter) == null ? void 0 : o.filterStyle) || "filter-column" : e === "enable" ? ((i = t.filter) == null ? void 0 : i.enable) !== void 0 ? !!t.filter.enable : !!t.enableFilter : ((s = t.filter) == null ? void 0 : s[e]) || void 0; } }, Ze = { convertTo: (t, e, n, r) => { t.rowOption ? t.rowOption[e] = n : t.rowOption = { [e]: n }; }, convertFrom: (t, e, n) => { if (t.rowOption) { if (e === "customRowStyle") return t.rowOption.customRowStyle; if (e === "customCellStyle") return t.rowOption.customCellStyle; if (e === "height") return t.rowOption.height; } return ""; } }, Ke = { convertTo: (t, e, n, r) => { (t.type === "data-grid-column" || t.type === "tree-grid-column") && (t[e] = n, e === "columnTemplateType" && n === "hyperlink" && (t.onClickLinkCommand ? t.columnTemplate = ` <span class="f-pretend-link f-cursor-pointer" @click="(ctx)=>viewModel.current.${t.onClickLinkCommand || ""}({id: rowData.id,context: ctx})"> {{rowData.${t.field}}} </span>` : t.columnTemplate = ` <span class="f-pretend-link f-cursor-pointer"> {{rowData.${t.field}}} </span>`), e === "columnTemplateType" && n === "default" && (t.columnTemplate = ""), e === "columnTemplateType" && n === "custom" && (t.columnTemplate = "")); }, convertFrom: (t, e, n) => e === "columnTemplate" ? t.columnTemplate : e === "columnTemplateType" ? t.columnTemplateType ? t.columnTemplateType || "default" : t.columnTemplate && !t.onClickLinkCommand ? "custom" : t.columnTemplate && t.onClickLinkCommand ? "hyperlink" : "default" : "" }, et = { convertTo: (t, e, n, r) => { t.hierarchy || (t.hierarchy = { cascadeOption: {} }), t.hierarchy.cascadeOption || (t.hierarchy.cascadeOption = {}), t.hierarchy.cascadeOption[e] = n; }, convertFrom: (t, e, n) => { var r, o; return !!((o = (r = t.hierarchy) == null ? void 0 : r.cascadeOption) != null && o[e]); } }; function te(t, e, n) { const r = /* @__PURE__ */ new Map([ ["/converter/appearance.converter", ke], ["/converter/buttons.converter", Oe], ["/converter/property-editor.converter", Ne], ["/converter/items-count.converter", Ge], ["/converter/type.converter", Be], ["/converter/change-editor.converter", Ue], ["/converter/change-formatter.converter", je], ["/converter/column-command.converter", $e], ["/converter/column-option.converter", ze], ["/converter/summary.converter", Ae], ["/converter/group.converter", De], ["/converter/form-group-label.converter", He], ["/converter/field-selector.converter", _e], ["/converter/pagination.converter", Le], ["/converter/row-number.converter", qe], ["/converter/grid-selection.converter", We], ["/converter/size.converter", Ye], ["/converter/change-formatter-enum.converter", Je], ["/converter/grid-sort.converter", Qe], ["/converter/grid-filter.converter", Xe], ["/converter/row-option.converter", Ze], ["/converter/change-formatter-type.converter", Ke], ["/converter/tree-auto-check.converter", et] ]), o = /* @__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" }] ]), i = Ve(); function s(d, f) { return () => i.parseValueSchema(d, f); } function v(d, f, c) { return d.includes("visible") && f.visible !== void 0 ? typeof f.visible == "boolean" ? () => !!f.visible : f.visible === void 0 ? !0 : s(f.visible, c) : () => !0; } function a(d, f, c) { return d.includes("readonly") && f.readonly !== void 0 ? typeof f.readonly == "boolean" ? () => !!f.readonly : s(f.readonly, c) : () => !1; } function u(d, f) { const c = d.$converter || f; return typeof c == "string" && c && r.has(c) ? r.get(c) || null : c || null; } function m(d, f, c, h, x, T = "", V = "") { return Object.keys(d).map((S) => { const N = O(1), k = S, y = d[S], g = Object.keys(y), E = y.title, M = y.type, b = o.get(M) || { type: "input-group", enableClear: !1 }, w = y.editor ? Object.assign({}, b, y.editor) : Object.assign({}, b), $ = v(g, y, f), A = a(g, y, f); w.readonly = w.readonly === void 0 ? A() : w.readonly; const _ = y.type === "cascade" ? m(y.properties, f, c, h, x, T, V) : [], L = !0; let R = u(y, V); const de = U({ get() { if (N.value) { if (["class", "style"].find((D) => D === k) && !R && (R = r.get("/converter/appearance.converter") || null), R && R.convertFrom) { const D = R.convertFrom(c, S, x, T); return D === void 0 && Object.prototype.hasOwnProperty.call(y, "defaultValue") ? y.type === "boolean" ? y.defaultValue : y.defaultValue || "" : D; } const B = c[S]; return Object.prototype.hasOwnProperty.call(y, "defaultValue") && (B === void 0 || typeof B == "string" && B === "") ? y.type === "boolean" ? y.defaultValue : y.defaultValue || "" : B; } return null; }, set(B) { N.value += 1, R && R.convertTo ? (R.convertTo(h, S, B, x, T), R.convertTo(c, S, B, x, T)) : (h[S] = B, c[S] = B); } }), { refreshPanelAfterChanged: fe, description: me, isExpand: pe, parentPropertyID: ve } = y, G = { propertyID: k, propertyName: E, propertyType: M, propertyValue: de, editor: w, visible: $, readonly: A, cascadeConfig: _, hideCascadeTitle: L, refreshPanelAfterChanged: fe, description: me, isExpand: pe, parentPropertyID: ve }; return f[k] = G, G; }); } function l(d, f, c = {}) { const h = {}, x = t[d]; return x && x.categories ? Object.keys(x.categories).map((V) => { const I = x.categories[V], S = I == null ? void 0 : I.title, N = m(I.properties || {}, h, {}, c, f); return { categoryId: V, categoryName: S, properties: N }; }) : []; } function p(d, f, c, h, x = "") { const T = f.$ref.schema, V = f.$ref.converter, I = c[T], S = I.type, N = n(I), k = {}, y = t[S]; if (y && y.categories) { const g = y.categories[d], E = g == null ? void 0 : g.title; V && Object.keys(g.properties).forEach((w) => { g.properties[w].$converter = V; }); const M = (g == null ? void 0 : g.properties) || {}, b = m(M, k, N, I, h, x); return { categoryId: d, categoryName: E, properties: b }; } return { categoryId: d, categoryName: "", properties: [] }; } function C(d, f, c, h, x) { const T = d.type, V = n(d), I = {}; let S = x || t[T]; if (!(S && Object.keys(S).length > 0) && c && c.getPropConfig && (S = c.getPropConfig(h)), S && S.categories) { const k = []; return Object.keys(S.categories).map((y) => { const g = S.categories[y]; if (g.$ref) { k.push(p(y, g, d, f, h)); return; } const E = g == null ? void 0 : g.title, M = g == null ? void 0 : g.tabId, b = g == null ? void 0 : g.tabName, w = g == null ? void 0 : g.hide, $ = g == null ? void 0 : g.hideTitle, A = m(g.properties || {}, I, V, d, f, h, g.$converter), { setPropertyRelates: _ } = g, L = g == null ? void 0 : g.parentPropertyID; k.push({ categoryId: y, categoryName: E, tabId: M, tabName: b, hide: w, properties: A, hideTitle: $, setPropertyRelates: _, parentPropertyID: L }); }), k; } return []; } return { getPropertyConfigBySchema: C, getPropertyConfigByType: l, propertyConverterMap: r }; } const ne = {}, re = {}; te(ne, re, Fe); const oe = {}, ie = {}, { resolveSchemaWithDefaultValue: tt } = Z(oe, ie), se = {}, ae = {}; te(se, ae, tt); function nt(t, e, n = /* @__PURE__ */ new Map(), r = (s, v, a, u) => v, o = {}, i = (s) => s) { return K[e.title] = e, ee[e.title] = r, ne[e.title] = o, re[e.title] = i, oe[e.title] = e, ie[e.title] = r, se[e.title] = o, ae[e.title] = i, (s = {}, v = !0) => { if (!v) return Ie(s, n); const a = Me(s, e, n), u = Object.keys(t).reduce((m, l) => (m[l] = t[l].default, m), {}); return Object.assign(u, a); }; } const rt = "https://json-schema.org/draft/2020-12/schema", ot = "https://farris-design.gitee.io/collection-property-editor.schema.json", it = "collection-property-editor", st = "A Farris Component", at = "object", lt = { id: { description: "The unique identifier for collection-property-editor", type: "string" }, type: { description: "The type string of collection-property-editor", type: "string", default: "collection-property-editor" }, appearance: { description: "", type: "object", properties: { class: { type: "string" }, style: { type: "string" } }, default: {} }, modelValue: { type: "array", default: [] }, idField: { type: "string", default: "id" }, textField: { type: "string", default: "" }, defaultComponentSchema: { type: "object", default: {} }, modalTitle: { type: "string", default: "编辑器" }, visibleCondition: { type: "object", default: null }, allowCollapse: { type: "boolean", default: !0 }, enableClear: { type: "boolean", default: !1 } }, ct = [ "type" ], ut = [ "id" ], dt = { $schema: rt, $id: ot, title: it, description: st, type: at, properties: lt, required: ct, ignore: ut }, le = { modelValue: { type: Array, default: [] }, idField: { type: String, default: "id" }, textField: { type: String, default: "" }, defaultComponentSchema: { type: Object, default: {} }, isToolbarHidden: { type: Boolean, default: !1 }, useFormCommand: { type: Object, default: {} }, useFormSchema: { type: Object, default: {} }, visibleCondition: { type: Function, default: null }, allowCollapse: { type: Boolean, default: !0 }, enableClear: { type: Boolean, default: !1 }, designerHostService: { type: Object, default: null } }, ce = { ...le, modalTitle: { type: String, default: "编辑器" } }, ft = nt(ce, dt), ue = /* @__PURE__ */ Q({ name: "CollectionPropertyContainer", props: le, emits: ["valueChange", "selectionChange"], setup(t, e) { const n = O(), r = O(), { idField: o, textField: i, defaultComponentSchema: s, isToolbarHidden: v } = t, a = O(t.modelValue || []), u = O(), m = O("collection-property-editor"); q("useFormCommand", t.useFormCommand), q("useFormSchema", t.useFormSchema), q("designerHostService", t.designerHostService); const l = O(), p = U(() => !a.value || a.value.length === 0), C = [{ field: i, title: "名称", width: 340, resizable: !0, dataType: "string" }], d = U(() => a.value.filter((b) => t.visibleCondition ? t.visibleCondition(b) : !0)); function f() { const b = j(s), w = Math.random().toString().slice(2, 6); return b[o] = b[o] + "_" + w, b[i] = b[i] + "_" + w, b; } function c(b) { l.value = b, e.emit("selectionChange", { selectedData: l, propertyConfig: u, propertyPanelRef: r.value }), r.value.updatePropertyConfig(u.value, l.value, !0); } function h(b) { if (b >= a.value.length && (b = a.value.length - 1), a.value.length > 0) { const w = a.value[b]; n.value.selectItemById(w[o]), c(w); } } function x() { const b = f(); a.value.push(b), n.value.updateDataSource(d.value), n.value.selectItemById(b[o]), c(b); } function T() { const b = a.value && a.value.length > 0 ? a.value[0] : null; b && (n.value.selectItemById(b[o]), c(b)); } function V() { const b = a.value.indexOf(l.value); a.value.splice(b, 1), n.value.updateDataSource(d.value), h(b); } function I() { if (!l.value) return; const b = a.value.indexOf(l.value); b !== a.value.length - 1 && (a.value[b] = a.value[b + 1], a.value[b + 1] = l.value, n.value.updateDataSource(d.value)); } function S() { X.question("您确定要清空所有按钮吗?", "", () => { a.value = [], n.value.updateDataSource([]), e.emit("clear"); }, () => { }); } function N() { if (!l.value) return; const b = a.value.indexOf(l.value); b !== 0 && (a.value[b] = a.value[b - 1], a.value[b - 1] = l.value, n.value.updateDataSource(d.value)); } function k(b) { c(b[0]); } function y(b) { const { changeObject: w, designerItem: $ } = b; n.value.updateDataSource(d.value); } he(() => { Ce(() => { T(); }); }); const g = U(() => !l.value || p.value), E = U(() => g.value || a.value.length <= 1 ? !1 : a.value.findIndex((w) => w.id === l.value.id) > 0), M = U(() => g.value || a.value.length <= 1 ? !1 : a.value.findIndex((w) => w.id === l.value.id) < a.value.length - 1); return e.expose({ propertyPanelRef: r }), () => F("div", { class: "f-utils-fill-flex-column h-100 pt-2 pl-2 border-bottom" }, [F("div", { hidden: v, class: "border-bottom pb-2" }, [F("button", { class: "btn btn-primary mr-2", onClick: x }, [z("新增")]), F("button", { class: "btn btn-secondary mr-2", onClick: V, disabled: g.value }, [z("删除")]), F("button", { class: "btn btn-secondary mr-2", onClick: N, disabled: !E.value }, [z("上移")]), F("button", { class: "btn btn-secondary mr-2", onClick: I, disabled: !M.value }, [z("下移")]), t.enableClear && F("button", { class: "btn btn-secondary mr-2 d-flex align-items-center", style: "float:right", onClick: S, disabled: p.value }, [F("i", { class: "f-icon f-icon-close mr-1" }, null), z("清空")])]), F("div", { class: "f-utils-fill-flex-row" }, [F("div", { class: "f-utils-fill f-utils-overflow-auto" }, [F(Se, { ref: n, columns: C, data: d.value, rowOption: { disabledField: "undefined" }, fit: "true", idField: o, columnOption: { fitColumns: !0 }, onSelectionChange: k }, null)]), F("div", { hidden: p.value, style: "display: flex;" }, [F(we, { propertyConfig: u.value, ref: r, propertyName: m.value, enableSearch: !1, allowCollapse: t.allowCollapse, onPropertyChanged: y }, null)])])]); } }), W = /* @__PURE__ */ Q({ name: "FCollectionPropertyEditor", props: ce, emits: ["valueChange", "selectionChange"], setup(t, e) { const n = O(), r = H("useFormCommand"), o = H("useFormSchema"), i = O(j(t.modelValue) || []), s = O(); ye(() => t.modelValue, (c) => { i.value = j(c) || []; }); const v = U(() => { var c; return (c = s.value) == null ? void 0 : c.getModal(); }), a = U(() => { let c = 0; return i.value && (t.visibleCondition ? c = i.value.filter(t.visibleCondition).length : c = i.value.length), `共 ${c || 0} 项`; }); function u(c) { Object.keys(c).forEach((h) => { h.indexOf("__fv") > -1 && delete c[h]; }); } function m(c) { c && c.forEach((h) => { u(h); }); } function l() { return m(i.value), e.emit("valueChange", i.value), !0; } function p() { return !0; } function C({ selectedData: c, propertyConfig: h }) { u(c.value), e.emit("selectionChange", { selectedData: c, propertyConfig: h, modalRef: v.value, buttonPropertyPanelInstance: n.value.propertyPanelRef }); } function d() { i.value = []; } const f = { title: t.modalTitle || "编辑器", width: 650, height: 700, minWidth: 380, minHeight: 400, fitContent: !1, showMaxButton: !0, resizeable: !0, draggable: !0, enableEsc: !0, buttons: [{ name: "cancel", text: "取消", class: "btn btn-secondary", handle: p }, { name: "accept", text: "确定", class: "btn btn-primary", handle: l }], closedCallback: (c, h) => { if ((c == null ? void 0 : c.target.name) === "cancel" || h === "icon" || h === "esc") return i.value = j(t.modelValue), e.emit("valueChange", i.value), !0; !c && h === "button" && l(); } }; return () => F(xe, { modelValue: a.value, "onUpdate:modelValue": (c) => a.value = c, editable: !1, enableTitle: !0, inputType: "text", buttonBehavior: "Modal", modalOptions: f, ref: s }, { default: () => [F("div", { class: "h-100 d-flex flex-column" }, [F(ue, { ref: n, modelValue: i.value, "onUpdate:modelValue": (c) => i.value = c, idField: t.idField, textField: t.textField, defaultComponentSchema: t.defaultComponentSchema, onSelectionChange: C, useFormCommand: r, useFormSchema: o, allowCollapse: t.allowCollapse, visibleCondition: t.visibleCondition, enableClear: t.enableClear, onClear: d }, null)])] }); } }); function mt(t) { const { formSchemaUtils: e, formStateMachineUtils: n } = t; function r(a, u = "") { return { path: u + a.code, field: a.id, fullPath: a.code }; } function o(a, u = "") { const m = e.getViewModelById(a); return m ? m.states.map((l) => r(l, u)) : []; } function i(a) { const u = e.getRootViewModelId(), m = o(a); if (a === u) return m; const l = o(u, "root-component."); return [...m, ...l]; } function s(a) { return a.binding && a.binding.path || a.id || ""; } function v() { return n && n.getRenderStates() || []; } return { getVariables: i, getControlName: s, getStateMachines: v }; } class pt { constructor(e) { P(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'" } ]); P(this, "expressionNames", { compute: "计算表达式", dependency: "依赖表达式", validate: "验证表达式", dataPicking: "帮助前表达式", visible: "可见表达式", readonly: "只读表达式", required: "必填表达式" }); P(this, "getExpressionConverter", (e, n) => ({ convertFrom: (r, o, i, s) => { const v = i.getExpressionRuleValue(e, n || o); return v && v.value || ""; }, convertTo: (r, o, i, s, v) => { var a; if (o === "dataPicking" && (i != null && i.target)) { const u = `${i.target}_dataPicking`; ((a = i.rules) == null ? void 0 : a.some( (l) => l.id === u && l.value )) ? r.dictPickingExpressionId = u : delete r.dictPickingExpressionId; } s.updateExpression(i); } })); this.formSchemaService = e; } getExpressionRule(e, n) { const r = this.getExpressionData(); if (!r) return ""; const o = r.find((s) => s.target === e); if (!o) return ""; const i = o.rules.find((s) => s.type === n); return i || ""; } // 获取上下文表单变量 getContextFormVariables() { const { module: e } = this.formSchemaService.getFormSchema(); if (!e.viewmodels || e.viewmodels.length === 0) return []; const n = this.formSchemaService.getRootViewModelId(), r = this.formSchemaService.getViewModelById(n); if (!r || !r.states || r.states.length === 0) return []; const o = []; return r.states.filter((i) => i.category === "remote").forEach((i) => { o.push({ key: i.code, name: i.name, description: i.name, category: i.category }); }), o; } createTreeNode(e, n, r = "label") { return { id: e.id, name: e.name, bindingPath: e[r], parents: n, type: "field" }; } buildEntityFieldsTreeData(e = null, n) { const r = []; return e == null || e.forEach((o) => { var v; const i = this.createTreeNode(o, n); let s = []; (v = o.type) != null && v.fields && (s = this.buildEntityFieldsTreeData(o.type.fields, [...n, o.label])), r.push({ data: i, children: s, expanded: !0 }); }), r; } buildChildEntityTreeData(e = null, n) { const r = []; return e == null || e.forEach((o) => { var a, u; const i = this.createTreeNode(o, n); i.type = "entity"; const s = this.buildEntityFieldsTreeData((a = o.type) == null ? void 0 : a.fields, [...n, o.label]), v = this.buildChildEntityTreeData((u = o.type) == null ? void 0 : u.entities, [...n, o.label]); v != null && v.length && (s == null || s.push(...v)), r.push({ data: i, children: s || [], // 空值回退 expanded: !0 }); }), r; } getEntitiesTreeData() { const e = this.formSchemaService.getSchemaEntities(); if (!(e != null && e.length)) return []; const n = e[0]; if (!(n != null && n.type)) return []; const r = this.buildEntityFieldsTreeData(n.type.fields, [n.code]), o = this.buildChildEntityTreeData(n.type.entities, [n.code]); return o != null && o.length && (r == null || r.push(...o)), { entityCode: n.code, fields: [{ data: this.createTreeNode(n, [], "code"), children: r || [] }] }; } getEntitiesAndVariables() { return { entities: this.getEntitiesTreeData(), variables: { session: { name: "系统变量", items: this.sessionVariables, visible: !1 }, forms: { name: "表单变量", items: this.getContextFormVariables(), visible: !0 } } }; } onBeforeOpenExpression(e, n, r) { const o = r === "Field" ? e.binding.field : e.id, i = this.getExpressionRule(o, n), s = this.getEntitiesAndVariables(), v = { message: ["validate", "required", "dataPicking"].includes(n) && i ? i.message : "", ...s }; return i.messageType != null && (v.messageType = i.messageType), v; } buildRule(e, n, r, o) { const { expression: i, message: s, messageType: v } = n, a = { id: `${e}_${r}`, type: r, value: i }; return (r === "validate" || r === "dataPicking" || r === "required") && (a.message = s), r === "dataPicking" && (a.messageType = v), r === "validate" && o && (a.elementId = o), a; } getExpressionData() { const { expressions: e } = this.formSchemaService.getFormSchema().module; return e || []; } updateExpression(e, n, r, o) { const i = n === "Field" ? e.binding.field : e.id, s = this.buildRule(i, r, o, e.type === "form-group" ? e.id : ""); let a = this.getExpressionData().find((m) => m.targetType === n && m.target === i); const u = (m) => m.value.trim() === ""; if (a) { const m = a.rules.find((l) => l.id === s.id); if (m) u(s) ? a.rules = a.rules.filter((l) => l.id !== s.id) : (Object.assign(m, s), o === "validate" && e.type === "form-group" && (m.elementId = e.id)); else { if (u(s)) return null; a.rules = a.rules || [], a.rules.push(s); } } else { if (u(s)) return null; a = { target: `${i}`, rules: [s], targetType: n }; } return a; } getExpressionEditorOptions(e, n, r, o) { return r.reduce((i, s) => { var a, u; const v = n === "Field" ? (a = e == null ? void 0 : e.binding) == null ? void 0 : a.field : e.id; return i[s] = { hide: n === "Field" ? !!((u = e == null ? void 0 : e.binding) != null && u.field) : !1, description: "", title: this.expressionNames[s], type: "string", $converter: this.getExpressionConverter(v), 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, n), onSubmitModal: (m) => { const l = this.updateExpression(e, n, m, s); if (o) { const p = this.buildRule(v, m, s); o(p); } return l; } } }, i; }, {}); } getExpressionInfo(e, n, r) { const o = n === "Field" ? e.binding.field : e.id, i = this.getExpressionRule(o, r), s = { value: i && i.value, targetId: o, targetType: n, expressionType: r }; return i && i.message && (s.message = i.message), s; } getExpressionConfig(e, n, r = ["compute", "dependency", "validate"], o) { var i; return { description: "表达式", title: "表达式", hide: !(e.binding && ((i = e.binding) == null ? void 0 : i.type) === "Form"), properties: { ...this.getExpressionEditorOptions(e, n, r, o) } }; } getExpressionOptions(e, n, r) { const o = this.getExpressionInfo(e, n, r); return { dialogTitle: `${this.expressionNames[r] || "表达式"}编辑器`, singleExpand: !1, showMessage: r === "required", beforeOpen: () => this.onBeforeOpenExpression(e, r, n), expressionInfo: o }; } } class vt { constructor(e, n) { P(this, "componentId"); P(this, "viewModelId"); P(this, "eventsEditorUtils"); P(this, "formSchemaUtils"); P(this, "formMetadataConverter"); P(this, "designViewModelUtils"); P(this, "designViewModelField"); P(this, "controlCreatorUtils"); P(this, "designerHostService"); P(this, "designerContext"); P(this, "modalService", null); /** 表单规则 */ P(this, "formRule", null); P(this, "schemaService", null); P(this, "metadataService", null); P(this, "propertyConfig", { type: "object", categories: {} }); P(this, "expressionProperty"); var r; this.componentId = e, this.designerHostService = n, this.eventsEditorUtils = n.eventsEditorUtils, this.formSchemaUtils = n.formSchemaUtils, this.formMetadataConverter = n.formMetadataConverter, this.viewModelId = ((r = this.formSchemaUtils) == null ? void 0 : r.getViewModelIdByComponentId(e)) || "", this.designViewModelUtils = n.designViewModelUtils, this.controlCreatorUtils = n.controlCreatorUtils, this.metadataService = n.metadataService, this.schemaService = n.schemaService, this.designerContext = n.designerContext, this.modalService = n.modalService, this.expressionProperty = new pt(this.formSchemaUtils); } /** * 是否在响应式表单中 */ inResponsiveForm() { var e; return !!((e = this.designerContext) != null && e.responsiveForm); } getFormDesignerInstance() { var e, n; return (n = (e = this.designerContext) == null ? void 0 : e.instances) == null ? void 0 : n.formDesigner.value; } getTableInfo() { var e; return (e = this.schemaService) == null ? void 0 : e.getTableInfoByViewModelId(this.viewModelId); } setDesignViewModelField(e) { var r; const n = e.binding && e.binding.type === "Form" && e.binding.field; if (n) { if (!this.designViewModelField) { const o = this.designViewModelUtils.getDgViewModel(this.viewModelId); this.designViewModelField = o.fields.find((i) => i.id === n); } e.updateOn = (r = this.designViewModelField) == null ? void 0 : r.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: J[e.type] && J[e.type].name }] } } } }; } getAppearanceConfig(e = null, n = {}, r) { const o = { title: "外观", description: "Appearance" }, i = { 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 n) i[s] = Object.assign(i[s] || {}, n[s]); return { ...o, properties: { ...i }, setPropertyRelates(s, v) { if (s) { switch (s && s.propertyID) { case "class": case "style": { Ee.value++; break; } } r && r(s, e, v); } } }; } /** * * @param propertyData * @param propertyTypes * @param propertyName * @param constInfos * @param variableInfos * @param expressionType 指定表达式类型,存在属性和表达式类型不一致的情况 * @returns */ getPropertyEditorParams(e, n = [], r = "visible", o = {}, i = {}, s = "") { const { getVariables: v, getControlName: a, getStateMachines: u } = mt(this.designerHostService), m = this.getRealTargetType(e), l = n && n.length > 0 ? n : ["Const", "Variable", "StateMachine", "Expression"], p = { type: "property-editor", propertyTypes: l }; return l.map((C) => { switch (C) { case "Const": Object.assign(p, { constType: "enum", constEnums: [{ id: !0, name: "是" }, { id: !1, name: "否" }] }, o); break; case "Expression": p.expressionConfig = this.getExpressionOptions(e, m, s || r); break; case "StateMachine": p.stateMachines = u(); break; case "Variable": Object.assign(p, { controlName: a(e), newVariablePrefix: "is", newVariableType: "Boolean", variables: v(this.viewModelId), parentComponentId: this.componentId === "root-component" ? "" : "root-component", onBeforeOpenVariables: (d) => { d.value = v(this.viewModelId); } }, i), this.designerContext.designerMode === "PC_RTC" && (p.newVariablePrefix = "ext_" + p.newVariablePrefix); break; } }), p; } getVisibleProperty(e, n = "") { var i; let r = ["Const", "Variable", "StateMachine", "Expression"]; return n === "gridFieldEditor" ? r = ["Const", "Expression"] : n === "form-group" && !((i = e.binding) != null && i.field) ? r = ["Const", "Variable", "StateMachine", "Custom"] : n === "dataGrid" || n === "treeGrid" || n === "wizard" ? r = ["Const", "Variable", "Expression"] : (e.type.indexOf("toolbar-item") > -1 || n === "form-group") && (r = ["Const", "Variable", "StateMachine", "Custom", "Expression"]), { visible: { title: "是否可见", type: "boolean", description: "运行时组件是否可见", editor: this.getPropertyEditorParams(e, r, "visible") } }; } /** * 获取行为 * @param propertyData * @param viewModelId * @returns */ getBehaviorConfig(e, n = "", r = {}, o) { const i = { title: "行为", description: "" }, s = this.getVisibleProperty(e, n); f