index.tsx 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. import { PageContainer } from '@ant-design/pro-layout';
  2. import { useRef } from 'react';
  3. import type { ActionType, ProColumns } from '@jetlinks/pro-table';
  4. import type { SQLRuleItem } from '@/pages/rule-engine/SQLRule/typings';
  5. import { Tooltip } from 'antd';
  6. import {
  7. CaretRightOutlined,
  8. DownloadOutlined,
  9. EditOutlined,
  10. MinusOutlined,
  11. ReloadOutlined,
  12. StopOutlined,
  13. } from '@ant-design/icons';
  14. import BaseCrud from '@/components/BaseCrud';
  15. import { service } from '@/pages/rule-engine/Instance';
  16. import { useIntl } from '@@/plugin-locale/localeExports';
  17. import { onlyMessage } from '@/utils/util';
  18. const SQLRule = () => {
  19. const intl = useIntl();
  20. const actionRef = useRef<ActionType>();
  21. const columns: ProColumns<SQLRuleItem>[] = [
  22. {
  23. dataIndex: 'index',
  24. valueType: 'indexBorder',
  25. width: 48,
  26. },
  27. {
  28. dataIndex: 'name',
  29. title: intl.formatMessage({
  30. id: 'pages.table.name',
  31. defaultMessage: '名称',
  32. }),
  33. },
  34. {
  35. dataIndex: 'createTime',
  36. title: intl.formatMessage({
  37. id: 'pages.ruleEngine.sqlRule.time',
  38. defaultMessage: '创建时间',
  39. }),
  40. },
  41. {
  42. dataIndex: 'state',
  43. title: intl.formatMessage({
  44. id: 'pages.searchTable.titleStatus',
  45. defaultMessage: '状态',
  46. }),
  47. render: (text, record) => record.state.value,
  48. },
  49. {
  50. title: intl.formatMessage({
  51. id: 'pages.data.option',
  52. defaultMessage: '操作',
  53. }),
  54. valueType: 'option',
  55. align: 'center',
  56. width: 200,
  57. render: (text, record) => [
  58. <a onClick={() => console.log(record)}>
  59. <Tooltip
  60. title={intl.formatMessage({
  61. id: 'pages.data.option.edit',
  62. defaultMessage: '编辑',
  63. })}
  64. >
  65. <EditOutlined />
  66. </Tooltip>
  67. </a>,
  68. <a onClick={() => console.log(record)}>
  69. <Tooltip
  70. title={intl.formatMessage({
  71. id: 'pages.ruleEngine.option.start',
  72. defaultMessage: '启动',
  73. })}
  74. >
  75. <CaretRightOutlined />
  76. </Tooltip>
  77. </a>,
  78. <a onClick={() => console.log(record)}>
  79. <Tooltip
  80. title={intl.formatMessage({
  81. id: 'pages.ruleEngine.option.restart',
  82. defaultMessage: '重启',
  83. })}
  84. >
  85. <ReloadOutlined />
  86. </Tooltip>
  87. </a>,
  88. <a onClick={() => console.log(record)}>
  89. <Tooltip
  90. title={intl.formatMessage({
  91. id: 'pages.ruleEngine.option.stop',
  92. defaultMessage: '停止',
  93. })}
  94. >
  95. <StopOutlined />
  96. </Tooltip>
  97. </a>,
  98. <a>
  99. <Tooltip
  100. title={intl.formatMessage({
  101. id: 'pages.data.option.remove',
  102. defaultMessage: '删除',
  103. })}
  104. >
  105. <MinusOutlined />
  106. </Tooltip>
  107. </a>,
  108. <a key="download">
  109. <Tooltip
  110. title={intl.formatMessage({
  111. id: 'pages.data.option.download',
  112. defaultMessage: '下载配置',
  113. })}
  114. >
  115. <DownloadOutlined
  116. onClick={() => {
  117. onlyMessage(
  118. `${intl.formatMessage({
  119. id: 'pages.data.option.download',
  120. defaultMessage: '下载',
  121. })}`,
  122. );
  123. }}
  124. />
  125. </Tooltip>
  126. </a>,
  127. ],
  128. },
  129. ];
  130. const schema = {};
  131. return (
  132. <PageContainer>
  133. <BaseCrud
  134. columns={columns}
  135. service={service}
  136. title={intl.formatMessage({
  137. id: 'pages.ruleEngine.sqlRule',
  138. defaultMessage: '数据转发',
  139. })}
  140. schema={schema}
  141. defaultParams={{ modelType: 'sql_rule' }}
  142. actionRef={actionRef}
  143. />
  144. </PageContainer>
  145. );
  146. };
  147. export default SQLRule;