index.tsx 3.7 KB

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