index.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import { Badge, Modal } from 'antd';
  2. import { observer } from '@formily/react';
  3. import { service, state } from '..';
  4. import ProTable, { ActionType, ProColumns } from '@jetlinks/pro-table';
  5. import SearchComponent from '@/components/SearchComponent';
  6. import { useLocation } from 'umi';
  7. import { InfoCircleOutlined } from '@ant-design/icons';
  8. import { useRef, useState } from 'react';
  9. const Log = observer(() => {
  10. const location = useLocation<{ id: string }>();
  11. const id = (location as any).query?.id;
  12. const columns: ProColumns<LogItem>[] = [
  13. {
  14. dataIndex: 'id',
  15. title: 'ID',
  16. ellipsis: true,
  17. },
  18. {
  19. dataIndex: 'notifyTime',
  20. title: '发送时间',
  21. },
  22. {
  23. dataIndex: 'state',
  24. title: '状态',
  25. renderText: (text: { value: string; text: string }, record) => {
  26. return (
  27. <>
  28. <Badge status={text.value === 'success' ? 'success' : 'error'} text={text.text} />
  29. {text.value !== 'success' && (
  30. <a
  31. style={{ marginLeft: 5 }}
  32. key="info"
  33. onClick={() => {
  34. Modal.info({
  35. title: '错误信息',
  36. width: '30vw',
  37. content: (
  38. <div style={{ height: '300px', overflowY: 'auto' }}>{record.errorStack}</div>
  39. ),
  40. onOk() {},
  41. });
  42. }}
  43. >
  44. <InfoCircleOutlined />
  45. </a>
  46. )}
  47. </>
  48. );
  49. },
  50. },
  51. {
  52. dataIndex: 'action',
  53. title: '操作',
  54. render: (text, record) => [
  55. <a
  56. onClick={() => {
  57. Modal.info({
  58. title: '详情信息',
  59. width: '30vw',
  60. content: (
  61. <div style={{ height: '300px', overflowY: 'auto' }}>
  62. {JSON.stringify(record.context)}
  63. </div>
  64. ),
  65. onOk() {},
  66. });
  67. }}
  68. >
  69. <InfoCircleOutlined />
  70. </a>,
  71. ],
  72. },
  73. ];
  74. const actionRef = useRef<ActionType>();
  75. const [param, setParam] = useState<any>();
  76. return (
  77. <Modal
  78. footer={null}
  79. onCancel={() => (state.log = false)}
  80. title="通知记录"
  81. width={'70vw'}
  82. visible={state.log && !!state.current?.id}
  83. >
  84. <SearchComponent
  85. defaultParam={[{ column: 'notifyType$IN', value: id }]}
  86. field={columns}
  87. onSearch={(data) => {
  88. actionRef.current?.reset?.();
  89. setParam(data);
  90. }}
  91. enableSave={false}
  92. />
  93. <ProTable<LogItem>
  94. params={param}
  95. search={false}
  96. pagination={{
  97. pageSize: 5,
  98. }}
  99. columns={columns}
  100. request={async (params) => service.getHistoryLog(state.current?.id || '', params)}
  101. />
  102. </Modal>
  103. );
  104. });
  105. export default Log;