index.tsx 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. import * as React from 'react';
  2. import { Table, TableColumnsType, TablePaginationConfig, Drawer, Button } from 'antd';
  3. import { StepForwardOutlined, PlusOutlined } from '@ant-design/icons';
  4. import dayjs from 'dayjs';
  5. import { GuideTips } from '@/components/common';
  6. import store from './store';
  7. import { Record } from './types';
  8. import './style.scss';
  9. import LocalStorage from '@/LocalStorage';
  10. import InfoModal from './components/InfoModal';
  11. import PreviewModal from './components/PreviewModal';
  12. import AuditHistory from './components/auditHistory';
  13. const KnowledgeLibList: React.FC = () => {
  14. const {
  15. state,
  16. onChangePagination,
  17. onClickCreate,
  18. onClickModify,
  19. onClickfetchTakaiApplicationDetail,
  20. infoModalOnClickConfirm,
  21. infoModalOnClickCancel,
  22. infoModalOnClickClose,
  23. init,
  24. reset
  25. } = store;
  26. const {
  27. listLoading,
  28. list,
  29. infoModalId,
  30. infoModalOpen,
  31. page
  32. } = state;
  33. const [drawerFlag, setDrawerFlag] = React.useState<boolean>(false);
  34. const [drawerData, setDrawerData] = React.useState<any>({});
  35. const [historyOpen, setHistoryOpen] = React.useState<boolean>(false);
  36. React.useEffect(() => {
  37. const userInfo = LocalStorage.getUserInfo();
  38. const userId = (userInfo?.id ?? '').toString();
  39. init(userId);
  40. // 监听面包屑创建知识库事件
  41. const handleKnowledgeLibCreate = (event: CustomEvent) => {
  42. if (event.detail.platform === 'auditHistory') {
  43. // onClickCreate();
  44. setHistoryOpen(true);
  45. }
  46. };
  47. window.addEventListener('auditHistory', handleKnowledgeLibCreate as EventListener);
  48. return () => {
  49. reset();
  50. window.removeEventListener('auditHistory', handleKnowledgeLibCreate as EventListener);
  51. };
  52. }, []);
  53. const columns: TableColumnsType<Record> = [
  54. {
  55. title: '序号',
  56. dataIndex: 'index',
  57. width: 80,
  58. render: (text, record, index) => {
  59. return index + 1;
  60. }
  61. },
  62. {
  63. title: '知识名称',
  64. dataIndex: 'name',
  65. render: (text, record) => {
  66. // const previewUrl = `/preview/${record.url}`; // 根据实际字段构造 URL
  67. return (
  68. <a
  69. href={record.url}
  70. target="_blank"
  71. rel="noopener noreferrer"
  72. onClick={(e) => {
  73. e.stopPropagation(); // 防止 Table 默认事件干扰
  74. }}
  75. >
  76. {text}
  77. </a>
  78. );
  79. }
  80. },
  81. {
  82. title: '状态',
  83. dataIndex: 'status',
  84. render: (text) => {
  85. if (text === '1') {
  86. return '待审核';
  87. }else if(text === '2'){
  88. return '审核中';
  89. }else if(text === '3'){
  90. return '审核通过';
  91. }else if(text === '4'||text === '5'){
  92. return '审核拒绝';
  93. }
  94. }
  95. },
  96. {
  97. title: '审核人',
  98. dataIndex: 'userName',
  99. render: (text) => {
  100. return `${text}`;
  101. }
  102. },
  103. {
  104. title: '审核意见',
  105. dataIndex: 'comment',
  106. render: (text) => {
  107. if(text){
  108. return `${text}`;
  109. }else{
  110. return '--';
  111. }
  112. }
  113. },
  114. {
  115. title: '创建时间',
  116. dataIndex: 'createTime',
  117. width: 200,
  118. render: (text) => {
  119. if (text) {
  120. return dayjs(text).format('YYYY-MM-DD HH:mm:ss');
  121. } else {
  122. return '--';
  123. }
  124. }
  125. },
  126. {
  127. title: '操作',
  128. dataIndex: 'operation',
  129. width: 150,
  130. fixed: 'right',
  131. render: (text, record) => {
  132. return (
  133. <>
  134. <a
  135. style={{ marginRight: 16 }}
  136. onClick={() => {
  137. // onClickfetchTakaiApplicationDetail(record.appId);
  138. setDrawerFlag(true)
  139. setDrawerData(record)
  140. }}
  141. title='审核'
  142. >
  143. 查看
  144. </a >
  145. <a
  146. style={{ marginRight: 16 }}
  147. onClick={() => {
  148. onClickModify(record.appId);
  149. }}
  150. title='审核'
  151. >
  152. <StepForwardOutlined />审核
  153. </a >
  154. </>
  155. )
  156. }
  157. }
  158. ];
  159. const paginationConfig: TablePaginationConfig = {
  160. // 显示数据总量
  161. showTotal: (total: number) => {
  162. return `共 ${total} 条`;
  163. },
  164. // 展示分页条数切换
  165. showSizeChanger: true,
  166. // 指定每页显示条数
  167. pageSizeOptions: ['10', '20', '50', '100'],
  168. // 快速跳转至某页
  169. showQuickJumper: true,
  170. current: page.pageNum,
  171. pageSize: page.pageSize,
  172. total: page.total,
  173. onChange: async (page, pageSize) => {
  174. await onChangePagination(page, pageSize);
  175. },
  176. };
  177. return (
  178. <div className="page-container">
  179. {/* 标题区域 */}
  180. <div className="list-header">
  181. <div className='list-header-title'>
  182. <h1>应用审核</h1>
  183. <p>审核和管理应用</p>
  184. </div>
  185. <div className='list-header-actions'>
  186. <Button
  187. type='primary'
  188. icon={<PlusOutlined />}
  189. onClick={onClickCreate}
  190. >
  191. 创建
  192. </Button>
  193. </div>
  194. </div>
  195. {/* 表格区域 - 使用单个 content-section */}
  196. <div className="content-section">
  197. <Table
  198. scroll={{ x: 'max-content' }}
  199. rowKey={(record) => record.createTime}
  200. loading={listLoading}
  201. columns={columns}
  202. dataSource={list}
  203. pagination={paginationConfig}
  204. />
  205. </div>
  206. </div>
  207. {
  208. infoModalOpen &&
  209. <InfoModal
  210. id={infoModalId}
  211. open={infoModalOpen}
  212. onClickConfirm={infoModalOnClickConfirm}
  213. onClickCancel={infoModalOnClickCancel}
  214. onClickClose={infoModalOnClickClose}
  215. />
  216. }
  217. {
  218. <Drawer
  219. title={drawerData.name}
  220. closable={{ 'aria-label': 'Close Button' }}
  221. onClose={() => { setDrawerFlag(false) }}
  222. width="80%"
  223. open={drawerFlag}
  224. >
  225. {drawerFlag&&<PreviewModal isComponent={true} AuditAppId={drawerData.appId} />}
  226. </Drawer>
  227. }
  228. <AuditHistory open={historyOpen} onClose={() => setHistoryOpen(false)} />
  229. );
  230. };
  231. export default KnowledgeLibList;