{{ slotProps.deviceType.text }}
@@ -172,8 +182,10 @@ import {
addProduct,
editProduct,
queryProductId,
+ updateDevice,
} from '@/api/device/product';
-import { isNoCommunity } from '@/utils/utils';
+import { isNoCommunity, downloadObject } from '@/utils/utils';
+import { omit } from 'lodash-es';
import { typeOptions } from '@/components/Search/util';
import Save from './Save/index.vue';
/**
@@ -293,6 +305,17 @@ const getActions = (
},
icon: 'icon-xiazai',
+ onClick: () => {
+ const extra = omit(data, [
+ 'transportProtocol',
+ 'protocolName',
+ 'accessId',
+ 'accessName',
+ 'accessProvider',
+ 'messageProtocol',
+ ]);
+ downloadObject(extra, '产品');
+ },
},
{
key: 'action',
@@ -356,6 +379,42 @@ const add = () => {
saveRef.value.show(currentForm.value);
});
};
+
+/**
+ * 导入
+ */
+const beforeUpload = (file: any) => {
+ const reader = new FileReader();
+ reader.readAsText(file);
+ reader.onload = async (result) => {
+ const text = result.target?.result;
+ console.log('text: ', text);
+ if (!file.type.includes('json')) {
+ message.error('请上传json格式文件');
+ return false;
+ }
+ try {
+ const data = JSON.parse(text || '{}');
+ // 设置导入的产品状态为未发布
+ data.state = 0;
+ if (Array.isArray(data)) {
+ message.error('请上传json格式文件');
+ return false;
+ }
+ delete data.state;
+ const res = await updateDevice(data);
+ if (res.status === 200) {
+ message.success('操作成功');
+ tableRef.value?.reload();
+ }
+ return true;
+ } catch {
+ message.error('请上传json格式文件');
+ }
+ return true;
+ };
+ return false;
+};
/**
* 查看
*/
diff --git a/src/views/iot-card/CardManagement/Detail/index.vue b/src/views/iot-card/CardManagement/Detail/index.vue
index 580fe4df..e36063b1 100644
--- a/src/views/iot-card/CardManagement/Detail/index.vue
+++ b/src/views/iot-card/CardManagement/Detail/index.vue
@@ -119,7 +119,7 @@
-
+
昨日流量消耗
@@ -137,7 +137,7 @@
/>
-
+
当月流量消耗
@@ -152,7 +152,7 @@
-
+
本年流量消耗
@@ -328,7 +328,7 @@ getDataTotal();
align-items: center;
padding: 20px;
- .info {
+ .flow-info {
// width: 180px;
width: 28%;
.label {
diff --git a/src/views/iot-card/Dashboard/index.vue b/src/views/iot-card/Dashboard/index.vue
index 4bc42f09..ece76606 100644
--- a/src/views/iot-card/Dashboard/index.vue
+++ b/src/views/iot-card/Dashboard/index.vue
@@ -7,7 +7,7 @@
-
+
昨日流量消耗
@@ -27,7 +27,7 @@
-
+
当月流量消耗
@@ -44,7 +44,7 @@
-
+
本年流量消耗
@@ -279,7 +279,7 @@ getDataTotal();
align-items: center;
padding: 20px;
- .info {
+ .flow-info {
// width: 180px;
width: 28%;
.label {