修改bug

This commit is contained in:
zhujiyan
2024-10-30 15:02:25 +08:00
parent 038b5275ea
commit 45942b3205
15 changed files with 57 additions and 483 deletions

View File

@@ -40,32 +40,19 @@
</div>
</template>
<script lang="ts" setup>
import { ref, onMounted, defineProps, defineExpose, onBeforeUnmount, inject } from 'vue'
import { ref, onMounted, defineExpose, onBeforeUnmount, inject } from 'vue'
import { getMakeUpData, getAskDirOrFile, offlineDataUploadMakeUp } from '@/api/cs-harmonic-boot/recruitment.ts'
import DatePicker from '@/components/form/datePicker/index.vue'
import { useRouter, useRoute } from 'vue-router'
import { mainHeight } from '@/utils/layout'
import {
Plus,
Back,
Search,
Refresh,
RefreshRight,
RefreshLeft,
ScaleToOriginal,
ZoomIn,
Setting,
Cpu,
View,
Download,
ZoomOut,
FolderOpened
} from '@element-plus/icons-vue'
Setting} from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus'
import mqtt from 'mqtt'
const checkList: any = ref([])
// const props = defineProps(['lineId'])
const { push, currentRoute, go } = useRouter() // 路由
const { go } = useRouter() // 路由
const loading = ref(false)
const dirList = ref([])
@@ -111,7 +98,6 @@ const handleUpDevice = () => {
ndid: routes.query.ndid,
proList: proList
}
// loading.value = true
offlineDataUploadMakeUp(form)
.then((res: any) => {
if (res.code == 'A0000') {
@@ -119,26 +105,10 @@ const handleUpDevice = () => {
// loading.value = false
}
})
.catch(e => {
.catch(() => {
// loading.value = false
})
}
const handleIntoDir = (row: any) => {
if (dirCheckedList.value.indexOf(row) == -1) {
dirCheckedList.value.push(row)
}
console.log(row, 'hhhhh', dirCheckedList.value)
const obj = {
fileType: row.type,
nDid: route.value.ndid,
path: row.prjDataPath,
prjName: row.prjName
}
getAskDirOrFile(obj).then(res => {
dirList.value = res.data
console.log(dirList.value, '查询3333333333333333')
})
}
const mqttRef = ref()
const url: any = inject('MQTTURL')
@@ -160,7 +130,7 @@ const connectMqtt = () => {
mqttRef.value = mqtt.connect(url, options)
}
connectMqtt()
mqttRef.value.on('connect', (e: any) => {
mqttRef.value.on('connect', () => {
// ElMessage.success('连接mqtt服务器成功!')
console.log('mqtt客户端已连接....')
// mqttRef.value.subscribe('/Web/Progress')
@@ -168,22 +138,17 @@ mqttRef.value.on('connect', (e: any) => {
mqttRef.value.subscribe('/dataOnlineRecruitment/Progress/' + route.value.id)
})
const mqttMessage = ref<any>({})
const status: any = ref()
mqttRef.value.on('message', (topic: any, message: any) => {
// console.log('🚀 ~ mqttRef.value.on ~ message:', JSON.parse(message))
// console.log('mqtt接收到消息', message,topic)
console.log('mqtt接收到消息', JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message)))))
loading.value = false
// "{allStep:\""+times+"\",nowStep:"+i+"}"
let str = JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message))))
// eval('(' + str + ')').includes('fileName')
let regex1 = /allStep:(.*?),nowStep/
let regex2 = /nowStep:(.*?)}/
mqttMessage.value = {
allStep: str.match(regex1)[1],
nowStep: str.match(regex2)[1]
}
console.log(mqttMessage.value, '=============================================185')
console.log(mqttMessage.value)
let checkedList = tableRef.value.getCheckboxRecords().map((item: any) => {
return item.name
})
@@ -194,10 +159,6 @@ mqttRef.value.on('message', (topic: any, message: any) => {
}
})
})
// status.value = parseInt(Number((mqttMessage.value.nowStep / mqttMessage.value.allStep) * 100))
// if (status.value == 100) {
// status.value = 99
// }
})
mqttRef.value.on('error', (error: any) => {
@@ -209,8 +170,6 @@ mqttRef.value.on('close', function () {
console.log('mqtt客户端已断开连接.....')
})
onMounted(() => {
console.log()
// getMakeUpDataList()
})
onBeforeUnmount(() => {
if (mqttRef.value) {
@@ -220,40 +179,6 @@ onBeforeUnmount(() => {
defineExpose({ getMakeUpDataList })
</script>
<style lang="scss" scoped>
// .current_device {
// width: 100%;
// height: calc(100vh - 200px);
// display: flex;
// flex-wrap: wrap;
// align-items: flex-start;
// // justify-content: space-between;
// overflow-y: auto;
// .device_dir {
// width: 24.1%;
// height: 120px;
// border: 1px solid #eee;
// margin: 0 0.3%;
// display: flex;
// align-items: center;
// flex-direction: column;
// justify-content: center;
// .device_dir_file {
// width: 60px;
// height: 60px;
// }
// img {
// width: 50px;
// height: 50px;
// }
// img:hover {
// cursor: pointer;
// }
// p {
// margin-top: 10px;
// }
// // margin:10px;
// }
// }
.current_device {
width: 100%;
height: calc(100vh - 200px);