Browse Source

feat: 一些调整

main
betaqi 1 month ago
parent
commit
e16ace00f8
  1. 4
      global.types/components.d.ts
  2. 1
      src/api/module/transfer/index.ts
  3. 20
      src/router/index.ts
  4. 2
      src/views/stationData/component/pointCheckbox.vue
  5. 3
      src/views/stationData/topology/components/Node.vue
  6. 79
      src/views/stationData/topology/components/detailDrawer.vue
  7. 14
      src/views/stationData/topology/index.vue
  8. 2
      src/views/stationData/transfer/components/PointGroupTree.vue
  9. 51
      src/views/stationData/transfer/components/deviceDrawer.vue
  10. 8
      src/views/stationData/transfer/index.vue
  11. 2
      src/views/stationData/type.ts
  12. 6
      src/views/taskList/index.vue

4
global.types/components.d.ts vendored

@ -15,8 +15,6 @@ declare module 'vue' {
EdfsTable: typeof import('./../src/components/Edfs-table/index.vue')['default'] EdfsTable: typeof import('./../src/components/Edfs-table/index.vue')['default']
EdfsWrap: typeof import('./../src/components/Edfs-wrap.vue')['default'] EdfsWrap: typeof import('./../src/components/Edfs-wrap.vue')['default']
ElAside: typeof import('element-plus/es')['ElAside'] ElAside: typeof import('element-plus/es')['ElAside']
ElBreadcrumb: typeof import('element-plus/es')['ElBreadcrumb']
ElBreadcrumbItem: typeof import('element-plus/es')['ElBreadcrumbItem']
ElButton: typeof import('element-plus/es')['ElButton'] ElButton: typeof import('element-plus/es')['ElButton']
ElCheckbox: typeof import('element-plus/es')['ElCheckbox'] ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup'] ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup']
@ -33,10 +31,12 @@ declare module 'vue' {
ElInput: typeof import('element-plus/es')['ElInput'] ElInput: typeof import('element-plus/es')['ElInput']
ElMenu: typeof import('element-plus/es')['ElMenu'] ElMenu: typeof import('element-plus/es')['ElMenu']
ElMenuItem: typeof import('element-plus/es')['ElMenuItem'] ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
ElOption: typeof import('element-plus/es')['ElOption']
ElPagination: typeof import('element-plus/es')['ElPagination'] ElPagination: typeof import('element-plus/es')['ElPagination']
ElProgress: typeof import('element-plus/es')['ElProgress'] ElProgress: typeof import('element-plus/es')['ElProgress']
ElRow: typeof import('element-plus/es')['ElRow'] ElRow: typeof import('element-plus/es')['ElRow']
ElScrollbar: typeof import('element-plus/es')['ElScrollbar'] ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
ElSelect: typeof import('element-plus/es')['ElSelect']
ElSubMenu: typeof import('element-plus/es')['ElSubMenu'] ElSubMenu: typeof import('element-plus/es')['ElSubMenu']
ElTableColumn: typeof import('element-plus/es')['ElTableColumn'] ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
ElTag: typeof import('element-plus/es')['ElTag'] ElTag: typeof import('element-plus/es')['ElTag']

1
src/api/module/transfer/index.ts

@ -66,6 +66,7 @@ export interface IPointGroupOV {
id: number | string, id: number | string,
ip: string, ip: string,
name: string, name: string,
cnName:string
port: number, port: number,
slave_addr: number | string, slave_addr: number | string,
type: string, type: string,

20
src/router/index.ts

@ -63,16 +63,16 @@ export const defaultRouter = [
icon: 'i-mingcute:task-line', icon: 'i-mingcute:task-line',
} }
}, },
{ // {
path: '/testG6', // path: '/testG6',
name: 'testG6', // name: 'testG6',
component: () => import('@/views/testG6/index.vue'), // component: () => import('@/views/testG6/index.vue'),
meta: { // meta: {
title: '测试G6', // title: '测试G6',
isShow: true, // isShow: true,
icon: 'i-mingcute:task-line', // icon: 'i-mingcute:task-line',
} // }
} // }
], ],
}, },
] ]

2
src/views/stationData/component/pointCheckbox.vue

@ -1,5 +1,5 @@
<template> <template>
<div class="w-340 h-full" v-loading="loadingPoints" element-loading-text="数据加载中..."> <div class="w-320 h-full" v-loading="loadingPoints" element-loading-text="数据加载中...">
<template v-if="!pointList.length"> <template v-if="!pointList.length">
<el-empty></el-empty> <el-empty></el-empty>
</template> </template>

3
src/views/stationData/topology/components/Node.vue

@ -14,7 +14,8 @@
<img :src="Device.icon" style="height: 100%;" alt=""> <img :src="Device.icon" style="height: 100%;" alt="">
</div> </div>
<div class="bg-white flex-1 flex items-center justify-center overflow-hidden"> <div class="bg-white flex-1 flex items-center justify-center overflow-hidden">
<span class="text-12px overflow-hidden text-ellipsis whitespace-nowrap">{{ Device.name }}</span> <span class="text-12px overflow-hidden text-ellipsis whitespace-nowrap">{{ Device.cnName
}}</span>
</div> </div>
</div> </div>
</template> </template>

79
src/views/stationData/topology/components/detailDrawer.vue

@ -9,7 +9,23 @@
:before-close="handleBeforeClose" :before-close="handleBeforeClose"
@opened="onDrawerOpened"> @opened="onDrawerOpened">
<main class="wh-full flex"> <main class="wh-full flex">
<EdfsWrap title="选择" class="p-r-4 h-full w-340 border-r-1 border-solid border-r-#e4e7ed">
<EdfsWrap title="点位选择"
class="p-r-4 h-full w-340 border-r-1 border-solid border-r-#e4e7ed">
<el-select
v-if="currentGroup?.customNode"
v-model="selectValue"
placeholder="单体选择"
style="width:240px"
@change="onchangeSelect"
>
<el-option
v-for="item in currentGroup.brother"
:key="item.name"
:label="item.customCnName"
:value="item.name"
/>
</el-select>
<PointCheckbox <PointCheckbox
:pointList="pointList" :pointList="pointList"
:loadingPoints="loadingPoints" :loadingPoints="loadingPoints"
@ -34,7 +50,21 @@
</div> </div>
</div> </div>
</div> </div>
<el-button class="mb-4" type="primary" @click="loadChardData">查询数据</el-button> <div class="flex w-full items-center gap-16">
<div class="w-400px">
<el-date-picker
v-model="time"
type="datetimerange"
value-format="YYYY-MM-DD HH:mm:ss"
range-separator="到"
:default-value="getBeforeMonth"
start-placeholder="开始时间"
end-placeholder="结束时间"
:disabled-date="disabledDate"
/>
</div>
<el-button type="primary" @click="loadChardData">查询数据</el-button>
</div>
<NewDataChart <NewDataChart
v-if="isShowChart" v-if="isShowChart"
:chart-datas="chartData" :chart-datas="chartData"
@ -79,6 +109,13 @@ async function open(device: IDevice & {
}, group: IPointGroupOV) { }, group: IPointGroupOV) {
curDevice.value = device curDevice.value = device
currentGroup.value = group currentGroup.value = group
if (
currentGroup.value.customNode &&
currentGroup.value.brother &&
currentGroup.value.brother.length
) {
selectValue.value = currentGroup.value.brother[0].name
}
PointCheckboxRef.value?.clearCheck() PointCheckboxRef.value?.clearCheck()
await loadPoints() await loadPoints()
.then(async () => { .then(async () => {
@ -90,11 +127,19 @@ async function open(device: IDevice & {
}) })
} }
const selectValue = ref()
function onchangeSelect(value: string) {
PointCheckboxRef.value?.clearCheck()
}
const loadingPoints = ref(false) const loadingPoints = ref(false)
const columParams = computed(() => ['ts', ...checkPointList.value.map(i => i.addr)]) const columParams = computed(() => ['ts', ...checkPointList.value.map(i => i.addr)])
const currentGroup = ref<IPointGroupOV>() const currentGroup = ref<IPointGroupOV & {
customNode?: boolean
brother?: Array<any>
}>()
async function loadPoints() { async function loadPoints() {
if (!currentGroup.value) { if (!currentGroup.value) {
@ -159,6 +204,10 @@ const chartOffset = ref(0)
const progress = ref(0) const progress = ref(0)
async function loadChardData() { async function loadChardData() {
if (!time.value || time.value.length !== 2) {
message.error('请选择时间范围')
return
}
if (!currentGroup.value) return if (!currentGroup.value) return
if (!columParams.value.filter(i => i !== 'ts').length) { if (!columParams.value.filter(i => i !== 'ts').length) {
message.error('请选择点位') message.error('请选择点位')
@ -171,7 +220,9 @@ async function loadChardData() {
columns: columParams.value, columns: columParams.value,
isLocal: !curDevice.value?.isonLine, isLocal: !curDevice.value?.isonLine,
host: curDevice.value?.isonLine ? (curDevice.value as IOnlineDevice).clientIp : '', host: curDevice.value?.isonLine ? (curDevice.value as IOnlineDevice).clientIp : '',
name: currentGroup.value.name as string, name: selectValue.value as string,
startTime: time.value[0],
endTime: time.value[1],
} }
const params: IGetDeviceDataParams = { const params: IGetDeviceDataParams = {
@ -315,6 +366,26 @@ function onchangePoints(checkPoints: IMyPoint[]) {
checkPointList.value = checkPoints checkPointList.value = checkPoints
} }
const time = ref<[string, string]>()
const disabledDate = (time: any) => {
const current = dayjs(time)
if (curDevice.value?.isonLine) {
return current.isAfter(dayjs(), 'day')
}
try {
const deviceOff = curDevice.value as IOfflineDevice
const start = dayjs(deviceOff.start_time).format('YYYY-MM-DD')
const end = dayjs(deviceOff.end_time).format('YYYY-MM-DD')
return current.isBefore(start, 'day') || current.isAfter(end, 'day')
} catch (e) {
console.log('disableDate error', e)
return current.isAfter(dayjs(), 'day')
}
}
const getBeforeMonth = dayjs().startOf('month').subtract(1, 'month').startOf('month').toDate()
defineExpose({ defineExpose({
open, open,
openFullScreen, openFullScreen,

14
src/views/stationData/topology/index.vue

@ -56,6 +56,7 @@ async function loadDeviceTopology() {
id: deviceInfo.sn, id: deviceInfo.sn,
ip: deviceInfo.ip, ip: deviceInfo.ip,
name: deviceInfo?.sn, name: deviceInfo?.sn,
cnName: deviceInfo?.name ?? deviceInfo?.sn,
port: deviceInfo.port, port: deviceInfo.port,
slave_addr: 'root', slave_addr: 'root',
type: deviceInfo?.type ?? 'emu', type: deviceInfo?.type ?? 'emu',
@ -81,7 +82,7 @@ const plugins: PluginOptions = [
enable: (e: any) => e.targetType === 'node', enable: (e: any) => e.targetType === 'node',
getContent: (e: any, items: any) => { getContent: (e: any, items: any) => {
console.log(items) console.log(items)
return `<div>节点: ${items[0].data.name}</div>`; return `<div>${items[0].data.cnName}</div>`;
}, },
}, },
] ]
@ -102,6 +103,7 @@ function init() {
function onDetail(value: string, item: HTMLElement, current: any) { function onDetail(value: string, item: HTMLElement, current: any) {
const nodeData = current.config.context.model.getNodeData(current.config.id) const nodeData = current.config.context.model.getNodeData(current.config.id)
console.log(nodeData[nodeData.length - 1].data)
const device = deviceInfo as unknown as IDevice & { const device = deviceInfo as unknown as IDevice & {
isonLine: boolean isonLine: boolean
siteName: string siteName: string
@ -117,10 +119,14 @@ onMounted(async () => {
function filterTree(node: IPointGroupOV) { function filterTree(node: IPointGroupOV) {
if (node.type === 'bms_cluster' && Array.isArray(node.children)) { if (node.type === 'bms_cluster' && Array.isArray(node.children)) {
if (node.children.length > 2) { if (node.children.length > 1) {
const customNode = node.children[node.children.length - 1] as any const customNode = node.children[0] as any
customNode.name = `${node.children[0].name} ~ ${node.children[node.children.length - 2].name}` node.children.forEach(r => {
r.customCnName = r.cnName
})
customNode.cnName = `${node.children[0].cnName} ~ ${node.children[node.children.length - 1].cnName}`
customNode.customNode = true customNode.customNode = true
customNode.brother = node.children
node.children = [customNode] node.children = [customNode]
} }
} }

2
src/views/stationData/transfer/components/PointGroupTree.vue

@ -64,7 +64,7 @@ const handleNodeClick = (data: IPointGroupOV) => {
const defaultProps = { const defaultProps = {
children: 'children', children: 'children',
label: 'name', label: 'cnName',
} }
function changePoints() { function changePoints() {

51
src/views/stationData/transfer/components/deviceDrawer.vue

@ -33,7 +33,22 @@
</div> </div>
</div> </div>
</div> </div>
<el-button class="mb-4" type="primary" @click="loadChardData">查询数据</el-button> <div class="flex w-full items-center gap-16">
<div class="w-400px">
<el-date-picker
v-model="time"
type="datetimerange"
value-format="YYYY-MM-DD HH:mm:ss"
range-separator="到"
:default-value="getBeforeMonth"
start-placeholder="开始时间"
end-placeholder="结束时间"
:disabled-date="disabledDate"
/>
</div>
<el-button type="primary" @click="loadChardData">查询数据</el-button>
</div>
<NewDataChart v-if="isShowChart" :chart-datas="chartData" :legends="legends" <NewDataChart v-if="isShowChart" :chart-datas="chartData" :legends="legends"
:axis-data="Array.from(axisData)" ref="chartRef"/> :axis-data="Array.from(axisData)" ref="chartRef"/>
</div> </div>
@ -61,6 +76,8 @@ import dayjs from 'dayjs'
import { nextTick } from "vue"; import { nextTick } from "vue";
import EdfsWrap from "@/components/Edfs-wrap.vue"; import EdfsWrap from "@/components/Edfs-wrap.vue";
const time = ref<[string, string]>()
const env = import.meta.env const env = import.meta.env
@ -160,6 +177,10 @@ const chartOffset = ref(0)
const progress = ref(0) const progress = ref(0)
async function loadChardData() { async function loadChardData() {
if (!time.value || time.value.length !== 2) {
message.error('请选择时间范围')
return
}
if (!columParams.value.filter(i => i !== 'ts').length) { if (!columParams.value.filter(i => i !== 'ts').length) {
message.error('请选择点位') message.error('请选择点位')
return return
@ -167,11 +188,17 @@ async function loadChardData() {
clearData() clearData()
const limit = chartLimit.value const limit = chartLimit.value
const offset = chartOffset.value const offset = chartOffset.value
const options = { const options:any = {
columns: columParams.value, columns: columParams.value,
isLocal: !props.isTransfer, isLocal: !props.isTransfer,
host: props.isTransfer ? (curDevice.value as IOnlineDevice).clientIp : '', host: props.isTransfer ? (curDevice.value as IOnlineDevice).clientIp : '',
name: curGroupName.value as string, name: curGroupName.value as string,
startTime: time.value[0],
endTime: time.value[1],
}
if (env.VITE_APP_ENV !== 'local' || !props.isTransfer) {
options.site_id = props.siteInfo!.name || ''
options.device_id = curDevice.value?.sn || ''
} }
const params: IGetDeviceDataParams = { const params: IGetDeviceDataParams = {
@ -180,13 +207,8 @@ async function loadChardData() {
offset offset
} }
if (env.VITE_APP_ENV !== 'local' || !props.isTransfer) {
params.site_id = props.siteInfo!.name || ''
params.device_id = curDevice.value?.sn || ''
}
loadingChart.value = true loadingChart.value = true
isShowChart.value = false isShowChart.value = false
const res = await getDeviceDetails(params) const res = await getDeviceDetails(params)
if (res.code !== 0) { if (res.code !== 0) {
@ -355,6 +377,21 @@ function onchangePoints(checkPoints: IMyPoint[]) {
checkPointList.value = checkPoints checkPointList.value = checkPoints
} }
const disabledDate = (time: any) => {
const current = dayjs(time)
if (props.isTransfer) return current.isAfter(dayjs(), 'day')
try {
const deviceOff = curDevice.value as IOfflineDevice
const start = dayjs(deviceOff.start_time).format('YYYY-MM-DD')
const end = dayjs(deviceOff.end_time).format('YYYY-MM-DD')
return current.isBefore(start, 'day') || current.isAfter(end, 'day')
} catch (e) {
console.log('disableDate error', e)
return current.isAfter(dayjs(), 'day')
}
}
const getBeforeMonth = dayjs().startOf('month').subtract(1, 'month').startOf('month').toDate()
defineExpose({ defineExpose({
open, open,
openFullScreen, openFullScreen,

8
src/views/stationData/transfer/index.vue

@ -104,7 +104,7 @@
</template> </template>
<template v-else> <template v-else>
<template v-for="key in Object.keys(offlineDeviceMap)"> <template v-for="key in Object.keys(offlineDeviceMap)">
<div class="info-item" v-if="key === 'create_time'"> <div class="info-item" v-if="['create_time','end_time','start_time'].includes(key)">
<div> <div>
{{ offlineDeviceMap[key as keyof typeof offlineDeviceMap] }}: {{ offlineDeviceMap[key as keyof typeof offlineDeviceMap] }}:
</div> </div>
@ -204,12 +204,14 @@ const onlineDeviceMap: Record<
footprint: '数据占用空间', footprint: '数据占用空间',
} }
const offlineDeviceMap: Record< const offlineDeviceMap: Record<
keyof Pick<IOfflineDevice, 'site_id' | 'db' | 'create_time'>, keyof Pick<IOfflineDevice, 'site_id' | 'db' | 'create_time' | 'start_time' | 'end_time'>,
string string
> = { > = {
site_id: '站点名称', site_id: '站点名称',
db: '数据库', db: '数据库',
create_time: '创建时间', create_time: '创建时间',
start_time: '数据启始时间',
end_time: '数据结束时间',
} }
const checkDeviceList = ref<string[]>([]) const checkDeviceList = ref<string[]>([])
@ -463,7 +465,7 @@ function onOffDeviceTransfer() {
} }
.device-item { .device-item {
@apply w-289 h-160 border border-solid border-[#E0E0E0] rounded-8px p-x-14 p-y-10 flex-col; @apply w-292 border border-solid border-[#E0E0E0] rounded-8px p-x-14 p-y-10 flex-col;
.device-item-header { .device-item-header {
@apply w-full text-black text-18px font-500 flex items-center justify-between; @apply w-full text-black text-18px font-500 flex items-center justify-between;

2
src/views/stationData/type.ts

@ -21,6 +21,8 @@ export interface IOfflineDevice {
site_id: string site_id: string
status: number status: number
type: string type: string
start_time: string
end_time: string
} }
export type IDevice = IOnlineDevice | IOfflineDevice export type IDevice = IOnlineDevice | IOfflineDevice

6
src/views/taskList/index.vue

@ -89,10 +89,10 @@ const taskMode = [{
const tableCol = [ const tableCol = [
{ label: '任务ID', prop: 'id', minWidth: '10%' }, { label: '任务ID', prop: 'id', minWidth: '10%' },
{ label: '站点', prop: 'site', minWidth: '16%' }, { label: '站点', prop: 'site', minWidth: '10%' },
{ label: '任务类型', prop: 'mode', minWidth: '10%' }, { label: '任务类型', prop: 'mode', minWidth: '8%' },
{ label: '任务状态', prop: 'status', minWidth: '10%' }, { label: '任务状态', prop: 'status', minWidth: '10%' },
{ label: '创建时间', prop: 'startTime', minWidth: '10%' }, { label: '创建时间', prop: 'startTime', minWidth: '12%' },
{ label: '任务详情', prop: 'info', minWidth: '20%' }, { label: '任务详情', prop: 'info', minWidth: '20%' },
] ]

Loading…
Cancel
Save