diff --git a/src/api/device.ts b/src/api/device.ts
index 3ebbc30..4d9bdd9 100644
--- a/src/api/device.ts
+++ b/src/api/device.ts
@@ -477,6 +477,17 @@ export function getTaskPath(params) {
})
}
+//下载 机器属性模板
+
+export function downloadDeviceTemplate(params) {
+ return request({
+ url: '/iot/deviceRunParam/downloadTemplate',
+ method: 'get',
+ params,
+ responseType: 'blob', // 关键!告诉axios返回二进制
+ })
+}
+
diff --git a/src/components/SystemSetting/SmartDeviceManagement.tsx b/src/components/SystemSetting/SmartDeviceManagement.tsx
index 13d2fd8..a3ad236 100644
--- a/src/components/SystemSetting/SmartDeviceManagement.tsx
+++ b/src/components/SystemSetting/SmartDeviceManagement.tsx
@@ -23,6 +23,7 @@ import {
DisconnectOutlined,
UploadOutlined,
EditOutlined,
+ DownloadOutlined,
} from '@ant-design/icons';
import {
@@ -41,6 +42,7 @@ import { RootState } from '@/src/store';
import utils from '@/lib/utils';
import DeviceParamModal from '../devices/DeviceParamModal';
import { useTranslation } from 'react-i18next';
+import { downloadDeviceTemplate } from '@/api/device';
interface SmartDeviceManagementProps {
allOrgOptions: any[];
@@ -195,6 +197,9 @@ export default function SmartDeviceManagement({
const params = {
deviceId: data.serialNumber,
};
+ setCurrentParamDevice(data);
+ setParamModalVisible(true);
+ return;
hasPermission(params).then(res => {
if (res.code == 200) {
if (res.data) {
@@ -383,6 +388,23 @@ export default function SmartDeviceManagement({
),
},
];
+ const downloadDeviceTemplatefn = async () => {
+ try {
+ const res = await downloadDeviceTemplate(); // 你的参数
+ // 从响应头拿文件名(后端要返回 Content-Disposition)
+ let fileName = '设备模板.xlsx';
+ const blob = new Blob([res]);
+ const a = document.createElement('a');
+ a.href = URL.createObjectURL(blob);
+ a.download = fileName;
+ document.body.appendChild(a);
+ a.click();
+ a.remove();
+ URL.revokeObjectURL(a.href);
+ } catch (err) {
+ console.error('下载失败', err);
+ }
+ }
const selectorgId = Form.useWatch('orgId', bindSmartForm);
const selectsiteId = Form.useWatch('siteId', bindSmartForm);
@@ -415,6 +437,10 @@ export default function SmartDeviceManagement({