|
|
|
@ -1,27 +1,35 @@
|
|
|
|
import React, { useEffect, useState } from 'react';
|
|
|
|
import React, { useEffect, useState } from 'react';
|
|
|
|
import styles from './style/index.module.less';
|
|
|
|
import styles from './style/index.module.less';
|
|
|
|
import { Button, Input, Select, Space, Cascader } from '@arco-design/web-react';
|
|
|
|
import { Button, Input, Select, Space } from '@arco-design/web-react';
|
|
|
|
import { IconSearch } from '@arco-design/web-react/icon';
|
|
|
|
import { IconSearch } from '@arco-design/web-react/icon';
|
|
|
|
|
|
|
|
import { useSelector, useDispatch } from 'react-redux';
|
|
|
|
|
|
|
|
import { getMyComponentList } from '@/api/componentBase';
|
|
|
|
|
|
|
|
import { updateComponentCodingPath } from '@/store/ideContainer';
|
|
|
|
|
|
|
|
|
|
|
|
const Option = Select.Option;
|
|
|
|
const Option = Select.Option;
|
|
|
|
|
|
|
|
|
|
|
|
const ComponentCoding = () => {
|
|
|
|
const ComponentCoding = () => {
|
|
|
|
const [serverUrl, setServerUrl] = useState('https://arco.design/vue/component/button');
|
|
|
|
const [serverUrl, setServerUrl] = useState('');
|
|
|
|
const [localProjectPath, setLocalProjectPath] = useState('');
|
|
|
|
const [optionsList, setOptionsList] = useState([]);
|
|
|
|
|
|
|
|
const [originList, setOriginList] = useState([]);
|
|
|
|
|
|
|
|
const { componentCoding } = useSelector((state: any) => state.ideContainer);
|
|
|
|
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const getOptionsList = async () => {
|
|
|
|
// 监听导航事件
|
|
|
|
const res: any = await getMyComponentList({
|
|
|
|
const handleNavigateToTab = (event: CustomEvent) => {
|
|
|
|
currPage: 1,
|
|
|
|
if (event.detail.path === 'componentCoding' && event.detail.localProjectPath) {
|
|
|
|
pageSize: 999
|
|
|
|
setLocalProjectPath(event.detail.localProjectPath);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (res.code === 200) {
|
|
|
|
};
|
|
|
|
setOriginList(res.data.list);
|
|
|
|
|
|
|
|
setOptionsList(res.data.list.map(item => {
|
|
|
|
document.addEventListener('navigateToTab', handleNavigateToTab as EventListener);
|
|
|
|
return { label: item.name, value: item.localProjectPath, ...item };
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
useEffect(() => {
|
|
|
|
document.removeEventListener('navigateToTab', handleNavigateToTab as EventListener);
|
|
|
|
getOptionsList();
|
|
|
|
};
|
|
|
|
|
|
|
|
}, []);
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
@ -29,172 +37,9 @@ const ComponentCoding = () => {
|
|
|
|
const codeServerFolderPre = '/app/data';
|
|
|
|
const codeServerFolderPre = '/app/data';
|
|
|
|
|
|
|
|
|
|
|
|
// 使用传入的localProjectPath或默认值
|
|
|
|
// 使用传入的localProjectPath或默认值
|
|
|
|
const path = localProjectPath || '/000000/admin_testcode1/master';
|
|
|
|
const path = componentCoding.localProjectPath || '/000000/admin_testcode1/master';
|
|
|
|
setServerUrl(`${uri}?folder=${codeServerFolderPre}${path}`);
|
|
|
|
setServerUrl(`${uri}?folder=${codeServerFolderPre}${path}`);
|
|
|
|
}, [localProjectPath]);
|
|
|
|
}, [componentCoding]);
|
|
|
|
|
|
|
|
|
|
|
|
const componentScreening = () => {
|
|
|
|
|
|
|
|
// 将数据结构修改为级联结构
|
|
|
|
|
|
|
|
const cascaderOptions = [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '设备数采与控制交互组件',
|
|
|
|
|
|
|
|
value: '2',
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: 'Java:8',
|
|
|
|
|
|
|
|
value: '2-1',
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '数据采集模块',
|
|
|
|
|
|
|
|
value: '2-1-1'
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '设备控制接口',
|
|
|
|
|
|
|
|
value: '2-1-2'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: 'Python:3.10.12',
|
|
|
|
|
|
|
|
value: '2-2',
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '数据采集模块',
|
|
|
|
|
|
|
|
value: '2-2-1'
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '设备控制接口',
|
|
|
|
|
|
|
|
value: '2-2-2'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '视觉AI组件',
|
|
|
|
|
|
|
|
value: '3',
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: 'Java:8',
|
|
|
|
|
|
|
|
value: '3-1',
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '图像识别',
|
|
|
|
|
|
|
|
value: '3-1-1'
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '目标检测',
|
|
|
|
|
|
|
|
value: '3-1-2'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: 'Python:3.10.12',
|
|
|
|
|
|
|
|
value: '3-2',
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '图像识别',
|
|
|
|
|
|
|
|
value: '3-2-1'
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '目标检测',
|
|
|
|
|
|
|
|
value: '3-2-2'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '运动规划组件',
|
|
|
|
|
|
|
|
value: '4',
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: 'Java:8',
|
|
|
|
|
|
|
|
value: '4-1',
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '路径规划',
|
|
|
|
|
|
|
|
value: '4-1-1'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: 'Python:3.10.12',
|
|
|
|
|
|
|
|
value: '4-2',
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '路径规划',
|
|
|
|
|
|
|
|
value: '4-2-1'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '工艺知识服务组件',
|
|
|
|
|
|
|
|
value: '5',
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: 'Java:8',
|
|
|
|
|
|
|
|
value: '5-1',
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '工艺参数优化',
|
|
|
|
|
|
|
|
value: '5-1-1'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: 'Python:3.10.12',
|
|
|
|
|
|
|
|
value: '5-2',
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '工艺参数优化',
|
|
|
|
|
|
|
|
value: '5-2-1'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '时序数据AI组件',
|
|
|
|
|
|
|
|
value: '6',
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: 'Java:8',
|
|
|
|
|
|
|
|
value: '6-1',
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '时间序列预测',
|
|
|
|
|
|
|
|
value: '6-1-1'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: 'Python:3.10.12',
|
|
|
|
|
|
|
|
value: '6-2',
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: '时间序列预测',
|
|
|
|
|
|
|
|
value: '6-2-1'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
|
|
// 使用 Cascader 组件替换 Select 组件
|
|
|
|
|
|
|
|
<Cascader
|
|
|
|
|
|
|
|
placeholder="选择组件"
|
|
|
|
|
|
|
|
autoWidth={true}
|
|
|
|
|
|
|
|
showSearch
|
|
|
|
|
|
|
|
options={cascaderOptions}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div className={styles['component-coding']}>
|
|
|
|
<div className={styles['component-coding']}>
|
|
|
|
@ -203,9 +48,48 @@ const ComponentCoding = () => {
|
|
|
|
size={50}
|
|
|
|
size={50}
|
|
|
|
style={{ marginTop: '20px', marginBottom: '30px' }}
|
|
|
|
style={{ marginTop: '20px', marginBottom: '30px' }}
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<div className={styles['handleRow']}>
|
|
|
|
<div className={styles['handle-row']}>
|
|
|
|
<span>组件筛选:</span>
|
|
|
|
<Space size={40}>
|
|
|
|
{componentScreening()}
|
|
|
|
<div className={styles['handle-row-item']}>
|
|
|
|
|
|
|
|
<span>组件名称:</span>
|
|
|
|
|
|
|
|
<span>{componentCoding.name || '未选择组件'}</span>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className={styles['handle-row-item']}>
|
|
|
|
|
|
|
|
<span>组件标识:</span>
|
|
|
|
|
|
|
|
<span>{componentCoding.projectId || '未选择组件'}</span>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className={styles['handle-row-item']}>
|
|
|
|
|
|
|
|
<span>组件选择:</span>
|
|
|
|
|
|
|
|
<Select
|
|
|
|
|
|
|
|
placeholder="选择组件"
|
|
|
|
|
|
|
|
style={{ width: 250 }}
|
|
|
|
|
|
|
|
showSearch
|
|
|
|
|
|
|
|
filterOption={(inputValue, option) => {
|
|
|
|
|
|
|
|
return option.props.children.toLowerCase().indexOf(inputValue.toLowerCase()) >= 0;
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
onChange={(value) => {
|
|
|
|
|
|
|
|
// 查找选中项的完整信息
|
|
|
|
|
|
|
|
const selectedComponent = originList.find(item => item.localProjectPath === value);
|
|
|
|
|
|
|
|
if (selectedComponent) {
|
|
|
|
|
|
|
|
// 更新Redux状态
|
|
|
|
|
|
|
|
dispatch(updateComponentCodingPath({
|
|
|
|
|
|
|
|
localProjectPath: selectedComponent.localProjectPath,
|
|
|
|
|
|
|
|
name: selectedComponent.name,
|
|
|
|
|
|
|
|
projectId: selectedComponent.projectId,
|
|
|
|
|
|
|
|
id: selectedComponent.id
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
value={componentCoding.localProjectPath || undefined}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
{optionsList.map((option, index) => (
|
|
|
|
|
|
|
|
<Option key={option.value} value={option.value}>
|
|
|
|
|
|
|
|
{option.label}
|
|
|
|
|
|
|
|
</Option>
|
|
|
|
|
|
|
|
))}
|
|
|
|
|
|
|
|
</Select>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</Space>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Space>
|
|
|
|
</Space>
|
|
|
|
|
|
|
|
|
|
|
|
@ -216,11 +100,6 @@ const ComponentCoding = () => {
|
|
|
|
>
|
|
|
|
>
|
|
|
|
启动项设置
|
|
|
|
启动项设置
|
|
|
|
</Button>
|
|
|
|
</Button>
|
|
|
|
<Input
|
|
|
|
|
|
|
|
prefix={<IconSearch />}
|
|
|
|
|
|
|
|
placeholder={'搜索组件关键词'}
|
|
|
|
|
|
|
|
style={{ width: 236 }}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</Space>
|
|
|
|
</Space>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|