|
@@ -1,4 +1,4 @@
|
|
|
-import React, { useReducer, useState } from 'react';
|
|
|
+import React, { useState } from 'react';
|
|
|
import {
|
|
|
Input,
|
|
|
Tree,
|
|
@@ -10,45 +10,34 @@ import {
|
|
|
Modal,
|
|
|
Checkbox,
|
|
|
TreeSelect,
|
|
|
- Select,
|
|
|
+ Upload,
|
|
|
Space,
|
|
|
message,
|
|
|
} from 'antd';
|
|
|
+import dayjs from 'dayjs';
|
|
|
import { PageContainer, ProCard } from '@ant-design/pro-components';
|
|
|
-import { useRequest, useModel, useRef } from '@umijs/max';
|
|
|
+import { useRequest, useModel } from '@umijs/max';
|
|
|
import {
|
|
|
queryDirCreate,
|
|
|
queryDirList,
|
|
|
queryFileList,
|
|
|
+ queryOAFile,
|
|
|
} from '../../services/file';
|
|
|
-import {
|
|
|
- FolderOpenOutlined,
|
|
|
- PlusCircleOutlined,
|
|
|
- PlusOutlined,
|
|
|
-} from '@ant-design/icons';
|
|
|
+import { queryGetContractList } from '../../services/contract';
|
|
|
+import { downloadFile, getToken } from '@/utils/utils';
|
|
|
+import { PlusOutlined } from '@ant-design/icons';
|
|
|
import AddFileModal from './components/model';
|
|
|
|
|
|
const temp = [
|
|
|
{
|
|
|
id: 999,
|
|
|
dir_name: '受控文件',
|
|
|
- children: [
|
|
|
- // { id: '1-1', dir_name: '文件夹1' },
|
|
|
- // {
|
|
|
- // id: '1-2',
|
|
|
- // dir_name: '文件夹2',
|
|
|
- // children: [{ id: '1-2-1', dir_name: '文件夹1' }],
|
|
|
- // },
|
|
|
- ],
|
|
|
+ children: [],
|
|
|
},
|
|
|
{
|
|
|
id: 998,
|
|
|
dir_name: '部门文件',
|
|
|
- children: [
|
|
|
- // { id: '2-1', dir_name: '文件夹1' },
|
|
|
- // { id: '2-2', dir_name: '文件夹2' },
|
|
|
- // { id: '2-3', dir_name: '文件夹3' },
|
|
|
- ],
|
|
|
+ children: [],
|
|
|
},
|
|
|
];
|
|
|
|
|
@@ -73,6 +62,8 @@ function FileManagement(props) {
|
|
|
const [visible, setVisible] = useState(false);
|
|
|
const [id, setId] = useState();
|
|
|
|
|
|
+ const [fileType, setType] = useState(null);
|
|
|
+
|
|
|
const {} = useRequest((data) => queryDirList(data), {
|
|
|
onSuccess: (data) => {
|
|
|
console.log(data);
|
|
@@ -83,10 +74,25 @@ function FileManagement(props) {
|
|
|
console.log(result);
|
|
|
},
|
|
|
});
|
|
|
+
|
|
|
const { data, loading, run } = useRequest((data) => queryFileList(data), {
|
|
|
manual: true,
|
|
|
});
|
|
|
|
|
|
+ const {
|
|
|
+ data: OAdata,
|
|
|
+ loading: OAloading,
|
|
|
+ run: runOA,
|
|
|
+ } = useRequest((data) => queryOAFile(data), { manual: true });
|
|
|
+
|
|
|
+ const {
|
|
|
+ data: contractData,
|
|
|
+ loading: contractLoading,
|
|
|
+ run: runContract,
|
|
|
+ } = useRequest((data) => queryGetContractList({ ...data, status: 3 }), {
|
|
|
+ manual: true,
|
|
|
+ });
|
|
|
+
|
|
|
const { loading: createLoading, run: RunCreate } = useRequest(
|
|
|
(data) => queryDirCreate(data),
|
|
|
{
|
|
@@ -109,7 +115,41 @@ function FileManagement(props) {
|
|
|
const columns = [
|
|
|
{ title: '文档名称', dataIndex: 'file_name' },
|
|
|
{ title: '上传人员', dataIndex: 'user_name' },
|
|
|
- { title: '上传时间', dataIndex: 'create_time' },
|
|
|
+ {
|
|
|
+ title: '上传时间',
|
|
|
+ dataIndex: 'create_time',
|
|
|
+ render: (text) => dayjs(text).format('YYYY-MM-DD'),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '操作',
|
|
|
+ render: (_, record) => (
|
|
|
+ <>
|
|
|
+ <a onClick={() => onDownload(record)}>下载</a>
|
|
|
+ <Divider type="vertical" />
|
|
|
+ <a>删除</a>
|
|
|
+ </>
|
|
|
+ ),
|
|
|
+ },
|
|
|
+ ];
|
|
|
+
|
|
|
+ const OAcolumns = [
|
|
|
+ { title: '文档名称', dataIndex: 'name' },
|
|
|
+ { title: '上传人员', dataIndex: ['CreatorUser', 'CName'] },
|
|
|
+ {
|
|
|
+ title: '上传时间',
|
|
|
+ dataIndex: 'c_time',
|
|
|
+ render: (text) => dayjs(text).format('YYYY-MM-DD'),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '操作',
|
|
|
+ render: (_, record) => <a onClick={() => onDownloadOA(record)}>下载</a>,
|
|
|
+ },
|
|
|
+ ];
|
|
|
+
|
|
|
+ const contractColumns = [
|
|
|
+ { title: '文档名称', dataIndex: 'name' },
|
|
|
+ { title: '上传人员', dataIndex: 'created_name' },
|
|
|
+ { title: '上传时间', dataIndex: 'created_on' },
|
|
|
{
|
|
|
title: '操作',
|
|
|
render: (_, record) => (
|
|
@@ -117,7 +157,6 @@ function FileManagement(props) {
|
|
|
<a>下载</a>
|
|
|
<Divider type="vertical" />
|
|
|
<a>删除</a>
|
|
|
- <a onClick={() => {}}>申请权限</a>
|
|
|
</>
|
|
|
),
|
|
|
},
|
|
@@ -197,8 +236,71 @@ function FileManagement(props) {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
- const handlerSelect = (SelectKeys, e) => {
|
|
|
- run({ dir_id: SelectKeys[0] });
|
|
|
+ const handleSelect = (SelectKeys, e) => {
|
|
|
+ const node = e.node;
|
|
|
+ if (node?.classify_id == 42 || node?.classify_id == 43) {
|
|
|
+ setType('OA');
|
|
|
+ runOA({ classify_id: node.classify_id });
|
|
|
+ } else if (node.id == 6) {
|
|
|
+ setType('contract');
|
|
|
+ runContract({});
|
|
|
+ } else {
|
|
|
+ setType(null);
|
|
|
+ run({ dir_id: SelectKeys[0] });
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ const renderFileTable = () => {
|
|
|
+ let tableColumns = [];
|
|
|
+ let tableData = [];
|
|
|
+ let tableLoading = false;
|
|
|
+
|
|
|
+ switch (fileType) {
|
|
|
+ case 'OA':
|
|
|
+ tableColumns = OAcolumns;
|
|
|
+ tableData = OAdata?.list;
|
|
|
+ tableLoading = OAloading;
|
|
|
+ break;
|
|
|
+ case 'contract':
|
|
|
+ tableColumns = contractColumns;
|
|
|
+ tableData = contractData?.list;
|
|
|
+ tableLoading = contractLoading;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ tableColumns = columns;
|
|
|
+ tableData = data?.list;
|
|
|
+ tableLoading = loading;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ return (
|
|
|
+ <Table
|
|
|
+ columns={tableColumns}
|
|
|
+ dataSource={tableData}
|
|
|
+ loading={tableLoading}
|
|
|
+ style={{ overflowY: 'auto' }}
|
|
|
+ pagination={false}
|
|
|
+ />
|
|
|
+ );
|
|
|
+ };
|
|
|
+
|
|
|
+ const onDownload = (record) => {
|
|
|
+ const token = getToken();
|
|
|
+ // downloadFile(
|
|
|
+ // `/api/archive/v1/file/download?file_id=${record.id}&JWT-TOKEN=${token}`,
|
|
|
+ // record.file_name,
|
|
|
+ // false,
|
|
|
+ // );
|
|
|
+ downloadFile(
|
|
|
+ `http://47.96.12.136:8888/api/archive/v1/file/download?file_id=${record.id}&JWT-TOKEN=${token}`,
|
|
|
+ record.file_name,
|
|
|
+ false,
|
|
|
+ );
|
|
|
+ };
|
|
|
+
|
|
|
+ const onDownloadOA = (record) => {
|
|
|
+ const token = getToken();
|
|
|
+ downloadFile(record.url, record.name);
|
|
|
};
|
|
|
|
|
|
return (
|
|
@@ -210,7 +312,7 @@ function FileManagement(props) {
|
|
|
expandedKeys={expandedKeys}
|
|
|
onExpand={onExpand}
|
|
|
treeData={treeData}
|
|
|
- onSelect={handlerSelect}
|
|
|
+ onSelect={handleSelect}
|
|
|
fieldNames={{ key: 'id', title: 'dir_name', children: 'children' }}
|
|
|
filterTreeNode={filterTreeNode}
|
|
|
titleRender={(item) => {
|
|
@@ -255,13 +357,7 @@ function FileManagement(props) {
|
|
|
</Form.Item>
|
|
|
</Form>
|
|
|
<div>
|
|
|
- <Table
|
|
|
- columns={columns}
|
|
|
- dataSource={data?.list}
|
|
|
- loading={loading}
|
|
|
- style={{ overflowY: 'auto' }}
|
|
|
- pagination={false}
|
|
|
- />
|
|
|
+ {renderFileTable()}
|
|
|
{/*
|
|
|
<Button type="primary" onClick={() => setAddOpen(true)}>
|
|
|
<PlusOutlined />
|