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) {
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/components/offTransferDlg.vue

@ -1,5 +1,5 @@
<template> <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"> <div class="flex-col gap-10 w-80% m-x-30px">
<el-row> <el-row>
<div class="label"> <div class="label">

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

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