index.tsx 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. import React from 'react';
  2. import { ProColumns, ProTable } from '@ant-design/pro-components';
  3. import { appTaskLogStatusEnum, conversationTypeEnum, timeRangeFieldProps } from '@/constants/enums';
  4. import { listAppTaskLog } from '@/services/api/appTask';
  5. type TableListItem = API.AppTaskLogPo;
  6. /**
  7. * 获取数据
  8. * @param params 参数
  9. * @param sort 排序
  10. */
  11. const getDataSource = async (params: any, sort: any) => {
  12. const res = await listAppTaskLog({
  13. ...params,
  14. startTime: params?.dateTimeRange?.[0],
  15. endTime: params?.dateTimeRange?.[1],
  16. sort,
  17. });
  18. return Promise.resolve({
  19. success: true,
  20. data: res?.data?.list,
  21. total: res?.data?.total,
  22. });
  23. };
  24. /** 应用任务日志组件 */
  25. const AppTaskLogTable: React.FC<{
  26. /** 任务id */
  27. taskId?: string;
  28. }> = ({ taskId }) => {
  29. // 表格列的配置描述
  30. const columns: ProColumns<TableListItem>[] = [
  31. {
  32. title: '执行时间',
  33. dataIndex: 'createTime',
  34. valueType: 'dateTime',
  35. search: false,
  36. sorter: true,
  37. },
  38. {
  39. title: '日志id',
  40. dataIndex: 'id',
  41. copyable: true,
  42. sorter: true,
  43. ellipsis: true,
  44. },
  45. {
  46. title: '应用名称',
  47. dataIndex: 'appName',
  48. copyable: true,
  49. sorter: true,
  50. },
  51. {
  52. title: 'appId',
  53. dataIndex: 'appId',
  54. copyable: true,
  55. sorter: true,
  56. ellipsis: true,
  57. },
  58. {
  59. title: '任务id',
  60. dataIndex: 'taskId',
  61. copyable: true,
  62. sorter: true,
  63. initialValue: taskId,
  64. ellipsis: true,
  65. },
  66. {
  67. title: '任务名称',
  68. dataIndex: 'taskName',
  69. copyable: true,
  70. sorter: true,
  71. },
  72. {
  73. title: '执行结果',
  74. dataIndex: 'status',
  75. valueEnum: appTaskLogStatusEnum.valueEnum,
  76. sorter: true,
  77. },
  78. {
  79. title: '详情',
  80. dataIndex: 'detail',
  81. copyable: true,
  82. search: false,
  83. ellipsis: true,
  84. },
  85. {
  86. title: '机器人编码',
  87. dataIndex: 'robotCode',
  88. copyable: true,
  89. sorter: true,
  90. ellipsis: true,
  91. },
  92. {
  93. title: '机器人名称',
  94. dataIndex: 'robotName',
  95. copyable: true,
  96. sorter: true,
  97. },
  98. {
  99. title: '会话类型',
  100. dataIndex: 'conversationType',
  101. valueEnum: conversationTypeEnum.valueEnum,
  102. sorter: true,
  103. },
  104. {
  105. title: '群id',
  106. dataIndex: 'openConversationId',
  107. copyable: true,
  108. sorter: true,
  109. ellipsis: true,
  110. },
  111. {
  112. title: '接收机器人消息的手机号列表',
  113. dataIndex: 'phones',
  114. copyable: true,
  115. sorter: true,
  116. },
  117. {
  118. title: '接收机器人消息的userId列表',
  119. dataIndex: 'userIds',
  120. copyable: true,
  121. sorter: true,
  122. },
  123. {
  124. title: 'sftpId',
  125. dataIndex: 'sftpId',
  126. copyable: true,
  127. sorter: true,
  128. ellipsis: true,
  129. },
  130. {
  131. title: 'sftp ip',
  132. dataIndex: 'host',
  133. copyable: true,
  134. sorter: true,
  135. },
  136. {
  137. title: 'sftp端口',
  138. dataIndex: 'port',
  139. copyable: true,
  140. sorter: true,
  141. },
  142. {
  143. title: '数据文件夹',
  144. dataIndex: 'dataDir',
  145. copyable: true,
  146. search: false,
  147. },
  148. {
  149. title: '文件名匹配正则表达式',
  150. dataIndex: 'filePattern',
  151. copyable: true,
  152. search: false,
  153. },
  154. {
  155. title: '文件路径',
  156. dataIndex: 'filePath',
  157. copyable: true,
  158. search: false,
  159. },
  160. {
  161. title: '时间范围',
  162. dataIndex: 'dateTimeRange',
  163. valueType: 'dateTimeRange',
  164. hideInTable: true,
  165. fieldProps: timeRangeFieldProps,
  166. },
  167. ];
  168. return (
  169. <ProTable<TableListItem>
  170. headerTitle="应用任务日志列表"
  171. rowKey="id"
  172. columns={columns}
  173. pagination={{
  174. showQuickJumper: true,
  175. defaultPageSize: 10,
  176. }}
  177. search={{
  178. layout: 'vertical',
  179. }}
  180. request={getDataSource}
  181. />
  182. );
  183. };
  184. export default AppTaskLogTable;