|
|
|
@ -27,25 +27,30 @@ const EventSelect: React.FC<EventSelectProps> = ({ nodeData, eventList, type, on
|
|
|
|
const [form] = Form.useForm();
|
|
|
|
const [form] = Form.useForm();
|
|
|
|
const [showModal, setShowModal] = useState(false);
|
|
|
|
const [showModal, setShowModal] = useState(false);
|
|
|
|
const [currentEvent, setCurrentEvent] = useState<any>(null);
|
|
|
|
const [currentEvent, setCurrentEvent] = useState<any>(null);
|
|
|
|
const { currentAppData } = useSelector(state => state.ideContainer);
|
|
|
|
const { currentAppData, eventListOld } = useSelector(state => state.ideContainer);
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
if (nodeData && eventList && eventList.length > 0) {
|
|
|
|
if (nodeData && eventList && eventList.length > 0) {
|
|
|
|
setOptions(eventList.filter(item => !item.topic.includes('**empty**')));
|
|
|
|
setOptions(eventList.filter(item => !item.topic.includes('**empty**')));
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
// 数据是JSON字符串,标识是接口回来的
|
|
|
|
const customDef = JSON.parse(nodeData.component?.customDef);
|
|
|
|
const customDef = JSON.parse(nodeData.component?.customDef);
|
|
|
|
// 先判断topic是不是**empty**,是就不设置currentevent
|
|
|
|
// 先判断topic是不是**empty**,是就不设置currentevent
|
|
|
|
if (customDef.topic && customDef.topic.includes('**empty**')) {
|
|
|
|
if (customDef.topic && customDef.topic.includes('**empty**')) setCurrentEvent(null);
|
|
|
|
setCurrentEvent(null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
setCurrentEvent(eventList.find(item => customDef.topic === item.topic));
|
|
|
|
if (!customDef.eventId) {
|
|
|
|
|
|
|
|
setCurrentEvent(eventList.find(item => customDef.topic === item.topic));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
const currentItem = eventListOld.find(item => customDef.eventId === item.eventId);
|
|
|
|
|
|
|
|
console.log('1', currentItem);
|
|
|
|
|
|
|
|
setCurrentEvent(currentItem.topic);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
// 数据是普通对象标识是当前操作数据
|
|
|
|
// 先判断topic是不是**empty**,是就不设置currentevent
|
|
|
|
// 先判断topic是不是**empty**,是就不设置currentevent
|
|
|
|
if (nodeData.component?.customDef?.topic && nodeData.component?.customDef?.topic.includes('**empty**')) {
|
|
|
|
if (nodeData.component?.customDef?.topic && nodeData.component?.customDef?.topic.includes('**empty**')) setCurrentEvent(null);
|
|
|
|
setCurrentEvent(null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
setCurrentEvent(eventList.find(item => nodeData.component?.customDef.topic === item.topic));
|
|
|
|
setCurrentEvent(eventList.find(item => nodeData.component?.customDef.topic === item.topic));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -80,10 +85,11 @@ const EventSelect: React.FC<EventSelectProps> = ({ nodeData, eventList, type, on
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handelSelect = (e) => {
|
|
|
|
const handelSelect = (e) => {
|
|
|
|
|
|
|
|
console.log('e:', e);
|
|
|
|
const data = {
|
|
|
|
const data = {
|
|
|
|
type: typeMap[type],
|
|
|
|
type: typeMap[type],
|
|
|
|
customDef: {
|
|
|
|
customDef: {
|
|
|
|
eventId: null,
|
|
|
|
eventId: e.eventId,
|
|
|
|
name: e.name,
|
|
|
|
name: e.name,
|
|
|
|
topic: e.topic
|
|
|
|
topic: e.topic
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -123,8 +129,8 @@ const EventSelect: React.FC<EventSelectProps> = ({ nodeData, eventList, type, on
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
dropdownMenuStyle={{ maxHeight: 300 }}
|
|
|
|
dropdownMenuStyle={{ maxHeight: 300 }}
|
|
|
|
>
|
|
|
|
>
|
|
|
|
{options.map((option) => (
|
|
|
|
{options.map((option, index) => (
|
|
|
|
<Option key={option.topicId} value={option}>
|
|
|
|
<Option key={option.topic} value={option}>
|
|
|
|
{option.name}
|
|
|
|
{option.name}
|
|
|
|
</Option>
|
|
|
|
</Option>
|
|
|
|
))}
|
|
|
|
))}
|
|
|
|
|