From c56c301365ce2bbda0134a14dd24fb195f59820c Mon Sep 17 00:00:00 2001
From: GGJ <357021191@qq.com>
Date: Fri, 8 Nov 2024 14:02:27 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9mqtt=E6=96=87=E4=BB=B6?=
=?UTF-8?q?=E4=B8=8B=E8=BD=BD=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/form/area/index.vue | 2 +-
src/components/table/header/index.vue | 1 +
.../govern/device/control/tabs/trend.vue | 2 +-
src/views/govern/device/fileService/index.vue | 122 ++++++------------
src/views/govern/device/fileService/popup.vue | 24 ++--
src/views/govern/device/planData/index.vue | 16 ++-
6 files changed, 68 insertions(+), 99 deletions(-)
diff --git a/src/components/form/area/index.vue b/src/components/form/area/index.vue
index 3d91d97..6125a3c 100644
--- a/src/components/form/area/index.vue
+++ b/src/components/form/area/index.vue
@@ -19,7 +19,7 @@ const cascaderProps = {
const cascader = ref()
const dictData = useDictData()
const options = dictData.state.area
-const areaName = ref(dictData.state.area[0].name)
+const areaName = ref(dictData.state.area[0]?.name || '')
const change = (e: any) => {
if (cascader.value.getCheckedNodes()[0].pathLabels.length == 1) {
areaName.value = cascader.value.getCheckedNodes()[0].pathLabels[0]
diff --git a/src/components/table/header/index.vue b/src/components/table/header/index.vue
index 01baed8..35d480a 100644
--- a/src/components/table/header/index.vue
+++ b/src/components/table/header/index.vue
@@ -110,6 +110,7 @@ const handlerHeight = () => {
}
// 刷新页面handler高度出下拉
const computedSearchRow = () => {
+
if (!headerForm.value.$el) return
diff --git a/src/views/govern/device/control/tabs/trend.vue b/src/views/govern/device/control/tabs/trend.vue
index 0f96c93..a2da213 100644
--- a/src/views/govern/device/control/tabs/trend.vue
+++ b/src/views/govern/device/control/tabs/trend.vue
@@ -590,7 +590,7 @@ const formatCountOptions = (list: any) => {
}
setTimeout(() => {
tableHeaderRef.value.computedSearchRow()
- }, 100)
+ }, 500)
}
// 判断下拉框是否存在
const onCountChange = (val: any, index: any) => {
diff --git a/src/views/govern/device/fileService/index.vue b/src/views/govern/device/fileService/index.vue
index 9c27476..2b47bb7 100644
--- a/src/views/govern/device/fileService/index.vue
+++ b/src/views/govern/device/fileService/index.vue
@@ -8,12 +8,8 @@
-
+
搜索
重置
-
+ ">
文件上传
@@ -60,29 +45,19 @@
-
+
-
+
{{
row &&
- row?.prjDataPath &&
- row?.prjDataPath.includes(activePath) &&
- row?.prjDataPath.length > activePath.length
+ row?.prjDataPath &&
+ row?.prjDataPath.includes(activePath) &&
+ row?.prjDataPath.length > activePath.length
? row?.prjDataPath.replace(activePath, ' ').replace('/', ' ')
: row?.prjDataPath.replace('/', ' ')
}}
@@ -97,7 +72,7 @@
{{ row.type == 'dir' ? '文件夹' : row.type == 'file' ? '文件' : '/' }}
-
+
{{ row.size && row.type == 'file' ? row.size + 'KB' : '/' }}
@@ -108,13 +83,8 @@
删除
-
+
下载
@@ -125,13 +95,8 @@
-
+
@@ -143,19 +108,15 @@

-

+
{{
item &&
- item?.prjDataPath &&
- item?.prjDataPath.includes(activePath) &&
- item?.prjDataPath.length > activePath.length
+ item?.prjDataPath &&
+ item?.prjDataPath.includes(activePath) &&
+ item?.prjDataPath.length > activePath.length
? item?.prjDataPath.replace(activePath, ' ').replace('/', ' ')
: item?.prjDataPath.replace('/', ' ')
}}
@@ -165,18 +126,9 @@
-
-
+
+
@@ -207,13 +159,14 @@ import { defaultAttribute } from '@/components/table/defaultAttribute'
import { Delete, Download, Upload, Plus, Refresh, Search } from '@element-plus/icons-vue'
import popup from './popup.vue'
import mqtt from 'mqtt'
+import { useAdminInfo } from '@/stores/adminInfo'
import { passwordConfirm } from '@/api/user-boot/user'
defineOptions({
name: 'govern/device/fileService'
})
const pageHeight = mainHeight(20)
const tableHeight = mainHeight(130)
-
+const adminInfo = useAdminInfo()
const loading = ref(false)
//nDid
const nDid = ref('')
@@ -496,7 +449,7 @@ const changeType = ref('')
//下载文件
const fileRef = ref()
const handleDownLoad = async (row: any) => {
- ;(await nDid.value) && fileRef.value && fileRef.value.open(row, nDid.value)
+ ; (await nDid.value) && fileRef.value && fileRef.value.open(row, nDid.value)
// fileName.value = row?.prjDataPath.split('/')[row?.prjDataPath.split('/').length - 1]
// localStorage.setItem('fileName', fileName.value)
changeType.value = 'download'
@@ -569,15 +522,21 @@ const status: any = ref()
mqttRef.value.on('message', (topic: any, message: any) => {
console.log('mqtt接收到消息', JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message)))))
+
let str = JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message))))
+
let regex = /fileName:(.*?),allStep/
let regex1 = /allStep:(.*?),nowStep/
- let regex2 = /nowStep:(.*?)}/
+ let regex2 = /nowStep:(.*?),userId/
+ let regex3 = /userId:(.*?)}/
+
mqttMessage.value = {
fileName: str.match(regex)[1],
allStep: str.match(regex1)[1],
- nowStep: str.match(regex2)[1]
+ nowStep: str.match(regex2)[1],
+ userId: str.match(regex3)[1]
}
+ console.log("🚀 ~ str.match(regex3)[1]:", str.match(regex3)[1])
status.value = parseInt(Number((mqttMessage.value.nowStep / mqttMessage.value.allStep) * 100))
fileRef.value.setStatus(mqttMessage.value)
fileName.value = mqttMessage.value.fileName
@@ -613,6 +572,7 @@ onBeforeUnmount(() => {
display: flex;
justify-content: space-between;
padding-bottom: 10px;
+
.main_left {
// width: 280px;
}
@@ -696,6 +656,7 @@ onBeforeUnmount(() => {
padding-bottom: 200px;
z-index: 100;
position: relative;
+
.list_item {
flex: none;
width: 23.3%;
@@ -714,6 +675,7 @@ onBeforeUnmount(() => {
height: 40px;
margin: 0;
border: 1px solid #eee;
+
.item_download,
.item_upload {
position: absolute;
diff --git a/src/views/govern/device/fileService/popup.vue b/src/views/govern/device/fileService/popup.vue
index bc6f18e..672f4c8 100644
--- a/src/views/govern/device/fileService/popup.vue
+++ b/src/views/govern/device/fileService/popup.vue
@@ -3,16 +3,14 @@
-
+
正在下载:
{{
// fileData?.prjDataPath
- // ? fileData?.prjDataPath.split('/')[fileData?.prjDataPath.split('/').length - 1]
- // : '/'
+ // ? fileData?.prjDataPath.split('/')[fileData?.prjDataPath.split('/').length - 1]
+ // : '/'
mqttFileName
}}
@@ -59,9 +57,11 @@ import {
downLoadDeviceFilePath
} from '@/api/cs-device-boot/fileService.ts'
import { ElMessage } from 'element-plus'
+import { useAdminInfo } from '@/stores/adminInfo'
import { downLoadFile } from '@/api/cs-system-boot/manage.ts'
const dialogVisible = ref(false)
const loading = ref(false)
+const adminInfo = useAdminInfo()
const downLoading = ref(false)
const emit = defineEmits(['downLoadFile'])
const handleClose = () => {
@@ -146,14 +146,16 @@ const handleDownLoad = () => {
}
})
}
-onMounted(() => {})
-onUnmounted(() => {})
+onMounted(() => { })
+onUnmounted(() => { })
const status = ref(0)
const mqttFileName = ref('')
const setStatus = (val: any) => {
- status.value = parseInt(Number((val.nowStep / val.allStep) * 100))
+ status.value = parseInt(Number((val.nowStep / val.allStep) * 100)) || 0
+
mqttFileName.value = val.fileName
- downLoading.value=true
+ if (adminInfo.userIndex != val.userId) return
+ downLoading.value = true
if (status.value == 100) {
downLoadDeviceFilePath({ nDid: fileData.value.nDid, name: fileData.value.prjDataPath }).then((ress: any) => {
if (ress.code == 'A0000') {
@@ -196,9 +198,11 @@ defineExpose({ open, setStatus })
margin: 10px 0;
align-items: center;
justify-content: space-between;
+
.progress_left {
width: auto;
}
+
.progress_right {
flex: 1;
padding-left: 10px;
diff --git a/src/views/govern/device/planData/index.vue b/src/views/govern/device/planData/index.vue
index 9a884a9..0bf6aa9 100644
--- a/src/views/govern/device/planData/index.vue
+++ b/src/views/govern/device/planData/index.vue
@@ -113,6 +113,12 @@
:value="item.id">
+
+
+
+
+
@@ -129,12 +135,7 @@
:value="vv">
-
-
-
-
-
+
@@ -756,7 +757,8 @@ const formatCountOptions = (list: any) => {
}
setTimeout(() => {
- tableHeaderRef.value && tableHeaderRef.value[activeName.value]?.computedSearchRow()
+
+ tableHeaderRef.value && tableHeaderRef.value?.computedSearchRow()
}, 100)
}
const flag = ref(false)