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

2
src/views/stationData/transferData.vue

@ -1,7 +1,7 @@
<template> <template>
<div class="flex-col gap-16 wh-full"> <div class="flex-col gap-16 wh-full">
<el-button type="primary" @click="onBack" class="w-150px"> <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> </el-button>
<EdfsWrap title="设备列表" class="flex-1" useScrollBar> <EdfsWrap title="设备列表" class="flex-1" useScrollBar>
<template #title-right> <template #title-right>

Loading…
Cancel
Save