From 812a32a0bc328a3a568af0914d487bf36ef16f15 Mon Sep 17 00:00:00 2001 From: haixin <1875934025@qq.com> Date: Sat, 13 Apr 2024 17:29:42 +0800 Subject: [PATCH] fix: bug #10 --- packages/editor/package.json | 2 +- packages/editor/src/utils/_.ts | 14 +++++--------- playground/package.json | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/packages/editor/package.json b/packages/editor/package.json index c7ceeec..de53e31 100644 --- a/packages/editor/package.json +++ b/packages/editor/package.json @@ -1,6 +1,6 @@ { "name": "starfish-editor", - "version": "1.1.20", + "version": "1.1.21", "main": "dist/starfish-editor.umd.js", "style": "dist/style.css", "module": "dist/starfish-editor.es.js", diff --git a/packages/editor/src/utils/_.ts b/packages/editor/src/utils/_.ts index c14592f..42cf625 100644 --- a/packages/editor/src/utils/_.ts +++ b/packages/editor/src/utils/_.ts @@ -2,10 +2,10 @@ import { ElNotification } from "element-plus"; import { nanoid } from "nanoid"; import { AllFormItem, BaseComponentItem, PartialKey } from "@/type"; import formStore from "@/controller/form"; -const fieldlist: string[] = []; class Flex { lastClickTime: number; openTanc: boolean; + constructor() { this.lastClickTime = 0; this.openTanc = false; // 是否有弹窗 @@ -58,7 +58,7 @@ class Flex { } public deepClone(target: any): any { // 定义一个变量 - let result; + let result: any; // 如果当前需要深拷贝的是一个对象的话 if (typeof target === "object") { // 如果是一个数组的话 @@ -143,14 +143,10 @@ class Flex { if (!item.data) { item.data = item.formConfig.data(); } + if (!item.data.fieldName) { item.data.fieldName = item.ControlType + "_" + this.generateMixed(); } - if (fieldlist.includes(item.data.fieldName)) { - item.data.fieldName = item.ControlType + "_" + this.generateMixed(); - } else { - fieldlist.push(item.data.fieldName); - } if (item.layout) { if (item.ControlType == "Grid" && item.data.columns && item.data.columns.length > 0) { item.data.columns = item.data.columns.map((colItem: any) => { @@ -196,7 +192,7 @@ class Flex { */ if (currentComponent.actionType && currentComponent.actionType.length > 0) { console.log(controlItems); - controlItems.find((item) => { + controlItems.find((item: any) => { if (item.ControlType == "Action") { item.data.formConfig = { value: {}, @@ -212,7 +208,7 @@ class Flex { } }); } else { - controlItems = controlItems.filter((item) => { + controlItems = controlItems.filter((item: any) => { if (item.ControlType !== "Action") { return item; } diff --git a/playground/package.json b/playground/package.json index c0320ee..144355c 100644 --- a/playground/package.json +++ b/playground/package.json @@ -11,7 +11,7 @@ "dependencies": { "@element-plus/icons-vue": "^2.0.8", "element-plus": "^2.2.12", - "starfish-editor": "^1.1.19", + "starfish-editor": "^1.1.21", "starfish-form": "^1.2.9", "vite": "^4.5.2", "vue": "^3.2.37",