1
This commit is contained in:
parent
e9dc5f1754
commit
10dda22a4b
@ -1,7 +1,7 @@
|
||||
import React, {useState, useEffect} from 'react';
|
||||
import {PageContainer} from '@ant-design/pro-layout';
|
||||
import {Button, Card, Form, Input, InputNumber, Select, Switch, Space, Menu, Tabs, Row, Col, message, ColorPicker} from 'antd';
|
||||
import type {NodeDesignData} from './types';
|
||||
import type {NodeDesignDataResponse} from './types';
|
||||
import * as service from './service';
|
||||
|
||||
// Tab 配置
|
||||
@ -223,21 +223,22 @@ const FormRenderer: React.FC<{
|
||||
};
|
||||
|
||||
const NodeDesignForm: React.FC = () => {
|
||||
const [nodeDefinitionsDefined, setNodeDefinitionsDefined] = useState<NodeDesignData[]>([]);
|
||||
const [nodeDefinitionsDefined, setNodeDefinitionsDefined] = useState<NodeDesignDataResponse[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [selectedNode, setSelectedNode] = useState<NodeDesignData | null>(null);
|
||||
const [selectedNode, setSelectedNode] = useState<NodeDesignDataResponse | null>(null);
|
||||
const [activeTab, setActiveTab] = useState<string>('panel');
|
||||
const [form] = Form.useForm();
|
||||
|
||||
// 加载节点定义数据
|
||||
useEffect(() => {
|
||||
const loadNodeDefinitionsDefined = async () => {
|
||||
const loadNodeDefinitions = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const data = await service.getNodeDefinitionsDefined();
|
||||
setNodeDefinitionsDefined(data);
|
||||
if (data.length > 0) {
|
||||
setSelectedNode(data[0]);
|
||||
// 自动选中第一个节点
|
||||
if (data && data.length > 0) {
|
||||
handleNodeSelect(data[0]);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载节点定义失败:', error);
|
||||
@ -247,20 +248,20 @@ const NodeDesignForm: React.FC = () => {
|
||||
}
|
||||
};
|
||||
|
||||
loadNodeDefinitionsDefined();
|
||||
loadNodeDefinitions();
|
||||
}, []);
|
||||
|
||||
// 获取当前节点可用的 Tab 列表
|
||||
const getAvailableTabs = (node: NodeDesignData | null) => {
|
||||
const getAvailableTabs = (node: NodeDesignDataResponse | null) => {
|
||||
if (!node) return [];
|
||||
return TAB_CONFIG.filter(tab => {
|
||||
const value = node[tab.schemaKey as keyof NodeDesignData];
|
||||
const value = node[tab.schemaKey as keyof NodeDesignDataResponse];
|
||||
return value !== null && value !== undefined;
|
||||
});
|
||||
};
|
||||
|
||||
// 处理节点选择
|
||||
const handleNodeSelect = (node: NodeDesignData) => {
|
||||
const handleNodeSelect = (node: NodeDesignDataResponse) => {
|
||||
setSelectedNode(node);
|
||||
// 更新表单数据
|
||||
form.setFieldsValue({
|
||||
@ -340,7 +341,7 @@ const NodeDesignForm: React.FC = () => {
|
||||
if (!selectedNode) return null;
|
||||
const currentTab = TAB_CONFIG.find(tab => tab.key === activeTab);
|
||||
if (!currentTab) return null;
|
||||
return selectedNode[currentTab.schemaKey as keyof NodeDesignData];
|
||||
return selectedNode[currentTab.schemaKey as keyof NodeDesignDataResponse];
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@ -4,7 +4,7 @@ import type { ProColumns } from '@ant-design/pro-components';
|
||||
import { Tag, Space, Button, Modal } from 'antd';
|
||||
import { PlusOutlined } from '@ant-design/icons';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { NodeTypeEnum, type NodeDesignData } from './types';
|
||||
import { NodeTypeEnum, type NodeDesignDataResponse } from './types';
|
||||
import * as service from './service';
|
||||
|
||||
// 节点类型标签颜色映射
|
||||
@ -17,10 +17,10 @@ const nodeTypeColors = {
|
||||
const NodeDesignList: React.FC = () => {
|
||||
const navigate = useNavigate();
|
||||
const [detailVisible, setDetailVisible] = useState(false);
|
||||
const [currentNode, setCurrentNode] = useState<NodeDesignData>();
|
||||
const [currentNode, setCurrentNode] = useState<NodeDesignDataResponse>();
|
||||
|
||||
// 表格列定义
|
||||
const columns: ProColumns<NodeDesignData>[] = [
|
||||
const columns: ProColumns<NodeDesignDataResponse>[] = [
|
||||
{
|
||||
title: '节点编码',
|
||||
dataIndex: 'nodeCode',
|
||||
@ -92,11 +92,11 @@ const NodeDesignList: React.FC = () => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<ProTable<NodeDesignData>
|
||||
<ProTable<NodeDesignDataResponse>
|
||||
columns={columns}
|
||||
request={async (params) => {
|
||||
const { current, pageSize, ...rest } = params;
|
||||
const response = await service.getNodeDesigns({
|
||||
const response = await service.getNodeDefinitions({
|
||||
current,
|
||||
pageSize,
|
||||
...rest,
|
||||
|
||||
@ -1,26 +1,23 @@
|
||||
// 节点设计相关服务
|
||||
|
||||
import request from '@/utils/request';
|
||||
import type { NodeDesignQuery, NodeDesignResponse, NodeDesignData, NodeDefinitionData } from './types';
|
||||
import type { NodeDesignQuery, NodeDefinitionResponse, NodeDesignDataResponse } from './types';
|
||||
|
||||
const BASE_URL = '/api/v1/workflow/node-definition';
|
||||
|
||||
// 获取节点设计列表
|
||||
export const getNodeDesigns = (params: NodeDesignQuery) =>
|
||||
request.get<NodeDesignResponse>(`${BASE_URL}/page`, { params });
|
||||
export const getNodeDefinitions = (params: NodeDesignQuery) =>
|
||||
request.get<NodeDefinitionResponse>(`${BASE_URL}/page`, { params });
|
||||
|
||||
// 获取节点设计详情
|
||||
export const getNodeDesign = (nodeCode: string) =>
|
||||
request.get<NodeDesignData>(`${BASE_URL}/${nodeCode}`);
|
||||
export const getNodeDefinition = (id: string) =>
|
||||
request.get<NodeDefinitionResponse>(`${BASE_URL}/${id}`);
|
||||
|
||||
// 更新节点UI配置
|
||||
export const updateNodeUIConfig = (nodeCode: string, uiVariables: any) =>
|
||||
request.put(`${BASE_URL}/${nodeCode}/ui`, uiVariables);
|
||||
|
||||
// 获取已定义的节点类型配置
|
||||
export const getNodeDefinitionsDefined = () =>
|
||||
request.get<NodeDefinitionData[]>(`${BASE_URL}/defined`);
|
||||
request.get<NodeDesignDataResponse[]>(`${BASE_URL}/defined`);
|
||||
|
||||
// 保存节点定义
|
||||
export const saveNodeDefinition = (data: NodeDefinitionData) =>
|
||||
export const saveNodeDefinition = (data: NodeDesignDataResponse) =>
|
||||
request.post<void>(`${BASE_URL}`, data);
|
||||
|
||||
@ -71,7 +71,7 @@ export interface UIVariables extends BaseSchema {
|
||||
}
|
||||
|
||||
// 节点设计数据
|
||||
export interface NodeDesignData {
|
||||
export interface NodeDesignDataResponse extends BaseResponse{
|
||||
nodeCode: string;
|
||||
nodeName: string;
|
||||
category: string;
|
||||
@ -89,12 +89,18 @@ export enum NodeTypeEnum {
|
||||
}
|
||||
|
||||
// 查询参数接口
|
||||
export interface NodeDesignQuery extends BaseQuery{
|
||||
export interface NodeDesignQuery extends BaseQuery {
|
||||
nodeCode?: string;
|
||||
nodeName?: string;
|
||||
}
|
||||
|
||||
// 分页响应接口
|
||||
export interface NodeDesignResponse extends BaseResponse{
|
||||
|
||||
export interface NodeDefinitionResponse extends BaseResponse {
|
||||
nodeCode: string;
|
||||
nodeName: string;
|
||||
nodeType: NodeTypeEnum;
|
||||
panelVariablesSchema: NodeVariablesSchema | null;
|
||||
uiVariables: UIVariables | null;
|
||||
localVariablesSchema: NodeVariablesSchema | null;
|
||||
formVariablesSchema: NodeVariablesSchema | null;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user