index.tsx 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. valueType: 'select',
  27. valueEnum: {
  28. success: {
  29. text: '成功',
  30. status: 'success',
  31. },
  32. error: {
  33. text: '失败',
  34. status: 'error',
  35. },
  36. },
  37. renderText: (text: { value: string; text: string }, record) => {
  38. return (
  39. <>
  40. <Badge status={text.value === 'success' ? 'success' : 'error'} text={text.text} />
  41. {text.value !== 'success' && (
  42. <a
  43. style={{ marginLeft: 5 }}
  44. key="info"
  45. onClick={() => {
  46. Modal.info({
  47. title: '错误信息',
  48. width: '30vw',
  49. content: (
  50. <div style={{ height: '300px', overflowY: 'auto' }}>{record.errorStack}</div>
  51. ),
  52. onOk() {},
  53. });
  54. }}
  55. >
  56. <InfoCircleOutlined />
  57. </a>
  58. )}
  59. </>
  60. );
  61. },
  62. },
  63. {
  64. dataIndex: 'action',
  65. title: '操作',
  66. hideInSearch: true,
  67. render: (text, record) => [
  68. <a
  69. key="info"
  70. onClick={() => {
  71. Modal.info({
  72. title: '详情信息',
  73. width: '30vw',
  74. content: (
  75. <div style={{ height: '300px', overflowY: 'auto' }}>
  76. {JSON.stringify(record.context)}
  77. </div>
  78. ),
  79. onOk() {},
  80. });
  81. }}
  82. >
  83. <InfoCircleOutlined />
  84. </a>,
  85. ],
  86. },
  87. ];
  88. const [param, setParam] = useState<any>();
  89. const actionRef = useRef<ActionType>();
  90. return (
  91. <Modal
  92. forceRender
  93. footer={null}
  94. destroyOnClose
  95. onCancel={() => (state.log = false)}
  96. title="通知记录"
  97. width={'65vw'}
  98. visible={state.log && !!state.current?.id}
  99. >
  100. <SearchComponent
  101. defaultParam={[{ column: 'notifyType$IN', value: state.current?.type || '' }]}
  102. field={columns}
  103. model="simple"
  104. onSearch={(data) => {
  105. actionRef.current?.reset?.();
  106. setParam(data);
  107. }}
  108. enableSave={false}
  109. />
  110. <ProTable<LogItem>
  111. search={false}
  112. pagination={
  113. {
  114. // pageSize: 5,
  115. }
  116. }
  117. columnEmptyText={''}
  118. params={param}
  119. columns={columns}
  120. request={async (params) =>
  121. service.getHistoryLog(state.current?.id || '', {
  122. ...params,
  123. sorts: [{ name: 'notifyTime', order: 'desc' }],
  124. })
  125. }
  126. />
  127. </Modal>
  128. );
  129. });
  130. export default Log;