From 9e41db9e8af5b339c1a61310e84cfd20686e3dab Mon Sep 17 00:00:00 2001 From: vform666 <78128214+vform666@users.noreply.github.com> Date: Thu, 9 Feb 2023 13:19:34 +0800 Subject: [PATCH] Revert "Added base logic" --- .../form-designer/toolbar-panel/index.vue | 11 +---- src/utils/widgets-preview.js | 47 ------------------- 2 files changed, 2 insertions(+), 56 deletions(-) delete mode 100644 src/utils/widgets-preview.js diff --git a/src/components/form-designer/toolbar-panel/index.vue b/src/components/form-designer/toolbar-panel/index.vue index 56beaa1..dbca38c 100644 --- a/src/components/form-designer/toolbar-panel/index.vue +++ b/src/components/form-designer/toolbar-panel/index.vue @@ -50,7 +50,7 @@ :fullscreen="(layoutType === 'H5') || (layoutType === 'Pad')">
- @@ -201,8 +201,7 @@ import loadBeautifier from "@/utils/beautifierLoader" import { saveAs } from 'file-saver' import axios from 'axios' - import SvgIcon from "@/components/svg-icon/index" - import { fillUnfilledWidgetPropsForPreview, unfilledWidgetPropsDefaultData } from "@/utils/widgets-preview" + import SvgIcon from "@/components/svg-icon/index"; export default { name: "ToolbarPanel", @@ -274,12 +273,6 @@ } }, computed: { - previewFormJson() { - return { - widgetList: fillUnfilledWidgetPropsForPreview(this.designer.widgetList, unfilledWidgetPropsDefaultData), - formConfig: deepClone(this.designer.formConfig) - } - }, formJson() { return { // widgetList: this.designer.widgetList, diff --git a/src/utils/widgets-preview.js b/src/utils/widgets-preview.js deleted file mode 100644 index 74da360..0000000 --- a/src/utils/widgets-preview.js +++ /dev/null @@ -1,47 +0,0 @@ -import { deepClone } from "@/utils/util" - -const widgetPropsForDetectChanges = { - input: { defaultValue: '' }, - textarea: { defaultValue: '' }, - number: { defaultValue: 0 }, - radio: { defaultValue: null }, - checkbox: { defaultValue: [] }, - select: { defaultValue: '' }, - time: { defaultValue: null }, - 'time-range': { defaultValue: null }, - date: { defaultValue: null }, - 'date-range': { defaultValue: null }, - switch: { defaultValue: null }, - rate: { defaultValue: null }, - color: { defaultValue: null }, - slider: {}, - 'static-text': { textContent: 'static text' }, - 'html-text': { htmlContent: 'html text' }, - button: { label: 'button', type: '' }, - divider: { label: '' }, - 'picture-upload': { uploadURL: '' }, - 'file-upload': { uploadURL: '' }, - 'rich-editor': {}, - 'cascader': { defaultValue: '' } -} -export const unfilledWidgetPropsDefaultData = { - input: { defaultValue: 'test text' }, - checkbox: { defaultValue: [1] }, - button: { label: 'custom label', type: 'success' }, - time: { defaultValue: '16:04:48' }, -} -export function fillUnfilledWidgetPropsForPreview(widgets, unfilledWidgetPropsData) { - return deepClone(widgets).map((widget) => { - const widgetPropsForDetect = widgetPropsForDetectChanges[widget.type] - Object.keys(widgetPropsForDetect).forEach((widgetProp) => { - if( - unfilledWidgetPropsData[widget.type] - && - JSON.stringify(widget.options[widgetProp]) === JSON.stringify(widgetPropsForDetect[widgetProp]) - ) { - widget.options[widgetProp] = unfilledWidgetPropsData[widget.type][widgetProp] - } - }) - return widget - }); -}