diff --git a/src/api/event.ts b/src/api/event.ts new file mode 100644 index 0000000..d0ce188 --- /dev/null +++ b/src/api/event.ts @@ -0,0 +1,41 @@ +import axios from 'axios'; +import { AddEventParams, DeleteEventParams, DeleteEventForAppParams } from '@/api/interface'; + +// 公共路径 +const urlPrefix = '/api/v1/bpms-workbench'; + +// 事件管理-获取事件列表 +export function getEventList() { + return axios.get(`${urlPrefix}/event/list`); +} + +// 事件管理-添加事件 +export function addEventItem(params: AddEventParams) { + return axios.post(`${urlPrefix}/event/addSub`, params); +} + +// 事件管理-删除事件 +export function deleteEventItem(id: DeleteEventParams) { + return axios.delete(`${urlPrefix}/event/${id}/del`); +} + +// 事件管理-删除应用发布(事件发送) +export function deleteEventPub(params: DeleteEventForAppParams) { + return axios.delete(`${urlPrefix}/event/pub`, { data: params }); +} + +// 事件管理-删除应用定远(事件接收) +export function deleteEventSub(params: DeleteEventForAppParams) { + return axios.delete(`${urlPrefix}/event/sub`, { data: params }); +} + +// 事件管理-查询事件 +export function queryEventItem(name: string) { + return axios.post(`${urlPrefix}/event/get`, { name }); +} + +// 事件管理-使用场景ID查询事件 +export function queryEventItemBySceneId(sceneId: string) { + return axios.get(`${urlPrefix}/event/${sceneId}/get`); +} + diff --git a/src/pages/orchestration/event/index.tsx b/src/pages/orchestration/event/index.tsx new file mode 100644 index 0000000..92e2ef4 --- /dev/null +++ b/src/pages/orchestration/event/index.tsx @@ -0,0 +1,233 @@ +import React, { useEffect, useState } from 'react'; +import styles from './style/index.module.less'; +import { + Button, + Input, + Space, + Divider, + Table, + TableColumnProps, + Modal, + Form, + Message, + Popconfirm +} from '@arco-design/web-react'; +import { IconSearch } from '@arco-design/web-react/icon'; +import { useSelector } from 'react-redux'; +import { addEventItem, deleteEventItem, queryEventItemBySceneId } from '@/api/event'; + +const FormItem = Form.Item; +const TextArea = Input.TextArea; + +const HandleModal = ({ visible, onChangeVisible, onRefresh }) => { + const [form] = Form.useForm(); + const { info } = useSelector((state: any) => state.ideContainer); + + const onOk = async () => { + await form.validate(); + const formData = form.getFields(); + + const params = { + name: formData.name, + topic: `${formData.topic}/${info.identity}`, + description: formData.description, + sceneId: info.id + }; + + const res: any = await addEventItem(params); + + if (res && res.code === 200) { + Message.success('添加成功'); + onChangeVisible(false); + onRefresh(); + } + else { + Message.error(res.message); + } + + // 清空表单数据和其他变量数据 + form.resetFields(); + + }; + + return ( + onOk()} + onCancel={() => onChangeVisible(false)} + autoFocus={false} + focusLock={true} + maskClosable={false} + > + + + + + + + + + + + + + ); +}; + + +const EventContainer = () => { + const [eventData, setEventData] = useState([]); + const [visible, setVisible] = useState(false); + const { info } = useSelector((state: any) => state.ideContainer); + + const columns: TableColumnProps[] = [ + { + title: '序号', + dataIndex: 'index', + render: (_, record, index) => ( + {index + 1} + ) + }, + { + title: '事件名称', + dataIndex: 'name' + }, + { + title: '事件标识', + dataIndex: 'topic', + render: (_, record) => ( + {record.topic.includes('/') ? record.topic.split('/')[0] : record.topic} + ) + }, + { + title: '事件描述', + dataIndex: 'description', + width: '80%' + }, + { + title: '操作', + dataIndex: 'actions', + render: (_, record) => ( + { + const res: any = await deleteEventItem(record.id); + if (res && res.code === 200) { + Message.success('删除成功'); + fetchEventData(); + } + else { + Message.error(res.message); + } + }} + + > + 删除 + + ) + } + ]; + + const fetchEventData = async () => { + const res: any = await queryEventItemBySceneId(info.id); + if (res && res.code === 200) setEventData(res.data); + }; + + useEffect(() => { + if (info.id) { + fetchEventData(); + } + }, [info.id]); + + return ( + + {/*头部*/} + + 事件列表 + + }> + } + placeholder={'搜索'} + style={{ width: 236 }} + /> + setVisible(true)} + > + + 添加事件 + + + + + {/*数据列表*/} + + + + + {visible && + setVisible(value))} + onRefresh={() => fetchEventData()} + /> + } + + ); +}; + +export default EventContainer; \ No newline at end of file diff --git a/src/pages/orchestration/event/style/index.module.less b/src/pages/orchestration/event/style/index.module.less new file mode 100644 index 0000000..8dedc34 --- /dev/null +++ b/src/pages/orchestration/event/style/index.module.less @@ -0,0 +1,22 @@ +.event-container { + background-color: #ffffff; + padding: 17px 19px 0 24px; + height: 98%; + + .event-header { + display: flex; + justify-content: space-between; + margin-bottom: 15px; + + .event-title { + font-size: 18px; + font-weight: 700; + } + + .event-handle{} + } + + .event-list { + + } +} \ No newline at end of file