From 5a77167ed48cf2daf83928cba5baa318d164071c Mon Sep 17 00:00:00 2001 From: vdpAdmin Date: Thu, 4 Aug 2022 16:01:29 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E4=BF=AE=E5=A4=8D=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E7=BB=84=E4=BB=B6=E7=9A=84=E5=A4=A7=E5=9B=BE?= =?UTF-8?q?=E9=A2=84=E8=A7=88=E5=8A=9F=E8=83=BD=EF=BC=9B=202.=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E9=83=A8=E5=88=86=E6=8B=BC=E5=86=99=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../field-widget/picture-upload-widget.vue | 7 ++++++- .../form-designer/toolbar-panel/index.vue | 18 +++++++++++++++++- src/utils/util.js | 14 +++++++------- src/utils/vue2js-generator.js | 4 ++-- 4 files changed, 32 insertions(+), 11 deletions(-) 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 74db269..5e32267 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 @@ -8,7 +8,7 @@ :with-credentials="field.options.withCredentials" :multiple="field.options.multipleSelect" :file-list="fileList" :show-file-list="field.options.showFileList" list-type="picture-card" :class="{'hideUploadDiv': uploadBtnHidden}" - :limit="field.options.limit" :on-exceed="handlePictureExceed" + :limit="field.options.limit" :on-exceed="handlePictureExceed" :on-preview="handlePicturePreview" :before-upload="beforePictureUpload" :on-success="handlePictureUpload" :on-error="handleUploadError" :before-remove="handleBeforeRemove" :on-remove="handlePictureRemove"> @@ -124,6 +124,11 @@ this.$message.warning( this.i18nt('render.hint.uploadExceed').replace('${uploadLimit}', uploadLimit) ) }, + handlePicturePreview(file) { + this.previewUrl = file.url + this.showPreviewDialogFlag = true + }, + beforePictureUpload(file) { let fileTypeCheckResult = false if (!!this.field.options && !!this.field.options.fileTypes) { diff --git a/src/components/form-designer/toolbar-panel/index.vue b/src/components/form-designer/toolbar-panel/index.vue index e01c981..fa3c6c8 100644 --- a/src/components/form-designer/toolbar-panel/index.vue +++ b/src/components/form-designer/toolbar-panel/index.vue @@ -67,6 +67,7 @@ Test Load Test SFJ Test SFD + Test ROD @@ -258,7 +259,13 @@ {label: '01', value: 1}, {label: '22', value: 2}, {label: '333', value: 3}, - ] + ], + + 'select001': [ + {label: '辣椒', value: 1}, + {label: '菠萝', value: 2}, + {label: '丑橘子', value: 3}, + ], }, } @@ -646,6 +653,15 @@ this.$refs.preForm.setFormData(testFD) }, + testReloadOptionData() { + this.testOptionData['select001'].push({ + label: 'aaa', + value: 888 + }) + + this.$refs.preForm.reloadOptionData() + }, + handleFormChange(fieldName, newValue, oldValue, formModel) { /* console.log('---formChange start---') diff --git a/src/utils/util.js b/src/utils/util.js index ad80715..4240614 100644 --- a/src/utils/util.js +++ b/src/utils/util.js @@ -152,7 +152,7 @@ export function traverseFieldWidgets(widgetList, handler, parent = null) { }) } -export function traverseContainWidgets(widgetList, handler) { +export function traverseContainerWidgets(widgetList, handler) { widgetList.map(w => { if (w.category === 'container') { handler(w) @@ -160,22 +160,22 @@ export function traverseContainWidgets(widgetList, handler) { if (w.type === 'grid') { w.cols.map(col => { - traverseContainWidgets(col.widgetList, handler) + traverseContainerWidgets(col.widgetList, handler) }) } else if (w.type === 'table') { w.rows.map(row => { row.cols.map(cell => { - traverseContainWidgets(cell.widgetList, handler) + traverseContainerWidgets(cell.widgetList, handler) }) }) } else if (w.type === 'tab') { w.tabs.map(tab => { - traverseContainWidgets(tab.widgetList, handler) + traverseContainerWidgets(tab.widgetList, handler) }) } else if (w.type === 'sub-form') { - traverseContainWidgets(w.widgetList, handler) + traverseContainerWidgets(w.widgetList, handler) } else if (w.category === 'container') { //自定义容器 - traverseContainWidgets(w.widgetList, handler) + traverseContainerWidgets(w.widgetList, handler) } }) } @@ -286,7 +286,7 @@ export function getAllContainerWidgets(widgetList) { container: w }) } - traverseContainWidgets(widgetList, handlerFn) + traverseContainerWidgets(widgetList, handlerFn) return result } diff --git a/src/utils/vue2js-generator.js b/src/utils/vue2js-generator.js index 9430c6a..2d5cd90 100644 --- a/src/utils/vue2js-generator.js +++ b/src/utils/vue2js-generator.js @@ -1,4 +1,4 @@ -import {isNotNull, traverseContainWidgets, traverseFieldWidgets} from "@/utils/util"; +import {isNotNull, traverseContainerWidgets, traverseFieldWidgets} from "@/utils/util"; import {translate} from "@/utils/i18n"; import FormValidators, {getRegExp} from "@/utils/validators"; @@ -79,7 +79,7 @@ export function buildActiveTabs(formConfig, widgetList) { cw.tabs.length > 0 && resultList.push(`'${cop.name}ActiveTab': '${cw.tabs[0].options.name}',`) } } - traverseContainWidgets(widgetList, handlerFn) + traverseContainerWidgets(widgetList, handlerFn) return resultList }