Browse Source

fix: 点位逻辑修改

main
betaqi 2 months ago
parent
commit
fd6f931823
  1. 88
      src/views/stationData/components/deviceDrawer.vue
  2. 2
      src/views/stationData/transferData.vue

88
src/views/stationData/components/deviceDrawer.vue

@ -70,11 +70,11 @@ async function open(device: IOfflineDevice | IOnlineDevice) { @@ -70,11 +70,11 @@ async function open(device: IOfflineDevice | IOnlineDevice) {
curDevice.value = device
await loadPointGroup()
.then(async () => {
if (env.VITE_APP_ENV === 'local') {
props.isTransfer ? await loadDeviceDetails() : zmqImport(device as IOfflineDevice)
} else {
// if (env.VITE_APP_ENV === 'local') {
// props.isTransfer ? await loadDeviceDetails() : zmqImport(device as IOfflineDevice)
// } else {
await loadDeviceDetails()
}
// }
})
.catch(() => {
message.error('获取点位组数据失败')
@ -160,11 +160,10 @@ async function loadChardData() { @@ -160,11 +160,10 @@ async function loadChardData() {
name: curGroupName.value as string
}
if (env.VITE_APP_ENV !== 'local') {
if (env.VITE_APP_ENV !== 'local' || !props.isTransfer) {
params.site_id = props.siteInfo!.name || ''
params.device_id = curDevice.value?.sn || ''
}
loading.value = true
const res = await getDeviceDetails(params)
@ -204,45 +203,44 @@ async function loadChardData() { @@ -204,45 +203,44 @@ async function loadChardData() {
loading.value = false
}
function zmqImport(device: IOfflineDevice) {
console.log('object')
if (!device.sn || !props.siteInfo!.name) {
message.error('未找到站点或设备')
return
}
const msg = getPubInitData<'import'>(
'import',
['', '', '', '', '', '', `${props.siteInfo!.name}/${device.sn}`],
'yes'
)
pubIdWithDevice.set(msg.id, { device, action: 'import' })
worker.publish(postTransferTopic, msg, true, zmqTimeoutCb)
worker.subscribe(getTransferTopic, zmqImportCb, msg.id)
}
function zmqImportCb(msg: PubMsgData) {
const { id, result } = msg
if (result !== 'progress') {
const { device, action } = pubIdWithDevice.get(id)!
if (result === 'success' && device && action === 'import') {
loadDeviceDetails()
pubIdWithDevice.delete(id)
} else {
message.error(`设备数据获取失败`)
fullscreenLoading.value?.close()
pubIdWithDevice.delete(id)
}
}
}
function zmqTimeoutCb(msg: TimeoutMsg) {
const { device, action } = pubIdWithDevice.get(msg.timeoutId)!
if (device && action === 'import') {
message.error(`设备${device.sn},查询信息超时,请稍后重试`)
pubIdWithDevice.delete(msg.timeoutId)
fullscreenLoading.value?.close()
}
}
// function zmqImport(device: IOfflineDevice) {
// if (!device.sn || !props.siteInfo!.name) {
// message.error('')
// return
// }
// const msg = getPubInitData<'import'>(
// 'import',
// ['', '', '', '', '', '', `${props.siteInfo!.name}/${device.sn}`],
// 'yes'
// )
// pubIdWithDevice.set(msg.id, { device, action: 'import' })
// worker.publish(postTransferTopic, msg, true, zmqTimeoutCb)
// worker.subscribe(getTransferTopic, zmqImportCb, msg.id)
// }
// function zmqImportCb(msg: PubMsgData) {
// const { id, result } = msg
// if (result !== 'progress') {
// const { device, action } = pubIdWithDevice.get(id)!
// if (result === 'success' && device && action === 'import') {
// loadDeviceDetails()
// pubIdWithDevice.delete(id)
// } else {
// message.error(``)
// fullscreenLoading.value?.close()
// pubIdWithDevice.delete(id)
// }
// }
// }
// function zmqTimeoutCb(msg: TimeoutMsg) {
// const { device, action } = pubIdWithDevice.get(msg.timeoutId)!
// if (device && action === 'import') {
// message.error(`${device.sn},,`)
// pubIdWithDevice.delete(msg.timeoutId)
// fullscreenLoading.value?.close()
// }
// }
function handleBeforeClose(done: () => void) {
isShowDrawer.value = false

2
src/views/stationData/transferData.vue

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
<template>
<div class="flex-col gap-16 wh-full">
<el-button type="primary" @click="onBack" class="w-150px">
<i class="i-line-md:arrow-left"></i>返回站点数据 {{ isonLineTransfer }}
<i class="i-line-md:arrow-left"></i>返回站点数据
</el-button>
<EdfsWrap title="设备列表" class="flex-1" useScrollBar>
<template #title-right>

Loading…
Cancel
Save