|
|
@@ -1,17 +1,27 @@
|
|
|
import { PageContainer } from '@ant-design/pro-layout';
|
|
|
-import BaseService from '@/utils/BaseService';
|
|
|
import type { ProColumns, ActionType } from '@jetlinks/pro-table';
|
|
|
-import { message, Popconfirm, Tooltip } from 'antd';
|
|
|
+import { Button, message, Popconfirm, Tooltip } from 'antd';
|
|
|
import moment from 'moment';
|
|
|
import { useRef } from 'react';
|
|
|
-import BaseCrud from '@/components/BaseCrud';
|
|
|
import { useIntl } from '@@/plugin-locale/localeExports';
|
|
|
-import { EditOutlined, EyeOutlined, MinusOutlined } from '@ant-design/icons';
|
|
|
-import { CurdModel } from '@/components/BaseCrud/model';
|
|
|
+import { EditOutlined, EyeOutlined, MinusOutlined, PlusOutlined } from '@ant-design/icons';
|
|
|
+import { Link } from 'umi';
|
|
|
+import { model } from '@formily/reactive';
|
|
|
+import ProTable from '@jetlinks/pro-table';
|
|
|
+import { observer } from '@formily/react';
|
|
|
+import type { FirmwareItem } from '@/pages/device/Firmware/typings';
|
|
|
+import Service from '@/pages/device/Firmware/service';
|
|
|
+import Save from '@/pages/device/Firmware/Save';
|
|
|
|
|
|
-const service = new BaseService('firmware');
|
|
|
+export const service = new Service('firmware');
|
|
|
|
|
|
-const Firmware = () => {
|
|
|
+export const state = model<{
|
|
|
+ current?: FirmwareItem;
|
|
|
+ visible: boolean;
|
|
|
+}>({
|
|
|
+ visible: false,
|
|
|
+});
|
|
|
+const Firmware = observer(() => {
|
|
|
const actionRef = useRef<ActionType>();
|
|
|
const intl = useIntl();
|
|
|
|
|
|
@@ -71,10 +81,12 @@ const Firmware = () => {
|
|
|
width: 200,
|
|
|
|
|
|
render: (text, record) => [
|
|
|
- <a
|
|
|
+ <Link
|
|
|
onClick={() => {
|
|
|
- // router.push(`/device/firmware/save/${record.id}`);
|
|
|
+ state.current = record;
|
|
|
}}
|
|
|
+ to={`/device/firmware/detail/${record.id}`}
|
|
|
+ key="link"
|
|
|
>
|
|
|
<Tooltip
|
|
|
title={intl.formatMessage({
|
|
|
@@ -85,8 +97,13 @@ const Firmware = () => {
|
|
|
>
|
|
|
<EyeOutlined />
|
|
|
</Tooltip>
|
|
|
- </a>,
|
|
|
- <a key="editable" onClick={() => CurdModel.update(record)}>
|
|
|
+ </Link>,
|
|
|
+ <a
|
|
|
+ key="editable"
|
|
|
+ onClick={() => {
|
|
|
+ state.visible = true;
|
|
|
+ }}
|
|
|
+ >
|
|
|
<Tooltip
|
|
|
title={intl.formatMessage({
|
|
|
id: 'pages.data.option.edit',
|
|
|
@@ -96,7 +113,7 @@ const Firmware = () => {
|
|
|
<EditOutlined />
|
|
|
</Tooltip>
|
|
|
</a>,
|
|
|
- <a>
|
|
|
+ <a key="delete">
|
|
|
<Popconfirm
|
|
|
title={intl.formatMessage({
|
|
|
id: 'pages.data.option.remove.tips',
|
|
|
@@ -127,21 +144,33 @@ const Firmware = () => {
|
|
|
},
|
|
|
];
|
|
|
|
|
|
- const schema = {};
|
|
|
-
|
|
|
return (
|
|
|
<PageContainer>
|
|
|
- <BaseCrud<FirmwareItem>
|
|
|
+ <ProTable<FirmwareItem>
|
|
|
+ toolBarRender={() => [
|
|
|
+ <Button
|
|
|
+ onClick={() => {
|
|
|
+ state.visible = true;
|
|
|
+ }}
|
|
|
+ key="button"
|
|
|
+ icon={<PlusOutlined />}
|
|
|
+ type="primary"
|
|
|
+ >
|
|
|
+ 新增
|
|
|
+ </Button>,
|
|
|
+ ]}
|
|
|
+ request={async (params) => service.query(params)}
|
|
|
columns={columns}
|
|
|
- service={service}
|
|
|
- title={intl.formatMessage({
|
|
|
- id: 'pages.device.firmware',
|
|
|
- defaultMessage: '固件升级',
|
|
|
- })}
|
|
|
- schema={schema}
|
|
|
actionRef={actionRef}
|
|
|
/>
|
|
|
+ <Save
|
|
|
+ data={state.current}
|
|
|
+ visible={state.visible}
|
|
|
+ close={() => {
|
|
|
+ state.visible = false;
|
|
|
+ }}
|
|
|
+ />
|
|
|
</PageContainer>
|
|
|
);
|
|
|
-};
|
|
|
+});
|
|
|
export default Firmware;
|