From 40c54170ec4e96bae33a8fc38b34807ba70fd4b3 Mon Sep 17 00:00:00 2001 From: ZLY Date: Wed, 21 Jan 2026 17:32:05 +0800 Subject: [PATCH] =?UTF-8?q?feat(component):=20=E6=B7=BB=E5=8A=A0=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=8D=8F=E4=BD=9C=E5=8A=9F=E8=83=BD=E5=92=8C=E6=9D=83?= =?UTF-8?q?=E9=99=90=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/componentCollaborator.ts | 28 ++ src/api/user.ts | 5 + .../componentList/addComponentModal.tsx | 82 ++-- .../componentList/handleButtonGroup.tsx | 182 +++++---- .../componentList/index.tsx | 40 +- .../componentList/shareCollaborationModal.tsx | 355 ++++++++++++++++++ 6 files changed, 575 insertions(+), 117 deletions(-) create mode 100644 src/api/componentCollaborator.ts create mode 100644 src/pages/componentDevelopment/componentList/shareCollaborationModal.tsx diff --git a/src/api/componentCollaborator.ts b/src/api/componentCollaborator.ts new file mode 100644 index 0000000..db151d8 --- /dev/null +++ b/src/api/componentCollaborator.ts @@ -0,0 +1,28 @@ +import axios from 'axios'; + +// 公共路径 +const urlPrefix = '/api/v1/bpms-workbench'; + +// 添加协作用户 +export function addCollaborator(params: { + componentBaseId: string|number, + collaboratorId: string, + permission: string +}) { + return axios.post(`${urlPrefix}/componentCollaborator/submit`, params); +} + +// 删除协作用户 +export function deleteCollaborator(params: { id: string }) { + return axios.post(`${urlPrefix}/componentCollaborator/delete`, params); +} + +// 组件协作 同步gitea协作者数据到本地 +export function synchronizeCollaborator(componentBaseId: string | number) { + return axios.get(`${urlPrefix}/componentCollaborator/synchronize`, { params: { componentBaseId } }); +} + +// 获取该组件下的协作者列表 +export function getCollaboratorList(componentBaseId: string | number) { + return axios.get(`${urlPrefix}/componentCollaborator/list`, { params: { componentBaseId } }); +} \ No newline at end of file diff --git a/src/api/user.ts b/src/api/user.ts index c3e4cde..20dda12 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -42,4 +42,9 @@ export function logout() { export function getUserToken() { return axios.get(`${urlPrefix}/sessions/validate`, {}); +} + +// 获取用户列表 +export function getUserList() { + return axios.get(`${urlPrefix}/users/list`); } \ No newline at end of file diff --git a/src/pages/componentDevelopment/componentList/addComponentModal.tsx b/src/pages/componentDevelopment/componentList/addComponentModal.tsx index d645c95..1bc25b8 100644 --- a/src/pages/componentDevelopment/componentList/addComponentModal.tsx +++ b/src/pages/componentDevelopment/componentList/addComponentModal.tsx @@ -38,7 +38,7 @@ const Option = Select.Option; // 定义组件模式类型 type ComponentMode = 'create' | 'edit' | 'copy'; -const AddComponentModal = ({ visible, baseInfo, setVisible, onReFresh, mode = 'create' }) => { +const AddComponentModal = ({ visible, baseInfo, setVisible, onReFresh, mode = 'create', permission = 'write' }) => { const [selectedImage, setSelectedImage] = useState(''); const [description, setDescription] = useState(''); const [classifyList, setClassifyList] = useState([]); @@ -73,6 +73,8 @@ const AddComponentModal = ({ visible, baseInfo, setVisible, onReFresh, mode = 'c const isEditMode = mode === 'edit'; // 判断是否为创建模式 const isCreateMode = mode === 'create'; + // 判断是否为只读模式(read权限) + const isReadOnly = permission === 'read'; const columns: TableColumnProps[] = [ { @@ -112,14 +114,14 @@ const AddComponentModal = ({ visible, baseInfo, setVisible, onReFresh, mode = 'c setSelectedApiData(record); setShowApiModal(true); }} - disabled={isCopyMode || (componentInfo && !['DEFAULT', 'DESIGN'].includes(componentInfo.componentStatus))} + disabled={isReadOnly || isCopyMode || (componentInfo && !['DEFAULT', 'DESIGN'].includes(componentInfo.componentStatus))} > 编辑 - {isCopyMode ? ( + + {!isReadOnly && ( <> - - + {isCopyMode ? ( + <> + + + + ) : showSaveBtn ? ( + + ) : ( + + )} - ) : showSaveBtn ? ( - - ) : ( - )} ); @@ -506,6 +514,7 @@ const AddComponentModal = ({ visible, baseInfo, setVisible, onReFresh, mode = 'c headers={{ Authorization: getToken() }} fileList={file ? [file] : initialImageUrl ? [{ url: initialImageUrl, status: 'done' }] : []} showUploadList={false} + disabled={isReadOnly} onChange={(_, currentFile: any) => { setFile({ ...currentFile, @@ -601,7 +610,7 @@ const AddComponentModal = ({ visible, baseInfo, setVisible, onReFresh, mode = 'c } } ]}> - + @@ -620,7 +629,7 @@ const AddComponentModal = ({ visible, baseInfo, setVisible, onReFresh, mode = 'c style={{ width: '90%' }} allowClear placeholder="请输入代码标识" - disabled={created || isEditMode} + disabled={isReadOnly || created || isEditMode} onChange={(e) => debouncedValidateProjectId(e)} /> @@ -642,6 +651,7 @@ const AddComponentModal = ({ visible, baseInfo, setVisible, onReFresh, mode = 'c {codeLanguageOptions.map((option) => (