Quellcode durchsuchen

新增审核历史

sunsheng vor 4 Wochen
Ursprung
Commit
94b8009e1a

+ 5 - 0
src/apis/index.ts

@@ -472,6 +472,10 @@ const fetchAuditInfoLibDetailApi: FetchAuditInfoLibDetailApi = async (documentId
 const fetchTakaiAuditConfigLibListApi: FetchTakaiAuditConfigLibListApi = async (data) => {
     return api.post('/deepseek/api/app/audit/list', data);
 };
+// 获取应用审核历史列表
+const fetchTakaiAuditHistoryLibListApi: FetchTakaiAuditConfigLibListApi = async (data) => {
+    return api.post('/deepseek/api/app/auditHistory/list', data);
+};
 
 // 修改takai知识审核
 const modifyTakaiAuditDocumentApi: ModifyTakaiAuditDocumentLibApi = async (id, data) => {
@@ -557,5 +561,6 @@ export const apis = {
     fetchTakaiProjectLibApi: fetchTakaiProjectApi,
     fetchUserListApi: fetchUserListApi,
     deleteTakaidelUnfinishedDocumentLibApi: deleteTakaidelUnfinishedDocumentApi,
+    fetchTakaiAuditHistoryLibListApi:fetchTakaiAuditHistoryLibListApi,
 
 };

+ 193 - 0
src/pages/deepseek/audit/components/auditHistory.tsx

@@ -0,0 +1,193 @@
+import * as React from 'react';
+import { observer } from 'mobx-react';
+import { Table, TableColumnsType, TablePaginationConfig, Drawer } from 'antd';
+import { StepForwardOutlined } from '@ant-design/icons';
+import dayjs from 'dayjs';
+import store from './auditHistoryStore';
+import { Record } from '../types';
+import '../style.less';
+import InfoModal from './InfoModal';
+import PreviewModal from './PreviewModal';
+import LocalStorage from '@/LocalStorage';
+
+
+interface AuditHistoryProps {
+    open: boolean;
+    onClose: () => void;
+}
+
+const AuditHistory: React.FC<AuditHistoryProps> = ({ open, onClose }) => {
+    const {
+        state,
+        init,
+        onChangePagination,
+        onClickModify,
+        infoModalOnClickConfirm,
+        infoModalOnClickCancel,
+        infoModalOnClickClose,
+    } = store;
+    const {
+        listLoading,
+        list,
+        infoModalId,
+        infoModalOpen,
+        page
+    } = state;
+
+    const [drawerFlag, setDrawerFlag] = React.useState<boolean>(false);
+    const [drawerData, setDrawerData] = React.useState<any>({});
+    React.useEffect(() => {
+        if(open){
+            const userInfo = LocalStorage.getUserInfo();
+            const userId = (userInfo?.id ?? '').toString();
+            init(userId);
+        }
+    }, [open]);
+    const columns: TableColumnsType<Record> = [
+        {
+            title: '序号',
+            dataIndex: 'index',
+            width: 80,
+            render: (_text, _record, index) => {
+                return index + 1;
+            }
+        },
+        {
+            title: '知识名称',
+            dataIndex: 'name',
+            width: 300,
+            render: (text, record) => {
+                // const previewUrl = `/preview/${record.url}`; // 根据实际字段构造 URL
+                return (
+                    <a
+                        href={record.url}
+                        target="_blank"
+                        rel="noopener noreferrer"
+                        onClick={(e) => {
+                            e.stopPropagation(); // 防止 Table 默认事件干扰
+                        }}
+                    >
+                        {text}
+                    </a>
+                );
+            }
+        },
+        {
+            title: '状态',
+            dataIndex: 'status',
+            render: (text) => {
+                if (text === '1') {
+                    return '待审核';
+                } else if (text === '2') {
+                    return '审核中';
+                } else if (text === '3') {
+                    return '审核通过';
+                } else if (text === '4') {
+                    return '审核拒绝';
+                }
+            }
+        },
+        {
+            title: '审核人',
+            dataIndex: 'userName',
+            render: (text) => {
+                return `${text}`;
+            }
+        },
+        {
+            title: '审核意见',
+            dataIndex: 'comment',
+            render: (text) => {
+                if (text) {
+                    return `${text}`;
+                } else {
+                    return '--';
+                }
+            }
+        },
+        {
+            title: '创建时间',
+            dataIndex: 'createTime',
+            width: 200,
+            render: (text) => {
+                if (text) {
+                    return dayjs(text).format('YYYY-MM-DD HH:mm:ss');
+                } else {
+                    return '--';
+                }
+            }
+        },
+        // {
+        //     title: '操作',
+        //     dataIndex: 'operation',
+        //     width: 150,
+        //     fixed: 'right',
+        //     render: (_text, record) => {
+        //         return (
+        //             <>
+        //                 <a
+        //                     style={{ marginRight: 16 }}
+        //                     onClick={() => {
+        //                         setDrawerFlag(true)
+        //                         setDrawerData(record)
+        //                     }}
+        //                     title='查看'
+        //                 >
+        //                     查看
+        //                 </a >
+        //                 <a
+        //                     style={{ marginRight: 16 }}
+        //                     onClick={() => {
+        //                         onClickModify(record.appId);
+        //                     }}
+        //                     title='审核'
+        //                 >
+        //                     <StepForwardOutlined />审核
+        //                 </a >
+        //             </>
+        //         )
+        //     }
+        // }
+    ];
+    const paginationConfig: TablePaginationConfig = {
+        // 显示数据总量
+        showTotal: (total: number) => {
+            return `共 ${total} 条`;
+        },
+        // 展示分页条数切换
+        showSizeChanger: true,
+        // 指定每页显示条数
+        pageSizeOptions: ['10', '20', '50', '100'],
+        // 快速跳转至某页
+        showQuickJumper: true,
+        current: page.pageNumber,
+        pageSize: page.pageSize,
+        total: page.total,
+        onChange: async (page, pageSize) => {
+            await onChangePagination(page, pageSize);
+        },
+    };
+
+    return (
+        <Drawer
+            title="审核历史"
+            width="80%"
+            open={open}
+            onClose={onClose}
+        >
+            <div className='knowledgeLibList'>
+                <div className='knowledgeLibList-table'>
+                    <Table
+                        scroll={{ x: 'max-content' }}
+                        rowKey={(record) => record.createTime}
+                        loading={listLoading}
+                        columns={columns}
+                        dataSource={list}
+                        pagination={paginationConfig}
+                    />
+                </div>
+            </div>
+        </Drawer>
+    );
+}
+export default observer(AuditHistory);

+ 193 - 0
src/pages/deepseek/audit/components/auditHistoryStore.ts

@@ -0,0 +1,193 @@
+import { makeAutoObservable } from 'mobx';
+import { message } from 'antd';
+import { apis, ModifyDocumentApiParams } from '@/apis';
+import { State, ReadonlyState, StateAction, DocumentLibListStore } from '../types';
+
+// 定义状态
+const stateGenerator = (): ReadonlyState => ({
+    listLoading: false,
+    list: [],
+    infoModalId: '',
+    infoModalOpen: false,
+    page: {
+        pageNumber: 1,
+        pageSize: 10,
+        total: 0,
+    },
+});
+
+// 修改状态
+const stateActionsGenerator = (state: State): StateAction => {
+    return {
+        setListLoading: (loading) => {
+            state.listLoading = loading;
+        },
+        setList: (list) => {
+            state.list = list;
+        },
+        setInfoModalId: (id) => {
+            state.infoModalId = id;
+        },
+        setInfoModalOpen: (open) => {
+            state.infoModalOpen = open;
+        },
+        setPage: (page) => {
+            state.page = page;
+        },
+    };
+};
+
+// 使用仓库
+const useKnowledgeLibListStore = (): DocumentLibListStore => {
+    const state = makeAutoObservable(stateGenerator());
+    const actions = stateActionsGenerator(state);
+
+    const api = {
+        // 获取审核列表
+        fetchApplicationLibList: async (userId: string) => {
+            actions.setListLoading(true);
+            try {
+                const data = {
+                    pageNumber: state.page.pageNumber,
+                    pageSize: state.page.pageSize,
+                    approver: userId,
+                };
+                const res = await apis.fetchTakaiAuditHistoryLibListApi(data);
+                console.log(res.rows, 'rew.rows');
+                actions.setList(res.rows);
+                actions.setPage({
+                    ...state.page,
+                    total: res.total,
+                });
+            } catch (error: any) {
+                console.error(error);
+            } finally {
+                actions.setListLoading(false);
+            }
+        },
+        
+        // 应用审核
+        modifyDocumentLib: async (documentId: string, userId: string, data: ModifyDocumentApiParams) => {
+            try {
+                const res = await apis.modifyTakaiAuditDocumentLibApi(documentId, data);
+                // 获取审核列表
+                api.fetchApplicationLibList(userId);
+                if(res.data === 1 && res.code === 200){
+                    message.success('修改成功');
+                }else{
+                    message.error('修改失败');
+                }
+            } catch (error: any) {
+                message.error(error.msg);
+            }
+        },
+        // 获取详情
+        fetchTakaiApplicationDetail: async (appId: string) => {
+            try {
+                const res = await apis.fetchTakaiApplicationDetail(appId);
+                console.log(res, 'resresres');
+                return res;
+            } catch (error: any) {
+                message.error(error.msg);
+            }
+        },
+    }
+    // 点击查看出现弹窗
+    const onClickfetchTakaiApplicationDetail = async (appId: string) => {
+        if(appId){
+            await api.fetchTakaiApplicationDetail(appId);
+        }
+    }
+    // 更改分页
+    const onChangePagination: DocumentLibListStore['onChangePagination'] = async (pageNumber, pageSize) => {
+        actions.setPage({
+            ...state.page,
+            pageNumber: pageNumber,
+            pageSize: pageSize,
+        });
+        // 获取知识库列表
+        await api.fetchApplicationLibList('');
+    }
+
+    // 点击创建
+    const onClickCreate: DocumentLibListStore['onClickCreate'] = () => {
+        const initialInfoModalId = stateGenerator().infoModalId;
+
+        actions.setInfoModalId(initialInfoModalId);
+        actions.setInfoModalOpen(true);
+    }
+
+    // 点击修改
+    const onClickModify: DocumentLibListStore['onClickModify'] = (documentId) => {
+        actions.setInfoModalId(documentId);
+        actions.setInfoModalOpen(true);
+    }
+
+    // 信息弹出层-点击通过
+    const infoModalOnClickConfirm: DocumentLibListStore['infoModalOnClickConfirm'] = async (documentId, userId, data) => {
+        const initialInfoModalOpen = stateGenerator().infoModalOpen;
+
+        actions.setInfoModalOpen(initialInfoModalOpen);
+
+        if (documentId) {
+            // 审核通过
+            console.log(data, 'datadata');
+            await api.modifyDocumentLib(documentId, userId, data);
+        } 
+    }
+
+    // 信息弹出层-点击拒绝
+    const infoModalOnClickCancel: DocumentLibListStore['infoModalOnClickCancel'] = async(documentId, userId, data) => {
+        const initialInfoModalOpen = stateGenerator().infoModalOpen;
+
+        actions.setInfoModalOpen(initialInfoModalOpen);
+
+        if (documentId) {
+            // 审核拒绝
+            await api.modifyDocumentLib(documentId, userId, data);
+        } 
+    }
+
+    const infoModalOnClickClose: DocumentLibListStore['infoModalOnClickClose'] = () => {
+        const initialInfoModalOpen = stateGenerator().infoModalOpen;
+        actions.setInfoModalOpen(initialInfoModalOpen);
+
+    }
+
+    
+    // 初始渲染
+    const init: DocumentLibListStore['init'] = async (userId) => {
+        // 获取知识库列表
+        await api.fetchApplicationLibList(userId);
+    }
+
+    // 状态重置
+    const reset: DocumentLibListStore['reset'] = () => {
+        const initialListLoading = stateGenerator().listLoading;
+        const initialList = stateGenerator().list;
+        const initialInfoModalId = stateGenerator().infoModalId;
+        const initialInfoModalOpen = stateGenerator().infoModalOpen;
+        const initialPage = stateGenerator().page;
+
+        actions.setListLoading(initialListLoading);
+        actions.setList(initialList);
+        actions.setInfoModalId(initialInfoModalId);
+        actions.setInfoModalOpen(initialInfoModalOpen);
+        actions.setPage(initialPage);
+    }
+
+    return {
+        state,
+        onChangePagination,
+        onClickCreate,
+        onClickModify,
+        onClickfetchTakaiApplicationDetail,
+        infoModalOnClickConfirm,
+        infoModalOnClickCancel,
+        infoModalOnClickClose,
+        init,
+        reset
+    };
+};
+
+export default useKnowledgeLibListStore();

+ 19 - 2
src/pages/deepseek/audit/index.tsx

@@ -9,6 +9,7 @@ import './style.less';
 import LocalStorage from '@/LocalStorage';
 import InfoModal from './components/InfoModal';
 import PreviewModal from './components/PreviewModal';
+import AuditHistory from './components/auditHistory';
 const KnowledgeLibList: React.FC = () => {
     const {
         state,
@@ -36,12 +37,27 @@ const KnowledgeLibList: React.FC = () => {
     const [listFlag, setListFlag] = React.useState<boolean>();
     const [drawerFlag, setDrawerFlag] = React.useState<boolean>(false);
     const [drawerData, setDrawerData] = React.useState<any>({});
+    const [historyOpen, setHistoryOpen] = React.useState<boolean>(false);
 
     React.useEffect(() => {
         const userInfo = LocalStorage.getUserInfo();
         const userId = (userInfo?.id ?? '').toString();
         init(userId);
-        return () => reset();
+
+        // 监听面包屑创建知识库事件
+        const handleKnowledgeLibCreate = (event: CustomEvent) => {
+            if (event.detail.platform === 'deepseek') {
+                // onClickCreate();
+                setHistoryOpen(true);
+            }
+        };
+        
+        window.addEventListener('auditHistory', handleKnowledgeLibCreate as EventListener);
+        
+        return () => {
+            reset();
+            window.removeEventListener('auditHistory', handleKnowledgeLibCreate as EventListener);
+        };
     }, []);
 
     const columns: TableColumnsType<Record> = [
@@ -202,7 +218,8 @@ const KnowledgeLibList: React.FC = () => {
                 >
                     {drawerFlag&&<PreviewModal isComponent={true} AuditAppId={drawerData.appId} />}
                 </Drawer> 
-            }        
+            }  
+            <AuditHistory open={historyOpen} onClose={() => setHistoryOpen(false)} />     
         </div>
     );
 };

+ 21 - 1
src/pages/layout/components/Breadcrumb.tsx

@@ -1,7 +1,7 @@
 import * as React from 'react';
 import { Link, useLocation } from 'react-router-dom';
 import { Breadcrumb as AntdBreadcrumb, Button, Tooltip } from 'antd';
-import { PlusOutlined, TagOutlined, ReadOutlined } from '@ant-design/icons';
+import { PlusOutlined, TagOutlined, ReadOutlined,LayoutOutlined } from '@ant-design/icons';
 import { State } from '../types';
 import router from '@/router';
 
@@ -48,6 +48,14 @@ const Breadcrumb: React.FC<Props> = (props: Props) => {
         onClick,
         type: 'primary'
     });
+    // 创建主要操作按钮的工厂函数
+    const historyAuditButton = (text: string, onClick: () => void): ButtonConfig => ({
+        text,
+        icon: <LayoutOutlined />,
+        tooltip: '',
+        onClick,
+        type: 'primary'
+    });
 
     // 页面按钮配置
     const pageConfigs: PageButtonConfig[] = [
@@ -75,6 +83,18 @@ const Breadcrumb: React.FC<Props> = (props: Props) => {
                 })
             ]
         },
+        {
+            pattern: '/deepseek/audit',
+            matcher: (path) => path === '/deepseek/audit',
+            buttons: [
+                historyAuditButton('审核历史', () => {
+                    const event = new CustomEvent('auditHistory', {
+                        detail: { platform: location.pathname.startsWith('/deepseek') ? 'deepseek' : 'zhipu' }
+                    });
+                    window.dispatchEvent(event);
+                })
+            ]
+        },
         {
             pattern: /^\/(deepseek|zhipu)\/knowledgeLib\/[^/]+/,
             matcher: (path) => !!path.match(/^\/(deepseek|zhipu)\/knowledgeLib\/[^/]+/) && !path.includes('/slice/'),