diff --git a/platform/example/src/component/AddStep.tsx b/platform/example/src/component/AddStep.tsx
new file mode 100644
index 0000000..1b5d302
--- /dev/null
+++ b/platform/example/src/component/AddStep.tsx
@@ -0,0 +1,24 @@
+import {Dropdown, MenuProps, Space} from "antd";
+import style from "@/component/layout/css/header.module.less";
+import {DownOutlined} from "@ant-design/icons";
+import {menus, stepList, stepMap} from "@/component/step";
+import drapStore from "@/mobx/DrapStore";
+
+console.log(stepList)
+const items: MenuProps['items'] = [...menus];
+
+const onClick: MenuProps['onClick'] = ({ key }) => {
+ // 给容器添加组件
+ // message.info(`Click on item ${key}`);
+ const component = stepMap[key];
+ console.log(key,component)
+ drapStore.addChildren(null,component.defaultDataFunc())
+};
+const AddStep :React.FC= (props)=>{
+ return
+ e.preventDefault()}>
+ {props.children}
+
+
+}
+export default AddStep
\ No newline at end of file
diff --git a/platform/example/src/component/CardItem.tsx b/platform/example/src/component/CardItem.tsx
index 7818619..62377e9 100644
--- a/platform/example/src/component/CardItem.tsx
+++ b/platform/example/src/component/CardItem.tsx
@@ -1,9 +1,12 @@
import {memo, useRef} from "react";
import {useDrag, useDrop} from "react-dnd";
import drapStore from "@/mobx/DrapStore";
-import {Content, StepDragType, StepType} from "@/component/type";
+import {Content, StepDragEnum, StepDragType, StepType} from "@/component/type";
import style from "./css/DrapItem.module.less"
import {stepMap} from "@/component/step";
+import lodash from "lodash"
+// import AddStep from "./AddStep";
+import {DownOutlined} from "@ant-design/icons";
let id = 0
export const getDropStoreId = (type?:string) =>{
const DropStore = {
@@ -67,6 +70,10 @@ const CardItem = memo((props:CardItemProps) => {
// 如果是根组件,不移除自身
if(props.parent===null){
return;
+ }
+ // 子组件不移除
+ if(childrenFind(droppedId)){
+ return;
}
// 跨组件移动--移除自身
deleteCard(props.parent,props.data)
@@ -75,6 +82,20 @@ const CardItem = memo((props:CardItemProps) => {
}),
[id, originalIndex, moveCard],
)
+ // 父级是否存在
+ const childrenFind = (id:string)=>{
+ // @ts-ignore
+ if(Array.isArray(props.parent.children)){
+ // @ts-ignore
+ for (let i = 0; i < props.parent.children?.length; i++) {
+ // @ts-ignore
+ if(props.parent.children[i].id===id){
+ return true
+ }
+ }
+ }
+ return false
+ }
const [{isOver,canDrop,isOverCurrent}, drop] = useDrop(
() => ({
accept: StepType.CARD,
@@ -135,8 +156,10 @@ const CardItem = memo((props:CardItemProps) => {
// @ts-ignore
const newItem = { ...item, id: String(new Date().getTime()) }
if(tag!==Propstag){
- // @ts-ignore
- const newItem = { ...item, id: String(new Date().getTime()) }
+ // 销毁自己
+ item.destruction()
+ const newItem = lodash.cloneDeep(item)
+ newItem.id = String(new Date().getTime())
childrenCreate(newItem)
}
return
@@ -158,7 +181,12 @@ const CardItem = memo((props:CardItemProps) => {
drapStore.updateState()
}
-
+ // const addStepDom = ()=>{
+ // return
+ // 新增步骤
+ //
+ //
+ // }
return (
drag(drop(node))} >
@@ -175,11 +203,13 @@ const CardItem = memo((props:CardItemProps) => {
{step&&()}
-
- {props.data.children&&props.data.children.length>0&&(
childrenDrop(node)} className={style.woodExampleChildren}>
- {props.children}
+ {props.children}
+ {props.data.type===StepDragEnum.CONTAINER&&(
childrenDrop(node)} className={style.woodExampleChildren}>
+ 拖动到此处或者
+ {/*{addStepDom()}*/}
)}
+
)
})
diff --git a/platform/example/src/component/DragList.tsx b/platform/example/src/component/DragList.tsx
index 57c7b7e..aaaf0f7 100644
--- a/platform/example/src/component/DragList.tsx
+++ b/platform/example/src/component/DragList.tsx
@@ -12,15 +12,15 @@ interface DragListProps {
const _tagStore = getDropStoreId()
const tagStore = _tagStore()
const DragList = ({data,parent}:DragListProps) => {
- console.log(data)
if(!Array.isArray(data)){
data = []
}
// const [list, setList] = useState(data);
- data.forEach((e:StepDragType