UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,387 lines 55.9 kB
var H = Object.defineProperty; var G = (y, n, e) => n in y ? H(y, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : y[n] = e; var g = (y, n, e) => G(y, typeof n != "symbol" ? n + "" : n, e); import O, { timePickerProps as W } from "../../components/time-picker/index.esm.js"; import { resolveAppearance as z, createPropsResolver as X } from "../../components/dynamic-resolver/index.esm.js"; import { nextTick as j, defineComponent as _, ref as x, inject as T, onMounted as J, createVNode as P, resolveComponent as Q } from "vue"; import { FButtonEdit as Y } from "../../components/button-edit/index.esm.js"; import { DgControl as d, canvasChanged as V, refreshCanvas as Z, useDesignerComponent as K } from "../../components/designer-canvas/index.esm.js"; import { cloneDeep as D } from "lodash-es"; import { FormSchemaEntityField$Type as B, FormSchemaEntityFieldType$Type as ee } from "../../components/common/index.esm.js"; const te = { /** * 组件值,这个是与指定的format格式相对应的值 */ modelValue: { type: String, default: "" }, hourStep: { type: Number, default: 1 }, minuteStep: { type: Number, default: 1 }, secondStep: { type: Number, default: 1 }, popupClassName: { type: String, default: "" }, placeholder: { type: String, default: "请选择时间" }, placement: { type: String, default: "auto" }, /** * 默认时间控件下拉面板,展开时的值 */ defaultOpenValue: { type: Date, default: null }, format: { type: String, default: "HH:mm:ss" }, isOpen: { type: Boolean, default: !1 }, showHeader: { type: Boolean, default: !1 }, use12Hours: { type: Boolean, default: !1 }, disabledHours: { type: Function, default: null }, disabledMinutes: { type: Function, default: null }, disabledSeconds: { type: Function, default: null }, /** * 是否隐藏禁用的元素 */ hideDisabledElements: { type: Boolean, default: !1 }, disabled: { type: Boolean, default: !1 }, readonly: { type: Boolean, default: !1 }, editable: { type: Boolean, default: !0 } }; function ie(y) { const { formSchemaUtils: n, formStateMachineUtils: e } = y; function t(l, u = "") { return { path: u + l.code, field: l.id, fullPath: l.code }; } function i(l, u = "") { const a = n.getViewModelById(l); return a ? a.states.map((r) => t(r, u)) : []; } function s(l) { const u = n.getRootViewModelId(), a = i(l); if (l === u) return a; const r = i(u, "root-component."); return [...a, ...r]; } function o(l) { return l.binding && l.binding.path || l.id || ""; } function c() { return e && e.getRenderStates() || []; } return { getVariables: s, getControlName: o, getStateMachines: c }; } class ne { constructor(n) { g(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'" } ]); g(this, "expressionNames", { compute: "计算表达式", dependency: "依赖表达式", validate: "验证表达式", dataPicking: "帮助前表达式", visible: "可见表达式", readonly: "只读表达式", required: "必填表达式" }); g(this, "getExpressionConverter", (n, e) => ({ convertFrom: (t, i, s, o) => { const c = s.getExpressionRuleValue(n, e || i); return c && c.value || ""; }, convertTo: (t, i, s, o, c) => { var l; if (i === "dataPicking" && (s != null && s.target)) { const u = `${s.target}_dataPicking`; ((l = s.rules) == null ? void 0 : l.some( (r) => r.id === u && r.value )) ? t.dictPickingExpressionId = u : delete t.dictPickingExpressionId; } o.updateExpression(s); } })); this.formSchemaService = n; } getExpressionRule(n, e) { const t = this.getExpressionData(); if (!t) return ""; const i = t.find((o) => o.target === n); if (!i) return ""; const s = i.rules.find((o) => o.type === e); return s || ""; } // 获取上下文表单变量 getContextFormVariables() { const { module: n } = this.formSchemaService.getFormSchema(); if (!n.viewmodels || n.viewmodels.length === 0) return []; const e = this.formSchemaService.getRootViewModelId(), t = this.formSchemaService.getViewModelById(e); if (!t || !t.states || t.states.length === 0) return []; const i = []; return t.states.filter((s) => s.category === "remote").forEach((s) => { i.push({ key: s.code, name: s.name, description: s.name, category: s.category }); }), i; } createTreeNode(n, e, t = "label") { return { id: n.id, name: n.name, bindingPath: n[t], parents: e, type: "field" }; } buildEntityFieldsTreeData(n = null, e) { const t = []; return n == null || n.forEach((i) => { var c; const s = this.createTreeNode(i, e); let o = []; (c = i.type) != null && c.fields && (o = this.buildEntityFieldsTreeData(i.type.fields, [...e, i.label])), t.push({ data: s, children: o, expanded: !0 }); }), t; } buildChildEntityTreeData(n = null, e) { const t = []; return n == null || n.forEach((i) => { var l, u; const s = this.createTreeNode(i, e); s.type = "entity"; const o = this.buildEntityFieldsTreeData((l = i.type) == null ? void 0 : l.fields, [...e, i.label]), c = this.buildChildEntityTreeData((u = i.type) == null ? void 0 : u.entities, [...e, i.label]); c != null && c.length && (o == null || o.push(...c)), t.push({ data: s, children: o || [], // 空值回退 expanded: !0 }); }), t; } getEntitiesTreeData() { const n = this.formSchemaService.getSchemaEntities(); if (!(n != null && n.length)) return []; const e = n[0]; if (!(e != null && e.type)) return []; const t = this.buildEntityFieldsTreeData(e.type.fields, [e.code]), i = this.buildChildEntityTreeData(e.type.entities, [e.code]); return i != null && i.length && (t == null || t.push(...i)), { entityCode: e.code, fields: [{ data: this.createTreeNode(e, [], "code"), children: t || [] }] }; } getEntitiesAndVariables() { return { entities: this.getEntitiesTreeData(), variables: { session: { name: "系统变量", items: this.sessionVariables, visible: !1 }, forms: { name: "表单变量", items: this.getContextFormVariables(), visible: !0 } } }; } onBeforeOpenExpression(n, e, t) { const i = t === "Field" ? n.binding.field : n.id, s = this.getExpressionRule(i, e), o = this.getEntitiesAndVariables(), c = { message: ["validate", "required", "dataPicking"].includes(e) && s ? s.message : "", ...o }; return s.messageType != null && (c.messageType = s.messageType), c; } buildRule(n, e, t, i) { const { expression: s, message: o, messageType: c } = e, l = { id: `${n}_${t}`, type: t, value: s }; return (t === "validate" || t === "dataPicking" || t === "required") && (l.message = o), t === "dataPicking" && (l.messageType = c), t === "validate" && i && (l.elementId = i), l; } getExpressionData() { const { expressions: n } = this.formSchemaService.getFormSchema().module; return n || []; } updateExpression(n, e, t, i) { const s = e === "Field" ? n.binding.field : n.id, o = this.buildRule(s, t, i, n.type === "form-group" ? n.id : ""); let l = this.getExpressionData().find((a) => a.targetType === e && a.target === s); const u = (a) => a.value.trim() === ""; if (l) { const a = l.rules.find((r) => r.id === o.id); if (a) u(o) ? l.rules = l.rules.filter((r) => r.id !== o.id) : (Object.assign(a, o), i === "validate" && n.type === "form-group" && (a.elementId = n.id)); else { if (u(o)) return null; l.rules = l.rules || [], l.rules.push(o); } } else { if (u(o)) return null; l = { target: `${s}`, rules: [o], targetType: e }; } return l; } getExpressionEditorOptions(n, e, t, i) { return t.reduce((s, o) => { var l, u; const c = e === "Field" ? (l = n == null ? void 0 : n.binding) == null ? void 0 : l.field : n.id; return s[o] = { hide: e === "Field" ? !!((u = n == null ? void 0 : n.binding) != null && u.field) : !1, description: "", title: this.expressionNames[o], type: "string", $converter: this.getExpressionConverter(c), refreshPanelAfterChanged: !0, editor: { type: "expression-editor", singleExpand: !1, dialogTitle: `${this.expressionNames[o]}编辑器`, showMessage: o === "validate" || o === "dataPicking" || o === "required", showMessageType: o === "dataPicking", beforeOpen: () => this.onBeforeOpenExpression(n, o, e), onSubmitModal: (a) => { const r = this.updateExpression(n, e, a, o); if (i) { const m = this.buildRule(c, a, o); i(m); } return r; } } }, s; }, {}); } getExpressionInfo(n, e, t) { const i = e === "Field" ? n.binding.field : n.id, s = this.getExpressionRule(i, t), o = { value: s && s.value, targetId: i, targetType: e, expressionType: t }; return s && s.message && (o.message = s.message), o; } getExpressionConfig(n, e, t = ["compute", "dependency", "validate"], i) { return { description: "表达式", title: "表达式", hide: !n.binding, properties: { ...this.getExpressionEditorOptions(n, e, t, i) } }; } getExpressionOptions(n, e, t) { const i = this.getExpressionInfo(n, e, t); return { dialogTitle: `${this.expressionNames[t] || "表达式"}编辑器`, singleExpand: !1, showMessage: t === "required", beforeOpen: () => this.onBeforeOpenExpression(n, t, e), expressionInfo: i }; } } class se { constructor(n, e) { g(this, "componentId"); g(this, "viewModelId"); g(this, "eventsEditorUtils"); g(this, "formSchemaUtils"); g(this, "formMetadataConverter"); g(this, "designViewModelUtils"); g(this, "designViewModelField"); g(this, "controlCreatorUtils"); g(this, "designerHostService"); g(this, "designerContext"); g(this, "modalService", null); /** 表单规则 */ g(this, "formRule", null); g(this, "schemaService", null); g(this, "metadataService", null); g(this, "propertyConfig", { type: "object", categories: {} }); g(this, "expressionProperty"); var t; this.componentId = n, this.designerHostService = e, this.eventsEditorUtils = e.eventsEditorUtils, this.formSchemaUtils = e.formSchemaUtils, this.formMetadataConverter = e.formMetadataConverter, this.viewModelId = ((t = this.formSchemaUtils) == null ? void 0 : t.getViewModelIdByComponentId(n)) || "", 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 ne(this.formSchemaUtils); } getFormDesignerInstance() { var n, e; return (e = (n = this.designerContext) == null ? void 0 : n.instances) == null ? void 0 : e.formDesigner.value; } getTableInfo() { var n; return (n = this.schemaService) == null ? void 0 : n.getTableInfoByViewModelId(this.viewModelId); } setDesignViewModelField(n) { var t; const e = n.binding && n.binding.type === "Form" && n.binding.field; if (e) { if (!this.designViewModelField) { const i = this.designViewModelUtils.getDgViewModel(this.viewModelId); this.designViewModelField = i.fields.find((s) => s.id === e); } n.updateOn = (t = this.designViewModelField) == null ? void 0 : t.updateOn; } } getBasicPropConfig(n) { 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: n.type, name: d[n.type] && d[n.type].name }] } } } }; } getAppearanceConfig(n = null, e = {}, t) { const i = { title: "外观", description: "Appearance" }, s = { 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 o in e) s[o] = Object.assign(s[o] || {}, e[o]); return { ...i, properties: { ...s }, setPropertyRelates(o, c) { if (o) { switch (o && o.propertyID) { case "class": case "style": { V.value++; break; } } t && t(o, n, c); } } }; } /** * * @param propertyData * @param propertyTypes * @param propertyName * @param constInfos * @param variableInfos * @param expressionType 指定表达式类型,存在属性和表达式类型不一致的情况 * @returns */ getPropertyEditorParams(n, e = [], t = "visible", i = {}, s = {}, o = "") { const { getVariables: c, getControlName: l, getStateMachines: u } = ie(this.designerHostService), a = this.getRealTargetType(n), r = e && e.length > 0 ? e : ["Const", "Variable", "StateMachine", "Expression"], m = { type: "property-editor", propertyTypes: r }; return r.map((h) => { switch (h) { case "Const": Object.assign(m, { constType: "enum", constEnums: [{ id: !0, name: "是" }, { id: !1, name: "否" }] }, i); break; case "Expression": m.expressionConfig = this.getExpressionOptions(n, a, o || t); break; case "StateMachine": m.stateMachines = u(); break; case "Variable": Object.assign(m, { controlName: l(n), newVariablePrefix: "is", newVariableType: "Boolean", variables: c(this.viewModelId), parentComponentId: this.componentId === "root-component" ? "" : "root-component", onBeforeOpenVariables: (p) => { p.value = c(this.viewModelId); } }, s), this.designerContext.designerMode === "PC_RTC" && (m.newVariablePrefix = "ext_" + m.newVariablePrefix); break; } }), m; } getVisibleProperty(n, e = "") { var s; let t = ["Const", "Variable", "StateMachine", "Expression"]; return e === "gridFieldEditor" ? t = ["Const", "Expression"] : e === "form-group" && !((s = n.binding) != null && s.field) && (t = ["Const", "Variable", "StateMachine"]), { visible: { title: "是否可见", type: "boolean", description: "运行时组件是否可见", editor: this.getPropertyEditorParams(n, t, "visible") } }; } /** * 获取行为 * @param propertyData * @param viewModelId * @returns */ getBehaviorConfig(n, e = "", t = {}, i) { const s = { title: "行为", description: "" }, o = this.getVisibleProperty(n, e); for (const l in t) o[l] = Object.assign(o[l] || {}, t[l]); const c = this; return { ...s, properties: { ...o }, setPropertyRelates(l, u) { if (l) { switch (l.propertyID) { case "disabled": case "readonly": case "visible": c.afterMutilEditorChanged(n, l); break; } i && i(l, u); } } }; } /** * 当多值编辑器变更时 * @param propertyData * @param changeObject */ afterMutilEditorChanged(n, e) { this.addNewVariableToViewModel(e, this.viewModelId), this.updateExpressionValue(e, n), this.clearExpression(e, n); } /** * * @param propertyId * @param componentInstance * @returns */ updateElementByParentContainer(n, e) { const t = e && e.parent && e.parent.schema; if (!t) return; const i = t.contents.findIndex((o) => o.id === n), s = D(t.contents[i]); t.contents.splice(i, 1), t.contents.splice(i, 0, s), Z(); } /** * 属性编辑器,在编辑过程中会新增变量,此处需要将新增的变量追加到ViewModel中 * @param changeObject * @param viewModelId * @returns */ addNewVariableToViewModel(n, e) { const t = n.propertyValue; if (!(t && typeof t == "object") || !(t.type === "Variable" && t.isNewVariable)) return; const o = { id: t.field, category: "locale", code: t.fullPath, name: t.fullPath, type: t.newVariableType || "String", isRtcVariable: this.designerContext.designerMode === "PC_RTC" ? !0 : void 0 }; delete t.newVariableType, delete t.isNewVariable, this.formSchemaUtils.getVariableByCode(o.code) || this.formSchemaUtils.getViewModelById("root-viewmodel").states.push(o); } getExpressions() { let n = []; return this.formRule ? (this.formRule.expressions = this.formRule.expressions || [], n = this.formRule.expressions || []) : n = this.formSchemaUtils.getExpressions(), n; } /** * 更新表达式到expressions节点 * @param changeObject */ updateExpressionValue(n, e) { const t = n.propertyValue; if (!((t && t.type) === "Expression" && t.expressionInfo)) return; const { expressionId: o, expressionInfo: c } = t, { targetId: l, targetType: u, expressionType: a, value: r, message: m } = c, h = this.getExpressions(); let p = h.find((b) => b.target === l); p || (p = { target: l, rules: [], targetType: u }, h.push(p)); const f = p.rules.find((b) => b.type === a); if (f) f.value = r, f.message = m, (a === "minDate" || a === "maxDate" || a === "defaultTime") && (f.elementId = e.id); else { const b = { id: o, type: a, value: r, message: m, elementId: e.id }; p.rules.push(b); } delete t.expressionInfo; } /** * 属性类型切换为非表达式后,清除原表达式 * @param changeObject * @param propertyData * @returns */ clearExpression(n, e) { const t = n.propertyValue; if (t && t.type === "Expression") return; const s = n.propertyID, o = this.getExpressions(), c = e.binding ? e.binding.field : e.id, l = o.find((u) => u.target === c); !l || !l.rules || (l.rules = l.rules.filter((u) => u.type !== s)); } getExpressionOptions(n, e, t) { return this.expressionProperty.getExpressionOptions(n, e, t); } getRealTargetType(n) { return ["response-toolbar-item", "tab-toolbar-item", "section-toolbar-item", "drawer-toolbar-item"].indexOf(n.type) > -1 ? "Button" : n.binding && n.binding.field ? "Field" : "Container"; } createBaseEventProperty(n) { const e = {}; return e[this.viewModelId] = { type: "events-editor", editor: { initialData: n, viewSourceHandle: (t) => { var i; ((i = t.controller) == null ? void 0 : i.label.indexOf(this.formSchemaUtils.getModule().code)) > -1 && this.eventsEditorUtils.jumpToMethod(t); } } }, e; } } const E = class E { /** * 根据绑定字段类型获取可用的输入类控件 */ static getEditorTypesByMDataType(n, e = !1, t = "") { if (e) return [{ key: d["language-textbox"].type, value: d["language-textbox"].name }]; let i = E.fieldControlTypeMapping[n]; if (t === "data-grid-column" && (i != null && i.length)) { const s = [d["check-group"].type, d["radio-group"].type, d.image.type, d["rich-text-editor"].type]; i = i.filter((o) => !s.includes(o.key)); } return i; } /** * 获取所有输入类控件 */ static getAllInputTypes() { const n = []; for (const e in E.fieldControlTypeMapping) E.fieldControlTypeMapping[e].forEach((t) => { n.find((i) => i.key === t.key && i.value === t.value) || n.push({ key: t.key, value: t.value }); }); return n; } /** * 提供schema字段基础属性和DOM控件属性的映射 * @param control 控件元数据 */ static mappingDomPropAndSchemaProp(n, e) { var s; const t = (s = n.editor) == null ? void 0 : s.type, i = []; return (n.type === d["data-grid-column"].type || n.type === d["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" }), (t === d["input-group"].type || t === d.textarea.type || t === d["number-spinner"].type) && i.push({ domField: "editor.maxLength", schemaField: "type.length" }), t === d["number-spinner"].type && i.push({ domField: "editor.precision", schemaField: "type.precision" }), (n.type === d["data-grid-column"].type || n.type === d["tree-grid-column"].type) && i.push({ domField: "formatter.precision", schemaField: "type.precision" }), (t === d["combo-list"].type || t === d["radio-group"].type) && i.push({ domField: "editor.data", schemaField: "type.enumValues" }), (n.type === d["data-grid-column"].type || n.type === d["tree-grid-column"].type) && i.push({ domField: "formatter.data", schemaField: "type.enumValues" }), t === d["date-picker"].type && (i.push({ domField: "editor.displayFormat", schemaField: "editor.format" }), i.push({ domField: "editor.fieldType", schemaField: "type.name" })), t === d["number-spinner"].type && (i.push({ domField: "editor.max", schemaField: "editor.maxValue" }), i.push({ domField: "editor.min", schemaField: "editor.minValue" })), t === d.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" }), (n.type === d["data-grid-column"].type || n.type === d["tree-grid-column"].type) && i.push({ domField: "field", schemaField: "bindingPath" }), i; } }; /** * <字段类型,可配置的控件类型列表>的映射 */ g(E, "fieldControlTypeMapping", { String: [ { key: d["input-group"].type, value: d["input-group"].name }, { key: d.lookup.type, value: d.lookup.name }, { key: d.image.type, value: d.image.name }, { key: d["date-picker"].type, value: d["date-picker"].name }, { key: d.switch.type, value: d.switch.name }, { key: d["check-box"].type, value: d["check-box"].name }, { key: d["check-group"].type, value: d["check-group"].name }, { key: d["radio-group"].type, value: d["radio-group"].name }, { key: d["combo-list"].type, value: d["combo-list"].name }, { key: d.textarea.type, value: d.textarea.name }, { key: d["time-picker"].type, value: d["time-picker"].name } ], Text: [ { key: d.textarea.type, value: d.textarea.name }, { key: d.lookup.type, value: d.lookup.name }, { key: d.image.type, value: d.image.name }, { key: d["rich-text-editor"].type, value: d["rich-text-editor"].name } ], Decimal: [ { key: d["number-spinner"].type, value: d["number-spinner"].name } ], Integer: [ { key: d["number-spinner"].type, value: d["number-spinner"].name } ], Number: [ { key: d["number-spinner"].type, value: d["number-spinner"].name }, { key: d.switch.type, value: d.switch.name }, { key: d["check-box"].type, value: d["check-box"].name } ], BigNumber: [ { key: d["number-spinner"].type, value: d["number-spinner"].name } ], Date: [ { key: d["date-picker"].type, value: d["date-picker"].name } ], DateTime: [ { key: d["date-picker"].type, value: d["date-picker"].name } ], Boolean: [ { key: d.switch.type, value: d.switch.name }, { key: d["check-box"].type, value: d["check-box"].name } ], Enum: [ { key: d["combo-list"].type, value: d["combo-list"].name }, { key: d["radio-group"].type, value: d["radio-group"].name } ], Object: [ { key: d.lookup.type, value: d.lookup.name }, { key: d["combo-list"].type, value: d["combo-list"].name }, { key: d["radio-group"].type, value: d["radio-group"].name } ] }); let M = E; var I = /* @__PURE__ */ ((y) => (y.Form = "Form", y.Variable = "Variable", y))(I || {}); class L { constructor() { /** 控件标题 */ g(this, "label", ""); /** 控件id */ g(this, "id", ""); /** 每个控件占用的栅格数 */ g(this, "columnInSM", 12); g(this, "columnInMD", 6); g(this, "columnInLG", 3); g(this, "columnInEL", 2); /** 每个控件占用的列数 */ g(this, "displayWidthInSM", 1); g(this, "displayWidthInMD", 1); g(this, "displayWidthInLG", 1); g(this, "displayWidthInEL", 1); /** 编辑器内部默认显示的屏幕大小-----可以去掉 */ g(this, "displayColumnCountAtBreakPoint", "md"); /** 控件所在行,传0即可-----编辑器内部使用 */ g(this, "tagRow", 0); /** 控件是否显示上方空白:传0即可-----编辑器内部使用 */ g(this, "showTopBorder", 0); /** 区域,从1开始。卡片内的控件从上往下,从左往右划分区域,遇到分组fieldSet时group+1,分组结束后group+1 */ g(this, "group", 1); /** 控件是否符合标准的class配置(设计器用的) */ g(this, "isSupportedClass", !0); /** 控件所在分组id(设计器用的) */ g(this, "fieldSetId", ""); } } function oe(y) { let n, e; const t = /* @__PURE__ */ new Map(); let i = []; function s(a, r) { const h = ((a == null ? void 0 : a.split(" ")) || []).filter((v) => v.startsWith("col-")); if (h.length === 0) { r.isSupportedClass = !1; return; } let p = h.find((v) => /^col-([1-9]|10|11|12)$/.test(v)), f = h.find((v) => /^col-md-([1-9]|10|11|12)$/.test(v)), b = h.find((v) => /^col-xl-([1-9]|10|11|12)$/.test(v)), C = h.find((v) => /^col-el-([1-9]|10|11|12)$/.test(v)); p = p || "col-12", r.columnInSM = parseInt(p.replace("col-", ""), 10), r.displayWidthInSM = r.columnInSM / 12, r.displayWidthInSM !== 1 && (r.isSupportedClass = !1), f = f || "col-md-" + r.columnInSM, r.columnInMD = parseInt(f.replace("col-md-", ""), 10), r.displayWidthInMD = r.columnInMD / 6, [1, 2].includes(r.displayWidthInMD) || (r.isSupportedClass = !1), b = b || "col-xl-" + r.columnInMD, r.columnInLG = parseInt(b.replace("col-xl-", ""), 10), r.displayWidthInLG = r.columnInLG / 3, [1, 2, 3, 4].includes(r.displayWidthInLG) || (r.isSupportedClass = !1), C = C || "col-el-" + r.columnInLG, r.columnInEL = parseInt(C.replace("col-el-", ""), 10), r.displayWidthInEL = r.columnInEL / 2, [1, 2, 3, 4, 5, 6].includes(r.displayWidthInEL) || (r.isSupportedClass = !1); } function o(a, r, m, h = !1) { let p = !1; if (!a.contents || a.contents.length === 0) { const f = new L(); s(a.layout, f), r.push(f); return; } a.contents.forEach((f) => { if (f.type === "fieldset") { m += 1, o(f, r, m, !0), p = !0; return; } if (f.type === "dynamic-form") return; p && (m += 1, p = !1); const b = f.appearance && f.appearance.class, C = new L(); b ? s(b, C) : C.isSupportedClass = !1, C.label = f.label || f.id, C.id = f.id, C.group = m, h && (C.fieldSetId = a.id), e === f.id && (n = m), t.set(f.id, f), r.push(C); }); } function c(a) { const r = y.getComponentById(a); if (!r || !r.componentType || !r.componentType.startsWith("form")) return { result: !1, message: "只可以在响应式表单组件中调整响应式布局配置" }; const m = y.selectNode(r, (h) => h.type === d["response-form"].type); return !m || !m.contents || m.contents.length === 0 ? { result: !1, message: "Form区域内没有控件,请先添加控件" } : { result: !0, message: "", formNode: m }; } function l(a, r) { r = r || a.id; const { result: m, message: h, formNode: p } = c(r); if (!m) return { result: m, message: h }; e = a.id, i = [], t.clear(); const f = p.contents[0].type === d.fieldset.type ? 0 : 1; o(p, i, f); const b = i.find((v) => !v.isSupportedClass); return { defaultState: { defaultGroupNumber: n || 1, model: b ? "customize" : "standard" }, importData: i }; } function u(a, r) { r = r; const { result: m, formNode: h } = c(r); if (!m) return ""; const p = []; return a.forEach((f) => { var v; const b = t.get(f.id), C = b.appearance && b.appearance.class; if (C) { const w = C.split(" ").filter((q) => !q.startsWith("col-")), F = "col-" + f.columnInSM, U = "col-md-" + f.columnInMD, A = "col-xl-" + f.columnInLG, R = "col-el-" + f.columnInEL, $ = [F, U, A, R].concat(w); b.appearance.class = $.join(" "); } if (f.fieldSetId) { const k = h.contents.find((F) => F.id === f.fieldSetId), w = p.find((F) => F.id === f.fieldSetId); w ? (v = w.contents) == null || v.push(b) : (p.push(k), k.contents = [b]); } else p.push(b); }), h.contents = p, h.id; } return { checkCanFindFormNode: c, checkCanOpenLayoutEditor: l, changeFormControlsByResponseLayoutConfig: u, getResonseFormLayoutConfig: o }; } class re extends se { constructor(e, t) { super(e, t); g(this, "responseLayoutEditorFunction"); /** 控件绑定的变量 */ g(this, "bindingVarible"); g(this, "formGroupEvents", [ // { // label: 'fieldValueChanging', // name: '绑定字段值变化前事件', // }, // { // label: 'fieldValueChanged', // name: '绑定字段值变化后事件', // }, { label: "onClickLabel", name: "标签点击事件" } ]); g(this, "numberEditorOptions", { type: "number-spinner", useThousands: !1, keyboard: !1, showButton: !1 }); g(this, "showCustomValue", (e) => { var i; const t = this.designViewModelField != null && ((i = this.designViewModelField) == null ? void 0 : i.type.name) !== "Boolean"; return this.formRule ? e.dataType !== "boolean" : t; }); this.responseLayoutEditorFunction = oe(this.formSchemaUtils); } getCommonPropertyConfig(e, t, i = "Card") { this.propertyConfig.categories.basic = this.getBasicProperties(e, t, i), this.propertyConfig.categories.appearance = this.getAppearanceProperties(e, t), this.propertyConfig.categories.behavior = this.getBehaviorConfig(e, "form-group"); } getPropertyConfig(e, t) { return this.getCommonPropertyConfig(e, t, "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, t) { return this.propertyConfig.categories = {}, this.getCommonPropertyConfig(e, t, "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, t, i = "Card") { var a; const s = this; this.setDesignViewModelField(e); const { canChangeControlType: o, editorTypeList: c } = this.getAvailableEditorType(e); let l = c; this.formRule && (l = c.filter((r) => r.key !== "image" && r.key !== "rich-text-editor")); const u = { 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: l, readonly: !o } }, 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: ((a = e.editor) == null ? void 0 : a.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(r, m, h) { if (r) switch (r && r.propertyID) { case "type": { s.changeControlType(e, r, t); break; } case "label": { r.needRefreshControlTree = !0; break; } case "binding": { s.changeBindingField(e, r, h); break; } } } }; return i.toLocaleLowerCase() !== "card" && delete u.properties.showLabelType, u; } /** * 校验控件是否支持切换类型 * @param control 控件 */ checkCanChangeControlType(e, t) { 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 !== B.SimpleField) return !1; return !0; } /** * 获取可选的编辑器类型 */ getAvailableEditorType(e) { var s, o; const t = this.checkCanChangeControlType(e, this.viewModelId); if (!t) return { canChangeControlType: !1, editorTypeList: [{ key: e.editor.type, value: ((s = d[e.editor.type]) == null ? void 0 : s.name) || e.editor.type }] }; let i = []; return this.designViewModelField && this.designViewModelField.$type === B.SimpleField ? i = M.getEditorTypesByMDataType(this.designViewModelField.type.name, this.designViewModelField.multiLanguage) : this.bindingVarible && (i = M.getEditorTypesByMDataType(this.bindingVarible.type, !!((o = this.designViewModelField) != null && o.multiLanguage))), { canChangeControlType: t, editorTypeList: i }; } changeBindingField(e, t, i) { t.needRefreshEntityTree = !0; } getAppearanceProperties(e, t) { 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(s, o) { if (s) switch (s && s.propertyID) { case "responseLayout": i.responseLayoutEditorFunction.changeFormControlsByResponseLayoutConfig(s.propertyValue, i.componentId || e.id), i.updateUnifiedLayoutAfterResponseLayoutChanged(i.componentId), i.updateElementByParentContainer(e.id, t), delete e.responseLayout; break; case "class": i.updateUnifiedLayoutAfterControlChanged(s.propertyValue, e.id, this.componentId), V.value++; break; case "style": { V.value++; break; } } } }; } getEditorProperties(e) { return this.getComponentConfig(e); } /** * 卡片控件:切换控件类型后事件 * @param propertyData 控件DOM属性 * @param newControlType 新控件类型 */ changeControlType(e, t, i) { const s = t.propertyValue, o = i && i.parent && i.parent.schema; if (!o) return; const c = o.contents.findIndex((a) => a.id === e.id); if (c === -1) return; const l = o.contents[c]; let u; if (this.designViewModelField) { const m = this.formSchemaUtils.getViewModelById(this.viewModelId).fields.find((p) => p.id === this.designViewModelField.id).fieldSchema || {}; m.editor || (m.editor = {}), m.editor.$type = s, this.designViewModelUtils.getDgViewModel(this.viewModelId).changeField(this.designViewModelField.id, m, !1), u = this.controlCreatorUtils.setFormFieldProperty(this.designViewModelField, s); } u || (u = this.controlCreatorUtils.createFormGroupWithoutField(s)), Object.assign(u, { id: l.id, appearance: l.appearance, size: l.size, label: l.label, binding: l.binding }), Object.prototype.hasOwnProperty.call(l, "visible") && Object.assign(u, { visible: l.visible }), l.editor && ["readonly", "required", "placeholder"].map((a) => { Object.prototype.hasOwnProperty.call(l.editor, a) && (u.editor[a] = l.editor[a]); }), i != null && i.updateContextSchema ? i.updateContextSchema(u) : (i.schema = Object.assign(l, u), Object.assign(e, u)), Array.from(document.getElementsByClassName("dgComponentSelected")).forEach( (a) => a.classList.remove("dgComponentSelected") ), Array.from(document.getElementsByClassName("dgComponentFocused")).forEach( (a) => a.classList.remove("dgComponentFocused") ), V.value++, j(() => { this.getFormDesignerInstance().reloadPropertyPanel(); }); } getComponentConfig(e, t = {}, i = {}, s) { var m, h; const o = Object.assign({ description: "编辑器", title: "编辑器", type: "input-group", $converter: "/converter/property-editor.converter", parentPropertyID: "editor" }, t), c = (m = e.binding) != null && m.field ? [] : ["Const", "Variable", "StateMachine"], l = this.getPropertyEditorParams(e, c, "readonly"), u = this.getPropertyEditorParams(e, c, "required"), a = { readonly: { description: "", title: "只读", editor: l }, required: { description: "", title: "必填", type: "boolean", editor: u, visible: !!((h = e.binding) != null && h.field) }, placeholder: { description: "当控件没有值时在输入框中显示的文本", title: "提示文本", type: "string" } }; for (const p in i) a[p] = Object.assign(a[p] || {}, i[p]); const r = this; return { ...o, properties: { ...a }, setPropertyRelates(p, f) { if (p) { switch (p.propertyID) { case "readonly": case "required": r.afterMutilEditorChanged(e, p); break; } s && s.bind(r)(p, e, f); } } }; } /** * 修改某一输入控件的样式后更新Form的统一布局配置 * @param controlClass 控件样式 * @param controlId 控件Id * @param componentId 控件所在组件id */ updateUnifiedLayoutAfterControlChanged(e, t, i) { const s = e.split(" "); let o = s.find((r) => /^col-([1-9]|10|11|12)$/.test(r)), c = s.find((r) => /^col-md-([1-9]|10|11|12)$/.test(r)), l = s.find((r) => /^col-xl-([1-9]|10|11|12)$/.test(r)), u = s.find((r) => /^col-el-([1-9]|10|11|12)$/.test(r)); o = o || "col-12", c = c || "col-md-" + o.replace("col-", ""), l = l || "col-xl-" + c.replace("col-md-", ""), u = u || "col-el-" + l.replace("col-xl-", ""); const a = { id: t, columnInSM: parseInt(o.replace("col-", ""), 10), columnInMD: parseInt(c.replace("col-md-", ""), 10), columnInLG: parseInt(l.replace("col-xl-", ""), 10), columnInEL: parseInt(u.replace("col-el-", ""), 10) }; this.updateUnifiedLayoutAfterResponseLayoutChanged(i, a); } /** * 修改控件布局配置后更新Form统一布局配置 * @param componentId 组件Id * @param controlLayoutConfig 某单独变动的控件配置项,FormResponseLayoutContext类型 */ updateUnifiedLayoutAfterResponseLayoutChanged(e, t) { const { formNode: i } = this.responseLayoutEditorFunction.checkCanFindFormNode(e); if (!i || !i.unifiedLayout) return; const s = []; if (this.responseLayoutEditorFunction.getResonseFormLayoutConfig(i, s, 1), t) { const p = s.find((f) => f.id === t.id); Object.assign(p || {}, t); } const o = s.map((p) => p.columnInSM), c = s.map((p) => p.columnInMD), l = s.map((p) => p.columnInLG), u = s.map((p) => p.columnInEL), a = this.checkIsUniqueColumn(o) ? o[0] : null, r = this.checkIsUniqueColumn(c) ? c[0] : null, m = this.checkIsUniqueColumn(l) ? l[0] : null, h = this.checkIsUniqueColumn(u) ? u[0] : null; Object.assign(i.unifiedLayout, { uniqueColClassInSM: a, uniqueColClassInMD: r, uniqueColClassInLG: m, uniqueColClassInEL: h }); } /** * 校验宽度样式值是否一致 */ checkIsUniqueColumn(e) { const t = new Set(e); return Array.from(t).length === 1; } /** * 枚举项编辑器 * @param propertyData * @param valueField * @param textField * @returns */ getItemCollectionEditor(e, t, i) { return t = t || "value", i = i || "name", { editor: { columns: [ { field: t, title: "值", dataType: "string" }, { field: i, title: "名称", dataType: "string" } // { field: 'disabled', title: '禁用', dataType: 'boolean', editor: { type: 'switch' } }, ], type: "item-collection-editor", valueField: t, nameField: i, requiredFields: [t, i], uniqueFields: [t, 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 === ee.EnumType); } /** * 将字段值变化前事件、变化后事件追加到交互面板 * 注意:因为绑定字段值变化后事件与下拉框的值变化事件(valueChanged)重名,所以这里将事件label都重命名下 */ appendFieldValueChangeEvents(e, t) { e.binding && e.binding.type === I.Form && e.binding.field ? (t.find((i) => i.label === "fieldValueChanging"), t.find((i) => i.label === "fieldValueChanged"), this.designViewModelField && (e.fieldValueChanging = this.designViewModelField.valueChanging, e.fieldValueChanged = this.designViewModelField.valueChanged)) : t = t.filter((i) => i.label !== "fieldValueChanging" && i.label !== "fieldValueChanged"); } getControlMethodType(e) { if (!e.binding) return e.type; switch (e.binding.type) { case I.Form: return e.binding.path || e.type; case I.Variable: return e.binding.fullPath || e.type; } return e.type; } updateLinkedLabel(e, t) { if (e.boundEventsList && e.boundEventsList.length > 0) { const i = e.boundEventsList.find((s) => s.boundEvents && s.boundEvents.label === "onClickLabel"); t.linkLabel = !!i; } else t.linkLabel = !1; } getInputCommonEvents(e) { return e.binding && e.binding.type === I.Variable ? [{ label: "onClickLabel", name: "标签点击事件" }] : [...this.formGroupEvents]; } /** * 组装输入类控件的交互面板:包含标签超链、绑定字段值变化前后事件等。 * @param propertyData 属性值 * @param viewModelId 视图模型id * @param showPosition 面板展示位置 * @param customEvent 输入控件特有的事件配置 */ getEventPropertyConfig(e, t = "card", i, s) { const o = this; let c = this.getInputCommonEvents(e); if (i && (c = c.concat(i)), c.length === 0) return { title: "事件", hideTitle: !0, properties: {}, tabId: "commands", tabName: "交互", hide: !0 }; this.appendFieldValueChangeEvents(e, c); const l = o.eventsEditorUtils.formProperties(e, o.viewModelId, c); return { title: "事件", hideTitle: !0, properties: o.createBaseEventProperty(l), tabId: "commands", tabName: "交互", setPropertyRelates(r, m) { const h = r.propertyValue; delete e[o.viewModelId], h && (h.setPropertyRelates = this.setPropertyRelates, h.controlInfo = { type: o.getControlMethodType(e), name: e.title }, o.eventsEditorUtils.saveRelatedParameters(e, o.viewModelId, h.events, h), o.updateLinkedLabel(h, m)), s && s(r, m, h); const p = o.designViewModelUtils.getDgViewModel(o.viewModelId); p && o.designViewModelField && p.changeField(o.designViewModelField.id, { valueChanging: e.fieldValueChanging, valueChanged: e.fieldValueChanged }); } }; } getExpressionConfig(e, t, i = ["compute", "dependency", "validate"], s) { return this.expressionProperty.getExpressionConfig(e, t, i, s); } 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, t, i) { var s; e.editor[t] !== i ? e.editor[t] = i : (s = this.getFormDesignerInstance()) == null || s.reloadPropertyPanel(); } setBooleanValue(e, t, i) { let s = i; this.getBindingDataType() === "string" && (s = (s || "").trim() || (t === "trueValue" ? "true" : "false")); const c = t === "trueValue" ? "falseValue" : "trueValue"; e.editor[c] === s && (s = s + 1), this.updatePropertyValue(e, t, s); } getBooleanValueConverter() { return { convertFrom: (e, t) => e.editor[t], convertTo: (e, t, i) => { this.setBooleanValue(e, t, i); } }; } } class le extends re { constructor(n, e) { super(n, e); } getEditorProperties(n) { const e = n.editor.format || "HH:mm:ss"; return this.getComponentConfig(n, { type: "time-picker" }, { editable: { description: "", title: "允许编辑", type: "boolean" }, use12Hours: { description: "", title: "是否使用12小时制", type: "boolean", refreshPanelAfterChanged: !0 }, format: { description: "", title: "格式", type: "enum", editor: { type: "combo-list", textField: "name", valueField: "value", data: n.editor.use12Hours ? [ { value: "hh:mm:ss", name: "hh:mm:ss" }, { value: "hh:mm", name: "hh:mm" } ] : [ { value: "HH:mm:ss", name: "HH:mm:ss" }, { value: "HH:mm", name: "HH:mm" } ] } }, showHeader: { description: "", title: "是否显示时分秒标题", type: "boolean" }, hourStep: { description: "", title: "时步长", type: "number", editor: { min: 1, max: 12, useThousands: !1 } }, minuteStep: { description: "", title: "分步长", type: "number", editor: { min: 1, max: 30, useThousands: !1 } }, secondStep: { description: "", title: "秒步长", type: "number", editor: { min: 1, max: 30, useThousands: !1 }, visible: e.includes("ss") } }, (t, i) => { t.propertyID === "use12Hours" && (