Compare commits

...

2 Commits

  1. 88
      src/views/stationData/components/deviceDrawer.vue
  2. 2
      src/views/stationData/components/offTransferDlg.vue
  3. 116
      src/views/stationData/components/onLineTransferDlg.vue
  4. 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/components/offTransferDlg.vue

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
<template>
<EdfsDialog :title="'数据迁移'" :is-show="visible" width="50%" @on-close="close" @on-save="onSave">
<EdfsDialog :title="'数据迁移'" :is-show="visible" width="580px" @on-close="close" @on-save="onSave">
<div class="flex-col gap-10 w-80% m-x-30px">
<el-row>
<div class="label">

116
src/views/stationData/components/onLineTransferDlg.vue

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
<EdfsDialog
:title="isBatchTransfer ? '批量迁移' : '数据迁移'"
:is-show="visible"
width="50%"
width="580px"
@on-close="close"
@on-save="onSave"
>
@ -10,17 +10,38 @@ @@ -10,17 +10,38 @@
<el-row>
<div class="label">
<span class="require">*</span>
数据时间范围:
数据开始时间:
</div>
<el-date-picker
v-model="form.timeArr"
type="datetimerange"
v-model="startTime"
value-format="YYYY-MM-DD HH:mm"
format="YYYY-MM-DD HH:mm"
class="flex-1"
start-placeholder="开始时间"
end-placeholder="结束时间"
:default-value="(defaultDateRange as any)"
:disabled-date="disabledAfterToday"
/></el-row>
type="datetime"
placeholder="请选择开始时间"
:disabled-date="disabledDate"
:disabled-time="disabledStartTime"
@change="handleStartTimeChange"
/>
</el-row>
<el-row>
<div class="label">
<span class="require">*</span>
数据结束时间:
</div>
<el-date-picker
v-model="endTime"
class="flex-1"
value-format="YYYY-MM-DD HH:mm"
format="YYYY-MM-DD HH:mm"
type="datetime"
placeholder="请选择结束时间"
:disabled-date="disabledDate"
:disabled-time="disabledEndTime"
@change="handleEndTimeChange"
/>
</el-row>
</div>
</EdfsDialog>
</template>
@ -28,17 +49,10 @@ @@ -28,17 +49,10 @@
<script setup lang="ts">
import dayjs from 'dayjs'
import { getPubInitData, type PublishMsg } from '@/utils/zmq'
import { cloneDeep } from 'lodash-es'
import type { IOnlineDevice } from '../type'
import { useMessage } from '@/composables/useMessage'
const message = useMessage()
const disabledAfterToday = (time: { getTime: () => number }) => {
return time.getTime() > Date.now() //
}
const defaultDateRange = [
dayjs().subtract(1, 'month').startOf('month'),
dayjs().endOf('month'),
] //
const emit = defineEmits<{
'on-save': [PublishMsg<'export'>, IOnlineDevice]
}>()
@ -48,12 +62,60 @@ const props = defineProps<{ @@ -48,12 +62,60 @@ const props = defineProps<{
}>()
const visible = ref(false)
const fromData = {
timeArr: [],
const startTime = ref('')
const endTime = ref('')
const disabledDate = (time: Date) => {
return dayjs(time).isAfter(dayjs())
}
const disabledStartTime = (date: Date) => {
if (endTime.value) {
const end = dayjs(endTime.value)
const current = dayjs(date)
if (current.isSame(end, 'day')) {
return {
hours: () => Array.from({ length: 24 }, (_, i) => i).filter(h => h > end.hour()),
minutes: () => Array.from({ length: 60 }, (_, i) => i).filter(m => m > end.minute())
}
}
}
return {}
}
const disabledEndTime = (date: Date) => {
if (startTime.value) {
const start = dayjs(startTime.value)
const current = dayjs(date)
if (current.isSame(start, 'day')) {
return {
hours: () => Array.from({ length: 24 }, (_, i) => i).filter(h => h < start.hour()),
minutes: () => Array.from({ length: 60 }, (_, i) => i).filter(m => m < start.minute())
}
}
}
return {}
}
function handleStartTimeChange(val: string) {
if (val && endTime.value) {
if (dayjs(val).isAfter(dayjs(endTime.value))) {
message.warning('开始时间不能晚于结束时间')
startTime.value = ''
}
}
}
function handleEndTimeChange(val: string) {
if (val && startTime.value) {
if (dayjs(val).isBefore(dayjs(startTime.value))) {
message.warning('结束时间不能早于开始时间')
endTime.value = ''
}
}
}
const curDevice = ref<IOnlineDevice>()
const form = ref(cloneDeep(fromData))
const batchClientIp = ref('')
const batchPath = ref('')
@ -83,7 +145,7 @@ function onSave() { @@ -83,7 +145,7 @@ function onSave() {
? batchPath.value
: `${curDevice.value.site_id}/${curDevice.value.sn}`
}`,
`${dayjs(form.value.timeArr[0]).valueOf()},${dayjs(form.value.timeArr[1]).valueOf()}`,
`${dayjs(startTime.value).valueOf()},${dayjs(endTime.value).valueOf()}`,
]
const msg = getPubInitData<'export'>('export', params)
emit('on-save', msg, curDevice.value as IOnlineDevice)
@ -91,7 +153,8 @@ function onSave() { @@ -91,7 +153,8 @@ function onSave() {
}
function close() {
form.value = cloneDeep(fromData)
startTime.value = ''
endTime.value = ''
visible.value = false
curDevice.value = undefined
batchClientIp.value = ''
@ -99,8 +162,13 @@ function close() { @@ -99,8 +162,13 @@ function close() {
}
function verifyData() {
if (!form.value.timeArr.length) {
message.error('请选择数据时间范围')
if(!startTime.value) {
message.error('请选择开始时间')
return false
}
if(!endTime.value) {
message.error('请选择结束时间')
return 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