Browse Source

oa文件列表接口

XuZinan 2 years ago
parent
commit
67d885e0ea
2 changed files with 49 additions and 28 deletions
  1. 43 27
      src/pages/FileManagement/index.js
  2. 6 1
      src/services/file.js

+ 43 - 27
src/pages/FileManagement/index.js

@@ -1,4 +1,4 @@
-import React, { useReducer, useState } from 'react';
+import React, { useState } from 'react';
 import {
 import {
   Input,
   Input,
   Tree,
   Tree,
@@ -14,41 +14,28 @@ import {
   Space,
   Space,
   message,
   message,
 } from 'antd';
 } from 'antd';
+import dayjs from 'dayjs';
 import { PageContainer, ProCard } from '@ant-design/pro-components';
 import { PageContainer, ProCard } from '@ant-design/pro-components';
-import { useRequest, useModel, useRef } from '@umijs/max';
+import { useRequest, useModel } from '@umijs/max';
 import {
 import {
   queryDirCreate,
   queryDirCreate,
   queryDirList,
   queryDirList,
   queryFileList,
   queryFileList,
+  queryOAFile,
 } from '../../services/file';
 } from '../../services/file';
-import {
-  FolderOpenOutlined,
-  PlusCircleOutlined,
-  PlusOutlined,
-} from '@ant-design/icons';
+import { PlusOutlined } from '@ant-design/icons';
 import AddFileModal from './components/model';
 import AddFileModal from './components/model';
 
 
 const temp = [
 const temp = [
   {
   {
     id: 999,
     id: 999,
     dir_name: '受控文件',
     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,
     id: 998,
     dir_name: '部门文件',
     dir_name: '部门文件',
-    children: [
-      // { id: '2-1', dir_name: '文件夹1' },
-      // { id: '2-2', dir_name: '文件夹2' },
-      // { id: '2-3', dir_name: '文件夹3' },
-    ],
+    children: [],
   },
   },
 ];
 ];
 
 
@@ -73,6 +60,8 @@ function FileManagement(props) {
   const [visible, setVisible] = useState(false);
   const [visible, setVisible] = useState(false);
   const [id, setId] = useState();
   const [id, setId] = useState();
 
 
+  const [isOA, setOA] = useState(false);
+
   const {} = useRequest((data) => queryDirList(data), {
   const {} = useRequest((data) => queryDirList(data), {
     onSuccess: (data) => {
     onSuccess: (data) => {
       console.log(data);
       console.log(data);
@@ -83,10 +72,17 @@ function FileManagement(props) {
       console.log(result);
       console.log(result);
     },
     },
   });
   });
+
   const { data, loading, run } = useRequest((data) => queryFileList(data), {
   const { data, loading, run } = useRequest((data) => queryFileList(data), {
     manual: true,
     manual: true,
   });
   });
 
 
+  const {
+    data: OAdata,
+    loading: OAloading,
+    run: runOA,
+  } = useRequest((data) => queryOAFile(data), { manual: true });
+
   const { loading: createLoading, run: RunCreate } = useRequest(
   const { loading: createLoading, run: RunCreate } = useRequest(
     (data) => queryDirCreate(data),
     (data) => queryDirCreate(data),
     {
     {
@@ -117,12 +113,25 @@ function FileManagement(props) {
           <a>下载</a>
           <a>下载</a>
           <Divider type="vertical" />
           <Divider type="vertical" />
           <a>删除</a>
           <a>删除</a>
-          <a onClick={() => {}}>申请权限</a>
         </>
         </>
       ),
       ),
     },
     },
   ];
   ];
 
 
+  const OAcolumns = [
+    { title: '文档名称', dataIndex: 'name' },
+    { title: '上传人员', dataIndex: ['CreatorUser', 'CName'] },
+    {
+      title: '上传时间',
+      dataIndex: 'c_time',
+      render: (text) => dayjs(text).format('YYYY-MM-DD HH:mm:ss'),
+    },
+    {
+      title: '操作',
+      render: (_, record) => <a>下载</a>,
+    },
+  ];
+
   const columnsPer = [
   const columnsPer = [
     { title: '用户', dataIndex: 'name' },
     { title: '用户', dataIndex: 'name' },
     {
     {
@@ -197,8 +206,15 @@ 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) {
+      setOA(true);
+      runOA({ classify_id: node.classify_id });
+    } else {
+      setOA(false);
+      run({ dir_id: SelectKeys[0] });
+    }
   };
   };
 
 
   return (
   return (
@@ -210,7 +226,7 @@ function FileManagement(props) {
             expandedKeys={expandedKeys}
             expandedKeys={expandedKeys}
             onExpand={onExpand}
             onExpand={onExpand}
             treeData={treeData}
             treeData={treeData}
-            onSelect={handlerSelect}
+            onSelect={handleSelect}
             fieldNames={{ key: 'id', title: 'dir_name', children: 'children' }}
             fieldNames={{ key: 'id', title: 'dir_name', children: 'children' }}
             filterTreeNode={filterTreeNode}
             filterTreeNode={filterTreeNode}
             titleRender={(item) => {
             titleRender={(item) => {
@@ -256,9 +272,9 @@ function FileManagement(props) {
           </Form>
           </Form>
           <div>
           <div>
             <Table
             <Table
-              columns={columns}
-              dataSource={data?.list}
-              loading={loading}
+              columns={isOA ? OAcolumns : columns}
+              dataSource={isOA ? OAdata?.list : data?.list}
+              loading={isOA ? OAloading : loading}
               style={{ overflowY: 'auto' }}
               style={{ overflowY: 'auto' }}
               pagination={false}
               pagination={false}
             />
             />

+ 6 - 1
src/services/file.js

@@ -12,9 +12,14 @@ export const queryFileList = async (data) => {
     data,
     data,
   });
   });
 };
 };
+// 获取OA文件列表(合同文件&投标文件)
+// params: page_size, current_page, classify_id = 42/43
+export const queryOAFile = async (data) => {
+  return await request(`/api/v1/oa/file/list`, { params: data });
+};
 export const queryDirCreate = async (data) => {
 export const queryDirCreate = async (data) => {
   return await request('/api/archive/v1/dir/create', {
   return await request('/api/archive/v1/dir/create', {
     method: 'POST',
     method: 'POST',
     data,
     data,
   });
   });
-};
+};