UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,388 lines 64.2 kB
var G = Object.defineProperty; var O = (h, n, e) => n in h ? G(h, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[n] = e; var f = (h, n, e) => O(h, typeof n != "symbol" ? n + "" : n, e); import W, { timePickerProps as z } from "../../components/time-picker/index.esm.js"; import { resolveAppearance as _, createPropsResolver as X } from "../../components/dynamic-resolver/index.esm.js"; import { createVNode as x, Fragment as Y, createTextVNode as J, nextTick as Q, defineComponent as Z, ref as P, inject as T, onMounted as j } from "vue"; import { FButtonEdit as K } from "../../components/button-edit/index.esm.js"; import { DgControl as o, canvasChanged as w, refreshCanvas as D, useDesignerComponent as ee } from "../../components/designer-canvas/index.esm.js"; import { cloneDeep as te } from "lodash-es"; import { FormSchemaEntityField$Type as B, FormSchemaEntityFieldType$Type as ie, EVENT_PROPERTY_TAB_IDS as L } from "../../components/common/index.esm.js"; const ne = { /** * 绑定值,格式要与指定的 format 一致 * @default '' */ modelValue: { type: String, default: "" }, /** * 小时步长值 * @default 1 */ hourStep: { type: Number, default: 1 }, /** * 分钟步长值 * @default 1 */ minuteStep: { type: Number, default: 1 }, /** * 秒步长值 * @default 1 */ secondStep: { type: Number, default: 1 }, popupClassName: { type: String, default: "" }, /** * 提示文字 * @default 请选择时间 */ placeholder: { type: String, default: "请选择时间" }, placement: { type: String, default: "auto" }, /** * 默认时间控件下拉面板,展开时显示的值 * @default null */ defaultOpenValue: { type: Date, default: null }, /** * 显示格式 * @default 'HH:mm:ss' */ format: { type: String, default: "HH:mm:ss" }, isOpen: { type: Boolean, default: !1 }, /** * 时间下拉面板是否显示标题 * @default false */ showHeader: { type: Boolean, default: !1 }, /** * 是否使用 12 小时制 * @default false */ use12Hours: { type: Boolean, default: !1 }, /** * @default null */ disabledHours: { type: Function, default: null }, /** * @default null */ disabledMinutes: { type: Function, default: null }, /** * @default null */ disabledSeconds: { type: Function, default: null }, /** * 是否隐藏被禁用的元素 * @default false */ hideDisabledElements: { type: Boolean, default: !1 }, /** * 禁用 * @default false */ disabled: { type: Boolean, default: !1 }, /** * 只读 * @default false */ readonly: { type: Boolean, default: !1 }, /** * 可编辑 * @default true */ editable: { type: Boolean, default: !0 }, /** * 是否可扩展 */ expandable: { type: Boolean, default: !1 }, /** * 扩展模式 text | button */ expandMode: { type: String, default: "text" }, /** * 扩展文本内容 */ expandContent: { type: String, default: "" }, /** * 扩展按钮是否禁用 */ expandDisabled: { type: Boolean, default: !1 }, enableClear: { type: Boolean, default: !0 } }; function se(h) { const { formSchemaUtils: n, formStateMachineUtils: e } = h; function t(l, c = "") { return { path: c + l.code, field: l.id, fullPath: l.code }; } function i(l, c = "") { const p = n.getViewModelById(l); return p ? p.states.map((d) => t(d, c)) : []; } function s(l) { const c = n.getRootViewModelId(), p = i(l); if (l === c) return p; const d = i(c, "root-component."); return [...p, ...d]; } function r(l) { return l.binding && l.binding.path || l.id || ""; } function a() { return e && e.getRenderStates() || []; } return { getVariables: s, getControlName: r, getStateMachines: a }; } class re { constructor(n) { f(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'" } ]); f(this, "expressionNames", { compute: "计算表达式", dependency: "依赖表达式", validate: "验证表达式", dataPicking: "帮助前表达式", visible: "可见表达式", readonly: "只读表达式", required: "必填表达式" }); f(this, "getExpressionConverter", (n, e) => ({ convertFrom: (t, i, s, r) => { const a = s.getExpressionRuleValue(n, e || i); return a && a.value || ""; }, convertTo: (t, i, s, r, a) => { var l; if (i === "dataPicking" && (s != null && s.target)) { const c = `${s.target}_dataPicking`; ((l = s.rules) == null ? void 0 : l.some( (d) => d.id === c && d.value )) ? t.dictPickingExpressionId = c : delete t.dictPickingExpressionId; } r.updateExpression(s); } })); this.formSchemaService = n; } getExpressionRule(n, e) { const t = this.getExpressionData(); if (!t) return ""; const i = t.find((r) => r.target === n); if (!i) return ""; const s = i.rules.find((r) => r.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 a; const s = this.createTreeNode(i, e); let r = []; (a = i.type) != null && a.fields && (r = this.buildEntityFieldsTreeData(i.type.fields, [...e, i.label])), t.push({ data: s, children: r, expanded: !0 }); }), t; } buildChildEntityTreeData(n = null, e) { const t = []; return n == null || n.forEach((i) => { var l, c; const s = this.createTreeNode(i, e); s.type = "entity"; const r = this.buildEntityFieldsTreeData((l = i.type) == null ? void 0 : l.fields, [...e, i.label]), a = this.buildChildEntityTreeData((c = i.type) == null ? void 0 : c.entities, [...e, i.label]); a != null && a.length && (r == null || r.push(...a)), t.push({ data: s, children: r || [], // 空值回退 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), r = this.getEntitiesAndVariables(), a = { message: ["validate", "required", "dataPicking"].includes(e) && s ? s.message : "", ...r }; return s.messageType != null && (a.messageType = s.messageType), a; } buildRule(n, e, t, i) { const { expression: s, message: r, messageType: a } = e, l = { id: `${n}_${t}`, type: t, value: s }; return (t === "validate" || t === "dataPicking" || t === "required") && (l.message = r), t === "dataPicking" && (l.messageType = a), 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, r = this.buildRule(s, t, i, n.type === "form-group" ? n.id : ""); let l = this.getExpressionData().find((p) => p.targetType === e && p.target === s); const c = (p) => p.value.trim() === ""; if (l) { const p = l.rules.find((d) => d.id === r.id); if (p) c(r) ? l.rules = l.rules.filter((d) => d.id !== r.id) : (Object.assign(p, r), i === "validate" && n.type === "form-group" && (p.elementId = n.id)); else { if (c(r)) return null; l.rules = l.rules || [], l.rules.push(r); } } else { if (c(r)) return null; l = { target: `${s}`, rules: [r], targetType: e }; } return l; } getExpressionEditorOptions(n, e, t, i) { return t.reduce((s, r) => { var l, c; const a = e === "Field" ? (l = n == null ? void 0 : n.binding) == null ? void 0 : l.field : n.id; return s[r] = { hide: e === "Field" ? !!((c = n == null ? void 0 : n.binding) != null && c.field) : !1, description: "", title: this.expressionNames[r], type: "string", $converter: this.getExpressionConverter(a), refreshPanelAfterChanged: !0, editor: { type: "expression-editor", singleExpand: !1, dialogTitle: `${this.expressionNames[r]}编辑器`, showMessage: r === "validate" || r === "dataPicking" || r === "required", showMessageType: r === "dataPicking", beforeOpen: () => this.onBeforeOpenExpression(n, r, e), onSubmitModal: (p) => { const d = this.updateExpression(n, e, p, r); if (i) { const m = this.buildRule(a, p, r); i(m); } return d; } } }, s; }, {}); } getExpressionInfo(n, e, t) { const i = e === "Field" ? n.binding.field : n.id, s = this.getExpressionRule(i, t), r = { value: s && s.value, targetId: i, targetType: e, expressionType: t }; return s && s.message && (r.message = s.message), r; } getExpressionConfig(n, e, t = ["compute", "dependency", "validate"], i) { var s; return { description: "表达式", title: "表达式", hide: !(n.binding && ((s = n.binding) == null ? void 0 : s.type) === "Form"), 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 oe { constructor(n, e) { f(this, "componentId"); f(this, "viewModelId"); f(this, "eventsEditorUtils"); f(this, "formSchemaUtils"); f(this, "formMetadataConverter"); f(this, "designViewModelUtils"); f(this, "designViewModelField"); f(this, "controlCreatorUtils"); f(this, "designerHostService"); f(this, "designerContext"); f(this, "modalService", null); /** 表单规则 */ f(this, "formRule", null); f(this, "schemaService", null); f(this, "metadataService", null); f(this, "propertyConfig", { type: "object", categories: {} }); f(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 re(this.formSchemaUtils); } /** * 是否在响应式表单中 */ inResponsiveForm() { var n; return !!((n = this.designerContext) != null && n.responsiveForm); } 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: o[n.type] && o[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 r in e) s[r] = Object.assign(s[r] || {}, e[r]); return { ...i, properties: { ...s }, setPropertyRelates(r, a) { if (r) { switch (r && r.propertyID) { case "class": case "style": { w.value++; break; } } t && t(r, n, a); } } }; } /** * * @param propertyData * @param propertyTypes * @param propertyName * @param constInfos * @param variableInfos * @param expressionType 指定表达式类型,存在属性和表达式类型不一致的情况 * @returns */ getPropertyEditorParams(n, e = [], t = "visible", i = {}, s = {}, r = "") { const { getVariables: a, getControlName: l, getStateMachines: c } = se(this.designerHostService), p = this.getRealTargetType(n), d = e && e.length > 0 ? e : ["Const", "Variable", "StateMachine", "Expression"], m = { type: "property-editor", propertyTypes: d }; return d.map((y) => { switch (y) { case "Const": Object.assign(m, { constType: "enum", constEnums: [{ id: !0, name: "是" }, { id: !1, name: "否" }] }, i); break; case "Expression": m.expressionConfig = this.getExpressionOptions(n, p, r || t); break; case "StateMachine": m.stateMachines = c(); break; case "Variable": Object.assign(m, { controlName: l(n), newVariablePrefix: "is", newVariableType: "Boolean", variables: a(this.viewModelId), parentComponentId: this.componentId === "root-component" ? "" : "root-component", onBeforeOpenVariables: (g) => { g.value = a(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", "Custom"] : e === "dataGrid" || e === "treeGrid" || e === "wizard" ? t = ["Const", "Variable", "Expression"] : (n.type.indexOf("toolbar-item") > -1 || e === "form-group") && (t = ["Const", "Variable", "StateMachine", "Custom", "Expression"]), { 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: "" }, r = this.getVisibleProperty(n, e); for (const l in t) r[l] = Object.assign(r[l] || {}, t[l]); const a = this; return { ...s, properties: { ...r }, setPropertyRelates(l, c) { if (l) { switch (l.propertyID) { case "disabled": case "readonly": case "visible": a.afterMutilEditorChanged(n, l); break; } i && i(l, c); } } }; } /** * 当多值编辑器变更时 * @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((r) => r.id === n), s = te(t.contents[i]); t.contents.splice(i, 1), t.contents.splice(i, 0, s), D(); } /** * 属性编辑器,在编辑过程中会新增变量,此处需要将新增的变量追加到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 r = { 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(r.code) || this.formSchemaUtils.getViewModelById("root-viewmodel").states.push(r); } 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: r, expressionInfo: a } = t, { targetId: l, targetType: c, expressionType: p, value: d, message: m } = a, y = this.getExpressions(); let g = y.find((b) => b.target === l); g || (g = { target: l, rules: [], targetType: c }, y.push(g)); const u = g.rules.find((b) => b.type === p); if (u) u.id = r, u.value = d, u.message = m, (p === "minDate" || p === "maxDate" || p === "defaultTime") && (u.elementId = e.id); else { const b = { id: r, type: p, value: d, message: m, elementId: e.id }; g.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, r = this.getExpressions(), a = e.binding ? e.binding.field : e.id, l = r.find((c) => c.target === a); !l || !l.rules || (l.rules = l.rules.filter((c) => c.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: o["language-textbox"].type, value: o["language-textbox"].name }]; let i = E.fieldControlTypeMapping[n]; if (t === "data-grid-column" && (i != null && i.length)) { const s = [o["check-group"].type, o["radio-group"].type, o.image.type, o["rich-text-editor"].type, o.avatar.type]; i = i.filter((r) => !s.includes(r.key)); } if (t === "tree-grid-column" && (i != null && i.length)) { const s = [o["check-group"].type, o["radio-group"].type, o.image.type, o["rich-text-editor"].type, o.avatar.type, o.switch.type]; i = i.filter((r) => !s.includes(r.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 === o["data-grid-column"].type || n.type === o["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 === o["input-group"].type || t === o.textarea.type || t === o["number-spinner"].type) && i.push({ domField: "editor.maxLength", schemaField: "type.length" }), t === o["number-spinner"].type && i.push({ domField: "editor.precision", schemaField: "type.precision" }), (n.type === o["data-grid-column"].type || n.type === o["tree-grid-column"].type) && i.push({ domField: "formatter.precision", schemaField: "type.precision" }), (t === o["combo-list"].type || t === o["radio-group"].type) && i.push({ domField: "editor.data", schemaField: "type.enumValues" }), (n.type === o["data-grid-column"].type || n.type === o["tree-grid-column"].type) && i.push({ domField: "formatter.data", schemaField: "type.enumValues" }), t === o["date-picker"].type && (i.push({ domField: "editor.displayFormat", schemaField: "editor.format" }), i.push({ domField: "editor.fieldType", schemaField: "type.name" })), t === o["number-spinner"].type && (i.push({ domField: "editor.max", schemaField: "editor.maxValue" }), i.push({ domField: "editor.min", schemaField: "editor.minValue" })), t === o.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 === o["data-grid-column"].type || n.type === o["tree-grid-column"].type) && i.push({ domField: "field", schemaField: "bindingPath" }), i; } }; /** * <字段类型,可配置的控件类型列表>的映射 */ f(E, "fieldControlTypeMapping", { String: [ { key: o["input-group"].type, value: o["input-group"].name }, { key: o.lookup.type, value: o.lookup.name }, { key: o.image.type, value: o.image.name }, { key: o["date-picker"].type, value: o["date-picker"].name }, { key: o.switch.type, value: o.switch.name }, { key: o["check-box"].type, value: o["check-box"].name }, { key: o["check-group"].type, value: o["check-group"].name }, { key: o["radio-group"].type, value: o["radio-group"].name }, { key: o["combo-list"].type, value: o["combo-list"].name }, { key: o.textarea.type, value: o.textarea.name }, { key: o["time-picker"].type, value: o["time-picker"].name }, { key: o["rich-text-editor"].type, value: o["rich-text-editor"].name } ], Text: [ { key: o.textarea.type, value: o.textarea.name }, { key: o.lookup.type, value: o.lookup.name }, { key: o.image.type, value: o.image.name }, { key: o.avatar.type, value: o.avatar.name }, { key: o["rich-text-editor"].type, value: o["rich-text-editor"].name } ], Decimal: [ { key: o["number-spinner"].type, value: o["number-spinner"].name } ], Integer: [ { key: o["number-spinner"].type, value: o["number-spinner"].name } ], Number: [ { key: o["number-spinner"].type, value: o["number-spinner"].name }, { key: o.switch.type, value: o.switch.name }, { key: o["check-box"].type, value: o["check-box"].name } ], BigNumber: [ { key: o["number-spinner"].type, value: o["number-spinner"].name } ], Date: [ { key: o["date-picker"].type, value: o["date-picker"].name } ], DateTime: [ { key: o["date-picker"].type, value: o["date-picker"].name } ], Boolean: [ { key: o.switch.type, value: o.switch.name }, { key: o["check-box"].type, value: o["check-box"].name } ], Enum: [ { key: o["combo-list"].type, value: o["combo-list"].name }, { key: o["radio-group"].type, value: o["radio-group"].name } ], Object: [ { key: o.lookup.type, value: o.lookup.name }, { key: o["combo-list"].type, value: o["combo-list"].name } // { key: DgControl['radio-group'].type, value: DgControl['radio-group'].name }, ] }); let M = E; var V = /* @__PURE__ */ ((h) => (h.Form = "Form", h.Variable = "Variable", h))(V || {}); class N { constructor() { /** 控件标题 */ f(this, "label", ""); /** 控件id */ f(this, "id", ""); /** 每个控件占用的栅格数 */ f(this, "columnInSM", 12); f(this, "columnInMD", 6); f(this, "columnInLG", 3); f(this, "columnInEL", 2); /** 每个控件占用的列数 */ f(this, "displayWidthInSM", 1); f(this, "displayWidthInMD", 1); f(this, "displayWidthInLG", 1); f(this, "displayWidthInEL", 1); /** 编辑器内部默认显示的屏幕大小-----可以去掉 */ f(this, "displayColumnCountAtBreakPoint", "md"); /** 控件所在行,传0即可-----编辑器内部使用 */ f(this, "tagRow", 0); /** 控件是否显示上方空白:传0即可-----编辑器内部使用 */ f(this, "showTopBorder", 0); /** 区域,从1开始。卡片内的控件从上往下,从左往右划分区域,遇到分组fieldSet时group+1,分组结束后group+1 */ f(this, "group", 1); /** 控件是否符合标准的class配置(设计器用的) */ f(this, "isSupportedClass", !0); /** 控件所在分组id(设计器用的) */ f(this, "fieldSetId", ""); } } function le(h) { let n, e; const t = /* @__PURE__ */ new Map(); let i = []; function s(p, d) { const y = (p || "").split(" ").filter((v) => v.startsWith("col-")); if (y.length === 0) { d.isSupportedClass = !1; return; } let g = y.find((v) => /^col-([1-9]|10|11|12)$/.test(v)), u = y.find((v) => /^col-md-([1-9]|10|11|12)$/.test(v)), b = y.find((v) => /^col-xl-([1-9]|10|11|12)$/.test(v)), C = y.find((v) => /^col-el-([1-9]|10|11|12)$/.test(v)); g = g || "col-12", d.columnInSM = parseInt(g.replace("col-", ""), 10), d.displayWidthInSM = d.columnInSM / 12, d.displayWidthInSM !== 1 && (d.isSupportedClass = !1), u = u || "col-md-" + d.columnInSM, d.columnInMD = parseInt(u.replace("col-md-", ""), 10), d.displayWidthInMD = d.columnInMD / 6, [1, 2].includes(d.displayWidthInMD) || (d.isSupportedClass = !1), b = b || "col-xl-" + d.columnInMD, d.columnInLG = parseInt(b.replace("col-xl-", ""), 10), d.displayWidthInLG = d.columnInLG / 3, [1, 2, 3, 4].includes(d.displayWidthInLG) || (d.isSupportedClass = !1), C = C || "col-el-" + d.columnInLG, d.columnInEL = parseInt(C.replace("col-el-", ""), 10), d.displayWidthInEL = d.columnInEL / 2, [1, 2, 3, 4, 5, 6].includes(d.displayWidthInEL) || (d.isSupportedClass = !1); } function r(p, d, m, y = !1) { let g = !1; if (!p.contents || p.contents.length === 0) { const u = new N(); s(p.layout, u), d.push(u); return; } p.contents.forEach((u) => { if (u.type === "fieldset") { m += 1, r(u, d, m, !0), g = !0; return; } if (u.type === "dynamic-form") return; g && (m += 1, g = !1); const b = u.appearance && u.appearance.class, C = new N(); b ? s(b, C) : C.isSupportedClass = !1, C.label = u.label || u.id, C.id = u.id, C.group = m, y && (C.fieldSetId = p.id), e === u.id && (n = m), t.set(u.id, u), d.push(C); }); } function a(p) { const d = h.getComponentById(p); if (!d || !d.componentType || !d.componentType.startsWith("form")) return { result: !1, message: "只可以在响应式表单组件中调整响应式布局配置" }; const m = h.selectNode(d, (y) => y.type === o["response-form"].type); return !m || !m.contents || m.contents.length === 0 ? { result: !1, message: "Form区域内没有控件,请先添加控件" } : { result: !0, message: "", formNode: m }; } function l(p, d) { d = d || p.id; const { result: m, message: y, formNode: g } = a(d); if (!m) return { result: m, message: y }; e = p.id, i = [], t.clear(); const u = g.contents[0].type === o.fieldset.type ? 0 : 1; r(g, i, u); const b = i.find((v) => !v.isSupportedClass); return { defaultState: { defaultGroupNumber: n || 1, model: b ? "customize" : "standard" }, importData: i }; } function c(p, d) { d = d; const { result: m, formNode: y } = a(d); if (!m) return ""; const g = []; return p.forEach((u) => { var v; const b = t.get(u.id), C = b.appearance && b.appearance.class; if (C) { const k = C.split(" ").filter((H) => !H.startsWith("col-")), I = "col-" + u.columnInSM, A = "col-md-" + u.columnInMD, R = "col-xl-" + u.columnInLG, $ = "col-el-" + u.columnInEL, q = [I, A, R, $].concat(k); b.appearance.class = q.join(" "); } if (u.fieldSetId) { const F = y.contents.find((I) => I.id === u.fieldSetId), k = g.find((I) => I.id === u.fieldSetId); k ? (v = k.contents) == null || v.push(b) : (g.push(F), F.contents = [b]); } else g.push(b); }), y.contents = g, y.id; } return { checkCanFindFormNode: a, checkCanOpenLayoutEditor: l, changeFormControlsByResponseLayoutConfig: c, getResonseFormLayoutConfig: r }; } const de = (h) => x(Y, null, [x("h5", null, [J("代码示例")]), x("pre", { style: "background-color: #f5f5f5; padding: 10px; border-radius: 5px;" }, [x("code", null, [` <h3>Tips:</h3> <span style="color: blue;"> 自定义提示内容 </span> `])])]); class ae extends oe { constructor(e, t) { super(e, t); f(this, "responseLayoutEditorFunction"); /** 控件绑定的变量 */ f(this, "bindingVarible"); f(this, "formGroupEvents", [ { label: "fieldValueChanging", name: "绑定字段值变化前事件" }, { label: "fieldValueChanged", name: "绑定字段值变化后事件" }, { label: "onClickLabel", name: "标签点击事件" } ]); f(this, "numberEditorOptions", { type: "number-spinner", useThousands: !1, keyboard: !1, showButton: !1 }); f(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 = le(this.formSchemaUtils); } getCommonPropertyConfig(e, t, i = "Card") { if (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"), i === "Card") { const s = this.getTipsConfig(e); this.propertyConfig.categories.behavior.properties = { ...this.propertyConfig.categories.behavior.properties, ...s }, ["time-picker", "date-picker", "lookup", "combo-list", "number-spinner", "input-group", "language-textbox"].includes(e.editor.type) && (this.propertyConfig.categories.expansion = this.getExpandProperties(e, i)); } } 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 d; const s = this; this.setDesignViewModelField(e); const { canChangeControlType: r, editorTypeList: a } = this.getAvailableEditorType(e), l = this.getPropertyEditorParams(e, ["Variable"], "label", {}, { newVariablePrefix: "", newVariableType: "String" }); let c = a; this.formRule && (c = a.filter((m) => m.key !== "image" && m.key !== "rich-text-editor" && m.key !== "avatar")); const p = { 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: c, readonly: !r } }, titleSourceType: { description: "标签来源类型", title: "标签类型", type: "string", refreshPanelAfterChanged: !0, editor: { type: "combo-list", textField: "name", valueField: "id", idField: "id", editable: !1, data: [{ id: "static", name: "静态" }, { id: "dynamic", name: "动态" }] }, defaultValue: "static" }, label: { title: "标签", type: "string", $converter: "/converter/form-group-label.converter", visible: !e.titleSourceType || e.titleSourceType === "static" }, titleDataSource: { description: "标签", title: "标签", type: "string", editor: l, visible: e.titleSourceType === "dynamic" }, showLabelType: { description: "标签显示方式:1、显示:显示标签 2、占位:保留标签空间,但不显示文本 3、不显示:不显示标签", title: "标签显示", type: "enum", editor: { data: [{ id: "visible", name: "显示" }, { id: "reserve-space", name: "占位" }, { id: "none", name: "不显示" }] }, defaultValue: ((d = e.editor) == null ? void 0 : d.type) === "image" ? "none" : "visible" }, binding: { description: "绑定的表单字段", title: "绑定", editor: { type: "binding-selector", bindingType: { enable: !0 }, title: "绑定编辑器", 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(m, y, g) { if (m) switch (m && m.propertyID) { case "type": { s.changeControlType(e, m, t); break; } case "label": { m.needRefreshControlTree = !0; break; } case "binding": { s.changeBindingField(e, m, g); break; } case "titleDataSource": { s.afterMutilEditorChanged(e, m); break; } } } }; return i.toLocaleLowerCase() !== "card" && (p.hide = !0, delete p.properties.showLabelType), p; } getExpandProperties(e, t = "Card") { const i = this, s = ["Const", "Variable"], r = this.getPropertyEditorParams(e, s, "expandable"), a = this.getPropertyEditorParams(e, s, "expandDisabled"); return t === "Card" ? { description: "Expand Information", hide: !!this.formRule, title: "扩展区域", properties: { expandable: { description: "扩展区域是指输入框右侧的区域,常用于展示自定义按钮或者文本,以便于丰富输入控件的展示内容。", title: "启用扩展区域", refreshPanelAfterChanged: !0, $converter: "/converter/property-editor.converter", editor: r }, expandMode: { description: "静态文本:扩展内容不可点击;交互式按钮:扩展内容可以点击并配置交互事件。", title: "扩展模式", type: "enum", refreshPanelAfterChanged: !0, $converter: "/converter/property-editor.converter", editor: { data: [{ id: "text", name: "静态文本" }, { id: "button", name: "交互按钮" }] }, defaultValue: "text", visible: !!e.editor.expandable }, expandContent: { $converter: "/converter/property-editor.converter", description: "扩展区域内展示的文本内容", title: "扩展内容", type: "string", visible: !!e.editor.expandable, editor: { type: "code-editor", language: "html" } }, expandDisabled: { $converter: "/converter/property-editor.converter", description: "是否动态隐藏扩展区域,常用于根据变量或自定义条件配置扩展区域的隐藏状态。", title: "隐藏扩展区域", editor: a, visible: !!e.editor.expandable } }, setPropertyRelates(c, p) { if (c) switch (c.propertyID) { case "expandable": case "expandDisabled": i.afterMutilEditorChanged(e, c); break; } } } : { properties: {} }; } /** * 校验控件是否支持切换类型 * @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, r; const t = this.checkCanChangeControlType(e, this.viewModelId); if (!t) return { canChangeControlType: !1, editorTypeList: [{ key: e.editor.type, value: ((s = o[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, !!((r = this.designViewModelField) != null && r.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, r) { 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), w.value++; break; case "style": { w.value++; break; } } } }; } getEditorProperties(e) { return this.getComponentConfig(e); } /** * 卡片控件:切换控件类型后事件 * @param propertyData 控件DOM属性 * @param newControlType 新控件类型 */ changeControlType(e, t, i) { var g; const s = t.propertyValue, r = i && i.parent && i.parent.schema; if (!r) return; const a = r.contents.findIndex((u) => u.id === e.id); if (a === -1) return; const l = r.contents[a]; let c; if (this.designViewModelField) { const C = this.formSchemaUtils.getViewModelById(this.viewModelId).fields.find((F) => F.id === this.designViewModelField.id).fieldSchema || {}; C.editor || (C.editor = {}), C.editor.$type = s, this.designViewModelUtils.getDgViewModel(this.viewModelId).changeField(this.designViewModelField.id, C, !1), c = this.controlCreatorUtils.setFormFieldProperty(this.designViewModelField, s); } c || (c = this.controlCreatorUtils.createFormGroupWithoutField(s)), Object.assign(c, { id: l.id, appearance: l.appearance, size: l.size, label: l.label, binding: l.binding }), Object.prototype.hasOwnProperty.call(l, "visible") && Object.assign(c, { visible: l.visible }), l.editor && ["readonly", "required", "placeholder"].map((u) => { Object.prototype.hasOwnProperty.call(l.editor, u) && (c.editor[u] = l.editor[u]); }); const p = ["image", "avatar"], d = l.editor.type && p.indexOf(l.editor.type) > -1, m = ((g = c.editor) == null ? void 0 : g.type) && p.indexOf(c.editor.type) > -1; d && l.showLabelType === "none" && !m && (c.showLabelType = "visible"), i != null && i.updateContextSchema ? i.updateContextSchema(c) : (i.schema = Object.assign(l, c), Object.assign(e, c)), Array.from(document.getElementsByClassName("dgComponentSelected")).forEach( (u) => u.classList.remove("dgComponentSelected") ), Array.from(document.getElementsByClassName("dgComponentFocused")).forEach( (u) => u.classList.remove("dgComponentFocused") ), ["time-picker", "date-picker", "lookup", "combo-list", "number-spinner", "input-group", "textarea", "rich-text-editor", "language-textbox"].includes(e.editor.type) || (e.enableTips = !1), w.value++, Q(() => { this.getFormDesignerInstance().reloadPropertyPanel(); }); } getTipsConfig(e) { return ["time-picker", "date-picker", "lookup", "combo-list", "number-spinner", "input-group", "textarea", "rich-text-editor", "language-textbox"].includes(e.editor.type) ? { enableTips: { refreshPanelAfterChanged: !0, description: "", title: "启用提示", type: "boolean", default: !1, visible: !this.formRule }, tipsContent: { description: "提示内容", title: "提示内容", type: "string", editor: { type: "code-editor", language: "html", leftTemplate: de }, visible: !!e.enableTips && !this.formRule } } : {}; } getComponentConfig(e, t = {}, i = {}, s) { var m, y, g; const r = Object.assign({ description: "编辑器", title: "编辑器", type: "input-group", $converter: "/converter/property-editor.converter", parentPropertyID: "editor" }, t), a = (m = e.binding) != null && m.field ? ["Const", "Variable", "StateMachine", "Custom", "Expression"] : ["Const", "Variable", "StateMachine", "Custom"], l = this.getPropertyEditorParams(e, a, "readonly"), c = this.getPropertyEditorParams(e, a, "required"), p = { readonly: { description: "", title: "只读", editor: l }, required: { description: "", title: "必填", type: "boolean", editor: c, visible: !!((y = e.binding) != null && y.field) && ((g = e.binding) == null ? void 0 : g.type) === "Form" }, placeholder: { description: "当控件没有值时在输入框中显示的文本", title: "提示文本", type: "string" } }; for (const u in i) p[u] = Object.assign(p[u] || {}, i[u]); const d = this; return { ...r, properties: { ...p }, setPropertyRelates(u, b) { if (u) { switch (u.propertyID) { case "readonly": case "required": case "label": d.afterMutilEditorChanged(e, u); break; } s && s.bind(d)(u, e, b); } } }; } /** * 修改某一输入控件的样式后更新Form的统一布局配置 * @param controlClass 控件样式 * @param controlId 控件Id * @param componentId 控件所在组件id */ updateUnifiedLayoutAfterControlChanged(e, t, i) { const s = e.split(" "); let r = s.find((d) => /^col-([1-9]|10|11|12)$/.test(d)), a = s.find((d) => /^col-md-([1-9]|10|11|12)$/.test(d)), l = s.find((d) => /^col-xl-([1-9]|10|11|12)$/.test(d)), c = s.find((d) => /^col-el-([1-9]|10|11|12)$/.test(d)); r = r || "col-12", a = a || "col-md-" + r.replace("col-", ""), l = l || "col-xl-" + a.replace("col-md-", ""), c = c || "col-el-" + l.replace("col-xl-", ""); const p = { id: t, columnInSM: parseInt(r.replace("col-", ""), 10), columnInMD: parseInt(a.replace("col-md-", ""), 10), columnInLG: parseInt(l.replace("col-xl-", ""), 10), columnInEL: parseInt(c.replace("col-el-", ""), 10) }; this.updateUnifiedLayoutAfterResponseLayoutChanged(i, p); } /** * 修改控件布局配置后更新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 g = s.find((u) => u.id === t.id); Object.assign(g || {}, t); } const r = s.map((g) => g.columnInSM), a = s.map((g) => g.columnInMD), l = s.map((g) => g.columnInLG), c = s.map((g) => g.columnInEL), p = this.checkIsUniqueColumn(r) ? r[0] : null, d = this.checkIsUniqueColumn(a) ? a[0] : null, m = this.checkIsUniqueColumn(l) ? l[0] : null, y = this.checkIsUniqueColumn(c) ? c[0] : null; Object.assign(i.unifiedLayout, { uniqueColClassInSM: p, uniqueColClassInMD: d, uniqueColClassInLG: m, uniqueCo