diff --git a/src/components/form-designer/form-widget/field-widget/fieldMixin.js b/src/components/form-designer/form-widget/field-widget/fieldMixin.js index e161aea..08e1d8d 100644 --- a/src/components/form-designer/form-widget/field-widget/fieldMixin.js +++ b/src/components/form-designer/form-widget/field-widget/fieldMixin.js @@ -25,6 +25,13 @@ export default { methods: { //--------------------- 组件内部方法 begin ------------------// + getPropName() { + if (this.subFormItemFlag && !this.designState) { + return this.subFormName + "." + this.subFormRowIndex + "." + this.field.options.name + "" + } else { + return this.field.options.name + } + }, initFieldModel() { if (!this.field.formItemFlag) { @@ -304,7 +311,7 @@ export default { } }, - handleChangeEvent(value) { + handleChangeEvent(value) { /* input的清除输入小按钮会同时触发handleChangeEvent、handleInputCustomEvent!! */ this.syncUpdateFormModel(value) this.emitFieldDataChange(value, this.oldFieldValue) @@ -312,7 +319,7 @@ export default { this.oldFieldValue = deepClone(value) /* oldFieldValue需要在initFieldModel()方法中赋初值!! */ /* 主动触发表单的单个字段校验,用于清除字段可能存在的校验错误提示 */ - this.dispatch('VFormRender', 'fieldValidation', [this.field.options.name]) + this.dispatch('VFormRender', 'fieldValidation', [this.getPropName()]) }, handleFocusCustomEvent(event) { @@ -335,7 +342,7 @@ export default { this.syncUpdateFormModel(value) /* 主动触发表单的单个字段校验,用于清除字段可能存在的校验错误提示 */ - this.dispatch('VFormRender', 'fieldValidation', [this.field.options.name]) + this.dispatch('VFormRender', 'fieldValidation', [this.getPropName()]) if (!!this.field.options.onInput) { let customFn = new Function('value', this.field.options.onInput) @@ -429,11 +436,12 @@ export default { }, resetField() { + if (!!this.subFormItemFlag) { //跳过子表单组件 + return + } + let defaultValue = this.field.options.defaultValue this.setValue(defaultValue) - this.$nextTick(() => { - // - }) //清空上传组件文件列表 if ((this.field.type === 'picture-upload') || (this.field.type === 'file-upload')) { @@ -519,7 +527,7 @@ export default { reloadOptions(options) { this.field.options.optionItems = deepClone(options) }, - + /** * 返回radio/checkbox/select/cascader的选项数据 * @returns 选择项数组 diff --git a/src/components/form-designer/index.vue b/src/components/form-designer/index.vue index f322f1f..2a5362c 100644 --- a/src/components/form-designer/index.vue +++ b/src/components/form-designer/index.vue @@ -65,7 +65,13 @@ import SettingPanel from './setting-panel/index' import VFormWidget from './form-widget/index' import {createDesigner} from "@/components/form-designer/designer" - import {addWindowResizeHandler, deepClone, getQueryParam} from "@/utils/util" + import { + addWindowResizeHandler, + deepClone, + getAllContainerWidgets, + getAllFieldWidgets, + getQueryParam + } from "@/utils/util" import {MOCK_CASE_URL, VARIANT_FORM_VERSION} from "@/utils/config" import i18n, { changeLocale } from "@/utils/i18n" import axios from "axios" @@ -101,12 +107,15 @@ externalLink: true, //是否显示GitHub、文档等外部链接 formTemplates: true, //是否显示表单模板 eventCollapse: true, //是否显示组件事件属性折叠面板 + widgetNameReadonly: false, //禁止修改组件名称 + clearDesignerButton: true, //是否显示清空设计器按钮 previewFormButton: true, //是否显示预览表单按钮 importJsonButton: true, //是否显示导入JSON按钮 exportJsonButton: true, //是否显示导出JSON器按钮 exportCodeButton: true, //是否显示导出代码按钮 generateSFCButton: true, //是否显示生成SFC按钮 + toolBarMaxWidth: 420, //设计器工具按钮栏最大宽度(单位像素) presetCssCode: '', //设计器预设CSS样式代码 } @@ -327,6 +336,22 @@ this.$refs.toolbarRef.generateSFC() }, + /** + * 获取所有字段组件 + * @returns {*[]} + */ + getFieldWidgets() { + return getAllFieldWidgets(this.designer.widgetList) + }, + + /** + * 获取所有容器组件 + * @returns {*[]} + */ + getContainerWidgets() { + return getAllContainerWidgets(this.designer.widgetList) + }, + //TODO: 增加更多方法!! } @@ -334,6 +359,14 @@