From f49c9e607530dc82449d4cb3e68da800969d7ea2 Mon Sep 17 00:00:00 2001
From: mmc <1556375442@qq.com>
Date: Thu, 22 Oct 2026 15:14:13 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=85=A5excel=E8=A1=A8=E6=A0=BC?=
=?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=8F=82=E6=95=B0=20=E4=B8=8B=E8=BD=BD?=
=?UTF-8?q?=E6=A8=A1=E6=9D=BF=20=20=E5=8F=82=E6=95=B0=E6=9E=9A=E4=B8=BE?=
=?UTF-8?q?=E5=80=BC=E8=A1=A5=E5=85=85=20=20=E6=9F=A5=E7=9C=8B=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9=20=E4=BF=9D=E5=AD=98=E5=8F=82=E6=95=B0=20=20=E9=99=90?=
=?UTF-8?q?=E5=88=B6=20=E5=8F=AA=E6=9C=89admin=E5=8F=AF=E4=BB=A5=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/device.ts | 11 +
.../SystemSetting/SmartDeviceManagement.tsx | 26 ++
src/components/devices/DeviceOverviewPage.tsx | 8 +-
src/components/devices/DeviceParamModal.tsx | 252 +++++++++++-------
src/locales/en/index.ts | 48 +++-
src/locales/zh/index.ts | 51 +++-
6 files changed, 291 insertions(+), 105 deletions(-)
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({