index.tsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. width: 200,
  17. },
  18. {
  19. dataIndex: 'notifyTime',
  20. title: '发送时间',
  21. valueType: 'dateTime',
  22. },
  23. {
  24. dataIndex: 'state',
  25. title: '状态',
  26. renderText: (text: { value: string; text: string }, record) => {
  27. return (
  28. <>
  29. <Badge status={text.value === 'success' ? 'success' : 'error'} text={text.text} />
  30. {text.value !== 'success' && (
  31. <a
  32. style={{ marginLeft: 5 }}
  33. key="info"
  34. onClick={() => {
  35. Modal.info({
  36. title: '错误信息',
  37. width: '30vw',
  38. content: (
  39. <div style={{ height: '300px', overflowY: 'auto' }}>{record.errorStack}</div>
  40. ),
  41. onOk() {},
  42. });
  43. }}
  44. >
  45. <InfoCircleOutlined />
  46. </a>
  47. )}
  48. </>
  49. );
  50. },
  51. },
  52. {
  53. dataIndex: 'action',
  54. title: '操作',
  55. render: (text, record) => [
  56. <a
  57. key="info"
  58. onClick={() => {
  59. Modal.info({
  60. title: '详情信息',
  61. width: '30vw',
  62. content: (
  63. <div style={{ height: '300px', overflowY: 'auto' }}>
  64. {JSON.stringify(record.context)}
  65. </div>
  66. ),
  67. onOk() {},
  68. });
  69. }}
  70. >
  71. <InfoCircleOutlined />
  72. </a>,
  73. ],
  74. },
  75. ];
  76. const [param, setParam] = useState<any>();
  77. const actionRef = useRef<ActionType>();
  78. return (
  79. <Modal
  80. forceRender
  81. footer={null}
  82. destroyOnClose
  83. onCancel={() => (state.log = false)}
  84. title="通知记录"
  85. width={'50vw'}
  86. visible={state.log && !!state.current?.id}
  87. >
  88. <SearchComponent
  89. defaultParam={[{ column: 'notifyType$IN', value: id }]}
  90. field={columns}
  91. model="simple"
  92. onSearch={(data) => {
  93. actionRef.current?.reset?.();
  94. setParam(data);
  95. }}
  96. enableSave={false}
  97. />
  98. <ProTable<LogItem>
  99. search={false}
  100. pagination={{
  101. pageSize: 5,
  102. }}
  103. params={param}
  104. columns={columns}
  105. request={async (params) => service.getHistoryLog(state.current?.id || '', params)}
  106. />
  107. </Modal>
  108. );
  109. });
  110. export default Log;