Compare commits

..

No commits in common. 'fd6f9318234a3f2ebcae2a74a1ba1b96636a44e8' and 'ac90170f78cc1769b79fd676ab18feaa03d27390' have entirely different histories.

  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,10 +160,11 @@ async function loadChardData() {
name: curGroupName.value as string name: curGroupName.value as string
} }
if (env.VITE_APP_ENV !== 'local' || !props.isTransfer) { if (env.VITE_APP_ENV !== 'local') {
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)
@ -203,44 +204,45 @@ async function loadChardData() {
loading.value = false loading.value = false
} }
// function zmqImport(device: IOfflineDevice) { function zmqImport(device: IOfflineDevice) {
// if (!device.sn || !props.siteInfo!.name) { console.log('object')
// message.error('') if (!device.sn || !props.siteInfo!.name) {
// return message.error('未找到站点或设备')
// } return
// const msg = getPubInitData<'import'>( }
// 'import', const msg = getPubInitData<'import'>(
// ['', '', '', '', '', '', `${props.siteInfo!.name}/${device.sn}`], 'import',
// 'yes' ['', '', '', '', '', '', `${props.siteInfo!.name}/${device.sn}`],
// ) 'yes'
// pubIdWithDevice.set(msg.id, { device, action: 'import' }) )
// worker.publish(postTransferTopic, msg, true, zmqTimeoutCb) pubIdWithDevice.set(msg.id, { device, action: 'import' })
// worker.subscribe(getTransferTopic, zmqImportCb, msg.id) worker.publish(postTransferTopic, msg, true, zmqTimeoutCb)
// } worker.subscribe(getTransferTopic, zmqImportCb, msg.id)
}
// function zmqImportCb(msg: PubMsgData) {
// const { id, result } = msg function zmqImportCb(msg: PubMsgData) {
// if (result !== 'progress') { const { id, result } = msg
// const { device, action } = pubIdWithDevice.get(id)! if (result !== 'progress') {
// if (result === 'success' && device && action === 'import') { const { device, action } = pubIdWithDevice.get(id)!
// loadDeviceDetails() if (result === 'success' && device && action === 'import') {
// pubIdWithDevice.delete(id) loadDeviceDetails()
// } else { pubIdWithDevice.delete(id)
// message.error(``) } else {
// fullscreenLoading.value?.close() message.error(`设备数据获取失败`)
// pubIdWithDevice.delete(id) fullscreenLoading.value?.close()
// } pubIdWithDevice.delete(id)
// } }
// } }
}
// function zmqTimeoutCb(msg: TimeoutMsg) {
// const { device, action } = pubIdWithDevice.get(msg.timeoutId)! function zmqTimeoutCb(msg: TimeoutMsg) {
// if (device && action === 'import') { const { device, action } = pubIdWithDevice.get(msg.timeoutId)!
// message.error(`${device.sn},,`) if (device && action === 'import') {
// pubIdWithDevice.delete(msg.timeoutId) message.error(`设备${device.sn},查询信息超时,请稍后重试`)
// fullscreenLoading.value?.close() pubIdWithDevice.delete(msg.timeoutId)
// } 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="580px" @on-close="close" @on-save="onSave"> <EdfsDialog :title="'数据迁移'" :is-show="visible" width="50%" @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="580px" width="50%"
@on-close="close" @on-close="close"
@on-save="onSave" @on-save="onSave"
> >
@ -10,38 +10,17 @@
<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="startTime" v-model="form.timeArr"
value-format="YYYY-MM-DD HH:mm" type="datetimerange"
format="YYYY-MM-DD HH:mm"
class="flex-1" class="flex-1"
type="datetime" start-placeholder="开始时间"
placeholder="请选择开始时间" end-placeholder="结束时间"
:disabled-date="disabledDate" :default-value="(defaultDateRange as any)"
:disabled-time="disabledStartTime" :disabled-date="disabledAfterToday"
@change="handleStartTimeChange" /></el-row>
/>
</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>
@ -49,10 +28,17 @@
<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]
}>() }>()
@ -62,60 +48,12 @@ const props = defineProps<{
}>() }>()
const visible = ref(false) const visible = ref(false)
const startTime = ref('') const fromData = {
const endTime = ref('') timeArr: [],
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('')
@ -145,7 +83,7 @@ function onSave() {
? batchPath.value ? batchPath.value
: `${curDevice.value.site_id}/${curDevice.value.sn}` : `${curDevice.value.site_id}/${curDevice.value.sn}`
}`, }`,
`${dayjs(startTime.value).valueOf()},${dayjs(endTime.value).valueOf()}`, `${dayjs(form.value.timeArr[0]).valueOf()},${dayjs(form.value.timeArr[1]).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)
@ -153,8 +91,7 @@ function onSave() {
} }
function close() { function close() {
startTime.value = '' form.value = cloneDeep(fromData)
endTime.value = ''
visible.value = false visible.value = false
curDevice.value = undefined curDevice.value = undefined
batchClientIp.value = '' batchClientIp.value = ''
@ -162,13 +99,8 @@ function close() {
} }
function verifyData() { function verifyData() {
if(!startTime.value) { if (!form.value.timeArr.length) {
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>返回站点数据 <i class="i-line-md:arrow-left"></i>返回站点数据 {{ isonLineTransfer }}
</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