index.tsx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. import { PageContainer } from '@ant-design/pro-layout';
  2. import BaseService from '@/utils/BaseService';
  3. import type { ProColumns, ActionType } from '@jetlinks/pro-table';
  4. import { message, Popconfirm, Tooltip } from 'antd';
  5. import moment from 'moment';
  6. import { useRef } from 'react';
  7. import BaseCrud from '@/components/BaseCrud';
  8. import { useIntl } from '@@/plugin-locale/localeExports';
  9. import { EditOutlined, EyeOutlined, MinusOutlined } from '@ant-design/icons';
  10. import { CurdModel } from '@/components/BaseCrud/model';
  11. const service = new BaseService('firmware');
  12. const Firmware = () => {
  13. const actionRef = useRef<ActionType>();
  14. const intl = useIntl();
  15. const columns: ProColumns<FirmwareItem>[] = [
  16. {
  17. title: '固件名称',
  18. dataIndex: 'name',
  19. },
  20. {
  21. title: '固件版本',
  22. dataIndex: 'version',
  23. },
  24. {
  25. title: '所属产品',
  26. dataIndex: 'productName',
  27. },
  28. {
  29. title: '签名方式',
  30. dataIndex: 'signMethod',
  31. },
  32. {
  33. title: '创建时间',
  34. dataIndex: 'createTime',
  35. width: '200px',
  36. align: 'center',
  37. render: (text: any) => moment(text).format('YYYY-MM-DD HH:mm:ss'),
  38. sorter: true,
  39. defaultSortOrder: 'descend',
  40. },
  41. {
  42. title: intl.formatMessage({
  43. id: 'pages.data.option',
  44. defaultMessage: '操作',
  45. }),
  46. valueType: 'option',
  47. align: 'center',
  48. width: 200,
  49. render: (text, record) => [
  50. <a
  51. onClick={() => {
  52. // router.push(`/device/firmware/save/${record.id}`);
  53. }}
  54. >
  55. <Tooltip
  56. title={intl.formatMessage({
  57. id: 'pages.data.option.detail',
  58. defaultMessage: '查看',
  59. })}
  60. key={'detail'}
  61. >
  62. <EyeOutlined />
  63. </Tooltip>
  64. </a>,
  65. <a key="editable" onClick={() => CurdModel.update(record)}>
  66. <Tooltip
  67. title={intl.formatMessage({
  68. id: 'pages.data.option.edit',
  69. defaultMessage: '编辑',
  70. })}
  71. >
  72. <EditOutlined />
  73. </Tooltip>
  74. </a>,
  75. <a>
  76. <Popconfirm
  77. title={intl.formatMessage({
  78. id: 'pages.data.option.remove.tips',
  79. defaultMessage: '确认删除?',
  80. })}
  81. onConfirm={async () => {
  82. await service.remove(record.id);
  83. message.success(
  84. intl.formatMessage({
  85. id: 'pages.data.option.success',
  86. defaultMessage: '操作成功!',
  87. }),
  88. );
  89. actionRef.current?.reload();
  90. }}
  91. >
  92. <Tooltip
  93. title={intl.formatMessage({
  94. id: 'pages.data.option.remove',
  95. defaultMessage: '删除',
  96. })}
  97. >
  98. <MinusOutlined />
  99. </Tooltip>
  100. </Popconfirm>
  101. </a>,
  102. ],
  103. },
  104. ];
  105. const schema = {};
  106. return (
  107. <PageContainer>
  108. <BaseCrud<FirmwareItem>
  109. columns={columns}
  110. service={service}
  111. title={'固件升级'}
  112. schema={schema}
  113. actionRef={actionRef}
  114. />
  115. </PageContainer>
  116. );
  117. };
  118. export default Firmware;