Browse Source

设备上线

master
nili 8 months ago
parent
commit
e877e4fc7c
  1. 2
      dist/index.html
  2. 1
      dist/p__DeviceOwnerApp.6709cb8d.async.js
  3. 1
      dist/p__DeviceOwnerApp.d8b740d9.async.js
  4. 2
      dist/umi.4523c287.js
  5. 15
      src/pages/DeviceOwnerApp.tsx
  6. 15
      src/services/matrix/device.ts
  7. 4
      src/services/matrix/typings.d.ts

2
dist/index.html

@ -8,6 +8,6 @@
</head>
<body>
<div id="root"></div>
<script src="/umi.23ba36fb.js"></script>
<script src="/umi.4523c287.js"></script>
</body></html>

1
dist/p__DeviceOwnerApp.6709cb8d.async.js

File diff suppressed because one or more lines are too long

1
dist/p__DeviceOwnerApp.d8b740d9.async.js

File diff suppressed because one or more lines are too long

2
dist/umi.23ba36fb.js → dist/umi.4523c287.js

File diff suppressed because one or more lines are too long

15
src/pages/DeviceOwnerApp.tsx

@ -17,7 +17,7 @@ import { useParams } from 'react-router-dom';
import { advList } from '../services/matrix/admin';
// import { RequestOptionsType, ProFieldRequestData } from "@ant-design/pro-utils";
import { deviceList, incomeDaily1, incomeOverview1, offline } from '@/services/matrix/device';
import { deviceList, incomeDaily1, incomeOverview1, offline, online } from '@/services/matrix/device';
import { Column } from '@ant-design/charts';
import type { ActionType } from '@ant-design/pro-components';
import moment from 'moment';
@ -62,6 +62,16 @@ const DeviceOwnerApp: React.FC = () => {
deviceRef.current?.reload();
};
const handleSetOnline = async (deviceId: string | undefined) => {
if (!deviceId) {
return;
}
try {
await online({ deviceId: deviceId });
deviceRef.current?.reload();
} catch {}
};
const [columnsState, setColumnsState] = useState<Record<string, ColumnsState>>({
deviceId: { show: !isMobile() },
appName: { show: !isMobile() },
@ -210,6 +220,9 @@ const DeviceOwnerApp: React.FC = () => {
if (record.status === 0) {
return <a onClick={() => handleSetOffline(record.deviceId)}>线</a>;
}
if (record.status === -1) {
return <a onClick={() => handleSetOnline(record.deviceId)}>线</a>;
}
return null;
},
},

15
src/services/matrix/device.ts

@ -73,3 +73,18 @@ export async function offline(
...(options || {}),
});
}
/** 此处后端没有提供注释 POST /api/admin/device/online */
export async function online(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
params: API.onlineParams,
options?: { [key: string]: any },
) {
return request<API.RString>('/api/admin/device/online', {
method: 'POST',
params: {
...params,
},
...(options || {}),
});
}

4
src/services/matrix/typings.d.ts

@ -226,6 +226,10 @@ declare namespace API {
deviceId: string;
};
type onlineParams = {
deviceId: string;
};
type OverviewBo = {
todayIncome?: number;
totalIncome?: number;

Loading…
Cancel
Save