wip: alpha
This commit is contained in:
parent
b4e3e7d5c6
commit
b2bbfab22c
@ -22,11 +22,11 @@ export interface TaskCreateProps {
|
||||
const steps: Step[] = [
|
||||
{ id: 1, title: '步骤1', type: 'src' } as Step,
|
||||
{ id: 2, title: '步骤2', type: 'mid' } as Step,
|
||||
{ id: 2, title: '步骤3', type: 'mid' } as Step,
|
||||
{ id: 2, title: '步骤4', type: 'mid' } as Step,
|
||||
{ id: 2, title: '步骤5', type: 'mid' } as Step,
|
||||
{ id: 2, title: '步骤6', type: 'mid' } as Step,
|
||||
{ id: 3, title: '步骤7', type: 'dst' } as Step,
|
||||
{ id: 3, title: '步骤3', type: 'mid' } as Step,
|
||||
{ id: 4, title: '步骤4', type: 'mid' } as Step,
|
||||
{ id: 5, title: '步骤5', type: 'mid' } as Step,
|
||||
{ id: 6, title: '步骤6', type: 'mid' } as Step,
|
||||
{ id: 7, title: '步骤7', type: 'dst' } as Step,
|
||||
]
|
||||
|
||||
|
||||
@ -37,14 +37,13 @@ export const TaskCreate = (props: TaskCreateProps) => {
|
||||
const onDragEnd = ({ active, over }) => {
|
||||
if (active.id !== over?.id) {
|
||||
setItems(items => {
|
||||
const oldIndex = items.indexOf(active.id);
|
||||
const newIndex = items.indexOf(over.id);
|
||||
const oldIndex = items.findIndex(item => item.id === active.id);
|
||||
const newIndex = items.findIndex(item => item.id === over.id);
|
||||
return arrayMove(items, oldIndex, newIndex);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Modal
|
||||
@ -57,16 +56,14 @@ export const TaskCreate = (props: TaskCreateProps) => {
|
||||
}}
|
||||
title="新建任务"
|
||||
open={props.open}
|
||||
|
||||
// footer={null}
|
||||
>
|
||||
<DndContext onDragEnd={onDragEnd}>
|
||||
<SortableContext items={items} strategy={verticalListSortingStrategy}>
|
||||
<Collapse>
|
||||
{items.filter(v => v.type === "mid").map(item => (
|
||||
{items.map(item => (
|
||||
<SortableItem key={item.id} id={item.id}>
|
||||
<Collapse.Panel key={item.id} header={item.title}>
|
||||
步骤内容
|
||||
{'步骤内容-' + item.type}
|
||||
</Collapse.Panel>
|
||||
</SortableItem>
|
||||
))}
|
||||
@ -79,7 +76,6 @@ export const TaskCreate = (props: TaskCreateProps) => {
|
||||
};
|
||||
|
||||
|
||||
// Bug fix: Correctly define the type of the children prop to avoid implicit 'any' type
|
||||
const SortableItem = ({ id, children }: { id: number; children: JSX.Element }) => {
|
||||
const { attributes, listeners, setNodeRef, transform, transition } = useSortable({ id });
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user