fix: bpmn-process-designer structuredClone => cloneDeep

This commit is contained in:
puhui999
2025-09-15 11:05:25 +08:00
parent 9e3b4461cf
commit 40e04f773d
7 changed files with 25 additions and 19 deletions

View File

@@ -478,7 +478,7 @@ const elementsAlign = (align: string) => {
content: '自动对齐可能造成图形变形,是否继续?',
okText: '确定',
cancelText: '取消',
icon: WarningOutlined as any,
icon: h(WarningOutlined) as any,
onOk() {
Align.trigger(SelectedElements, align);
},

View File

@@ -2,6 +2,7 @@
import { nextTick, onBeforeUnmount, onMounted, provide, ref, watch } from 'vue';
import { IconifyIcon } from '@vben/icons';
import { cloneDeep } from '@vben/utils';
import { Collapse } from 'ant-design-vue';
@@ -186,9 +187,7 @@ const initFormOnChanged = (element: any) => {
bpmnElement.value = activatedElement;
elementId.value = activatedElement.id;
elementType.value = activatedElement.type.split(':')[1] || '';
elementBusinessObject.value = structuredClone(
activatedElement.businessObject,
);
elementBusinessObject.value = cloneDeep(activatedElement.businessObject);
conditionFormVisible.value =
elementType.value === 'SequenceFlow' &&
activatedElement.source &&

View File

@@ -1,6 +1,8 @@
<script lang="ts" setup>
import { computed, inject, nextTick, onMounted, ref, toRaw, watch } from 'vue';
import { cloneDeep } from '@vben/utils';
import { Form, FormItem, Select } from 'ant-design-vue';
import { getFormSimpleList } from '#/api/bpm/form';
@@ -72,7 +74,7 @@ const resetFormList = () => {
);
// 复制原始值,填充表格
fieldList.value = structuredClone(formData.value.fields || []);
fieldList.value = cloneDeep(formData.value.fields || []);
// 更新元素扩展属性,避免后续报错
updateElementExtensions();
@@ -109,7 +111,7 @@ const _openFieldForm = (field: any, index: any) => {
fieldPropertiesList.value = [];
} else {
const FieldObject = formData.value.fields[index];
formFieldForm.value = structuredClone(field);
formFieldForm.value = cloneDeep(field);
// 设置自定义类型
// this.$set(this.formFieldForm, "typeType", !this.fieldType[field.type] ? "custom" : field.type);
formFieldForm.value.typeType = fieldType.value[
@@ -119,13 +121,13 @@ const _openFieldForm = (field: any, index: any) => {
: 'custom';
// 初始化枚举值列表
field.type === 'enum' &&
(fieldEnumList.value = structuredClone(FieldObject?.values || []));
(fieldEnumList.value = cloneDeep(FieldObject?.values || []));
// 初始化约束条件列表
fieldConstraintsList.value = structuredClone(
fieldConstraintsList.value = cloneDeep(
FieldObject?.validation?.constraints || [],
);
// 初始化自定义属性列表
fieldPropertiesList.value = structuredClone(
fieldPropertiesList.value = cloneDeep(
FieldObject?.properties?.values || [],
);
}
@@ -137,14 +139,14 @@ const _openFieldOptionForm = (option: any, index: any, type: any) => {
fieldOptionType.value = type;
formFieldOptionIndex.value = index;
if (type === 'property') {
fieldOptionForm.value = option ? structuredClone(option) : {};
fieldOptionForm.value = option ? cloneDeep(option) : {};
return (optionModelTitle.value = '属性配置');
}
if (type === 'enum') {
fieldOptionForm.value = option ? structuredClone(option) : {};
fieldOptionForm.value = option ? cloneDeep(option) : {};
return (optionModelTitle.value = '枚举值配置');
}
fieldOptionForm.value = option ? structuredClone(option) : {};
fieldOptionForm.value = option ? cloneDeep(option) : {};
return (optionModelTitle.value = '约束条件配置');
};

View File

@@ -2,6 +2,7 @@
import { inject, nextTick, ref, watch } from 'vue';
import { IconifyIcon, PlusOutlined } from '@vben/icons';
import { cloneDeep } from '@vben/utils';
import {
Button,
@@ -96,9 +97,10 @@ const openListenerForm = (listener: any, index: number) => {
}
});
};
// 打开监听器字段编辑弹窗
const openListenerFieldForm = (field: any, index: number) => {
listenerFieldForm.value = field ? structuredClone(field) : {};
listenerFieldForm.value = field ? cloneDeep(field) : {};
editingListenerFieldIndex.value = field ? index : -1;
listenerFieldFormModelVisible.value = true;
nextTick(() => {

View File

@@ -2,6 +2,7 @@
import { inject, nextTick, ref, watch } from 'vue';
import { MenuOutlined, PlusOutlined, SelectOutlined } from '@vben/icons';
import { cloneDeep } from '@vben/utils';
import {
Button,
@@ -162,9 +163,10 @@ const saveListenerConfig = async () => {
listenerFormModelVisible.value = false;
listenerForm.value = {};
};
// 打开监听器字段编辑弹窗
const openListenerFieldForm = (field: any, index?: number) => {
listenerFieldForm.value = field ? structuredClone(field) : {};
listenerFieldForm.value = field ? cloneDeep(field) : {};
editingListenerFieldIndex.value = field ? index : -1;
listenerFieldFormModelVisible.value = true;
nextTick(() => {

View File

@@ -1,4 +1,6 @@
// 初始化表单数据
import { cloneDeep } from '@vben/utils';
export function initListenerForm(listener: any) {
let self = {
...listener,
@@ -36,7 +38,7 @@ export function initListenerType(listener: any) {
if (listener.delegateExpression) listenerType = 'delegateExpressionListener';
if (listener.script) listenerType = 'scriptListener';
return {
...structuredClone(listener),
...cloneDeep(listener),
...listener.script,
listenerType,
};

View File

@@ -2,6 +2,7 @@
import { inject, nextTick, ref, toRaw, watch } from 'vue';
import { IconifyIcon } from '@vben/icons';
import { cloneDeep } from '@vben/utils';
import {
Button,
@@ -60,9 +61,7 @@ const resetAttributesList = () => {
(current: any) => current.values,
);
// 复制 显示
elementPropertyList.value = structuredClone(
bpmnElementPropertyList.value ?? [],
);
elementPropertyList.value = cloneDeep(bpmnElementPropertyList.value ?? []);
};
const openAttributesForm = (
@@ -71,7 +70,7 @@ const openAttributesForm = (
) => {
editingPropertyIndex.value = index;
// @ts-ignore
propertyForm.value = index === -1 ? {} : structuredClone(attr);
propertyForm.value = index === -1 ? {} : cloneDeep(attr);
propertyFormModelVisible.value = true;
nextTick(() => {
if (attributeFormRef.value) attributeFormRef.value.clearValidate();