diff --git a/package.json b/package.json index 268d6e0..85f31ce 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "axios": "^0.24.0", "clipboard": "^2.0.8", "core-js": "^3.6.5", - "element-plus": "^1.3.0-beta.9", + "element-plus": "^2.0.4", "file-saver": "^2.0.5", "mitt": "^3.0.0", "sortablejs": "1.14.0", diff --git a/src/components/form-designer/form-widget/container-widget/containerMixin.js b/src/components/form-designer/form-widget/container-widget/containerMixin.js index 72c8f79..c3224a0 100644 --- a/src/components/form-designer/form-widget/container-widget/containerMixin.js +++ b/src/components/form-designer/form-widget/container-widget/containerMixin.js @@ -1,4 +1,13 @@ export default { + inject: ['getFormConfig'], + + computed: { + formConfig() { + return this.getFormConfig() + }, + + }, + methods: { appendTableRow(widget) { this.designer.appendTableRow(widget) diff --git a/src/components/form-designer/form-widget/field-widget/cascader-widget.vue b/src/components/form-designer/form-widget/field-widget/cascader-widget.vue index 8a0830c..d307202 100644 --- a/src/components/form-designer/form-widget/field-widget/cascader-widget.vue +++ b/src/components/form-designer/form-widget/field-widget/cascader-widget.vue @@ -55,7 +55,6 @@ components: { FormItemWrapper, }, - inject: ['refList', 'formConfig', 'globalOptionData', 'globalModel'], data() { return { oldFieldValue: null, //field组件change之前的值 diff --git a/src/components/form-designer/form-widget/field-widget/checkbox-widget.vue b/src/components/form-designer/form-widget/field-widget/checkbox-widget.vue index 351c6dc..bbef3d2 100644 --- a/src/components/form-designer/form-widget/field-widget/checkbox-widget.vue +++ b/src/components/form-designer/form-widget/field-widget/checkbox-widget.vue @@ -58,7 +58,6 @@ components: { FormItemWrapper, }, - inject: ['refList', 'formConfig', 'globalOptionData', 'globalModel'], data() { return { oldFieldValue: null, //field组件change之前的值 diff --git a/src/components/form-designer/form-widget/field-widget/color-widget.vue b/src/components/form-designer/form-widget/field-widget/color-widget.vue index 75cf669..ff5bf3c 100644 --- a/src/components/form-designer/form-widget/field-widget/color-widget.vue +++ b/src/components/form-designer/form-widget/field-widget/color-widget.vue @@ -49,7 +49,6 @@ components: { FormItemWrapper, }, - inject: ['refList', 'formConfig', 'globalOptionData', 'globalModel'], data() { return { oldFieldValue: null, //field组件change之前的值 diff --git a/src/components/form-designer/form-widget/field-widget/date-range-widget.vue b/src/components/form-designer/form-widget/field-widget/date-range-widget.vue index 64bbd7d..1580745 100644 --- a/src/components/form-designer/form-widget/field-widget/date-range-widget.vue +++ b/src/components/form-designer/form-widget/field-widget/date-range-widget.vue @@ -56,7 +56,6 @@ components: { FormItemWrapper, }, - inject: ['refList', 'formConfig', 'globalOptionData', 'globalModel'], data() { return { oldFieldValue: null, //field组件change之前的值 diff --git a/src/components/form-designer/form-widget/field-widget/date-widget.vue b/src/components/form-designer/form-widget/field-widget/date-widget.vue index 13db9bd..5452d82 100644 --- a/src/components/form-designer/form-widget/field-widget/date-widget.vue +++ b/src/components/form-designer/form-widget/field-widget/date-widget.vue @@ -54,7 +54,6 @@ components: { FormItemWrapper, }, - inject: ['refList', 'formConfig', 'globalOptionData', 'globalModel'], data() { return { oldFieldValue: null, //field组件change之前的值 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 c309f96..d22800b 100644 --- a/src/components/form-designer/form-widget/field-widget/fieldMixin.js +++ b/src/components/form-designer/form-widget/field-widget/fieldMixin.js @@ -3,9 +3,13 @@ import FormValidators from '@/utils/validators' import eventBus from "@/utils/event-bus" export default { - inject: ['refList', 'formConfig', 'globalOptionData', 'globalModel', 'getOptionData'], + inject: ['refList', 'getFormConfig', 'globalOptionData', 'globalModel', 'getOptionData'], computed: { + formConfig() { + return this.getFormConfig() + }, + widgetSize() { return this.field.options.size || 'default' }, diff --git a/src/components/form-designer/form-widget/field-widget/file-upload-widget.vue b/src/components/form-designer/form-widget/field-widget/file-upload-widget.vue index db04a78..7caf101 100644 --- a/src/components/form-designer/form-widget/field-widget/file-upload-widget.vue +++ b/src/components/form-designer/form-widget/field-widget/file-upload-widget.vue @@ -77,7 +77,6 @@ SvgIcon, FormItemWrapper, }, - inject: ['refList', 'formConfig', 'globalOptionData', 'globalModel'], data() { return { oldFieldValue: null, //field组件change之前的值 diff --git a/src/components/form-designer/form-widget/field-widget/form-item-wrapper.vue b/src/components/form-designer/form-widget/field-widget/form-item-wrapper.vue index 237c608..3cd44e0 100644 --- a/src/components/form-designer/form-widget/field-widget/form-item-wrapper.vue +++ b/src/components/form-designer/form-widget/field-widget/form-item-wrapper.vue @@ -93,8 +93,12 @@ rules: Array, }, - inject: ['formConfig'], + inject: ['getFormConfig'], computed: { + formConfig() { + return this.getFormConfig() + }, + selected() { return !!this.designer && this.field.id === this.designer.selectedId }, diff --git a/src/components/form-designer/form-widget/field-widget/input-widget.vue b/src/components/form-designer/form-widget/field-widget/input-widget.vue index 04f29da..3c21855 100644 --- a/src/components/form-designer/form-widget/field-widget/input-widget.vue +++ b/src/components/form-designer/form-widget/field-widget/input-widget.vue @@ -61,7 +61,6 @@ components: { FormItemWrapper, }, - inject: ['refList', 'formConfig', 'globalOptionData', 'globalModel'], data() { return { oldFieldValue: null, //field组件change之前的值 diff --git a/src/components/form-designer/form-widget/field-widget/number-widget.vue b/src/components/form-designer/form-widget/field-widget/number-widget.vue index 441736f..6535de0 100644 --- a/src/components/form-designer/form-widget/field-widget/number-widget.vue +++ b/src/components/form-designer/form-widget/field-widget/number-widget.vue @@ -53,7 +53,6 @@ components: { FormItemWrapper, }, - inject: ['refList', 'formConfig', 'globalOptionData', 'globalModel'], data() { return { oldFieldValue: null, //field组件change之前的值 diff --git a/src/components/form-designer/form-widget/field-widget/picture-upload-widget.vue b/src/components/form-designer/form-widget/field-widget/picture-upload-widget.vue index 76c5ca4..228ea97 100644 --- a/src/components/form-designer/form-widget/field-widget/picture-upload-widget.vue +++ b/src/components/form-designer/form-widget/field-widget/picture-upload-widget.vue @@ -60,7 +60,6 @@ components: { FormItemWrapper, }, - inject: ['refList', 'formConfig', 'globalOptionData', 'globalModel'], data() { return { oldFieldValue: null, //field组件change之前的值 @@ -180,8 +179,12 @@ handlePictureRemove(file, fileList) { this.fileList = deepClone(fileList) //this.fileList = fileList this.updateUploadFieldModelAndEmitDataChange(fileList) - this.uploadBtnHidden = fileList.length >= this.field.options.limit + + if (!!this.field.options.onFileRemove) { + let customFn = new Function('file', 'fileList', this.field.options.onFileRemove) + customFn.call(this, file, fileList) + } }, handelUploadError(err, file, fileList) { diff --git a/src/components/form-designer/form-widget/field-widget/radio-widget.vue b/src/components/form-designer/form-widget/field-widget/radio-widget.vue index 4d6dd48..8f74cdb 100644 --- a/src/components/form-designer/form-widget/field-widget/radio-widget.vue +++ b/src/components/form-designer/form-widget/field-widget/radio-widget.vue @@ -58,7 +58,6 @@ components: { FormItemWrapper, }, - inject: ['refList', 'formConfig', 'globalOptionData', 'globalModel'], data() { return { oldFieldValue: null, //field组件change之前的值 diff --git a/src/components/form-designer/form-widget/field-widget/rate-widget.vue b/src/components/form-designer/form-widget/field-widget/rate-widget.vue index d3fadc1..74d3150 100644 --- a/src/components/form-designer/form-widget/field-widget/rate-widget.vue +++ b/src/components/form-designer/form-widget/field-widget/rate-widget.vue @@ -52,7 +52,6 @@ components: { FormItemWrapper, }, - inject: ['refList', 'formConfig', 'globalOptionData', 'globalModel'], data() { return { oldFieldValue: null, //field组件change之前的值 diff --git a/src/components/form-designer/form-widget/field-widget/rich-editor-widget.vue b/src/components/form-designer/form-widget/field-widget/rich-editor-widget.vue index fc14e43..f501a1f 100644 --- a/src/components/form-designer/form-widget/field-widget/rich-editor-widget.vue +++ b/src/components/form-designer/form-widget/field-widget/rich-editor-widget.vue @@ -71,7 +71,6 @@ // } quillEditor, }, - inject: ['refList', 'formConfig', 'globalOptionData', 'globalModel'], data() { return { oldFieldValue: null, //field组件change之前的值 diff --git a/src/components/form-designer/form-widget/field-widget/select-widget.vue b/src/components/form-designer/form-widget/field-widget/select-widget.vue index 215ff00..06c4e51 100644 --- a/src/components/form-designer/form-widget/field-widget/select-widget.vue +++ b/src/components/form-designer/form-widget/field-widget/select-widget.vue @@ -61,7 +61,6 @@ components: { FormItemWrapper, }, - inject: ['refList', 'formConfig', 'globalOptionData', 'globalModel'], data() { return { oldFieldValue: null, //field组件change之前的值 diff --git a/src/components/form-designer/form-widget/field-widget/slider-widget.vue b/src/components/form-designer/form-widget/field-widget/slider-widget.vue index 0b65ca2..fd28c34 100644 --- a/src/components/form-designer/form-widget/field-widget/slider-widget.vue +++ b/src/components/form-designer/form-widget/field-widget/slider-widget.vue @@ -50,7 +50,6 @@ components: { FormItemWrapper, }, - inject: ['refList', 'formConfig', 'globalOptionData', 'globalModel'], data() { return { oldFieldValue: null, //field组件change之前的值 diff --git a/src/components/form-designer/form-widget/field-widget/switch-widget.vue b/src/components/form-designer/form-widget/field-widget/switch-widget.vue index 44d5588..af475b3 100644 --- a/src/components/form-designer/form-widget/field-widget/switch-widget.vue +++ b/src/components/form-designer/form-widget/field-widget/switch-widget.vue @@ -51,7 +51,6 @@ components: { FormItemWrapper, }, - inject: ['refList', 'formConfig', 'globalOptionData', 'globalModel'], data() { return { oldFieldValue: null, //field组件change之前的值 diff --git a/src/components/form-designer/form-widget/field-widget/textarea-widget.vue b/src/components/form-designer/form-widget/field-widget/textarea-widget.vue index 15b677c..286bef3 100644 --- a/src/components/form-designer/form-widget/field-widget/textarea-widget.vue +++ b/src/components/form-designer/form-widget/field-widget/textarea-widget.vue @@ -53,7 +53,6 @@ components: { FormItemWrapper, }, - inject: ['refList', 'formConfig', 'globalOptionData', 'globalModel'], data() { return { oldFieldValue: null, //field组件change之前的值 diff --git a/src/components/form-designer/form-widget/field-widget/time-range-widget.vue b/src/components/form-designer/form-widget/field-widget/time-range-widget.vue index df77a7a..38e170e 100644 --- a/src/components/form-designer/form-widget/field-widget/time-range-widget.vue +++ b/src/components/form-designer/form-widget/field-widget/time-range-widget.vue @@ -57,7 +57,6 @@ components: { FormItemWrapper, }, - inject: ['refList', 'formConfig', 'globalOptionData', 'globalModel'], data() { return { oldFieldValue: null, //field组件change之前的值 diff --git a/src/components/form-designer/form-widget/field-widget/time-widget.vue b/src/components/form-designer/form-widget/field-widget/time-widget.vue index 723c5f3..e564f6b 100644 --- a/src/components/form-designer/form-widget/field-widget/time-widget.vue +++ b/src/components/form-designer/form-widget/field-widget/time-widget.vue @@ -54,7 +54,6 @@ components: { FormItemWrapper, }, - inject: ['refList', 'formConfig', 'globalOptionData', 'globalModel'], data() { return { oldFieldValue: null, //field组件change之前的值 diff --git a/src/components/form-designer/form-widget/index.vue b/src/components/form-designer/form-widget/index.vue index f12aac1..647abaa 100644 --- a/src/components/form-designer/form-widget/index.vue +++ b/src/components/form-designer/form-widget/index.vue @@ -53,7 +53,7 @@ provide() { return { refList: this.widgetRefList, - formConfig: this.formConfig, + getFormConfig: () => this.formConfig, /* 解决provide传递formConfig属性的响应式更新问题!! */ globalOptionData: this.optionData, getOptionData: () => this.optionData, globalModel: { @@ -172,7 +172,6 @@