diff --git a/src/api/componentBase.ts b/src/api/componentBase.ts new file mode 100644 index 0000000..1710f92 --- /dev/null +++ b/src/api/componentBase.ts @@ -0,0 +1,9 @@ +import axios from 'axios'; + +// 公共路径 +const urlPrefix = '/api/v1/bpms-workbench'; + +// 我的组件 +export function getMyComponentList(params) { + return axios.get(`${urlPrefix}/componentBase/list`, { params }); +} \ No newline at end of file diff --git a/src/api/interface/index.ts b/src/api/interface/index.ts index 0af6396..36a1832 100644 --- a/src/api/interface/index.ts +++ b/src/api/interface/index.ts @@ -230,4 +230,29 @@ export interface GlobalParams { arrayType: any, defaultValue: any, sceneId: string, -} \ No newline at end of file +} + +// component +export interface ComponentItem { + id: number; + name: string; + identifier: string; + projectId: string; + componentClassify: string; + codeLanguage: string; + desc: string; + componentStatus: string; + tags: string[]; + version: string; + logoUrl: string; + localProjectPath: string; + publishStatus: number; + publicStatus: number; + publishTime: string; + updateTime: string; + onlineInstanceCount: number; + createUser: string; + permission: string; + repoCloneUrl: string; + createUserName: string; +} diff --git a/src/pages/componentDevelopment/componentList/addComponentModal.tsx b/src/pages/componentDevelopment/componentList/addComponentModal.tsx new file mode 100644 index 0000000..7bb2a94 --- /dev/null +++ b/src/pages/componentDevelopment/componentList/addComponentModal.tsx @@ -0,0 +1,146 @@ +import React, { useState } from 'react'; +import { Modal, Form, Input, Grid, Space, Divider, Button, Table, TableColumnProps } from '@arco-design/web-react'; +import styles from './style/addComponentModal.module.less'; +import Cover from '@/pages/scene/cover'; + +const FormItem = Form.Item; + +const columns: TableColumnProps[] = [ + { + title: '接口名称', + dataIndex: 'name' + }, + { + title: '输入参数', + dataIndex: 'salary' + }, + { + title: '输出参数', + dataIndex: 'address' + }, + { + title: '操作', + dataIndex: 'email' + } +]; +const data = [ + { + key: '1', + name: 'Jane Doe', + salary: 23000, + address: '32 Park Road, London', + email: 'jane.doe@example.com' + } +]; + + +const AddComponentModal = ({ visible, setVisible }) => { + const [selectedImage, setSelectedImage] = useState(''); + const [form] = Form.useForm(); + + const transformImageUrl = (image: string) => { + if (!image) return; + if (image.includes('/')) setSelectedImage(image.split('/')[image.split('/').length - 1]); + else setSelectedImage(image); + }; + + const modalFooter = () => { + return ( + + + + + + ); + }; + return ( + setVisible(false)} + onCancel={() => setVisible(false)} + autoFocus={false} + focusLock={true} + style={{ width: '60%' }} + footer={modalFooter} + > +
+
+
+ + transformImageUrl(selectedImage)} + /> + + +
组件外壳 +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 富文本编辑器 + +
+
+
+
+

组件接口

+ +
+ + + + + + ); +}; + +export default AddComponentModal; \ No newline at end of file diff --git a/src/pages/componentDevelopment/componentList/index.tsx b/src/pages/componentDevelopment/componentList/index.tsx index a3289a0..520b443 100644 --- a/src/pages/componentDevelopment/componentList/index.tsx +++ b/src/pages/componentDevelopment/componentList/index.tsx @@ -1,98 +1,208 @@ -import React, { useState } from 'react'; +import React, { useState, useEffect } from 'react'; import styles from './style/index.module.less'; -import { Button, Divider, Input, Space, Table, Radio } from '@arco-design/web-react'; +import { Button, Divider, Input, Space, Table, Radio, Pagination } from '@arco-design/web-react'; import { IconSearch } from '@arco-design/web-react/icon'; +import { getMyComponentList } from '@/api/componentBase'; +import { ComponentItem } from '@/api/interface'; +import AddComponentModal from '@/pages/componentDevelopment/componentList/addComponentModal'; const Group = Radio.Group; +const menuItems = [ + { + key: '1', + label: '我的组件', + icon: '/ideContainer/icon/myComp.png', + activeIcon: '/ideContainer/icon/myComp_active.png' + }, + { + key: '2', + label: '协同组件', + icon: '/ideContainer/icon/teamComp.png', + activeIcon: '/ideContainer/icon/teamComp_active.png' + }, + { + key: '3', + label: '组件审核', + icon: '/ideContainer/icon/compAudit.png', + activeIcon: '/ideContainer/icon/compAudit_active.png' + } +]; + +const columns = [ + { + title: '组件名称', + dataIndex: 'name' + }, + { + title: '标识符', + dataIndex: 'identifier' + }, + { + title: '分类', + dataIndex: 'componentClassify' + }, + { + title: '语言', + dataIndex: 'codeLanguage' + }, + { + title: '描述', + dataIndex: 'desc' + }, + { + title: '状态', + dataIndex: 'componentStatus' + }, + { + title: '更新时间', + dataIndex: 'updateTime' + }, + { + title: '操作', + dataIndex: 'operations', + render: () => ( + + ) + } +]; + const GlobalVarContainer = () => { - const [selectedItem, setSelectedItem] = useState('数字类型'); + const [selectedItem, setSelectedItem] = useState('我的组件'); + const [componentData, setComponentData] = useState([]); + const [pagination, setPagination] = useState({ + totalCount: 0, + pageSize: 10, + totalPage: 0, + currPage: 1 + }); + const [loading, setLoading] = useState(false); + const [visible, setVisible] = useState(false); - const menuItems = [ - { - key: '1', - label: '我的组件', - icon: '/ideContainer/icon/myComp.png', - activeIcon: '/ideContainer/icon/myComp_active.png' - }, - { - key: '2', - label: '协同组件', - icon: '/ideContainer/icon/teamComp.png', - activeIcon: '/ideContainer/icon/teamComp_active.png' - }, - { - key: '3', - label: '组件审核', - icon: '/ideContainer/icon/compAudit.png', - activeIcon: '/ideContainer/icon/compAudit_active.png' + useEffect(() => { + if (selectedItem === '我的组件') { + fetchComponentData(); } - ]; + }, [selectedItem, pagination.currPage, pagination.pageSize]); + + const fetchComponentData = async () => { + setLoading(true); + try { + const res: any = await getMyComponentList({ + currPage: pagination.currPage, + pageSize: pagination.pageSize + }); + + setComponentData(res.list); + setPagination({ + totalCount: res.totalCount, + pageSize: res.pageSize, + totalPage: res.totalPage, + currPage: res.currPage + }); + } catch (error) { + console.error('获取组件列表失败:', error); + } finally { + setLoading(false); + } + }; + + const handlePageChange = (page: number, pageSize?: number) => { + setPagination({ + ...pagination, + currPage: page, + pageSize: pageSize || pagination.pageSize + }); + }; + return ( -
- {/*左侧菜单*/} -
- {menuItems.map((item, index) => ( -
setSelectedItem(item.label)} - > - - {item.label} + <> +
+ {/*左侧菜单*/} +
+ {menuItems.map((item, index) => ( +
setSelectedItem(item.label)} + > + + {item.label} +
+ ))} +
+
+ {/*头部*/} +
+
+ + } + placeholder={'搜索'} + style={{ width: 236 }} + /> + + +
+
+ + {['未设计', '编码中', '已部署'].map((item) => { + return ( + + {({ checked }) => { + return ( + + ); + }} + + ); + })} + + }> + + + + +
+
- ))} -
-
- {/*头部*/} -
-
- - } - placeholder={'搜索'} - style={{ width: 236 }} + {/*数据列表*/} +
+
+
+ `第 ${range[0]}-${range[1]} 条,共 ${total} 条`} + onChange={handlePageChange} /> - - -
-
- - {['未设计', '编码中', '已部署'].map((item) => { - return ( - - {({ checked }) => { - return ( - - ); - }} - - ); - })} - - }> - - - - +
- - - {/*数据列表*/} -
- {/*
*/} - + + {/*新增弹窗*/} + + ); }; diff --git a/src/pages/componentDevelopment/componentList/style/addComponentModal.module.less b/src/pages/componentDevelopment/componentList/style/addComponentModal.module.less new file mode 100644 index 0000000..4ef4d57 --- /dev/null +++ b/src/pages/componentDevelopment/componentList/style/addComponentModal.module.less @@ -0,0 +1,48 @@ +.add-component-modal { + :global(.arco-modal-content) { + padding-left: 0; + padding-right: 0; + background-color: #f7f8fa + } +} + +.add-component-container { + + .first-half { + width: 100%; + display: flex; + justify-content: space-between; + margin-bottom: 20px; + + .component-preview { + overflow: hidden; + width: 30%; + background-color: #fff; + padding: 15px 5px; + border: 1px solid transparent; + border-top-right-radius: 5px; + border-bottom-right-radius: 5px; + } + + .component-info { + width: 67%; + background-color: #fff; + padding: 15px 5px; + border: 1px solid transparent; + border-top-left-radius: 5px; + border-bottom-left-radius: 5px; + } + } + + .last-half { + box-sizing: border-box; + width: 100%; + background-color: #fff; + padding: 15px 20px; + + .last-half-header { + display: flex; + justify-content: space-between; + } + } +} \ No newline at end of file