UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,652 lines (1,651 loc) 153 kB
var Et = Object.defineProperty; var Vt = (e, a, t) => a in e ? Et(e, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[a] = t; var ie = (e, a, t) => Vt(e, typeof a != "symbol" ? a + "" : a, t); import { defineComponent as ve, ref as O, inject as J, computed as H, onMounted as Se, createVNode as L, watch as q, reactive as ge, toRaw as Mt, nextTick as We, withDirectives as Ge, vModelCheckbox as it, onUnmounted as Ue, isVNode as Nt, Fragment as Dt, resolveDirective as Ot, provide as me, mergeProps as ot } from "vue"; import Bt from "../../designer/button-edit/index.esm.js"; import { useDesignerComponent as Rt, DgControl as et, canvasChanged as At, refreshCanvas as Ut } from "../designer-canvas/index.esm.js"; import { resolveAppearance as zt, createPropsResolver as _t, getPropsResolverGenerator as $t } from "../dynamic-resolver/index.esm.js"; import { InputBaseProperty as jt, ExpressionProperty as qt } from "../property-panel/index.esm.js"; import { FieldSelectorRepositoryToken as Me } from "../field-selector/index.esm.js"; import { isNil as Wt, isNaN as Gt, flatten as Ht, cloneDeep as ke, throttle as Jt, get as Ce, debounce as lt, isEmpty as Qt } from "lodash-es"; import { FNotifyService as Xt, F_NOTIFY_SERVICE_TOKEN as He } from "../notify/index.esm.js"; import { F_MODAL_SERVICE_TOKEN as Yt } from "../modal/index.esm.js"; import { FButtonEdit as st } from "../button-edit/index.esm.js"; import { FLayout as Zt, FLayoutPane as tt } from "../layout/index.esm.js"; import { FDataGrid as ze } from "../data-grid/index.esm.js"; import { resolveField as Ne, encrypt as Kt, isMobilePhone as Be } from "../common/index.esm.js"; import { LocaleService as en } from "../locale/index.esm.js"; import { FTreeGrid as Je } from "../tree-grid/index.esm.js"; import { FComboList as rt } from "../combo-list/index.esm.js"; import tn from "../popover/index.esm.js"; function nt(e) { return typeof e == "string" && e.startsWith("{") && e.endsWith("}") ? (e = e.replace(/'/g, '"'), { mappingFields: JSON.parse(e) }) : { mappingFields: e }; } const ut = /* @__PURE__ */ new Map([ ["appearance", zt], ["mappingFields", (e, a, t) => { if (a) return nt(a); const { mappingFields: n } = t; return nt(n); }], ["uri", (e, a, t) => { var n; return a ? { uri: a } : { uri: (n = t == null ? void 0 : t.dataSource) == null ? void 0 : n.uri }; }], ["idField", (e, a, t) => { var n; return a ? { idField: a } : { idField: (n = t == null ? void 0 : t.dataSource) == null ? void 0 : n.idField }; }] ]), nn = "https://json-schema.org/draft/2020-12/schema", an = "https://farris-design.gitee.io/lookup.schema.json", on = "lookup", ln = "A Farris Input Component", sn = "object", rn = { id: { description: "The unique identifier for a combo list", type: "string" }, type: { description: "The type string of number combo list component", type: "string", default: "lookup" }, appearance: { description: "", type: "object", properties: { class: { type: "string" }, style: { type: "string" } }, default: {} }, binding: { description: "", type: "object", default: {} }, editable: { description: "", type: "boolean", default: !1 }, enableLinkLabel: { description: "", type: "boolean", default: !1 }, label: { description: "", type: "string", default: "帮助" }, lableWidth: { description: "", type: "number" }, placeholder: { description: "", type: "string", default: "请选择" }, readonly: { description: "", type: "boolean", default: !1 }, required: { description: "", type: "boolean", default: !1 }, tabindex: { description: "", type: "number", default: -1 }, textAlign: { description: "", type: "string", enum: [ "left", "middle", "right" ], default: "left" }, visible: { description: "", type: "boolean", default: !0 }, textField: { description: "帮助显示文本字段", type: "string", default: "" }, mappingFields: { description: "帮助字段映射", type: "object", default: {} }, uri: { type: "string", default: "" }, dataSource: { type: "object", default: null }, displayType: { type: "string", default: "list" }, "onUpdate:dataMapping": { type: "object", default: null }, onClear: { type: "object", default: null }, context: { type: "object", default: null }, enableToSelect: { type: "boolean", default: !0 }, idValue: { type: "string", default: "" }, multiSelect: { type: "boolean", default: !1 }, separator: { type: "string", default: "," }, fitColumns: { type: "boolean", default: !0 }, enableFavorite: { type: "boolean", default: !1 }, enableUserData: { type: "boolean", default: !1 }, showSelections: { type: "boolean", default: !0 }, treeToList: { type: "boolean", default: !1 }, navTreeToList: { type: "boolean", default: !1 }, showNavigation: { type: "boolean", default: !0 }, dictPicking: { type: "object", default: null }, dictPicked: { type: "object", default: null }, enableSearchBar: { type: "boolean", default: !0 }, searchAnyField: { type: "boolean", default: !0 }, dialog: { type: "object", default: null }, idField: { type: "string", default: "id" }, pagination: { type: "object", default: null }, allowFreeInput: { type: "boolean", default: !1 }, loadTreeDataType: { type: "string", default: "default" }, onlySelectLeaf: { type: "boolean", default: !1 }, enableFullTree: { type: "boolean", default: !0 }, beforeLoadData: { type: "object", default: null }, beforeSelectData: { type: "object", default: null }, enableCascade: { type: "boolean", default: !1 }, showCascadeControl: { type: "boolean", default: !0 }, cascadeItems: { type: "object", default: { both: !0, up: !0, down: !0, disable: !0 } }, cascadeValue: { type: "string", default: "both" }, expandLevel: { type: "number", default: 0 }, enableClear: { type: "boolean", default: !0 }, openType: { type: "string", default: "Modal" }, enableTitle: { type: "boolean", default: !1 }, showIncludeChildNodes: { type: "boolean", default: !0 }, includeChildNodesValue: { type: "boolean", default: !0 }, enableEqualSearch: { type: "boolean", default: !1 }, onClearMapping: { type: "string", default: "" }, userDataKey: { type: "string", default: "" } }, un = [ "type" ], dn = [ "appearance", "binding", "visible" ], cn = { dictPicking: "帮助前事件", dictPicked: "帮助后事件", beforeSelectData: "数据选择确认前事件", beforeLoadData: "数据加载前事件", clear: "清空事件" }, dt = { $schema: nn, $id: an, title: on, description: ln, type: sn, properties: rn, required: un, ignore: dn, events: cn }; function ct(e, a, t) { return a; } var ft = /* @__PURE__ */ ((e) => (e.Both = "both", e.Up = "up", e.Down = "down", e.Disable = "disable", e))(ft || {}); const qe = [ { value: "both", text: "同步选择" }, { value: "up", text: "包含上级" }, { value: "down", text: "包含下级" }, { value: "disable", text: "仅选择自身" } ], pt = ""; var pe = /* @__PURE__ */ ((e) => (e.List = "LIST", e.Tree = "TREELIST", e.ListList = "NAVLIST", e.TreeList = "NAVTREELIST", e.ListTree = "NAVLISTTREE", e))(pe || {}), ye = /* @__PURE__ */ ((e) => (e.default = "default", e.all = "all", e.async = "async", e))(ye || {}); const Le = "__lookup_active_tab__", Ta = "__lookup_user_data_id__"; var de = /* @__PURE__ */ ((e) => (e.dataList = "datalist", e.favorite = "favorite", e))(de || {}); const ht = { showPageInfo: !0, enable: !1, showLimits: !0, sizeLimits: [10, 20, 30, 50, 100], size: 20, index: 1, total: 0, mode: "server", showGoto: !1 }, fn = Symbol("f_lookup-http-service_token"); var De = /* @__PURE__ */ ((e) => (e[e.Equal = 0] = "Equal", e[e.NotEqual = 1] = "NotEqual", e[e.Greater = 2] = "Greater", e[e.GreaterOrEqual = 3] = "GreaterOrEqual", e[e.Less = 4] = "Less", e[e.LessOrEqual = 5] = "LessOrEqual", e[e.Like = 6] = "Like", e[e.LikeStartWith = 7] = "LikeStartWith", e[e.LikeEndWith = 8] = "LikeEndWith", e[e.NotLike = 9] = "NotLike", e[e.NotLikeStartWith = 10] = "NotLikeStartWith", e[e.NotLikeEndWith = 11] = "NotLikeEndWith", e[e.Is = 12] = "Is", e[e.IsNot = 13] = "IsNot", e[e.In = 14] = "In", e[e.NotIn = 15] = "NotIn", e))(De || {}), Oe = /* @__PURE__ */ ((e) => (e[e.Empty = 0] = "Empty", e[e.And = 1] = "And", e[e.Or = 2] = "Or", e))(Oe || {}), pn = /* @__PURE__ */ ((e) => (e[e.Value = 0] = "Value", e[e.Expression = 1] = "Expression", e.FrontExpress = "frontExpress", e))(pn || {}); const hn = { showCloseButton: !0, showMaxButton: !0, draggable: !0, resizeable: !0, enableEsc: !0, rememberSize: !0 }; function gn() { function e(a, t, n) { const i = {}; return i.dictPicking = (o) => t.call("dictPicking", a, [o, a], n), i.beforeLoadData = (o) => t.call("beforeLoadData", a, [o, a], n), i.beforeSelectData = (o) => t.call("beforeSelectData", a, [o, a], n), i.dictPicked = (o) => t.call("dictPicked", a, [o, a], n), i; } return { resolve: e }; } const Ee = { id: { type: String, require: !0 }, uri: { type: String, default: "" }, readonly: { type: Boolean, default: !1 }, disabled: { type: Boolean, default: !1 }, editable: { type: Boolean, default: !1 }, enableFavorite: { type: Boolean, default: !1 }, mappingFields: { type: Object, default: null }, fitColumns: { type: Boolean, default: !0 }, columns: { type: Array, default: [] }, idField: { type: String, default: "id" }, textField: { type: String, defalut: "name" }, data: { type: Array, default: [] }, displayType: { type: String, default: pe.List }, dialog: { type: Object, default: { title: "" } }, multiSelect: { type: Boolean, default: !1 }, showSelections: { type: Boolean, default: !0 }, separator: { type: String, default: "," }, pagination: { type: Object, default: ht }, enableClear: { type: Boolean, default: !0 }, inputType: { type: String, default: "text" }, idValue: { type: String, default: "" }, dictPicking: { type: Function, default: null }, dictPicked: { type: Function, default: null }, beforeSelectData: { type: Function, default: null }, beforeLoadData: { type: Function, default: null }, enableSearchBar: { type: Boolean, default: !0 }, searchFields: { type: Array, default: [] }, searchAnyField: { type: Boolean, default: !0 }, navigation: { type: Object, default: null }, textChangeType: { type: String, default: "any" }, showNavigation: { type: Boolean, default: !0 }, showIncludeChildNodes: { type: Boolean, default: !0 }, includeChildNodesValue: { type: Boolean, default: !0 }, enableMultiFieldSearch: { type: Boolean, default: !1 }, treeToList: { type: Boolean, default: !1 }, navTreeToList: { type: Boolean, default: !1 }, loadTreeDataType: { type: String, default: ye.default }, enableToSelect: { type: Boolean, default: !0 }, customData: { type: Object, default: null }, modelValue: { type: String, default: "" }, enableUserData: { type: Boolean, default: !1 }, userDataKey: { type: String, default: "" }, onReady: { type: Function, default: null }, context: { type: Object, default: {} }, placeholder: { type: String, default: "请选择" }, loader: { type: Function, default: null }, allowFreeInput: { type: Boolean, default: !1 }, onlySelectLeaf: { type: Boolean, default: !1 }, enableFullTree: { type: Boolean, default: !0 }, enableCascade: { type: Boolean, default: !1 }, showCascadeControl: { type: Boolean, default: !0 }, cascadeItems: { type: Object, default: { both: !0, up: !0, down: !0, disable: !0 } }, cascadeValue: { type: String, default: "both" }, /** 0: 不展开; -1: 全部展开;>0: 展开到指定级数 */ expandLevel: { type: Number, default: 0 }, openType: { type: String, default: "Modal" }, enableTitle: { type: Boolean, default: !1 }, /** 是否启用等于搜索功能 */ enableEqualSearch: { type: Boolean, default: !1 }, togglePopupOnClickInput: { type: Boolean, default: !1 } }, wa = _t(Ee, dt, ut, ct), mn = gn(), gt = $t( Ee, dt, ut, ct ); function Re(e) { let a = [10, 20, 30, 50, 100]; return e && (typeof e == "string" && (a = e.replaceAll("[", "").replaceAll("]", "").replaceAll(" ", "").split(",")), Array.isArray(e) && (a = e)), a.map((t) => ({ value: parseInt(t, 10) })).sort((t, n) => t.value - n.value); } const te = { convertFrom: (e, a) => { const t = e.editor ? e.editor : e; return a === "multiSelect" || a === "enableTitle" ? !!t[a] : a === "separator" ? t[a] || "," : a === "onlySelectLeaf" ? t[a] == null ? !1 : t[a] : a === "loadTreeDataType" ? t[a] || "default" : a === "placeholder" ? Wt(t[a]) ? "请选择" : t[a] : a === "openType" ? t[a] || "Modal" : t[a]; }, convertTo: (e, a, t) => { const n = e.editor ? e.editor : e; if (n[a] = t, a === "multiSelect" && !t && (n.enableCascade = !1), a === "openType") { if (t === "Popup") n.showSelections = !1, n.enableCascade = !1; else if (n.dialog) { const { width: i } = n.dialog, { displayType: o } = n; o && o.toUpperCase().indexOf("NAV") > -1 && (!i || i < 520) && (n.dialog.width = 960); } } n.multiSelect && n.openType === "Popup" && (n.editable = !1, n.allowFreeInput = !1); } }; function vn(e) { let a = "form_group_" + Date.now(); return e && (a = e.replace(/-/g, "_").replace(/\./g, "_")), "lookup." + a; } function bn(e, a) { const { enablePager: t, pageSize: n, pageList: i } = a; e.pagination = e.pagination || {}, Object.assign(e.pagination, { enable: t, sizeLimits: Re(i).map((o) => o.value), size: n, showLimits: !0, showGoto: !1, mode: "server" }); } const mt = { convertFrom: (e, a) => { var n; return (n = (e.editor ? e.editor : e).dataSource) == null ? void 0 : n.displayName; }, convertTo: (e, a, t) => { if (t && t.length > 0) { const n = e.editor ? e.editor : e, i = t[0], { name: o, id: s, metadataContent: r, code: l } = i; n.dataSource || (n.dataSource = {}), n.dataSource.displayName = `${o}(${l})`, n.helpId = s; const { displayType: c, idField: u, textField: f } = r; n.displayType = c, n.dataSource.idField = u, n.textField = f, n.dataSource.type = "ViewObject", n.enableEqualSearch = !1; const { pageInfo: C } = r.dataSource; bn(n, C); const { treeInfo: I } = c.toUpperCase() === "NAVTREELIST" ? r.navigation : r.dataSource; if (I) { const { onlySelectLeaf: y, loadDataType: h } = I; n.loadTreeDataType = "default", n.onlySelectLeaf = y ?? !1; } if (n.dataSource.uri || (n.dataSource.uri = vn(e.id)), n.dialog) { const { width: y } = n.dialog; c && c.toUpperCase().indexOf("NAV") > -1 && (!y || y < 520) && (n.dialog.width = 960); } } } }, yn = { convertFrom: (e, a) => { var t; return (t = e.editor.dataSource) == null ? void 0 : t.idField; }, convertTo: (e, a, t) => { if (t && t.length > 0) { const n = t[0]; e.editor.dataSource.idField = n == null ? void 0 : n.bindingPath; } } }, Cn = { convertFrom: (e, a) => { var t; return (t = e.editor) == null ? void 0 : t.textField; }, convertTo: (e, a, t) => { if (t && t.length > 0) { const n = t[0]; e.editor.textField = n == null ? void 0 : n.bindingPath; } } }, Sn = { convertFrom: (e, a) => e.editor.displayType ? e.editor.displayType.toUpperCase() : "LIST", convertTo: (e, a, t) => { e.editor.displayType = t; } }, he = { convertFrom: (e, a) => { var o; let t = e.editor ? e.editor.dialog : e.dialog; const n = e.editor ? e.editor.openType : e.openType; if (t || (t = {}), a === "title") return t[a] || pt; if (!n || n === "Modal") { if (a === "width") return (o = t.displayType) != null && o.toUpperCase().startsWith("NAV") ? t[a] || 960 : t[a] || 590; if (a === "height") return t[a] || 620; if (a === "navigatorWidth") return t[a] || 320; } else { if (a === "width") return t[a] || 460; if (a === "height") return t[a] || 380; } if (a === "draggable") return !0; if (["showMaxButton", "showCloseButton", "resizeable", "enableEsc", "rememberSize"].includes(a)) return t[a] == null ? !0 : t[a]; }, convertTo: (e, a, t) => { const n = e.editor ? e.editor : e; n.dialog = n.dialog || {}, n.dialog[a] = t; } }, Tn = { convertFrom: (e, a) => { const t = e.editor ? e.editor : e; if (t.pagination = t.pagination || {}, a === "enable" || a === "showLimits") return t.pagination[a] == null ? !1 : t.pagination[a]; if (a === "sizeLimits") { const n = t.pagination[a]; return Re(n); } if (a === "size") return t.pagination[a] || 20; }, convertTo: (e, a, t) => { var i; const n = e.editor ? e.editor || {} : e; if (n.pagination = n.pagination || {}, a === "sizeLimits") { const o = t.map((r) => r.value); n.pagination[a] = o; const s = ((i = n.pagination) == null ? void 0 : i.size) ?? 20; o.includes(s) || (n.pagination.size = o[0]); return; } n.pagination[a] = t; } }, wn = [ { label: "clear", name: "清空事件" }, { label: "dictPicking", name: "帮助前事件" }, { label: "beforeLoadData", name: "数据加载前事件" }, { label: "beforeSelectData", name: "选择数据确认前事件" }, { label: "dictPicked", name: "帮助后事件" } ], In = [ { label: "dictPicking", name: "帮助前事件" }, { label: "beforeLoadData", name: "数据加载前事件" }, { label: "beforeSelectData", name: "选择数据确认前事件" }, { label: "dictPicked", name: "帮助后事件" } ], Fn = Symbol("schema_repository_token"); function Pn(e, a) { const t = /* @__PURE__ */ new Map(); a.forEach((i) => { t.set(i.id, i.title); }); const n = (i) => { var o; if (!(!i || i.length === 0)) for (const s of i) { const r = (o = s.data) == null ? void 0 : o.id; r && t.has(r) && (s.data.name = t.get(r)), s.children && s.children.length > 0 && n(s.children); } }; n(e); } function kn(e, a) { const t = (n) => n && n.length ? n.map((i) => `${i.name}[${i.bindingPath}]`).join(",") : ""; return { dataSourceEditor: { type: "schema-selector", title: "选择数据源", editorParams: { propertyData: e, formBasicInfo: a.formSchemaUtils.getFormMetadataBasicInfo() }, viewOptions: a.formSchemaUtils.designerMode === "PC_RTC" ? [ { id: "total", title: "全部", type: "List", dataSource: "Total" } ] : [ { id: "recommend", title: "推荐", type: "List", dataSource: "Recommand", enableGroup: !0, groupField: "category", groupFormatter: (n, i) => `${n === "local" ? "本地元数据" : "最近使用"}` }, { id: "total", title: "全部", type: "List", dataSource: "Total" } ], repositoryToken: Fn }, dataSourceConverter: mt, defaultConverter: te, idFieldEditor: { type: "field-selector", textField: "bindingPath", idField: "bindingPath", disabled: !1, editorParams: { propertyData: e, formBasicInfo: a.formSchemaUtils.getFormMetadataBasicInfo() }, columns: [ { field: "name", title: "名称" }, { field: "code", title: "编号" }, { field: "bindingPath", title: "绑定字段" } ], repositoryToken: Me }, textFieldEditor: { type: "field-selector", textField: "bindingPath", idField: "bindingPath", editorParams: { propertyData: e, formBasicInfo: a.formSchemaUtils.getFormMetadataBasicInfo() }, columns: [ { field: "name", title: "名称" }, { field: "code", title: "编号" }, { field: "bindingPath", title: "绑定字段" } ], repositoryToken: Me }, mappingFieldsEditor: { type: "mapping-editor", modalWidth: 800, modalHeight: 600, editable: !1, editorParams: { propertyData: e, formBasicInfo: a.formSchemaUtils.getFormMetadataBasicInfo() }, fromData: { editable: !0, formatter: (n, i) => `${i.raw.name} [${i.raw.bindingPath}]`, idField: "bindingPath", textField: "name", valueField: "bindingPath", searchFields: ["name", "bindingPath"], repositoryToken: Me, displayFormatter: t }, toData: { editable: !1, idField: "bindingPath", textField: "name", valueField: "bindingPath", searchFields: ["name", "bindingPath"], dataSource: () => { const n = a.designViewModelUtils.getAllFields2TreeByVMId(a.viewModelId); if (a.formRule) { const o = a.formRule.fields.map((s) => ({ id: s.binding.field, title: s.label })); Pn(n, o); } const i = a.schemaService.getPrimaryField(); return i ? n.filter((o) => o.data.bindingPath !== i) : n; }, formatter: (n, i) => `${i.raw.name} [${i.raw.bindingPath}]`, displayFormatter: t } } }; } function xn(e) { var o, s; const a = { type: "combo-list", enableClear: !1, editable: !1 }, t = { type: "number-spinner", useThousands: !1 }, n = () => e.displayType ? e.displayType.toUpperCase() : "", i = () => n().startsWith("NAV") ? e.showNavigation === void 0 ? !0 : !!e.showNavigation : !1; return { openType: { description: "窗口展示方式:弹出窗口、下拉面板", title: "打开方式", type: "string", refreshPanelAfterChanged: !0, $converter: te, editor: { ...a, data: [ { text: "弹出窗口", value: "Modal" }, { text: "下拉面板", value: "Popup" } ], valueField: "value", textField: "text", idField: "value" }, visible: !0, defaultValue: "Modal" }, title: { description: "帮助标题", title: "标题", type: "string", visible: e.openType !== "Popup", $converter: he }, width: { description: "窗口宽度,单位:px,最小值:300px", title: "宽度", type: "number", editor: { ...t, min: i() ? 520 : 300, needValid: !0 }, $converter: he }, height: { description: "窗口高度,单位:px,最小值:200px", title: "高度", type: "number", editor: { ...t, min: 200, needValid: !0 }, $converter: he }, showNavigation: { description: "显示导航栏", $converter: te, refreshPanelAfterChanged: !0, title: "显示导航栏", type: "boolean", visible: n().includes("NAV") && e.openType !== "Popup" }, navigatorWidth: { description: "导航栏宽度,最小200px, 最大为窗口宽度减去200px", title: "导航栏宽度", type: "number", visible: i() && e.openType !== "Popup", editor: { ...t, min: 200, max: (((o = e == null ? void 0 : e.dialog) == null ? void 0 : o.width) ?? 960) - 200, needValid: !0 }, $converter: he }, resizeable: { description: "允许鼠标拖拽窗口边缘调整尺寸", title: "允许调整窗口尺寸", type: "boolean", visible: e.openType !== "Popup", $converter: he }, rememberSize: { description: "记录窗口尺寸", title: "记录窗口尺寸", type: "boolean", visible: !!e.enableUserData && (((s = e == null ? void 0 : e.dialog) == null ? void 0 : s.resizeable) ?? !0) && e.openType !== "Popup", $converter: he }, enableEsc: { description: "允许ESC关闭", title: "允许ESC关闭", type: "boolean", visible: e.openType !== "Popup", $converter: he }, showMaxButton: { description: "显示最大化按钮", title: "显示最大化按钮", type: "boolean", visible: e.openType !== "Popup", $converter: he }, showCloseButton: { description: "显示关闭按钮", title: "显示关闭按钮", type: "boolean", visible: e.openType !== "Popup", $converter: he } }; } function Ln(e, a = !0) { var o, s, r, l; const t = !((o = e.pagination) != null && o.enable), n = () => e.displayType ? e.displayType.toUpperCase() : "", i = (c, u) => { const f = n() !== "TREELIST" || c.treeToList; return u && f ? c.pagination && c.pagination[u] : f; }; return { hide: !i(e) || t, description: "分页配置", title: "分页", parentPropertyID: "pagination", $converter: Tn, properties: { // enable: { // description: "启用分页", // title: "启用分页", // type: "boolean", // refreshPanelAfterChanged: true, // $converter: lookupPaginationConverter // }, showLimits: { description: "显示每页条数选择器", title: "显示条数选择器", type: "boolean", refreshPanelAfterChanged: a, visible: i(e) }, sizeLimits: { description: "每页可显示条数", title: "每页显示条数", type: "array", refreshPanelAfterChanged: a, visible: i(e, "showLimits"), editor: { columns: [ { field: "value", title: "显示条数", dataType: "number", editor: { type: "number-spinner", useThousands: !1, min: 10, max: 1e4 } } ], title: "每页显示条数编辑器", modalWidth: 400, modalHeight: 500, type: "item-collection-editor", valueField: "value", nameField: "value", requiredFields: ["value"], uniqueFields: ["value"], modelValue: Re((s = e.pagination) == null ? void 0 : s.sizeLimits), beforeSubmit: ({ notifyService: c, data: u }) => !u || !u.length ? (c == null || c.warning({ message: "每页显示条数不能为空!" }), !1) : new Set(u.map((C) => parseInt(C.value, 10))).size === u.length ? !0 : (c == null || c.warning({ message: "每页显示条数不能重复!" }), !1) } }, size: { description: "默认显示条数", title: "默认显示条数", type: "number", visible: i(e), editor: { type: "combo-list", enableClear: !1, editable: !1, data: Re((r = e.pagination) == null ? void 0 : r.sizeLimits), textField: "value", idField: "value", valueField: "value", modelValue: (l = e.pagination) == null ? void 0 : l.size } } } }; } class vt extends jt { constructor() { super(...arguments); ie(this, "comboListEditor", { type: "combo-list", enableClear: !1, editable: !1 }); ie(this, "numberEditor", { type: "number-spinner", useThousands: !1 }); ie(this, "readonlyEditor", { ...this.comboListEditor, editable: !0 }); ie(this, "visibleEditor", { ...this.comboListEditor, editable: !1 }); ie(this, "requiredEditor", { ...this.comboListEditor, editable: !1 }); ie(this, "freeInputEditor", { ...this.comboListEditor, editable: !1 }); } getExpressionConfig(t, n) { const i = ["validate"]; return t.type === "form-group" && i.push("dataPicking"), this.expressionProperty.getExpressionConfig(t, "Field", i); } getPropertyConfig(t, n, i = "Card") { var d; const o = (d = t.binding) != null && d.field ? [] : ["Const", "Variable", "StateMachine"]; this.readonlyEditor = this.getPropertyEditorParams(t, o, "readonly"), this.visibleEditor = this.getPropertyEditorParams(t, o, "visible"), this.requiredEditor = this.getPropertyEditorParams(t, o, "required"), this.freeInputEditor = this.getPropertyEditorParams(t, ["Const", "Variable"], "allowFreeInput"); const s = this.getBasicProperties(t, n, i), r = this.getBehaviorConfig(t), l = this.getAppearanceProperties(t, n), c = this.getLookupConfig(t), u = this.getEventPropConfig(t), f = this.getDialogPropertyConfig(t), C = this.getPageConfig(t.editor), I = this.getTreePropConfig(t.editor), y = this.getSearchConfig(t), h = this.getExpressionConfig(t, "Field"), p = { basic: s, appearance: l, behavior: r, lookup: c, treeConfig: I, dialog: f, pager: C, searchConfig: y, expressions: h }; return t.type === "form-group" && (p.eventsEditor = u), { type: "object", categories: p }; } getGridFieldEdtiorPropConfig(t) { return this.getPropertyConfig(t, null, "Grid").categories; } flattenTreeNodes(t) { return t.reduce((n, i) => { var o; return n.push(i), (o = i.children) != null && o.length && n.push(...this.flattenTreeNodes(i.children)), n; }, []); } isSimpleStringField() { var r; const t = ((r = this.designViewModelField) == null ? void 0 : r.path) || ""; if (!t || !t.includes(".")) return !0; const n = t.split("."), i = this.designViewModelUtils.getAllFields2TreeByVMId(this.viewModelId); if (!(i != null && i.length)) return !1; const o = i.find((l) => l.data.code === n[0]); if (!o) return !1; const s = [o, ...this.flattenTreeNodes(o.children)]; return !n.reduce( (l, c, u) => [...l, u ? `${l[u - 1]}.${c}` : c], [] ).some( (l) => { var c, u, f; return ((f = (u = (c = s.find((C) => C.data.path === l)) == null ? void 0 : c.data) == null ? void 0 : u.type) == null ? void 0 : f.$type) === "EntityType"; } ); } getBehaviorConfig(t) { return { description: "Basic Infomation", title: "行为", properties: { visible: { description: "运行时组件是否可见", title: "是否可见", type: "boolean", editor: this.visibleEditor } }, setPropertyRelates: (n, i) => { this.afterMutilEditorChanged(i, n); } }; } // 绑定字段更新后,处理lookup 的相关属性 changeBindingField(t, n) { super.changeBindingField(t, n), t.editor.multiSelect = !1; } getDisplayType(t) { return t.displayType ? t.displayType.toUpperCase() : ""; } mapFieldsDisplayFormatter(t) { return t && t.length ? t.map((n) => `${n.name}[${n.bindingPath}]`).join(",") : ""; } getSearchConfig(t) { var n; return { description: "Lookup Search Infomation", title: "搜索", parentPropertyID: "editor", properties: { enableSearchBar: { $converter: te, description: "是否启用搜索栏", refreshPanelAfterChanged: !0, title: "启用搜索栏", type: "boolean", visible: !1 }, searchAnyField: { description: "显示所有列", $converter: te, title: "允许查询所有列", type: "boolean", visible: t.editor.openType !== "Popup" && t.editor.enableSearchBar == null ? !0 : !!t.editor.enableSearchBar }, enableEqualSearch: { $converter: te, description: "是否启用等于搜索", title: "启用精确搜索", type: "boolean", visible: t.editor.openType !== "Popup" && (((n = t.editor) == null ? void 0 : n.enableSearchBar) ?? !0) !== !1 && this.getDisplayType(t.editor) !== "TREELIST" } }, hide: t.editor.openType === "Popup" }; } getLookupConfig(t) { var c; const n = t.editor, i = () => { const u = this.formSchemaUtils.getFormSchema().module.entity[0].id, f = this.formSchemaUtils.getFormMetadataBasicInfo(); return { propertyData: n, formBasicInfo: f, viewModelId: u, dataSourceId: n.helpId }; }, { dataSourceEditor: o, idFieldEditor: s, textFieldEditor: r, mappingFieldsEditor: l } = kn(n, this); return { description: "Basic Infomation", title: "编辑器", setPropertyRelates: (u, f) => { if (u) switch (u.propertyID) { case "readonly": case "required": this.afterMutilEditorChanged(f, u); break; } }, parentPropertyID: "editor", properties: { readonly: { description: "", title: "只读", type: "boolean", $converter: "/converter/property-editor.converter", editor: this.readonlyEditor }, required: { description: "", title: "必填", type: "boolean", $converter: "/converter/property-editor.converter", editor: this.requiredEditor, visible: !!((c = t.binding) != null && c.field) }, placeholder: { description: "当控件没有值时在输入框中显示的文本", title: "提示文本", type: "string", $converter: te }, enableTitle: { description: "鼠标悬停显示文本内容", title: "悬停提示", type: "boolean", $converter: te, editor: this.comboListEditor }, editable: { description: "", title: "允许编辑", type: "boolean", $converter: te, refreshPanelAfterChanged: !0, editor: this.comboListEditor, visible: !(n.multiSelect && n.openType === "Popup") }, allowFreeInput: { description: "", title: "任意输入", type: "boolean", $converter: te, editor: this.freeInputEditor, visible: !!n.editable && this.isSimpleStringField() }, enableClear: { title: "启用清除按钮", type: "boolean", $converter: te }, dataSource: { description: "数据源", title: "数据源", type: "string", refreshPanelAfterChanged: !0, editor: { ...o, displayFormatter: (u) => u && u.length ? u.map((f) => `${f.name}(${f.code})`).join(",") : "", validateFunction: async (u) => this.formSchemaUtils.designerMode !== "PC_RTC" ? !0 : this.checkSameBESource(u, t), onSubmitModal: (u) => { if (u) { delete n.mappingFields; const f = this.formSchemaUtils.getFormMetadataBasicInfo(); return this.metadataService.getPickMetadata(f.relativePath, u[0].data).then((C) => JSON.parse(C == null ? void 0 : C.metadata.content)); } } }, $converter: mt }, filterConditions: { descriptions: "帮助过滤条件", title: "过滤条件", type: "string", $converter: te, editor: { type: "filter-condition-editor", editable: !1, displayText: "点击配置", enableClear: !1, enableExpression: !0, editorParams: { propertyData: n, formBasicInfo: this.formSchemaUtils.getFormMetadataBasicInfo(), viewModelId: this.formSchemaUtils.getFormSchema().module.entity[0].id }, idField: "path", repositoryToken: Me, beforeOpen: async ({ repository: u, notifyService: f }) => { var d; if (!(n == null ? void 0 : n.helpId)) return f == null || f.warning({ message: "请先配置数据源!" }), !1; const I = i(), h = new qt(this.formSchemaUtils).getEntitiesAndVariables(); let p = {}; if (u) { const v = await u.getData(I), S = await u.getLookupConditions(I); p = { fieldList: v, conditionList: S }; } return (d = h.variables) != null && d.forms && (h.variables.forms.items = h.variables.forms.items.filter((v) => v.category === "remote")), { ...p, ...h, isServerSide: !0 }; }, onSubmitModal: async ({ loadingService: u, repository: f, conditions: C, originalConditions: I, FMessageBoxService: y }) => { if (f) try { const h = i(), p = await f.getLookupConditions(h) || []; return JSON.stringify(p) !== JSON.stringify(I.value) ? (u == null || u.clearAll(), y.question("视图对象中的帮助过滤条件已更改,请点击确定同步过滤数据", "", () => { C.value = p, I.value = JSON.parse(JSON.stringify(C.value)); }, () => { }), !1) : (JSON.stringify(C.value) === JSON.stringify(I.value) || await f.saveFilterCondition(C.value, h, this.formSchemaUtils.getFormMetadataBasicInfo()), !0); } catch { return y == null || y.error("保存失败", ""), !1; } finally { u == null || u.clearAll(); } } }, visible: !!n.helpId }, displayType: { description: "类型: 树列表、列表、双列表、左树右列表", title: "展示类型", type: "string", $converter: Sn, editor: { type: "combo-list", editable: !1, disabled: !0, data: [ { text: "列表", value: "LIST" }, { text: "树列表", value: "TREELIST" }, { text: "双列表", value: "NAVLIST" }, { text: "左树右列表", value: "NAVTREELIST" } ], textField: "text", idField: "value", valueField: "value" } }, idField: { description: "数据源标识字段", title: "标识字段", type: "string", editor: { ...s }, $converter: yn }, textField: { description: "显示文本字段", title: "文本字段", type: "string", $converter: Cn, editor: r }, mappingFields: { description: "字段映射", title: "字段映射", type: "string", $converter: te, editor: { ...l } }, enableToSelect: { description: "数据加载后是否选中现有值", $converter: te, title: "选中已选值", type: "boolean", editor: this.comboListEditor }, multiSelect: { description: "启用多选", $converter: te, title: "启用多选", type: "boolean", editor: this.comboListEditor, refreshPanelAfterChanged: !0, visible: this.isSimpleStringField() }, showSelections: { description: "显示已选记录", $converter: te, title: "显示已选记录", type: "boolean", visible: !!n.multiSelect && n.openType !== "Popup" }, separator: { description: "多选分隔符", $converter: te, title: "多选分隔符", type: "string", editor: { type: "combo-list", editable: !1, disabled: !1, data: [ { text: ",", value: "," }, { text: "|", value: "|" }, { text: "#", value: "#" } ], textField: "text", idField: "value", valueField: "value", separator: "@" }, visible: !!n.multiSelect }, enableSearchBar: { description: "显示搜索工具条", $converter: te, refreshPanelAfterChanged: !0, title: "启用搜索框", type: "boolean", visible: !1 }, enableFavorite: { description: "启用收藏夹", $converter: te, title: "启用收藏夹", type: "boolean", visible: n.openType !== "Popup" }, enableUserData: { description: "保存界面状态", $converter: te, refreshPanelAfterChanged: !0, title: "保存界面状态", type: "boolean", visible: n.openType !== "Popup" } } }; } showNavigatiorWidth(t) { return this.getDisplayType(t).startsWith("NAV") && t.openType !== "Popup" ? t.showNavigation === void 0 ? !0 : !!t.showNavigation : !1; } getDialogPropertyConfig(t) { const n = xn(t.editor); return n.openType.$converter = te, { description: "帮助窗口尺寸配置", title: "帮助窗口", parentPropertyID: "dialog", $converter: he, properties: n }; } showPagerProperty(t, n) { const i = this.getDisplayType(t) !== "TREELIST" || t.treeToList; return n && i ? t.pagination && t.pagination[n] : i; } /** * 获取页配置 * @param editorOptions * @returns */ getPageConfig(t) { return Ln(t); } showLoadType(t) { const n = this.getDisplayType(t); return (n === "TREELIST" || n === "NAVTREELIST") && !t.treeToList && !t.navTreeToList; } isTree(t) { return this.getDisplayType(t) === "TREELIST" && !t.treeToList; } getTreePropConfig(t) { return { hide: this.getDisplayType(t) !== "TREELIST" && this.getDisplayType(t) !== "NAVTREELIST", description: "树形数据配置", title: "树形数据配置", parentPropertyID: "editor", properties: { treeToList: { description: "以列表的形式展示树结构数据", $converter: te, refreshPanelAfterChanged: !0, title: "以列表形式展示", type: "boolean", visible: this.getDisplayType(t) === "TREELIST" }, navTreeToList: { description: "以列表的形式展示树结构数据", $converter: te, refreshPanelAfterChanged: !0, title: "以列表形式展示", type: "boolean", visible: this.getDisplayType(t) === "NAVTREELIST" }, loadTreeDataType: { description: "树形数据加载方式", $converter: te, title: "数据加载方式", type: "string", editor: { ...this.comboListEditor, data: [ { value: "default", text: "默认" }, { value: "all", text: "全部加载" }, { value: "async", text: "分层加载" } ], textField: "text", valueField: "value" }, visible: this.showLoadType(t) }, enableFullTree: { description: "启用构造完整树", $converter: te, title: "构造完整树", type: "boolean", visible: this.showLoadType(t) }, onlySelectLeaf: { description: "仅选择叶子节点", $converter: te, title: "仅选择叶子节点", type: "boolean", visible: this.isTree(t) }, enableCascade: { description: "启用级联选择", $converter: te, refreshPanelAfterChanged: !0, title: "启用级联选择", type: "boolean", visible: this.isTree(t) && !!t.multiSelect && t.openType !== "Popup" }, showCascadeControl: { description: "是否在界面中显示级联状态", $converter: te, title: "显示级联状态", type: "boolean", visible: !!t.enableCascade && this.isTree(t) }, cascadeValue: { description: "缺省级联选择模式", $converter: te, title: "缺省级联选择模式", type: "string", visible: !!t.enableCascade && this.isTree(t), editor: { ...this.comboListEditor, data: qe, textField: "text", valueField: "value" } }, expandLevel: { description: "默认展开层级: 0: 不展开; -1: 全部展开;>0: 展开到指定级数 ", $converter: te, title: "默认展开层级", type: "number", visible: this.showLoadType(t), editor: { ...this.numberEditor, min: -1, max: 99, needValid: !0 } } } }; } getEventPropConfig(t) { const n = this; let i = [...wn]; t.editor.openType === "Popup" && (i = i.filter((r) => r.label !== "beforeSelectData")), i.push(...this.getInputCommonEvents(t)); const o = n.eventsEditorUtils.formProperties(t, n.viewModelId, i); return { title: "事件", hideTitle: !0, properties: n.createBaseEventProperty(o), // 这个属性,标记当属性变更得时候触发重新更新属性 refreshPanelAfterChanged: !0, tabId: "commands", tabName: "交互", setPropertyRelates(r, l) { const c = r.propertyValue; delete l[n.viewModelId], c && (n.eventsEditorUtils.saveRelatedParameters(l, n.viewModelId, c.events, c), n.updateLinkedLabel(c, l)); const u = n.designViewModelUtils.getDgViewModel(n.viewModelId); u && n.designViewModelField && u.changeField(n.designViewModelField.id, { valueChanging: l.fieldValueChanging, valueChanged: l.fieldValueChanged }); } }; } /** * 运行时定制:校验帮助是否绑定同一be(目前不限制通过vo创建的帮助元数据) * @param newHelpDataSource 新选的帮助 */ async checkSameBESource(t, n) { var i, o, s, r, l; if (t && ((i = n == null ? void 0 : n.editor) != null && i.helpId) && !n.isRtcControl) { if (t.data.id === n.editor.helpId) return !0; const c = await this.metadataService.getPickMetadata("", t.data).then((h) => { var p; if ((p = h == null ? void 0 : h.metadata) != null && p.content) return JSON.parse(h.metadata.content); }), u = await this.metadataService.getPickMetadata("", { id: n.editor.helpId }).then((h) => { var p; if ((p = h == null ? void 0 : h.metadata) != null && p.content) return JSON.parse(h.metadata.content); }), f = (o = c == null ? void 0 : c.dataSource) == null ? void 0 : o.sourceType, C = (s = u.dataSource) == null ? void 0 : s.sourceType, I = (r = c == null ? void 0 : c.dataSource) == null ? void 0 : r.sourceId, y = (l = u == null ? void 0 : u.dataSource) == null ? void 0 : l.sourceId; if (f === "BE" && C === "BE" && I !== y) return new Xt().error({ message: "只允许更换同数据源的帮助元数据", position: "top-center" }), !1; } return !0; } } function En(e, a) { function t(n, i) { const o = e.schema; return new vt(n, a).getPropertyConfig(o, i); } return { getPropsConfig: t }; } const Vn = /* @__PURE__ */ ve({ name: "FLookupDesign", props: Ee, emits: [], setup(e, a) { const t = O(), n = J("design-item-context"), i = J("designer-host-service"), o = En(n, i), s = Rt(t, n, o), r = '<i class="f-icon f-icon-lookup"></i>', l = '<i class="f-icon f-icon-arrow-chevron-down"></i>', c = H(() => e.openType === "Popup" ? "Popup" : "Modal"), u = H(() => c.value === "Popup" ? l : r); return Se(() => { t.value.componentInstance = s; }), a.expose(s.value), () => L("div", { class: "f-lookup-design", ref: t }, [L(Bt, { ref: t, buttonContent: u.value, readonly: !0, editable: !1, placeholder: e.placeholder }, null)]); } }); function Te(e, a) { const { lookupOptions: t } = a; function n(h) { return { ...ht, ...h }; } function i() { return { enableSelectRow: !0, multiSelect: t.multiSelect, showCheckbox: t.multiSelect, multiSelectMode: "OnCheckAndClick" }; } function o() { return { fitColumns: e.fitColumns, fitMode: "percentage", resizeColumn: !0 }; } function s() { const { displayType: h } = a.lookupOptions; return typeof h == "string" && h in pe ? !1 : h.toLowerCase().startsWith("nav"); } function r() { const { displayType: h, treeToList: p } = a.lookupOptions; return (h.toLowerCase() === pe.Tree.toLowerCase() || h.toLowerCase() === pe.ListTree.toLowerCase()) && !p; } function l() { const { displayType: h, navTreeToList: p } = a.lookupOptions; return h.toLowerCase() === pe.TreeList.toLowerCase() && !p; } function c() { const { displayType: h, navTreeToList: p } = a.lookupOptions, d = h.toLowerCase(); return d === pe.ListList.toLowerCase() || d === pe.ListTree.toLowerCase() || p; } function u() { var d; return t.dialog ? { width: ((d = t.dialog) == null ? void 0 : d.navigatorWidth) || 320, minWidth: 200 } : { width: 320, minWidth: 200 }; } function f(h) { const { loadTreeDataType: p } = t; return p === ye.all || p === "default" && (h == null ? void 0 : h.loadDataType) === "all"; } function C(h) { return (h == null ? void 0 : h.layerType) === "pathcode"; } function I() { return t.enableCascade && t.multiSelect; } function y() { return e.openType === "Popup"; } return { checkPaination: n, checkMultiSelect: i, checkColumnOptions: o, isDoubleList: s, getNavigationSize: u, isTreeList: r, navIsTreeList: l, navIsList: c, isLoadAll: f, isPathCodeTree: C, isEnableCascadeCheck: I, isDropdownMode: y }; } function bt(e, a, t) { var o; const n = O(e.searchFields || []), i = O(((o = e.navigation) == null ? void 0 : o.searchFields) || []); return q(() => a == null ? void 0 : a.searchFields, (s) => { n.value = s; }), q(() => t == null ? void 0 : t.searchFields, (s) => { i.value = s; }), { searchFieldItems: n, navSearchFieldItems: i }; } function Mn(e) { const a = ge({}), t = ge({}), n = ge({}), i = ge({}), o = ge({}), s = O([]), r = O(), l = ge({}), c = ge({ canClose: !0 }), u = O(!1), f = [ "displayType", "treeToList", "navTreeToList", "showSelections", "showNavigation", "multiSelect", "mappingFields", "loader", "idField", "textField", "userDataKey", "dialog", "expandLevel", "treeInfo", "navTreeInfo", "onlySelectLeaf", "loadTreeDataType", "uri", "enableFullTree", "cascadeValue", "showCascadeControl", "enableCascade", "enableFavorite" ]; function C() { f.forEach((I) => { l[I] = e[I]; }); } return C(), { pageInfoState: a, lookupState: t, navigationState: n, queryState: i, searchState: o, selectionState: s,