|
@@ -33,18 +33,26 @@ import { downloadFile, getToken } from '@/utils/utils';
|
|
|
import {
|
|
|
ExclamationCircleOutlined,
|
|
|
PlusCircleOutlined,
|
|
|
+ PlusOutlined,
|
|
|
} from '@ant-design/icons';
|
|
|
import AddFileModal from './components/model';
|
|
|
import PerModal from './components/PreModal';
|
|
|
import { queryAuditList, createAduit } from '@/services/boom';
|
|
|
import { stringify } from 'qs';
|
|
|
import FileViewerModal from '@/components/FileViewerNew';
|
|
|
+import AddModal from './components/AddModal';
|
|
|
+import { useMemo } from 'react';
|
|
|
|
|
|
const tempData = [
|
|
|
{ name: '文件1', upload_user: '管理员', upload_time: '2023-04-08 11:00:00' },
|
|
|
{ name: '文件2', upload_user: '管理员', upload_time: '2023-04-10 11:00:00' },
|
|
|
];
|
|
|
|
|
|
+const tempPer = [
|
|
|
+ { name: '管理员', list: 1, read: 1, download: 1, delete: 1, permission: 1 },
|
|
|
+ { name: '徐俊杰', list: 1, read: 1, download: 0, delete: 0, permission: 0 },
|
|
|
+];
|
|
|
+
|
|
|
const { DirectoryTree } = Tree;
|
|
|
const { Search } = Input;
|
|
|
const { RangePicker } = DatePicker;
|
|
@@ -53,12 +61,20 @@ function FileManagement(props) {
|
|
|
const [form] = Form.useForm();
|
|
|
const [modal, contextHolder] = Modal.useModal();
|
|
|
const { user } = useModel('userInfo');
|
|
|
+ const { userList, run: userListRun } = useModel('userList');
|
|
|
const [tableData, setTableData] = useState([]);
|
|
|
const [visible, setVisible] = useState(false);
|
|
|
const [node, setNode] = useState();
|
|
|
const [selectedRowKeys, setSelectedRowKeys] = useState([]);
|
|
|
const [fileViewerVisible, setFileViewerVisible] = useState(false);
|
|
|
const [fileViewerData, setFileViewerData] = useState();
|
|
|
+ const [editPer, setEditPer] = useState(false);
|
|
|
+ const [preUserListData, setPreUserListData] = useState([]);
|
|
|
+
|
|
|
+ const isSuper = useMemo(() => {
|
|
|
+ if (user?.Permission['menu-001-audit']) return true;
|
|
|
+ return false;
|
|
|
+ }, [user]);
|
|
|
|
|
|
const {
|
|
|
data: treeData,
|
|
@@ -81,8 +97,8 @@ function FileManagement(props) {
|
|
|
return {
|
|
|
...item,
|
|
|
dir_name: item.file_name,
|
|
|
- create_time: item.created_on,
|
|
|
- key: idx,
|
|
|
+ create_time: item.create_time,
|
|
|
+ key: item.id,
|
|
|
};
|
|
|
}) || [];
|
|
|
setTableData(result);
|
|
@@ -110,8 +126,9 @@ function FileManagement(props) {
|
|
|
return {
|
|
|
...item,
|
|
|
dir_name: name,
|
|
|
+ user_name: item.CreatorUser.CName,
|
|
|
create_time: dayjs(item.c_time).format('YYYY-MM-DD'),
|
|
|
- key: idx,
|
|
|
+ key: item.id,
|
|
|
};
|
|
|
}) || [];
|
|
|
setTableData(result);
|
|
@@ -121,7 +138,13 @@ function FileManagement(props) {
|
|
|
);
|
|
|
|
|
|
const { loading: contractLoading, run: runContract } = useRequest(
|
|
|
- (data) => queryGetContractList({ ...data, status: 3 }),
|
|
|
+ (data) =>
|
|
|
+ queryGetContractList({
|
|
|
+ status: 3,
|
|
|
+ name: data.file_name,
|
|
|
+ check_start: data.start_time,
|
|
|
+ check_end: data.end_time,
|
|
|
+ }),
|
|
|
{
|
|
|
manual: true,
|
|
|
onSuccess: (data) => {
|
|
@@ -130,8 +153,9 @@ function FileManagement(props) {
|
|
|
return {
|
|
|
...item,
|
|
|
dir_name: item.name,
|
|
|
- create_time: item.created_on,
|
|
|
- key: idx,
|
|
|
+ user_name: item.created_name,
|
|
|
+ create_time: item.check_on,
|
|
|
+ key: item.id,
|
|
|
};
|
|
|
}) || [];
|
|
|
setTableData(result);
|
|
@@ -154,16 +178,23 @@ function FileManagement(props) {
|
|
|
},
|
|
|
},
|
|
|
);
|
|
|
- //申请权限
|
|
|
+ //文件授权
|
|
|
const { loading: perLoading, run: runPer } = useRequest(
|
|
|
(data) => querySetPermit(data),
|
|
|
{
|
|
|
manual: true,
|
|
|
onSuccess: (data) => {
|
|
|
- message.success('申请成功');
|
|
|
+ setAddOpen(false);
|
|
|
+ const params = {
|
|
|
+ file_type: node.dir_type,
|
|
|
+ file_ids: selectedRowKeys[0].toString(),
|
|
|
+ permit_type: 1,
|
|
|
+ };
|
|
|
+ runPreUserList(params);
|
|
|
+ message.success('授权成功');
|
|
|
},
|
|
|
onError: () => {
|
|
|
- message.error('申请失败');
|
|
|
+ message.error('授权失败');
|
|
|
},
|
|
|
},
|
|
|
);
|
|
@@ -196,7 +227,7 @@ function FileManagement(props) {
|
|
|
},
|
|
|
);
|
|
|
|
|
|
- //文档权限列表
|
|
|
+ //当前用户文档权限列表
|
|
|
const {
|
|
|
data: preListData,
|
|
|
loading: preListLoading,
|
|
@@ -205,6 +236,37 @@ function FileManagement(props) {
|
|
|
manual: true,
|
|
|
});
|
|
|
|
|
|
+ //当前文件的所有用户的权限列表
|
|
|
+ const {
|
|
|
+ // data: preUserListData,
|
|
|
+ loading: preUserListLoading,
|
|
|
+ run: runPreUserList,
|
|
|
+ } = useRequest((data) => queryPermitList(data), {
|
|
|
+ manual: true,
|
|
|
+ onSuccess: (data) => {
|
|
|
+ if (!data.list) return [];
|
|
|
+ const Ids = data.list?.map((item) => item.user_id);
|
|
|
+ const result = [...new Set(Ids)].map((id) => {
|
|
|
+ const userPres = data.list
|
|
|
+ .filter((item) => item.user_id == id)
|
|
|
+ .map((item) => item.permit);
|
|
|
+ const user_name = userList?.find((item) => item.ID == id)?.CName;
|
|
|
+ const downPermit =
|
|
|
+ userPres.findIndex((pre) => pre == 1) > -1 ? true : false;
|
|
|
+ const delPermit =
|
|
|
+ userPres.findIndex((pre) => pre == 2) > -1 ? true : false;
|
|
|
+ return {
|
|
|
+ user_id: id,
|
|
|
+ user_name,
|
|
|
+ delPermit,
|
|
|
+ downPermit,
|
|
|
+ disabled: id == 7 ? true : false,
|
|
|
+ };
|
|
|
+ });
|
|
|
+ setPreUserListData(result?.sort((a, b) => a.user_id - b.user_id));
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
//删除文件
|
|
|
const { loading: delFileLoading, run: runDelFile } = useRequest(
|
|
|
(data) => queryFileDelete(data),
|
|
@@ -236,6 +298,25 @@ function FileManagement(props) {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
+ const delPreConfirm = (record) => {
|
|
|
+ const data = {
|
|
|
+ user_id: record.user_id,
|
|
|
+ file_type: node?.dir_type,
|
|
|
+ permit: '1,2',
|
|
|
+ file_id: selectedRowKeys[0],
|
|
|
+ action_type: 1, // 1 删除权限
|
|
|
+ };
|
|
|
+ // runPer(data);
|
|
|
+ modal.confirm({
|
|
|
+ title: '删除',
|
|
|
+ icon: <ExclamationCircleOutlined />,
|
|
|
+ content: `是否取消对${record.user_name}的授权?`,
|
|
|
+ okText: '确认',
|
|
|
+ cancelText: '取消',
|
|
|
+ onOk: () => runPer(data),
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
const isShow = (id, num) => {
|
|
|
//num 下载 1 删除 2
|
|
|
let bool = false;
|
|
@@ -271,6 +352,73 @@ function FileManagement(props) {
|
|
|
},
|
|
|
];
|
|
|
|
|
|
+ const columnsPer = [
|
|
|
+ { title: '用户', dataIndex: 'user_name' },
|
|
|
+ {
|
|
|
+ title: '查看列表',
|
|
|
+ render: () => <Checkbox checked={true} disabled />,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '只读',
|
|
|
+ render: () => <Checkbox checked={true} disabled />,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '下载',
|
|
|
+ // dataIndex: 'downPermit',
|
|
|
+ render: (record) => (
|
|
|
+ <Checkbox
|
|
|
+ checked={record.downPermit}
|
|
|
+ onChange={(e) => handlePreChange(record, e.target.checked, '1')}
|
|
|
+ disabled={record.disabled}
|
|
|
+ />
|
|
|
+ ),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '删除',
|
|
|
+ // dataIndex: 'delPermit',
|
|
|
+ render: (record) => (
|
|
|
+ <Checkbox
|
|
|
+ checked={record.delPermit}
|
|
|
+ onChange={(e) => handlePreChange(record, e.target.checked, '2')}
|
|
|
+ disabled={record.disabled}
|
|
|
+ />
|
|
|
+ ),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '授权',
|
|
|
+ dataIndex: 'permission',
|
|
|
+ render: (value, _) => <Checkbox checked={value} disabled={!editPer} />,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '操作',
|
|
|
+ render: (record) => <a onClick={() => delPreConfirm(record)}>删除</a>,
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ const handlePreChange = (record, checked, permit) => {
|
|
|
+ //checked 为true false->true 设置权限 反之删除权限
|
|
|
+ const data = {
|
|
|
+ user_id: record.user_id,
|
|
|
+ file_type: node?.dir_type,
|
|
|
+ permit,
|
|
|
+ file_id: selectedRowKeys[0],
|
|
|
+ action_type: checked ? 0 : 1, // 0 设置权限 1 删除权限
|
|
|
+ };
|
|
|
+ runPer(data);
|
|
|
+ };
|
|
|
+
|
|
|
+ const handlerEditClick = (record) => {
|
|
|
+ const newData = [...preUserListData];
|
|
|
+ const curIdx = preUserListData.findIndex(
|
|
|
+ (item) => item.user_id == record.user_id,
|
|
|
+ );
|
|
|
+ newData[curIdx] = { ...newData[curIdx], disabled: false };
|
|
|
+ setPreUserListData(newData);
|
|
|
+ };
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ userListRun();
|
|
|
+ }, []);
|
|
|
+
|
|
|
useEffect(() => {
|
|
|
//获取列表的权限
|
|
|
if (!tableData || tableData.length <= 0) return;
|
|
@@ -278,10 +426,22 @@ function FileManagement(props) {
|
|
|
const data = {
|
|
|
file_type: node.dir_type,
|
|
|
file_ids: ids?.join(','),
|
|
|
+ permit_type: 0,
|
|
|
};
|
|
|
runPreList(data);
|
|
|
}, [tableData]);
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
+ if (selectedRowKeys.length > 0) {
|
|
|
+ const data = {
|
|
|
+ file_type: node.dir_type,
|
|
|
+ file_ids: selectedRowKeys[0].toString(),
|
|
|
+ permit_type: 1,
|
|
|
+ };
|
|
|
+ runPreUserList(data);
|
|
|
+ }
|
|
|
+ }, [selectedRowKeys]);
|
|
|
+
|
|
|
// 搜索文件夹树
|
|
|
const onSearchDirectory = (value, nodes = treeData) => {
|
|
|
const expandedKeys = getExpandedKeys(nodes, value);
|
|
@@ -320,9 +480,17 @@ function FileManagement(props) {
|
|
|
form
|
|
|
.validateFields()
|
|
|
.then((values) => {
|
|
|
- console.log(values);
|
|
|
+ const start_time = values?.date
|
|
|
+ ? dayjs(values?.date[0]).format('YYYY-MM-DD 00:00:00')
|
|
|
+ : null;
|
|
|
+ const end_time = values?.date
|
|
|
+ ? dayjs(values?.date[1]).format('YYYY-MM-DD 23:59:59')
|
|
|
+ : null;
|
|
|
+ const req = { start_time, end_time, file_name: values.file_name };
|
|
|
+ updateTableFile(node, req);
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
+ console.log(err);
|
|
|
return;
|
|
|
});
|
|
|
};
|
|
@@ -347,24 +515,26 @@ function FileManagement(props) {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
- const updateTableFile = (node) => {
|
|
|
+ const updateTableFile = (node, req = {}) => {
|
|
|
if (node.id == 1) {
|
|
|
- //点击受控文件直接把文件夹下的文件夹列表显示出来
|
|
|
- setTableData(findListById(1));
|
|
|
+ //点击受控文件直接把文件夹下的文件夹列表显示出来 或者直接展示空表格因为一些选中授权操作不能做
|
|
|
+ // setTableData(findListById(1));
|
|
|
+ setTableData([]);
|
|
|
setSelectedRowKeys([]);
|
|
|
} else if (node.id == 3) {
|
|
|
- //点击合同文件直接把文件夹下的文件夹列表显示出来
|
|
|
- setTableData(findListById(3));
|
|
|
+ //点击合同文件直接把文件夹下的文件夹列表显示出来 或者直接展示空表格因为一些选中授权操作不能做
|
|
|
+ // setTableData(findListById(3));
|
|
|
+ setTableData([]);
|
|
|
setSelectedRowKeys([]);
|
|
|
} else if (node.id == 7) {
|
|
|
//合同归档走合同接口
|
|
|
- runContract({});
|
|
|
+ runContract(req);
|
|
|
} else if (node.is_limit) {
|
|
|
//其他受控文件走classify_id
|
|
|
- runOA({ classify_id: node.classify_id });
|
|
|
+ runOA({ ...req, classify_id: node.classify_id });
|
|
|
} else {
|
|
|
//部门文件
|
|
|
- run({ dir_id: node.id });
|
|
|
+ run({ ...req, dir_id: node.id });
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -468,7 +638,7 @@ function FileManagement(props) {
|
|
|
<Form.Item name="date">
|
|
|
<RangePicker />
|
|
|
</Form.Item>
|
|
|
- <Form.Item name="name">
|
|
|
+ <Form.Item name="file_name">
|
|
|
<Input />
|
|
|
</Form.Item>
|
|
|
<Form.Item>
|
|
@@ -476,15 +646,17 @@ function FileManagement(props) {
|
|
|
查询
|
|
|
</Button>
|
|
|
</Form.Item>
|
|
|
- <Form.Item>
|
|
|
- <Button
|
|
|
- type="primary"
|
|
|
- onClick={() => document.getElementById('files')?.click()}
|
|
|
- disabled={node ? false : true}
|
|
|
- >
|
|
|
- 上传
|
|
|
- </Button>
|
|
|
- </Form.Item>
|
|
|
+ {node?.dir_type == 0 && (
|
|
|
+ <Form.Item>
|
|
|
+ <Button
|
|
|
+ type="primary"
|
|
|
+ onClick={() => document.getElementById('files')?.click()}
|
|
|
+ disabled={node ? false : true}
|
|
|
+ >
|
|
|
+ 上传
|
|
|
+ </Button>
|
|
|
+ </Form.Item>
|
|
|
+ )}
|
|
|
<Form.Item>
|
|
|
<Button
|
|
|
type="primary"
|
|
@@ -494,6 +666,18 @@ function FileManagement(props) {
|
|
|
申请权限
|
|
|
</Button>
|
|
|
</Form.Item>
|
|
|
+ {isSuper && (
|
|
|
+ <Form.Item>
|
|
|
+ <Button
|
|
|
+ type="primary"
|
|
|
+ onClick={() => setAddOpen(true)}
|
|
|
+ disabled={selectedRowKeys?.length > 0 ? false : true}
|
|
|
+ >
|
|
|
+ <PlusOutlined />
|
|
|
+ 新增权限
|
|
|
+ </Button>
|
|
|
+ </Form.Item>
|
|
|
+ )}
|
|
|
</Form>
|
|
|
<div>
|
|
|
<Table
|
|
@@ -513,35 +697,30 @@ function FileManagement(props) {
|
|
|
childrenColumnName="none"
|
|
|
pagination={false}
|
|
|
/>
|
|
|
- {/*
|
|
|
- <Button type="primary" onClick={() => setAddOpen(true)}>
|
|
|
- <PlusOutlined />
|
|
|
- 新增权限
|
|
|
- </Button>
|
|
|
- {!editPer && (
|
|
|
- <Button
|
|
|
- type="primary"
|
|
|
- onClick={() => setEditPer(true)}
|
|
|
- style={{ marginLeft: 20 }}
|
|
|
- >
|
|
|
- 编辑权限
|
|
|
- </Button>
|
|
|
+ {isSuper && selectedRowKeys?.length > 0 && (
|
|
|
+ <>
|
|
|
+ <div
|
|
|
+ style={{
|
|
|
+ marginTop: '30px',
|
|
|
+ fontWeight: 'bold',
|
|
|
+ fontSize: '20px',
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 《
|
|
|
+ {
|
|
|
+ tableData?.find((item) => item.key == selectedRowKeys[0])
|
|
|
+ ?.dir_name
|
|
|
+ }
|
|
|
+ 》权限列表
|
|
|
+ </div>
|
|
|
+ <Table
|
|
|
+ loading={preUserListLoading}
|
|
|
+ columns={columnsPer}
|
|
|
+ dataSource={preUserListData}
|
|
|
+ style={{ overflowY: 'auto' }}
|
|
|
+ />
|
|
|
+ </>
|
|
|
)}
|
|
|
- {editPer && (
|
|
|
- <Button
|
|
|
- type="primary"
|
|
|
- onClick={() => setEditPer(false)}
|
|
|
- style={{ marginLeft: 20 }}
|
|
|
- >
|
|
|
- 确定
|
|
|
- </Button>
|
|
|
- )}
|
|
|
- <Table
|
|
|
- columns={columnsPer}
|
|
|
- dataSource={tempPer}
|
|
|
- style={{ overflowY: 'auto' }}
|
|
|
- />
|
|
|
- */}
|
|
|
</div>
|
|
|
</ProCard>
|
|
|
<Input
|
|
@@ -553,9 +732,15 @@ function FileManagement(props) {
|
|
|
/>
|
|
|
{contextHolder}
|
|
|
</div>
|
|
|
- {/* <PerModal /> */}
|
|
|
- <AddModal />
|
|
|
-
|
|
|
+ <AddModal
|
|
|
+ node={node}
|
|
|
+ userList={userList}
|
|
|
+ havePreList={[]}
|
|
|
+ fileNode={tableData?.find((item) => item.key == selectedRowKeys[0])}
|
|
|
+ addOpen={addOpen}
|
|
|
+ onCancel={() => setAddOpen(false)}
|
|
|
+ onOk={(data) => runPer(data)}
|
|
|
+ />
|
|
|
<AddFileModal
|
|
|
id={node?.id}
|
|
|
visible={visible}
|
|
@@ -584,51 +769,6 @@ function FileManagement(props) {
|
|
|
/>
|
|
|
</PageContainer>
|
|
|
);
|
|
|
- function AddModal(props) {
|
|
|
- const perList = [
|
|
|
- { label: '查看列表', value: 'a', disabled: true },
|
|
|
- { label: '只读', value: 'b', disabled: true },
|
|
|
- { label: '下载', value: 'c' },
|
|
|
- { label: '删除', value: 'd' },
|
|
|
- { label: '授权', value: 'e' },
|
|
|
- ];
|
|
|
-
|
|
|
- const rowSelection = {
|
|
|
- onChange: (selectedRowKeys, selectedRows) => {
|
|
|
- console.log(
|
|
|
- `selectedRowKeys: ${selectedRowKeys}`,
|
|
|
- 'selectedRows: ',
|
|
|
- selectedRows,
|
|
|
- );
|
|
|
- },
|
|
|
- };
|
|
|
-
|
|
|
- return (
|
|
|
- <Modal
|
|
|
- title="新增权限"
|
|
|
- open={addOpen}
|
|
|
- onCancel={() => setAddOpen(false)}
|
|
|
- width={800}
|
|
|
- >
|
|
|
- <Table
|
|
|
- title={() => '文档列表'}
|
|
|
- columns={columns.slice(0, -1)}
|
|
|
- dataSource={tempData}
|
|
|
- pagination={false}
|
|
|
- rowSelection={rowSelection}
|
|
|
- destroyOnClose
|
|
|
- />
|
|
|
- <div style={{ margin: '20px 0px' }}>
|
|
|
- <span style={{ marginRight: 20 }}>选择用户:</span>
|
|
|
- <TreeSelect multiple={true} style={{ width: 200 }}></TreeSelect>
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- <span style={{ marginRight: 20 }}>选择权限:</span>
|
|
|
- <Checkbox.Group options={perList} defaultValue={['a', 'b']} />
|
|
|
- </div>
|
|
|
- </Modal>
|
|
|
- );
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
export default FileManagement;
|