UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,548 lines 108 kB
var Ae = Object.defineProperty; var $e = (n, t, e) => t in n ? Ae(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e; var E = (n, t, e) => $e(n, typeof t != "symbol" ? t + "" : t, e); import { ref as w, computed as $, createVNode as C, defineComponent as X, inject as Z, onMounted as ee, mergeProps as je, createTextVNode as G, Fragment as ce, Teleport as We, nextTick as ne, provide as ue, watch as fe, onUnmounted as me } from "vue"; import { resolveAppearance as qe, getSchemaByType as le, createPropsResolver as Ge } from "../dynamic-resolver/index.esm.js"; import { DgControl as h, canvasChanged as H, refreshCanvas as ze, useDesignerComponent as De } from "../designer-canvas/index.esm.js"; import { useGuid as _, getMaxZIndex as Xe, getCustomStyle as pe, FormSchemaEntityField$Type as se, FormSchemaEntityFieldType$Type as _e } from "../common/index.esm.js"; import { useConditionValue as Qe, useConditionUtils as ie } from "../condition/index.esm.js"; import { useCondition as Ze, useSolutionUtils as ge } from "../query-solution/index.esm.js"; import { FNotifyService as Je } from "../notify/index.esm.js"; import { LocaleService as ve } from "../locale/index.esm.js"; import { cloneDeep as J, isPlainObject as ae } from "lodash-es"; import { FDynamicFormGroup as Ye, useTypeResolver as he } from "../dynamic-form/index.esm.js"; import { radioGroupProps as He } from "../radio-group/index.esm.js"; import { useDataSource as Ke, FComboListContainer as et } from "../combo-list/index.esm.js"; import { DgControl as tt } from "../designer-canvas/index.esm.js/"; const be = /* @__PURE__ */ new Map([ ["appearance", qe] ]); function nt(n, t) { const e = t == null ? void 0 : t.formSchemaUtils, i = t == null ? void 0 : t.messagerService, r = n.parentComponentInstance, l = "54bddc89-5f7e-4b91-9c45-80dd6606cfe9"; function s() { const o = le(h["content-container"].type), c = le(h["filter-bar"].type); if (!o || !c) return; const g = Math.random().toString(36).substr(2, 4); Object.assign(o, { id: "filter-container-" + g, appearance: { class: "f-filter-container" }, contents: [c] }), Object.assign(c, { id: "filter-" + g, fields: [] }); const a = r.belongedComponentId, u = e.getViewModelIdByComponentId(a), p = e.getViewModelById(u); return p != null && p.states && (p.states.find((y) => y.code === "originalFilterConditionList") || p.states.push( { id: _().guid(), category: "locale", code: "originalFilterConditionList", name: "筛选条过滤条件", type: "String" } )), { filterBar: c, filterBarContainer: o }; } function v(o) { const c = e.getViewModelIdByComponentId(r.belongedComponentId), g = e.getViewModelById(c); let a; if (g && g.commands) { if (a = g.commands.find((p) => p.handlerName === "Filter" && p.cmpId === l), !a) a = { id: _().guid(), code: `${g.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: l }, g.commands.push(a); else if (a.params && a.params.length) { const p = a.params.find((y) => y.name === "filter"); p && (p.value = `{UISTATE~/#{${r.belongedComponentId}}/originalFilterConditionList}`); } } const u = e.getCommands(); if (u) { let p = u.find((y) => y.id === l); p || (p = { id: l, path: "igix/Web/WebCmp/bo-webcmp/metadata/webcmd/data-commands", name: "LoadCommands.webcmd", refedHandlers: [] }, e.getCommands().push(p)), a && !p.refedHandlers.find((y) => y.host === a.id) && p.refedHandlers.push( { host: a.id, handler: "Filter" } ); } o && a && (o.onQuery = a.code); } function d(o, c) { const g = e.getViewModelById(c.viewModel), a = "8fe977a1-2b32-4f0f-a6b3-2657c4d03574", u = []; let p = g.commands.find((b) => b.handlerName === "loadFullTree" && b.cmpId === a); if (p) p.params && p.params.length && p.params.map((b) => { b.name === "fullTreeType" && (b.value = "0"), b.name === "loadType" && (b.value = "1"), b.name === "filters" && (b.value = `{UISTATE~/#{${r.belongedComponentId}}/originalFilterConditionList}`); }); else { const b = _().guid(); p = { id: b, 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 }, g.commands.push(p), u.push({ host: b, handler: "loadFullTree" }); } if (!g.commands.find((b) => b.handlerName === "LoadFullTreeChildren" && b.cmpId === a)) { const b = _().guid(); g.commands.push({ id: b, code: "treegridLoadFullTreeChildren1", name: "以完整树形结构加载下级数据1", params: [ { name: "commandName", shownName: "数据加载的命令编号", value: p.code }, { name: "frameId", shownName: "目标组件", value: c ? `#{${c.id}}` : "" } ], handlerName: "LoadFullTreeChildren", cmpId: a }), u.push({ host: b, handler: "LoadFullTreeChildren" }); } if (!g.commands.find((b) => b.handlerName === "LoadFullTreeInit" && b.cmpId === a)) { const b = _().guid(); g.commands.push({ id: b, code: "treegridLoadFullTreeInit1", name: "加载完整树初始化1", params: [ { name: "fullTreeType", shownName: "完整树类型", value: "0", defaultValue: null }, { name: "loadType", shownName: "分级加载方式", value: "1", defaultValue: null } ], handlerName: "LoadFullTreeInit", cmpId: a }), u.push({ host: b, handler: "LoadFullTreeInit" }); } o.onQuery = p.code; const y = e.getFormSchema().module.webcmds; if (y) { let b = y.find((M) => M.id === a); b || (b = { id: a, path: "/projects/packages/Inspur.GS.Gsp.Web.WebCmp/webcmd", name: "TreeCardController.webcmd", refedHandlers: [] }, e.getFormSchema().module.webcmds.push(b)), u.map((M) => { b.refedHandlers.find((V) => V.host === M.host) || b.refedHandlers.push(M); }); } } function m(o) { const c = r.belongedComponentId, g = e.getComponentById(c); if (!g) return; const a = e.selectNode(g, (p) => p.type === "data-grid"), u = e.selectNode(g, (p) => p.type === "tree-grid"); if (a) return v(o), { gridType: "data-grid" }; if (u) return d(o, g), { gridType: "tree-grid" }; } function f() { const { filterBar: o, filterBarContainer: c } = s(), g = m(o), a = t == null ? void 0 : t.useFormCommand; if (a && a.checkCommands(), (g == null ? void 0 : g.gridType) === "tree-grid" && i) { let u = "启用成功!请参考XXX配置筛选条查询方法以及视图模型动作。"; u = u.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>' ), i.success(u); } return c; } return { createFilterBar: f }; } function ye(n, t, e, i) { if (e.parentComponentInstance && i) { const s = nt(e, i).createFilterBar(); if (s) return s; } return t; } const it = "https://json-schema.org/draft/2020-12/schema", rt = "https://farris-design.gitee.io/filter-bar.schema.json", ot = "filter-bar", lt = "A Farris Component", st = "object", at = { 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" } }, dt = [ "id", "type" ], ct = { onQuery: "查询事件" }, Ce = { $schema: it, $id: rt, title: ot, description: lt, type: st, properties: at, required: dt, events: ct }, re = { /** 指定已设的筛选条件列表 */ defaultValues: { type: Array, default: [] }, /** 指定参与筛选的字段列表 */ fields: { type: Array, default: [] }, /** 是否可选择 */ mode: { type: String, default: "editable" }, /** 是否可见 */ visible: { type: Boolean, default: !0 }, /** 是否禁用 */ disabled: { type: Boolean, default: !1 }, /** 清空值文字 */ resetText: { type: String, default: "清空筛选" }, customClass: { type: String, default: "" }, customStyle: { type: String, default: "" } }, ut = Ge(re, Ce, be, ye); function te() { const { getLocaleValue: n } = ve; return { confirm: n("filterBar.confirm"), cancel: n("filterBar.cancel"), advancedFilter: n("filterBar.advancedFilter"), clearAll: n("filterBar.clearAll"), expand: n("filterBar.expand"), fold: n("filterBar.fold"), require: n("filterBar.require") }; } function ft(n) { return ve.getRealPropertyValue(n, "清空筛选", "filterBar.reset"); } function mt(n, t, e, i) { const r = w([]), l = w([]), s = w([]), v = w(""); w(n.mode); const d = /* @__PURE__ */ new Map(), { createConditionValue: m } = Qe(), { convertToControls: f } = ie("filter-bar"), o = Ze(n, t), { getFilterConditions: c } = o, { fieldToCondition: g, judgeLoadNewValue: a } = ge(), u = new Je(), p = te(); let y = "[]"; function b(I) { return !n.disabled && !I.value.isEmpty(); } function M(I) { l.value = f(I), l.value.reduce((k, R) => (k.set(R.labelCode, R), k), d); } function V(I) { const k = Array.isArray(I) ? I : []; s.value = l.value.map((R) => { const T = k.find((x) => x.id === R.id); if (T) { const x = g(R, T.value); return a(x, R) && x.value.clear(), x; } return g(R); }); } function S(I) { s.value = s.value.filter((k) => k.id !== I.id), r.value = r.value.filter((k) => k.fieldCode !== I.fieldCode), l.value = l.value.filter((k) => k.id !== I.id), t.emit("remove", I.fieldCode); } function B() { var I; n.disabled ? e.value = !1 : e.value = ((I = s.value) == null ? void 0 : I.findIndex((k) => { var R; return k.value && !((R = k.value) != null && R.isEmpty()); })) > -1; } function U(I, k = []) { const R = JSON.stringify(I || []); R !== y && (t.emit("conditionChange", I), y = R, k.length === 0 && t.emit("query", I)); } function N() { var T; B(); const I = []; (s.value || []).map((x) => { x.required && (!x.value || x.value.isEmpty()) && I.push(x.fieldName || ""); }); const k = (T = s.value) == null ? void 0 : T.filter((x) => { var A; return x.value && !((A = x.value) != null && A.isEmpty()); }); if (I.length > 0) { u.warning({ message: p.require.replace("[fields]", I.join(",")), position: "top-center" }); return; } const R = c(k, l.value); U(R, I); } function P(I, k, R = !0) { M(I), V(k), R && N(); } function F(I) { I.value.clear(), r.value = r.value.filter((k) => k.fieldCode !== I.fieldCode), t.emit("clear", I.fieldCode), N(); } function j() { s.value.forEach((I) => I.value.clear()); } function O() { s.value.forEach((I) => { I.value.clear(); }), t.emit("reset"), N(), i.resizeFilerBar(); } return { clearAll: j, clearFilterItem: F, currentFilterId: v, filterFields: l, filterItems: s, fieldMap: d, loadFilterItems: P, removeFilterItem: S, reset: O, shouldShowClearButtonInFilterItem: b, handleQuery: N }; } function pt(n, t, e, i) { const r = w([]), l = te(), s = w(l.advancedFilter), v = w(ft(n.resetText)), d = w(!1), { clearAll: m, reset: f, filterItems: o } = e; function c() { r.value = o.value.filter((p) => p.isExtend); } c(); const g = $(() => r.value && r.value.length > 0); function a(p) { d.value = !0; } function u(p) { n.mode === "display-only" ? m() : f(); } return () => C("div", { class: "f-filter-toolbars" }, [g.value && C("button", { class: "btn btn-link", onClick: (p) => a() }, [s.value]), i.value && C("button", { class: "btn btn-link", onClick: (p) => u() }, [v.value])]); } const gt = { filterItem: { type: Object, default: null }, position: { type: Object, default: null }, /** * 位置参照元素 */ reference: { type: Object } }, vt = Object.assign({}, He), ht = /* @__PURE__ */ X({ name: "FFilterRadioGroup", props: vt, emits: ["update:modelValue", "change"], setup(n, t) { const e = w(), { dataSource: i, displayText: r, modelValue: l } = Ke(n, t); function s(v) { r.value = v.map((m) => m[n.textField]).join(n.separator); let d = ""; v.length === 1 ? d = v[0][n.valueField] : d = v.map((m) => m[n.valueField]).join(n.separator), l.value !== d && (l.value = d, t.emit("update:modelValue", l.value), t.emit("change", l.value)); } return () => C(et, { style: "margin: -2px -15px;padding: 0;", ref: e, idField: n.valueField, valueField: n.valueField, textField: n.textField, titleField: n.titleField, dataSource: i.value, selectedValues: l.value, multiSelect: !1, enableSearch: !1, onSelectionChange: (v) => { s(v); } }, null); } }), bt = /* @__PURE__ */ X({ name: "FFilterBarItemCondition", props: gt, emits: ["cancel", "confirm", "clearFilter"], setup(n, t) { const e = w(J(n.filterItem)), i = w(), r = te(), l = w("0px"), s = w("0px"), v = w("0px"), d = w("auto"), m = $(() => ({ left: d.value === "auto" ? "26px" : "auto", right: d.value })), f = $(() => ({ left: l.value, top: s.value })), o = $(() => ({ width: v.value === "0px" ? null : v.value, maxWidth: v.value === "0px" ? null : v.value })), c = w(), { useFilterItemsComposition: g, resolveEditorProps: a } = Z("useFilterItemsComposition"), { fieldMap: u } = g, { renderFieldConditionEditor: p, conditionChangeHandler: y } = ie("filter-bar"), b = w(""); let M = !1, V = {}; const S = w(!0); function B() { var W, Y; if (!n.reference || !c.value) return; const T = (W = n.reference) == null ? void 0 : W.getBoundingClientRect(); let x = (Y = c.value) == null ? void 0 : Y.getBoundingClientRect().width; const A = document.body.clientWidth - T.x - 30, L = document.body.clientWidth - T.y - 30; x > A && x > L && (x = Math.max(A, L)), T.left > document.body.clientWidth - x - 20 ? (l.value = T.left + T.width - x + "px", s.value = T.top + T.height + "px", d.value = "26px") : (l.value = T.left + "px", s.value = T.top + T.height + "px", d.value = "auto"), v.value = x + "px"; } function U(T, x, A, L) { M = !0, V = { value: x, editor: A, option: L }; } function N() { if (!i.value) return !1; const T = i.value.parentElement, x = Array.from(T.children); return x ? !!x.find((L) => !L || !L.classList ? !1 : L.classList.contains("popover") && L.style.visibility === "visible") : !1; } function P(T, x, A, L) { y(T, x, A, L), t.emit("confirm", e.value); } function F() { const { id: T, editor: x, needEmitChange: A } = p(u, e.value, U); if (b.value = "filter-panel--" + x.type, x.type === "radio-group") { const L = a(x.type, x); return S.value = !1, C(ht, je(L, { modelValue: e.value.value.value, "onUpdate:modelValue": (W) => e.value.value.value = W, onChange: (W) => { P(e.value, W, x); } }), { default: () => [G(" ")] }); } return C(Ye, { showLabelType: "force-none", id: T, key: T, editor: x, modelValue: e.value.value.value, "onUpdate:modelValue": (L) => e.value.value.value = L, onChange: (L, W) => { A && U(e.value, L, x, W); } }, null); } ee(() => { B(); }); function j(T) { const x = b.value.replace("filter-panel--", ""); ["input", "radio-group", "switch"].findIndex((A) => A === x) > -1 ? t.emit("cancel") : N() || t.emit("cancel"); } function O(T) { T.stopPropagation(), M && y(e.value, V.value, V.editor, V.option), t.emit("confirm", e.value); } function I(T) { e.value.value.clear(), T.stopPropagation(), t.emit("confirm", e.value); } function k() { const T = Xe(); return { zIndex: Math.max(T, 1050) }; } const R = k(); return () => C("div", { class: "f-filter-panel-wrapper can-close", ref: i, onClick: j, style: { zIndex: R } }, [C("div", { class: "f-filter-panel " + b.value, ref: c, style: f.value }, [C("div", { class: "f-filter-panel-inner", style: o.value, onClick: (T) => T.stopPropagation() }, [C("div", { class: "f-filter-panel-arrow", style: m.value }, null), F(), S.value && C("div", { class: "f-filter-panel-footer" }, [C("div", { class: "filter-panel-clear" }, [C("button", { class: "btn btn-link", onClick: I, style: "padding-left:0;" }, [r.clearAll])]), C("div", { class: "filter-panel-btns" }, [C("button", { class: "btn btn-secondary can-close", onClick: j }, [r.cancel]), C("button", { class: "filter-panel-submit btn btn-primary", onClick: O }, [r.confirm])])])])])]); } }), Fe = { filterItem: { type: Object, default: null }, disabled: { type: Boolean, default: !1 } }, yt = /* @__PURE__ */ X({ name: "FFilterBarItem", props: Fe, emits: ["confirm"], setup(n, t) { const e = w(n.filterItem), { useFilterItemsComposition: i } = Z("useFilterItemsComposition"), { clearFilterItem: r, currentFilterId: l, removeFilterItem: s, shouldShowClearButtonInFilterItem: v } = i, d = w(!1), m = w(!1), f = w(), o = w(""), c = w(), g = function() { return { "f-filter-item": !0, "f-state-disabled": n.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 === l.value || d.value }; }; $(() => !n.disabled && n.mode === "editable"); function a(S) { n.disabled || (n.mode === "display-only" ? s(e.value) : r(e.value)); } function u(S) { n.disabled || (d.value = !0); } function p() { d.value = !1; } function y() { c.value && c.value.scrollWidth > c.value.clientWidth ? o.value = c.value.innerHTML : o.value = ""; } function b(S) { d.value = !1, e.value.value = S.value, t.emit("confirm", S), ne(() => { y(); }); } function M() { m.value = n.disabled ? !1 : v(e.value); } function V() { m.value = !1; } return ee(() => { y(); }), () => C("div", { key: e.value.id, id: e.value.id, class: g(), onMouseenter: () => M(), onMouseleave: () => V() }, [C("div", { class: "f-filter-item-inner", ref: f, onClick: (S) => u() }, [e.value.required && C("span", { class: "f-filter-item-required text-danger" }, [G("*")]), C("span", { class: "f-filter-item-text" }, [e.value.fieldName]), !e.value.value.isEmpty() && C(ce, null, [C("span", { class: "f-filter-item-tip" }, [G(":")]), C("span", { class: "f-filter-item-content", ref: c, title: o.value }, [e.value.value.getDisplayText()])]), !n.disabled && C("span", { class: "f-filter-item-arrow f-icon f-icon-arrow-chevron-down" }, null)]), m.value && C("span", { class: "mr-3 f-filter-item-clear", onClick: (S) => a() }, [C("span", { class: "f-icon f-icon-close-circle" }, null)]), d.value && C(We, { to: "body" }, { default: () => [C(bt, { filterItem: e.value, reference: f.value, onConfirm: b, onCancel: p }, null)] })]); } }); function we(n, t) { const e = w(null), i = 15; let r = 0; function l(d = -1, m = -1) { var a; if (!n.value) return; const f = (a = n.value) == null ? void 0 : a.querySelector(".f-filter-list"); if (!f) return; const o = f.children; if (!o || o.length === 0 || (d < 0 && (d = n.value.clientWidth), r = m < 0 ? r : m, Math.abs(d - r) < i)) return; Array.from(o).forEach((u) => { u.style.display = "flex"; }), t.value = f.clientWidth < f.scrollWidth; let c = !1, g = 0; for (let u = 0; u < o.length; u++) { const p = o[u], y = Math.ceil(p.offsetWidth + (parseFloat(getComputedStyle(p).marginRight) || 0) + parseFloat(getComputedStyle(p).marginLeft)); !c && g + y <= d ? g += y : (p.style.display = "none", c = !0); } r = d; } function s() { var m, f; if (!n.value) return; (m = e.value) == null || m.unobserve(n.value); const d = ((f = n.value.querySelector(".f-filter-list")) == null ? void 0 : f.children) || []; Array.from(d).forEach((o) => { o.style.display = "flex"; }), r = 0; } function v() { if (!n.value) return; const d = new ResizeObserver((m) => { const f = m[0].contentRect.width; l(f); }); return d.observe(n.value), e.value = d, d; } return { setupWidthObserver: v, cancelWidthObserver: s, handleVisibleChildren: l }; } const D = /* @__PURE__ */ X({ name: "FFilterBar", props: re, emits: ["clear", "remove", "reset", "conditionChange", "change", "query"], setup(n, t) { const e = w(!1), i = w(!1), r = w(null), l = w(!1), s = w(0), v = we(r, i), { cancelWidthObserver: d, setupWidthObserver: m, handleVisibleChildren: f } = v, o = { resizeFilerBar: () => { e.value || ne(() => { f(-1, 0); }); } }, c = mt(n, t, l, o), { filterFields: g, filterItems: a, loadFilterItems: u, handleQuery: p } = c, { resolveEditorProps: y } = he(); ue("useFilterItemsComposition", { useFilterItemsComposition: c, resolveEditorProps: y }); const b = te(), M = $(() => { const O = { display: g.value && g.value.length ? "" : "none" }; return pe(O, n == null ? void 0 : n.customStyle); }); u(n.fields, n.defaultValues, !!(n.defaultValues && n.defaultValues.length > 0)), fe([() => n.defaultValues, () => n.fields], ([O, I]) => { u(I, O), s.value++, o.resizeFilerBar(); }), ee(() => { m(); }), me(() => { d(); }); const V = $(() => ({ "f-filter-list": !0, "f-filter-list-extend": e.value // 'f-utils-overflow-hidden': true })), S = $(() => ({ "extend-btn-arrow": !0, "f-icon": !0, "f-icon-arrow-chevron-up": e.value, "f-icon-arrow-chevron-down": !e.value })), B = $(() => !e.value && i.value); function U() { e.value = !e.value, e.value ? d() : m(); } const N = pt(n, t, c, l); function P(O) { t.emit("change", O), p(), o.resizeFilerBar(); } function F() { return C("div", { class: V.value, key: n.id + "-main-" + s.value }, [a.value.map((O, I) => !O.isExtend && C(yt, { filterItem: O, onConfirm: P, disabled: n.disabled || O.disabled }, null)), e.value && N()]); } function j() { return B.value && C("div", { class: "f-filter-list-ellipsis", onClick: (O) => U() }, [G("...")]); } return () => C("div", { class: "f-filter-wrapper " + n.customClass, style: M.value }, [C("div", { class: "f-filter-wrapper-inner f-utils-fill" }, [C("div", { class: "f-filter-main f-utils-fill" }, [C("div", { class: "f-filter-list-wrapper flex-fill", ref: r }, [F()]), j(), !e.value && N()]), i.value && C("div", { class: "f-filter-extend-btn" }, [C("button", { class: "btn btn-link", onClick: U }, [C("span", { class: "extend-btn-text" }, [e.value ? b.fold : b.expand]), C("span", { class: S.value }, null)])])])]); } }); function Ct(n, t) { w([]); const e = w([]), i = w([]), r = w(""); w(!1), w(n.mode); const l = /* @__PURE__ */ new Map(), { convertToControls: s } = ie("filter-bar"), { fieldToCondition: v } = ge(); function d(c) { return !c.value.isEmpty(); } function m(c) { e.value = J(c), e.value.reduce((g, a) => (g.set(a.labelCode, a), g), l); } function f(c) { i.value = e.value.map((g) => v(g)); } function o(c, g) { m(c), f(); } return o(n.fields), { currentFilterId: r, filterFields: e, filterItems: i, fieldMap: l, loadFilterItems: o, shouldShowClearButtonInFilterItem: d }; } function Ft(n, t, e) { const i = w([]), r = w("更多筛选"), { filterItems: l } = e; function s() { i.value = l.value.filter((d) => d.isExtend); } s(); const v = $(() => i.value && i.value.length > 0); return () => C("div", { class: "f-filter-toolbars" }, [v.value && C("button", { class: "btn btn-link" }, [r.value])]); } const wt = /* @__PURE__ */ X({ name: "FFilterBarItemDesign", props: Fe, emits: ["confirm"], setup(n, t) { const e = w(n.filterItem), { useFilterItemsComposition: i } = Z("useFilterItemsComposition"), { currentFilterId: r, shouldShowClearButtonInFilterItem: l } = i, s = w(n.disabled), v = 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 () => C("div", { key: e.value.id, id: e.value.id, class: v() }, [C("div", { class: "f-filter-item-inner" }, [e.value.required && C("span", { class: "f-filter-item-required text-danger" }, [G("*")]), C("span", { class: "f-filter-item-text" }, [e.value.fieldName]), e.value.value.getDisplayText() && C(ce, null, [C("span", { class: "f-filter-item-tip" }, [G(":")]), C("span", { class: "f-filter-item-content" }, [e.value.value.getDisplayText()])]), !s.value && C("span", { class: "f-filter-item-arrow f-icon f-icon-arrow-chevron-down" }, null)]), l(e.value) && C("span", { class: "mr-3 f-filter-item-clear" }, [C("span", { class: "f-icon f-icon-close-circle" }, null)])]); } }); function It(n) { const { formSchemaUtils: t, formStateMachineUtils: e } = n; function i(d, m = "") { return { path: m + d.code, field: d.id, fullPath: d.code }; } function r(d, m = "") { const f = t.getViewModelById(d); return f ? f.states.map((o) => i(o, m)) : []; } function l(d) { const m = t.getRootViewModelId(), f = r(d); if (d === m) return f; const o = r(m, "root-component."); return [...f, ...o]; } function s(d) { return d.binding && d.binding.path || d.id || ""; } function v() { return e && e.getRenderStates() || []; } return { getVariables: l, getControlName: s, getStateMachines: v }; } class Et { constructor(t) { 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", (t, e) => ({ convertFrom: (i, r, l, s) => { const v = l.getExpressionRuleValue(t, e || r); return v && v.value || ""; }, convertTo: (i, r, l, s, v) => { var d; if (r === "dataPicking" && (l != null && l.target)) { const m = `${l.target}_dataPicking`; ((d = l.rules) == null ? void 0 : d.some( (o) => o.id === m && o.value )) ? i.dictPickingExpressionId = m : delete i.dictPickingExpressionId; } s.updateExpression(l); } })); this.formSchemaService = t; } getExpressionRule(t, e) { const i = this.getExpressionData(); if (!i) return ""; const r = i.find((s) => s.target === t); if (!r) return ""; const l = r.rules.find((s) => s.type === e); return l || ""; } // 获取上下文表单变量 getContextFormVariables() { const { module: t } = this.formSchemaService.getFormSchema(); if (!t.viewmodels || t.viewmodels.length === 0) return []; const e = this.formSchemaService.getRootViewModelId(), i = this.formSchemaService.getViewModelById(e); if (!i || !i.states || i.states.length === 0) return []; const r = []; return i.states.filter((l) => l.category === "remote").forEach((l) => { r.push({ key: l.code, name: l.name, description: l.name, category: l.category }); }), r; } createTreeNode(t, e, i = "label") { return { id: t.id, name: t.name, bindingPath: t[i], parents: e, type: "field" }; } buildEntityFieldsTreeData(t = null, e) { const i = []; return t == null || t.forEach((r) => { var v; const l = this.createTreeNode(r, e); let s = []; (v = r.type) != null && v.fields && (s = this.buildEntityFieldsTreeData(r.type.fields, [...e, r.label])), i.push({ data: l, children: s, expanded: !0 }); }), i; } buildChildEntityTreeData(t = null, e) { const i = []; return t == null || t.forEach((r) => { var d, m; const l = this.createTreeNode(r, e); l.type = "entity"; const s = this.buildEntityFieldsTreeData((d = r.type) == null ? void 0 : d.fields, [...e, r.label]), v = this.buildChildEntityTreeData((m = r.type) == null ? void 0 : m.entities, [...e, r.label]); v != null && v.length && (s == null || s.push(...v)), i.push({ data: l, children: s || [], // 空值回退 expanded: !0 }); }), i; } getEntitiesTreeData() { const t = this.formSchemaService.getSchemaEntities(); if (!(t != null && t.length)) return []; const e = t[0]; if (!(e != null && e.type)) return []; const i = this.buildEntityFieldsTreeData(e.type.fields, [e.code]), r = this.buildChildEntityTreeData(e.type.entities, [e.code]); return r != null && r.length && (i == null || i.push(...r)), { entityCode: e.code, fields: [{ data: this.createTreeNode(e, [], "code"), children: i || [] }] }; } getEntitiesAndVariables() { return { entities: this.getEntitiesTreeData(), variables: { session: { name: "系统变量", items: this.sessionVariables, visible: !1 }, forms: { name: "表单变量", items: this.getContextFormVariables(), visible: !0 } } }; } onBeforeOpenExpression(t, e, i) { const r = i === "Field" ? t.binding.field : t.id, l = this.getExpressionRule(r, e), s = this.getEntitiesAndVariables(), v = { message: ["validate", "required", "dataPicking"].includes(e) && l ? l.message : "", ...s }; return l.messageType != null && (v.messageType = l.messageType), v; } buildRule(t, e, i, r) { const { expression: l, message: s, messageType: v } = e, d = { id: `${t}_${i}`, type: i, value: l }; return (i === "validate" || i === "dataPicking" || i === "required") && (d.message = s), i === "dataPicking" && (d.messageType = v), i === "validate" && r && (d.elementId = r), d; } getExpressionData() { const { expressions: t } = this.formSchemaService.getFormSchema().module; return t || []; } updateExpression(t, e, i, r) { const l = e === "Field" ? t.binding.field : t.id, s = this.buildRule(l, i, r, t.type === "form-group" ? t.id : ""); let d = this.getExpressionData().find((f) => f.targetType === e && f.target === l); const m = (f) => f.value.trim() === ""; if (d) { const f = d.rules.find((o) => o.id === s.id); if (f) m(s) ? d.rules = d.rules.filter((o) => o.id !== s.id) : (Object.assign(f, s), r === "validate" && t.type === "form-group" && (f.elementId = t.id)); else { if (m(s)) return null; d.rules = d.rules || [], d.rules.push(s); } } else { if (m(s)) return null; d = { target: `${l}`, rules: [s], targetType: e }; } return d; } getExpressionEditorOptions(t, e, i, r) { return i.reduce((l, s) => { var d, m; const v = e === "Field" ? (d = t == null ? void 0 : t.binding) == null ? void 0 : d.field : t.id; return l[s] = { hide: e === "Field" ? !!((m = t == null ? void 0 : t.binding) != null && m.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(t, s, e), onSubmitModal: (f) => { const o = this.updateExpression(t, e, f, s); if (r) { const c = this.buildRule(v, f, s); r(c); } return o; } } }, l; }, {}); } getExpressionInfo(t, e, i) { const r = e === "Field" ? t.binding.field : t.id, l = this.getExpressionRule(r, i), s = { value: l && l.value, targetId: r, targetType: e, expressionType: i }; return l && l.message && (s.message = l.message), s; } getExpressionConfig(t, e, i = ["compute", "dependency", "validate"], r) { return { description: "表达式", title: "表达式", hide: !t.binding, properties: { ...this.getExpressionEditorOptions(t, e, i, r) } }; } getExpressionOptions(t, e, i) { const r = this.getExpressionInfo(t, e, i); return { dialogTitle: `${this.expressionNames[i] || "表达式"}编辑器`, singleExpand: !1, showMessage: i === "required", beforeOpen: () => this.onBeforeOpenExpression(t, i, e), expressionInfo: r }; } } class xt { constructor(t, 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 i; this.componentId = t, this.designerHostService = e, this.eventsEditorUtils = e.eventsEditorUtils, this.formSchemaUtils = e.formSchemaUtils, this.formMetadataConverter = e.formMetadataConverter, this.viewModelId = ((i = this.formSchemaUtils) == null ? void 0 : i.getViewModelIdByComponentId(t)) || "", this.designViewModelUtils = e.designViewModelUtils, this.controlCreatorUtils = e.controlCreatorUtils, this.metadataService = e.metadataService, this.schemaService = e.schemaService, this.designerContext = e.designerContext, this.modalService = e.modalService, this.expressionProperty = new Et(this.formSchemaUtils); } getFormDesignerInstance() { var t, e; return (e = (t = this.designerContext) == null ? void 0 : t.instances) == null ? void 0 : e.formDesigner.value; } getTableInfo() { var t; return (t = this.schemaService) == null ? void 0 : t.getTableInfoByViewModelId(this.viewModelId); } setDesignViewModelField(t) { var i; const e = t.binding && t.binding.type === "Form" && t.binding.field; if (e) { if (!this.designViewModelField) { const r = this.designViewModelUtils.getDgViewModel(this.viewModelId); this.designViewModelField = r.fields.find((l) => l.id === e); } t.updateOn = (i = this.designViewModelField) == null ? void 0 : i.updateOn; } } getBasicPropConfig(t) { return { description: "Basic Information", title: "基本信息", properties: { id: { description: "组件标识", title: "标识", type: "string", readonly: !0 }, type: { description: "组件类型", title: "控件类型", type: "select", editor: { type: "combo-list", textField: "name", valueField: "value", idField: "value", editable: !1, data: [{ value: t.type, name: h[t.type] && h[t.type].name }] } } } }; } getAppearanceConfig(t = null, e = {}, i) { const r = { title: "外观", description: "Appearance" }, l = { 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) l[s] = Object.assign(l[s] || {}, e[s]); return { ...r, properties: { ...l }, setPropertyRelates(s, v) { if (s) { switch (s && s.propertyID) { case "class": case "style": { H.value++; break; } } i && i(s, t, v); } } }; } /** * * @param propertyData * @param propertyTypes * @param propertyName * @param constInfos * @param variableInfos * @param expressionType 指定表达式类型,存在属性和表达式类型不一致的情况 * @returns */ getPropertyEditorParams(t, e = [], i = "visible", r = {}, l = {}, s = "") { const { getVariables: v, getControlName: d, getStateMachines: m } = It(this.designerHostService), f = this.getRealTargetType(t), o = e && e.length > 0 ? e : ["Const", "Variable", "StateMachine", "Expression"], c = { type: "property-editor", propertyTypes: o }; return o.map((g) => { switch (g) { case "Const": Object.assign(c, { constType: "enum", constEnums: [{ id: !0, name: "是" }, { id: !1, name: "否" }] }, r); break; case "Expression": c.expressionConfig = this.getExpressionOptions(t, f, s || i); break; case "StateMachine": c.stateMachines = m(); break; case "Variable": Object.assign(c, { controlName: d(t), newVariablePrefix: "is", newVariableType: "Boolean", variables: v(this.viewModelId), parentComponentId: this.componentId === "root-component" ? "" : "root-component", onBeforeOpenVariables: (a) => { a.value = v(this.viewModelId); } }, l), this.designerContext.designerMode === "PC_RTC" && (c.newVariablePrefix = "ext_" + c.newVariablePrefix); break; } }), c; } getVisibleProperty(t, e = "") { var l; let i = ["Const", "Variable", "StateMachine", "Expression"]; return e === "gridFieldEditor" ? i = ["Const", "Expression"] : e === "form-group" && !((l = t.binding) != null && l.field) && (i = ["Const", "Variable", "StateMachine"]), { visible: { title: "是否可见", type: "boolean", description: "运行时组件是否可见", editor: this.getPropertyEditorParams(t, i, "visible") } }; } /** * 获取行为 * @param propertyData * @param viewModelId * @returns */ getBehaviorConfig(t, e = "", i = {}, r) { const l = { title: "行为", description: "" }, s = this.getVisibleProperty(t, e); for (const d in i) s[d] = Object.assign(s[d] || {}, i[d]); const v = this; return { ...l, properties: { ...s }, setPropertyRelates(d, m) { if (d) { switch (d.propertyID) { case "disabled": case "readonly": case "visible": v.afterMutilEditorChanged(t, d); break; } r && r(d, m); } } }; } /** * 当多值编辑器变更时 * @param propertyData * @param changeObject */ afterMutilEditorChanged(t, e) { this.addNewVariableToViewModel(e, this.viewModelId), this.updateExpressionValue(e, t), this.clearExpression(e, t); } /** * * @param propertyId * @param componentInstance * @returns */ updateElementByParentContainer(t, e) { const i = e && e.parent && e.parent.schema; if (!i) return; const r = i.contents.findIndex((s) => s.id === t), l = J(i.contents[r]); i.contents.splice(r, 1), i.contents.splice(r, 0, l), ze(); } /** * 属性编辑器,在编辑过程中会新增变量,此处需要将新增的变量追加到ViewModel中 * @param changeObject * @param viewModelId * @returns */ addNewVariableToViewModel(t, e) { const i = t.propertyValue; if (!(i && typeof i == "object") || !(i.type === "Variable" && i.isNewVariable)) return; const s = { id: i.field, category: "locale", code: i.fullPath, name: i.fullPath, type: i.newVariableType || "String", isRtcVariable: this.designerContext.designerMode === "PC_RTC" ? !0 : void 0 }; delete i.newVariableType, delete i.isNewVariable, this.formSchemaUtils.getVariableByCode(s.code) || this.formSchemaUtils.getViewModelById("root-viewmodel").states.push(s); } getExpressions() { let t = []; return this.formRule ? (this.formRule.expressions = this.formRule.expressions || [], t = this.formRule.expressions || []) : t = this.formSchemaUtils.getExpressions(), t; } /** * 更新表达式到expressions节点 * @param changeObject */ updateExpressionValue(t, e) { const i = t.propertyValue; if (!((i && i.type) === "Expression" && i.expressionInfo)) return; const { expressionId: s, expressionInfo: v } = i, { targetId: d, targetType: m, expressionType: f, value: o, message: c } = v, g = this.getExpressions(); let a = g.find((p) => p.target === d); a || (a = { target: d, rules: [], targetType: m }, g.push(a)); const u = a.rules.find((p) => p.type === f); if (u) u.value = o, u.message = c, (f === "minDate" || f === "maxDate" || f === "defaultTime") && (u.elementId = e.id); else { const p = { id: s, type: f, value: o, message: c, elementId: e.id }; a.rules.push(p); } delete i.expressionInfo; } /** * 属性类型切换为非表达式后,清除原表达式 * @param changeObject * @param propertyData * @returns */ clearExpression(t, e) { const i = t.propertyValue; if (i && i.type === "Expression") return; const l = t.propertyID, s = this.getExpressions(), v = e.binding ? e.binding.field : e.id, d = s.find((m) => m.target === v); !d || !d.rules || (d.rules = d.rules.filter((m) => m.type !== l)); } getExpressionOptions(t, e, i) { return this.expressionProperty.getExpressionOptions(t, e, i); } getRealTargetType(t) { return ["response-toolbar-item", "tab-toolbar-item", "section-toolbar-item", "drawer-toolbar-item"].indexOf(t.type) > -1 ? "Button" : t.binding && t.binding.field ? "Field" : "Container"; } createBaseEventProperty(t) { const e = {}; return e[this.viewModelId] = { type: "events-editor", editor: { initialData: t, viewSourceHandle: (i) => { var r; ((r = i.controller) == null ? void 0 : r.label.indexOf(this.formSchemaUtils.getModule().code)) > -1 && this.eventsEditorUtils.jumpToMethod(i); } } }, e; } } const z = class z { /** * 根据绑定字段类型获取可用的输入类控件 */ static getEditorTypesByMDataType(t, e = !1, i = "") { if (e) return [{ key: h["language-textbox"].type, value: h["language-textbox"].name }]; let r = z.fieldControlTypeMapping[t]; if (i === "data-grid-column" && (r != null && r.length)) { const l = [h["check-group"].type, h["radio-group"].type, h.image.type, h["rich-text-editor"].type]; r = r.filter((s) => !l.includes(s.key)); } return r; } /** * 获取所有输入类控件 */ static getAllInputTypes() { const t = []; for (const e in z.fieldControlTypeMapping) z.fieldControlTypeMapping[e].forEach((i) => { t.find((r) => r.key === i.key && r.value === i.value) || t.push({ key: i.key, value: i.value }); }); return t; } /** * 提供schema字段基础属性和DOM控件属性的映射 * @param control 控件元数据 */ static mappingDomPropAndSchemaProp(t, e) { var l; const i = (l = t.editor) == null ? void 0 : l.type, r = []; return (t.type === h["data-grid-column"].type || t.type === h["tree-grid-column"].type) && e && e.categoryId && e.categoryId.indexOf("gridFieldEditor") < 0 && r.push({ domField: "title", schemaField: "name" }), r.push({ domField: "label", schemaField: "name" }), r.push({ domField: "editor.required", schemaField: "require" }), r.push({ domField: "editor.readonly", schemaField: "readonly" }), (i === h["input-group"].type || i === h.textarea.type || i === h["number-spinner"].type) && r.push({ domField: "editor.maxLength", schemaField: "type.length" }), i === h["number-spinner"].type && r.push({ domField: "editor.precision", schemaField: "type.precision" }), (t.type === h["data-grid-column"].type || t.type === h["tree-grid-column"].type) && r.push({ domField: "formatter.precision", schemaField: "type.precision" }), (i === h["combo-list"].type || i === h["radio-group"].type) && r.push({ domField: "editor.data", schemaField: "type.enumValues" }), (t.type === h["data-grid-column"].type || t.type === h["tree-grid-column"].type) && r.push({ domField: "formatter.data", schemaField: "type.enumValues" }), i === h["date-picker"].type && (r.push({ domField: "editor.displayFormat", schemaField: "editor.format" }), r.push({ domField: "editor.fieldType", schemaField: "type.name" })), i === h["number-spinner"].type && (r.push({ domField: "editor.max", schemaField: "editor.maxValue" }), r.push({ domField: "editor.min", schemaField: "editor.minValue" })), i === h.lookup.type && (r.push({ domField: "editor.dataSource", schemaField: "editor.dataSource" }), r.push({ domField: "editor.valueField", schemaField: "editor.valueField" }), r.push({ domField: "editor.textField", schemaField: "editor.textField" }), r.push({ domField: "editor.displayType", schemaField: "editor.displayType" }), r.push({ domField: "editor.mapFields", schemaField: "editor.mapFields" }), r.push({ domField: "editor.helpId", schemaField: "editor.helpId" })), r.push({ domField: "path", schemaField: "bindingPath" }), r.push({ domField: "binding.path", schemaField: "bindingField" }), r.push({ domField: "binding.fullPath", schemaField: "path" }), (t.type === h["data-grid-column"].type || t.type === h["tree-grid-column"].type) && r.push({ domField: "field", schemaField: "bindingPath" }), r; } }; /** * <字段类型,可配