UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,617 lines 125 kB
var qe = Object.defineProperty; var je = (t, i, e) => i in t ? qe(t, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[i] = e; var E = (t, i, e) => je(t, typeof i != "symbol" ? i + "" : i, e); import { ref as w, computed as W, createVNode as b, defineComponent as Q, inject as D, onMounted as ee, mergeProps as Ge, createTextVNode as j, Fragment as le, Teleport as ze, nextTick as se, provide as be, watch as ye, onUnmounted as Ce } from "vue"; import { resolveAppearance as Xe, getSchemaByType as fe, createPropsResolver as _e } from "../dynamic-resolver/index.esm.js"; import { DgControl as h, canvasChanged as ie, refreshCanvas as Qe, useDesignerComponent as Ze } from "../designer-canvas/index.esm.js"; import { useGuid as Y, getMaxZIndex as Je, getCustomClass as Ye, getCustomStyle as Fe, FormSchemaEntityField$Type as me, FormSchemaEntityFieldType$Type as He, EVENT_PROPERTY_TAB_IDS as oe } from "../common/index.esm.js"; import { useConditionValue as De, useConditionUtils as ae, FConditionFields as pe, FConditionFieldsDesign as ge } from "../condition/index.esm.js"; import { useCondition as Ke, useSolutionUtils as we } from "../query-solution/index.esm.js"; import { FNotifyService as et } from "../notify/index.esm.js"; import { LocaleService as de } from "../locale/index.esm.js"; import { cloneDeep as K, isPlainObject as ve } from "lodash-es"; import { FDynamicFormGroup as tt, useTypeResolver as xe } from "../dynamic-form/index.esm.js"; import { radioGroupProps as it } from "../radio-group/index.esm.js"; import { useDataSource as nt, FComboListContainer as rt } from "../combo-list/index.esm.js"; import { DgControl as ot } from "../designer-canvas/index.esm.js/"; const Ie = /* @__PURE__ */ new Map([ ["appearance", Xe] ]); function lt(t, i) { const e = i == null ? void 0 : i.formSchemaUtils, n = i == null ? void 0 : i.messagerService, r = t.parentComponentInstance, o = "54bddc89-5f7e-4b91-9c45-80dd6606cfe9"; function s() { const l = fe(h["content-container"].type), u = fe(h["filter-bar"].type); if (!l || !u) return; const v = Math.random().toString(36).substr(2, 4); Object.assign(l, { id: "filter-container-" + v, appearance: { class: "f-filter-container" }, contents: [u] }), Object.assign(u, { id: "filter-" + v, fields: [] }); const a = r.belongedComponentId, d = e.getViewModelIdByComponentId(a), m = e.getViewModelById(d); return m != null && m.states && (m.states.find((C) => C.code === "originalFilterConditionList") || m.states.push( { id: Y().guid(), category: "locale", code: "originalFilterConditionList", name: "筛选条过滤条件", type: "String" } )), { filterBar: u, filterBarContainer: l }; } function g(l) { const u = e.getViewModelIdByComponentId(r.belongedComponentId), v = e.getViewModelById(u); let a; if (v && v.commands) { if (a = v.commands.find((m) => m.handlerName === "Filter" && m.cmpId === o), !a) a = { id: Y().guid(), code: `${v.id.replace(/-/g, "").replace("component", "").replace("viewmodel", "")}Filter1`, name: "过滤并加载数据1", params: [ { name: "filter", shownName: "过滤条件", value: `{UISTATE~/#{${r.belongedComponentId}}/originalFilterConditionList}`, defaultValue: null }, { name: "sort", shownName: "排序条件", value: "", defaultValue: null } ], handlerName: "Filter", cmpId: o }, v.commands.push(a); else if (a.params && a.params.length) { const m = a.params.find((C) => C.name === "filter"); m && (m.value = `{UISTATE~/#{${r.belongedComponentId}}/originalFilterConditionList}`); } } const d = e.getCommands(); if (d) { let m = d.find((C) => C.id === o); m || (m = { id: o, path: "igix/Web/WebCmp/bo-webcmp/metadata/webcmd/data-commands", name: "LoadCommands.webcmd", refedHandlers: [] }, e.getCommands().push(m)), a && !m.refedHandlers.find((C) => C.host === a.id) && m.refedHandlers.push( { host: a.id, handler: "Filter" } ); } l && a && (l.onQuery = a.code); } function c(l, u) { const v = e.getViewModelById(u.viewModel), a = "8fe977a1-2b32-4f0f-a6b3-2657c4d03574", d = []; let m = v.commands.find((y) => y.handlerName === "loadFullTree" && y.cmpId === a); if (m) m.params && m.params.length && m.params.map((y) => { y.name === "fullTreeType" && (y.value = "0"), y.name === "loadType" && (y.value = "1"), y.name === "filters" && (y.value = `{UISTATE~/#{${r.belongedComponentId}}/originalFilterConditionList}`); }); else { const y = Y().guid(); m = { id: y, code: "treegridLoadFullTree1", name: "以完整树形结构加载数据1", params: [ { name: "fullTreeType", shownName: "是否是完整树加载", value: "0" }, { name: "loadType", shownName: "是否分级加载", value: "1" }, { name: "filters", shownName: "过滤条件", value: `{UISTATE~/#{${r.belongedComponentId}}/originalFilterConditionList}`, defaultValue: null } ], handlerName: "loadFullTree", cmpId: a }, v.commands.push(m), d.push({ host: y, handler: "loadFullTree" }); } if (!v.commands.find((y) => y.handlerName === "LoadFullTreeChildren" && y.cmpId === a)) { const y = Y().guid(); v.commands.push({ id: y, code: "treegridLoadFullTreeChildren1", name: "以完整树形结构加载下级数据1", params: [ { name: "commandName", shownName: "数据加载的命令编号", value: m.code }, { name: "frameId", shownName: "目标组件", value: u ? `#{${u.id}}` : "" } ], handlerName: "LoadFullTreeChildren", cmpId: a }), d.push({ host: y, handler: "LoadFullTreeChildren" }); } if (!v.commands.find((y) => y.handlerName === "LoadFullTreeInit" && y.cmpId === a)) { const y = Y().guid(); v.commands.push({ id: y, code: "treegridLoadFullTreeInit1", name: "加载完整树初始化1", params: [ { name: "fullTreeType", shownName: "完整树类型", value: "0", defaultValue: null }, { name: "loadType", shownName: "分级加载方式", value: "1", defaultValue: null } ], handlerName: "LoadFullTreeInit", cmpId: a }), d.push({ host: y, handler: "LoadFullTreeInit" }); } l.onQuery = m.code; const C = e.getFormSchema().module.webcmds; if (C) { let y = C.find((V) => V.id === a); y || (y = { id: a, path: "/projects/packages/Inspur.GS.Gsp.Web.WebCmp/webcmd", name: "TreeCardController.webcmd", refedHandlers: [] }, e.getFormSchema().module.webcmds.push(y)), d.map((V) => { y.refedHandlers.find((L) => L.host === V.host) || y.refedHandlers.push(V); }); } } function f(l) { const u = r.belongedComponentId, v = e.getComponentById(u); if (!v) return; const a = e.selectNode(v, (m) => m.type === "data-grid"), d = e.selectNode(v, (m) => m.type === "tree-grid"); if (a) return g(l), { gridType: "data-grid" }; if (d) return c(l, v), { gridType: "tree-grid" }; } function p() { const { filterBar: l, filterBarContainer: u } = s(), v = f(l), a = i == null ? void 0 : i.useFormCommand; if (a && a.checkCommands(), (v == null ? void 0 : v.gridType) === "tree-grid" && n) { let d = "启用成功!请参考XXX配置筛选条查询方法以及视图模型动作。"; d = d.replace( "XXX", '<a href="https://open.inspures.com/doc/#/doc/md/iGIX%2FiGIX_2506%2Freference-guide%2Ffarris-next%2Fformdev%2Ftreegrid-filter.md" target="_blank">在线文档</a>' ), n.success(d); } return u; } return { createFilterBar: p }; } function Te(t, i, e, n) { if (e.parentComponentInstance && n) { const s = lt(e, n).createFilterBar(); if (s) return s; } return i; } const st = "https://json-schema.org/draft/2020-12/schema", at = "https://farris-design.gitee.io/filter-bar.schema.json", dt = "filter-bar", ct = "A Farris Component", ut = "object", ft = { id: { description: "The unique identifier for filter-bar", type: "string" }, type: { description: "The type string of filter-bar", type: "string", default: "filter-bar" }, appearance: { description: "", type: "object", properties: { class: { type: "string" }, style: { type: "string" } }, default: {} }, defaultValues: { description: "", type: "array" }, disabled: { type: "boolean", default: !1 }, visible: { description: "", type: "boolean", default: !0 }, fields: { description: "", type: "array" }, resetText: { description: "", type: "string", default: "清空筛选" }, filterText: { description: "", type: "string", default: "筛选" }, filterType: { description: "", type: "string", default: "light" }, tileShowType: { description: "", type: "string", default: "multiline" }, liveSearch: { description: "", type: "boolean", default: !0 }, allInOneAlign: { description: "", type: "string", default: "left" }, lineLabelWidth: { description: "", type: "string", default: "fixed" }, itemClass: { description: "", type: "string" } }, mt = [ "id", "type" ], pt = { onQuery: "查询事件", onReset: "清空条件", onConditionChange: "搜索变化事件" }, Se = { $schema: st, $id: at, title: dt, description: ct, type: ut, properties: ft, required: mt, events: pt }, ce = { /** * 指定已设的筛选条件列表 * @default [] */ defaultValues: { type: Array, default: [] }, /** * 指定参与筛选的字段列表 * @default [] */ fields: { type: Array, default: [] }, /** * 是否可选择 * @default 'editable' */ mode: { type: String, default: "editable" }, /** * 是否可见 */ visible: { type: Boolean, default: !0 }, /** * 是否禁用 */ disabled: { type: Boolean, default: !1 }, /** * 清空值文字 * @default '清空筛选' */ resetText: { type: String, default: "清空筛选" }, /** * 筛选按钮文本 */ filterText: { type: String, default: "筛选" }, customClass: { type: String, default: "" }, customStyle: { type: String, default: "" }, // 筛选类型:轻量 | 平铺 filterType: { type: String, default: "light" }, // 平铺筛选的展示方式:单行展示、多行展示、所有在一行(会出现滚动条) tileShowType: { type: String, default: "multiline" }, // 是否即时搜索 liveSearch: { type: Boolean, default: !0 }, // 是否左对齐--all-in-one时才生效 allInOneAlign: { type: String, default: "left" }, // 行展示方式下,标签是否自动宽度自动 lineLabelWidth: { type: String, default: "fixed" }, // 项的样式 itemClass: { type: String, default: "" } }, gt = _e(ce, Se, Ie, Te); function re() { const { getLocaleValue: t } = de; return { confirm: t("filterBar.confirm"), cancel: t("filterBar.cancel"), advancedFilter: t("filterBar.advancedFilter"), clearAll: t("filterBar.clearAll"), expand: t("filterBar.expand"), fold: t("filterBar.fold"), require: t("filterBar.require") }; } function vt(t) { return de.getRealPropertyValue(t, "清空筛选", "filterBar.reset"); } function ht(t) { return de.getRealPropertyValue(t, "筛选", "filterBar.filter"); } function bt(t, i, e, n) { const r = w([]), o = w([]), s = w([]), g = w(""); w(t.mode); const c = /* @__PURE__ */ new Map(), { createConditionValue: f } = De(), { convertToControls: p } = ae("filter-bar"), l = Ke(t, i), { getFilterConditions: u } = l, { fieldToCondition: v, judgeLoadNewValue: a } = we(), d = new et(), m = re(); let C = "[]"; function y(x) { return !t.disabled && !x.value.isEmpty(); } function V(x) { o.value = p(x), o.value.reduce((k, F) => (k.set(F.labelCode, F), k), c); } function L(x) { const k = Array.isArray(x) ? x : []; s.value = o.value.map((F) => { const B = k.find((S) => S.id === F.id || S.labelCode === F.labelCode); if (B) { const S = v(F, B.value); return a(S, F) && S.value.clear(), S; } return v(F); }); } function O(x) { s.value = s.value.filter((k) => k.id !== x.id), r.value = r.value.filter((k) => k.fieldCode !== x.fieldCode), o.value = o.value.filter((k) => k.id !== x.id), i.emit("remove", x.fieldCode); } function T() { var x; t.disabled ? e.value = !1 : t.filterType === "tile" ? e.value = !t.disabled : e.value = ((x = s.value) == null ? void 0 : x.findIndex((k) => { var F; return k.value && !((F = k.value) != null && F.isEmpty()); })) > -1; } function R() { var k; const x = (k = s.value) == null ? void 0 : k.filter((F) => { var B; return F.value && !((B = F.value) != null && B.isEmpty()); }); return u(x, o.value); } function A(x = !0) { const k = R(), F = JSON.stringify(k || []); F !== C && (x && i.emit("conditionChange", k), C = F); } function M() { const x = []; if ((s.value || []).map((k) => { k.required && (!k.value || k.value.isEmpty()) && x.push(k.fieldName || ""); }), x.length > 0) { d.warning({ message: m.require.replace("[fields]", x.join(",")), position: "top-center" }); return; } i.emit("query", R()); } function I(x, k, F = !0) { V(x), L(k), T(), F && (A(), M()); } function U(x) { x.value.clear(), r.value = r.value.filter((k) => k.fieldCode !== x.fieldCode), i.emit("clear", x.fieldCode), T(), A(), t.liveSearch && M(); } function N() { s.value.forEach((x) => x.value.clear()); } function $() { s.value.forEach((x) => { x.value.clear(); }), i.emit("reset"), T(), A(), t.liveSearch && M(), n.resizeFilerBar(); } return { clearAll: N, clearFilterItem: U, currentFilterId: g, filterFields: o, filterItems: s, fieldMap: c, loadFilterItems: I, removeFilterItem: O, reset: $, shouldShowClearButtonInFilterItem: y, handleQuery: M, updateResetButtonState: T, handleConditionChange: A }; } function yt(t, i, e, n) { const r = w([]), o = re(), s = w(o.advancedFilter), g = w(vt(t.resetText)), c = w(!1), { clearAll: f, reset: p, filterItems: l } = e; function u() { r.value = l.value.filter((m) => m.isExtend); } u(); const v = W(() => r.value && r.value.length > 0); function a(m) { c.value = !0; } function d(m) { t.disabled || (t.mode === "display-only" ? f() : p()); } return () => b("div", { class: "f-filter-toolbars", style: "flex-shrink:0;" }, [t.filterType === "light" && v.value && b("button", { class: "btn btn-link", onClick: (m) => a() }, [s.value]), t.filterType === "light" && n.value && b("button", { class: "btn btn-link", onClick: (m) => d() }, [g.value]), t.filterType === "tile" && v.value && b("button", { class: "btn btn-secondary filter-search-btn-reset", onClick: (m) => a() }, [b("span", { class: "f-icon f-icon-filtrate" }, null)]), t.filterType === "tile" && !t.liveSearch && b("button", { class: "btn btn-secondary filter-search-btn-reset", disabled: t.disabled, onClick: (m) => d() }, [b("span", { class: "f-icon f-icon-remove" }, null)])]); } const Ct = { filterItem: { type: Object, default: null }, position: { type: Object, default: null }, /** * 位置参照元素 */ reference: { type: Object } }, Ft = Object.assign({}, it), wt = /* @__PURE__ */ Q({ name: "FFilterRadioGroup", props: Ft, emits: ["update:modelValue", "change"], setup(t, i) { const e = w(), { dataSource: n, displayText: r, modelValue: o } = nt(t, i); function s(g) { r.value = g.map((f) => f[t.textField]).join(t.separator); let c = ""; g.length === 1 ? c = g[0][t.valueField] : c = g.map((f) => f[t.valueField]).join(t.separator), o.value !== c && (o.value = c, i.emit("update:modelValue", o.value), i.emit("change", o.value)); } return () => b(rt, { style: "margin: -2px -15px;padding: 0;", ref: e, idField: t.valueField, valueField: t.valueField, textField: t.textField, titleField: t.titleField, dataSource: n.value, selectedValues: o.value, multiSelect: !1, enableSearch: !1, onSelectionChange: (g) => { s(g); } }, null); } }), xt = /* @__PURE__ */ Q({ name: "FFilterBarItemCondition", props: Ct, emits: ["cancel", "confirm", "clearFilter"], setup(t, i) { const e = w(K(t.filterItem)), n = w(), r = re(), o = w("0px"), s = w("0px"), g = w("0px"), c = w("auto"), f = W(() => ({ left: c.value === "auto" ? "26px" : "auto", right: c.value })), p = W(() => ({ left: o.value, top: s.value })), l = W(() => ({ width: g.value === "0px" ? null : g.value, maxWidth: g.value === "0px" ? null : g.value })), u = w(), { useFilterItemsComposition: v, resolveEditorProps: a } = D("useFilterItemsComposition"), { fieldMap: d } = v, { renderFieldConditionEditor: m, conditionChangeHandler: C } = ae("filter-bar"), y = w(""); let V = !1, L = {}; const O = w(!0); function T() { var q, z; if (!t.reference || !u.value) return; const F = (q = t.reference) == null ? void 0 : q.getBoundingClientRect(); let B = (z = u.value) == null ? void 0 : z.getBoundingClientRect().width; const S = document.body.clientWidth - F.x - 30, P = document.body.clientWidth - F.y - 30; B > S && B > P && (B = Math.max(S, P)), F.left > document.body.clientWidth - B - 20 ? (o.value = F.left + F.width - B + "px", s.value = F.top + F.height + "px", c.value = "26px") : (o.value = F.left + "px", s.value = F.top + F.height + "px", c.value = "auto"), g.value = B + "px"; } function R(F, B, S, P) { V = !0, L = { value: B, editor: S, option: P }; } function A() { if (!n.value) return !1; const F = n.value.parentElement, B = Array.from(F.children); return B ? !!B.find((P) => !P || !P.classList ? !1 : P.classList.contains("popover") && P.style.visibility === "visible") : !1; } function M(F, B, S, P) { C(F, B, S, P), i.emit("confirm", e.value); } function I() { const { id: F, editor: B, needEmitChange: S } = m(d, e.value, R); if (y.value = "filter-panel--" + B.type, B.type === "radio-group") { const P = a(B.type, B); return O.value = !1, b(wt, Ge(P, { modelValue: e.value.value.value, "onUpdate:modelValue": (q) => e.value.value.value = q, onChange: (q) => { M(e.value, q, B); } }), { default: () => [j(" ")] }); } return b(tt, { showLabelType: "force-none", id: F, key: F, editor: B, modelValue: e.value.value.value, "onUpdate:modelValue": (P) => e.value.value.value = P, onChange: (P, q) => { S && R(e.value, P, B, q); } }, null); } ee(() => { T(); }); function U(F) { const B = y.value.replace("filter-panel--", ""); ["input", "radio-group", "switch"].findIndex((S) => S === B) > -1 ? i.emit("cancel") : A() || i.emit("cancel"); } function N(F) { F.stopPropagation(), V && C(e.value, L.value, L.editor, L.option), i.emit("confirm", e.value); } function $(F) { e.value.value.clear(), F.stopPropagation(), i.emit("confirm", e.value); } function x() { const F = Je(); return { zIndex: Math.max(F, 1050) }; } const k = x(); return () => b("div", { class: "f-filter-panel-wrapper can-close", ref: n, onClick: U, style: { zIndex: k } }, [b("div", { class: "f-filter-panel " + y.value, ref: u, style: p.value }, [b("div", { class: "f-filter-panel-inner", style: l.value, onClick: (F) => F.stopPropagation() }, [b("div", { class: "f-filter-panel-arrow", style: f.value }, null), I(), O.value && b("div", { class: "f-filter-panel-footer" }, [b("div", { class: "filter-panel-clear" }, [b("button", { class: "btn btn-link", onClick: $, style: "padding-left:0;" }, [r.clearAll])]), b("div", { class: "filter-panel-btns" }, [b("button", { class: "btn btn-secondary can-close", onClick: U }, [r.cancel]), b("button", { class: "filter-panel-submit btn btn-primary", onClick: N }, [r.confirm])])])])])]); } }), Ee = { filterItem: { type: Object, default: null }, disabled: { type: Boolean, default: !1 }, customClass: { type: String, default: "" } }; function It() { const t = w(!1); return ee(() => { t.value = !0; }), t; } const Tt = /* @__PURE__ */ Q({ name: "FFilterBarItem", props: Ee, emits: ["confirm"], setup(t, i) { const e = w(t.filterItem), { useFilterItemsComposition: n } = D("useFilterItemsComposition"), { clearFilterItem: r, currentFilterId: o, removeFilterItem: s, shouldShowClearButtonInFilterItem: g } = n, c = w(!1), f = w(!1), p = w(), l = w(""), u = w(), v = It(), a = function() { const T = { "f-filter-item": !0, "f-state-disabled": t.disabled, "f-filter-item-actived": !e.value.value.isEmpty(), // 'f-filter-item-last': index === filterItems.value.length - 1, "f-filter-item-edit": e.value.id === o.value || c.value }; return Ye(T, t.customClass); }; W(() => !t.disabled && t.mode === "editable"); function d(T) { t.disabled || (t.mode === "display-only" ? s(e.value) : r(e.value)); } function m(T) { t.disabled || (c.value = !0); } function C() { c.value = !1; } function y() { u.value && u.value.scrollWidth > u.value.clientWidth ? l.value = u.value.innerHTML : l.value = ""; } function V(T) { c.value = !1, e.value.value = T.value, i.emit("confirm", T), se(() => { y(); }); } function L() { f.value = t.disabled ? !1 : g(e.value); } function O() { f.value = !1; } return ee(() => { y(); }), () => b("div", { key: e.value.id, id: e.value.id, class: a(), onMouseenter: () => L(), onMouseleave: () => O() }, [b("div", { class: "f-filter-item-inner", ref: p, onClick: (T) => m() }, [e.value.required && b("span", { class: "f-filter-item-required text-danger" }, [j("*")]), b("span", { class: "f-filter-item-text" }, [e.value.fieldName]), !e.value.value.isEmpty() && b(le, null, [b("span", { class: "f-filter-item-tip" }, [j(":")]), b("span", { class: "f-filter-item-content", ref: u, title: l.value }, [e.value.value.getDisplayText()])]), !t.disabled && b("span", { class: "f-filter-item-arrow f-icon f-icon-arrow-chevron-down" }, null)]), f.value && b("span", { class: "mr-3 f-filter-item-clear", onClick: (T) => d() }, [b("span", { class: "f-icon f-icon-close-circle" }, null)]), v.value && c.value && b(ze, { to: "body" }, { default: () => [b(xt, { filterItem: e.value, reference: p.value, onConfirm: V, onCancel: C }, null)] })]); } }); function Me(t, i) { const e = w(null), n = 15; let r = 0; function o(c = -1, f = -1) { var a; if (!t.value) return; const p = (a = t.value) == null ? void 0 : a.querySelector(".f-filter-list"); if (!p) return; const l = p.children; if (!l || l.length === 0 || (c < 0 && (c = t.value.clientWidth), r = f < 0 ? r : f, Math.abs(c - r) < n)) return; Array.from(l).forEach((d) => { d.style.display = "flex"; }), i.value = p.clientWidth < p.scrollWidth; let u = !1, v = 0; for (let d = 0; d < l.length; d++) { const m = l[d], C = Math.ceil(m.offsetWidth + (parseFloat(getComputedStyle(m).marginRight) || 0) + parseFloat(getComputedStyle(m).marginLeft)); !u && v + C <= c ? v += C : (m.style.display = "none", u = !0); } r = c; } function s() { var f, p; if (!t.value) return; (f = e.value) == null || f.unobserve(t.value); const c = ((p = t.value.querySelector(".f-filter-list")) == null ? void 0 : p.children) || []; Array.from(c).forEach((l) => { l.style.display = "flex"; }), r = 0; } function g() { if (!t.value) return; const c = new ResizeObserver((f) => { const p = f[0].contentRect.width; o(p); }); return c.observe(t.value), e.value = c, c; } return { setupWidthObserver: g, cancelWidthObserver: s, handleVisibleChildren: o }; } const _ = /* @__PURE__ */ Q({ name: "FFilterBar", props: ce, emits: ["clear", "remove", "reset", "conditionChange", "change", "query"], setup(t, i) { const e = w(!1), n = w(!1), r = w(null), o = w(!1), s = w(ht(t.filterText)), g = w(0), c = Me(r, n), { cancelWidthObserver: f, setupWidthObserver: p, handleVisibleChildren: l } = c, u = { resizeFilerBar: () => { e.value || se(() => { l(-1, 0); }); } }, v = bt(t, i, o, u), { filterFields: a, filterItems: d, loadFilterItems: m, handleQuery: C, updateResetButtonState: y, handleConditionChange: V } = v, { resolveEditorProps: L } = xe(); be("useFilterItemsComposition", { useFilterItemsComposition: v, resolveEditorProps: L }); const O = re(), T = W(() => { const S = { display: t.filterType === "tile" || a.value && a.value.length ? "" : "none" }; return Fe(S, t == null ? void 0 : t.customStyle); }), R = w(); m(t.fields, t.defaultValues, !!(t.defaultValues && t.defaultValues.length > 0)), ye([() => t.defaultValues, () => t.fields], ([S, P]) => { m(P, S), g.value++, u.resizeFilerBar(); }), ee(() => { if (p(), t.filterType === "tile" && t.tileShowType === "all-in-one") { const S = R.value.querySelector(".condition-div"); S.scrollWidth > S.clientWidth && (R.value.className = R.value.className + " all-in-one--item-fill"); } }), Ce(() => { f(); }); const A = W(() => ({ "f-filter-list": !0, "f-filter-list-extend": e.value // 'f-utils-overflow-hidden': true })), M = W(() => ({ "extend-btn-arrow": !0, "f-icon": !0, "f-icon-arrow-chevron-up": e.value, "f-icon-arrow-chevron-down": !e.value })), I = W(() => !e.value && n.value); function U() { e.value = !e.value, e.value ? f() : p(); } const N = yt(t, i, v, o); function $(S, P = !0) { i.emit("change", S), P && y(), V(), t.liveSearch && C(), P && u.resizeFilerBar(); } function x() { return b("div", { class: A.value, key: t.id + "-main-" + g.value }, [d.value.map((S, P) => !S.isExtend && b(Tt, { filterItem: S, onConfirm: $, disabled: t.disabled || S.disabled }, null)), e.value && N()]); } function k() { return I.value && b("div", { class: "f-filter-list-ellipsis", onClick: (S) => U() }, [j("...")]); } function F() { t.disabled || (V(), C()); } function B() { let S = "", P; t.tileShowType !== "all-in-one" && (S = t.lineLabelWidth === "auto" ? " filter-item-wrap" : "", P = t.tileShowType === "aline" ? "col-12" + S : S ? "col-12 col-md-6 col-xl-3 col-el-2" + S : void 0); const q = t.tileShowType === "multiline", z = t.disabled ? d.value.map((Z) => ({ ...Z, disabled: !0 })) : d.value; return b("div", { class: "f-list-filter d-flex list-filter--" + t.tileShowType + t.customClass, style: T.value }, [t.tileShowType !== "all-in-one" && b("div", { class: "flex-fill" }, [b(pe, { fields: a.value, conditions: z, itemClass: P, autoResponse: q, onValueChange: (Z, J) => $(J) }, null), j(" ")]), t.tileShowType === "all-in-one" && b("div", { class: "filter-inputs-main-basis-wrapper filter-input--all-in-one" + t.customClass, ref: R, style: T.value }, [b(pe, { style: "flex-wrap:nowrap!important;overflow-x:auto;", fields: a.value, customClass: t.allInOneAlign === "right" ? "justify-content-end" : "", conditions: z, itemClass: t.lineLabelWidth === "auto" ? "filter-input-list filter-item-wrap" : "filter-input-list", autoResponse: !1, onValueChange: (Z, J) => $(J) }, null)]), !t.liveSearch && b("div", { class: "filter-search-btn filter-search-btn--filter", onClick: F }, [b("button", { class: "btn btn-primary", disabled: t.disabled }, [s.value])]), N()]); } return () => t.filterType === "light" ? b("div", { class: "f-filter-wrapper " + t.customClass, style: T.value }, [b("div", { class: "f-filter-wrapper-inner f-utils-fill" }, [b("div", { class: "f-filter-main f-utils-fill" }, [b("div", { class: "f-filter-list-wrapper flex-fill", ref: r }, [x()]), k(), !e.value && N()]), !t.liveSearch && b("div", { class: "filter-search-btn filter-search-btn--filter", style: "margin:0 8px 0 0;", onClick: F }, [b("button", { class: "btn btn-primary", disabled: t.disabled }, [s.value])]), n.value && b("div", { class: "f-filter-extend-btn" }, [b("button", { class: "btn btn-link", onClick: U }, [b("span", { class: "extend-btn-text" }, [e.value ? O.fold : O.expand]), b("span", { class: M.value }, null)])])])]) : B(); } }); function St(t, i) { w([]); const e = w([]), n = w([]), r = w(""); w(!1), w(t.mode); const o = /* @__PURE__ */ new Map(), { convertToControls: s } = ae("filter-bar"), { fieldToCondition: g } = we(); function c(u) { return !u.value.isEmpty(); } function f(u) { e.value = K(u), e.value.reduce((v, a) => (v.set(a.labelCode, a), v), o); } function p(u) { n.value = e.value.map((v) => g(v)); } function l(u, v) { f(u), p(); } return l(t.fields), { currentFilterId: r, filterFields: e, filterItems: n, fieldMap: o, loadFilterItems: l, shouldShowClearButtonInFilterItem: c }; } function Et(t, i, e) { const n = w([]), r = w("更多筛选"), { filterItems: o } = e; function s() { n.value = o.value.filter((c) => c.isExtend); } s(); const g = W(() => n.value && n.value.length > 0); return () => b("div", { class: "f-filter-toolbars" }, [t.filterType === "light" && g.value && g.value && b("button", { class: "btn btn-link" }, [r.value]), t.filterType === "tile" && !t.liveSearch && b("button", { class: "btn btn-secondary filter-search-btn-reset" }, [b("span", { class: "f-icon f-icon-remove" }, null)])]); } const Mt = /* @__PURE__ */ Q({ name: "FFilterBarItemDesign", props: Ee, emits: ["confirm"], setup(t, i) { const e = w(t.filterItem), { useFilterItemsComposition: n } = D("useFilterItemsComposition"), { currentFilterId: r, shouldShowClearButtonInFilterItem: o } = n, s = w(t.disabled), g = function() { return { "f-filter-item": !0, "f-filter-item-actived": !e.value.value.isEmpty(), // 'f-filter-item-last': index === filterItems.value.length - 1, "f-filter-item-edit": e.value.id === r.value }; }; return () => b("div", { key: e.value.id, id: e.value.id, class: g() }, [b("div", { class: "f-filter-item-inner" }, [e.value.required && b("span", { class: "f-filter-item-required text-danger" }, [j("*")]), b("span", { class: "f-filter-item-text" }, [e.value.fieldName]), e.value.value.getDisplayText() && b(le, null, [b("span", { class: "f-filter-item-tip" }, [j(":")]), b("span", { class: "f-filter-item-content" }, [e.value.value.getDisplayText()])]), !s.value && b("span", { class: "f-filter-item-arrow f-icon f-icon-arrow-chevron-down" }, null)]), o(e.value) && b("span", { class: "mr-3 f-filter-item-clear" }, [b("span", { class: "f-icon f-icon-close-circle" }, null)])]); } }); function kt(t) { const { formSchemaUtils: i, formStateMachineUtils: e } = t; function n(c, f = "") { return { path: f + c.code, field: c.id, fullPath: c.code }; } function r(c, f = "") { const p = i.getViewModelById(c); return p ? p.states.map((l) => n(l, f)) : []; } function o(c) { const f = i.getRootViewModelId(), p = r(c); if (c === f) return p; const l = r(f, "root-component."); return [...p, ...l]; } function s(c) { return c.binding && c.binding.path || c.id || ""; } function g() { return e && e.getRenderStates() || []; } return { getVariables: o, getControlName: s, getStateMachines: g }; } class Pt { constructor(i) { E(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'" } ]); E(this, "expressionNames", { compute: "计算表达式", dependency: "依赖表达式", validate: "验证表达式", dataPicking: "帮助前表达式", visible: "可见表达式", readonly: "只读表达式", required: "必填表达式" }); E(this, "getExpressionConverter", (i, e) => ({ convertFrom: (n, r, o, s) => { const g = o.getExpressionRuleValue(i, e || r); return g && g.value || ""; }, convertTo: (n, r, o, s, g) => { var c; if (r === "dataPicking" && (o != null && o.target)) { const f = `${o.target}_dataPicking`; ((c = o.rules) == null ? void 0 : c.some( (l) => l.id === f && l.value )) ? n.dictPickingExpressionId = f : delete n.dictPickingExpressionId; } s.updateExpression(o); } })); this.formSchemaService = i; } getExpressionRule(i, e) { const n = this.getExpressionData(); if (!n) return ""; const r = n.find((s) => s.target === i); if (!r) return ""; const o = r.rules.find((s) => s.type === e); return o || ""; } // 获取上下文表单变量 getContextFormVariables() { const { module: i } = this.formSchemaService.getFormSchema(); if (!i.viewmodels || i.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(i, e, n = "label") { return { id: i.id, name: i.name, bindingPath: i[n], parents: e, type: "field" }; } buildEntityFieldsTreeData(i = null, e) { const n = []; return i == null || i.forEach((r) => { var g; const o = this.createTreeNode(r, e); let s = []; (g = r.type) != null && g.fields && (s = this.buildEntityFieldsTreeData(r.type.fields, [...e, r.label])), n.push({ data: o, children: s, expanded: !0 }); }), n; } buildChildEntityTreeData(i = null, e) { const n = []; return i == null || i.forEach((r) => { var c, f; const o = this.createTreeNode(r, e); o.type = "entity"; const s = this.buildEntityFieldsTreeData((c = r.type) == null ? void 0 : c.fields, [...e, r.label]), g = this.buildChildEntityTreeData((f = r.type) == null ? void 0 : f.entities, [...e, r.label]); g != null && g.length && (s == null || s.push(...g)), n.push({ data: o, children: s || [], // 空值回退 expanded: !0 }); }), n; } getEntitiesTreeData() { const i = this.formSchemaService.getSchemaEntities(); if (!(i != null && i.length)) return []; const e = i[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(i, e, n) { const r = n === "Field" ? i.binding.field : i.id, o = this.getExpressionRule(r, e), s = this.getEntitiesAndVariables(), g = { message: ["validate", "required", "dataPicking"].includes(e) && o ? o.message : "", ...s }; return o.messageType != null && (g.messageType = o.messageType), g; } buildRule(i, e, n, r) { const { expression: o, message: s, messageType: g } = e, c = { id: `${i}_${n}`, type: n, value: o }; return (n === "validate" || n === "dataPicking" || n === "required") && (c.message = s), n === "dataPicking" && (c.messageType = g), n === "validate" && r && (c.elementId = r), c; } getExpressionData() { const { expressions: i } = this.formSchemaService.getFormSchema().module; return i || []; } updateExpression(i, e, n, r) { const o = e === "Field" ? i.binding.field : i.id, s = this.buildRule(o, n, r, i.type === "form-group" ? i.id : ""); let c = this.getExpressionData().find((p) => p.targetType === e && p.target === o); const f = (p) => p.value.trim() === ""; if (c) { const p = c.rules.find((l) => l.id === s.id); if (p) f(s) ? c.rules = c.rules.filter((l) => l.id !== s.id) : (Object.assign(p, s), r === "validate" && i.type === "form-group" && (p.elementId = i.id)); else { if (f(s)) return null; c.rules = c.rules || [], c.rules.push(s); } } else { if (f(s)) return null; c = { target: `${o}`, rules: [s], targetType: e }; } return c; } getExpressionEditorOptions(i, e, n, r) { return n.reduce((o, s) => { var c, f; const g = e === "Field" ? (c = i == null ? void 0 : i.binding) == null ? void 0 : c.field : i.id; return o[s] = { hide: e === "Field" ? !!((f = i == null ? void 0 : i.binding) != null && f.field) : !1, description: "", title: this.expressionNames[s], type: "string", $converter: this.getExpressionConverter(g), 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(i, s, e), onSubmitModal: (p) => { const l = this.updateExpression(i, e, p, s); if (r) { const u = this.buildRule(g, p, s); r(u); } return l; } } }, o; }, {}); } getExpressionInfo(i, e, n) { const r = e === "Field" ? i.binding.field : i.id, o = this.getExpressionRule(r, n), s = { value: o && o.value, targetId: r, targetType: e, expressionType: n }; return o && o.message && (s.message = o.message), s; } getExpressionConfig(i, e, n = ["compute", "dependency", "validate"], r) { var o; return { description: "表达式", title: "表达式", hide: !(i.binding && ((o = i.binding) == null ? void 0 : o.type) === "Form"), properties: { ...this.getExpressionEditorOptions(i, e, n, r) } }; } getExpressionOptions(i, e, n) { const r = this.getExpressionInfo(i, e, n); return { dialogTitle: `${this.expressionNames[n] || "表达式"}编辑器`, singleExpand: !1, showMessage: n === "required", beforeOpen: () => this.onBeforeOpenExpression(i, n, e), expressionInfo: r }; } } class Vt { constructor(i, e) { E(this, "componentId"); E(this, "viewModelId"); E(this, "eventsEditorUtils"); E(this, "formSchemaUtils"); E(this, "formMetadataConverter"); E(this, "designViewModelUtils"); E(this, "designViewModelField"); E(this, "controlCreatorUtils"); E(this, "designerHostService"); E(this, "designerContext"); E(this, "modalService", null); /** 表单规则 */ E(this, "formRule", null); E(this, "schemaService", null); E(this, "metadataService", null); E(this, "propertyConfig", { type: "object", categories: {} }); E(this, "expressionProperty"); var n; this.componentId = i, 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(i)) || "", 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 Pt(this.formSchemaUtils); } /** * 是否在响应式表单中 */ inResponsiveForm() { var i; return !!((i = this.designerContext) != null && i.responsiveForm); } getFormDesignerInstance() { var i, e; return (e = (i = this.designerContext) == null ? void 0 : i.instances) == null ? void 0 : e.formDesigner.value; } getTableInfo() { var i; return (i = this.schemaService) == null ? void 0 : i.getTableInfoByViewModelId(this.viewModelId); } setDesignViewModelField(i) { var n; const e = i.binding && i.binding.type === "Form" && i.binding.field; if (e) { if (!this.designViewModelField) { const r = this.designViewModelUtils.getDgViewModel(this.viewModelId); this.designViewModelField = r.fields.find((o) => o.id === e); } i.updateOn = (n = this.designViewModelField) == null ? void 0 : n.updateOn; } } getBasicPropConfig(i) { 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: i.type, name: h[i.type] && h[i.type].name }] } } } }; } getAppearanceConfig(i = 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 s in e) o[s] = Object.assign(o[s] || {}, e[s]); return { ...r, properties: { ...o }, setPropertyRelates(s, g) { if (s) { switch (s && s.propertyID) { case "class": case "style": { ie.value++; break; } } n && n(s, i, g); } } }; } /** * * @param propertyData * @param propertyTypes * @param propertyName * @param constInfos * @param variableInfos * @param expressionType 指定表达式类型,存在属性和表达式类型不一致的情况 * @returns */ getPropertyEditorParams(i, e = [], n = "visible", r = {}, o = {}, s = "") { const { getVariables: g, getControlName: c, getStateMachines: f } = kt(this.designerHostService), p = this.getRealTargetType(i), l = e && e.length > 0 ? e : ["Const", "Variable", "StateMachine", "Expression"], u = { type: "property-editor", propertyTypes: l }; return l.map((v) => { switch (v) { case "Const": Object.assign(u, { constType: "enum", constEnums: [{ id: !0, name: "是" }, { id: !1, name: "否" }] }, r); break; case "Expression": u.expressionConfig = this.getExpressionOptions(i, p, s || n); break; case "StateMachine": u.stateMachines = f(); break; case "Variable": Object.assign(u, { controlName: c(i), newVariablePrefix: "is", newVariableType: "Boolean", variables: g(this.viewModelId), parentComponentId: this.componentId === "root-component" ? "" : "root-component", onBeforeOpenVariables: (a) => { a.value = g(this.viewModelId); } }, o), this.designerContext.designerMode === "PC_RTC" && (u.newVariablePrefix = "ext_" + u.newVariablePrefix); break; } }), u; } getVisibleProperty(i, e = "") { var o; let n = ["Const", "Variable", "StateMachine", "Expression"]; return e === "gridFieldEditor" ? n = ["Const", "Expression"] : e === "form-group" && !((o = i.binding) != null && o.field) ? n = ["Const", "Variable", "StateMachine", "Custom"] : e === "dataGrid" || e === "treeGrid" || e === "wizard" ? n = ["Const", "Variable", "Expression"] : (i.type.indexOf("toolbar-item") > -1 || e === "form-group") && (n = ["Const", "Variable", "StateMachine", "Custom", "Expression"]), { visible: { title: "是否可见", type: "boolean", description: "运行时组件是否可见", editor: this.getPropertyEditorParams(i, n, "visible") } }; } /** * 获取行为 * @param propertyData * @param viewModelId * @returns */ getBehaviorConfig(i, e = "", n = {}, r) { const o = { title: "行为", description: "" }, s = this.getVisibleProperty(i, e); for (const c in n) s[c] = Object.assign(s[c] || {}, n[c]); const g = this; return { ...o, properties: { ...s }, setPropertyRelates(c, f) { if (c) { switch (c.propertyID) { case "disabled": case "readonly": case "visible": g.afterMutilEditorChanged(i, c); break; } r && r(c, f); } } }; } /** * 当多值编辑器变更时 * @param propertyData * @param changeObject */ afterMutilEditorChanged(i, e) { this.addNewVariableToViewModel(e, this.viewModelId), this.updateExpressionValue(e, i), this.clearExpression(e, i); } /** * * @param propertyId * @param componentInstance * @returns */ updateElementByParentContainer(i, e) { const n = e && e.parent && e.parent.schema; if (!n) return; const r = n.contents.findIndex((s) => s.id === i), o = K(n.contents[r]); n.contents.splice(r, 1), n.contents.splice(r, 0, o), Qe(); } /** * 属性编辑器,在编辑过程中会新增变量,此处需要将新增的变量追加到ViewModel中 * @param changeObject * @param viewModelId * @returns */ addNewVariableToViewModel(i, e) { const n = i.propertyValue; if (!(n && typeof n == "object") || !(n.type === "Variable" && n.isNewVariable)) return; const s = { id: n.field, category: "locale", code: n.fullPath, name: n.fullPath, type: n.newVariableType || "String", isRtcVariable: this.designerContext.designerMode === "PC_RTC" ? !0 : void 0 }; delete n.newVariableType, delete n.isNewVariable, this.formSchemaUtils.getVariableByCode(s.code) || this.formSchemaUtils.getViewModelById("root-viewmodel").states.push(s); } getExpressions() { let i = []; return this.formRul