UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,388 lines 131 kB
var gt = Object.defineProperty; var yt = (n, t, e) => t in n ? gt(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e; var B = (n, t, e) => yt(n, typeof t != "symbol" ? t + "" : t, e); import { radioCheckboxCommonProps as bt, FormSchemaEntityField$Type as Be, FormSchemaEntityFieldType$Type as Ve, isMobilePhone as Ct, getMaxZIndex as Se, useGuid as we, withInstall as wt } from "../../components/common/index.esm.js"; import { resolveAppearance as xt, createPropsResolver as Re, getPropsResolverGenerator as Oe } from "../../components/dynamic-resolver/index.esm.js"; import Et, { radioGroupProps as Le } from "../../components/radio-group/index.esm.js"; import { computed as S, nextTick as ne, defineComponent as J, ref as h, inject as ce, onMounted as Z, createVNode as v, Teleport as Ne, createApp as xe, onUnmounted as pe, Fragment as le, watch as K, onBeforeMount as Mt, watchEffect as It, Transition as ze, shallowRef as Ft, render as ye, h as kt, cloneVNode as Bt, mergeProps as Ee, withDirectives as be, vShow as St, onUpdated as Tt, onBeforeUnmount as Pt, createTextVNode as ee, reactive as Vt, vModelText as Te } from "vue"; import { DgControl as C, canvasChanged as ue, refreshCanvas as Rt, useDesignerComponent as Ot } from "../../components/designer-canvas/index.esm.js"; import { cloneDeep as He, debounce as Lt } from "lodash-es"; import { LocaleService as ie } from "../../components/locale/index.esm.js"; import "../../components/property-panel/index.esm.js"; import Nt from "../../components/tags/index.esm.js"; import zt from "../../components/popover/index.esm.js"; import Ht from "../../components/data-grid/index.esm.js"; import { FNotifyService as At } from "../../components/notify/index.esm.js"; const $t = { ...bt, /** * 组件标识 */ id: String, /** * 禁用组件,不允许切换单选值 */ disabled: { type: Boolean, default: !1 }, /** * 功能同disabled */ readonly: { type: Boolean, default: !1 }, /** * 单选组枚举数组----废弃 */ enumData: { type: Array }, /** * 单选组枚举数组 */ data: { type: Array }, /** * 组件值 */ modelValue: { type: String, default: "" }, /** * 组件名称 */ name: { type: String, default: "" }, /** * 输入框Tab键索引 */ tabIndex: { type: Number, default: -1 }, /** * 枚举数组中展示文本的key值。 */ textField: { type: String, default: "name" }, /** * 枚举数组中枚举值的key值。 */ valueField: { type: String, default: "value" } }; function Ut(n, t, e) { const o = S(() => !n.disabled), i = S(() => n.data || n.enumData || n.options || []); function l(r) { return r[n.valueField]; } function a(r) { return r[n.textField]; } function s(r, d) { if (o.value) { const c = l(r); e.value !== c && (e.value = c, t.emit("change", c), t.emit("changeValue", c), t.emit("update:modelValue", c)); } d.stopPropagation(); } return { enumData: i, getValue: l, getText: a, onClickRadio: s }; } function Wt(n) { const { formSchemaUtils: t, formStateMachineUtils: e } = n; function o(r, d = "") { return { path: d + r.code, field: r.id, fullPath: r.code }; } function i(r, d = "") { const c = t.getViewModelById(r); return c ? c.states.map((u) => o(u, d)) : []; } function l(r) { const d = t.getRootViewModelId(), c = i(r); if (r === d) return c; const u = i(d, "root-component."); return [...c, ...u]; } function a(r) { return r.binding && r.binding.path || r.id || ""; } function s() { return e && e.getRenderStates() || []; } return { getVariables: l, getControlName: a, getStateMachines: s }; } class jt { constructor(t) { B(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'" } ]); B(this, "expressionNames", { compute: "计算表达式", dependency: "依赖表达式", validate: "验证表达式", dataPicking: "帮助前表达式", visible: "可见表达式", readonly: "只读表达式", required: "必填表达式" }); B(this, "getExpressionConverter", (t, e) => ({ convertFrom: (o, i, l, a) => { const s = l.getExpressionRuleValue(t, e || i); return s && s.value || ""; }, convertTo: (o, i, l, a, s) => { var r; if (i === "dataPicking" && (l != null && l.target)) { const d = `${l.target}_dataPicking`; ((r = l.rules) == null ? void 0 : r.some( (u) => u.id === d && u.value )) ? o.dictPickingExpressionId = d : delete o.dictPickingExpressionId; } a.updateExpression(l); } })); this.formSchemaService = t; } getExpressionRule(t, e) { const o = this.getExpressionData(); if (!o) return ""; const i = o.find((a) => a.target === t); if (!i) return ""; const l = i.rules.find((a) => a.type === e); return l || ""; } // 获取上下文表单变量 getContextFormVariables() { const { module: t } = this.formSchemaService.getFormSchema(); if (!t.viewmodels || t.viewmodels.length === 0) return []; const e = this.formSchemaService.getRootViewModelId(), o = this.formSchemaService.getViewModelById(e); if (!o || !o.states || o.states.length === 0) return []; const i = []; return o.states.filter((l) => l.category === "remote").forEach((l) => { i.push({ key: l.code, name: l.name, description: l.name, category: l.category }); }), i; } createTreeNode(t, e, o = "label") { return { id: t.id, name: t.name, bindingPath: t[o], parents: e, type: "field" }; } buildEntityFieldsTreeData(t = null, e) { const o = []; return t == null || t.forEach((i) => { var s; const l = this.createTreeNode(i, e); let a = []; (s = i.type) != null && s.fields && (a = this.buildEntityFieldsTreeData(i.type.fields, [...e, i.label])), o.push({ data: l, children: a, expanded: !0 }); }), o; } buildChildEntityTreeData(t = null, e) { const o = []; return t == null || t.forEach((i) => { var r, d; const l = this.createTreeNode(i, e); l.type = "entity"; const a = this.buildEntityFieldsTreeData((r = i.type) == null ? void 0 : r.fields, [...e, i.label]), s = this.buildChildEntityTreeData((d = i.type) == null ? void 0 : d.entities, [...e, i.label]); s != null && s.length && (a == null || a.push(...s)), o.push({ data: l, children: a || [], // 空值回退 expanded: !0 }); }), o; } getEntitiesTreeData() { const t = this.formSchemaService.getSchemaEntities(); if (!(t != null && t.length)) return []; const e = t[0]; if (!(e != null && e.type)) return []; const o = this.buildEntityFieldsTreeData(e.type.fields, [e.code]), i = this.buildChildEntityTreeData(e.type.entities, [e.code]); return i != null && i.length && (o == null || o.push(...i)), { entityCode: e.code, fields: [{ data: this.createTreeNode(e, [], "code"), children: o || [] }] }; } getEntitiesAndVariables() { return { entities: this.getEntitiesTreeData(), variables: { session: { name: "系统变量", items: this.sessionVariables, visible: !1 }, forms: { name: "表单变量", items: this.getContextFormVariables(), visible: !0 } } }; } onBeforeOpenExpression(t, e, o) { const i = o === "Field" ? t.binding.field : t.id, l = this.getExpressionRule(i, e), a = this.getEntitiesAndVariables(), s = { message: ["validate", "required", "dataPicking"].includes(e) && l ? l.message : "", ...a }; return l.messageType != null && (s.messageType = l.messageType), s; } buildRule(t, e, o, i) { const { expression: l, message: a, messageType: s } = e, r = { id: `${t}_${o}`, type: o, value: l }; return (o === "validate" || o === "dataPicking" || o === "required") && (r.message = a), o === "dataPicking" && (r.messageType = s), o === "validate" && i && (r.elementId = i), r; } getExpressionData() { const { expressions: t } = this.formSchemaService.getFormSchema().module; return t || []; } updateExpression(t, e, o, i) { const l = e === "Field" ? t.binding.field : t.id, a = this.buildRule(l, o, i, t.type === "form-group" ? t.id : ""); let r = this.getExpressionData().find((c) => c.targetType === e && c.target === l); const d = (c) => c.value.trim() === ""; if (r) { const c = r.rules.find((u) => u.id === a.id); if (c) d(a) ? r.rules = r.rules.filter((u) => u.id !== a.id) : (Object.assign(c, a), i === "validate" && t.type === "form-group" && (c.elementId = t.id)); else { if (d(a)) return null; r.rules = r.rules || [], r.rules.push(a); } } else { if (d(a)) return null; r = { target: `${l}`, rules: [a], targetType: e }; } return r; } getExpressionEditorOptions(t, e, o, i) { return o.reduce((l, a) => { var r, d; const s = e === "Field" ? (r = t == null ? void 0 : t.binding) == null ? void 0 : r.field : t.id; return l[a] = { hide: e === "Field" ? !!((d = t == null ? void 0 : t.binding) != null && d.field) : !1, description: "", title: this.expressionNames[a], type: "string", $converter: this.getExpressionConverter(s), refreshPanelAfterChanged: !0, editor: { type: "expression-editor", singleExpand: !1, dialogTitle: `${this.expressionNames[a]}编辑器`, showMessage: a === "validate" || a === "dataPicking" || a === "required", showMessageType: a === "dataPicking", beforeOpen: () => this.onBeforeOpenExpression(t, a, e), onSubmitModal: (c) => { const u = this.updateExpression(t, e, c, a); if (i) { const y = this.buildRule(s, c, a); i(y); } return u; } } }, l; }, {}); } getExpressionInfo(t, e, o) { const i = e === "Field" ? t.binding.field : t.id, l = this.getExpressionRule(i, o), a = { value: l && l.value, targetId: i, targetType: e, expressionType: o }; return l && l.message && (a.message = l.message), a; } getExpressionConfig(t, e, o = ["compute", "dependency", "validate"], i) { return { description: "表达式", title: "表达式", hide: !t.binding, properties: { ...this.getExpressionEditorOptions(t, e, o, i) } }; } getExpressionOptions(t, e, o) { const i = this.getExpressionInfo(t, e, o); return { dialogTitle: `${this.expressionNames[o] || "表达式"}编辑器`, singleExpand: !1, showMessage: o === "required", beforeOpen: () => this.onBeforeOpenExpression(t, o, e), expressionInfo: i }; } } class qt { constructor(t, e) { B(this, "componentId"); B(this, "viewModelId"); B(this, "eventsEditorUtils"); B(this, "formSchemaUtils"); B(this, "formMetadataConverter"); B(this, "designViewModelUtils"); B(this, "designViewModelField"); B(this, "controlCreatorUtils"); B(this, "designerHostService"); B(this, "designerContext"); B(this, "modalService", null); /** 表单规则 */ B(this, "formRule", null); B(this, "schemaService", null); B(this, "metadataService", null); B(this, "propertyConfig", { type: "object", categories: {} }); B(this, "expressionProperty"); var o; this.componentId = t, this.designerHostService = e, this.eventsEditorUtils = e.eventsEditorUtils, this.formSchemaUtils = e.formSchemaUtils, this.formMetadataConverter = e.formMetadataConverter, this.viewModelId = ((o = this.formSchemaUtils) == null ? void 0 : o.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 jt(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 o; const e = t.binding && t.binding.type === "Form" && t.binding.field; if (e) { if (!this.designViewModelField) { const i = this.designViewModelUtils.getDgViewModel(this.viewModelId); this.designViewModelField = i.fields.find((l) => l.id === e); } t.updateOn = (o = this.designViewModelField) == null ? void 0 : o.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: C[t.type] && C[t.type].name }] } } } }; } getAppearanceConfig(t = null, e = {}, o) { const i = { 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 a in e) l[a] = Object.assign(l[a] || {}, e[a]); return { ...i, properties: { ...l }, setPropertyRelates(a, s) { if (a) { switch (a && a.propertyID) { case "class": case "style": { ue.value++; break; } } o && o(a, t, s); } } }; } /** * * @param propertyData * @param propertyTypes * @param propertyName * @param constInfos * @param variableInfos * @param expressionType 指定表达式类型,存在属性和表达式类型不一致的情况 * @returns */ getPropertyEditorParams(t, e = [], o = "visible", i = {}, l = {}, a = "") { const { getVariables: s, getControlName: r, getStateMachines: d } = Wt(this.designerHostService), c = this.getRealTargetType(t), u = e && e.length > 0 ? e : ["Const", "Variable", "StateMachine", "Expression"], y = { type: "property-editor", propertyTypes: u }; return u.map((m) => { switch (m) { case "Const": Object.assign(y, { constType: "enum", constEnums: [{ id: !0, name: "是" }, { id: !1, name: "否" }] }, i); break; case "Expression": y.expressionConfig = this.getExpressionOptions(t, c, a || o); break; case "StateMachine": y.stateMachines = d(); break; case "Variable": Object.assign(y, { controlName: r(t), newVariablePrefix: "is", newVariableType: "Boolean", variables: s(this.viewModelId), parentComponentId: this.componentId === "root-component" ? "" : "root-component", onBeforeOpenVariables: (f) => { f.value = s(this.viewModelId); } }, l), this.designerContext.designerMode === "PC_RTC" && (y.newVariablePrefix = "ext_" + y.newVariablePrefix); break; } }), y; } getVisibleProperty(t, e = "") { var l; let o = ["Const", "Variable", "StateMachine", "Expression"]; return e === "gridFieldEditor" ? o = ["Const", "Expression"] : e === "form-group" && !((l = t.binding) != null && l.field) && (o = ["Const", "Variable", "StateMachine"]), { visible: { title: "是否可见", type: "boolean", description: "运行时组件是否可见", editor: this.getPropertyEditorParams(t, o, "visible") } }; } /** * 获取行为 * @param propertyData * @param viewModelId * @returns */ getBehaviorConfig(t, e = "", o = {}, i) { const l = { title: "行为", description: "" }, a = this.getVisibleProperty(t, e); for (const r in o) a[r] = Object.assign(a[r] || {}, o[r]); const s = this; return { ...l, properties: { ...a }, setPropertyRelates(r, d) { if (r) { switch (r.propertyID) { case "disabled": case "readonly": case "visible": s.afterMutilEditorChanged(t, r); break; } i && i(r, d); } } }; } /** * 当多值编辑器变更时 * @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 o = e && e.parent && e.parent.schema; if (!o) return; const i = o.contents.findIndex((a) => a.id === t), l = He(o.contents[i]); o.contents.splice(i, 1), o.contents.splice(i, 0, l), Rt(); } /** * 属性编辑器,在编辑过程中会新增变量,此处需要将新增的变量追加到ViewModel中 * @param changeObject * @param viewModelId * @returns */ addNewVariableToViewModel(t, e) { const o = t.propertyValue; if (!(o && typeof o == "object") || !(o.type === "Variable" && o.isNewVariable)) return; const a = { id: o.field, category: "locale", code: o.fullPath, name: o.fullPath, type: o.newVariableType || "String", isRtcVariable: this.designerContext.designerMode === "PC_RTC" ? !0 : void 0 }; delete o.newVariableType, delete o.isNewVariable, this.formSchemaUtils.getVariableByCode(a.code) || this.formSchemaUtils.getViewModelById("root-viewmodel").states.push(a); } 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 o = t.propertyValue; if (!((o && o.type) === "Expression" && o.expressionInfo)) return; const { expressionId: a, expressionInfo: s } = o, { targetId: r, targetType: d, expressionType: c, value: u, message: y } = s, m = this.getExpressions(); let f = m.find((I) => I.target === r); f || (f = { target: r, rules: [], targetType: d }, m.push(f)); const b = f.rules.find((I) => I.type === c); if (b) b.value = u, b.message = y, (c === "minDate" || c === "maxDate" || c === "defaultTime") && (b.elementId = e.id); else { const I = { id: a, type: c, value: u, message: y, elementId: e.id }; f.rules.push(I); } delete o.expressionInfo; } /** * 属性类型切换为非表达式后,清除原表达式 * @param changeObject * @param propertyData * @returns */ clearExpression(t, e) { const o = t.propertyValue; if (o && o.type === "Expression") return; const l = t.propertyID, a = this.getExpressions(), s = e.binding ? e.binding.field : e.id, r = a.find((d) => d.target === s); !r || !r.rules || (r.rules = r.rules.filter((d) => d.type !== l)); } getExpressionOptions(t, e, o) { return this.expressionProperty.getExpressionOptions(t, e, o); } 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: (o) => { var i; ((i = o.controller) == null ? void 0 : i.label.indexOf(this.formSchemaUtils.getModule().code)) > -1 && this.eventsEditorUtils.jumpToMethod(o); } } }, e; } } const oe = class oe { /** * 根据绑定字段类型获取可用的输入类控件 */ static getEditorTypesByMDataType(t, e = !1, o = "") { if (e) return [{ key: C["language-textbox"].type, value: C["language-textbox"].name }]; let i = oe.fieldControlTypeMapping[t]; if (o === "data-grid-column" && (i != null && i.length)) { const l = [C["check-group"].type, C["radio-group"].type, C.image.type, C["rich-text-editor"].type]; i = i.filter((a) => !l.includes(a.key)); } return i; } /** * 获取所有输入类控件 */ static getAllInputTypes() { const t = []; for (const e in oe.fieldControlTypeMapping) oe.fieldControlTypeMapping[e].forEach((o) => { t.find((i) => i.key === o.key && i.value === o.value) || t.push({ key: o.key, value: o.value }); }); return t; } /** * 提供schema字段基础属性和DOM控件属性的映射 * @param control 控件元数据 */ static mappingDomPropAndSchemaProp(t, e) { var l; const o = (l = t.editor) == null ? void 0 : l.type, i = []; return (t.type === C["data-grid-column"].type || t.type === C["tree-grid-column"].type) && e && e.categoryId && e.categoryId.indexOf("gridFieldEditor") < 0 && i.push({ domField: "title", schemaField: "name" }), i.push({ domField: "label", schemaField: "name" }), i.push({ domField: "editor.required", schemaField: "require" }), i.push({ domField: "editor.readonly", schemaField: "readonly" }), (o === C["input-group"].type || o === C.textarea.type || o === C["number-spinner"].type) && i.push({ domField: "editor.maxLength", schemaField: "type.length" }), o === C["number-spinner"].type && i.push({ domField: "editor.precision", schemaField: "type.precision" }), (t.type === C["data-grid-column"].type || t.type === C["tree-grid-column"].type) && i.push({ domField: "formatter.precision", schemaField: "type.precision" }), (o === C["combo-list"].type || o === C["radio-group"].type) && i.push({ domField: "editor.data", schemaField: "type.enumValues" }), (t.type === C["data-grid-column"].type || t.type === C["tree-grid-column"].type) && i.push({ domField: "formatter.data", schemaField: "type.enumValues" }), o === C["date-picker"].type && (i.push({ domField: "editor.displayFormat", schemaField: "editor.format" }), i.push({ domField: "editor.fieldType", schemaField: "type.name" })), o === C["number-spinner"].type && (i.push({ domField: "editor.max", schemaField: "editor.maxValue" }), i.push({ domField: "editor.min", schemaField: "editor.minValue" })), o === C.lookup.type && (i.push({ domField: "editor.dataSource", schemaField: "editor.dataSource" }), i.push({ domField: "editor.valueField", schemaField: "editor.valueField" }), i.push({ domField: "editor.textField", schemaField: "editor.textField" }), i.push({ domField: "editor.displayType", schemaField: "editor.displayType" }), i.push({ domField: "editor.mapFields", schemaField: "editor.mapFields" }), i.push({ domField: "editor.helpId", schemaField: "editor.helpId" })), i.push({ domField: "path", schemaField: "bindingPath" }), i.push({ domField: "binding.path", schemaField: "bindingField" }), i.push({ domField: "binding.fullPath", schemaField: "path" }), (t.type === C["data-grid-column"].type || t.type === C["tree-grid-column"].type) && i.push({ domField: "field", schemaField: "bindingPath" }), i; } }; /** * <字段类型,可配置的控件类型列表>的映射 */ B(oe, "fieldControlTypeMapping", { String: [ { key: C["input-group"].type, value: C["input-group"].name }, { key: C.lookup.type, value: C.lookup.name }, { key: C.image.type, value: C.image.name }, { key: C["date-picker"].type, value: C["date-picker"].name }, { key: C.switch.type, value: C.switch.name }, { key: C["check-box"].type, value: C["check-box"].name }, { key: C["check-group"].type, value: C["check-group"].name }, { key: C["radio-group"].type, value: C["radio-group"].name }, { key: C["combo-list"].type, value: C["combo-list"].name }, { key: C.textarea.type, value: C.textarea.name }, { key: C["time-picker"].type, value: C["time-picker"].name } ], Text: [ { key: C.textarea.type, value: C.textarea.name }, { key: C.lookup.type, value: C.lookup.name }, { key: C.image.type, value: C.image.name }, { key: C["rich-text-editor"].type, value: C["rich-text-editor"].name } ], Decimal: [ { key: C["number-spinner"].type, value: C["number-spinner"].name } ], Integer: [ { key: C["number-spinner"].type, value: C["number-spinner"].name } ], Number: [ { key: C["number-spinner"].type, value: C["number-spinner"].name }, { key: C.switch.type, value: C.switch.name }, { key: C["check-box"].type, value: C["check-box"].name } ], BigNumber: [ { key: C["number-spinner"].type, value: C["number-spinner"].name } ], Date: [ { key: C["date-picker"].type, value: C["date-picker"].name } ], DateTime: [ { key: C["date-picker"].type, value: C["date-picker"].name } ], Boolean: [ { key: C.switch.type, value: C.switch.name }, { key: C["check-box"].type, value: C["check-box"].name } ], Enum: [ { key: C["combo-list"].type, value: C["combo-list"].name }, { key: C["radio-group"].type, value: C["radio-group"].name } ], Object: [ { key: C.lookup.type, value: C.lookup.name }, { key: C["combo-list"].type, value: C["combo-list"].name }, { key: C["radio-group"].type, value: C["radio-group"].name } ] }); let fe = oe; var ae = /* @__PURE__ */ ((n) => (n.Form = "Form", n.Variable = "Variable", n))(ae || {}); class Pe { constructor() { /** 控件标题 */ B(this, "label", ""); /** 控件id */ B(this, "id", ""); /** 每个控件占用的栅格数 */ B(this, "columnInSM", 12); B(this, "columnInMD", 6); B(this, "columnInLG", 3); B(this, "columnInEL", 2); /** 每个控件占用的列数 */ B(this, "displayWidthInSM", 1); B(this, "displayWidthInMD", 1); B(this, "displayWidthInLG", 1); B(this, "displayWidthInEL", 1); /** 编辑器内部默认显示的屏幕大小-----可以去掉 */ B(this, "displayColumnCountAtBreakPoint", "md"); /** 控件所在行,传0即可-----编辑器内部使用 */ B(this, "tagRow", 0); /** 控件是否显示上方空白:传0即可-----编辑器内部使用 */ B(this, "showTopBorder", 0); /** 区域,从1开始。卡片内的控件从上往下,从左往右划分区域,遇到分组fieldSet时group+1,分组结束后group+1 */ B(this, "group", 1); /** 控件是否符合标准的class配置(设计器用的) */ B(this, "isSupportedClass", !0); /** 控件所在分组id(设计器用的) */ B(this, "fieldSetId", ""); } } function Gt(n) { let t, e; const o = /* @__PURE__ */ new Map(); let i = []; function l(c, u) { const m = ((c == null ? void 0 : c.split(" ")) || []).filter((E) => E.startsWith("col-")); if (m.length === 0) { u.isSupportedClass = !1; return; } let f = m.find((E) => /^col-([1-9]|10|11|12)$/.test(E)), b = m.find((E) => /^col-md-([1-9]|10|11|12)$/.test(E)), I = m.find((E) => /^col-xl-([1-9]|10|11|12)$/.test(E)), k = m.find((E) => /^col-el-([1-9]|10|11|12)$/.test(E)); f = f || "col-12", u.columnInSM = parseInt(f.replace("col-", ""), 10), u.displayWidthInSM = u.columnInSM / 12, u.displayWidthInSM !== 1 && (u.isSupportedClass = !1), b = b || "col-md-" + u.columnInSM, u.columnInMD = parseInt(b.replace("col-md-", ""), 10), u.displayWidthInMD = u.columnInMD / 6, [1, 2].includes(u.displayWidthInMD) || (u.isSupportedClass = !1), I = I || "col-xl-" + u.columnInMD, u.columnInLG = parseInt(I.replace("col-xl-", ""), 10), u.displayWidthInLG = u.columnInLG / 3, [1, 2, 3, 4].includes(u.displayWidthInLG) || (u.isSupportedClass = !1), k = k || "col-el-" + u.columnInLG, u.columnInEL = parseInt(k.replace("col-el-", ""), 10), u.displayWidthInEL = u.columnInEL / 2, [1, 2, 3, 4, 5, 6].includes(u.displayWidthInEL) || (u.isSupportedClass = !1); } function a(c, u, y, m = !1) { let f = !1; if (!c.contents || c.contents.length === 0) { const b = new Pe(); l(c.layout, b), u.push(b); return; } c.contents.forEach((b) => { if (b.type === "fieldset") { y += 1, a(b, u, y, !0), f = !0; return; } if (b.type === "dynamic-form") return; f && (y += 1, f = !1); const I = b.appearance && b.appearance.class, k = new Pe(); I ? l(I, k) : k.isSupportedClass = !1, k.label = b.label || b.id, k.id = b.id, k.group = y, m && (k.fieldSetId = c.id), e === b.id && (t = y), o.set(b.id, b), u.push(k); }); } function s(c) { const u = n.getComponentById(c); if (!u || !u.componentType || !u.componentType.startsWith("form")) return { result: !1, message: "只可以在响应式表单组件中调整响应式布局配置" }; const y = n.selectNode(u, (m) => m.type === C["response-form"].type); return !y || !y.contents || y.contents.length === 0 ? { result: !1, message: "Form区域内没有控件,请先添加控件" } : { result: !0, message: "", formNode: y }; } function r(c, u) { u = u || c.id; const { result: y, message: m, formNode: f } = s(u); if (!y) return { result: y, message: m }; e = c.id, i = [], o.clear(); const b = f.contents[0].type === C.fieldset.type ? 0 : 1; a(f, i, b); const I = i.find((E) => !E.isSupportedClass); return { defaultState: { defaultGroupNumber: t || 1, model: I ? "customize" : "standard" }, importData: i }; } function d(c, u) { u = u; const { result: y, formNode: m } = s(u); if (!y) return ""; const f = []; return c.forEach((b) => { var E; const I = o.get(b.id), k = I.appearance && I.appearance.class; if (k) { const A = k.split(" ").filter((O) => !O.startsWith("col-")), H = "col-" + b.columnInSM, $ = "col-md-" + b.columnInMD, p = "col-xl-" + b.columnInLG, w = "col-el-" + b.columnInEL, T = [H, $, p, w].concat(A); I.appearance.class = T.join(" "); } if (b.fieldSetId) { const P = m.contents.find((H) => H.id === b.fieldSetId), A = f.find((H) => H.id === b.fieldSetId); A ? (E = A.contents) == null || E.push(I) : (f.push(P), P.contents = [I]); } else f.push(I); }), m.contents = f, m.id; } return { checkCanFindFormNode: s, checkCanOpenLayoutEditor: r, changeFormControlsByResponseLayoutConfig: d, getResonseFormLayoutConfig: a }; } class Dt extends qt { constructor(e, o) { super(e, o); B(this, "responseLayoutEditorFunction"); /** 控件绑定的变量 */ B(this, "bindingVarible"); B(this, "formGroupEvents", [ // { // label: 'fieldValueChanging', // name: '绑定字段值变化前事件', // }, // { // label: 'fieldValueChanged', // name: '绑定字段值变化后事件', // }, { label: "onClickLabel", name: "标签点击事件" } ]); B(this, "numberEditorOptions", { type: "number-spinner", useThousands: !1, keyboard: !1, showButton: !1 }); B(this, "showCustomValue", (e) => { var i; const o = this.designViewModelField != null && ((i = this.designViewModelField) == null ? void 0 : i.type.name) !== "Boolean"; return this.formRule ? e.dataType !== "boolean" : o; }); this.responseLayoutEditorFunction = Gt(this.formSchemaUtils); } getCommonPropertyConfig(e, o, i = "Card") { this.propertyConfig.categories.basic = this.getBasicProperties(e, o, i), this.propertyConfig.categories.appearance = this.getAppearanceProperties(e, o), this.propertyConfig.categories.behavior = this.getBehaviorConfig(e, "form-group"); } getPropertyConfig(e, o) { return this.getCommonPropertyConfig(e, o, "Card"), this.propertyConfig.categories.editor = this.getEditorProperties(e), this.propertyConfig.categories.expressions = this.getExpressionConfig(e, "Field"), this.propertyConfig.categories.eventsEditor = this.getEventPropertyConfig(e), this.propertyConfig; } getGridFieldEdtiorPropConfig(e, o) { return this.propertyConfig.categories = {}, this.getCommonPropertyConfig(e, o, "Grid"), this.getGridFieldEdtiorProperties ? this.propertyConfig.categories.editor = this.getGridFieldEdtiorProperties(e) : this.propertyConfig.categories.editor = this.getEditorProperties(e), this.propertyConfig.categories.expressons = this.getExpressionConfig(e, "Field"), this.propertyConfig.categories; } getBasicProperties(e, o, i = "Card") { var c; const l = this; this.setDesignViewModelField(e); const { canChangeControlType: a, editorTypeList: s } = this.getAvailableEditorType(e); let r = s; this.formRule && (r = s.filter((u) => u.key !== "image" && u.key !== "rich-text-editor")); const d = { description: "Basic Information", title: "基本信息", properties: { id: { description: "组件标识", title: "标识", type: "string", readonly: !0 }, type: { description: "编辑器类型", title: "编辑器类型", type: "string", $converter: "/converter/change-editor.converter", parentPropertyID: "editor", editor: { type: "combo-list", textField: "value", valueField: "key", idField: "key", editable: !1, data: r, readonly: !a } }, label: { title: "标签", type: "string", $converter: "/converter/form-group-label.converter" }, showLabelType: { description: "标签显示方式:1、显示:显示标签 2、占位:保留标签空间,但不显示文本 3、不显示:不显示标签", title: "标签显示", type: "enum", editor: { data: [{ id: "visible", name: "显示" }, { id: "reserve-space", name: "占位" }, { id: "none", name: "不显示" }] }, defaultValue: ((c = e.editor) == null ? void 0 : c.type) === "image" ? "none" : "visible" }, binding: { description: "绑定的表单字段", title: "绑定", editor: { type: "binding-selector", bindingType: { enable: !1 }, editorParams: { componentSchema: e, needSyncToViewModel: !0, viewModelId: this.viewModelId, designerHostService: this.designerHostService, disableOccupiedFields: !0 }, textField: "bindingField" }, refreshPanelAfterChanged: !0, readonly: this.formSchemaUtils.designerMode === "PC_RTC" && !e.isRtcControl } }, setPropertyRelates(u, y, m) { if (u) switch (u && u.propertyID) { case "type": { l.changeControlType(e, u, o); break; } case "label": { u.needRefreshControlTree = !0; break; } case "binding": { l.changeBindingField(e, u, m); break; } } } }; return i.toLocaleLowerCase() !== "card" && delete d.properties.showLabelType, d; } /** * 校验控件是否支持切换类型 * @param control 控件 */ checkCanChangeControlType(e, o) { if (!e.binding) return !1; if (e.binding.type === "Variable") { if (this.bindingVarible = this.formSchemaUtils.getVariableById(e.binding.field), !this.bindingVarible) return !1; } else if (!this.designViewModelField || this.designViewModelField.$type !== Be.SimpleField) return !1; return !0; } /** * 获取可选的编辑器类型 */ getAvailableEditorType(e) { var l, a; const o = this.checkCanChangeControlType(e, this.viewModelId); if (!o) return { canChangeControlType: !1, editorTypeList: [{ key: e.editor.type, value: ((l = C[e.editor.type]) == null ? void 0 : l.name) || e.editor.type }] }; let i = []; return this.designViewModelField && this.designViewModelField.$type === Be.SimpleField ? i = fe.getEditorTypesByMDataType(this.designViewModelField.type.name, this.designViewModelField.multiLanguage) : this.bindingVarible && (i = fe.getEditorTypesByMDataType(this.bindingVarible.type, !!((a = this.designViewModelField) != null && a.multiLanguage))), { canChangeControlType: o, editorTypeList: i }; } changeBindingField(e, o, i) { o.needRefreshEntityTree = !0; } getAppearanceProperties(e, o) { const i = this; return { title: "外观", description: "Appearance", properties: { 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" }, fill: { title: "填充宽度", description: "启用后,控件占满父容器宽度", type: "boolean", parentPropertyID: "appearance", defaultValue: !1 }, responseLayout: { description: "响应式列宽", title: "响应式列宽", type: "boolean", visible: !i.formRule, // 这个属性,标记当属性变更得时候触发重新更新属性 refreshPanelAfterChanged: !0, editor: { type: "response-layout-editor-setting", beforeOpen: () => i.responseLayoutEditorFunction.checkCanOpenLayoutEditor(e, i.componentId) } } }, setPropertyRelates(l, a) { if (l) switch (l && l.propertyID) { case "responseLayout": i.responseLayoutEditorFunction.changeFormControlsByResponseLayoutConfig(l.propertyValue, i.componentId || e.id), i.updateUnifiedLayoutAfterResponseLayoutChanged(i.componentId), i.updateElementByParentContainer(e.id, o), delete e.responseLayout; break; case "class": i.updateUnifiedLayoutAfterControlChanged(l.propertyValue, e.id, this.componentId), ue.value++; break; case "style": { ue.value++; break; } } } }; } getEditorProperties(e) { return this.getComponentConfig(e); } /** * 卡片控件:切换控件类型后事件 * @param propertyData 控件DOM属性 * @param newControlType 新控件类型 */ changeControlType(e, o, i) { const l = o.propertyValue, a = i && i.parent && i.parent.schema; if (!a) return; const s = a.contents.findIndex((c) => c.id === e.id); if (s === -1) return; const r = a.contents[s]; let d; if (this.designViewModelField) { const y = this.formSchemaUtils.getViewModelById(this.viewModelId).fields.find((f) => f.id === this.designViewModelField.id).fieldSchema || {}; y.editor || (y.editor = {}), y.editor.$type = l, this.designViewModelUtils.getDgViewModel(this.viewModelId).changeField(this.designViewModelField.id, y, !1), d = this.controlCreatorUtils.setFormFieldProperty(this.designViewModelField, l); } d || (d = this.controlCreatorUtils.createFormGroupWithoutField(l)), Object.assign(d, { id: r.id, appearance: r.appearance, size: r.size, label: r.label, binding: r.binding }), Object.prototype.hasOwnProperty.call(r, "visible") && Object.assign(d, { visible: r.visible }), r.editor && ["readonly", "required", "placeholder"].map((c) => { Object.prototype.hasOwnProperty.call(r.editor, c) && (d.editor[c] = r.editor[c]); }), i != null && i.updateContextSchema ? i.updateContextSchema(d) : (i.schema = Object.assign(r, d), Object.assign(e, d)), Array.from(document.getElementsByClassName("dgComponentSelected")).forEach( (c) => c.classList.remove("dgComponentSelected") ), Array.from(document.getElementsByClassName("dgComponentFocused")).forEach( (c) => c.classList.remove("dgComponentFocused") ), ue.value++, ne(() => { this.getFormDesignerInstance().reloadPropertyPanel(); }); } getComponentConfig(e, o = {}, i = {}, l) { var y, m; const a = Object.assign({ description: "编辑器", title: "编辑器", type: "input-group", $converter: "/converter/property-editor.converter", parentPropertyID: "editor" }, o), s = (y = e.binding) != null && y.field ? [] : ["Const", "Variable", "StateMachine"], r = this.getPropertyEditorParams(e, s, "readonly"), d = this.getPropertyEditorParams(e, s, "required"), c = { readonly: { description: "", title: "只读", editor: r }, required: { description: "", title: "必填", type: "boolean", editor: d, visible: !!((m = e.binding) != null && m.field) }, placeholder: { description: "当控件没有值时在输入框中显示的文本", title: "提示文本", type: "string" } }; for (const f in i) c[f] = Object.assign(c[f] || {}, i[f]); const u = this; return { ...a, properties: { ...c }, setPropertyRelates(f, b) { if (f) { switch (f.propertyID) { case "readonly": case "required": u.afterMutilEditorChanged(e, f); break; } l && l.bind(u)(f, e, b); } } }; } /** * 修改某一输入控件的样式后更新Form的统一布局配置 * @param controlClass 控件样式 * @param controlId 控件Id * @param componentId 控件所在组件id */ updateUnifiedLayoutAfterControlChanged(e, o, i) { const l = e.split(" "); let a = l.find((u) => /^col-([1-9]|10|11|12)$/.test(u)), s = l.find((u) => /^col-md-([1-9]|10|11|12)$/.test(u)), r = l.find((u) => /^col-xl-([1-9]|10|11|12)$/.test(u)), d = l.find((u) => /^col-el-([1-9]|10|11|12)$/.test(u)); a = a || "col-12", s = s || "col-md-" + a.replace("col-", ""), r = r || "col-xl-" + s.replace("col-md-", ""), d = d || "col-el-" + r.replace("col-xl-", ""); const c = { id: o, columnInSM: parseInt(a.replace("col-", ""), 10), columnInMD: parseInt(s.replace("col-md-", ""), 10), columnInLG: parseInt(r.replace("col-xl-", ""), 10), columnInEL: parseInt(d.replace("col-el-", ""), 10) }; this.updateUnifiedLayoutAfterResponseLayoutChanged(i, c); } /** * 修改控件布局配置后更新Form统一布局配置 * @param componentId 组件Id * @param controlLayoutConfig 某单独变动的控件配置项,FormResponseLayoutContext类型 */ updateUnifiedLayoutAfterResponseLayoutChanged(e, o) { const { formNode: i } = this.responseLayoutEditorFunction.checkCanFindFormNode(e); if (!i || !i.unifiedLayout) return; const l = []; if (this.responseLayoutEditorFunction.getResonseFormLayoutConfig(i, l, 1), o) { const f = l.find((b) => b.id === o.id); Object.assign(f || {}, o); } const a = l.map((f) => f.columnInSM), s = l.map((f) => f.columnInMD), r = l.map((f) => f.columnInLG), d = l.map((f) => f.columnInEL), c = this.checkIsUniqueColumn(a) ? a[0] : null, u = this.checkIsUniqueColumn(s) ? s[0] : null, y = this.checkIsUniqueColumn(r) ? r[0] : null, m = this.checkIsUniqueColumn(d) ? d[0] : null; Object.assign(i.unifiedLayout, { uniqueColClassInSM: c, uniqueColClassInMD: u, uniqueColClassInLG: y, uniqueColClassInEL: m }); } /** * 校验宽度样式值是否一致 */ checkIsUniqueColumn(e) { const o = new Set(e); return Array.from(o).length === 1; } /** * 枚举项编辑器 * @param propertyData * @param valueField * @param textField * @returns */ getItemCollectionEditor(e, o, i) { return o = o || "value", i = i || "name", { editor: { columns: [ { field: o, title: "值", dataType: "string" }, { field: i, title: "名称", dataType: "string" } // { field: 'disabled', title: '禁用', dataType: 'boolean', editor: { type: 'switch' } }, ], type: "item-collection-editor", valueField: o, nameField: i, requiredFields: [o, i], uniqueFields: [o, i], readonly: this.checkEnumDataReadonly(e) } }; } /** * 判断枚举数据是否只读 * 1、没有绑定信息或者绑定变量,可以新增、删除、修改 * 2、绑定类型为字段,且字段为枚举字段,则不可新增、删除、修改枚举值。只能从be修改然后同步到表单上。 * @param propertyData 下拉框控件属性值 */ checkEnumDataReadonly(e) { return !e.binding || e.binding.type !== "Form" ? !1 : !!(this.designViewModelField && this.designViewModelField.type && this.designViewModelField.type.$type === Ve.EnumType); } /** * 将字段值变化前事件、变化后事件追加到交互面板 * 注意:因为绑定字段值变化后事件与下拉框的值变化事件(valueChanged)重名,所以这里将事件label都重命名下 */ appendFieldValueChangeEvents(e, o) { e.binding && e.binding.type === ae.Form && e.binding.field ? (o.find((i) => i.label === "fieldValueChanging"), o.find((i) => i.label === "fieldValueChanged"), this.designViewModelField && (e.fieldValueChanging = this.designViewModelField.valueChanging, e.fieldValueChanged = this.designViewModelField.valueChanged)) : o = o.filter((i) => i.label !== "fieldValueChanging" && i.label !== "fieldValueChanged"); } getControlMethodType(e) { if (!e.binding) return e.type; switch (e.binding.type) { case ae.Form: return e.binding.path || e.type; case ae.Variable: return e.binding.fullPath || e.type; } return e.type; } updateLinkedLabel(e, o) { if (e.boundEventsList && e.boundEventsList.length > 0) { const i = e.boundEventsList.find((l) => l.boundEvents && l.boundEvents.label === "onClickLabel"); o.linkLabel = !!i; } else o.linkLabel = !1; } getInputCommonEvents(e) { return e.binding && e.binding.type === ae.Variable ? [{ label: "onClickLabel", name: "标签点击事件" }] : [...this.formGroupEvents]; } /** * 组装输入类控件的交互面板:包含标签超链、绑定字段值变化前后事件等。 * @param propertyData 属性值 * @param viewModelId 视图模型id * @param showPosition 面板展示位置 * @param customEvent 输入控件特有的事件配置 */ getEventPropertyConfig(e, o = "card", i, l) { const a = this; let s = this.getInputCommonEvents(e); if (i && (s = s.concat(i)), s.length === 0) return { title: "事件", hideTitle: !0, properties: {}, tabId: "commands", tabName: "交互", hide: !0 }; this.appendFieldValueChangeEvents(e, s); const r = a.eventsEditorUtils.formProperties(e, a.viewModelId, s); return { title: "事件", hideTitle: !0, properties: a.createBaseEventProperty(r), tabId: "commands", tabName: "交互", setPropertyRelates(u, y) { const m = u.propertyValue; delete e[a.viewModelId], m && (m.setPropertyRelates = this.setPropertyRelates, m.controlInfo = { type: a.getControlMethodType(e), name: e.title }, a.eventsEditorUtils.saveRelatedParameters(e, a.viewModelId, m.events, m), a.updateLinkedLabel(m, y)), l && l(u, y, m); const f = a.designViewModelUtils.getDgViewModel(a.viewModelId); f && a.designViewModelField && f.changeField(a.designViewModelField.id, { valueChanging: e.fieldValueChanging, valueChanged: e.fieldValueChanged }); } }; } getExpressionConfig(e, o, i = ["compute", "dependency", "validate"], l) { return this.expressionProperty.getExpressionConfig(e, o, i, l); } getBindingDataType(e) { return this.formRule ? (e == null ? void 0 : e.dataType) || "string" : this.designViewModelField ? this.designViewModelField.type.name === "Number" ? "number" : this.designViewModelField.type.name === "String" ? "string" : "boolean" : "boolean"; } getEditor(e) { return this.getBindingDataType(e) === "number" ? this.numberEditorOptions : {}; } updatePropertyValue(e, o, i) { var l; e.editor[o] !== i ? e.editor[o] = i : (l = this.getFormDesignerInstance()) == null || l.reloadPropertyPanel(); } setBooleanValue(e, o, i) { let l = i; this.getBindingDataType() === "string" && (l = (l || "").trim() || (o === "trueValue" ? "true" : "false")); const s = o === "trueValue" ? "falseValue" : "trueValue"; e.editor[s] === l && (l = l + 1), this.updatePropertyValue(e, o, l); } getBooleanValueConverter() { return { convertFrom: (e, o) => e.editor[o], convertTo: (e, o, i) => { this.setBooleanValue(e, o, i); } }; } } class Kt extends Dt { constructor(t, e) { super(t, e); } getEditorProperties(t) { const e = this; return e.getComponentConfig(t, { type: "radio-group" }, { disabled: { visible: !1 }, placeholder: { visible: !1 }, direction: { description: "", title: "排列方向", type: "enum", editor: { data: [{ id: "horizontal", name: "横向" }, { id: "vertical", name: "纵向" }] } }, dataSourceType: { description: "", title: "数据源类型", type: "enum", visible: !1, editor: { default: "static", data: [ { id: "sta