每页行数:
-
+
+ {/* Add File Modal */}
+ {showAddFileModal && (
+
+
+
+
新增文件
+
+
+
+
+
+
+ 文件名称将自动填充为上传文件的名称
+
+
+
+
+
+
+
+
+
+ {newFile.file ? (
+
+
{newFile.name}
+
+ {(newFile.file.size / 1024).toFixed(2)} KB
+
+
+ ) : (
+
+
+
点击或拖拽文件到此处上传
+
支持 PDF, DOCX, TXT, CSV 等格式
+
+ )}
+
+ {fileErrors.file &&
{fileErrors.file}
}
+
+
+
+
+
+
+
+
+ )}
>
);
}
diff --git a/src/pages/KnowledgeBase/Detail/SettingsTab.jsx b/src/pages/KnowledgeBase/Detail/SettingsTab.jsx
index fd28adf..f08a19e 100644
--- a/src/pages/KnowledgeBase/Detail/SettingsTab.jsx
+++ b/src/pages/KnowledgeBase/Detail/SettingsTab.jsx
@@ -1,8 +1,114 @@
-import React from 'react';
+import React, { useState } from 'react';
import { Link } from 'react-router-dom';
import SvgIcon from '../../../components/SvgIcon';
+import { useDispatch } from 'react-redux';
+import { showNotification } from '../../../store/notification.slice';
export default function SettingsTab({ knowledgeBase }) {
+ const dispatch = useDispatch();
+ // State for pagination
+ const [currentPage, setCurrentPage] = useState(1);
+ const usersPerPage = 10;
+
+ // State for edit modal
+ const [showEditModal, setShowEditModal] = useState(false);
+ const [editUser, setEditUser] = useState(null);
+ const [formErrors, setFormErrors] = useState({});
+
+ // Mock data for users with permissions - convert to state so we can update it
+ const [users, setUsers] = useState([
+ {
+ id: '1001',
+ username: '张三',
+ email: 'zhang@abc.com',
+ permissionType: '只读',
+ accessDuration: '一个月',
+ },
+ {
+ id: '1002',
+ username: '李四',
+ email: 'li@abc.com',
+ permissionType: '完全访问',
+ accessDuration: '永久',
+ },
+ {
+ id: '1003',
+ username: '王五',
+ email: 'wang@abc.com',
+ permissionType: '只读',
+ accessDuration: '三个月',
+ },
+ {
+ id: '1004',
+ username: '赵六',
+ email: 'zhao@abc.com',
+ permissionType: '完全访问',
+ accessDuration: '六个月',
+ },
+ {
+ id: '1005',
+ username: '钱七',
+ email: 'qian@abc.com',
+ permissionType: '只读',
+ accessDuration: '一周',
+ },
+ {
+ id: '1006',
+ username: '孙八',
+ email: 'sun@abc.com',
+ permissionType: '只读',
+ accessDuration: '一个月',
+ },
+ {
+ id: '1007',
+ username: '周九',
+ email: 'zhou@abc.com',
+ permissionType: '完全访问',
+ accessDuration: '永久',
+ },
+ {
+ id: '1008',
+ username: '吴十',
+ email: 'wu@abc.com',
+ permissionType: '只读',
+ accessDuration: '三个月',
+ },
+ {
+ id: '1009',
+ username: '郑十一',
+ email: 'zheng@abc.com',
+ permissionType: '完全访问',
+ accessDuration: '六个月',
+ },
+ {
+ id: '1010',
+ username: '冯十二',
+ email: 'feng@abc.com',
+ permissionType: '只读',
+ accessDuration: '一周',
+ },
+ {
+ id: '1011',
+ username: '陈十三',
+ email: 'chen@abc.com',
+ permissionType: '只读',
+ accessDuration: '一个月',
+ },
+ {
+ id: '1012',
+ username: '褚十四',
+ email: 'chu@abc.com',
+ permissionType: '完全访问',
+ accessDuration: '永久',
+ },
+ ]);
+
+ // Get current users for pagination
+ const indexOfLastUser = currentPage * usersPerPage;
+ const indexOfFirstUser = indexOfLastUser - usersPerPage;
+ const currentUsers = users.slice(indexOfFirstUser, indexOfLastUser);
+ const totalPages = Math.ceil(users.length / usersPerPage);
+
// Handle form submission
const handleSubmit = (e) => {
e.preventDefault();
@@ -16,6 +122,83 @@ export default function SettingsTab({ knowledgeBase }) {
console.log('Deleting knowledge base:', knowledgeBase.id);
};
+ // Handle edit user permissions
+ const handleEditUser = (user) => {
+ setEditUser({ ...user });
+ setFormErrors({});
+ setShowEditModal(true);
+ };
+
+ // Handle input change in edit modal
+ const handleEditInputChange = (e) => {
+ const { name, value } = e.target;
+ setEditUser((prev) => ({
+ ...prev,
+ [name]: value,
+ }));
+
+ // Clear error if exists
+ if (formErrors[name]) {
+ setFormErrors((prev) => ({
+ ...prev,
+ [name]: '',
+ }));
+ }
+ };
+
+ // Validate edit form
+ const validateEditForm = () => {
+ const errors = {};
+
+ if (!editUser.permissionType) {
+ errors.permissionType = '请选择权限类型';
+ }
+
+ if (!editUser.accessDuration) {
+ errors.accessDuration = '请选择访问时长';
+ }
+
+ setFormErrors(errors);
+ return Object.keys(errors).length === 0;
+ };
+
+ // Handle save user permissions
+ const handleSaveUserPermissions = () => {
+ // Validate form
+ if (!validateEditForm()) {
+ return;
+ }
+
+ // Here you would typically call an API to update the user permissions
+ console.log('Updating user permissions:', editUser);
+
+ // Update the users array with the edited user
+ setUsers((prevUsers) => prevUsers.map((user) => (user.id === editUser.id ? { ...editUser } : user)));
+
+ // Show success notification (in a real app)
+ dispatch(showNotification({ message: '用户权限已更新', type: 'success' }));
+
+ // Close modal
+ setShowEditModal(false);
+ };
+
+ // Handle pagination
+ const handlePageChange = (pageNumber) => {
+ setCurrentPage(pageNumber);
+ };
+
+ // Handle delete user
+ const handleDeleteUser = (userId) => {
+ // Here you would typically call an API to delete the user
+ console.log('Deleting user:', userId);
+
+ // Update the users array by removing the deleted user
+ setUsers((prevUsers) => prevUsers.filter((user) => user.id !== userId));
+
+ // Show success notification (in a real app)
+ dispatch(showNotification({ message: '用户已删除', type: 'success' }));
+ };
+
return (
<>
{/* Breadcrumb navigation */}
@@ -23,10 +206,17 @@ export default function SettingsTab({ knowledgeBase }) {
+
+ {/* Pagination */}
+ {users.length > usersPerPage && (
+