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) => (