|
|
@@ -1,7 +1,7 @@
|
|
|
/**
|
|
|
* 工作流 - 工作流设置组件
|
|
|
*/
|
|
|
-import React, { useEffect, useState } from 'react';
|
|
|
+import React, { useContext, useEffect, useMemo, useState } from 'react';
|
|
|
import {
|
|
|
Form,
|
|
|
Card,
|
|
|
@@ -13,13 +13,25 @@ import {
|
|
|
Table,
|
|
|
Button,
|
|
|
Space,
|
|
|
- Row,
|
|
|
Col,
|
|
|
+ Row,
|
|
|
message,
|
|
|
} from 'antd';
|
|
|
import { SPACING } from '../../constants';
|
|
|
import { getConfig, modifyConfig } from '@/API/system/options';
|
|
|
-
|
|
|
+import type { SyntheticListenerMap } from '@dnd-kit/core/dist/hooks/utilities';
|
|
|
+import { HolderOutlined } from '@ant-design/icons';
|
|
|
+import { DndContext } from '@dnd-kit/core';
|
|
|
+import { restrictToVerticalAxis } from '@dnd-kit/modifiers';
|
|
|
+import {
|
|
|
+ arrayMove,
|
|
|
+ SortableContext,
|
|
|
+ useSortable,
|
|
|
+ verticalListSortingStrategy,
|
|
|
+} from '@dnd-kit/sortable';
|
|
|
+
|
|
|
+import { CSS } from '@dnd-kit/utilities';
|
|
|
+import { DragEndEvent } from '@dnd-kit/core';
|
|
|
const { Group: RadioGroup } = Radio;
|
|
|
|
|
|
// 字段配置数据类型
|
|
|
@@ -76,6 +88,55 @@ const initValues = {
|
|
|
//是否启用剂量调整功能
|
|
|
'System/DoseAdjustmentEnabled': false,
|
|
|
};
|
|
|
+
|
|
|
+interface RowContextProps {
|
|
|
+ setActivatorNodeRef?: (element: HTMLElement | null) => void;
|
|
|
+ listeners?: SyntheticListenerMap;
|
|
|
+}
|
|
|
+
|
|
|
+const RowContext = React.createContext<RowContextProps>({});
|
|
|
+const DragHandle: React.FC = () => {
|
|
|
+ const { setActivatorNodeRef, listeners } = useContext(RowContext);
|
|
|
+ return (
|
|
|
+ <HolderOutlined
|
|
|
+ style={{ cursor: 'move' }}
|
|
|
+ ref={setActivatorNodeRef}
|
|
|
+ {...listeners}
|
|
|
+ />
|
|
|
+ );
|
|
|
+};
|
|
|
+interface RowProps extends React.HTMLAttributes<HTMLTableRowElement> {
|
|
|
+ 'data-row-key': string;
|
|
|
+}
|
|
|
+const _Row: React.FC<RowProps> = (props) => {
|
|
|
+ const {
|
|
|
+ attributes,
|
|
|
+ listeners,
|
|
|
+ setNodeRef,
|
|
|
+ setActivatorNodeRef,
|
|
|
+ transform,
|
|
|
+ transition,
|
|
|
+ isDragging,
|
|
|
+ } = useSortable({ id: props['data-row-key'] });
|
|
|
+
|
|
|
+ const style: React.CSSProperties = {
|
|
|
+ ...props.style,
|
|
|
+ transform: CSS.Translate.toString(transform),
|
|
|
+ transition,
|
|
|
+ ...(isDragging ? { position: 'relative', zIndex: 9999 } : {}),
|
|
|
+ };
|
|
|
+
|
|
|
+ const contextValue = useMemo<RowContextProps>(
|
|
|
+ () => ({ setActivatorNodeRef, listeners }),
|
|
|
+ [setActivatorNodeRef, listeners]
|
|
|
+ );
|
|
|
+
|
|
|
+ return (
|
|
|
+ <RowContext.Provider value={contextValue}>
|
|
|
+ <tr {...props} ref={setNodeRef} style={style} {...attributes} />
|
|
|
+ </RowContext.Provider>
|
|
|
+ );
|
|
|
+};
|
|
|
/**
|
|
|
* 工作流组件
|
|
|
* 实现图像采集、多任务管理、APR编辑等设置功能
|
|
|
@@ -112,6 +173,12 @@ const Workflow: React.FC = () => {
|
|
|
dataIndex: 'Display',
|
|
|
key: 'Display',
|
|
|
},
|
|
|
+ // {
|
|
|
+ // key: 'drag-sort',
|
|
|
+ // align: 'center',
|
|
|
+ // width: 0,
|
|
|
+ // render: () => <DragHandle />,
|
|
|
+ // },
|
|
|
];
|
|
|
|
|
|
// 处理任务清单配置变更
|
|
|
@@ -206,8 +273,18 @@ const Workflow: React.FC = () => {
|
|
|
getWorkFlowData();
|
|
|
}, []);
|
|
|
|
|
|
- const onChange = (value) => {
|
|
|
- console.log('changed', value, typeof value);
|
|
|
+ const onDragEnd = ({ active, over }: DragEndEvent, setData) => {
|
|
|
+ if (active.id !== over?.id) {
|
|
|
+ setData((prevState) => {
|
|
|
+ const activeIndex = prevState.findIndex(
|
|
|
+ (record) => record.Order === active?.id
|
|
|
+ );
|
|
|
+ const overIndex = prevState.findIndex(
|
|
|
+ (record) => record.Order === over?.id
|
|
|
+ );
|
|
|
+ return arrayMove(prevState, activeIndex, overIndex);
|
|
|
+ });
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
return (
|
|
|
@@ -267,7 +344,7 @@ const Workflow: React.FC = () => {
|
|
|
},
|
|
|
]}
|
|
|
>
|
|
|
- <InputNumber min={0} max={60} onChange={onChange} />
|
|
|
+ <InputNumber min={0} max={60} />
|
|
|
</Form.Item>
|
|
|
|
|
|
<Form.Item
|
|
|
@@ -460,22 +537,46 @@ const Workflow: React.FC = () => {
|
|
|
>
|
|
|
{/* 任务清单显示配置 */}
|
|
|
<Card title="任务清单显示配置" size="small">
|
|
|
- <Table
|
|
|
- columns={getTableColumns(handleTaskListConfigChange)}
|
|
|
- dataSource={taskListConfig}
|
|
|
- pagination={false}
|
|
|
- size="small"
|
|
|
- />
|
|
|
+ <DndContext
|
|
|
+ modifiers={[restrictToVerticalAxis]}
|
|
|
+ onDragEnd={(e) => onDragEnd(e, setTaskListConfig)}
|
|
|
+ >
|
|
|
+ <SortableContext
|
|
|
+ items={taskListConfig.map((i) => i.Order)}
|
|
|
+ strategy={verticalListSortingStrategy}
|
|
|
+ >
|
|
|
+ <Table
|
|
|
+ rowKey="Order"
|
|
|
+ components={{ body: { row: _Row } }}
|
|
|
+ columns={getTableColumns(handleTaskListConfigChange)}
|
|
|
+ dataSource={taskListConfig}
|
|
|
+ pagination={false}
|
|
|
+ size="small"
|
|
|
+ />
|
|
|
+ </SortableContext>
|
|
|
+ </DndContext>
|
|
|
</Card>
|
|
|
|
|
|
{/* 历史清单显示配置 */}
|
|
|
<Card title="历史清单显示配置" size="small">
|
|
|
- <Table
|
|
|
- columns={getTableColumns(handleHistoryListConfigChange)}
|
|
|
- dataSource={historyListConfig}
|
|
|
- pagination={false}
|
|
|
- size="small"
|
|
|
- />
|
|
|
+ <DndContext
|
|
|
+ modifiers={[restrictToVerticalAxis]}
|
|
|
+ onDragEnd={(e) => onDragEnd(e, setHistoryListConfig)}
|
|
|
+ >
|
|
|
+ <SortableContext
|
|
|
+ items={historyListConfig.map((i) => i.Order)}
|
|
|
+ strategy={verticalListSortingStrategy}
|
|
|
+ >
|
|
|
+ <Table
|
|
|
+ rowKey="Order"
|
|
|
+ components={{ body: { row: _Row } }}
|
|
|
+ columns={getTableColumns(handleHistoryListConfigChange)}
|
|
|
+ dataSource={historyListConfig}
|
|
|
+ pagination={false}
|
|
|
+ size="small"
|
|
|
+ />
|
|
|
+ </SortableContext>
|
|
|
+ </DndContext>
|
|
|
</Card>
|
|
|
</div>
|
|
|
</div>
|