修改 测试bug

This commit is contained in:
GGJ
2024-09-24 10:19:54 +08:00
parent d1605fb37b
commit 0f95f3ebd3
6 changed files with 165 additions and 192 deletions

View File

@@ -1,12 +1,14 @@
<template>
<div style="width: 600px">
<el-select v-model="interval" style="min-width: 90px; width: 90px; margin-right: 10px" @change="timeChange">
<el-option v-for="item in timeOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
<el-date-picker
v-model="timeValue"
type="daterange"
:disabled="disabledPicker"
style="width: 230px; margin-right: 10px"
style="width: 220px; margin-right: 10px"
unlink-panels
:clearable="false"
range-separator=""
@@ -18,11 +20,22 @@
<el-button :disabled="backDisabled" type="primary" :icon="DArrowLeft" @click="preClick"></el-button>
<el-button type="primary" :icon="VideoPause" @click="nowTime">当前</el-button>
<el-button :disabled="preDisabled" type="primary" :icon="DArrowRight" @click="next"></el-button>
</div>
</template>
<script lang="ts" setup>
import { DArrowLeft, VideoPause, DArrowRight } from '@element-plus/icons-vue'
import { ref, onMounted, nextTick } from 'vue'
import { ref, onMounted, nextTick, watch } from 'vue'
interface Props {
nextFlag?: boolean
theCurrentTime: boolean
}
const props = withDefaults(defineProps<Props>(), {
nextFlag: false,
theCurrentTime: false
})
const interval = ref(3)
const timeFlag = ref(1)
@@ -110,6 +123,7 @@ const timeChange = (e: number) => {
// 当前
const nowTime = () => {
console.log(interval.value, '000000000')
timeChange(interval.value)
}
// 上一个
@@ -140,7 +154,6 @@ const preClick = () => {
//按周
} else if (interval.value == 4) {
//根据开始时间推
let start = new Date(year, month - 1, date)
start.setDate(start.getDate() - 7)
startTime = formatTime(start)
@@ -177,7 +190,6 @@ const preClick = () => {
//下一个
const next = () => {
//向后
let startTime = timeValue.value[0]
let endTime = timeValue.value[1]
let year = parseInt(startTime.substring(0, 4))
@@ -193,8 +205,9 @@ const next = () => {
if (interval.value == 3) {
if (month == 12) {
year = year + 1
// 年份进位后,大于当前的年份,是不科学的
if (presentY < year) {
if (presentY < year && !props.nextFlag) {
startTime = presentY + '-12-01'
if (presentD < 10) {
endTime = presentY + '-12' + '-0' + presentD
@@ -223,7 +236,7 @@ const next = () => {
// 年份等于当前年份
if (presentY == year) {
// 月份超过当前月份,是不科学的
if (month >= presentM) {
if (month >= presentM && !props.nextFlag) {
if (presentM < 10) {
startTime = year + '-0' + presentM + '-01'
if (presentD < 10) {
@@ -268,7 +281,7 @@ const next = () => {
if (month == 10) {
year = year + 1
// 年份进位后大于当前年份是不科学的
if (year > presentY) {
if (year > presentY && !props.nextFlag) {
startTime = presentY + '-10-01'
if (presentD < 10) {
endTime = year + '-' + presentM + '-0' + presentD
@@ -294,8 +307,10 @@ const next = () => {
}
} else {
month = month + 3
console.log('🚀 ~ next ~ presentM:', presentM, month)
// 季度进位后,超过当前月份是不科学的
if (year == presentY) {
if (year == presentY && !props.nextFlag) {
if (month >= presentM) {
// 当季度进位后大于当前月,以当前月的时间显示季度
if (presentM > 0 && presentM < 4) {
@@ -307,6 +322,7 @@ const next = () => {
endTime = year + '-0' + presentM + '-' + presentD
}
} else if (presentM > 3 && presentM < 7) {
console.log(123123)
// 第二季度
startTime = year + '-04-01'
if (presentD < 10) {
@@ -342,7 +358,7 @@ const next = () => {
endTime = NowgetEndTime()
} else {
var day = getDays(year, month)
endTime = year + '-' + month + '-' + day
endTime = year + '-0' + month + '-' + day
}
}
} else {
@@ -359,6 +375,7 @@ const next = () => {
}
}
}
console.log(startTime, endTime)
} else if (interval.value == 5) {
} else if (interval.value == 4) {
//根据开始时间推
@@ -371,7 +388,7 @@ const next = () => {
} else {
year = year + 1
// 年份进位后大于当前年份,是不科学的
if (year >= presentY) {
if (year >= presentY && !props.nextFlag) {
startTime = presentY + '-01-01'
if (presentM < 10) {
if (presentD < 10) {
@@ -395,7 +412,8 @@ const setTime = (flag = 0, e = 0) => {
let dd = window.XEUtils.toDateString(new Date().getTime() - e * 3600 * 1000 * 24, 'dd')
let data = ''
if (dd < 4 || dd == 0) {
if ((dd < 4 || dd == 0) && interval.value != 4 && !props.theCurrentTime) {
data = window.XEUtils.toDateString(new Date().getTime() - (e + dd) * 3600 * 1000 * 24, 'yyyy-MM-dd')
} else {
data = window.XEUtils.toDateString(new Date().getTime() - e * 3600 * 1000 * 24, 'yyyy-MM-dd')
@@ -496,7 +514,7 @@ function formatDate(date: Date): string {
const day = String(date.getDate()).padStart(2, '0')
return `${year}-${month}-${day}`
}
defineExpose({ timeValue, interval, timeFlag, setTimeOptions, setInterval, getYearOnYear, getMonthOnMonth,timeChange })
defineExpose({ timeValue, interval, timeFlag, setTimeOptions, setInterval, getYearOnYear, getMonthOnMonth, timeChange })
</script>
<style scoped>

View File

@@ -2,22 +2,23 @@
<div ref="tableHeader" class="cn-table-header">
<div class="table-header ba-scroll-style">
<el-form
style="flex: 1; height: 32px; margin-right: 20px"
style="flex: 1; height: 34px; margin-right: 20px; display: flex; flex-wrap: wrap"
ref="headerForm"
@submit.prevent=""
@keyup.enter="onComSearch"
label-position="left"
:inline="true"
>
<el-form-item label="日期" v-if="datePicker" style="grid-column: span 2; max-width: 570px">
<DatePicker ref="datePickerRef" :nextFlag="nextFlag" :theCurrentTime="theCurrentTime"></DatePicker>
</el-form-item>
<el-form-item label="区域" v-if="area">
<Area ref="areaRef" v-model="tableStore.table.params.deptIndex" />
</el-form-item>
<el-form-item label="日期" v-if="datePicker" style="grid-column: span 2; max-width: unset">
<DatePicker ref="datePickerRef"></DatePicker>
</el-form-item>
<slot name="select"></slot>
</el-form>
<template v-if="$slots.select || datePicker">
<template v-if="$slots.select || datePicker || showSearch">
<el-button type="primary" @click="showSelectChange" v-if="showUnfoldButton">
<Icon size="14" name="el-icon-ArrowUp" style="color: #fff" v-if="showSelect" />
<Icon size="14" name="el-icon-ArrowDown" style="color: #fff" v-else />
@@ -46,6 +47,7 @@ import Area from '@/components/form/area/index.vue'
import { mainHeight } from '@/utils/layout'
import { useDictData } from '@/stores/dictData'
import { Search, RefreshLeft } from '@element-plus/icons-vue'
import { defineProps } from 'vue'
const tableStore = inject('tableStore') as TableStore
const tableHeader = ref()
@@ -59,12 +61,16 @@ interface Props {
datePicker?: boolean
area?: boolean
showSearch?: boolean
nextFlag?: boolean //控制时间是否可以往后推
theCurrentTime?: boolean //控制时间前3天展示上个月时间
}
const props = withDefaults(defineProps<Props>(), {
datePicker: false,
area: false,
showSearch: true
showSearch: true,
nextFlag: false,
theCurrentTime: false
})
// 动态计算table高度
const resizeObserver = new ResizeObserver(entries => {
@@ -151,19 +157,19 @@ const onComSearch = async () => {
await tableStore.onTableAction('search', {})
}
const onResetForm = () => {
//时间重置成默认值
datePickerRef.value?.timeChange(3)
tableStore.onTableAction('reset', {})
}
const setDatePicker = (list: any) => {
datePickerRef.value.setTimeOptions(list)
}
const onResetForm = () => {
//时间重置成默认值
datePickerRef.value?.setInterval(3)
tableStore.onTableAction('reset', {})
}
const setInterval = (val: any) => {
datePickerRef.value.setInterval(val)
}
defineExpose({ onComSearch, areaRef, setDatePicker, setInterval, datePickerRef })
defineExpose({ onComSearch, areaRef, setDatePicker, setInterval, datePickerRef, showSelectChange})
</script>
<style scoped lang="scss">

View File

@@ -5,17 +5,18 @@ import { Method } from 'axios'
import { mainHeight } from '@/utils/layout'
interface TableStoreParams {
url: string
url: string // 请求地址
pk?: string
column: TableColumn[]
params?: anyObj
method?: Method
method?: Method // 请求方式
isWebPaging?: boolean // 是否前端分页
showPage?: boolean
publicHeight?: number
resetCallback?: () => void
loadCallback?: () => void
beforeSearchFun?: () => void
showPage?: boolean //是否需要分页
paramsPOST?: boolean // post请求 params传参
publicHeight?: number //计算高度
resetCallback?: () => void // 重置
loadCallback?: () => void // 接口调用后的回调
beforeSearchFun?: () => void // 接口调用前的回调
}
export default class TableStore {
@@ -24,6 +25,7 @@ export default class TableStore {
public method: Method
public initData: any = null
public isWebPaging = false
public paramsPOST = true
public showPage = true
public table: CnTable = reactive({
ref: null,
@@ -47,6 +49,7 @@ export default class TableStore {
constructor(public options: TableStoreParams) {
this.url = options.url
this.pk = options.pk || 'id'
this.paramsPOST = options.paramsPOST || false
this.isWebPaging = options.isWebPaging || false
this.method = options.method || 'GET'
this.table.column = options.column
@@ -73,12 +76,12 @@ export default class TableStore {
url: this.url,
method: this.method
},
requestPayload(this.method, this.table.params)
requestPayload(this.method, this.table.params, this.paramsPOST)
)
).then((res: any) => {
if (res.data) {
this.table.data = res.data.records || res.data
this.table.total = res.data.total || res.data.length || 0
this.table.total = res.data?.total || res.data.length || 0
} else {
this.table.data = []
this.table.total = 0

View File

@@ -20,12 +20,8 @@
</el-form-item>
<el-form-item label="数据类型" label-width="80px">
<el-select v-model="form.statMethod" placeholder="请选择值类型">
<el-option
v-for="item in typeOptions"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
<el-option v-for="item in typeOptions" :key="item.id" :label="item.name"
:value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item>
@@ -115,12 +111,7 @@ const init = () => {
dataLevel: form.dataLevel,
statMethod: form.statMethod
}).then(res => {
console.log(
123,
res.data.map((item: any[]) => {
return item[0].anotherName
})
)
if (res.data.length && res.data[0].length) {
let arr: any[] = []
@@ -187,20 +178,20 @@ const init = () => {
})
},
yAxis: {
name: `单位:(${arr[0].unit})`,
name: `单位:(${arr[0].unit == null ? ' / ' : arr[0].unit})`,
type: 'value',
axisLine: {
show: true
},
minInterval: 0.1,
min: parseFloat(
min: (
arr
.map(item => item.statisticalData)
.map((item: any) => item.statisticalData)
.sort((a, b) => {
return a - b
})[0] / 1.5
).toFixed(0),
max: parseFloat(
})[0] / 1.2
).toFixed(1),
max: (
arr
.map(item => item.statisticalData)
.sort((a, b) => {
@@ -239,6 +230,7 @@ defineExpose({ open })
display: flex;
flex-direction: column;
}
.el-form--inline .el-form-item {
margin-bottom: 10px !important;
}

View File

@@ -1,10 +1,6 @@
<template>
<div
class="default-main device-control"
:style="{ height: pageHeight.height }"
v-loading="loading"
style="position: relative"
>
<div class="default-main device-control" :style="{ height: pageHeight.height }" v-loading="loading"
style="position: relative">
<PointTree @node-click="nodeClick" @init="nodeClick" @pointTypeChange="pointTypeChange"></PointTree>
<div class="device-control-right" v-if="deviceData">
<el-descriptions title="设备基本信息" class="mb10" :column="3" border>
@@ -43,13 +39,8 @@
</el-descriptions-item>
</el-descriptions>
<el-tabs v-model="dataSet" type="border-card" class="device-control-box-card" @tab-click="handleClick">
<el-tab-pane
lazy
:label="item.name"
:name="item.id"
v-for="(item, index) in deviceData.dataSetList"
:key="index"
>
<el-tab-pane lazy :label="item.name" :name="item.id" v-for="(item, index) in deviceData.dataSetList"
:key="index">
<template #label>
<span class="custom-tabs-label">
<el-icon>
@@ -58,47 +49,35 @@
<DataAnalysis v-if="item.name.includes('趋势数据')" />
<Timer v-if="item.name.includes('实时数据')" />
<Monitor v-if="item.name.includes('暂态事件')" />
<Odometer
v-if="
<Odometer v-if="
item.name != 'APF模块数据' &&
item.name != '历史APF模块数据' &&
!item.name.includes('历史监测') &&
!item.name.includes('趋势数据') &&
!item.name.includes('实时数据') &&
!item.name.includes('暂态事件')
"
/>
<Histogram
v-if="
" />
<Histogram v-if="
item.name != 'APF模块数据' &&
item.name != '历史APF模块数据' &&
item.name.includes('历史监测') &&
!item.name.includes('趋势数据') &&
!item.name.includes('实时数据') &&
!item.name.includes('暂态事件')
"
/>
" />
</el-icon>
<span>{{ item.name }}</span>
</span>
</template>
</el-tab-pane>
<el-form
:inline="true"
style="white-space: nowrap; margin-top: 10px"
v-if="
<el-form :inline="true" style="white-space: nowrap; margin-top: 10px" v-if="
dataSet.indexOf('_trenddata') == -1 &&
dataSet.indexOf('_realtimedata') == -1 &&
dataSet.indexOf('_event') == -1
"
>
">
<el-form-item label="指标">
<el-input
v-model="formInline.searchValue"
autocomplete="off"
clearable
placeholder="请输入关键词"
></el-input>
<el-input style="width: 240px" v-model="formInline.searchValue" autocomplete="off" clearable
placeholder="请输入关键词"></el-input>
</el-form-item>
<el-form-item label="日期" v-show="dataSet.indexOf('_history') != -1">
<DatePicker ref="datePickerRef"></DatePicker>
@@ -113,38 +92,26 @@
<el-button type="primary" icon="el-icon-Search" @click="handleClick">查询</el-button>
</el-form-item>
</el-form>
<div
style="height: calc(100vh - 300px)"
v-if="
<div style="height: calc(100vh - 300px)" v-if="
dataSet.indexOf('_trenddata') == -1 &&
dataSet.indexOf('_realtimedata') == -1 &&
dataSet.indexOf('_event') == -1 &&
tableData.length == 0
"
v-loading="tableLoading"
></div>
<div
style="overflow: auto"
:style="{ height: tableHeight }"
v-if="
" v-loading="tableLoading"></div>
<div style="overflow: auto" :style="{ height: tableHeight }" v-if="
dataSet.indexOf('_trenddata') == -1 &&
dataSet.indexOf('_realtimedata') == -1 &&
dataSet.indexOf('_event') == -1 &&
tableData.length != 0
"
>
">
<!-- 循环渲染的card 最新数据/历史数据显示 -->
<div class="content">
<el-card class="box-card" v-for="(item, index) in tableData" :key="index">
<template #header>
<div class="clearfix">
<span style="flex: 1">{{ item.name }}</span>
<Icon
name="el-icon-TrendCharts"
class="ml10"
@click="getDeviceDataTrend(item)"
style="font-size: 26px; cursor: pointer; color: #fff"
></Icon>
<Icon name="el-icon-TrendCharts" class="ml10" @click="getDeviceDataTrend(item)"
style="font-size: 26px; cursor: pointer; color: #fff"></Icon>
</div>
</template>
<!-- 模块数据 -->
@@ -159,12 +126,8 @@
</div>
<div v-else-if="item.children.length">
<div style="display: flex; align-items: center">
<el-tag
effect="dark"
type="danger"
style="width: 40px; text-align: center"
class="mr10"
>
<el-tag effect="dark" type="danger" style="width: 40px; text-align: center"
class="mr10">
MAX
</el-tag>
{{
@@ -175,12 +138,8 @@
}}
</div>
<div style="display: flex; align-items: center" class="mt10">
<el-tag
effect="dark"
type="success"
style="width: 40px; text-align: center"
class="mr10"
>
<el-tag effect="dark" type="success" style="width: 40px; text-align: center"
class="mr10">
AVG
</el-tag>
{{
@@ -191,12 +150,8 @@
}}
</div>
<div style="display: flex; align-items: center" class="mt10">
<el-tag
effect="dark"
type="warning"
style="width: 40px; text-align: center"
class="mr10"
>
<el-tag effect="dark" type="warning" style="width: 40px; text-align: center"
class="mr10">
MIN
</el-tag>
{{
@@ -211,24 +166,15 @@
<el-empty description="暂无数据" v-if="tableData.length === 0"></el-empty>
</div>
</div>
<el-pagination
v-if="
<el-pagination v-if="
tableData.length &&
dataSet.indexOf('_trenddata') == -1 &&
dataSet.indexOf('_realtimedata') == -1 &&
dataSet.indexOf('_event') == -1
"
background
class="mr2 mt10"
style="float: right"
@size-change="handleSizeChange"
@current-change="pageChange"
:current-page="formInline.pageNum"
:page-sizes="[20, 30, 40, 50, 100]"
:page-size="formInline.pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="formInline.total"
></el-pagination>
" background class="mr2 mt10" style="float: right" @size-change="handleSizeChange"
@current-change="pageChange" :current-page="formInline.pageNum" :page-sizes="[20, 30, 40, 50, 100]"
:page-size="formInline.pageSize" layout="total, sizes, prev, pager, next, jumper"
:total="formInline.total"></el-pagination>
<!-- 趋势数据 -->
<div style="height: calc(100vh - 200px)" v-show="dataSet.indexOf('_trenddata') != -1">
@@ -257,10 +203,8 @@
<!-- 实时数据-实时趋势组件 -->
<realTrend v-show="!realTimeFlag && sonTab == 1" ref="realTrendRef"></realTrend>
<!-- 实时数据-谐波频谱组件 -->
<harmonicSpectrum
v-show="!realTimeFlag && sonTab == 2"
ref="harmonicSpectrumRef"
></harmonicSpectrum>
<harmonicSpectrum v-show="!realTimeFlag && sonTab == 2" ref="harmonicSpectrumRef">
</harmonicSpectrum>
</div>
<!-- 暂态事件 -->
<div style="height: calc(100vh - 200px)" v-show="dataSet.indexOf('_event') != -1">
@@ -402,6 +346,7 @@ const deviceId: any = ref('')
const lineId: any = ref('')
const dataLevel: any = ref('')
const nodeClick = async (e: anyObj) => {
deviceId.value = e?.pid
lineId.value = e?.id
if (!e) {
@@ -473,12 +418,14 @@ const eventRef: any = ref()
const timer: any = ref()
//tab点击事件
const handleClick = async (tab?: any) => {
//点击tab时更新dataSet最新值
if (tab && tab.props && tab.props.name && dataSet.value != tab.props.name) {
dataSet.value = tab.props.name
}
tableLoading.value = true
loading.value = true
//初始化点击tab隐藏实时录波、实时趋势、谐波频谱按钮
realTimeFlag.value = false
//初始化点击tab隐藏子页面
@@ -501,6 +448,7 @@ const handleClick = async (tab?: any) => {
tableData.value = res.data.records
formInline.total = res.data.total
tableLoading.value = false
loading.value = false
})
}
//查询趋势数据
@@ -557,13 +505,14 @@ const handleClick = async (tab?: any) => {
tableData.value = res.data.records
formInline.total = res.data.total
tableLoading.value = false
loading.value = false
})
}
// }, 100)
}
//模版下载
const handleDownLoadTemplate = () => {}
const handleDownLoadTemplate = () => { }
//解析列表
const analysisListRef = ref()
//打开解析列表
@@ -624,7 +573,7 @@ const openGroup = () => {
})
})
}
onMounted(() => {})
onMounted(() => { })
</script>
<style lang="scss">
@@ -635,12 +584,14 @@ onMounted(() => {})
overflow: hidden;
flex: 1;
padding: 10px 10px 10px 0;
.el-descriptions__header {
height: 36px;
margin-bottom: 7px;
display: flex;
align-items: center;
}
.content {
box-sizing: border-box;
overflow: auto;
@@ -660,6 +611,7 @@ onMounted(() => {})
.el-card__header {
padding: 0;
.clearfix {
box-sizing: border-box;
display: flex;
@@ -676,6 +628,7 @@ onMounted(() => {})
padding: 10px;
margin-bottom: 0;
background-image: linear-gradient(var(--el-color-primary), var(--el-color-primary-light-3));
.box-card-content {
height: 100%;
display: flex;
@@ -695,10 +648,12 @@ onMounted(() => {})
align-items: center;
justify-content: flex-end;
}
.custom-tabs-label {
display: flex;
align-items: center;
justify-content: space-between;
.el-icon {
margin-right: 5px;
}

View File

@@ -9,7 +9,6 @@
type="primary"
icon="el-icon-Share"
@click="openGroup"
size="small"
:loading="getGroupLoading"
>
设备模版分组
@@ -93,7 +92,7 @@ const dataSet = ref('')
const devTypeOptions = ref([])
const devModelOptions = ref([])
const tableData = ref([])
const tableHeight = mainHeight(235).height
const tableHeight = mainHeight(260).height
const mangePopup = ref()
const activeName = ref(0)
// 树节点点击