| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- import * as React from 'react';
- import { Table, TableColumnsType, TablePaginationConfig, Drawer, Button } from 'antd';
- import { StepForwardOutlined, PlusOutlined } from '@ant-design/icons';
- import dayjs from 'dayjs';
- import { GuideTips } from '@/components/common';
- import store from './store';
- import { Record } from './types';
- import './style.scss';
- 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,
- onChangePagination,
- onClickCreate,
- onClickModify,
- onClickfetchTakaiApplicationDetail,
- infoModalOnClickConfirm,
- infoModalOnClickCancel,
- infoModalOnClickClose,
- init,
- reset
- } = store;
- const {
- listLoading,
- list,
- infoModalId,
- infoModalOpen,
- page
- } = state;
- 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);
- // 监听面包屑创建知识库事件
- const handleKnowledgeLibCreate = (event: CustomEvent) => {
- if (event.detail.platform === 'auditHistory') {
- // onClickCreate();
- setHistoryOpen(true);
- }
- };
-
- window.addEventListener('auditHistory', handleKnowledgeLibCreate as EventListener);
- return () => {
- reset();
- window.removeEventListener('auditHistory', handleKnowledgeLibCreate as EventListener);
- };
- }, []);
- const columns: TableColumnsType<Record> = [
- {
- title: '序号',
- dataIndex: 'index',
- width: 80,
- render: (text, record, index) => {
- return index + 1;
- }
- },
- {
- title: '知识名称',
- dataIndex: 'name',
- 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'||text === '5'){
- 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={() => {
- // onClickfetchTakaiApplicationDetail(record.appId);
- 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.pageNum,
- pageSize: page.pageSize,
- total: page.total,
- onChange: async (page, pageSize) => {
- await onChangePagination(page, pageSize);
- },
- };
- return (
- <div className="page-container">
- {/* 标题区域 */}
- <div className="list-header">
- <div className='list-header-title'>
- <h1>应用审核</h1>
- <p>审核和管理应用</p>
- </div>
- <div className='list-header-actions'>
- <Button
- type='primary'
- icon={<PlusOutlined />}
- onClick={onClickCreate}
- >
- 创建
- </Button>
- </div>
- </div>
- {/* 表格区域 - 使用单个 content-section */}
- <div className="content-section">
- <Table
- scroll={{ x: 'max-content' }}
- rowKey={(record) => record.createTime}
- loading={listLoading}
- columns={columns}
- dataSource={list}
- pagination={paginationConfig}
- />
- </div>
- </div>
- {
- infoModalOpen &&
- <InfoModal
- id={infoModalId}
- open={infoModalOpen}
- onClickConfirm={infoModalOnClickConfirm}
- onClickCancel={infoModalOnClickCancel}
- onClickClose={infoModalOnClickClose}
- />
- }
- {
- <Drawer
- title={drawerData.name}
- closable={{ 'aria-label': 'Close Button' }}
- onClose={() => { setDrawerFlag(false) }}
- width="80%"
- open={drawerFlag}
- >
- {drawerFlag&&<PreviewModal isComponent={true} AuditAppId={drawerData.appId} />}
- </Drawer>
- }
- <AuditHistory open={historyOpen} onClose={() => setHistoryOpen(false)} />
- );
- };
- export default KnowledgeLibList;
|